Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/web-ui/src/flow_chat/components/ChatInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,28 @@
import { agentAPI } from '@/infrastructure/api/service-api/AgentAPI';
import './ChatInput.scss';

// Module-level popup state – used by ModernFlowChatContainer to conditionally
// disable the Escape shortcut so that slash-command and @-mention popups can be
// closed with Escape.
let _chatPopupActive = false;
const _chatPopupListeners = new Set<() => void>();

export function isChatPopupActive(): boolean {

Check warning on line 77 in src/web-ui/src/flow_chat/components/ChatInput.tsx

View workflow job for this annotation

GitHub Actions / Frontend Build

Fast refresh only works when a file only exports components. Use a new file to share constants or functions between components
return _chatPopupActive;
}

export function subscribeChatPopupChange(listener: () => void): () => void {

Check warning on line 81 in src/web-ui/src/flow_chat/components/ChatInput.tsx

View workflow job for this annotation

GitHub Actions / Frontend Build

Fast refresh only works when a file only exports components. Use a new file to share constants or functions between components
_chatPopupListeners.add(listener);
return () => { _chatPopupListeners.delete(listener); };
}

function setChatPopupActive(active: boolean) {
if (_chatPopupActive !== active) {
_chatPopupActive = active;
_chatPopupListeners.forEach(fn => fn());
}
}

const log = createLogger('ChatInput');

export interface ChatInputProps {
Expand Down Expand Up @@ -819,6 +841,12 @@
selectedIndex: 0,
});

// Keep the module-level popup-active flag in sync so ModernFlowChatContainer
// can disable the global Escape shortcut while popups are open.
useEffect(() => {
setChatPopupActive(slashCommandState.isActive || mentionState.isActive);
}, [slashCommandState.isActive, mentionState.isActive]);

const clearPendingLargePastes = useCallback(() => {
pendingLargePastesRef.current = {};
}, []);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { useFlowChatSearch } from './useFlowChatSearch';
import { useVirtualItems, useActiveSession, useVisibleTurnInfo, type VisibleTurnInfo } from '../../store/modernFlowChatStore';
import type { FlowChatConfig, FlowToolItem, Session, DialogTurn } from '../../types/flow-chat';
import type { LineRange } from '@/component-library';
import { isChatPopupActive, subscribeChatPopupChange } from '../ChatInput';
import { useWorkspaceContext } from '@/infrastructure/contexts/WorkspaceContext';
import { parsePullRequestUrl } from '@/shared/utils/pullRequestLinks';
import { createReviewPlatformPullRequestDetailTab } from '@/shared/utils/tabUtils';
Expand Down Expand Up @@ -171,6 +172,16 @@ export const ModernFlowChatContainer: React.FC<ModernFlowChatContainerProps> = (
const visibleTurnInfo = useVisibleTurnInfo();
const [pendingHeaderTurnId, setPendingHeaderTurnId] = useState<string | null>(null);
const [searchOpenRequest, setSearchOpenRequest] = useState(0);
// Track whether a slash-command or @-mention popup is open in ChatInput.
// When a popup is active, the global Escape shortcut is disabled so the
// popup can be closed with Escape instead of cancelling the current task.
const [chatPopupActive, setChatPopupActive] = useState(() => isChatPopupActive());

useEffect(() => {
return subscribeChatPopupChange(() => {
setChatPopupActive(isChatPopupActive());
});
}, []);
const [backgroundSubagents, setBackgroundSubagents] = useState<BackgroundSubagentSummary[]>([]);
const autoPinnedSessionIdRef = useRef<string | null>(null);
const virtualListRef = useRef<VirtualMessageListRef>(null);
Expand Down Expand Up @@ -474,7 +485,7 @@ export const ModernFlowChatContainer: React.FC<ModernFlowChatContainerProps> = (
() => {
void FlowChatManager.getInstance().cancelCurrentTask();
},
{ priority: 20, description: 'keyboard.shortcuts.chat.stopGeneration' }
{ priority: 20, enabled: !chatPopupActive, description: 'keyboard.shortcuts.chat.stopGeneration' }
);

useShortcut(
Expand Down
1 change: 1 addition & 0 deletions src/web-ui/src/tools/mermaid-editor/theme/mermaidTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export function getThemeType(): 'dark' | 'light' {
if (dataTheme?.includes('light')) return 'light';
if (dataTheme?.includes('dark')) return 'dark';
if (document.documentElement.classList.contains('light')) return 'light';
if (typeof window.matchMedia !== 'function') return 'dark';
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
}

Expand Down
Loading