Repository navigation
feat(native-chat): render a proposed plan as a plan, not a generic approval - #21090
Conversation
There was a problem hiding this comment.
ℹ️ No critical issues — one inline suggestion plus minor notes.
Reviewed changes — renders a Claude ExitPlanMode proposal as a typed, markdown plan instead of a serialized tool-input approval, on desktop and mobile.
- Typed plan subject —
AgentJournalApprovalSubject(kind: 'plan',text, optionalfilePath) added to the approval body type and schema, with text and path bounded byboundJournalPromptBody. - Host classification —
claudePermissionSubjectrecognisesExitPlanMode, extractsplan/planFilePath, and carries the subject onto the approval before registration; the generic JSONdetailis replaced and plan-specific option labels are used. - Desktop plan card —
NativeChatPlanApprovalCardrenders the plan throughCommentMarkdownin a collapsible, height-bounded, keyboard-reachable region keyed into the existing disclosure store, andNativeChatStructuredSessionroutes plan approvals to it. - Mobile plan rendering — the subject is projected through
projectStructuredPermissionand rendered byMobileMarkdownin a boundedScrollView. - Tests — new/updated coverage for classification, the stream ingress, the schema, the card, session routing, and mobile.
ℹ️ A plan that arrives only through the assistant stream still renders as raw tool input
The plan card is reached exclusively from the pending approval prompt. The assistant-stream ExitPlanMode tool use is journalled as a plain tool-call (pinned by claude-structured-journal-translation.plan.test.ts), and NativeChatToolLine renders its { plan, planFilePath } input as pretty-printed JSON. So in the case the PR itself calls out — the permission callback not firing — the user still sees the raw tool payload rather than the plan card.
Technical details
# Plan rendering depends on the permission callback alone
## Affected sites
- `src/main/claude/claude-permission-presentation.ts:50` — subject production is gated on `canUseTool`.
- `src/main/claude/claude-structured-journal-translation.plan.test.ts:37` — pins the stream ingress as a generic `tool-call`, not as a plan.
- `src/renderer/src/components/native-chat/NativeChatStructuredSession.tsx:249` — the only route to `NativeChatPlanApprovalCard`.
## Required outcome
- Decide whether a stream-only plan should reach the plan card (or a plan-styled row). If it stays JSON, scope the "two ingresses" claim in the PR to journalling so the fallback is explicit.
## Open questions for the human
- Is the stream-only fallback acceptable because it is bounded and previewed like every other tool call?ℹ️ Nitpicks
src/main/native-chat/agent-session-journal/journal-prompt-body-bounds.ts:75— the bounded subject is rebuilt with a literalkind: 'plan'instead ofbody.subject.kind; forward the discriminant so a second subject kind cannot be silently relabelled.src/main/claude/claude-permission-presentation.ts:61—input.plan_file_pathis not a key Claude Code emits (the CLI normalises toplanFilePath); the fallback is harmless but dead.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…proval A finished plan arrives as an ExitPlanMode tool call. With no handling for it, the generic approval path serialized the tool input, so a plan appeared as thousands of characters of escaped JSON. A plan is content to read, not a privilege to grant. Classify the plan in the permission callback and carry it as a typed subject on the approval item, keeping the existing approval kind so the prompt still reaches every consumer. Mobile filters pending approvals on that kind, so introducing a new one would have made the prompt vanish there silently. Classification runs before registration, so a future permission-mode short-circuit cannot swallow a plan proposal. The assistant tool-use stream is a second ingress and is pinned by its own test, because neither path can be assumed to fire on its own. Rather than adding a second card, the plan renders inside the approval card's existing bounded content region. It inherits the height cap, the scrolling, the keyboard focus and the pinned action row that region already provides, and a typed plan replaces the raw detail instead of rendering both. Buttons read as plan decisions. Mobile renders the same subject through its own markdown component in the same region.
ac816d9 to
f565f86
Compare
There was a problem hiding this comment.
ℹ️ No new issues from the rework — the plan now renders in the approval card's shared bounded region. The earlier open questions are unchanged and tracked in the existing thread.
Reviewed changes — reworked the desktop plan presentation after the approval-card fix landed on main, replacing the separate plan card with inline rendering; the host classification, schema, bounding, and mobile paths are unchanged.
- Inline plan rendering — the separate
NativeChatPlanApprovalCardand its disclosure wiring are gone; a plan now renders insideNativeChatApprovalCard's existing bounded content region, so it inherits the height cap, scroll, keyboard focus, and pinned action row, and a typed plan replacesdetail. - Link threading —
NativeChatApprovalCardgained optionalonLinkClick/allowFileUriLinks, wired fromNativeChatStructuredSession, so file paths inside a plan linkify and open like other native-chat markdown. - Test and copy updates — the desktop and mobile card tests assert the plan renders in the shared region and not as raw detail, and the
components.native-chat.approval.plan.filestring was added.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThis change adds a typed plan subject to approval journal data. Claude derives the subject from Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to No concrete merge-blocking risk is established by the reviewed change context. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description is detailed and covers the change, rationale, testing, compatibility, and review notes. However, it does not provide the required linked issue, and the required before-and-after visual proof is incomplete because only current-state screenshots are attached.
✨ 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 new issues found.
Reviewed changes — the fix commit on top of the plan-rendering feature, preserving the plan after resolution and tightening plan approval semantics.
- Restored compatibility detail —
claudeApprovalItemnow setsdetailto the plan text (truncated) instead of nulling it, soNativeChatResolutionReceiptand the structured-session status projection keep showing the plan once it is approved or denied rather than dropping it. - Plan-specific fallback title — when the harness omits a title, a plan approval reads
Review proposed planinstead ofAllow ExitPlanMode?. - Narrowed plan options — plan approvals offer approve / keep planning / stop; the session-scoped option is gone, while its id is still accepted from legacy senders.
- Plan-aware denial message — a rejected plan tells Claude to revise the plan and call
ExitPlanModeagain, instead of the generic "User denied this action." - Tests — journaling, fallback title, generic-vs-plan denial, legacy session reply, and the schema canonical body were updated to pin the new behavior.
The earlier inline concern about the plan disappearing from resolved surfaces is addressed by the restored detail; that thread has been resolved.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — follow-up fix keeping a plan approval one-turn, on top of the plan-rendering feature.
- Plan approvals no longer persist session permissions — when a plan approval is answered with the legacy
allowForSessionid, the SDK's permission-rulesuggestionsare no longer copied intoupdatedPermissions, so approving a plan authorises the plan for the turn without carrying permission rules into the session. Generic approvals are unchanged. - Tests — the generic Bash case now pins that
allowForSessionstill forwardsupdatedPermissions, and the plan case pins that it does not.
The guard is only reachable from a client still sending the old session option (the plan option list no longer offers it), and it is strictly more restrictive than before.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Visual QA evidence (desktop + native mobile)Scenario. Live structured Claude session in this worktree ( Desktop (hidden Electron, CDP 9336 / renderer 5177). Title is Review proposed plan, not Allow ExitPlanMode. Markdown headings, bullets, and a JavaScript code block render as document content. Plan file is shown. Only Approve plan / Keep planning / Stop are offered (option IDs Native mobile. Android was unavailable ( Gaps. No genuine before-state of the old raw-JSON “Allow ExitPlanMode?” card (that would need a main-build live plan prompt; not substituted with a mock). The transcript tool-activity line still shows a truncated |
Review status: cleanReviewed and fixed through three same-model review rounds. The third round returned CLEAN, and the final readiness audit passed on Meaningful fixes pushed during review:
After the repeated session-authorization finding, a separate architecture challenge confirmed that classification at the provider boundary plus an optional subject on the existing approval lifecycle removes the root cause. A new journal kind or parallel card would add compatibility and lifecycle risk without improving ownership. Validation:
Known non-blocking gaps are documented in the PR body: there is no genuine old-build before screenshot, an assistant-stream-only Status: ready to merge. |
…proval (stablyai#21090) * feat(native-chat): render a proposed plan as a plan, not a generic approval A finished plan arrives as an ExitPlanMode tool call. With no handling for it, the generic approval path serialized the tool input, so a plan appeared as thousands of characters of escaped JSON. A plan is content to read, not a privilege to grant. Classify the plan in the permission callback and carry it as a typed subject on the approval item, keeping the existing approval kind so the prompt still reaches every consumer. Mobile filters pending approvals on that kind, so introducing a new one would have made the prompt vanish there silently. Classification runs before registration, so a future permission-mode short-circuit cannot swallow a plan proposal. The assistant tool-use stream is a second ingress and is pinned by its own test, because neither path can be assumed to fire on its own. Rather than adding a second card, the plan renders inside the approval card's existing bounded content region. It inherits the height cap, the scrolling, the keyboard focus and the pinned action row that region already provides, and a typed plan replaces the raw detail instead of rendering both. Buttons read as plan decisions. Mobile renders the same subject through its own markdown component in the same region. * fix(native-chat): preserve plan review semantics * fix(native-chat): keep plan approval one-turn






ELI5
When an agent finishes planning, Orca used to show the plan as raw machine text under “Allow ExitPlanMode?”. This change presents it as a readable document with plan-specific actions: Approve plan, Keep planning, and Stop.
What Changed
Before: a live
ExitPlanModepermission prompt became a generic approval. The card serialized the tool input, offered session-wide permission, and used a tool-oriented title.After: the same prompt shows Review proposed plan, renders headings, lists, and code as markdown, includes the plan file when available, and offers only one-turn plan decisions. Keep planning asks the agent to revise the plan and call
ExitPlanModeagain. It never grants a session-wide permission, including when an older client sends the formerallowForSessionresponse.Mechanism: the host recognizes
ExitPlanModewith a stringplanat the permission callback and attaches an optional typed subject to the existing approval journal item. Current clients render that subject inside the approval card’s existing bounded scroller. The host also retains a bounded plain-textdetailfallback, so older clients still show the plan instead of losing its body. The existing approval kind and response lifecycle remain unchanged, which preserves mixed-version desktop/mobile behavior and compare-and-set prompt settlement.The assistant tool stream still records
ExitPlanModeas ordinary tool activity. Typed plan presentation comes from the permission callback, where the actionable prompt and response ownership exist.Why
A plan is a document to review, while the existing generic fallback treated it as a serialized permission payload. Classifying the prompt at the provider boundary removes that category error and lets desktop and mobile consume the same host-owned subject and action policy.
Alternatives considered:
Linked Issue
None. This follows a user report in chat and the bounded approval-card work in #21087.
Visual Proof
Validated from a real live
ExitPlanModepermission prompt on commitf9d0a655, using a hidden Electron renderer and a paired native iOS dev client. The full evidence, scrolled states, backing journal assertions, and known gaps are in the Visual QA comment.Desktop — live plan card
Mobile — the same pending plan on iPhone Simulator
A genuine before-state was not captured because it requires running an older build through a live plan-mode permission prompt. The current screenshots are real end-to-end states rather than seeded or mocked cards.
Testing
pnpm tc— passedFocused desktop/main/shared suites — 70 tests passed after the first review fixes; 49 affected tests passed after the final response-normalization fix
cd mobile && pnpm test src/session/MobileNativeChatPermission.test.ts— 4 tests passedpnpm run check:code-quality:changed— passed with 0 findingsLive hidden Electron on macOS — real structured Claude session; verified title, markdown, plan file, bounded scrolling, pinned actions,
allow/deny/cancel, the backing legacy fallback, and no session permission after Keep planningOrca Mobile on iPhone 17 Pro Simulator, iOS 26.5 — paired to the same live host; verified the plan card and scrolled state
PR CI — all required checks passed, including static analysis, typecheck, cross-version wire compatibility, mobile checks, all eight test shards, macOS packaging, and Windows packaging
I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Three same-model review rounds found and fixed mixed-version body loss, generic fallback labeling, session-wide authorization on plan prompts, generic plan denial behavior, and legacy
allowForSessionnormalization. The third round returned clean. A separate architecture challenge found that the typed subject on the existing approval lifecycle fixes the root cause without a broader journal rewrite.Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
detail; new clients connected to older hosts retain the previous generic presentation.ExitPlanModeremains a generic tool-activity row; the transcript summary above the card remains truncated tool JSON; Android was unavailable; Keep planning was exercised on desktop and covered by mobile unit tests, but was not tapped on mobile.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)Current-state desktop and mobile screenshots are attached. A genuine before-state is unavailable for the reason documented above.