@@ -133,9 +133,12 @@ function EmptyCell({ cellIndex }: { cellIndex: number }) {
133133 setBrainrotCell ( cellIndex ) ;
134134 } , [ layout , cells , setBrainrotCell , cellIndex ] ) ;
135135
136- const handleNewTerminal = useCallback ( ( ) => {
137- setTerminalCell ( cellIndex , secureRandomString ( 8 ) ) ;
138- } , [ setTerminalCell , cellIndex ] ) ;
136+ const handleNewTerminal = useCallback (
137+ ( cwd ?: string ) => {
138+ setTerminalCell ( cellIndex , secureRandomString ( 8 ) , cwd ) ;
139+ } ,
140+ [ setTerminalCell , cellIndex ] ,
141+ ) ;
139142
140143 const handleTaskCreated = useCallback (
141144 ( task : Task ) => {
@@ -279,13 +282,15 @@ function BrainrotCell({ cellIndex }: { cellIndex: number }) {
279282function TerminalCell ( {
280283 cellIndex,
281284 terminalId,
285+ terminalCwd,
282286} : {
283287 cellIndex : number ;
284288 terminalId : string ;
289+ terminalCwd : string | null ;
285290} ) {
286291 const clearCell = useCommandCenterStore ( ( s ) => s . clearCell ) ;
287292 const { getRecentFolders, getFolderDisplayName } = useFolders ( ) ;
288- const cwd = getRecentFolders ( 1 ) [ 0 ] ?. path ;
293+ const cwd = terminalCwd ?? getRecentFolders ( 1 ) [ 0 ] ?. path ;
289294 const folderName = cwd ? getFolderDisplayName ( cwd ) : null ;
290295 const stateKey = getTerminalCellStateKey ( terminalId ) ;
291296
@@ -413,7 +418,11 @@ export function CommandCenterPanel({
413418
414419 if ( cell . terminalId ) {
415420 return (
416- < TerminalCell cellIndex = { cell . cellIndex } terminalId = { cell . terminalId } />
421+ < TerminalCell
422+ cellIndex = { cell . cellIndex }
423+ terminalId = { cell . terminalId }
424+ terminalCwd = { cell . terminalCwd }
425+ />
417426 ) ;
418427 }
419428
0 commit comments