@@ -18,6 +18,10 @@ import {
1818import { LEGACY_PANE_LAYOUT_STORAGE_KEY_PREFIX , paneLayoutAtomFamily } from "./atoms/pane-layout" ;
1919import { AgentPanes } from "./index" ;
2020
21+ function editorPaneStateKey ( workspaceId : string , paneId : string ) : string {
22+ return `${ workspaceId } ::${ paneId } ` ;
23+ }
24+
2125type MockSessionCardProps = {
2226 dragState ?: {
2327 isActiveDropTarget : boolean ;
@@ -642,10 +646,9 @@ describe("AgentPanes", () => {
642646 id : "root" ,
643647 type : "split" ,
644648 direction : "horizontal" ,
645- ratio : 0.5 ,
646649 children : [
647- { id : "left" , type : "leaf" , sessionId : "sess_2" } ,
648- { id : "right" , type : "leaf" , sessionId : "sess_1" } ,
650+ { id : "left" , type : "leaf" , leafKind : "session" , sessionId : "sess_2" } ,
651+ { id : "right" , type : "leaf" , leafKind : "session" , sessionId : "sess_1" } ,
649652 ] ,
650653 } ,
651654 } ) ,
@@ -732,10 +735,9 @@ describe("AgentPanes", () => {
732735 id : "root" ,
733736 type : "split" ,
734737 direction : "horizontal" ,
735- ratio : 0.5 ,
736738 children : [
737- { id : "left" , type : "leaf" } ,
738- { id : "right" , type : "leaf" , sessionId : "sess_1" } ,
739+ { id : "left" , type : "leaf" , leafKind : "draft" } ,
740+ { id : "right" , type : "leaf" , leafKind : "session" , sessionId : "sess_1" } ,
739741 ] ,
740742 } ,
741743 } ) ,
@@ -834,10 +836,19 @@ describe("AgentPanes", () => {
834836 id : expect . stringMatching ( / ^ s p l i t - r i g h t - l e f t - / ) ,
835837 type : "split" ,
836838 direction : "horizontal" ,
837- ratio : 0.5 ,
838839 children : [
839- expect . objectContaining ( { id : "left" , type : "leaf" , sessionId : "sess_1" } ) ,
840- expect . objectContaining ( { id : "right" , type : "leaf" , sessionId : "sess_2" } ) ,
840+ expect . objectContaining ( {
841+ id : "left" ,
842+ type : "leaf" ,
843+ leafKind : "session" ,
844+ sessionId : "sess_1" ,
845+ } ) ,
846+ expect . objectContaining ( {
847+ id : "right" ,
848+ type : "leaf" ,
849+ leafKind : "session" ,
850+ sessionId : "sess_2" ,
851+ } ) ,
841852 ] ,
842853 } ) ,
843854 } ) ,
@@ -1865,7 +1876,7 @@ describe("AgentPanes", () => {
18651876 expect ( await screen . findByTestId ( "editor-pane-root" ) ) . toBeInTheDocument ( ) ;
18661877 } ) ;
18671878
1868- it ( "reuses the existing editor pane when another draft launcher opens a file" , async ( ) => {
1879+ it ( "converts another draft launcher into a new editor pane when it opens a file" , async ( ) => {
18691880 const { store } = createAgentPaneStore ( {
18701881 id : "root" ,
18711882 type : "split" ,
@@ -1875,6 +1886,10 @@ describe("AgentPanes", () => {
18751886 { id : "right" , type : "leaf" , leafKind : "draft" } ,
18761887 ] ,
18771888 } ) ;
1889+ store . set (
1890+ editorPaneActiveFilePathAtomFamily ( editorPaneStateKey ( "ws-1" , "left" ) ) ,
1891+ "src/left.tsx"
1892+ ) ;
18781893
18791894 render (
18801895 < Provider store = { store } >
@@ -1890,12 +1905,17 @@ describe("AgentPanes", () => {
18901905 direction : "horizontal" ,
18911906 children : [
18921907 { id : "left" , type : "leaf" , leafKind : "editor" } ,
1893- { id : "right" , type : "leaf" , leafKind : "draft " } ,
1908+ { id : "right" , type : "leaf" , leafKind : "editor " } ,
18941909 ] ,
18951910 } ) ;
1896- expect ( store . get ( activeEditorPaneIdAtomFamily ( "ws-1" ) ) ) . toBe ( "left" ) ;
1897- expect ( store . get ( focusedEditorPaneIdAtomFamily ( "ws-1" ) ) ) . toBe ( "left" ) ;
1898- expect ( store . get ( editorPaneActiveFilePathAtomFamily ( "ws-1" ) ) ) . toBe ( "src/app.tsx" ) ;
1911+ expect ( store . get ( activeEditorPaneIdAtomFamily ( "ws-1" ) ) ) . toBe ( "right" ) ;
1912+ expect ( store . get ( focusedEditorPaneIdAtomFamily ( "ws-1" ) ) ) . toBe ( "right" ) ;
1913+ expect ( store . get ( editorPaneActiveFilePathAtomFamily ( editorPaneStateKey ( "ws-1" , "left" ) ) ) ) . toBe (
1914+ "src/left.tsx"
1915+ ) ;
1916+ expect ( store . get ( editorPaneActiveFilePathAtomFamily ( editorPaneStateKey ( "ws-1" , "right" ) ) ) ) . toBe (
1917+ "src/app.tsx"
1918+ ) ;
18991919 expect ( store . get ( activeFilePathAtomFamily ( "ws-1" ) ) ) . toBeNull ( ) ;
19001920 } ) ;
19011921
@@ -1908,7 +1928,10 @@ describe("AgentPanes", () => {
19081928 store . set ( activeEditorPaneIdAtomFamily ( "ws-1" ) , "root" ) ;
19091929 store . set ( focusedEditorPaneIdAtomFamily ( "ws-1" ) , "root" ) ;
19101930 store . set ( activeFilePathAtomFamily ( "ws-1" ) , "src/global.tsx" ) ;
1911- store . set ( editorPaneActiveFilePathAtomFamily ( "ws-1" ) , "src/app.tsx" ) ;
1931+ store . set (
1932+ editorPaneActiveFilePathAtomFamily ( editorPaneStateKey ( "ws-1" , "root" ) ) ,
1933+ "src/app.tsx"
1934+ ) ;
19121935 store . set ( openFilesAtomFamily ( "ws-1" ) , {
19131936 "src/global.tsx" : {
19141937 kind : "text" ,
@@ -1943,7 +1966,9 @@ describe("AgentPanes", () => {
19431966 } ) ;
19441967 expect ( store . get ( activeEditorPaneIdAtomFamily ( "ws-1" ) ) ) . toBeNull ( ) ;
19451968 expect ( store . get ( focusedEditorPaneIdAtomFamily ( "ws-1" ) ) ) . toBeNull ( ) ;
1946- expect ( store . get ( editorPaneActiveFilePathAtomFamily ( "ws-1" ) ) ) . toBeNull ( ) ;
1969+ expect ( store . get ( editorPaneActiveFilePathAtomFamily ( editorPaneStateKey ( "ws-1" , "root" ) ) ) ) . toBe (
1970+ null
1971+ ) ;
19471972 expect ( store . get ( activeFilePathAtomFamily ( "ws-1" ) ) ) . toBe ( "src/global.tsx" ) ;
19481973 expect ( store . get ( openFilesAtomFamily ( "ws-1" ) ) ) . toEqual ( {
19491974 "src/global.tsx" : expect . objectContaining ( {
@@ -1962,7 +1987,10 @@ describe("AgentPanes", () => {
19621987 store . set ( activeEditorPaneIdAtomFamily ( "ws-1" ) , "root" ) ;
19631988 store . set ( focusedEditorPaneIdAtomFamily ( "ws-1" ) , "root" ) ;
19641989 store . set ( activeFilePathAtomFamily ( "ws-1" ) , "src/app.tsx" ) ;
1965- store . set ( editorPaneActiveFilePathAtomFamily ( "ws-1" ) , "src/app.tsx" ) ;
1990+ store . set (
1991+ editorPaneActiveFilePathAtomFamily ( editorPaneStateKey ( "ws-1" , "root" ) ) ,
1992+ "src/app.tsx"
1993+ ) ;
19661994 store . set ( openFilesAtomFamily ( "ws-1" ) , {
19671995 "src/app.tsx" : {
19681996 kind : "text" ,
@@ -1983,7 +2011,9 @@ describe("AgentPanes", () => {
19832011 fireEvent . click ( screen . getByRole ( "button" , { name : "close-editor-root" } ) ) ;
19842012
19852013 expect ( store . get ( activeFilePathAtomFamily ( "ws-1" ) ) ) . toBe ( "src/app.tsx" ) ;
1986- expect ( store . get ( editorPaneActiveFilePathAtomFamily ( "ws-1" ) ) ) . toBeNull ( ) ;
2014+ expect ( store . get ( editorPaneActiveFilePathAtomFamily ( editorPaneStateKey ( "ws-1" , "root" ) ) ) ) . toBe (
2015+ null
2016+ ) ;
19872017 expect ( store . get ( openFilesAtomFamily ( "ws-1" ) ) ) . toEqual ( {
19882018 "src/app.tsx" : expect . objectContaining ( {
19892019 path : "src/app.tsx" ,
0 commit comments