Problem
When the Supervisor spawns subagents for complex tasks, a single user session can generate dozens of nested subagent sessions. Deleting the root session currently requires manual SQL — the opencode session delete command only removes the single session, leaving orphaned child sessions that still consume database space.
Example: A research task session spawned 42 nested subagent sessions. opencode session delete <root> deleted only the root — children survived as orphans with broken parent_id references.
The database schema has ON DELETE CASCADE on message, part, todo, session_message, session_input, and session_context_epoch, but parent_id has no FK constraint, so cascade deletion at the app level is necessary.
Proposed solution
opencode session delete --recursive <sessionID> — recursively deletes the session and all its descendant subagent sessions.
- Desktop UI — add a session management panel or right-click → Delete option in the TUI session list, with a confirmation dialog showing session count (e.g. "Delete this session and its 42 subagent sessions?").
Current workaround
sqlite3 ~/.local/share/opencode/opencode.db "
WITH RECURSIVE c AS (
SELECT id FROM session WHERE id = '<sessionID>'
UNION ALL
SELECT s.id FROM session s JOIN c ON s.parent_id = c.id
) DELETE FROM session WHERE id IN (SELECT id FROM c);
"
Impact
Anyone using the Supervisor with complex delegated tasks accumulates large session trees. Manual SQL deletion is error-prone and not accessible to non-technical users.
Problem
When the Supervisor spawns subagents for complex tasks, a single user session can generate dozens of nested subagent sessions. Deleting the root session currently requires manual SQL — the
opencode session deletecommand only removes the single session, leaving orphaned child sessions that still consume database space.Example: A research task session spawned 42 nested subagent sessions.
opencode session delete <root>deleted only the root — children survived as orphans with brokenparent_idreferences.The database schema has
ON DELETE CASCADEonmessage,part,todo,session_message,session_input, andsession_context_epoch, butparent_idhas no FK constraint, so cascade deletion at the app level is necessary.Proposed solution
opencode session delete --recursive <sessionID>— recursively deletes the session and all its descendant subagent sessions.Current workaround
Impact
Anyone using the Supervisor with complex delegated tasks accumulates large session trees. Manual SQL deletion is error-prone and not accessible to non-technical users.