fix(host-service): clean up exited terminals on workspace delete
Merged
KI
6mo ago+2+2+0123456789-2-2-0123456789
Summary
disposeSessionsByWorkspaceIdfiltered DB rows bystatus = "active", so any session whose row had drifted toexited(viapty.onExit) was skipped on workspace deletion- The in-memory
sessionsMap entry stayed behind in those cases — slow leak per workspace delete - Widened the filter to
status != "disposed"so zombie rows are picked up too.disposeSessionis already idempotent against a dead PTY (see comment atterminal.ts:271)
Terminals are intentionally persistent across most lifecycle events; this only changes behavior on the explicit workspace-delete path. Pane-deletion path is unaffected (it goes through disposeSession directly).
Test plan
- Create a workspace with a terminal, kill the PTY out-of-band so its row becomes
exited, then delete the workspace and confirm nosessionsMap entry remains - Normal workspace delete with a live terminal still kills the PTY
- Deleting a workspace with no terminals is a no-op
Summary by cubic
Clean up exited terminal sessions on workspace delete to prevent leftover in-memory sessions entries. disposeSessionsByWorkspaceId now disposes all rows where status != 'disposed' (using ne from drizzle-orm) instead of only active; pane deletion is unchanged.
Summary by CodeRabbit
- Bug Fixes
- Terminal session disposal has been improved to comprehensively clean up all inactive terminal sessions within a workspace. Previously, only sessions marked as active were targeted for disposal; the system now properly disposes all sessions that are not already disposed, preventing orphaned resources and ensuring more efficient workspace management.