Repository navigation
Show Claude background task status in Native Chat - #18757
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthroughThe change adds Claude background-task tracking and monitoring state. It propagates that state through runtime adapters, session hosts, subscriber events, history, coalescing, and reduction. It adds scoped cancellation that stops tracked Claude tasks without cancelling the foreground turn. The renderer exposes monitoring state, displays a status bar, and provides a stop action. Tests cover tracking, cancellation, publication, state reduction, runtime integration, and renderer behavior. Merge Risk: 🟡 Moderate · up to Background-task monitoring can show completed or excluded tasks as active and offer Stop actions for them. Resolve the tracker lifecycle and aggregate-filtering issues before merge so task status and cancellation controls remain accurate. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 5.41% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 37 functions across 40 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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 |
There was a problem hiding this comment.
ℹ️ No critical issues — one wire-compatibility note inline.
Reviewed changes
- Claude background-task tracker — a new bounded state machine (
claude-background-task-tracker.ts) classifies SDKtask_started/task_updated/task_notification/background_tasks_changedframes into a single{ state: 'monitoring' } | nullsignal, with a terminal-id set that keeps terminal edges authoritative over out-of-order and late frames. - Stop path —
stopClaudeBackgroundTasksstops only the currently-backgrounded SDK task ids, guarded by a session/fence/generation ownership check;performCancelroutes the newscope: 'background-tasks'throughadapter.stopBackgroundTasksand writes no journal row. - Wire plumbing — additive
AgentSessionBackgroundTaskStatethreaded through the history page, subscribesnapshot/batch/resetevents, and a new optionalscopeonagentSession.cancel. - Host —
StructuredAgentSessionBackgroundTaskChannelcentralizes history/subscribe/publish; the Claude adapter emitsonBackgroundTasksChangedintohost.publishBackgroundTaskState. - Renderer —
isMonitoringBackgroundTasks(turnId === null && state.backgroundTasks?.state === 'monitoring') drives a newNativeChatBackgroundTasksStatusfooter above the composer; reducer and coalescer project/merge the field additively.
The tracker semantics against the real SDK contract check out: task_notification.status is always terminal (completed/failed/stopped), so unconditionally calling finish() there is correct, and task_updated.patch.status (pending/running/paused) is correctly excluded from the terminal set. Tests are focused and would actually fail with the bug present (exact stoppableTaskIds and state assertions, reference-equality check on duplicate publications).
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
| .object({ | ||
| envelope: MutationEnvelope, | ||
| turnId: Identifier('Invalid turn id'), | ||
| scope: z.literal('background-tasks').optional() |
There was a problem hiding this comment.
scope lands on a .strict() schema, but agentSession.cancel is a shared RPC that older hosts also register: an old host's z.object({ envelope, turnId }).strict() rejects the unknown scope key rather than ignoring it (repo Rule 1 assumes .strip()). This is unreachable today only because scope is sent solely from the footer, which renders only after the host has already published backgroundTasks — that implicit capability gate is what makes it safe, and it's worth a comment (or explicit negotiation) so a future change doesn't start sending scope unconditionally.
Electron visual proof — SHA
|
7e479b0 to
f446f70
Compare
There was a problem hiding this comment.
ℹ️ No new issues in this delta.
Reviewed changes
- Codex/Claude transcript-chrome parity test — a new
it.each(['codex', 'claude'])case inNativeChatStructuredSession.test.tsxasserts thatshowTurnStatusandruntimeContextare threaded throughNativeChatMessageListfor both agents, matching the component's unconditional prop pass-through. TheruntimeContextassertion (not.toBeUndefined()) is the right looseness here, since the unmockeduseNativeChatImageRuntimeContextresolves tonull(notundefined) in the happy-dom environment; assertingnullwould over-couple the test to store hydration state.
The delta is test-only and confined to NativeChatStructuredSession.test.tsx; no production behavior changed. The single open wire-compatibility note from the prior review is untouched by these commits.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: ffe48581-4308-4152-97a1-100f2d9bde37
📥 Commits
Reviewing files that changed from the base of the PR and between 8096cb2 and f446f7098b936fd6121c11a12cded89b2d6cfa17.
📒 Files selected for processing (39)
src/main/claude/claude-background-task-tracker.test.tssrc/main/claude/claude-background-task-tracker.tssrc/main/claude/claude-stream-json-connection.tssrc/main/claude/claude-structured-acquisition-release.tssrc/main/claude/claude-structured-control-actions.test.tssrc/main/claude/claude-structured-control-actions.tssrc/main/claude/claude-structured-dispatch.test.tssrc/main/claude/claude-structured-options.test.tssrc/main/claude/claude-structured-session-acquisition-processless.test.tssrc/main/claude/claude-structured-session-adapter.tssrc/main/claude/claude-structured-session-close.test.tssrc/main/claude/claude-structured-session-close.tssrc/main/claude/claude-structured-session-publication.tssrc/main/claude/claude-structured-session-state.tssrc/main/claude/claude-structured-session-test-support.tssrc/main/native-chat/agent-session-wire/structured-agent-session-adapter-router.tssrc/main/native-chat/agent-session-wire/structured-agent-session-adapter.tssrc/main/native-chat/agent-session-wire/structured-agent-session-background-task-channel.tssrc/main/native-chat/agent-session-wire/structured-agent-session-host-mutations.tssrc/main/native-chat/agent-session-wire/structured-agent-session-host.tssrc/main/native-chat/agent-session-wire/structured-agent-session-mutation-plans.tssrc/main/native-chat/agent-session-wire/structured-agent-session-subscribers.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-subscribers.tssrc/main/native-chat/agent-session-wire/structured-agent-session-turns.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-turns.tssrc/main/runtime/claude-structured-session-integration.test.tssrc/main/runtime/rpc/methods/structured-agent-session-schemas.tssrc/main/runtime/structured-agent-session-runtime.tssrc/main/runtime/structured-claude-runtime-adapter.tssrc/renderer/src/components/native-chat/NativeChatBackgroundTasksStatus.tsxsrc/renderer/src/components/native-chat/NativeChatStructuredSession.test.tsxsrc/renderer/src/components/native-chat/NativeChatStructuredSession.tsxsrc/renderer/src/components/native-chat/use-structured-agent-session.tssrc/renderer/src/i18n/locales/en.jsonsrc/shared/agent-session-wire.tssrc/shared/structured-agent-session-coalescer.test.tssrc/shared/structured-agent-session-coalescer.tssrc/shared/structured-agent-session-reducer.test.tssrc/shared/structured-agent-session-reducer.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.
| } | ||
| this.aggregateRosterObserved = true | ||
| this.tasks.clear() | ||
| this.terminalTaskIds.clear() |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Preserve terminal evidence during aggregate replacement.
Line 131 clears terminal evidence before the roster is rebuilt. A late roster that still contains a completed task then re-adds it. The monitoring footer returns and Stop can target an already completed task.
Keep bounded terminal IDs until clear(). Skip terminal IDs while rebuilding the roster. Add a regression case for task_notification followed by an aggregate roster containing the same ID.
Proposed fix
this.aggregateRosterObserved = true
this.tasks.clear()
- this.terminalTaskIds.clear()
for (const valueTask of value) {
@@
const id = taskId(task)
- if (!id) {
+ if (!id || this.terminalTaskIds.has(id)) {
continue
}Also applies to: 140-140
| break | ||
| } | ||
| const task = record(valueTask) | ||
| if (!task || task.ambient === true) { |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Exclude aggregate tasks marked skip_transcript.
The edge-frame path treats skip_transcript === true as finished. This aggregate path only excludes ambient tasks. An aggregate entry with skip_transcript: true becomes visible and stoppable despite the edge-path exclusion.
Filter task.skip_transcript === true here too. Add an aggregate-roster regression test.
Electron visual proof — SHA
|
f446f70 to
537f9ad
Compare
There was a problem hiding this comment.
ℹ️ No new issues in this delta — one prior note still open.
Reviewed changes
- Fence carry-forward on background-task publication —
AgentSessionSubscribers.backgroundTasks()now advancessubscriber.fenceto the published fence, mirroring the existinghandoff()pattern. Without it, the background-task batch advanced the renderer's fence but left the subscriber's own fence behind, so the next journalpublish()emitted a batch with a stale fence and regressed the renderer fence backwards. - Fence carry-forward test — the subscribers test appends a journal item after the background-task batch and asserts the follow-up batch carries
fence: 2; this fails against the pre-fix code. - Aggregate-roster-replaces-terminal-edge test — a new tracker test locks in that an authoritative
background_tasks_changedroster resurrects a task id a priortask_notificationmarked terminal. - Replacement-snapshot-clears-background-state test — a new reducer test documents that a full snapshot omitting
backgroundTasksclears the additive field toundefined.
The single production line mirrors handoff() exactly, and the three tests are discriminating rather than theatrical — exact stoppableTaskIds/state assertions plus a fence assertion that fails with the bug present. The only outstanding item is the .strict() scope wire-compat note from the prior review (structured-agent-session-schemas.ts:155), which these commits leave untouched.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Electron visual proof — SHA
|
916eed1 to
2220dac
Compare
There was a problem hiding this comment.
ℹ️ No new issues in this delta — one prior note still open.
Reviewed changes
- Timeout-bounded stop requests —
stopTaskmoved from an unboundedsession.stopTask(taskId)call onto the shared control surface, so everystop_tasknow runs underrunClaudeControl's deadline (default 30s) with the sameClaudeControlRequestErrorclassification as the other control methods. - Stop loop forwards the deadline —
stopClaudeBackgroundTasksacceptstimeoutMsand passes{ timeoutMs }to eachstopTask; the adapter suppliesthis.deps.requestTimeoutMs. - Lost-reply regression test — a new
claude-agent-sdk-control-requests.test.tscase pins that a never-resolving stop reply rejects withclaude stop_task request timed outwhile a subsequent request still resolves (per-call timer cleanup inrunClaudeControl's.finally).
The single open wire-compatibility note from prior reviews (.strict() scope on CancelParams) is untouched by these commits.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: 1091aca6-f4c0-4b6e-a0f6-5a6566ddd940
📥 Commits
Reviewing files that changed from the base of the PR and between f446f7098b936fd6121c11a12cded89b2d6cfa17 and 916eed1.
📒 Files selected for processing (9)
src/main/claude/claude-agent-sdk-control-requests.test.tssrc/main/claude/claude-agent-sdk-control-requests.tssrc/main/claude/claude-background-task-tracker.test.tssrc/main/claude/claude-structured-control-actions.test.tssrc/main/claude/claude-structured-control-actions.tssrc/main/claude/claude-structured-session-adapter.tssrc/main/native-chat/agent-session-wire/structured-agent-session-subscribers.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-subscribers.tssrc/shared/structured-agent-session-reducer.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
| tracker.observe(system('task_updated', { task_id: 'task-live', patch: { status: 'killed' } })) | ||
| ).toBe(true) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Ignore delayed background updates after a terminal event.
ClaudeBackgroundTaskTracker records terminal task IDs, but its task_updated background branch does not check that set before it re-adds a task. Without an aggregate roster, a delayed { is_backgrounded: true } update can restore monitoring for a completed task. Reject background patches for terminal IDs and add this replay case.
Electron visual proof — SHA
|
Final review status — readyReviewed and validated at exact head
Residual validation gaps: a live mixed-version pairing, SSH/remote runtime, mobile, a second overlapping turn, and a deliberately hung provider-control reply were not exercised end-to-end. The additive wire behavior, bounded timeout recovery, and relevant compatibility paths are covered by automated tests; this PR does not change a mobile-facing surface. |
2220dac to
76351da
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: 53f0b9ff-c5af-4085-aebd-9964c0017bdd
📒 Files selected for processing (12)
src/main/claude/claude-background-task-tracker.test.tssrc/main/claude/claude-background-task-tracker.tssrc/main/claude/claude-structured-session-close.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-subscribers.test.tssrc/renderer/src/components/native-chat/NativeChatBackgroundTasksStatus.tsxsrc/renderer/src/components/native-chat/NativeChatStructuredSession.test.tsxsrc/renderer/src/components/native-chat/NativeChatStructuredSession.tsxsrc/renderer/src/components/native-chat/use-structured-agent-session.tssrc/shared/agent-session-wire.tssrc/shared/structured-agent-session-coalescer.test.tssrc/shared/structured-agent-session-reducer.test.tssrc/shared/structured-agent-session-reducer.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.
| (patch.is_backgrounded === true || taskDescription(patch.description)) && | ||
| (!this.aggregateRosterObserved || existing) | ||
| ) { | ||
| this.upsert(id, { |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Reject terminal task updates before upsert. A delayed task_updated with patch.is_backgrounded === true can recreate monitoring for an ID already recorded in terminalTaskIds, because this branch runs before the terminal-ID guard used by task_started. With no aggregate roster observed, the completed task can reappear in stoppableTaskIds. Return early for terminal IDs before calling upsert.
There was a problem hiding this comment.
Important
The new background-task labels are missing from en.json, so the verify:localization-extraction CI gate fails and these strings stay English in all five non-English locales.
Reviewed changes
- Task detail tracking —
ClaudeBackgroundTaskTrackernow stores each task'skindand a whitespace-normalized, 512-char-cappeddescription, and publishes a boundedtasks: AgentSessionBackgroundTask[]alongside the{ state: 'monitoring' }signal, deduplicating via a string fingerprint so an unchanged roster does not re-publish. - Expandable footer —
NativeChatBackgroundTasksStatusrenders a disclosure (aria-expanded/aria-controls) that lists running tasks by description, falling back to a kind label, with a "details unavailable" state for hosts that publish state-only. - Wire & reducer deep-compare —
AgentSessionBackgroundTaskState.tasksis threaded additively through the history page, subscribesnapshot/batch/resetevents, the coalescer (newest-wins), and the reducer (deep-equality, so a roster-only change updatesbackgroundTaskswithout rebuilding transcript identity).
The tracker and reducer changes are correct and well-tested: the description-only task_updated path preserves backgrounded, terminal states still take precedence, the fingerprint stays deterministic under Map insertion order, and the new reducer/coalescer tests fail against the pre-change code. The tasks array itself is additive and host-authored, so it does not reintroduce the prior client-to-host wire-compatibility concern.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
ℹ️ No new issues in this delta — one prior wire-compat note still open.
Reviewed changes
- Tracker observe hardening —
observe()andobserveSystemFrame()now return a boolean and short-circuit, so stream frames that neither start a turn nor mutate task state no longer reach theJSON.stringifyfingerprint inrefreshMonitoring(). - Progress-frame contract pinned — a
task_progressassertion now locks in that progress-only system frames returnfalse(no publish). - Localization fix — the seven missing
components.native-chat.backgroundTasks.*keys are added toen.json, resolving the prior must-fix localization-extraction failure.
The short-circuit is sound: every mutation path (result, background_tasks_changed, task_notification, terminal task_updated, task_started, startsTurn, clear) still reaches refreshMonitoring(), and each observeSystemFrame early return corresponds exactly to a no-mutation path, so no state transition is skipped. The en.json additions cover all seven keys the component statically references.
The only open item is the .strict() scope wire-compat note from the prior review (structured-agent-session-schemas.ts:155), which this delta leaves untouched.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Electron visual proof — SHA
|
Final review status — readyReviewed and validated at exact HEAD
No further action is required before merge. |
* feat(native-chat): show Claude background task status * fix(native-chat): carry background task fence forward * fix(claude): bound background task stop requests * Show running Claude background task details * Harden Claude background task status updates --------- Co-authored-by: Merge Sim <sim@local>












ELI5
When Claude keeps tasks running after it finishes replying, Native Chat now shows a small status footer above the composer. Click it to see what is running, keep chatting normally, or stop only the background work.
What Changed
Why
Background work previously continued without a clear Native Chat status or scoped stop action. The implementation follows the SDK lifecycle as the source of truth, keeps the normal composer usable, and confines cancellation to the provider task IDs that are actually running.
Linked Issue
Follow-up to #18560.
Visual Proof
Validated in an isolated Electron instance on exact SHA
516cf64abf8cd64da5c954f35386dc81c7294a25with a real Claude Agent SDK session and live background process.Full Electron validation and process evidence
Collapsed:
Expanded task details:
After Stop:
Testing
Verification:
pnpm tcpnpm run check:code-quality:changed— zero code-quality, type-aware, and React Doctor findingsgit diff --checkAI Disclosure
Review
Same-model review-until-clean completed on the pushed semantic diff through three final passes. Proven lifecycle and performance issues were fixed with regression coverage: subscriber-fence rollback, an unbounded provider control request, and needless roster serialization for irrelevant SDK frames. The English localization catalog was synchronized. The final pass found no remaining in-scope correctness, lifecycle, compatibility, accessibility, localization, or performance issues.
Agent skill upstream boundary
Notes
Checklist