Repository navigation
fix(ai-vault): group OMP task subagent transcripts under their parent session - #12803
Conversation
… session OMP persists task-child transcripts inside the parent session's same-named artifact directory (<stamp>_<uuid>/), and discovery scanned them as ordinary top-level sessions - a coordinator's history drowned under its own workers. Extend the existing Claude subagent model to OMP, classifying purely by the artifact-dir layout (never by a transcript's parentSession field, which also describes non-task lineage): - prune artifact dirs from the top-level scan (name-pattern predicate) - count direct-child transcripts onto the parent row (local readdir; remote walks partition their listing instead, mirroring Claude's SSH posture) - list children on demand via the existing listSubagentSessions IPC, titled by their coordinator-given task label and linked to the layout-derived parent id - refresh the count on zero-turn cache reuse, matching Claude - extract session-scanner-roots.ts so the renderer-supplied-path allowlist for both agents lives in one module Fixes stablyai#9330
📝 WalkthroughWalkthroughThe change adds OMP subagent transcript discovery, counting, partitioning, pruning, and on-demand listing. Shared session-root utilities now support Claude, OMP, and WSL paths. Remote sources use provider-specific partition callbacks. OMP artifact directories are excluded from top-level session discovery. IPC validation and dispatch now support OMP subagent sessions. Cache and resume-state logic refresh OMP subagent counts. Tests cover local, remote, nested, malformed, and dynamically created transcripts. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…anches Prune predicate now skips depth 0 (the workspace dir), so a workspace whose name happens to look like a session stem keeps its sessions. Drop degenerate OMP roots in ompSessionsRootDirs: OMP_CODING_AGENT_DIR='/' normalizes to '', which resolve()s to the process cwd and would have allowlisted it for the renderer-supplied subagent path. Rename session-scanner-omp-subagents.ts to -omp-subagent-transcripts.ts so it mirrors Claude's transcripts/lister split by role rather than inverting it. Correct two comments that asserted things the codebase contradicts: OMP task children do carry their own sessionId and would resume by path (OMP's own picker globs `*/*.jsonl`, so it never offers them either), and workspace dir names are not uniformly dash-prefixed. Cover branches the change added with no test: the remote/SSH partition wiring, the IPC `omp` gate and per-agent allowlist, the parse-cache zero-turn recount, and the executionHostId disk-ownership guard. Extract the remote scanner's in-memory provider into a fixtures module to stay under the max-lines cap.
Jinwoo-H
left a comment
There was a problem hiding this comment.
Thanks for this — the direction is right and the reasoning in the description held up under scrutiny.
I reproduced the issue end-to-end against a real OMP 17.2.9 store rather than reviewing the diff alone: a coordinator that delegated 3 tasks showed 11 top-level OMP rows on main (7 of them worker transcripts) vs 4 on this branch, with the coordinator carrying its count and expanding to list children by task label.
Two things that made me confident in the classification rule specifically:
- OMP's own bug-report bundler defines subagents as exactly "every
*.jsonldirectly inside<parentStem>/" — the same rule this implements. Spilled tool artifacts are always<id>.<label>.log, so they can't inflate the count. - OMP's own session picker globs
*/*.jsonl, one level deep, so it never offers these transcripts for resume either.
I also seeded a grandchild transcript, a local/ dir, a spilled .log, and a /tan fork into a real store — all classified correctly, and the badge count matched the expanded list in every case.
I pushed four review commits on top of yours:
- Security-relevant:
OMP_CODING_AGENT_DIR='/'normalizes to'', whichresolve()s to the process cwd — that would have silently allowlisted it for the renderer-supplied subagent path. Inert before, but this PR is what wires that constant into the IPC gate. Guarded inompSessionsRootDirs. - Hardening: the prune predicate now skips depth 0, so a workspace directory whose name happens to look like a session stem keeps its sessions.
- Naming: renamed the primitives module to
session-scanner-omp-subagent-transcripts.tsso it mirrors Claude's transcripts/lister split by role rather than inverting it (Claude's-subagents.tsis the lister). - Comments: corrected two that asserted things the codebase contradicts — notably that OMP task children "aren't independently resumable." They carry their own session id and
ai-vault-resume-command.tsresumes them by path. The prune is still right, just for a different reason. - Coverage for six branches the change added with no test — the remote/SSH partition wiring, the IPC
ompgate, the parse-cache zero-turn recount, and theexecutionHostIddisk-ownership guard. Two of those mutations were surviving silently.
Two carve-outs worth naming, since they're accepted rather than fixed: OMP task children lose an obscure resume path (they were resumable by file path; the row is view-only now), and grandchild transcripts become unreachable in the UI. I'm filing a follow-up to make subagent rows resumable, which closes both — the renderer already receives everything it needs and discards it.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/ipc/ai-vault.test.ts (1)
645-654: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAssert that both provider listers remain unused.
Line 645 checks only
listOmpSubagentSessions. A regression could calllistClaudeSubagentSessionsfor the remote OMP request without failing this test.Line 656 has the same gap for the cross-agent and traversal requests. Add a Claude no-call assertion after each test.
Proposed test strengthening
expect(mocks.listOmpSubagentSessions).not.toHaveBeenCalled() + expect(mocks.listClaudeSubagentSessions).not.toHaveBeenCalled() ... expect(mocks.listOmpSubagentSessions).not.toHaveBeenCalled() + expect(mocks.listClaudeSubagentSessions).not.toHaveBeenCalled()Also applies to: 656-673
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: bb10be1b-935f-4350-924d-bc1f84f3ccd1
📒 Files selected for processing (14)
src/main/ai-vault/remote-session-scanner-omp-subagents.test.tssrc/main/ai-vault/remote-session-scanner-sources.tssrc/main/ai-vault/remote-session-scanner-test-fixtures.tssrc/main/ai-vault/remote-session-scanner.test.tssrc/main/ai-vault/session-scanner-graph-parsers.tssrc/main/ai-vault/session-scanner-omp-subagent-listing.tssrc/main/ai-vault/session-scanner-omp-subagent-prune.test.tssrc/main/ai-vault/session-scanner-omp-subagent-transcripts.test.tssrc/main/ai-vault/session-scanner-omp-subagent-transcripts.tssrc/main/ai-vault/session-scanner-parse-cache.tssrc/main/ai-vault/session-scanner-roots.test.tssrc/main/ai-vault/session-scanner-roots.tssrc/main/ai-vault/session-scanner-source-discovery.tssrc/main/ipc/ai-vault.test.ts
🚧 Files skipped from review as they are similar to previous changes (5)
- src/main/ai-vault/session-scanner-parse-cache.ts
- src/main/ai-vault/remote-session-scanner-sources.ts
- src/main/ai-vault/session-scanner-source-discovery.ts
- src/main/ai-vault/session-scanner-omp-subagent-listing.ts
- src/main/ai-vault/session-scanner-graph-parsers.ts
|
thanks for reporting. looking into it |
… session (stablyai#12803) * fix(ai-vault): group OMP task subagent transcripts under their parent session OMP persists task-child transcripts inside the parent session's same-named artifact directory (<stamp>_<uuid>/), and discovery scanned them as ordinary top-level sessions - a coordinator's history drowned under its own workers. Extend the existing Claude subagent model to OMP, classifying purely by the artifact-dir layout (never by a transcript's parentSession field, which also describes non-task lineage): - prune artifact dirs from the top-level scan (name-pattern predicate) - count direct-child transcripts onto the parent row (local readdir; remote walks partition their listing instead, mirroring Claude's SSH posture) - list children on demand via the existing listSubagentSessions IPC, titled by their coordinator-given task label and linked to the layout-derived parent id - refresh the count on zero-turn cache reuse, matching Claude - extract session-scanner-roots.ts so the renderer-supplied-path allowlist for both agents lives in one module Fixes stablyai#9330 * review: harden OMP subagent classification and cover its uncovered branches Prune predicate now skips depth 0 (the workspace dir), so a workspace whose name happens to look like a session stem keeps its sessions. Drop degenerate OMP roots in ompSessionsRootDirs: OMP_CODING_AGENT_DIR='/' normalizes to '', which resolve()s to the process cwd and would have allowlisted it for the renderer-supplied subagent path. Rename session-scanner-omp-subagents.ts to -omp-subagent-transcripts.ts so it mirrors Claude's transcripts/lister split by role rather than inverting it. Correct two comments that asserted things the codebase contradicts: OMP task children do carry their own sessionId and would resume by path (OMP's own picker globs `*/*.jsonl`, so it never offers them either), and workspace dir names are not uniformly dash-prefixed. Cover branches the change added with no test: the remote/SSH partition wiring, the IPC `omp` gate and per-agent allowlist, the parse-cache zero-turn recount, and the executionHostId disk-ownership guard. Extract the remote scanner's in-memory provider into a fixtures module to stay under the max-lines cap. * review: note why child rows carry an unrendered grandchild count * review: describe the real OMP grandchild layout in the pattern comment --------- Co-authored-by: Dan Cieslak <[email protected]> Co-authored-by: Jinwoo-H <[email protected]>
What: OMP task-worker transcripts no longer flood Agent Session History as top-level rows — they're pruned from the scan, counted on their coordinator's row, and listed on demand under it, exactly like Claude's subagents since #7423.
Risk: Additive per-agent branches on existing seams; Claude behavior byte-identical (its partition/count/lister untouched, suites green); Pi/OpenClaw skip the new readdir explicitly.
State: Based on today's
main; tsc/lint clean; 8 new tests; ai-vault + IPC suites green.Fixes #9330. Implements the issue's suggested direction 1–5:
…/<workspace>/<stamp>_<uuid>.jsonl+…/<workspace>/<stamp>_<uuid>/<TaskLabel>.jsonl). The rigid<ISO-stamp>_<uuidv7>dir-name pattern is the classification signal.directoryPredicateseam Claude uses forsubagents/.finalizeClaudeSessionParseState); remote SSH walks partition their listing instead, so no extra round-trips. Zero-turn cache reuse refreshes the count, matching Claude.aiVault:listSubagentSessionsIPC now acceptsomp, with the same renderer-supplied-path allowlist posture (newompSessionsRootDirs). The renderer needed zero changes — it was already agent-agnostic behind the count.parentSession, per the issue's warning that lineage alone is insufficient evidence.Children are titled by their coordinator-given task label (the transcript filename stem — the analog of Claude's
meta.description) and linked to the layout-derived parent id, so a child with no session record of its own still lands under the right parent.Changes
src/main/ai-vault/session-scanner-omp-subagents.ts(new) — artifact-dir name pattern, direct-child count, remote-walk partition, and the parse-state decorator that attaches the count for local parses only.src/main/ai-vault/session-scanner-omp-subagent-listing.ts(new) — on-demand child lister (separate module so the graph parser can import the count decorator without a parser↔lister cycle).src/main/ai-vault/session-scanner-source-discovery.ts— prune predicate on the OMP discovery.src/main/ai-vault/session-scanner-graph-parsers.ts— OMP resume state wrapped with the count decorator; Pi/OpenClaw untouched.src/main/ai-vault/session-scanner-parse-cache.ts— zero-turn reuse recount extended from Claude-only to Claude+OMP.src/main/ai-vault/remote-session-scanner-{types,discovery,sources}.ts—collectSubagentSiblingCounts: booleangeneralized to an explicit per-sourcepartitionSubagentTranscriptsfunction; Claude keeps its partition, OMP gets its own.src/main/ipc/ai-vault.ts— subagent-listing gate acceptsclaude | omp, roots resolved per agent.src/main/ai-vault/session-scanner-roots.ts(new) — extracted home ofclaudeProjectsRootDirs/ompSessionsRootDirs(the renderer-supplied-path allowlists), keeping discovery and the IPC module under the lint line caps without weakening them.Tests
session-scanner-omp-subagents.test.ts— dir-name pattern boundaries, direct-child-only counting (nestedlocal/artifacts excluded), remote partition on posix and Windows separators, grandchild transcripts attribute to their nearest parent and never surface as candidates.session-scanner-omp-subagent-prune.test.ts— scan-level mirror of the Claude prune test: coordinator surfaces as the only row withsubagentTranscriptCountattached.session-scanner-omp-subagent-listing.test.ts— children listed newest-first, titled by task label, linked to the layout-derived parent id; never-delegated sessions resolve empty.Verified against a real OMP store
A coordinator session that spawned 6 task workers went from 7 top-level history rows to 1 — the coordinator row now carries a "6 subagents" count and expanding it lists all 6 children by task label, each linked to the parent session id.