Skip to content

Handle large pastes in structured chat goal mode - #34654

Merged
brennanb2025 merged 9 commits into
mainfrom
brennanb2025/bug-orca-freezes-when-big-input-is-pasted
Oct 29, 2026
Merged

brennanb2025 merged 9 commits into
mainfrom
brennanb2025/bug-orca-freezes-when-big-input-is-pasted

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1331 $\color{#cf222e}{\Huge{\mathbf{−}}}$​44 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1287
Prod 16 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​422 $\color{#cf222e}{\Huge{\mathbf{−}}}$​165 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​257

Problem

Large pasted logs or JSON could freeze the chat editor (tracked in #32355). Ordinary structured chats already fold large text into a Pasted text attachment; goal mode still inserted the full source into the editor and could then reject it at the goal-length limit.

What changes

Goal mode uses the existing structured-chat paste treatment: large text becomes a Pasted text pill, and the objective references its stored file. Setting a goal protects its attachments before dispatch. A definite refusal releases only protection belonging exclusively to that attempt; accepted, uncertain or independently shared uses retain their files.

Independent durable user input written through affected journal step or lifecycle batches also acquires best-effort attachment protection. This protects content already saved in a conversation without adding an admission check or backfilling old history. A goal's own provisional restatement remains provisional.

Terminal-backed chats keep main's behavior throughout paste, editing, saving, restoring, copying and sending. Smaller structured pastes and Add to chat keep their existing behavior.

Implementation

The composer reuses the ordinary structured upload and size-admission pipeline for goal-mode paste. Goal journaling retains the existing claim schema and uses transaction-safe compensation for a proven refused attempt. Ownership receipts run after commit and before publication. This adds no saved goal owner, source store, terminal transport, paired-server operation or minimum server version. Typed commands and default permissions remain unchanged.

Differences from the common pattern

  • Intended: goal mode reuses the ordinary attachment rule for an existing action. Its independently applied goal request needs protection before dispatch and compensation after a proven refusal.
  • Intended: separate durable journal input acquires best-effort protection, including when no earlier claim exists; it does not add required availability admission or history backfill.
  • Temporary: follow-up PR, pasted-text viewer (Open pasted text in structured chats #35636). The lane's next PR adds source inspection; this PR keeps the existing structured Pasted text presentation and Copy behavior. This split is explicitly approved.

Validation

Five source review rounds, the independent performance pass and the whole-mechanism reference/readiness review are complete. Production SQLite tests cover goal refusal, rollback, shared use, independent durable input, streamed checkpoint durability and post-commit ownership. Renderer tests cover goal paste intake and terminal parity. Main was merged once before final validation; its composer extraction and merged #31180 queued-editor behavior are preserved. The subsequent CI fixture repair changes only tests and has independent review acceptance. CI is green on 2a232ab. Real QA on the exact head passed: baseline-created Claude/Codex pasted-file drafts survived a graceful upgrade with identical hashes, each agent returned two real file-content replies, and a 100 KiB Codex goal paste folded to a compact pill, completed from the saved file and restored its accepted state after a graceful restart. Default permissions were preserved. An old QA load-balancer route stalled one Codex attempt; it remains recorded as unpassed, and only isolated QA settings were corrected before normal recovery succeeded. All test copies stopped gracefully. Full-window before/after and result evidence is in the review-loop status comment. The pasted-text viewer remains the approved follow-up #35636.

…ts and goal mode

A paste of 32 KiB or more already became a "Pasted text" file in
structured chats, but terminal-backed chats and goal mode put the whole
text in the editor, where one long line can stall the window for seconds
(issue #32355). Every composer that can store the file now follows the
same rule.

- Terminal-backed chats on this machine save the file in the paste
  folder, where their pasted images already live; their sends claim
  nothing, so the attachment store's 30-day sweep must not reach it.
- Terminal-backed chats never get the structured 256 KB refusal.
- Setting a goal claims the uploads its objective names in the same
  journal write, so a goal's pasted file is not swept; a file already
  gone refuses the goal before the agent starts.
@brennanb2025
brennanb2025 marked this pull request as ready for review October 28, 2026 01:34
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

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: 39ffc65b-de42-421f-b7ed-8aecd8f982ef
Commits

Reviewing files that changed from the base of the PR and between badeabe and e117b72.

Files selected for processing: 1
  • src/main/native-chat/agent-session-journal/journal-store.ts

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

Walkthrough

Journal attachment claims now return referenced and newly inserted upload IDs. Journal write paths record claims after successful commits, while goal-specific tracking supports retaining or withdrawing claims. Composer paste staging no longer changes based on goal mode. Tests cover journal claim lifecycles and paste behavior across composer modes.

Priority: Normal

Merge Risk: Moderate · up to e117b

Ordinary streamed journal updates can take the slower full-durability path, reducing streaming throughput; this should be corrected before merge.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 18.18% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… 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 identifies the primary user-facing change: handling large pastes in structured chat goal mode.
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 description is detailed and relevant. It explains the problem, user-visible changes, implementation, scope boundaries, related issues, and validation results. It does not reproduce several templat…
Full details: Description check

Explanation

The description is detailed and relevant. It explains the problem, user-visible changes, implementation, scope boundaries, related issues, and validation results. It does not reproduce several template sections, including ELI5, Visual Proof, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist. It also references issues without an explicit Fixes # entry, but the available information is sufficient for review.

Full details: Docstring Coverage

Explanation

Docstring coverage is 18.18% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 11 functions across 19 files.

Resolution

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

Finishing Touches: 💡 2
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
⚔️ Resolve merge conflicts: 💡
  • Resolve merge conflict in branch brennanb2025/bug-orca-freezes-when-big-input-is-pasted
  • 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: 77c3ff9e-11c0-4fcf-8930-0fd0a0bafbf6
Commits

Reviewing files that changed from the base of the PR and between e8d5713 and 111591e.

Files selected for processing: 42
  • src/main/native-chat/agent-session-attachments/agent-session-attachment-claims.ts
  • src/main/native-chat/agent-session-journal/journal-epoch-controller.ts
  • src/main/native-chat/agent-session-journal/journal-epoch-replacement.ts
  • src/main/native-chat/agent-session-journal/journal-goal-attachment-inverse.ts
  • src/main/native-chat/agent-session-journal/journal-item-appender.ts
  • src/main/native-chat/agent-session-journal/journal-queue-adoption-plan.ts
  • src/main/native-chat/agent-session-journal/journal-queued-messages.ts
  • src/main/native-chat/agent-session-journal/journal-store-collaborators.ts
  • src/main/native-chat/agent-session-journal/journal-store.ts
  • src/main/native-chat/agent-session-journal/journal-submission-hook.ts
  • src/main/native-chat/agent-session-journal/journal-submission-writer.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-ready-operation-order.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-thread-goal.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-thread-goal.ts
  • src/main/window/clipboard-ipc-handlers.ts
  • src/main/window/native-chat-pasted-text-file.test.ts
  • src/main/window/native-chat-pasted-text-file.ts
  • src/main/window/native-chat-terminal-text-inputs.test.ts
  • src/main/window/native-chat-terminal-text-inputs.ts
  • src/main/window/native-chat-terminal-text-ipc.ts
  • src/preload/api/ui-bridge-clipboard-and-window-controls.ts
  • src/preload/api/ui-window-api.ts
  • src/renderer/src/components/native-chat/NativeChatComposer.paste-remount.test.tsx
  • src/renderer/src/components/native-chat/NativeChatComposer.tsx
  • src/renderer/src/components/native-chat/NativeChatFileReferencePill.tsx
  • src/renderer/src/components/native-chat/native-chat-composer-draft-indexeddb.test.ts
  • src/renderer/src/components/native-chat/native-chat-composer-draft-indexeddb.ts
  • src/renderer/src/components/native-chat/native-chat-composer-draft-load.ts
  • src/renderer/src/components/native-chat/native-chat-composer-draft-persistence.ts
  • src/renderer/src/components/native-chat/native-chat-composer-draft-storage.ts
  • src/renderer/src/components/native-chat/native-chat-composer-draft-store.ts
  • src/renderer/src/components/native-chat/native-chat-composer-pasted-text-references.ts
  • src/renderer/src/components/native-chat/native-chat-pasted-text-history.ts
  • src/renderer/src/components/native-chat/native-chat-pasted-text-state.ts
  • src/renderer/src/components/native-chat/native-chat-terminal-paste-sources.ts
  • src/renderer/src/components/native-chat/use-native-chat-composer-handle.ts
  • src/renderer/src/components/native-chat/use-native-chat-pasted-text-file.test.tsx
  • src/renderer/src/components/native-chat/use-native-chat-pasted-text-file.ts
  • src/renderer/src/components/native-chat/use-native-chat-pty-composer-send.test.tsx
  • src/renderer/src/components/native-chat/use-native-chat-pty-composer-send.ts
  • src/renderer/src/web/preload-api/web-ui-api.ts
  • src/shared/native-chat-terminal-text-input.ts

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

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

Minor · Abort materialization when the draft changes. · use-native-chat-pty-composer-send.ts:224-227

src/renderer/src/components/native-chat/use-native-chat-pty-composer-send.ts:224-227
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Abort materialization when the draft changes.

The materialization call runs asynchronously after submitted is captured. If the user edits the draft while the scope and PTY remain unchanged, the current guard dispatches the stale captured input. Compare the current draft with submitted and retire the request when they differ.

Suggested fix
          cancelled ||
          latest.current.draftScopeKey !== args.draftScopeKey ||
+         latest.current.draft !== submitted ||
          latest.current.resolveTarget()?.ptyId !== target.ptyId

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: bf74049f-28bb-4c05-b51d-b53c92bb14bf
Commits

Reviewing files that changed from the base of the PR and between 7359b22 and 3e8d86f.

Files selected for processing: 2
  • src/main/native-chat/agent-session-wire/structured-agent-session-thread-goal.test.ts
  • src/renderer/src/components/native-chat/use-native-chat-pty-composer-send.test.tsx

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

@greptile-apps

greptile-apps Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] No blocking code issue was found in the changes since the previous review.

Summary

Large pastes in structured goal mode now use the existing Pasted text attachment flow.

  • Saved chat messages keep referenced attachments from being swept.
  • Goal objectives keep their referenced files available to chat.
  • Goal mode turns large pastes into stored file references.

No new actionable issues were found. Review checks were static; tests were not run.

Reviews (5) · Last reviewed commit: "Align goal and deferred paste fixtures w..." · Reviewed by Greptile

@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: 04fd9629-2a64-4a94-9099-d13c6e6d82fd
Commits

Reviewing files that changed from the base of the PR and between 3e8d86f and badeabe.

Files selected for processing: 5
  • src/renderer/src/components/native-chat/NativeChatComposer.paste-remount.test.tsx
  • src/renderer/src/components/native-chat/NativeChatComposer.tsx
  • src/renderer/src/components/native-chat/use-native-chat-composer-handle.ts
  • src/renderer/src/components/native-chat/use-native-chat-pasted-text-file.test.tsx
  • src/renderer/src/components/native-chat/use-native-chat-pasted-text-file.ts

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

@brennanb2025 brennanb2025 changed the title Turn a big paste into a file in terminal-backed chats and goal mode Handle large pastes in structured chat goal mode Oct 28, 2026
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Large pasted logs or JSON could fill the goal editor with the entire source, freezing editing and running into the goal-length limit. This PR gives supported structured-chat goals the existing Pasted text pill and sends the saved file reference. It protects the file before goal dispatch and releases only an exclusively provisional claim after a definite refusal. Ordinary structured-chat paste and terminal-backed chats keep main's behavior.

The full loop finished five source rounds. Repairs cover refusal/rollback/shared-use ownership, post-commit ordering, the prototype-method contract, and streamed-checkpoint/queue scaling. Independent correctness, performance and whole-mechanism reference/readiness reviews are clean. Main was merged once; the later fixture-only repair was independently checked. Source and WSL CI passed on 2a232abc293fc8fa15a127ccd8fcbc06f8e58c11.

Real QA on the M4Air carried baseline-created Claude/Codex drafts through a graceful upgrade, verified exact file hashes, and obtained two real file-content replies from each agent under unchanged defaults. The old QA Codex bridge stalled after a successful read; that attempt remains unpassed. After correcting only isolated QA routing, the normal restart recovery completed the inherited request and the fresh-file send. Passed Claude checks were retained.

The supported Codex goal flow also passed: a fresh 100 KiB paste became a compact pill, normal goal submission referenced the saved file, and the real agent read its hidden marker and completed the goal. A further graceful restart restored the same objective, completed history, claim timestamp and exact file hash without another provider turn. All four test-copy launches stopped gracefully; QA ticket 3086 is released. No product defect was observed.

Temporary: follow-up PR, pasted-text viewer (#35636), owned by the lane owner. This approved split retains the existing passive pill and Copy behavior here. Terminal-only mechanisms were removed under the binding scope ruling; terminal parity is covered by source comparison and focused tests. Phone/viewer/paired inspection were outside this run. Refusal races and sweep behavior are proved by production SQLite tests, rather than claimed as live QA outcomes.

For Brennan's review

Saved structured-chat drafts: baseline → upgraded PR
Agent Baseline PR after graceful upgrade
Claude Claude baseline saved paste Claude restored paste
Codex Codex baseline saved paste Codex restored paste
100 KiB goal paste: main inline → PR folded
Main PR
Main goal paste inline PR goal paste folded
Real file-content replies and accepted-goal restoration
Claude: two real content replies Codex: recovered inherited request and fresh-file reply
Claude file-content results Codex file-content results
Completed goal from pasted file Same completed goal after graceful restart
Goal completed from actual saved file Accepted goal restored after graceful restart

Three review spots: composer eligibility, goal protection and refusal, and exclusive provisional withdrawal.

@brennanb2025
brennanb2025 merged commit 539c46b into main Oct 29, 2026
54 of 55 checks passed
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