Repository navigation
Closed
Labels
enhancementNew feature or requestinfraInfrastructure, CI, tooling, or release workpriority:mediumMedium priority
Description
Parent: #217 (delta 2 of 4).
Prerequisite for #217 delta 1 (worker_ tools).*
Problem
`parentID` on `Session.Info` currently entangles three behaviors that should be independent:
- Default session listing filters with `roots: true` — children are hidden from the UI session list.
- `packages/app/src/context/global-sync/session-load.ts:5`
- `packages/opencode/src/session/session.ts:842` (`listByProject` applies `isNull(parent_id)` when `roots: true`)
- Removing a session cascade-deletes its children.
- `packages/opencode/src/session/session.ts:561-563`
- Default title is auto-prefixed `"Child session - "`.
- `packages/opencode/src/session/session.ts:511`
This is correct for `task`-tool subagents but blocks the manager/worker model from #217, where a worker session needs to:
- be visible in the session list,
- survive the manager being deleted/archived,
- have a meaningful title.
Proposed change
Add an opt-out flag on `Session.Info`. Strawman:
```ts
// session/schema.ts ~line 186
isWorker: Schema.optional(Schema.Boolean) // or: detachedChild
```
Behavioral semantics when `isWorker === true`:
| Call site | Current behavior | New behavior |
|---|---|---|
| `listByProject({ roots: true })` (`session.ts:842`) | excluded | included (treat as a root for listing) |
| `Session.remove(parent)` cascade (`session.ts:561-563`) | child deleted | child preserved, optionally re-parented or orphaned |
| Title generation (`session.ts:511`) | `"Child session - …"` | use provided title, no prefix |
`Session.create` accepts the new flag; `task` tool keeps current behavior (does not set the flag). Worker spawn (see #217 delta 1) sets the flag.
Acceptance criteria
- `isWorker` (or chosen name) added to schema + Drizzle table.
- `listByProject` returns isWorker rows even when `roots: true`.
- `Session.remove` does not cascade-delete isWorker children.
- Default title generation skips the child prefix for isWorker sessions.
- Migration handles existing rows (default `false`).
- Test: create manager → create isWorker child → remove manager → assert worker still exists and is listed.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestinfraInfrastructure, CI, tooling, or release workpriority:mediumMedium priority
Activity