@@ -22,6 +22,7 @@ import { isTerminalClearShortcut, terminalNavigationShortcutData } from "../keyb
2222import {
2323 DEFAULT_THREAD_TERMINAL_HEIGHT ,
2424 DEFAULT_THREAD_TERMINAL_ID ,
25+ MAX_THREAD_TERMINAL_COUNT ,
2526 type ThreadTerminalGroup ,
2627} from "../types" ;
2728
@@ -581,16 +582,31 @@ export default function ThreadTerminalDrawer({
581582 const showGroupHeaders =
582583 resolvedTerminalGroups . length > 1 ||
583584 resolvedTerminalGroups . some ( ( terminalGroup ) => terminalGroup . terminalIds . length > 1 ) ;
585+ const hasReachedTerminalLimit = normalizedTerminalIds . length >= MAX_THREAD_TERMINAL_COUNT ;
584586 const terminalLabelById = useMemo (
585587 ( ) =>
586588 new Map (
587589 normalizedTerminalIds . map ( ( terminalId , index ) => [ terminalId , `Terminal ${ index + 1 } ` ] ) ,
588590 ) ,
589591 [ normalizedTerminalIds ] ,
590592 ) ;
593+ const splitTerminalActionLabel = hasReachedTerminalLimit
594+ ? `Split Terminal (max ${ MAX_THREAD_TERMINAL_COUNT } )`
595+ : ( splitShortcutLabel ? `Split Terminal (${ splitShortcutLabel } )` : "Split Terminal" ) ;
596+ const newTerminalActionLabel = hasReachedTerminalLimit
597+ ? `New Terminal (max ${ MAX_THREAD_TERMINAL_COUNT } )`
598+ : ( newShortcutLabel ? `New Terminal (${ newShortcutLabel } )` : "New Terminal" ) ;
591599 const closeTerminalActionLabel = closeShortcutLabel
592600 ? `Close Terminal (${ closeShortcutLabel } )`
593601 : "Close Terminal" ;
602+ const onSplitTerminalAction = useCallback ( ( ) => {
603+ if ( hasReachedTerminalLimit ) return ;
604+ onSplitTerminal ( ) ;
605+ } , [ hasReachedTerminalLimit , onSplitTerminal ] ) ;
606+ const onNewTerminalAction = useCallback ( ( ) => {
607+ if ( hasReachedTerminalLimit ) return ;
608+ onNewTerminal ( ) ;
609+ } , [ hasReachedTerminalLimit , onNewTerminal ] ) ;
594610
595611 useEffect ( ( ) => {
596612 onHeightChangeRef . current = onHeightChange ;
@@ -685,7 +701,7 @@ export default function ThreadTerminalDrawer({
685701
686702 return (
687703 < aside
688- className = "thread-terminal-drawer relative flex shrink-0 flex-col border-t border-border/80 bg-background"
704+ className = "thread-terminal-drawer relative flex min-w-0 shrink-0 flex-col overflow-hidden border-t border-border/80 bg-background"
689705 style = { { height : `${ drawerHeight } px` } }
690706 >
691707 < div
@@ -700,19 +716,25 @@ export default function ThreadTerminalDrawer({
700716 < div className = "pointer-events-none absolute right-2 top-2 z-20" >
701717 < div className = "pointer-events-auto inline-flex items-center overflow-hidden rounded-md border border-border/80 bg-background/70" >
702718 < TerminalActionButton
703- className = "p-1 text-foreground/90 transition-colors hover:bg-accent"
704- onClick = { onSplitTerminal }
705- label = {
706- splitShortcutLabel ? `Split Terminal (${ splitShortcutLabel } )` : "Split Terminal"
707- }
719+ className = { `p-1 text-foreground/90 transition-colors ${
720+ hasReachedTerminalLimit
721+ ? "cursor-not-allowed opacity-45 hover:bg-transparent"
722+ : "hover:bg-accent"
723+ } `}
724+ onClick = { onSplitTerminalAction }
725+ label = { splitTerminalActionLabel }
708726 >
709727 < SquareSplitHorizontal className = "size-3.25" />
710728 </ TerminalActionButton >
711729 < div className = "h-4 w-px bg-border/80" />
712730 < TerminalActionButton
713- className = "p-1 text-foreground/90 transition-colors hover:bg-accent"
714- onClick = { onNewTerminal }
715- label = { newShortcutLabel ? `New Terminal (${ newShortcutLabel } )` : "New Terminal" }
731+ className = { `p-1 text-foreground/90 transition-colors ${
732+ hasReachedTerminalLimit
733+ ? "cursor-not-allowed opacity-45 hover:bg-transparent"
734+ : "hover:bg-accent"
735+ } `}
736+ onClick = { onNewTerminalAction }
737+ label = { newTerminalActionLabel }
716738 >
717739 < Plus className = "size-3.25" />
718740 </ TerminalActionButton >
@@ -733,9 +755,9 @@ export default function ThreadTerminalDrawer({
733755 < div className = "min-w-0 flex-1" >
734756 { isSplitView ? (
735757 < div
736- className = "grid h-full w-full gap-0 overflow-x-auto "
758+ className = "grid h-full w-full min-w-0 gap-0 overflow-hidden "
737759 style = { {
738- gridTemplateColumns : `repeat(${ visibleTerminalIds . length } , minmax(260px , 1fr))` ,
760+ gridTemplateColumns : `repeat(${ visibleTerminalIds . length } , minmax(0 , 1fr))` ,
739761 } }
740762 >
741763 { visibleTerminalIds . map ( ( terminalId ) => (
@@ -787,20 +809,24 @@ export default function ThreadTerminalDrawer({
787809 < div className = "flex h-[22px] items-stretch justify-end border-b border-border/70" >
788810 < div className = "inline-flex h-full items-stretch" >
789811 < TerminalActionButton
790- className = " inline-flex h-full items-center px-1 text-foreground/90 transition-colors hover:bg-accent/70"
791- onClick = { onSplitTerminal }
792- label = {
793- splitShortcutLabel
794- ? `Split Terminal ( ${ splitShortcutLabel } )`
795- : "Split Terminal"
796- }
812+ className = { ` inline-flex h-full items-center px-1 text-foreground/90 transition-colors ${
813+ hasReachedTerminalLimit
814+ ? "cursor-not-allowed opacity-45 hover:bg-transparent"
815+ : "hover:bg-accent/70"
816+ } ` }
817+ onClick = { onSplitTerminalAction }
818+ label = { splitTerminalActionLabel }
797819 >
798820 < SquareSplitHorizontal className = "size-3.25" />
799821 </ TerminalActionButton >
800822 < TerminalActionButton
801- className = "inline-flex h-full items-center border-l border-border/70 px-1 text-foreground/90 transition-colors hover:bg-accent/70"
802- onClick = { onNewTerminal }
803- label = { newShortcutLabel ? `New Terminal (${ newShortcutLabel } )` : "New Terminal" }
823+ className = { `inline-flex h-full items-center border-l border-border/70 px-1 text-foreground/90 transition-colors ${
824+ hasReachedTerminalLimit
825+ ? "cursor-not-allowed opacity-45 hover:bg-transparent"
826+ : "hover:bg-accent/70"
827+ } `}
828+ onClick = { onNewTerminalAction }
829+ label = { newTerminalActionLabel }
804830 >
805831 < Plus className = "size-3.25" />
806832 </ TerminalActionButton >
0 commit comments