Skip to content

Native chat tabs can hand off work from their right-click menu - #34504

Merged
brennanb2025 merged 4 commits into
mainfrom
brennanb2025/chat-menu-hand-off-main
Oct 27, 2026
Merged

brennanb2025 merged 4 commits into
mainfrom
brennanb2025/chat-menu-hand-off-main

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1082 $\color{#cf222e}{\Huge{\mathbf{−}}}$​21 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1061
Prod 29 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​686 $\color{#cf222e}{\Huge{\mathbf{−}}}$​137 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​549

ELI5

A native chat opened as its own tab has no right-click action for handing its work to another agent. This adds “Hand Off to Another Agent” to that menu, using the existing chooser to start a fresh session in the same workspace.

What Changed

The menu prepares context from the chat’s host journal in one capability-negotiated read. That read returns a bounded starter and a complete saved-chat snapshot file on the same host. It preserves the saved questions and answers and respects clear/rewind boundaries. The file has one deterministic location per session under OS temp and is replaced on the next hand-off; there is no sweeper. Each preparation attempt owns its dialog, so cancelling or changing chats cannot produce a late chooser.

Older hosts keep an explicitly labelled fallback to messages already loaded in the chat, without pagination. Terminal panes retain their existing hand-off row. The chooser shows preparation immediately with disabled controls and keeps the workspace path visible from the first frame.

Main’s current chat/CLI agent picker and launch cancellation behavior remain in use. The new read is workspace-authorized and does not extend the phone allowlist. The host method registry is recounted against main: 42 existing methods become 43; the complete cross-version surface becomes 46. The protocol version and minimum peer versions remain unchanged.

Why

This is split out of #31782 so the right-click entry can land on main without waiting for the usage-limit/account-switch stack. The journal is the authoritative saved chat, and the complete file lets the destination recover earlier details beyond the starter’s budget. Reusing the existing chooser and launcher keeps hand-off consistent with other entry points.

Intended compatibility differences: capable hosts supply saved context plus a same-host file; older hosts supply only labelled loaded messages. The snapshot is the saved chat at preparation time, including existing truncation markers, and later preparation replaces the same session’s file. OS temp owns retention.

The only small pieces carried from the stack are an optional in-memory sourceKind: 'chat' discriminator with its recent-chat fallback wording, and the native_chat launch telemetry value. This PR adds no account-switch or usage-limit UI. Usage-limit entry wiring and source-agent exclusion remain with #31782.

Linked Issue

Tracked in #31782.

Visual Proof

Branch-only screenshots at df7cddb, captured through the real standalone chat menu and existing chooser in an isolated background copy. No agent was started. The later saved-read/export and indexed-lookup fixes preserve these rendered flows; their tests cover the changed behavior.

menu.png

dialog.png

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Named vitest runs through the local test gate cover snapshot publication ordering, saved context after clear/rewind/restart, retained prompt answers and editor prefill, host RPC registration, menu availability, fallback, timeout/cancellation ownership, dialog completion ownership, picker behavior, existing pane flows and both cross-version contracts. The split builder recorded 13 suites / 175 tests at its committed head and 11 existing pane suites / 120 tests.

Review repairs added a production-backed regression for readable saved chats with damaged execution metadata: saved content transfers while source execution remains refused and unchanged. Targeted host/store/RPC verification covered 83 distinct tests; the final at-rest run passed 19/19. The real hand-off hook/store performance contract runs at 57 and 570 consumers, asserts unrelated updates do no tab scans or renders, and verifies the correct title/name still updates. Its three named suites passed 21 tests. A stale third argument in the copied clear-history test was removed to match main’s two-argument API; its 19 tests pass. These counts overlap and are not additive.

No standalone typecheck, lint, build or full test run was performed on this Mac. Normal commit hooks passed. Final-head CI passed: static/typecheck, all five Node test shards, relay, cross-version compatibility, Linux/Windows packaging, changed layout/e2e checks and WSL distro tests. The Debian hosted runner froze on its first attempt; the existing automatic retry passed without a source change.

Review

Full review of the split against its source change and current main, including host authorization, mixed versions, current picker/launcher, attempt ownership, consumers, references and performance. The prior settled source design is retained. Three bounded findings were fixed: readable saved-conversation admission, duplicate public exports caught by CI, and repeated per-chat tab scans. Final CI and the loop's status comment record readiness.

Agent skill upstream boundary

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

Notes

The snapshot is private temp data on the source host, and WSL paths retain the existing conversion. Folder workspaces use the existing workspace launch route. Remote hosts negotiate the read capability; phones receive no added permission. Cross-platform behavior beyond the named tests is not newly claimed by this split.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred) — covered by CI

@brennanb2025
brennanb2025 marked this pull request as ready for review October 27, 2026 18:52
@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 35a84b47-c113-41f9-aa58-887d4aa4c14a
Commits

Reviewing files that changed from the base of the PR and between 327a90e and 9ffe1fb.

Files selected for processing: 1
  • src/main/runtime/rpc/methods/structured-agent-session-at-rest.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

Walkthrough

The changes add a structured continuation-context RPC that validates session context and publishes saved chat snapshots. Native-chat now offers a hand-off action that prepares context for an agent-session continuation dialog. The dialog and prompt distinguish chat context from terminal captures, and captured context uses a shared 36,000-character limit. Tests cover snapshot ordering, RPC results, hand-off preparation, and dialog behavior.

Priority: Normal

Merge Risk: Minimal · up to 9ffe1

No actionable issue remains that should block merging this change.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surv… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly states the primary user-facing change: native chat tabs can hand off work from their context menu.
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.
Description check Passed The pull request description is complete and follows the repository template. It includes the user-facing summary, scope, rationale, linked issue, visual proof, testing details, review notes, compatib…
Full details: Description check

Explanation

The pull request description is complete and follows the repository template. It includes the user-facing summary, scope, rationale, linked issue, visual proof, testing details, review notes, compatibility considerations, and checklist. The reported CI coverage and known local testing limitations are clearly stated.

Full details: Docstring Coverage

Explanation

Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 24 functions across 33 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@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
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1b42d740-8d80-457b-a659-6ec7ac8d80c8
Commits

Reviewing files that changed from the base of the PR and between d45d579 and df7cddb.

Files ignored due to path filters: 1
  • src/shared/rpc-contract/rpc-params-catalog.generated.ts is excluded by !**/*.generated.*
Files selected for processing: 38
  • src/main/native-chat/agent-session-context-snapshots.test.ts
  • src/main/native-chat/agent-session-context-snapshots.ts
  • src/main/native-chat/agent-session-saved-prompt-text.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-continuation-context.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-host.ts
  • src/main/runtime/rpc/methods/structured-agent-session-at-rest.test.ts
  • src/main/runtime/rpc/methods/structured-agent-session-options-read.ts
  • src/main/runtime/rpc/methods/structured-agent-session-schemas.ts
  • src/main/runtime/rpc/methods/structured-agent-session.test.ts
  • src/renderer/src/components/agent-session-continuation/AgentSessionContinuationDialog.test.tsx
  • src/renderer/src/components/agent-session-continuation/AgentSessionContinuationDialog.tsx
  • src/renderer/src/components/agent/AgentCombobox.tsx
  • src/renderer/src/components/native-chat/NativeChatStructuredSession.tsx
  • src/renderer/src/components/native-chat/structured-chat-menu-lifetime.test.tsx
  • src/renderer/src/components/native-chat/use-native-chat-context-menu.tsx
  • src/renderer/src/components/native-chat/use-native-chat-hand-off.tsx
  • src/renderer/src/components/native-chat/use-structured-native-chat-pane-commands.test.tsx
  • src/renderer/src/components/native-chat/use-structured-native-chat-pane-commands.tsx
  • src/renderer/src/components/terminal-pane/AgentSessionContinuationMenuItem.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/lib/agent-session-continuation.ts
  • src/renderer/src/lib/agent-session-fork-context.test.ts
  • src/renderer/src/lib/agent-session-fork-context.ts
  • src/renderer/src/runtime/structured-agent-session-client.ts
  • src/shared/agent-session-context-budget.ts
  • src/shared/agent-session-runtime-capabilities.ts
  • src/shared/agent-session-wire.ts
  • src/shared/rpc-contract/structured-agent-session-identifiers.ts
  • src/shared/rpc-contract/structured-agent-session-params.ts
  • src/shared/telemetry-property-schemas.ts
  • tests/e2e/cross-version-wire/structured-agent-session-host-fixture.ts
  • tests/e2e/cross-version-wire/structured-agent-session-surface-calls.ts
  • tests/e2e/cross-version-wire/structured-agent-session-surface-manifest.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Standalone native chats had no hand-off action in their context menu. This adds “Hand Off to Another Agent” and opens the existing chooser in the same workspace, using saved chat context from the owning host. Older hosts retain the labelled loaded-message fallback.

The full split/integration review retained the settled source design and fixed three issues: readable saved chats with damaged execution metadata now remain usable as hand-off sources without gaining execution permission; duplicate RPC exports are corrected; and each mounted chat reuses the existing tab index instead of scanning tabs on unrelated updates. A stale third argument in the ported clear-history test was also removed to match main’s current API; its 19 tests pass. No confirmed finding remains open.

Verification: final-head PR checks and WSL checks passed (29 passed, 20 skipped, no pending or failed checks). The first Debian hosted runner froze during setup; its existing automatic retry passed, with no source change. Targeted host/store/RPC tests include a regression that fails before the saved-read repair and passes afterward. The real hook/store contract passes at 57 and 570 consumers, with zero unrelated tab scans/renders and correct live title/name updates; its three focused suites pass 21 tests. Renderer/host, snapshot-ordering, prompt and mixed-version tests also cover the source design.

Branch-only screenshot check passed on the menu and prepared chooser, followed by Cancel. No agent was started and Start was not clicked. The transient preparation state completed too quickly to capture; its disabled controls are covered by renderer tests. The isolated copy stopped gracefully, with no owned leftovers or port listeners and unchanged real-config hashes.

Screenshots are from df7cddb. Since then, 3917ecc changes saved-read admission/exports and 327a90e changes indexed title lookup, each in tests-row flows with the regression coverage above. Their rendered menu/dialog and launch behavior are unchanged, so the screenshots carry through qa_head=. Later commit 9ffe1fb changes only the test call’s arity; all shipped code stays at the reviewed head. Whole-mechanism comparison and final readiness review cover 327a90e. Intended compatibility details remain: capable hosts return a bounded starter plus a same-host temp snapshot; old hosts use loaded messages without pagination; the per-session temp file is replaced on later preparation and OS temp owns retention.

For Brennan’s review

menu.png

dialog.png

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