1- import { Show , createMemo , createEffect , onMount , onCleanup , ErrorBoundary } from 'solid-js' ;
1+ import { Show , For , createMemo , createEffect , ErrorBoundary } from 'solid-js' ;
22import { store , pickAndAddProject , closeTerminal } from '../store/store' ;
33import { closeTask } from '../store/tasks' ;
4- import { ResizablePanel , type PanelChild , type ResizablePanelHandle } from './ResizablePanel' ;
4+ import type { PanelChild } from './ResizablePanel' ;
55import { TaskPanel } from './TaskPanel' ;
66import { TerminalPanel } from './TerminalPanel' ;
77import { NewTaskPlaceholder } from './NewTaskPlaceholder' ;
8+ import { markDirty } from '../lib/terminalFitManager' ;
89import { theme } from '../lib/theme' ;
910import { mod } from '../lib/platform' ;
10- import { createCtrlShiftWheelResizeHandler } from '../lib/wheelZoom' ;
1111
1212export function TilingLayout ( ) {
1313 let containerRef : HTMLDivElement | undefined ;
14- let panelHandle : ResizablePanelHandle | undefined ;
15-
16- onMount ( ( ) => {
17- if ( ! containerRef ) return ;
18- const handleWheel = createCtrlShiftWheelResizeHandler ( ( deltaPx ) => {
19- panelHandle ?. resizeAll ( deltaPx ) ;
20- } ) ;
21- containerRef . addEventListener ( 'wheel' , handleWheel , { passive : false } ) ;
22- onCleanup ( ( ) => containerRef ?. removeEventListener ( 'wheel' , handleWheel ) ) ;
23- } ) ;
2414
2515 // Scroll the active task panel into view when selection changes
2616 createEffect ( ( ) => {
@@ -29,6 +19,20 @@ export function TilingLayout() {
2919 const el = containerRef . querySelector < HTMLElement > ( `[data-task-id="${ CSS . escape ( activeId ) } "]` ) ;
3020 el ?. scrollIntoView ( { block : 'nearest' , inline : 'nearest' , behavior : 'instant' } ) ;
3121 } ) ;
22+
23+ // When switching tasks in focus mode, mark all terminals of the newly active
24+ // task as dirty so they re-fit to the correct size.
25+ createEffect ( ( ) => {
26+ const activeId = store . activeTaskId ;
27+ if ( ! store . focusMode || ! activeId ) return ;
28+ const task = store . tasks [ activeId ] ;
29+ if ( task ) {
30+ for ( const agentId of task . agentIds ) markDirty ( agentId ) ;
31+ for ( const shellId of task . shellAgentIds ) markDirty ( shellId ) ;
32+ }
33+ const terminal = store . terminals [ activeId ] ;
34+ if ( terminal ) markDirty ( terminal . agentId ) ;
35+ } ) ;
3236 // Cache PanelChild objects by ID so <For> sees stable references
3337 // and doesn't unmount/remount panels when taskOrder changes.
3438 const panelCache = new Map < string , PanelChild > ( ) ;
@@ -48,7 +52,7 @@ export function TilingLayout() {
4852 cached = {
4953 id : panelId ,
5054 initialSize : 520 ,
51- minSize : 300 ,
55+ minSize : 520 ,
5256 content : ( ) => {
5357 const task = store . tasks [ panelId ] ;
5458 const terminal = store . terminals [ panelId ] ;
@@ -334,15 +338,52 @@ export function TilingLayout() {
334338 </ div >
335339 }
336340 >
337- < ResizablePanel
338- direction = "horizontal"
339- children = { panelChildren ( ) }
340- fitContent
341- persistKey = "tiling"
342- onHandle = { ( h ) => {
343- panelHandle = h ;
341+ < div
342+ style = { {
343+ display : 'flex' ,
344+ 'flex-direction' : 'row' ,
345+ width : '100%' ,
346+ 'min-width' : '100%' ,
347+ height : '100%' ,
348+ position : 'relative' ,
344349 } }
345- />
350+ >
351+ < For each = { panelChildren ( ) } >
352+ { ( child ) => {
353+ const isPlaceholder = child . id === '__placeholder' ;
354+ const hidden = ( ) =>
355+ store . focusMode && ! isPlaceholder && child . id !== store . activeTaskId ;
356+ const hidePlaceholder = ( ) => store . focusMode && isPlaceholder ;
357+ return (
358+ < div
359+ style = { {
360+ // Focus mode: stack all panels on top of each other at full size
361+ // so terminals always compute correct dimensions.
362+ // Normal mode: standard flex row layout.
363+ ...( store . focusMode && ! isPlaceholder
364+ ? {
365+ position : hidden ( ) ? 'absolute' : 'relative' ,
366+ inset : '0' ,
367+ width : '100%' ,
368+ height : '100%' ,
369+ visibility : hidden ( ) ? 'hidden' : undefined ,
370+ 'pointer-events' : hidden ( ) ? 'none' : undefined ,
371+ }
372+ : {
373+ flex : isPlaceholder ? '0 0 54px' : '1 1 0px' ,
374+ 'min-width' : isPlaceholder ? undefined : '520px' ,
375+ height : '100%' ,
376+ display : hidePlaceholder ( ) ? 'none' : undefined ,
377+ } ) ,
378+ overflow : 'hidden' ,
379+ } }
380+ >
381+ { child . content ( ) }
382+ </ div >
383+ ) ;
384+ } }
385+ </ For >
386+ </ div >
346387 </ Show >
347388 </ div >
348389 ) ;
0 commit comments