Skip to content

feat(native-chat): render a proposed plan as a plan, not a generic approval - #21090

Merged
brennanb2025 merged 3 commits into
mainfrom
brennanb2025/plan-approval-card
Sep 17, 2026
Merged

brennanb2025 merged 3 commits into
mainfrom
brennanb2025/plan-approval-card

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​223 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​220
Prod 15 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​152 $\color{#cf222e}{\Huge{\mathbf{−}}}$​16 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​136

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 ExitPlanMode permission 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 ExitPlanMode again. It never grants a session-wide permission, including when an older client sends the former allowForSession response.

Mechanism: the host recognizes ExitPlanMode with a string plan at 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-text detail fallback, 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 ExitPlanMode as 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:

  • Infer plans in each client. That would duplicate provider-specific policy and could disagree across desktop, mobile, and client versions.
  • Add a new journal kind. Older schemas reject unknown kinds, and mobile already follows pending approvals through the existing approval lifecycle. This would require a capability-gated downgrade back to the same representation.
  • Build a separate plan card. That would duplicate the approval layout and its scrolling, focus, settlement, and action behavior.

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 ExitPlanMode permission prompt on commit f9d0a655, 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

Desktop plan approval

Mobile — the same pending plan on iPhone Simulator

Mobile plan approval

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 — passed

  • Focused 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 passed

  • pnpm run check:code-quality:changed — passed with 0 findings

  • Live 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 planning

  • Orca 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 allowForSession normalization. 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

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Security: plan text uses the existing sanitized markdown renderers. The plan path is displayed as text. No new capability is granted.
  • Cross-platform: there is no platform-specific code, path construction, or shortcut handling. CI packages macOS and Windows successfully.
  • Remote SSH and folder workspaces: the execution host creates and settles the same approval journal item through the existing stream. The change adds no local-only process or Git-worktree assumption.
  • Mobile and compatibility: the optional subject preserves the existing approval envelope. New hosts provide older clients with bounded readable detail; new clients connected to older hosts retain the previous generic presentation.
  • Performance: classification is one tool-name/input check per permission request. The subject and compatibility fallback are bounded, rendering occurs only for the pending card, and the change adds no polling, listener, process, or cache.
  • Known gaps: an assistant-stream-only ExitPlanMode remains 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

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

Current-state desktop and mobile screenshots are attached. A genuine before-state is unavailable for the reason documented above.

@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 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, optional filePath) added to the approval body type and schema, with text and path bounded by boundJournalPromptBody.
  • Host classification — claudePermissionSubject recognises ExitPlanMode, extracts plan / planFilePath, and carries the subject onto the approval before registration; the generic JSON detail is replaced and plan-specific option labels are used.
  • Desktop plan card — NativeChatPlanApprovalCard renders the plan through CommentMarkdown in a collapsible, height-bounded, keyboard-reachable region keyed into the existing disclosure store, and NativeChatStructuredSession routes plan approvals to it.
  • Mobile plan rendering — the subject is projected through projectStructuredPermission and rendered by MobileMarkdown in a bounded ScrollView.
  • 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 literal kind: 'plan' instead of body.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_path is not a key Claude Code emits (the CLI normalises to planFilePath); the fallback is harmless but dead.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using 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.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/plan-approval-card branch from ac816d9 to f565f86 Compare September 17, 2026 02:38
@brennanb2025
brennanb2025 changed the base branch from brennanb2025/approval-card-broad-fix to main September 17, 2026 02:38

@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 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 NativeChatPlanApprovalCard and its disclosure wiring are gone; a plan now renders inside NativeChatApprovalCard's existing bounded content region, so it inherits the height cap, scroll, keyboard focus, and pinned action row, and a typed plan replaces detail.
  • Link threading — NativeChatApprovalCard gained optional onLinkClick / allowFileUriLinks, wired from NativeChatStructuredSession, 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.file string was added.

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

@coderabbitai

coderabbitai Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: d86e2037-14b7-4971-b000-3825df55b885

📥 Commits

Reviewing files that changed from the base of the PR and between dee257f and f9d0a65.

📒 Files selected for processing (2)
  • src/main/claude/claude-structured-prompt-items.test.ts
  • src/main/claude/claude-structured-prompt-replies.ts

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


📝 Walkthrough

Walkthrough

This change adds a typed plan subject to approval journal data. Claude derives the subject from ExitPlanMode requests and preserves it through prompt registration and journal bounding. Desktop and mobile approval cards render plan markdown and optional file paths instead of generic detail text. Plan approvals use plan-specific action labels and denial messages. Tests cover ingress, schema validation, desktop rendering, and mobile rendering.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to f9d0a

No concrete merge-blocking risk is established by the reviewed change context.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 23.08% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 20 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning 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… Add a valid issue link after “Fixes #” and attach genuine before-and-after screenshots or videos for the UI change. Update the checklist to reflect the completed visual-proof requirement.
✅ Passed checks (3 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 and concisely describes the primary change: rendering proposed plans as plan-specific native-chat approvals instead of generic approvals.
Full details: Description check

Explanation

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.

  • 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 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 — claudeApprovalItem now sets detail to the plan text (truncated) instead of nulling it, so NativeChatResolutionReceipt and 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 plan instead of Allow 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 ExitPlanMode again, 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.

Pullfrog  | View workflow run | Using DeepSeek Flash (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 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 allowForSession id, the SDK's permission-rule suggestions are no longer copied into updatedPermissions, 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 allowForSession still forwards updatedPermissions, 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.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Visual QA evidence (desktop + native mobile)

Scenario. Live structured Claude session in this worktree (Orca: brennanb2025/plan-approval-card, commit f9d0a6556156c1c0518e2d57f8b81412934efcc8) on a throwaway git repo. /plan is not available in this Claude environment; the agent entered plan mode itself and issued a real ExitPlanMode canUseTool prompt. The pending plan card was then opened on paired Orca Mobile.

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 allow / deny / cancel). No “Allow for this session”. Typed plan replaces the raw payload ([data-native-chat-approval-detail] absent). Long plan scrolls inside max-h-72 (scrollHeight 1100 vs clientHeight 288) while actions stay pinned (actionsY 924 before and after scroll). Keep planning resolved the journal item as deny (resolvedBy: desktop-renderer); session options stayed model / effort / fastMode only — no session-wide permission was added.

desktop-plan-approval-full.png

desktop-plan-approval-scrolled.png

Native mobile. Android was unavailable (adb not present). iOS Simulator iPhone 17 Pro, iOS 26.5, Orca Mobile dev client from mobile/ (Metro 8082), paired to this live desktop host. The same pending plan card shows Review proposed plan, markdown document content, Plan file, and Approve plan / Keep planning / Stop with actions pinned while the body scrolls.

mobile-after-pair.png

mobile-plan-approval.png

mobile-plan-approval-scrolled.png

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 ExitPlanMode {"plan":...} summary above the card; the card itself does not double-render that payload. Keep planning was exercised on desktop, not re-tapped on mobile.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status: clean

Reviewed and fixed through three same-model review rounds. The third round returned CLEAN, and the final readiness audit passed on f9d0a6556156c1c0518e2d57f8b81412934efcc8 with no P0/P1/P2 findings.

Meaningful fixes pushed during review:

  • Preserve a bounded readable plan body for older desktop/mobile clients while current clients use the typed plan subject.
  • Use the friendly fallback title Review proposed plan.
  • Restrict plans to Approve plan / Keep planning / Stop and send a plan-specific revision message on denial.
  • Normalize legacy allowForSession replies for typed plans to one-turn approval without applying permission suggestions.

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:

  • Fresh final audit: 54 focused main/renderer/schema tests and 4 mobile tests passed.
  • Changed-code quality check passed.
  • CI is fully green: static analysis, typecheck, cross-version wire compatibility, mobile checks, all eight test shards, macOS packaging, and Windows packaging.
  • Live hidden Electron QA exercised a real ExitPlanMode prompt, including markdown, plan file, bounded scrolling, pinned actions, journal payload, and Keep planning without a session permission.
  • Paired native iOS QA rendered and scrolled the same pending plan card.
  • Desktop and mobile screenshots and detailed evidence

Known non-blocking gaps are documented in the PR body: there is no genuine old-build before screenshot, an assistant-stream-only ExitPlanMode remains generic tool activity, the transcript summary still shows truncated tool JSON, Android was unavailable, and the mobile denial action is covered by tests but was exercised end-to-end on desktop only.

Status: ready to merge.

@brennanb2025
brennanb2025 merged commit e42f7c0 into main Sep 17, 2026
28 checks passed
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
…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
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