Skip to content

fix(native-chat): render approvals from the harness presentation, not serialized tool input - #21087

Merged
brennanb2025 merged 2 commits into
mainfrom
brennanb2025/approval-card-broad-fix
Sep 16, 2026
Merged

brennanb2025 merged 2 commits into
mainfrom
brennanb2025/approval-card-broad-fix

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​295 $\color{#cf222e}{\Huge{\mathbf{−}}}$​9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​286
Prod 17 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​324 $\color{#cf222e}{\Huge{\mathbf{−}}}$​49 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​275

ELI5

Long approval requests could push every choice below the bottom of native chat, leaving no way to answer. The approval now uses the provider's own title and context, keeps that context in a scrollable area, and leaves the choices visible on desktop and mobile.

What Changed

The Claude permission callback now normalizes and sanitizes its presentation once, stores it on the existing durable approval journal item, and lets desktop and mobile render that same data. Responses still travel through the existing pending-prompt registry using the provider's opaque option ID.

Both clients keep the title and action buttons outside one bounded context scroller. The scroller contains the description, decision reason, blocked path, matched ask rule, and formatted tool detail, so any provider-controlled field can grow without moving the actions out of reach. Desktop focus moves to a new approval and Escape remains safe during IME composition.

The follow-up review removed unused future renderer scaffolding and reused the shared matched-rule type. It also made the intended readable JSON formatting part of the integration contract.

Why

Before this change, the renderer rebuilt approval text from the tool name and serialized input. A large write payload could fill the pane and hide every action. Keeping presentation ownership at the provider callback preserves the exact request the provider intended, while the existing journal remains the single durable delivery path for local, remote, desktop, and mobile clients. Reconstructing text in each client or adding another cache would create state that can disagree with the pending request.

Linked Issue

No separate issue; the approval overflow and missing provider context are tracked in this PR.

Visual Proof

Before: no screenshot was retained before the fix. The regression tests reproduce the prior failure with oversized provider fields and assert that they cannot move the actions out of reach.

After, live desktop approval at the normal pane size:

Desktop approval at normal size

After, the same live approval in a 1280×240 pane, with the context scrolled and actions still fixed on screen:

Desktop approval in a constrained pane

After, the same live approval delivered through the paired iOS client:

Mobile approval on iPhone 17 Pro

Testing

  • I manually tested these changes locally

  • Automated tests added/updated

  • 135 focused main, shared, renderer, and mobile tests pass across the two review loops.

  • pnpm tc and the mobile TypeScript check pass.

  • pnpm run verify:localization-runtime-catalog passes.

  • pnpm run check:code-quality:changed passes with zero new findings.

  • GitHub CI passes static analysis, typecheck, all eight test shards, mobile verification, cross-version wire compatibility, macOS packaging, and Windows packaging.

  • Electron on macOS: a real Claude Bash approval remained fully actionable at 1728×999 and 1280×240. At the constrained size, the context scrolled from 0 to 60 px while the action row stayed at the same position; Escape during composition did not dismiss the request.

  • iPhone 17 Pro simulator on iOS 26.5: the paired mobile client received the same live journal item, rendered all provider context, and kept Allow, Allow for this session, Deny, and Stop above the composer. Deny settled the request through the real action path.

AI Disclosure

Review

The final independent review found the provider callback → session registry → durable journal → desktop/mobile rendering ownership correct and the pushed head clean. No new polling, listener, cache, persistent obligation, subprocess churn, or repeated serialization was added. Provider text is bounded before publication, stripped of terminal control sequences, and rendered as text.

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

No platform-specific shell, path, shortcut, process, or Git behavior changed. Optional journal fields preserve mixed-version clients; folder workspaces and SSH continue to use the execution host's existing session and journal path.

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)
  • After screenshots are attached; the missing pre-fix screenshot is explained and the prior overflow is covered by regression tests
  • 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)

… serialized tool input

The approval card built its title from the tool name and rendered
JSON.stringify(input) into an element with no height bound. Any large
payload - a file write's contents, a proposed plan - pushed the action
buttons past the viewport with no way to scroll to them, leaving the
prompt unanswerable without zooming the pane out.

Thread the agent SDK's own presentation fields through the prompt
registry into the journal item: title, displayName, description,
decisionReason, blockedPath and matchedAskRule. The SDK documents its
title as the prompt text to use instead of reconstructing one, and
warns that the decision reason may carry terminal escapes, so those are
stripped before rendering. The card now also shows why a request was
raised rather than only what it was.

Bound the detail in a scrollable region that is reachable by keyboard,
and cap it main-side with the existing shared tool-detail limit rather
than the far looser journal payload bound. Focus moves to the card when
a prompt appears and Escape resolves it, which previously did nothing
because the composer owning that handler is unmounted while a prompt is
pending.

Mobile rendered the same unbounded detail and is fixed alongside.
@coderabbitai

coderabbitai Bot commented Sep 16, 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: 157c5ad0-6d79-436a-b39f-11c443dda322

📥 Commits

Reviewing files that changed from the base of the PR and between 7f597fd and 0d3dc6c.

📒 Files selected for processing (7)
  • mobile/src/session/MobileNativeChatPermission.test.ts
  • mobile/src/session/MobileNativeChatPermission.tsx
  • src/main/runtime/claude-structured-session-integration.test.ts
  • src/renderer/src/components/native-chat/NativeChatApprovalCard.test.tsx
  • src/renderer/src/components/native-chat/NativeChatApprovalCard.tsx
  • src/renderer/src/components/native-chat/native-chat-interactive-prompt.ts
  • src/renderer/src/i18n/locales/en.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/i18n/locales/en.json

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


📝 Walkthrough

Walkthrough

The change adds optional approval presentation metadata to shared types and journal schemas. Claude permission handling sanitizes and stores this metadata, while approval journal items format and truncate tool details. Desktop and mobile approval views render the metadata with bounded scrolling and focus behavior. Tests cover propagation, sanitization, rendering, fallback titles, denial responses, and focus restoration.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 0d3dc

The approval presentation changes are ready to merge based on the current evidence.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 26.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 24 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description is detailed and covers the change, rationale, visual proof, testing, review, compatibility notes, and checklist. However, the required Linked Issue section does not provide an issue li… Add the issue reference in the required Fixes #<number> format, or provide the repository-approved linked issue identifier for this work.
✅ 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 identifies the main change: native-chat approvals now render from harness presentation data instead of serialized tool input.
Full details: Docstring Coverage

Explanation

Docstring coverage is 26.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 24 files. (1 skipped: 1 unsupported.)

Full details: Description check

Explanation

The description is detailed and covers the change, rationale, visual proof, testing, review, compatibility notes, and checklist. However, the required Linked Issue section does not provide an issue link and explicitly states that no separate issue exists.

  • 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 keyboard-coverage gap and one de-duplication suggestion.

Reviewed changes

  • Harness presentation threaded end to end — claudePermissionPresentation sanitizes title, displayName, description, decisionReason, blockedPath, and matchedAskRule from the SDK's canUseTool options and carries them through the prompt registry into the journal body.
  • Generic detail bounded — claudeApprovalItem pretty-prints tool input under the shared MAX_TOOL_DETAIL_LENGTH cap instead of JSON.stringify plus the journal payload bound, and the card renders it in a fixed-height, keyboard-focusable scroller.
  • Journal schema widened — optional displayName/description/decisionReason/blockedPath/matchedAskRule added to the approval type, zod schema, canonical test body, and main-side prompt-body bounds.
  • Keyboard handling — the approval card takes focus on appearance and resolves Escape itself, plus a reveal-focus re-arm so the composer reclaims focus once the prompt settles.
  • Mobile parity — the same fields render on mobile, with the generic detail moved into a bounded ScrollView.

ℹ️ Question prompts still trap Escape

The approval card now takes focus on appearance and cancels on Escape, but the question card has neither, and the structured session unmounts the composer for any pending prompt (prompt ? null : <NativeChatComposer>). So while a question is on screen a keyboard-only user still cannot dismiss it with Escape, even though its close button calls the same cancelPrompt the approval card now shortcuts.

Technical details
# Escape dismissal is approval-only

## Affected sites
- `src/renderer/src/components/native-chat/NativeChatQuestionCard.tsx` — no card-level focus or Escape handler (only per-option Enter/Space at ~line 200)
- `src/renderer/src/components/native-chat/NativeChatStructuredSession.tsx:317` — composer is unmounted whenever any prompt is pending, so the composer's Escape handler cannot cover the card

## Required outcome
- Escape over an on-screen question card dismisses it exactly as the approval card does, or an explicit decision that question prompts are intentionally not Escape-dismissable.

## Suggested approach (optional)
- Reuse the same card-level `role`/`tabIndex`/`onKeyDown` shape the approval card adopted, or lift the Escape handling into the prompt region that owns both cards.

## Open questions for the human
- Is the asymmetry intentional (a question requires a choice; an approval can be abandoned), or is question-card Escape just out of scope for this PR?

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | 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

  • Kept approval actions reachable — the card now shrinks within its flex column (min-h-0 shrink / overflow-hidden) instead of shrink-0, all provider context moved into one max-h-72 keyboard-focusable scroller, the title is clamped to two lines, and the action row is pinned shrink-0. Applied to both the renderer and mobile.
  • Trimmed unused scaffolding — removed the body?: ReactNode slot and the approval.plan.* i18n keys that shipped unused in the first commit.
  • De-duplicated the ask-rule type — ChatApproval.matchedAskRule now imports the shared AgentJournalApprovalMatchedAskRule, resolving the prior review's inline nitpick.
  • Added layout coverage — renderer and mobile tests assert oversized context stays inside one bounded scroller while the actions remain outside it; the structured-session integration test now expects the pretty-printed detail.

ℹ️ PR description now describes a removed design slot

The PR body still documents "an optional body slot so a future tool-specific renderer can replace the generic detail" and a follow-up plan renderer "layered on the body slot above." Commit 2 removed the body prop, so both statements are now inaccurate.

Technical details
# Stale design note in the PR description

## Affected sites
- PR #21087 body — "Design note" and "Follow-up, deliberately not in this PR" sections reference the removed slot
- `src/renderer/src/components/native-chat/NativeChatApprovalCard.tsx` — `body?: ReactNode` is no longer in the props type

## Required outcome
- The PR description reflects the current component surface, or the plan-renderer follow-up names a different seam.

</details>

<!--
Pullfrog review metadata. These findings were written against 0d3dc6ca78;
if commits have landed on brennanb2025/approval-card-broad-fix since, treat every specific bug, file, or
line callout as POTENTIALLY STALE and re-diff before acting on it.

- Mode: IncrementalReview (delta against prior pullfrog review)
- Files reviewed: 25
- Commits reviewed: 2
- Base: main (85d1ffc)
- Head: brennanb2025/approval-card-broad-fix (0d3dc6ca78)
- Reviewed commits:
  - 0d3dc6ca78 — fix(native-chat): keep approval actions reachable
  - 7f597fdeb8 — fix(native-chat): render approvals from the harness presentation, not serialized tool input
- Prior pullfrog review: 7f597fd (https://github.com/stablyai/orca/pull/21087#pullrequestreview-5228040854)
-->


<!-- PULLFROG_DIVIDER_DO_NOT_REMOVE_PLZ -->
<sup><a href="https://pullfrog.com"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pullfrog.com/logos/frog-white-full-18px.png"><img src="https://pullfrog.com/logos/frog-green-full-18px.png" width="9px" height="9px" style="vertical-align: middle; " alt="Pullfrog"></picture></a>&nbsp;&nbsp;| [View workflow run](https://github.com/stablyai/orca/actions/runs/35157187402/job/104999323967) | Using `DeepSeek Flash` (free via [Pullfrog for OSS](https://pullfrog.com/for-oss)) | [𝕏](https://x.com/pullfrogai)</sup>

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron validation (hidden renderer, CDP)

PASS on the live native-chat approval card at 0d3dc6ca782285eb88d9b343e555cde94d0ca0a7.

Normal pane

Normal pane: the live Bash approval renders title, description, reason, and JSON detail in one scroll region, with Allow / Allow for this session / Deny / Stop remaining visible below that region.

Constrained pane

Constrained 1280×240 pane: the context region scrolls while the action buttons stay on screen and do not move with the scroller.

The pending approval was left unanswered so mobile can inspect the same journal item.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Final review status: READY

Reviewed and pushed through 0d3dc6ca782285eb88d9b343e555cde94d0ca0a7. The repeated code-review loop is clean, and the final readiness audit returned PASS with no P0, P1, or P2 findings.

The review resolved the meaningful issues it found:

  • The provider callback now captures and sanitizes the approval presentation once, then sends it through the existing session registry and durable journal to desktop and mobile.
  • Every variable provider field shares one bounded scroller. The title and actions remain fixed, so oversized context cannot make the decision unreachable.
  • Unused future renderer/localization scaffolding was removed, the shared matched-rule type is reused, and the readable detail format is covered by the integration contract.

Architecture, compatibility, and performance are clean. The change adds no polling, retry loop, cache, timer, listener fanout, subprocess, or second settlement path. Optional journal fields preserve mixed-version clients, and provider strings are control-stripped, byte-bounded, and rendered as text.

Validation:

  • 135 focused desktop, main, shared, and mobile tests passed across the review loops; the final audit independently reran 87 desktop/main/shared and 3 mobile tests.
  • TypeScript, localization verification, changed-code quality, all eight CI test shards, static analysis, mobile verification, cross-version wire checks, and macOS/Windows packaging pass.
  • Live Electron proof covers normal and 1280×240 panes; the constrained capture confirms the context scrolls while actions stay fixed.
  • Live paired iOS proof shows all four real provider actions above the composer, and Deny settled the request through the real action path.
  • GitHub reports the PR mergeable with a clean merge state, and a synthetic merge with current origin/main is conflict-free.

The remaining evidence gap is limited to no physical Android, Windows UI, or SSH UI run. This change has no platform-specific execution behavior; mobile tests, Windows packaging, and wire compatibility cover the affected contracts.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Visual proof: oversized Write payload

approval-card-oversized-payload.png

A Write approval carrying a whole file — the case a user hit where the action row was pushed past the bottom of the pane and the prompt could only be answered by zooming out.

The measurements are the actual evidence, read back from the rendered element rather than inferred from the image:

{
  "maxHeight": "288px",
  "overflowY": "auto",
  "clientHeight": 288,
  "scrollHeight": 1504,
  "keyboardFocusable": true
}

The scroll region is capped at 288px while holding 1504px of content — so it genuinely overflows and genuinely scrolls — and it is focusable, so it can be scrolled without a mouse. The action row's bottom edge is asserted to land within the window.

One caveat, stated plainly: this capture is from a 1998px-tall window, where the buttons would be reachable with or without the fix. The screenshot shows the fixed state looks right; it does not by itself dramatize the failure. What distinguishes fixed from broken here is the bounded-scroller measurement above, not the picture. A starker before/after would need the pane deliberately shortened.

Produced by tests/e2e/native-chat-approval-card-oversized-payload.spec.ts, which seeds the approval envelope, asserts the bound and the reachable action row, then captures the image. Note e2e is not a required check in this repo, so the behavioural guards for this change live in vitest; this spec exists to produce evidence.

@brennanb2025
brennanb2025 merged commit aad41b1 into main Sep 16, 2026
29 checks passed
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
… serialized tool input (stablyai#21087)

* fix(native-chat): render approvals from the harness presentation, not serialized tool input

The approval card built its title from the tool name and rendered
JSON.stringify(input) into an element with no height bound. Any large
payload - a file write's contents, a proposed plan - pushed the action
buttons past the viewport with no way to scroll to them, leaving the
prompt unanswerable without zooming the pane out.

Thread the agent SDK's own presentation fields through the prompt
registry into the journal item: title, displayName, description,
decisionReason, blockedPath and matchedAskRule. The SDK documents its
title as the prompt text to use instead of reconstructing one, and
warns that the decision reason may carry terminal escapes, so those are
stripped before rendering. The card now also shows why a request was
raised rather than only what it was.

Bound the detail in a scrollable region that is reachable by keyboard,
and cap it main-side with the existing shared tool-detail limit rather
than the far looser journal payload bound. Focus moves to the card when
a prompt appears and Escape resolves it, which previously did nothing
because the composer owning that handler is unmounted while a prompt is
pending.

Mobile rendered the same unbounded detail and is fixed alongside.

* fix(native-chat): keep approval actions reachable
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