Skip to content

feat(web): retain finished subagents across hydration - #922

Merged
chuks-qua merged 1 commit into
mainfrom
codex/issue-918-finished-subagents
Jul 22, 2026
Merged

chuks-qua merged 1 commit into
mainfrom
codex/issue-918-finished-subagents

Conversation

@chuks-qua

@chuks-qua chuks-qua commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

What

Keep settled delegated work inspectable in the Subagents panel after completion, thread switching, and hydration.

Why

Finished subagents disappeared when volatile narrative state settled. This completes the second tracer-bullet slice of #916 and unblocks #919.

Key Changes

  • Reconcile live and hydrated subagent records by stable tool-call identity.
  • Show completed, failed, and cancelled work in a dedicated Finished roster with status, result, elapsed duration, and terminal-time ordering.
  • Persist lifecycle timestamps through narrative settlement and repository hydration.
  • Keep Active or Finished selection per thread and clear it when a thread is deleted.
  • Add focused server, projection, store, and component coverage.

Verification

  • Live Browser: observed one delegated row move from Active to Finished with a 20-second duration and its result.
  • Live Browser: switched to another thread and observed an empty Finished roster, then returned to the original row.
  • Live Browser: reloaded the app and observed the Finished tab, completed status, duration, task, and result restored from persistence.
  • Focused tests: 122 passed across the affected server and web suites.
  • bun run verify: passed all typecheck, lint, unit-test, and agent-script gates.

Visual Evidence

Active roster before settlement:

Active subagent roster

Finished roster after settlement:

Finished subagent roster

Thread isolation with an empty Finished roster:

Thread-isolated subagent roster

Hydrated restoration after a full reload:

Hydrated finished subagent roster

Closes #918

@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Tool-call lifecycle timestamps are now persisted during narrative storage. The web Subagents roster reconciles live calls with hydrated records into active and finished rows, renders terminal statuses, and remembers the selected roster tab independently for each thread.

Changes

Subagent lifecycle and roster

Layer / File(s) Summary
Persist tool-call lifecycle timestamps
apps/server/src/repositories/tool-call-record-repo.ts, apps/server/src/services/narrative-store.ts, apps/server/src/**/__tests__/*
Repository inputs preserve explicit startedAt and completedAt values, while NarrativeStore records completion and settlement timestamps. Tests verify persisted timestamps and durations.
Reconcile active and finished subagents
apps/web/src/components/subagents/subagent-projection.ts, apps/web/src/components/subagents/__tests__/*
projectSubagents merges live calls with hydrated narrative records, derives terminal status and timing, removes duplicates, and sorts active and finished rows deterministically.
Render roster views and persist tab selection
apps/web/src/components/panels/SubagentsPanel.tsx, apps/web/src/stores/diffStore.ts, apps/web/src/components/panels/__tests__/*, apps/web/src/__tests__/diffStore.test.ts
The panel renders finished statuses and separate empty states, while the store remembers each thread’s selected tab and clears it with the thread.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related issues

Possibly related PRs

  • Mzeey-Empire/mcode#902 — Directly relates to persisted tool-call lifecycle timestamps used for duration and hydration.
  • Mzeey-Empire/mcode#921 — Modifies the Subagents roster and projection flow that this PR refactors.

Poem

A rabbit watched timestamps bloom,
While agents hopped from active room.
Finished rows wore badges bright,
Tabs remembered threads just right.
Hydrated tales kept every trace—
“Well done!” twitched one whiskered face.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 21.05% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes satisfy #918 by adding finished-state hydration, terminal statuses, sorting, deduplication, tab restoration, and coverage.
Out of Scope Changes check ✅ Passed The diff stays focused on subagent hydration, persistence, UI, and tests, with no clearly unrelated changes.
Title check ✅ Passed The title is concise and clearly summarizes the main change: retaining finished subagents across hydration.
Description check ✅ Passed The description covers What, Why, Key Changes, verification, and evidence, so it is mostly complete for the template.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chuks-qua
chuks-qua merged commit 6fcb0bb into main Jul 22, 2026
10 checks passed
@chuks-qua
chuks-qua deleted the codex/issue-918-finished-subagents branch July 22, 2026 07:34
@mze-bot mze-bot Bot mentioned this pull request Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: retain finished subagents across hydration

1 participant