Skip to content
Open
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
38 changes: 37 additions & 1 deletion apps/web/src/components/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2929,6 +2929,39 @@ function ChatViewContent(props: ChatViewProps) {
},
[activeThreadRef, diffOpen, dismissPlanSidebarForCurrentTurn, onDiffPanelOpen, planSidebarOpen],
);
// Returns false when the right panel is closed so terminal.toggle falls back to the drawer.
const toggleTerminalInRightPanel = useCallback(() => {
if (!activeThreadRef) return false;
const store = useRightPanelStore.getState();
const panelState = selectThreadRightPanelState(store.byThreadKey, activeThreadRef);
if (!panelState.isOpen) return false;
const activeSurface = panelState.surfaces.find(
(surface) => surface.id === panelState.activeSurfaceId,
);
if (activeSurface?.kind === "terminal") {
setMaximizedRightPanelThreadKey(null);
store.close(activeThreadRef);
return true;
}
const terminalSurface = panelState.surfaces.find((surface) => surface.kind === "terminal");
if (terminalSurface) {
activateRightPanelSurface(terminalSurface);
return true;
}
if (!activeThreadId || !activeProject) return false;
if (activeSurface?.kind === "plan") {
dismissPlanSidebarForCurrentTurn();
}
addTerminalSurface();
return true;
Comment thread
cursor[bot] marked this conversation as resolved.
}, [
activeProject,
activeThreadId,
activeThreadRef,
activateRightPanelSurface,
addTerminalSurface,
dismissPlanSidebarForCurrentTurn,
]);
const toggleRightPanel = useCallback(() => {
if (!activeThreadRef) return;
if (rightPanelOpen) {
Expand Down Expand Up @@ -3725,7 +3758,9 @@ function ChatViewContent(props: ChatViewProps) {
if (command === "terminal.toggle") {
event.preventDefault();
event.stopPropagation();
toggleTerminalVisibility();
if (terminalFocusOwner === "drawer" || !toggleTerminalInRightPanel()) {
toggleTerminalVisibility();
Comment thread
cursor[bot] marked this conversation as resolved.
}
return;
}

Expand Down Expand Up @@ -3838,6 +3873,7 @@ function ChatViewContent(props: ChatViewProps) {
keybindings,
onToggleDiff,
toggleRightPanel,
toggleTerminalInRightPanel,
toggleThreadPanel,
toggleTerminalVisibility,
composerRef,
Expand Down
Loading