DCP persists pruned state per session at ~/.local/share/opencode/storage/plugin/dcp/{sessionId}.json. When a session is deleted (via CLI or UI), the corresponding state file remains on disk indefinitely as an orphan. Over time these accumulate and waste space.
The opencode SDK already emits a session.deleted event with the session ID:
type EventSessionDeleted = {
type: "session.deleted";
properties: {
info: Session;
};
};
The existing event handler in lib/hooks.ts (createEventHandler) currently ignores all events except message.part.updated. Adding a session.deleted branch that unlinks the state file would fix this:
if (input.event.type === "session.deleted") {
const sessionId = input.event.properties.info?.id
if (sessionId) {
const filePath = join(STORAGE_DIR, `${sessionId}.json`)
await fs.unlink(filePath).catch(() => {})
}
return
}
Similarly, on plugin startup or when handling session.created, we could sweep orphaned state files for sessions that no longer exist in the DB.
DCP persists pruned state per session at
~/.local/share/opencode/storage/plugin/dcp/{sessionId}.json. When a session is deleted (via CLI or UI), the corresponding state file remains on disk indefinitely as an orphan. Over time these accumulate and waste space.The opencode SDK already emits a
session.deletedevent with the session ID:The existing
eventhandler inlib/hooks.ts(createEventHandler) currently ignores all events exceptmessage.part.updated. Adding asession.deletedbranch that unlinks the state file would fix this:Similarly, on plugin startup or when handling
session.created, we could sweep orphaned state files for sessions that no longer exist in the DB.