mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
fix(terminal): remove terminals that exit cleanly
A shell that exits with code 0 is now deleted and its tab removed, and the terminal panel closes when it was the last one. Non-zero exits keep their tab and output.
This commit is contained in:
1 parent
36b8c1b200
commit
8277ec253e
4 files changed
+160
-25
No files matched your search
@@ -33,7 +33,12 @@ vi.mock('@/components/source-control/RemoteSourceControlContent', () => ({
|
||||
),
|
||||
}))
|
||||
vi.mock('@/components/terminal/TerminalPanel', () => ({
|
||||
TerminalWorkspace: () => <div>terminal-tool</div>,
|
||||
TerminalWorkspace: ({ onLastTerminalExited }: { onLastTerminalExited?: () => void }) => (
|
||||
<div>
|
||||
terminal-tool
|
||||
<button type="button" onClick={onLastTerminalExited}>Exit last terminal</button>
|
||||
</div>
|
||||
),
|
||||
}))
|
||||
vi.mock('@/components/preview/PreviewPanel', () => ({ PreviewWorkspace: () => <div>preview-tool</div> }))
|
||||
vi.mock('@/components/schedules/RepoSchedulesContent', () => ({
|
||||
@@ -322,6 +327,16 @@ describe('ToolSidePanel', () => {
|
||||
expect(search().has('terminal')).toBe(false)
|
||||
})
|
||||
|
||||
it('closes the docked terminal panel when the last terminal exits', async () => {
|
||||
const user = userEvent.setup()
|
||||
renderAt('?panel=terminal&terminal=pty-1')
|
||||
|
||||
await user.click(await screen.findByRole('button', { name: 'Exit last terminal' }))
|
||||
|
||||
await waitFor(() => expect(search().has('panel')).toBe(false))
|
||||
expect(search().has('terminal')).toBe(false)
|
||||
})
|
||||
|
||||
it('falls back to the dialog when not docked', async () => {
|
||||
renderAt('?panel=sourceControl', false)
|
||||
|
||||
|
||||
@@ -211,7 +211,7 @@ export function ToolSidePanel({
|
||||
if (tool === 'activity') return <ActivityPanelBody />
|
||||
if (tool === 'terminal') {
|
||||
return terminalWorkspaceTarget
|
||||
? <TerminalWorkspace target={terminalWorkspaceTarget} directory={terminalDirectory ?? directory} isOpen />
|
||||
? <TerminalWorkspace target={terminalWorkspaceTarget} directory={terminalDirectory ?? directory} isOpen onLastTerminalExited={closePanel} />
|
||||
: null
|
||||
}
|
||||
if (tool === 'skills') {
|
||||
|
||||
Reference in new issue
Block a user