@@ -46,7 +46,11 @@ import {
4646import { CHAT_LIST_ANCHOR_OFFSET } from "@t3tools/shared/chatList" ;
4747import { projectScriptCwd , projectScriptRuntimeEnv } from "@t3tools/shared/projectScripts" ;
4848import { truncate } from "@t3tools/shared/String" ;
49- import { nextTerminalId , resolveTerminalSessionLabel } from "@t3tools/shared/terminalLabels" ;
49+ import {
50+ getTerminalLabel ,
51+ nextTerminalId ,
52+ resolveTerminalSessionLabel ,
53+ } from "@t3tools/shared/terminalLabels" ;
5054import { Debouncer } from "@tanstack/react-pacer" ;
5155import { useAtomValue } from "@effect/atom-react" ;
5256import {
@@ -192,6 +196,7 @@ import {
192196import { useNowMinute } from "../hooks/useNowMinute" ;
193197import { useNewThreadHandler } from "../hooks/useHandleNewThread" ;
194198import { resolveAppModelSelectionForInstance } from "../modelSelection" ;
199+ import { confirmTerminalClose } from "../lib/terminalCloseConfirm" ;
195200import { getTerminalFocusOwner } from "../lib/terminalFocus" ;
196201import { preventRepeatedTerminalCloseShortcut } from "../lib/terminalCloseShortcut" ;
197202import { resolveNewDraftStartFromOrigin } from "../lib/chatThreadActions" ;
@@ -3453,6 +3458,24 @@ function ChatViewContent(props: ChatViewProps) {
34533458 } ,
34543459 [ activeRightPanelSurface , activeThreadRef , closeTerminalMutation , storeCloseTerminal ] ,
34553460 ) ;
3461+ const requestCloseTerminal = useCallback (
3462+ ( terminalId : string ) => {
3463+ const label = activeTerminalLabelsById . get ( terminalId ) ?? getTerminalLabel ( terminalId ) ;
3464+ void confirmTerminalClose ( label ) . then ( ( confirmed ) => {
3465+ if ( confirmed ) closeTerminal ( terminalId ) ;
3466+ } ) ;
3467+ } ,
3468+ [ activeTerminalLabelsById , closeTerminal ] ,
3469+ ) ;
3470+ const requestClosePanelTerminal = useCallback (
3471+ ( terminalId : string ) => {
3472+ const label = activeTerminalLabelsById . get ( terminalId ) ?? getTerminalLabel ( terminalId ) ;
3473+ void confirmTerminalClose ( label ) . then ( ( confirmed ) => {
3474+ if ( confirmed ) closePanelTerminal ( terminalId ) ;
3475+ } ) ;
3476+ } ,
3477+ [ activeTerminalLabelsById , closePanelTerminal ] ,
3478+ ) ;
34563479 const activateRightPanelSurface = useCallback (
34573480 ( surface : RightPanelSurface ) => {
34583481 if ( ! activeThreadRef ) return ;
@@ -4807,11 +4830,11 @@ function ChatViewContent(props: ChatViewProps) {
48074830 event . preventDefault ( ) ;
48084831 event . stopPropagation ( ) ;
48094832 if ( terminalFocusOwner === "right-panel" && activeRightPanelSurface ?. kind === "terminal" ) {
4810- closePanelTerminal ( activeRightPanelSurface . activeTerminalId ) ;
4833+ requestClosePanelTerminal ( activeRightPanelSurface . activeTerminalId ) ;
48114834 return ;
48124835 }
48134836 if ( ! terminalUiState . terminalOpen ) return ;
4814- closeTerminal ( terminalUiState . activeTerminalId ) ;
4837+ requestCloseTerminal ( terminalUiState . activeTerminalId ) ;
48154838 return ;
48164839 }
48174840
@@ -4860,8 +4883,8 @@ function ChatViewContent(props: ChatViewProps) {
48604883 terminalUiState . terminalOpen ,
48614884 terminalUiState . activeTerminalId ,
48624885 activeThreadId ,
4863- closeTerminal ,
4864- closePanelTerminal ,
4886+ requestCloseTerminal ,
4887+ requestClosePanelTerminal ,
48654888 createNewTerminal ,
48664889 setTerminalOpen ,
48674890 runProjectScript ,
0 commit comments