fix: bootstrap embedded chat prompting state and review read-only handling
Pass initial subagent prompting settings into embedded chat URLs and views Prevent inactive embedded chats from stealing focus on load Treat review sessions as independent conversations when resolving prompt read-only state
This commit is contained in:
@@ -2528,8 +2528,8 @@ export const ContextPanel: React.FC = () => {
|
||||
lightThemeId,
|
||||
darkThemeId,
|
||||
currentTheme,
|
||||
});
|
||||
}, [currentTheme, darkThemeId, directoryKey, lightThemeId, themeMode]);
|
||||
}, { allowPromptingSubagentSessions });
|
||||
}, [allowPromptingSubagentSessions, currentTheme, darkThemeId, directoryKey, lightThemeId, themeMode]);
|
||||
|
||||
const activeChatSrc = activeChatTab && activeChatSessionID
|
||||
? getEmbeddedChatSrc(activeChatTab.id, activeChatSessionID, activeChatTab.readOnly)
|
||||
|
||||
@@ -128,6 +128,17 @@ describe('embedded session chat URL', () => {
|
||||
expect(new URL(second).searchParams.get('themeVariant')).toBe('dark');
|
||||
});
|
||||
|
||||
test('bootstraps subagent prompting before the embedded chat first renders', () => {
|
||||
const src = buildEmbeddedSessionChatURL('ses_1', '/repo', false, {
|
||||
mode: 'system',
|
||||
lightThemeId: 'light-a',
|
||||
darkThemeId: 'dark-a',
|
||||
currentTheme: makeTheme('dark-a', 'dark'),
|
||||
}, { allowPromptingSubagentSessions: true });
|
||||
|
||||
expect(new URL(src).searchParams.get('allowPromptingSubagentSessions')).toBe('1');
|
||||
});
|
||||
|
||||
test('rebuilds cached src when readOnly changes for an existing tab', () => {
|
||||
const cache = new Map<string, EmbeddedSessionChatURLCacheEntry>();
|
||||
const theme = {
|
||||
|
||||
@@ -8,6 +8,10 @@ export type EmbeddedSessionChatThemeBootstrap = {
|
||||
currentTheme: Theme;
|
||||
};
|
||||
|
||||
export type EmbeddedSessionChatSettingsBootstrap = {
|
||||
allowPromptingSubagentSessions: boolean;
|
||||
};
|
||||
|
||||
export type EmbeddedSessionChatURLCacheEntry = {
|
||||
signature: string;
|
||||
src: string;
|
||||
@@ -111,6 +115,7 @@ export const buildEmbeddedSessionChatURL = (
|
||||
directory: string | null,
|
||||
readOnly: boolean,
|
||||
theme: EmbeddedSessionChatThemeBootstrap,
|
||||
settings?: EmbeddedSessionChatSettingsBootstrap,
|
||||
): string => {
|
||||
if (typeof window === 'undefined') {
|
||||
return '';
|
||||
@@ -134,6 +139,9 @@ export const buildEmbeddedSessionChatURL = (
|
||||
url.searchParams.set('lightThemeId', theme.lightThemeId);
|
||||
url.searchParams.set('darkThemeId', theme.darkThemeId);
|
||||
url.searchParams.set('themeVariant', theme.currentTheme.metadata.variant === 'dark' ? 'dark' : 'light');
|
||||
if (settings) {
|
||||
url.searchParams.set('allowPromptingSubagentSessions', settings.allowPromptingSubagentSessions ? '1' : '0');
|
||||
}
|
||||
|
||||
url.hash = '';
|
||||
return url.toString();
|
||||
@@ -146,6 +154,7 @@ export const getOrCreateEmbeddedSessionChatURL = (
|
||||
directory: string | null,
|
||||
readOnly: boolean,
|
||||
theme: EmbeddedSessionChatThemeBootstrap,
|
||||
settings?: EmbeddedSessionChatSettingsBootstrap,
|
||||
): string => {
|
||||
const signature = buildEmbeddedSessionChatURLSignature(sessionID, directory, readOnly);
|
||||
const existing = cache.get(tabID);
|
||||
@@ -153,7 +162,7 @@ export const getOrCreateEmbeddedSessionChatURL = (
|
||||
return existing.src;
|
||||
}
|
||||
|
||||
const src = buildEmbeddedSessionChatURL(sessionID, directory, readOnly, theme);
|
||||
const src = buildEmbeddedSessionChatURL(sessionID, directory, readOnly, theme, settings);
|
||||
cache.set(tabID, { signature, src });
|
||||
return src;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user