Repository navigation
fix(native-chat): stop clipping assistant text blocks at the tool-preview cap - #12159
Conversation
…view cap Long assistant messages read over a paired connection (headless orca serve viewed from desktop or mobile) were cut at 4,000 chars with a '… (truncated)' marker and no way to read the rest. The mobile payload diet in nativeChat RPC applied the tool-preview char cap to text blocks, which are the fully rendered message body. Give text blocks their own 64k safety ceiling so real replies pass through whole while pathological multi-hundred-KB blocks still can't freeze the phone. Fixes STA-3230
Greptile SummaryFixes a regression where long assistant
Confidence Score: 5/5Safe to merge — the change is a two-constant, two-call-site string-budget adjustment with no new I/O, no schema changes, and full test coverage for all affected paths. The diff is minimal and surgically precise: clip() gains a parameter, clipBlock switches text blocks to the new 64k constant, and every other block type keeps its existing budget unchanged. Both the read and subscribe code paths route through the same clipBlock, so the fix is applied consistently. No auth, path, network, or dependency changes are involved. Files Needing Attention: No files require special attention.
|
| Filename | Overview |
|---|---|
| src/main/runtime/rpc/methods/native-chat.ts | Introduces a separate 64k cap (MOBILE_TEXT_BLOCK_CHAR_CAP) for text blocks while keeping the 4k cap for tool-result/tool-call previews; adds a cap parameter to clip() so all callers are explicit about which budget to use. |
| src/main/runtime/rpc/methods/native-chat.test.ts | Adds two readSession regression tests and one subscribe test verifying all three frame types carry unclipped text for mobile clients. Existing clipping assertions are tightened with exact toBe expectations. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[RPC call] --> B{clientKind?}
B -- runtime/undefined --> C[no char clipping]
B -- mobile --> D[sanitizeMessage via clipBlock]
D --> F{block.type?}
F -- text --> G{length > 64k?}
G -- No --> H[pass through unchanged]
G -- Yes --> I[clip to 64k + marker]
F -- tool-result --> J{length > 4k?}
J -- No --> K[pass through unchanged]
J -- Yes --> L[clip to 4k + marker]
F -- tool-call --> M[sanitizeToolInput 4k budget]
Reviews (2): Last reviewed commit: "test(native-chat): cover long text strea..." | Re-trigger Greptile
|
Warning Review limit reached
Next review available in: 4 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughMobile chat block clipping now uses separate limits for text and tool-result blocks. Text blocks allow up to 64,000 characters. Tool-result blocks remain limited to 4,000 characters. Tests cover unchanged long text below the limit and truncation of oversized text with a marker. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 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.
🧹 Nitpick comments (1)
src/main/runtime/rpc/methods/native-chat.test.ts (1)
170-182: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAssert the exact 64,000-character contract.
The current assertions pass for any smaller cap. Assert the exact preserved prefix and truncation marker so a regression to 4,000 or another value fails.
Suggested assertion
- expect(block.text.length).toBeLessThan(text.length) - expect(block.text).toContain('truncated') + expect(block.text).toBe(`${text.slice(0, 64_000)}\n… (truncated)`)
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a01f77ec-02fd-4444-89d3-564bf8f10cf0
📒 Files selected for processing (2)
src/main/runtime/rpc/methods/native-chat.test.tssrc/main/runtime/rpc/methods/native-chat.ts
|
Electron QA (isolated paired-desktop instance) passed for STA-3230.
Start of the long response: Completion sentinel preserved: |
…view cap (stablyai#12159) * fix(native-chat): stop clipping assistant text blocks at the tool-preview cap Long assistant messages read over a paired connection (headless orca serve viewed from desktop or mobile) were cut at 4,000 chars with a '… (truncated)' marker and no way to read the rest. The mobile payload diet in nativeChat RPC applied the tool-preview char cap to text blocks, which are the fully rendered message body. Give text blocks their own 64k safety ceiling so real replies pass through whole while pathological multi-hundred-KB blocks still can't freeze the phone. Fixes STA-3230 * test(native-chat): cover long text stream frames


Summary
Long assistant messages viewed over a paired connection (headless
orca serveviewed from a paired desktop client or the mobile app) were cut short with a… (truncated)marker and no way to read the rest (STA-3230, GitHub #12138). The mobile payload diet in thenativeChat.readSession/nativeChat.subscriberuntime RPC applied the 4,000-char tool-preview cap totextblocks — the fully rendered message body — for any connection whose paired device token has scopemobile(which includes desktops that redeem a--serve-mobile-pairingoffer, so both clients truncated identically). The reporter's "exactly 60 chars of the code block" was4000 − prose length; the collapsed newline was the broken markdown left by a mid-code-block cut.Fix at the source, shared by both clients:
textblocks now get their own generous 64k-char safety ceiling (real replies pass through whole), while tool-result/tool-call bodies keep the 4,000-char preview diet that the cap was designed for. No renderer changes needed on desktop or mobile.Screenshots
No visual change (transport fix; the chat views simply receive the full message text they already render).
Testing
pnpm lint(oxlint clean on the repo sweep)pnpm typecheckpnpm test(targeted:vitest run --config config/vitest.config.ts src/main/runtime/rpc/methods/native-chat.test.ts— 18/18, including 2 new regression tests)pnpm build(build:electron-vite+build:cli, used for the live repro/verify rig)mobileclients, and a 70k pathological block must still clip at the ceiling.Live end-to-end verification on an isolated
orca serverig (tempHOME+ORCA_USER_DATA_PATH; the primary daemon untouched), with a planted Claude transcript engineered so the 4,000-char boundary lands 60 chars into a trailing fenced code block, mirroring the ticket exactly:plans/lessons-cont\n… (truncated); runtime-scope token → full 4,149 chars. Reproduced identically through a real paired desktop instance (addFromPairingCode→runtimeEnvironments.call, the same bridge the chat view's transport uses).AI Review Report
Reviewed the change for: regression risk to the mobile payload diet (tool-result/tool-call clipping is byte-for-byte unchanged, verified by the existing 16 tests), wire-size risk from unclipped text (bounded by the new 64k ceiling, the 40-message window, and the upstream 2MB transcript-record cap), and parity with the desktop IPC path (which has never clipped). Confirmed both the read and subscribe paths flow through the same
clipBlock, so snapshots, replacements, and appends all benefit. Cross-platform: the change is pure main-process string handling with no shortcuts, labels, paths, shell, or Electron platform APIs; it is identical on macOS, Linux, and Windows hosts and for SSH/WSL-backed runtimes, and applies equally to folder workspaces and git worktrees.Security Audit
No new input surfaces: the RPC schema is unchanged, and the modified code only alters the char budget applied to already-parsed transcript strings before serialization. No command execution, path handling, auth, secrets, or dependency changes. The clip remains a bound (now 64k for text), so a hostile transcript still cannot ship unbounded payloads to paired clients; tool-input sanitization (depth/node/key budgets) is untouched. IPC/RPC gating by
clientKindis unchanged.Notes
mobileclient for every payload-diet decision, not just this one. If we want full-fidelity desktop behavior over mobile-scoped pairings, scope negotiation deserves its own ticket.Fixes STA-3230 (https://linear.app/stably/issue/STA-3230). Closes #12138.