You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(native-chat): keep a large paste from freezing the chat composer - #34501
When you paste a very long line into the chat box, Orca built all of it into the editor at once. The browser then spent seconds, or tens of seconds, laying out that one line, and the window froze. Many short lines are cheap, so the length of a line is what matters, not the total size. Now a paste with a line that is too long, or that is too big, becomes a "Pasted text" file, as large pastes already did in some chats. If files cannot be used, Orca shows a message and keeps your draft.
Before: in goal mode, in a terminal-backed chat, and on a host without file support, a paste always went into the editor whole. One 100 KB line stalled the window for 2.2 s, and one 1 MiB line for 23 s. A first change by Codex refused any paste once the whole draft passed 32 KiB. That also blocked cheap multi-line text, and still let a long single line through.
After:
native-chat-inline-paste-limits.ts decides if the pasted text can go into the editor: it must be at most 256 KB and have no line over 16,384 characters. Only the pasted text counts, so a small paste into a long draft still works.
When files work, a paste that fails this check, or is over 32 KiB, becomes a "Pasted text" file (use-native-chat-pasted-text-file.ts). Otherwise Orca shows a message and leaves the draft alone.
Terminal-backed chats on this machine can now store a long paste as a file (NativeChatComposer.tsx). Their send path already resolves the file reference.
A paired host whose status has not loaded yet gets a "still connecting" message (nativeChatPasteUploadHostUnverified). A host that cannot receive files still accepts multi-line text up to 256 KB.
"Add to chat" (quoting a transcript selection) uses the same check (use-native-chat-composer-handle.ts).
Unchanged: pastes into the terminal itself, and structured chats that already turn a 32 KiB paste into a file.
Why
I measured the cost in the real app. It follows the longest line: a 31 KB single line takes about 670 ms, 100 KB takes about 1 to 2 s, and 1 MiB takes 23 s. A 200 KB multi-line draft takes 7 ms, and a 1 MiB log of short lines about 340 ms. The slow part is the browser's own text layout for the caret (Selection.collapse), not our JavaScript. So bounding the line and the pasted size is the direct fix. Turning a long paste into a file costs the editor nothing, and the user keeps all of the text.
I did not cap the whole draft, as Codex's first change did. The draft around a paste does not change the cost of the paste, and that rule refused cheap multi-line pastes.
The reporter did not say which screen they pasted into. I confirmed this freeze in the chat composer. I tested the terminal path (100 KB to 5 MB) and saw no stall. I did not test the editor or other inputs. I asked the reporter on the issue.
Visual Proof
Timings in the real app (hidden dev copy, macOS, terminal-backed chat), the same paste on the unfixed code and on this branch. There is no screenshot: the visible change is a "Pasted text" pill instead of a stall.
Paste
Before
After
100 KB, one line
2,178 ms stall
12 ms (file)
1 MiB log, short lines
339 ms
24 ms (file)
20 KB, one line
287 ms
11 ms (file)
5 KB, one line
7 ms
13 ms (inline)
A 1 MiB single line also became a file in 27 ms on this branch. I did not run it on the unfixed code, to avoid a 23 s freeze. Codex measured 23 s for it.
Testing
Automated, macOS: pnpm tc:web, pnpm tc:node, oxlint, oxfmt and pnpm check:changed (21 checks) pass. The native-chat and i18n folders pass: 378 files, 3,909 tests.
New tests cover: a one-character paste into a 40 KB line; multi-line text in goal mode, without file support, and on a host that cannot receive files; the 16,384-character boundary, bare CR and CRLF; a line too long to edit that becomes a file; a terminal-backed chat on this machine (file), elsewhere (refused or inline); and a huge "Add to chat" quote.
Mutation checks: removing each of seven pieces of the change makes a test fail.
Real app: the table above, with a 20 ms timer and the paste event on the composer.
Not tested: Windows, Linux, a real remote server, sending a message from a terminal-backed chat with the new file pill, drag-drop of text, the queued-message editor. "Add to chat" is covered by unit tests only.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Written with Claude (Sonnet 5.5) via Claude Code, building on a first fix and review by Codex. I reviewed the diff, measured the cost in the real app and ran the verification above.
Cross-platform: renderer-only, no paths or shells. Chromium layout cost is the same on every platform, so the limits apply everywhere. Only macOS was tested.
SSH/remote: the attachment owner decides. Local owners store files. Paired hosts store files when they report the capability. Other owners (SSH, WSL) get the inline check. Older servers still accept multi-line text up to 256 KB.
Mobile: no change.
Performance: pastes that were seconds of stall are now one IPC call. The new check is one linear pass over the pasted text, after a size check.
Security: the same savePastedTextAsFile call as before, now also used for terminal-backed chats on this machine.
Folder workspaces: not affected.
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
Product change to review: terminal-backed chats on this machine now create "Pasted text" files for long pastes, as structured chats do. Before, they inserted the text inline.
Strings are added in English only (inlinePasteLineTooLong, pasteHostConnecting).
The limits (16,384 characters per line, 256 KB) are constants in one file and easy to change.
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) — lint, typecheck, check:changed and the native-chat tests pass locally; the full test run and build are left to CI
Pasting a long line into the chat composer built the whole text into the
editor at once. Chromium lays out one long line in superlinear time: a
100 KB line stalled the window for about 2 s and a 1 MiB line for about
23 s. Goal mode, terminal-backed chats and hosts without file support took
this path. Many short lines stay cheap, so size alone was the wrong test.
- A paste with a line over 16,384 characters, or over 256 KB in total,
becomes a "Pasted text" file whenever files work. Otherwise it is refused
with a message and the draft is left alone. Only the pasted text is
judged, so a small paste into a long draft still works.
- Terminal-backed chats on this machine can now store a long paste as a file
too. Their send path already resolves the file reference.
- A paired host whose status has not loaded yet gets a "still connecting"
message. Hosts that cannot receive files still accept multi-line text up
to 256 KB inline.
- "Add to chat" (quoting a transcript selection) uses the same bound.
In a terminal-backed chat, pasting 100 KB on one line went from a 2,178 ms
stall to 12 ms, and a 1 MiB log from 339 ms to 24 ms.
Builds on a first fix by Codex that capped the whole draft at 32 KiB.
Refs stablyai#32355
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The native chat composer now checks inline pastes against a 256 KiB UTF-8 limit and a 16,384-character line limit. Eligible text can be staged as a file when file pasting is available and a local or cached runtime upload target exists. The composer displays notices when a paste cannot be staged or a runtime host is still connecting. Tests cover paste handling, upload behavior, undo, and sending while a file save is pending.
Priority: Normal
Severity of issue fixed: Medium
Merge Risk: Low · up to 5e2e2
Long pasted text can still reach the composer through the clipboard-button fallback when the destination is unavailable, which may stall the editor. This narrow edge case is easy to fix by checking the text before the fallback. The main paste flows and the terminal-backed chat flow behave as intended.
Pre-merge checks: 5
Check name
Status
Explanation
Title check
The title clearly and concisely describes the main change: preventing large pastes from freezing the native chat composer.
Description check
The description covers the required sections, explains the user impact and implementation, links issue #32355, documents testing and limitations, includes AI disclosure, and addresses cross-platform a…
Linked Issues check
Directly linked issue #32355 reports that Orca freezes when very long text (logs, JSON) is pasted. Its only coding requirement is to stop that freeze. The reporter's wish to force-paste text as an att…
Out of Scope Changes check
All changed areas serve the paste-freeze fix for #32355: - native-chat-inline-paste-limits.ts: the inline limits and notices. - use-native-chat-pasted-text-file.ts: file routing, the editor getter, an…
Docstring Coverage
Docstring coverage is inconclusive: files from earlier reviews still need to be rechecked within the check's analysis limits. Not blocking.
Full details: Description check
Explanation
The description covers the required sections, explains the user impact and implementation, links issue #32355, documents testing and limitations, includes AI disclosure, and addresses cross-platform and remote considerations. The visual proof uses timing comparisons instead of attachments, but the overall description is complete and relevant.
Full details: Linked Issues check
Explanation
Directly linked issue #32355 reports that Orca freezes when very long text (logs, JSON) is pasted. Its only coding requirement is to stop that freeze. The reporter's wish to force-paste text as an attachment is a separate, prospective feature request. It is not an acceptance criterion here, so this PR does not need to add a force-paste option.
native-chat-inline-paste-limits.ts keeps a paste inline only when its UTF-8 size is at most 256 KiB and no line exceeds 16,384 characters. It splits lines on CRLF, CR, or LF and checks only the pasted text.
use-native-chat-pasted-text-file.ts sends a paste to a 'Pasted text' file when the paste is at least 32 KiB, fails the inline check, or would make the draft too large. This requires a local owner or a cached runtime upload target with file capability.
When no file path applies, the hook refuses the paste with a notice and does not insert the text. A host with unverified status shows the 'still connecting' notice (nativeChatPasteUploadHostUnverified).
Any paste that stays inline is bounded, so the long-line layout cost that causes the freeze is bounded too.
The PR description reports measured timings that support this mechanism. The changes since the previous review did not change this path in a way that alters the verdict. Automated test coverage is described in the PR and was not re-run here. The PTY-send-during-save guard is supported by the author's description and test (commit 4a35cf2). It was not independently re-read in this review.
Full details: Out of Scope Changes check
Explanation
All changed areas serve the paste-freeze fix for #32355:
native-chat-inline-paste-limits.ts: the inline limits and notices.
use-native-chat-pasted-text-file.ts: file routing, the editor getter, and the filePastes flag.
use-native-chat-composer-handle.ts: applies the same inline limit to 'Add to chat' transcript quotes, which insert long text by the same route.
native-chat-attachment-upload.ts: nativeChatPasteUploadHostUnverified, which drives the 'still connecting' notice for paste uploads.
NativeChatComposerPane.tsx: always passes the attachment scope editor as pastedTextEditor, so file pastes can reach the editor in every transport.
en.json: the three new English notices.
Tests: cover the new paths.
Enabling file pastes for terminal-backed chats on this machine is a product change. It is on the same paste path and is stated as such in the PR description. Terminal (PTY) input and structured-chat 32 KiB behavior are not changed, as the PR states. No unrelated change was found in the reviewed files.
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.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
nl -ba src/renderer/src/components/native-chat/NativeChatComposer.tsx | sed -n '250,265p'
Repository: stablyai/orca
Length of output: 638
Script executed:
sed -n '1,180p' src/renderer/src/components/native-chat/use-native-chat-composer-submit.ts
Repository: stablyai/orca
Length of output: 5816
Block PTY sends while pasted text is saving.
Completed pasted-text tokens are resolved correctly. However, admitNativeChatPastedText allows the saving state, and resolveNativeChatPastedText leaves that token unchanged. The non-structured submit path calls sendPty() without checking disabled, so pressing Enter during the save can send the raw token.
… saving
A terminal-backed chat can now store a long paste as a file. Pressing Enter
before the file is written must send nothing, and a send after it must carry
the file path, never the placeholder. Removing the pasted-text admission from
the PTY send path makes this test fail.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@coderabbitai On NativeChatComposer.tsx:217 (block PTY sends while pasted text is saving): I could not reproduce this, so I am not changing the code.
admitNativeChatPastedText returns false for the saving state (return state === null), and useNativeChatPtyComposerSend returns when it is false. So Enter during a save writes nothing to the PTY. The Send button is already held by attachments.pastedTextSaving through sendHeld.
I added a test for the exact case in 4a35cf2. A terminal-backed chat pastes 1 MiB, Enter is pressed while the file is still being written, and the PTY receives no input. After the save finishes, the next send carries @/tmp/pasted.txt, not the placeholder. If I remove the admission check from use-native-chat-pty-composer-send.ts, the test fails with three PTY writes during the save.
Your suggested disabled || attachments.pastedTextSaving would also block slash commands and the command picker during a save, which does not help here.
Revalidate settled pasted-file references before PTY dispatch.
A host-qualified worktree refresh can change the live runtime owner without changing the pane key or remounting NativeChatComposer. The settled path remains in the same draft scope. The PTY send path then resolves and sends that path as ordinary text without checking the current owner. Invalidate or revalidate settled pasted-file references against the current owner before dispatch.
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: 2742933b-26b2-4746-b271-833d87da0c74
Commits
Reviewing files that changed from the base of the PR and between 39556fd and 4a35cf2.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
@thefrikidude You’re right. I withdraw this finding. The existing guard already blocks PTY sends while pasted text is saving.
I checked the source:
admitNativeChatPastedText returns false for the saving state.
useNativeChatPtyComposerSend returns immediately when admission fails.
sendHeld includes attachments.pastedTextSaving.
The regression test checks that an early send produces no PTY input and that a later send includes @/tmp/pasted.txt. I inspected the test but did not run it.
My proposed disabled || attachments.pastedTextSaving change is unnecessary.
📝 I couldn't check this conversation for new learnings, so no new learning was saved.
Validate clipboard text before the draft fallback.
pasteFromClipboard() accepts up to 16 MiB. If the captured destination is mismatched or inactive, or bounded insertion returns false, insertCapturedText() calls insertNativeChatComposerDraftText(). That helper appends the complete text without checking the 256 KiB or 16,384-character-line limits. The oversized text updates the subscribed native-chat draft and can later stall the editor instead of showing the inline-paste notice.
Validate the text before this clipboard fallback. Keep the bounded insertion first so supported file staging remains unchanged.
Suggested fix
diff --git a/src/renderer/src/components/native-chat/native-chat-paste-destination.ts b/src/renderer/src/components/native-chat/native-chat-paste-destination.ts
@@
import { nativeChatPasteUnavailableNotice } from '@/lib/native-chat-paste-request'
+import {+ nativeChatInlinePasteNotice,+ nativeChatInlinePasteProblem+} from './native-chat-inline-paste-limits'
@@
}
if (destination) {
+ const problem = nativeChatInlinePasteProblem(text)+ if (problem) {+ setNotice(nativeChatInlinePasteNotice(problem))+ return+ }
insertNativeChatComposerDraftText(destination.scopeKey, text, { paste: true })
} else {
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: 223a17ea-0848-4e3f-be71-54cde4ac4486
Commits
Reviewing files that changed from the base of the PR and between 4a35cf2 and 5e2e2d4.
Files skipped from review as they are similar to previous changes: 1
src/renderer/src/i18n/locales/en.json
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Thanks @thefrikidude — this was taken over and landed in #36031 with you as co-author on every commit. The final fix keeps long pastes inline: it turns off font-kerning only on unbroken runs over 256 characters, which removes the layout freeze at the source rather than converting the paste to a file. Closing in favour of #36031.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
When you paste a very long line into the chat box, Orca built all of it into the editor at once. The browser then spent seconds, or tens of seconds, laying out that one line, and the window froze. Many short lines are cheap, so the length of a line is what matters, not the total size. Now a paste with a line that is too long, or that is too big, becomes a "Pasted text" file, as large pastes already did in some chats. If files cannot be used, Orca shows a message and keeps your draft.
Author: @thefrikidude
What Changed
native-chat-inline-paste-limits.tsdecides if the pasted text can go into the editor: it must be at most 256 KB and have no line over 16,384 characters. Only the pasted text counts, so a small paste into a long draft still works.use-native-chat-pasted-text-file.ts). Otherwise Orca shows a message and leaves the draft alone.NativeChatComposer.tsx). Their send path already resolves the file reference.nativeChatPasteUploadHostUnverified). A host that cannot receive files still accepts multi-line text up to 256 KB.use-native-chat-composer-handle.ts).Why
I measured the cost in the real app. It follows the longest line: a 31 KB single line takes about 670 ms, 100 KB takes about 1 to 2 s, and 1 MiB takes 23 s. A 200 KB multi-line draft takes 7 ms, and a 1 MiB log of short lines about 340 ms. The slow part is the browser's own text layout for the caret (
Selection.collapse), not our JavaScript. So bounding the line and the pasted size is the direct fix. Turning a long paste into a file costs the editor nothing, and the user keeps all of the text.I did not cap the whole draft, as Codex's first change did. The draft around a paste does not change the cost of the paste, and that rule refused cheap multi-line pastes.
Linked Issue
Fixes #32355
The reporter did not say which screen they pasted into. I confirmed this freeze in the chat composer. I tested the terminal path (100 KB to 5 MB) and saw no stall. I did not test the editor or other inputs. I asked the reporter on the issue.
Visual Proof
Timings in the real app (hidden dev copy, macOS, terminal-backed chat), the same paste on the unfixed code and on this branch. There is no screenshot: the visible change is a "Pasted text" pill instead of a stall.
A 1 MiB single line also became a file in 27 ms on this branch. I did not run it on the unfixed code, to avoid a 23 s freeze. Codex measured 23 s for it.
Testing
Automated, macOS:
pnpm tc:web,pnpm tc:node, oxlint, oxfmt andpnpm check:changed(21 checks) pass. Thenative-chatandi18nfolders pass: 378 files, 3,909 tests.New tests cover: a one-character paste into a 40 KB line; multi-line text in goal mode, without file support, and on a host that cannot receive files; the 16,384-character boundary, bare CR and CRLF; a line too long to edit that becomes a file; a terminal-backed chat on this machine (file), elsewhere (refused or inline); and a huge "Add to chat" quote.
Mutation checks: removing each of seven pieces of the change makes a test fail.
Real app: the table above, with a 20 ms timer and the paste event on the composer.
Not tested: Windows, Linux, a real remote server, sending a message from a terminal-backed chat with the new file pill, drag-drop of text, the queued-message editor. "Add to chat" is covered by unit tests only.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Written with Claude (Sonnet 5.5) via Claude Code, building on a first fix and review by Codex. I reviewed the diff, measured the cost in the real app and ran the verification above.
Author: X @thefrikidude
Review
AI review summary:
savePastedTextAsFilecall as before, now also used for terminal-backed chats on this machine.Agent skill upstream boundary
Notes
inlinePasteLineTooLong,pasteHostConnecting).Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred) — lint, typecheck,check:changedand the native-chat tests pass locally; the full test run and build are left to CI🤖 Generated with Claude Code