fix(chat): sync subagent prompting in context panel

This commit is contained in:
Bohdan Triapitsyn
2026-07-13 01:21:18 +03:00
parent 7e12a0dcef
commit 08e4ce5b99
3 changed files with 69 additions and 3 deletions
@@ -586,7 +586,40 @@ export const ChatContainer: React.FC<ChatContainerProps> = ({ autoOpenDraft = tr
{t('chat.container.returnToParent.label')}
</Button>
) : null;
const promptReadOnly = readOnly || (Boolean(parentSession) && !allowPromptingSubagentSessions);
const promptReadOnly = parentSession ? !allowPromptingSubagentSessions : readOnly;
React.useEffect(() => {
if (typeof window === 'undefined' || window.parent === window) {
return;
}
const applySetting = (value: boolean) => {
useUIStore.getState().setAllowPromptingSubagentSessions(value);
};
const scopedWindow = window as typeof window & {
__openchamberApplyChatSettingsSync?: (payload: { allowPromptingSubagentSessions: boolean }) => void;
};
const applySync = (payload: { allowPromptingSubagentSessions: boolean }) => {
applySetting(payload.allowPromptingSubagentSessions);
};
const handleMessage = (event: MessageEvent) => {
if (event.source !== window.parent || event.origin !== window.location.origin) return;
const data = event.data as { type?: unknown; payload?: { allowPromptingSubagentSessions?: unknown } };
if (data?.type !== 'openchamber:chat-settings-sync'
|| typeof data.payload?.allowPromptingSubagentSessions !== 'boolean') return;
applySetting(data.payload.allowPromptingSubagentSessions);
};
scopedWindow.__openchamberApplyChatSettingsSync = applySync;
window.addEventListener('message', handleMessage);
window.parent.postMessage({ type: 'openchamber:chat-settings-request' }, window.location.origin);
return () => {
window.removeEventListener('message', handleMessage);
if (scopedWindow.__openchamberApplyChatSettingsSync === applySync) {
delete scopedWindow.__openchamberApplyChatSettingsSync;
}
};
}, []);
React.useEffect(() => {
if (autoOpenDraft && !currentSessionId && !draftOpen) {
@@ -1017,6 +1017,7 @@ const ChatMessage: React.FC<ChatMessageProps> = ({
isUser={isUser}
isMessageCompleted={isMessageCompleted}
messageFinish={messageFinish}
messageCreatedAt={messageCreatedAt ?? undefined}
isMobile={isMobile}
alwaysShowActions={alwaysShowMessageActions}
hasTouchInput={hasTouchInput}
@@ -1050,6 +1051,7 @@ const ChatMessage: React.FC<ChatMessageProps> = ({
isUser={isUser}
isMessageCompleted={isMessageCompleted}
messageFinish={messageFinish}
messageCreatedAt={messageCreatedAt ?? undefined}
isMobile={isMobile}
alwaysShowActions={alwaysShowMessageActions}
hasTouchInput={hasTouchInput}