Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/components/terminal/terminal-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,24 @@ export function TerminalPanel({ isMobile }: TerminalPanelProps) {
)
continue
}
if (currentEvent === 'exit' || currentEvent === 'close') {
// Server reported the PTY is gone. Clear the tab's sessionId so
// any subsequent /api/terminal-input or /api/terminal-resize
// calls don't fire against a dead session and 404. (#80)
const exitInfo =
currentEvent === 'exit' && typeof payload === 'object'
? ` (exit code ${payload?.code ?? '?'}${payload?.signal ? `, signal ${payload.signal}` : ''})`
: ''
terminal.writeln(`\r\n\x1b[2m[session ended${exitInfo}]\x1b[0m`)
terminal.writeln(`\x1b[2m[click + to open a new tab, or reload to retry]\x1b[0m`)
setTabs((prev) =>
prev.map((tab) =>
tab.id === tabId ? { ...tab, sessionId: undefined } : tab,
),
)
sessionId = undefined
continue
}
if (currentEvent === 'data') {
const textChunk =
payload?.data ??
Expand Down
Loading