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
33 changes: 12 additions & 21 deletions apps/web/src/components/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3115,7 +3115,7 @@ function ChatViewContent(props: ChatViewProps) {
gitCwd,
storeNewTerminal,
]);
const closeTerminal = useCallback(
const closeTerminalSession = useCallback(
(terminalId: string) => {
if (!activeThreadId || !activeThreadRef) return;
const fallbackExitWrite = () =>
Expand All @@ -3137,7 +3137,6 @@ function ChatViewContent(props: ChatViewProps) {
}
})();
storeCloseTerminal(activeThreadRef, terminalId);
setTerminalFocusRequestId((value) => value + 1);
},
[
activeThreadId,
Expand All @@ -3148,6 +3147,13 @@ function ChatViewContent(props: ChatViewProps) {
writeTerminal,
],
);
const closeTerminal = useCallback(
(terminalId: string) => {
closeTerminalSession(terminalId);
setTerminalFocusRequestId((value) => value + 1);
},
[closeTerminalSession],
);
const runProjectScript = useCallback(
async (
script: ProjectScript,
Expand Down Expand Up @@ -3623,17 +3629,12 @@ function ChatViewContent(props: ChatViewProps) {
const closePanelTerminal = useCallback(
(terminalId: string) => {
if (!activeThreadRef || activeRightPanelSurface?.kind !== "terminal") return;
void closeTerminalMutation({
environmentId: activeThreadRef.environmentId,
input: { threadId: activeThreadRef.threadId, terminalId, deleteHistory: true },
});
storeCloseTerminal(activeThreadRef, terminalId);
closeTerminal(terminalId);
useRightPanelStore
.getState()
.closeTerminal(activeThreadRef, activeRightPanelSurface.id, terminalId);
setTerminalFocusRequestId((value) => value + 1);
},
[activeRightPanelSurface, activeThreadRef, closeTerminalMutation, storeCloseTerminal],
[activeRightPanelSurface, activeThreadRef, closeTerminal],
);
const requestCloseTerminal = useCallback(
(terminalId: string) => {
Expand Down Expand Up @@ -3697,22 +3698,12 @@ function ChatViewContent(props: ChatViewProps) {
}
if (surface.kind === "terminal") {
for (const terminalId of surface.terminalIds) {
storeCloseTerminal(activeThreadRef, terminalId);
void closeTerminalMutation({
environmentId: activeThreadRef.environmentId,
input: { threadId: activeThreadRef.threadId, terminalId, deleteHistory: true },
});
closeTerminalSession(terminalId);
}
}
}
},
[
activeThreadRef,
activePreviewState.sessions,
closePreview,
closeTerminalMutation,
storeCloseTerminal,
],
[activeThreadRef, activePreviewState.sessions, closePreview, closeTerminalSession],
);
const syncActivePreviewSurface = useCallback(() => {
if (!activeThreadRef) return;
Expand Down
Loading