Skip to content

Show Claude background task status in Native Chat - #18757

Merged
brennanb2025 merged 5 commits into
mainfrom
brennanb2025/claude-native-monitoring-footer
Sep 5, 2026
Merged

brennanb2025 merged 5 commits into
mainfrom
brennanb2025/claude-native-monitoring-footer

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​773 $\color{#cf222e}{\Huge{\mathbf{−}}}$​5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​768
Prod 27 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​793 $\color{#cf222e}{\Huge{\mathbf{−}}}$​55 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​738

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

  • detect Claude Agent SDK background-task lifecycle state with a bounded tracker
  • publish additive, optional monitoring state through the structured-session wire path
  • render a footer directly above the enabled composer: monitoring icon → “Monitoring background tasks” → chevron → Stop
  • expand the status area on click to show a bounded list of live task descriptions
  • stop active background tasks without cancelling the foreground chat turn or adding a cancellation transcript row
  • preserve runtime fences and clear monitoring state across completion, teardown, and old-host snapshots

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 516cf64abf8cd64da5c954f35386dc81c7294a25 with a real Claude Agent SDK session and live background process.

Full Electron validation and process evidence

Collapsed:

Collapsed monitoring footer

Expanded task details:

Expanded running task details

After Stop:

Footer cleared with composer still enabled

Testing

  • I manually tested these changes locally
  • Automated tests added/updated

Verification:

  • 173 tests across the 17 changed test files; final clean-review delta rerun: 59 tests across 7 focused files
  • pnpm tc
  • pnpm run check:code-quality:changed — zero code-quality, type-aware, and React Doctor findings
  • git diff --check
  • Electron/CDP validation on macOS with a real SDK background task
  • CI covers static analysis, typecheck, cross-version wire compatibility, all test shards, and Windows/Linux packaging

AI 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

  • Not applicable; this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Security: no dependency, credential, shell-evaluation, or new network surface
  • Cross-platform: shared structured-session and renderer paths; Windows package CI included
  • SSH/remote: execution remains host-owned; optional wire state preserves mixed-version behavior
  • Mobile: no mobile-facing surface touched
  • Backward compatibility: new wire state and cancel scope are optional and capability-gated; old-host snapshot clearing is covered
  • Performance: no polling, subprocess churn, or unbounded state; tracking is capped, and provider control requests use a cleared, unref'd timeout

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots attached
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and compatibility impact considered
  • Changed-file quality, typecheck, focused tests, and applicable CI checks pass

@coderabbitai

coderabbitai Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: e98fc160-299f-4494-9739-cc61d966ebd3

📥 Commits

Reviewing files that changed from the base of the PR and between 76351da and 516cf64.

📒 Files selected for processing (3)
  • src/main/claude/claude-background-task-tracker.test.ts
  • src/main/claude/claude-background-task-tracker.ts
  • src/renderer/src/i18n/locales/en.json
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/main/claude/claude-background-task-tracker.test.ts
  • src/renderer/src/i18n/locales/en.json

Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review.


📝 Walkthrough

Walkthrough

The 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 516cf

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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning 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: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the primary change: displaying Claude background-task status in Native Chat.
Description check ✅ Passed The description is complete and relevant. It includes ELI5, changes, rationale, linked issue, visual proof, testing, review notes, compatibility considerations, and checklist results.
Full details: Docstring Coverage

Explanation

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.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ 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 SDK task_started/task_updated/task_notification/background_tasks_changed frames into a single { state: 'monitoring' } | null signal, with a terminal-id set that keeps terminal edges authoritative over out-of-order and late frames.
  • Stop path — stopClaudeBackgroundTasks stops only the currently-backgrounded SDK task ids, guarded by a session/fence/generation ownership check; performCancel routes the new scope: 'background-tasks' through adapter.stopBackgroundTasks and writes no journal row.
  • Wire plumbing — additive AgentSessionBackgroundTaskState threaded through the history page, subscribe snapshot/batch/reset events, and a new optional scope on agentSession.cancel.
  • Host — StructuredAgentSessionBackgroundTaskChannel centralizes history/subscribe/publish; the Claude adapter emits onBackgroundTasksChanged into host.publishBackgroundTaskState.
  • Renderer — isMonitoringBackgroundTasks (turnId === null && state.backgroundTasks?.state === 'monitoring') drives a new NativeChatBackgroundTasksStatus footer 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).

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

.object({
envelope: MutationEnvelope,
turnId: Identifier('Invalid turn id'),
scope: z.literal('background-tasks').optional()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron visual proof — SHA 7e479b089b4

Scenario. Isolated Orca dev instance from this worktree on 7e479b089b480924f6fd1c0e5f69ee6248731953. Launched a real Claude Agent SDK structured Native Chat session, sent a prompt that backgrounded sleep 180 with run_in_background=true, and waited until the foreground turn settled (BACKGROUND_STARTED) while the bash task kept running.

Visible assertions (before Stop).

  • Footer sits immediately above the bottom composer.
  • Footer shows the monitoring status icon (aria-label="Monitoring background tasks"), the text Monitoring background tasks, and a trailing Stop.
  • Composer stays enabled: draft accepted, Send affordance is the normal up-arrow (not the working Stop square).

01-before-stop-full.png

Visible assertions (after Stop via the rendered footer button).

  • Footer clears.
  • Composer remains enabled with the same draft and Send affordance.
  • Transcript is unchanged: user prompt, 1× Bash sleep 180, BACKGROUND_STARTED. No cancellation/interrupt status row was inserted.

02-after-stop-full.png

Backing state.

  • Before Stop: Claude SDK child 80149 of this Electron instance, with descendant sleep 180 pid 87668.
  • After footer Stop: 87668 and its zsh wrapper exited immediately; Claude session process 80149 stayed alive. DOM: [data-native-chat-background-tasks] gone; no cancelled/canceled text in the pane.

Unverified gap. Not exercised: mixed-version clients, SSH/remote hosts, mobile, or a second overlapping turn while monitoring. Dictation control stayed disabled in this isolated profile and is unrelated to the footer.

Result: pass.

@brennanb2025
brennanb2025 force-pushed the brennanb2025/claude-native-monitoring-footer branch from 7e479b0 to f446f70 Compare September 5, 2026 00:46

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No new issues in this delta.

Reviewed changes

  • Codex/Claude transcript-chrome parity test — a new it.each(['codex', 'claude']) case in NativeChatStructuredSession.test.tsx asserts that showTurnStatus and runtimeContext are threaded through NativeChatMessageList for both agents, matching the component's unconditional prop pass-through. The runtimeContext assertion (not.toBeUndefined()) is the right looseness here, since the unmocked useNativeChatImageRuntimeContext resolves to null (not undefined) in the happy-dom environment; asserting null would 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.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts
  • src/main/claude/claude-background-task-tracker.ts
  • src/main/claude/claude-stream-json-connection.ts
  • src/main/claude/claude-structured-acquisition-release.ts
  • src/main/claude/claude-structured-control-actions.test.ts
  • src/main/claude/claude-structured-control-actions.ts
  • src/main/claude/claude-structured-dispatch.test.ts
  • src/main/claude/claude-structured-options.test.ts
  • src/main/claude/claude-structured-session-acquisition-processless.test.ts
  • src/main/claude/claude-structured-session-adapter.ts
  • src/main/claude/claude-structured-session-close.test.ts
  • src/main/claude/claude-structured-session-close.ts
  • src/main/claude/claude-structured-session-publication.ts
  • src/main/claude/claude-structured-session-state.ts
  • src/main/claude/claude-structured-session-test-support.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-adapter-router.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-adapter.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-background-task-channel.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-host-mutations.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-host.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-mutation-plans.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-subscribers.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-subscribers.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-turns.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-turns.ts
  • src/main/runtime/claude-structured-session-integration.test.ts
  • src/main/runtime/rpc/methods/structured-agent-session-schemas.ts
  • src/main/runtime/structured-agent-session-runtime.ts
  • src/main/runtime/structured-claude-runtime-adapter.ts
  • src/renderer/src/components/native-chat/NativeChatBackgroundTasksStatus.tsx
  • src/renderer/src/components/native-chat/NativeChatStructuredSession.test.tsx
  • src/renderer/src/components/native-chat/NativeChatStructuredSession.tsx
  • src/renderer/src/components/native-chat/use-structured-agent-session.ts
  • src/renderer/src/i18n/locales/en.json
  • src/shared/agent-session-wire.ts
  • src/shared/structured-agent-session-coalescer.test.ts
  • src/shared/structured-agent-session-coalescer.ts
  • src/shared/structured-agent-session-reducer.test.ts
  • src/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()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron visual proof — SHA f446f7098b9

Scenario. Isolated Orca dev instance from this worktree on f446f7098b936fd6121c11a12cded89b2d6cfa17. App identity: Orca: brennanb2025/claude-native-monitoring-footer, devRepoRoot = this worktree, devBranch = brennanb2025/claude-native-monitoring-footer. Launched a real Claude Agent SDK structured Native Chat session, sent a prompt that backgrounded sleep 180 with run_in_background=true, and waited until the foreground turn settled (BACKGROUND_STARTED) while the bash task kept running.

Visible assertions (before Stop).

  • Footer sits immediately above the bottom composer.
  • Footer shows the monitoring status icon (aria-label="Monitoring background tasks"), the text Monitoring background tasks, and a trailing Stop.
  • Composer stays enabled: draft accepted, Send affordance is the normal up-arrow (not the working Stop square).

01-before-stop-full.png

Visible assertions (after Stop via the rendered footer button).

  • Footer clears.
  • Composer remains enabled with the same draft and Send affordance.
  • Transcript is unchanged: user prompt, BACKGROUND_STARTED. No cancellation/interrupt status row was inserted.

02-after-stop-full.png

Backing state.

  • Before Stop: Claude SDK child 18617 of this Electron instance, with descendant sleep 180 pid 26173.
  • After footer Stop: 26173 and its zsh wrapper 26168 exited immediately; Claude session process 18617 stayed alive. DOM: [data-native-chat-background-tasks] gone; no cancelled/canceled text in the pane.

Unverified gap. Not exercised: mixed-version clients, SSH/remote hosts, mobile, or a second overlapping turn while monitoring. Dictation control stayed disabled in this isolated profile and is unrelated to the footer.

Result: pass.

@brennanb2025
brennanb2025 force-pushed the brennanb2025/claude-native-monitoring-footer branch from f446f70 to 537f9ad Compare September 5, 2026 01:11

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No new issues in this delta — one prior note still open.

Reviewed changes

  • Fence carry-forward on background-task publication — AgentSessionSubscribers.backgroundTasks() now advances subscriber.fence to the published fence, mirroring the existing handoff() pattern. Without it, the background-task batch advanced the renderer's fence but left the subscriber's own fence behind, so the next journal publish() 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_changed roster resurrects a task id a prior task_notification marked terminal.
  • Replacement-snapshot-clears-background-state test — a new reducer test documents that a full snapshot omitting backgroundTasks clears the additive field to undefined.

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.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron visual proof — SHA 537f9ad301c4ed84770db45d4476c70bca516eea

Scenario. Isolated Orca dev instance from this worktree on 537f9ad301c4ed84770db45d4476c70bca516eea. App identity: Orca: brennanb2025/claude-native-monitoring-footer, devRepoRoot = this worktree, devBranch = brennanb2025/claude-native-monitoring-footer. Launched a real Claude Agent SDK structured Native Chat session, sent a prompt that backgrounded sleep 180 with run_in_background=true, and waited until the foreground turn settled (BACKGROUND_STARTED) while the bash task kept running.

Visible assertions (before Stop).

  • Footer sits immediately above the bottom composer.
  • Footer shows the monitoring status icon (aria-label="Monitoring background tasks"), the text Monitoring background tasks, and a trailing Stop.
  • Composer stays enabled: draft accepted, Send affordance is the normal up-arrow (not the working Stop square).

01-before-stop-full.png

Visible assertions (after Stop via the rendered footer button).

  • Footer clears.
  • Composer remains enabled with the same draft and Send affordance.
  • Transcript is unchanged: user prompt, BACKGROUND_STARTED. No cancellation/interrupt status row was inserted.

02-after-stop-full.png

Backing state.

  • Before Stop: Claude SDK child 80512 of this Electron instance, with descendant sleep 180 pid 90875 (zsh wrapper 90872).
  • After footer Stop: 90875 and its zsh wrapper 90872 exited immediately; Claude session process 80512 stayed alive. DOM: [data-native-chat-background-tasks] gone; no cancelled/canceled text in the pane. Composer Send remained enabled (aria-label="Send", not Stop).

Unverified gap. Not exercised: mixed-version clients, SSH/remote hosts, mobile, or a second overlapping turn while monitoring. Dictation control stayed disabled in this isolated profile and is unrelated to the footer. After a later Playwright session drop/reattach, Claude pid 80512 had already exited on idle; the immediately-after-Stop process check is the session-alive proof.

Result: pass.

@brennanb2025
brennanb2025 force-pushed the brennanb2025/claude-native-monitoring-footer branch from 916eed1 to 2220dac Compare September 5, 2026 02:26

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No new issues in this delta — one prior note still open.

Reviewed changes

  • Timeout-bounded stop requests — stopTask moved from an unbounded session.stopTask(taskId) call onto the shared control surface, so every stop_task now runs under runClaudeControl's deadline (default 30s) with the same ClaudeControlRequestError classification as the other control methods.
  • Stop loop forwards the deadline — stopClaudeBackgroundTasks accepts timeoutMs and passes { timeoutMs } to each stopTask; the adapter supplies this.deps.requestTimeoutMs.
  • Lost-reply regression test — a new claude-agent-sdk-control-requests.test.ts case pins that a never-resolving stop reply rejects with claude stop_task request timed out while a subsequent request still resolves (per-call timer cleanup in runClaudeControl's .finally).

The single open wire-compatibility note from prior reviews (.strict() scope on CancelParams) is untouched by these commits.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts
  • src/main/claude/claude-agent-sdk-control-requests.ts
  • src/main/claude/claude-background-task-tracker.test.ts
  • src/main/claude/claude-structured-control-actions.test.ts
  • src/main/claude/claude-structured-control-actions.ts
  • src/main/claude/claude-structured-session-adapter.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-subscribers.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-subscribers.ts
  • src/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.

Comment on lines +185 to +186
tracker.observe(system('task_updated', { task_id: 'task-live', patch: { status: 'killed' } }))
).toBe(true)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron visual proof — SHA 2220dac59816925707ee550b2c57bdd56f3fb074

Scenario. Isolated Orca dev instance from this worktree on 2220dac59816925707ee550b2c57bdd56f3fb074 (post-rebase bounded-stop-request). App identity: Orca: brennanb2025/claude-native-monitoring-footer, devRepoRoot = this worktree, devBranch = brennanb2025/claude-native-monitoring-footer. Launched a real Claude Agent SDK structured Native Chat session in an isolated folder workspace, sent a prompt that backgrounded sleep 180 with run_in_background=true, and waited until the foreground turn settled (BACKGROUND_STARTED) while the bash task kept running.

Visible assertions (before Stop).

  • Footer sits immediately above the bottom composer.
  • Footer shows the monitoring status icon (aria-label="Monitoring background tasks"), the text Monitoring background tasks, and a trailing Stop.
  • Composer stays enabled: draft accepted, Send affordance is the normal up-arrow (not the working Stop square).

01-before-stop-full.png

Visible assertions (after Stop via the rendered footer button).

  • Footer clears.
  • Composer remains enabled with the same draft and Send affordance.
  • Transcript is unchanged: user prompt, Worked for 6s, BACKGROUND_STARTED. No cancellation/interrupt status row was inserted.

02-after-stop-full.png

Backing state.

  • Before Stop: Claude SDK child 92952 of this Electron instance (63388), with descendant sleep 180 pid 12215 (zsh wrapper 12212).
  • After footer Stop: 12215 and its zsh wrapper 12212 exited immediately (~132ms sample); Claude session process 92952 stayed alive. DOM: [data-native-chat-background-tasks] gone; no cancelled/canceled text in the pane. Composer Send remained enabled (aria-label="Send", not Stop).

Unverified gap. Not exercised: mixed-version clients, SSH/remote hosts, mobile, or a second overlapping turn while monitoring. Dictation control stayed disabled in this isolated profile and is unrelated to the footer. Bounded stop_task timeout is covered by the prompt Stop completing; a hung-control-request timeout path was not forced.

Result: pass.

@brennanb2025

brennanb2025 commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor Author

Final review status — ready

Reviewed and validated at exact head 2220dac59816925707ee550b2c57bdd56f3fb074.

  • Same-model review-until-clean: clean after two meaningful lifecycle fixes, both covered by regression tests
  • End-of-session readiness checklist: PASS, zero P0/P1/P2 candidate findings
  • Focused verification: 87 tests across 13 changed test files
  • pnpm tc: pass
  • changed-file code quality, type-aware checks, and React Doctor: zero findings
  • git diff --check: pass
  • CI run 33939084801: success, including static analysis, typecheck, cross-version wire checks, all eight test shards, and Windows/Linux packaging
  • Exact-SHA Electron visual proof: pass with a real Claude Agent SDK background task; rendered footer Stop ended only the background process in ~132ms, cleared the footer, preserved the live SDK session and enabled composer, and added no cancellation transcript row
  • Branch is clean, matches the PR head, contains current origin/main, and GitHub reports it mergeable

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.

@brennanb2025
brennanb2025 force-pushed the brennanb2025/claude-native-monitoring-footer branch from 2220dac to 76351da Compare September 5, 2026 03:15

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 53f0b9ff-c5af-4085-aebd-9964c0017bdd

📥 Commits

Reviewing files that changed from the base of the PR and between 916eed1 and 76351da.

📒 Files selected for processing (12)
  • src/main/claude/claude-background-task-tracker.test.ts
  • src/main/claude/claude-background-task-tracker.ts
  • src/main/claude/claude-structured-session-close.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-subscribers.test.ts
  • src/renderer/src/components/native-chat/NativeChatBackgroundTasksStatus.tsx
  • src/renderer/src/components/native-chat/NativeChatStructuredSession.test.tsx
  • src/renderer/src/components/native-chat/NativeChatStructuredSession.tsx
  • src/renderer/src/components/native-chat/use-structured-agent-session.ts
  • src/shared/agent-session-wire.ts
  • src/shared/structured-agent-session-coalescer.test.ts
  • src/shared/structured-agent-session-reducer.test.ts
  • src/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, {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 — ClaudeBackgroundTaskTracker now stores each task's kind and a whitespace-normalized, 512-char-capped description, and publishes a bounded tasks: AgentSessionBackgroundTask[] alongside the { state: 'monitoring' } signal, deduplicating via a string fingerprint so an unchanged roster does not re-publish.
  • Expandable footer — NativeChatBackgroundTasksStatus renders 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.tasks is threaded additively through the history page, subscribe snapshot/batch/reset events, the coalescer (newest-wins), and the reducer (deep-equality, so a roster-only change updates backgroundTasks without 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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No new issues in this delta — one prior wire-compat note still open.

Reviewed changes

  • Tracker observe hardening — observe() and observeSystemFrame() now return a boolean and short-circuit, so stream frames that neither start a turn nor mutate task state no longer reach the JSON.stringify fingerprint in refreshMonitoring().
  • Progress-frame contract pinned — a task_progress assertion now locks in that progress-only system frames return false (no publish).
  • Localization fix — the seven missing components.native-chat.backgroundTasks.* keys are added to en.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.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron visual proof — SHA 516cf64abf8cd64da5c954f35386dc81c7294a25

Scenario. Isolated Orca dev instance from this worktree on 516cf64abf8cd64da5c954f35386dc81c7294a25. App identity: Orca: brennanb2025/claude-native-monitoring-footer, devRepoRoot = this worktree, devBranch = brennanb2025/claude-native-monitoring-footer. Launched a real Claude Agent SDK structured Native Chat session in an isolated folder workspace, sent a prompt that backgrounded sleep 180 with run_in_background=true, and waited until the foreground turn settled (BACKGROUND_STARTED) while the bash task kept running.

Visible assertions (collapsed footer, before Stop).

  • Compact footer sits immediately above the bottom composer.
  • Footer shows the monitoring status icon (aria-label="Monitoring background tasks"), the text Monitoring background tasks, a chevron, and a trailing Stop.
  • Stop is a separate action from the status area (aria-expanded="false" on the status button).
  • Composer stays enabled: draft keep chatting while monitoring accepted, Send affordance is the normal up-arrow (aria-label="Send", not the working Stop square).

01-collapsed.png

Visible assertions (expanded list, before Stop).

  • Clicking the status area (not Stop) expands an inline bounded list labeled Running background tasks.
  • The list shows the real running task description: Sleep for 180 seconds in background.
  • Stop remains a separate trailing action. Composer draft and Send stay enabled.

02-expanded.png

Visible assertions (after Stop via the rendered footer button).

  • Footer and expanded list clear.
  • Composer remains enabled with the same draft and Send affordance.
  • Transcript is unchanged: user prompt, Worked for 2s, I'll start the background task., BACKGROUND_STARTED. No cancellation/interrupt status row was inserted.

03-stopped.png

Backing state.

  • Before Stop: Claude SDK child 22328 of this Electron instance (10248), with descendant sleep 180 pid 26692 (zsh wrapper 26689).
  • After footer Stop: 26692 and its zsh wrapper 26689 exited immediately; Claude session process 22328 stayed alive. DOM: [data-native-chat-background-tasks] gone; no cancelled/canceled/interrupt text in the pane. Composer Send remained enabled (aria-label="Send", not Stop) with draft preserved.

Unverified gap. Not exercised: mixed-version clients, SSH/remote hosts, mobile, or a second overlapping turn while monitoring. Dictation control stayed disabled in this isolated profile and is unrelated to the footer. Bounded stop_task timeout is covered by the footer Stop completing; a hung-control-request timeout path was not forced.

Result: pass. No in-scope defect found; no code changes.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Final review status — ready

Reviewed and validated at exact HEAD 516cf64abf8cd64da5c954f35386dc81c7294a25.

  • Same-model review-until-clean completed after three final passes; no in-scope issues remain.
  • Meaningful fixes retained: lifecycle fence preservation, bounded provider control requests, live task-detail publication, no-op handling for irrelevant SDK frames, and complete English localization entries.
  • Performance/resource audit: event-driven only; no polling or subprocess churn; task state and wire strings are bounded; duplicate/irrelevant frames avoid reducer and render churn.
  • Compatibility audit: additive optional wire fields preserve mixed-version behavior; execution and Stop remain runtime-host owned for local, folder, SSH, and relay paths; no mobile request/UI contract was broadened.
  • Exact-SHA Electron validation used a real Claude Agent SDK background process. Clicking the footer showed the live task description; Stop killed only that work, preserved the enabled composer draft, kept the Claude session alive, and added no cancellation transcript row.
  • Full visual proof and process evidence
  • Closing readiness checklist: PASS — P0 none, P1 none, P2 none.
  • GitHub: MERGEABLE / CLEAN; static analysis, typecheck, cross-version wire, all 8 test shards, macOS/Windows packaging, verify, and Pullfrog passed.

No further action is required before merge.

enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* 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>
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.

1 participant