@@ -167,7 +167,6 @@ import {
167167 WifiOffIcon ,
168168} from "lucide-react" ;
169169import { cn , randomHex } from "~/lib/utils" ;
170- import { COLLAPSED_SIDEBAR_TITLEBAR_INSET_CLASS } from "~/workspaceTitlebar" ;
171170import { stackedThreadToast , toastManager } from "./ui/toast" ;
172171import { decodeProjectScriptKeybindingRule } from "~/lib/projectScriptKeybindings" ;
173172import { type NewProjectScriptInput } from "./ProjectScriptsControl" ;
@@ -220,7 +219,11 @@ import {
220219import { appendPreviewAnnotationPrompt } from "../lib/previewAnnotation" ;
221220import { appendReviewCommentsToPrompt , type ReviewCommentContext } from "../reviewCommentContext" ;
222221import { environmentCatalog } from "../connection/catalog" ;
223- import { selectThreadTerminalUiState , useTerminalUiStateStore } from "../terminalUiStateStore" ;
222+ import {
223+ selectThreadTerminalCustomLabels ,
224+ selectThreadTerminalUiState ,
225+ useTerminalUiStateStore ,
226+ } from "../terminalUiStateStore" ;
224227import { useKnownTerminalSessions , useThreadRunningTerminalIds } from "../state/terminalSessions" ;
225228import { projectEnvironment } from "../state/projects" ;
226229import { useEnvironmentQuery } from "../state/query" ;
@@ -256,6 +259,7 @@ import { ChatHeader } from "./chat/ChatHeader";
256259import { PanelLayoutControls , RightPanelMaximizeControl } from "./chat/PanelLayoutControls" ;
257260import { type ExpandedImagePreview } from "./chat/ExpandedImagePreview" ;
258261import { NoActiveThreadState } from "./NoActiveThreadState" ;
262+ import { WorkspacePageHeader } from "./WorkspacePageContainer" ;
259263import {
260264 resolveEffectiveEnvMode ,
261265 resolveLocalCheckoutBranchMismatch ,
@@ -653,6 +657,7 @@ interface PersistentThreadTerminalDrawerProps {
653657 newShortcutLabel : string | undefined ;
654658 closeShortcutLabel : string | undefined ;
655659 keybindings : ResolvedKeybindingsConfig ;
660+ onHide : ( ) => void ;
656661 onAddTerminalContext : ( selection : TerminalContextSelection ) => void ;
657662}
658663
@@ -667,6 +672,7 @@ const PersistentThreadTerminalDrawer = memo(function PersistentThreadTerminalDra
667672 newShortcutLabel,
668673 closeShortcutLabel,
669674 keybindings,
675+ onHide,
670676 onAddTerminalContext,
671677} : PersistentThreadTerminalDrawerProps ) {
672678 const openTerminal = useAtomCommand ( terminalEnvironment . open , "terminal open" ) ;
@@ -990,6 +996,7 @@ const PersistentThreadTerminalDrawer = memo(function PersistentThreadTerminalDra
990996 onSplitTerminal = { splitTerminal }
991997 onSplitTerminalVertical = { splitTerminalVertical }
992998 onNewTerminal = { createNewTerminal }
999+ onHide = { onHide }
9931000 splitShortcutLabel = { visible ? splitShortcutLabel : undefined }
9941001 splitVerticalShortcutLabel = { visible ? splitVerticalShortcutLabel : undefined }
9951002 newShortcutLabel = { visible ? newShortcutLabel : undefined }
@@ -1540,6 +1547,16 @@ function ChatViewContent(props: ChatViewProps) {
15401547 const canCheckoutPullRequestIntoThread = isLocalDraftThread ;
15411548 const activeThreadId = activeThread ?. id ?? null ;
15421549 const activeThreadEnvironmentId = activeThread ?. environmentId ?? null ;
1550+ const activeThreadRef = useMemo (
1551+ ( ) =>
1552+ activeThreadEnvironmentId && activeThreadId
1553+ ? scopeThreadRef ( activeThreadEnvironmentId , activeThreadId )
1554+ : null ,
1555+ [ activeThreadEnvironmentId , activeThreadId ] ,
1556+ ) ;
1557+ const activeTerminalCustomLabels = useTerminalUiStateStore ( ( state ) =>
1558+ selectThreadTerminalCustomLabels ( state . terminalCustomLabelsByThreadKey , activeThreadRef ) ,
1559+ ) ;
15431560 const runningTerminalIds = useThreadRunningTerminalIds ( {
15441561 environmentId : activeThread ?. environmentId ?? null ,
15451562 threadId : activeThreadId ,
@@ -1569,18 +1586,15 @@ function ChatViewContent(props: ChatViewProps) {
15691586 for ( const session of activeThreadKnownSessions ) {
15701587 labels . set (
15711588 session . target . terminalId ,
1572- resolveTerminalSessionLabel ( session . target . terminalId , session . state . summary ) ,
1589+ activeTerminalCustomLabels [ session . target . terminalId ] ??
1590+ resolveTerminalSessionLabel ( session . target . terminalId , session . state . summary ) ,
15731591 ) ;
15741592 }
1593+ for ( const [ terminalId , label ] of Object . entries ( activeTerminalCustomLabels ) ) {
1594+ if ( ! labels . has ( terminalId ) ) labels . set ( terminalId , label ) ;
1595+ }
15751596 return labels ;
1576- } , [ activeThreadKnownSessions ] ) ;
1577- const activeThreadRef = useMemo (
1578- ( ) =>
1579- activeThreadEnvironmentId && activeThreadId
1580- ? scopeThreadRef ( activeThreadEnvironmentId , activeThreadId )
1581- : null ,
1582- [ activeThreadEnvironmentId , activeThreadId ] ,
1583- ) ;
1597+ } , [ activeTerminalCustomLabels , activeThreadKnownSessions ] ) ;
15841598 const activeThreadKey = activeThreadRef ? scopedThreadKey ( activeThreadRef ) : null ;
15851599 const [ timelineAnchor , setTimelineAnchor ] = useState < {
15861600 readonly threadKey : string | null ;
@@ -2808,6 +2822,7 @@ function ChatViewContent(props: ChatViewProps) {
28082822 } ,
28092823 [ activeThreadRef , storeSetTerminalOpen ] ,
28102824 ) ;
2825+ const hideTerminal = useCallback ( ( ) => setTerminalOpen ( false ) , [ setTerminalOpen ] ) ;
28112826 const toggleTerminalVisibility = useCallback ( ( ) => {
28122827 if ( ! activeThreadRef ) return ;
28132828 const nextOpen = ! terminalUiState . terminalOpen ;
@@ -6114,7 +6129,6 @@ function ChatViewContent(props: ChatViewProps) {
61146129 ? "thread"
61156130 : "page"
61166131 }
6117- chromeVariant = "collapse"
61186132 composerDraftTarget = { composerDraftTarget }
61196133 onStateChange = { handlePullRequestTabStatusChange }
61206134 />
@@ -6160,20 +6174,11 @@ function ChatViewContent(props: ChatViewProps) {
61606174 data-chat-column-maximized-away = { rightPanelMaximized ? "true" : "false" }
61616175 >
61626176 { /* Top bar */ }
6163- < header
6177+ < WorkspacePageHeader
61646178 data-chat-header
6165- className = { cn (
6166- "bg-background transition-[padding-left] duration-200 ease-linear motion-reduce:transition-none" ,
6167- isElectron
6168- ? cn (
6169- "drag-region relative flex h-[var(--workspace-topbar-height)] min-h-[var(--workspace-topbar-height)] shrink-0 items-center px-3 sm:px-5" ,
6170- reserveTitleBarControlInset &&
6171- ! inlineRightPanelOwnsTitleBar &&
6172- "wco:pr-[var(--workspace-native-controls-inset)]" ,
6173- )
6174- : "flex h-[var(--workspace-topbar-height)] min-h-[var(--workspace-topbar-height)] shrink-0 items-center pl-[calc(env(safe-area-inset-left)+0.75rem)] pr-[calc(env(safe-area-inset-right)+0.75rem)] sm:pl-[calc(env(safe-area-inset-left)+1.25rem)] sm:pr-[calc(env(safe-area-inset-right)+1.25rem)]" ,
6175- COLLAPSED_SIDEBAR_TITLEBAR_INSET_CLASS ,
6176- ) }
6179+ electron = { isElectron }
6180+ reserveNativeControls = { reserveTitleBarControlInset && ! inlineRightPanelOwnsTitleBar }
6181+ className = "relative bg-background"
61776182 >
61786183 { ! rightPanelOpen ? panelLayoutControls : null }
61796184 < ChatHeader
@@ -6204,7 +6209,7 @@ function ChatViewContent(props: ChatViewProps) {
62046209 onUpdateProjectScript = { updateProjectScript }
62056210 onDeleteProjectScript = { deleteProjectScript }
62066211 />
6207- </ header >
6212+ </ WorkspacePageHeader >
62086213
62096214 < ThreadErrorBanner
62106215 error = { visibleThreadError }
@@ -6542,6 +6547,7 @@ function ChatViewContent(props: ChatViewProps) {
65426547 newShortcutLabel = { newTerminalShortcutLabel ?? undefined }
65436548 closeShortcutLabel = { closeTerminalShortcutLabel ?? undefined }
65446549 keybindings = { keybindings }
6550+ onHide = { hideTerminal }
65456551 onAddTerminalContext = { addTerminalContextToDraft }
65466552 />
65476553 ) ) }
0 commit comments