Repository navigation
Handle large pastes in structured chat goal mode - #34654
Conversation
…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.
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review.
|
There was a problem hiding this comment.
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
Files selected for processing: 42-
src/main/native-chat/agent-session-attachments/agent-session-attachment-claims.tssrc/main/native-chat/agent-session-journal/journal-epoch-controller.tssrc/main/native-chat/agent-session-journal/journal-epoch-replacement.tssrc/main/native-chat/agent-session-journal/journal-goal-attachment-inverse.tssrc/main/native-chat/agent-session-journal/journal-item-appender.tssrc/main/native-chat/agent-session-journal/journal-queue-adoption-plan.tssrc/main/native-chat/agent-session-journal/journal-queued-messages.tssrc/main/native-chat/agent-session-journal/journal-store-collaborators.tssrc/main/native-chat/agent-session-journal/journal-store.tssrc/main/native-chat/agent-session-journal/journal-submission-hook.tssrc/main/native-chat/agent-session-journal/journal-submission-writer.tssrc/main/native-chat/agent-session-wire/structured-agent-session-ready-operation-order.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-thread-goal.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-thread-goal.tssrc/main/window/clipboard-ipc-handlers.tssrc/main/window/native-chat-pasted-text-file.test.tssrc/main/window/native-chat-pasted-text-file.tssrc/main/window/native-chat-terminal-text-inputs.test.tssrc/main/window/native-chat-terminal-text-inputs.tssrc/main/window/native-chat-terminal-text-ipc.tssrc/preload/api/ui-bridge-clipboard-and-window-controls.tssrc/preload/api/ui-window-api.tssrc/renderer/src/components/native-chat/NativeChatComposer.paste-remount.test.tsxsrc/renderer/src/components/native-chat/NativeChatComposer.tsxsrc/renderer/src/components/native-chat/NativeChatFileReferencePill.tsxsrc/renderer/src/components/native-chat/native-chat-composer-draft-indexeddb.test.tssrc/renderer/src/components/native-chat/native-chat-composer-draft-indexeddb.tssrc/renderer/src/components/native-chat/native-chat-composer-draft-load.tssrc/renderer/src/components/native-chat/native-chat-composer-draft-persistence.tssrc/renderer/src/components/native-chat/native-chat-composer-draft-storage.tssrc/renderer/src/components/native-chat/native-chat-composer-draft-store.tssrc/renderer/src/components/native-chat/native-chat-composer-pasted-text-references.tssrc/renderer/src/components/native-chat/native-chat-pasted-text-history.tssrc/renderer/src/components/native-chat/native-chat-pasted-text-state.tssrc/renderer/src/components/native-chat/native-chat-terminal-paste-sources.tssrc/renderer/src/components/native-chat/use-native-chat-composer-handle.tssrc/renderer/src/components/native-chat/use-native-chat-pasted-text-file.test.tsxsrc/renderer/src/components/native-chat/use-native-chat-pasted-text-file.tssrc/renderer/src/components/native-chat/use-native-chat-pty-composer-send.test.tsxsrc/renderer/src/components/native-chat/use-native-chat-pty-composer-send.tssrc/renderer/src/web/preload-api/web-ui-api.tssrc/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.
-
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

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 winAbort materialization when the draft changes.
The materialization call runs asynchronously after
submittedis 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 withsubmittedand 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
Files selected for processing: 2-
src/main/native-chat/agent-session-wire/structured-agent-session-thread-goal.test.tssrc/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.
-
[Medium impact] No blocking code issue was found in the changes since the previous review. SummaryLarge pastes in structured goal mode now use the existing Pasted text attachment flow.
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 |
There was a problem hiding this comment.
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
Files selected for processing: 5-
src/renderer/src/components/native-chat/NativeChatComposer.paste-remount.test.tsxsrc/renderer/src/components/native-chat/NativeChatComposer.tsxsrc/renderer/src/components/native-chat/use-native-chat-composer-handle.tssrc/renderer/src/components/native-chat/use-native-chat-pasted-text-file.test.tsxsrc/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.
-
|
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 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
Real file-content replies and accepted-goal restoration
Three review spots: composer eligibility, goal protection and refusal, and exclusive provisional withdrawal. |










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