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:
Bohdan Triapitsyn
2026-08-13 22:01:11 +03:00
parent e99f6560be
commit a9edc71e06
9 changed files with 80 additions and 17 deletions
+13 -2
View File
@@ -106,6 +106,7 @@ type EmbeddedSessionChatConfig = {
sessionId: string;
directory: string | null;
readOnly: boolean;
allowPromptingSubagentSessions?: boolean;
};
type EmbeddedVisibilityPayload = {
@@ -138,6 +139,9 @@ const readEmbeddedSessionChatConfig = (): EmbeddedSessionChatConfig | null => {
sessionId,
directory,
readOnly: params.get('readOnly') === '1' || params.get('readOnly') === 'true',
allowPromptingSubagentSessions: params.has('allowPromptingSubagentSessions')
? params.get('allowPromptingSubagentSessions') === '1'
: undefined,
};
};
@@ -199,7 +203,11 @@ const EmbeddedSessionChatContent: React.FC<{
<>
<SyncAppEffects embeddedBackgroundWorkEnabled={embeddedBackgroundWorkEnabled} />
<OpenCodeUpdateToast />
<ChatView readOnly={embeddedSessionChat.readOnly} />
<ChatView
active={embeddedBackgroundWorkEnabled}
readOnly={embeddedSessionChat.readOnly}
initialAllowPromptingSubagentSessions={embeddedSessionChat.allowPromptingSubagentSessions}
/>
<Toaster />
</>
);
@@ -228,7 +236,10 @@ function App({ apis }: AppProps) {
const [showMemoryDebug, setShowMemoryDebug] = React.useState(false);
const refreshGitHubAuthStatus = useGitHubAuthStore((state) => state.refreshStatus);
const [isVSCodeRuntime, setIsVSCodeRuntime] = React.useState<boolean>(() => apis.runtime.isVSCode);
const [isEmbeddedVisible, setIsEmbeddedVisible] = React.useState(true);
// Embedded chats start inactive until the parent panel identifies the active
// tab. Otherwise a newly loaded background tab can focus its composer first
// and steal keyboard input from the main chat.
const [isEmbeddedVisible, setIsEmbeddedVisible] = React.useState(false);
const [initRetryExhausted, setInitRetryExhausted] = React.useState(false);
const [initRetryEpoch, setInitRetryEpoch] = React.useState(0);
const [runtimeEndpointEpoch, setRuntimeEndpointEpoch] = React.useState(0);