From 7bba7f437c96e42f820b5888fdf0385ffb671e59 Mon Sep 17 00:00:00 2001 From: Jason Matthew Suhari Date: Sat, 11 Apr 2026 02:38:35 +0800 Subject: [PATCH] fix(cli): pass session id to interactive shell executions (#25114) --- .../ui/hooks/useExecutionLifecycle.test.tsx | 24 ++++++++++++++++++- .../cli/src/ui/hooks/useExecutionLifecycle.ts | 1 + 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/ui/hooks/useExecutionLifecycle.test.tsx b/packages/cli/src/ui/hooks/useExecutionLifecycle.test.tsx index 34d05ebc70..f802fe849b 100644 --- a/packages/cli/src/ui/hooks/useExecutionLifecycle.test.tsx +++ b/packages/cli/src/ui/hooks/useExecutionLifecycle.test.tsx @@ -133,6 +133,7 @@ describe('useExecutionLifecycle', () => { mockConfig = { getTargetDir: () => '/test/dir', getEnableInteractiveShell: () => false, + getSessionId: () => 'test-session-id', getShellExecutionConfig: () => ({ terminalHeight: 20, terminalWidth: 80, @@ -246,11 +247,32 @@ describe('useExecutionLifecycle', () => { expect.any(Function), expect.any(Object), false, - expect.any(Object), + expect.objectContaining({ + sessionId: 'test-session-id', + }), ); expect(onExecMock).toHaveBeenCalledWith(expect.any(Promise)); }); + it('should pass the config sessionId into shell execution config', async () => { + const { result } = await renderProcessorHook(); + + await act(async () => { + result.current.handleShellCommand('top', new AbortController().signal); + }); + + expect(mockShellExecutionService).toHaveBeenCalledWith( + expect.any(String), + '/test/dir', + expect.any(Function), + expect.any(Object), + false, + expect.objectContaining({ + sessionId: 'test-session-id', + }), + ); + }); + it('should handle successful execution and update history correctly', async () => { const { result } = await renderProcessorHook(); diff --git a/packages/cli/src/ui/hooks/useExecutionLifecycle.ts b/packages/cli/src/ui/hooks/useExecutionLifecycle.ts index 2e80bf8f95..d1fab89df8 100644 --- a/packages/cli/src/ui/hooks/useExecutionLifecycle.ts +++ b/packages/cli/src/ui/hooks/useExecutionLifecycle.ts @@ -409,6 +409,7 @@ export const useExecutionLifecycle = ( const activeTheme = themeManager.getActiveTheme(); const shellExecutionConfig = { ...config.getShellExecutionConfig(), + sessionId: config.getSessionId(), terminalWidth, terminalHeight, defaultFg: activeTheme.colors.Foreground,