@@ -61,7 +61,7 @@ describe("panelLayoutStore", () => {
6161 usePanelLayoutStore . getState ( ) . initializeTask ( "task-1" ) ;
6262 } ) ;
6363
64- it ( "adds file tab to main panel" , ( ) => {
64+ it ( "adds file tab to main panel by default " , ( ) => {
6565 usePanelLayoutStore . getState ( ) . openFile ( "task-1" , "src/App.tsx" ) ;
6666
6767 assertTabCount ( getPanelTree ( "task-1" ) , "main-panel" , 2 ) ;
@@ -73,6 +73,43 @@ describe("panelLayoutStore", () => {
7373 ] ) ;
7474 } ) ;
7575
76+ it ( "opens file in the focused panel" , ( ) => {
77+ // Focus the terminal panel
78+ usePanelLayoutStore
79+ . getState ( )
80+ . setFocusedPanel ( "task-1" , "terminal-panel" ) ;
81+
82+ usePanelLayoutStore . getState ( ) . openFile ( "task-1" , "src/App.tsx" ) ;
83+
84+ // File should open in terminal-panel (the focused panel), not main-panel
85+ assertPanelLayout ( getPanelTree ( "task-1" ) , [
86+ {
87+ panelId : "terminal-panel" ,
88+ expectedTabs : [ "shell" , "file-src/App.tsx" ] ,
89+ activeTab : "file-src/App.tsx" ,
90+ } ,
91+ ] ) ;
92+ assertTabCount ( getPanelTree ( "task-1" ) , "main-panel" , 1 ) ; // Only logs
93+ } ) ;
94+
95+ it ( "falls back to main panel if focused panel does not exist" , ( ) => {
96+ // Set focus to a non-existent panel
97+ usePanelLayoutStore
98+ . getState ( )
99+ . setFocusedPanel ( "task-1" , "non-existent-panel" ) ;
100+
101+ usePanelLayoutStore . getState ( ) . openFile ( "task-1" , "src/App.tsx" ) ;
102+
103+ // File should fall back to main-panel
104+ assertTabCount ( getPanelTree ( "task-1" ) , "main-panel" , 2 ) ;
105+ assertPanelLayout ( getPanelTree ( "task-1" ) , [
106+ {
107+ panelId : "main-panel" ,
108+ expectedTabs : [ "logs" , "file-src/App.tsx" ] ,
109+ } ,
110+ ] ) ;
111+ } ) ;
112+
76113 it ( "sets newly opened file as active" , ( ) => {
77114 usePanelLayoutStore . getState ( ) . openFile ( "task-1" , "src/App.tsx" ) ;
78115
0 commit comments