Repository navigation
Conversation
큰 PTY 출력이나 스크롤백 재생이 xterm.write() 한 번으로 들어가, xterm이 전부 파싱할 때까지 WebView 스레드를 붙잡았다. 4,096 UTF-16 코드 유닛을 넘는 쓰기만 순서대로 나눠 큐에 넣고, 서로게이트 쌍은 자르지 않는다. 큐는 조각 사이마다 xterm의 write 콜백을 기다리므로 입력과 그리기가 끼어들 수 있다. 짧은 쓰기는 지금처럼 그대로 넣는다. stablyai/orca#20489에서 출력 분할 부분만 분리한 변경이다. Rejected: 모든 쓰기 분할 | 짧은 쓰기의 경계와 기존 동작을 바꿀 이유가 없음 Related: stablyai#20489
|
No actionable comments were generated in the recent review.
|
There was a problem hiding this comment.
ℹ️ No critical issues — one minor robustness note inline.
Reviewed changes
- Large writes are sliced before xterm parses them —
enqueueWritenow normalizes first, then splits any write longer than 4,096 UTF-16 code units into ordered slices, decrementing the boundary when it would land on a high surrogate so astral characters stay whole; writes at or below the limit are queued unchanged. - Tests cover the new paths — a boundary-straddling emoji verifies order, slice count and pair integrity; a status dot is checked below and above the slice limit; the retention test now hands the queue exactly one slice per chunk so its code-unit counts stay exact.
I verified the slice loop cannot produce an empty slice (the decrement only runs when the slice is a full 4,096 units), that splitting escape sequences across term.write calls is safe for xterm's streaming parser, and that updateMouseModeFromData runs on the un-sliced data in write() so the mouse-mode scan and its tail are unaffected. The generated document bundle is gitignored and rebuilt at postinstall, so no committed artifact needs regenerating for the bundle-digest test.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
분할 코드가 정규화 결과의 length를 무조건 읽어서, data가 빠진 write 프레임이 오면 예외를 던졌다. 정규화와 마우스 모드 스캔은 문자열이 아닌 data를 그대로 넘기므로, 분할 전에도 문자열인지 확인해 예전처럼 그대로 큐에 넣도록 했다. pullfrog 리뷰에서 나온 지적이다. Tested: 새 테스트가 수정 전 코드에서 실패하고 수정 후 통과, 문서 번들 재생성 후 write-queue·native-document-bundle 21개 통과, mobile tsc·tests-typecheck·oxlint·oxfmt 통과, 전체 vitest 10,008개 통과(기존 main 실패 2개 제외) Related: stablyai#25503
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 · Yield before pumping the next terminal slice. · write-queue.ts:75-91
mobile/src/terminal/document/write-queue.ts:75-91
🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick winYield before pumping the next terminal slice.
When a large live write is split,
pumpWritescallsterm.write()again from xterm’s write callback. In@xterm/[email protected], that callback runs before_bufferOffsetadvances. The reentrantwrite()therefore appends to the active buffer, and_innerWrite()continues parsing the next slices in the same task until xterm’s 12 ms budget expires. The slices do not guarantee host-event-loop time for taps, typing, or painting.Schedule the next pump in a macrotask after the callback returns.
Suggested fix
scope.writesDraining = false - pumpWrites(scope, gen) + setTimeout(() => pumpWrites(scope, gen), 0)
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
ac3ec195-fe26-4ee9-970f-055fdd265981
📒 Files selected for processing (2)
mobile/src/terminal/document/write-queue.test.tsmobile/src/terminal/document/write-queue.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Text-less write frames no longer throw —
enqueueWritenow checkstypeof normalized !== 'string'before reading.length, so a bridge frame that arrives withoutdatais queued unchanged, restoring the previous tolerance; the fix matches hownormalizeStatusDotPresentationand the mouse-mode scan already handle such frames. - Regression test added —
queues a write frame that carries no text instead of throwingenqueuesundefined, asserts no throw, and asserts the slot is retained; it fails on the prior commit and passes onc1970ce136.
The incremental delta is exactly the robustness fix requested in the prior review, and its thread is resolved. The guard short-circuits before the length read, so the previously reachable undefined.length throw is gone, and the slicing loop and its surrogate handling are unchanged from the version reviewed earlier.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
|
On the outside-diff note in CodeRabbit's last review ("Yield before pumping the next terminal slice"): It is right that consecutive slices are not each a separate task. In I'm leaving the drain as it is rather than adding |
최신 main을 병합하고 출력 분할과 유니코드 경계 보존 테스트를 업스트림의 직접 모듈 실행 방식에 맞췄다. 텍스트 없는 프레임의 입력 타입을 명시하고 큐 메모리 회수 검증도 분할 크기에 맞춰 유지했다. Tested: 관련 테스트 25개, 모바일 타입 검사, check:changed 11개 검사 통과 Related: stablyai#25503

ELI5
When a lot of terminal output arrived at once, the phone handed all of it to the terminal renderer in one piece, and the app could not react to taps or typing until that piece was processed. Now large pieces are cut into small ones, so the app gets regular chances to respond while they are processed.
What Changed
Before:
document/write-queue.tsqueued each incoming write unchanged, so a large PTY burst or a scrollback replay reachedxterm.write()as one string. xterm.js parses a single write without yielding and yields to the event loop only between writes, so the WebView's main thread stayed busy for the whole burst.After:
enqueueWritesplits any write longer than 4,096 UTF-16 code units (TERMINAL_WRITE_SLICE_UNITS) into ordered slices. Shorter writes are queued unchanged, as before.normalizeStatusDotPresentationruns before slicing.WriteBuffer._innerWrite). With slices, a burst holds the thread for about one budget plus one slice at a time, instead of until all of it is parsed. Consecutive slices still run in the same task until the budget is spent, which keeps throughput the same as today.normalizeStatusDotPresentationand the mouse-mode scan already tolerate such frames.Why
Slicing only the oversized writes keeps the order and the boundaries of every other write, and needs no change to xterm or to the host. Normal interactive output is far below 4,096 code units, so it is unaffected.
Alternatives considered:
Linked Issue
Fixes #25501
This change was first part of #20489, which I have split into smaller PRs.
Visual Proof
N/A: there is no UI change. The terminal shows the same output; only the way it is fed to xterm changes.
Testing
Prebuilt APK for trying this on a phone: https://github.com/kargnas/orca/releases/tag/preview-mobile-20261005-f1d7719. It contains this PR and my other open mobile PRs on top of
main40f9e7a3fc, and installs next to the regular app as "Orca Preview". On an Android 13 emulator it launched, paired withmobile/scripts/mock-server.tsand painted the terminal. It was built from this PR's first commit,b093d63402, before the review follow-up below.On this branch (
c1970ce136, onmain40f9e7a3fc):tsc --noEmit,check:tests-typecheck,oxlintandformat:checkpass.vitest run: 925 files passed, 2 skipped; 10,008 tests passed, 6 skipped. The only failures are two tests insrc/tasks/mobile-agent-launch-architecture.test.ts, which fail the same way on plainmainon my machine.mobile-web-app-session-terminal-closure,mobile-web-app-page-closure-families,mobile-web-terminal-engine-closure,mobile-web-app-push-subsystem-closure) pass.New or updated tests (
write-queue.test.ts):c1970ce136, from the Pullfrog review). This test fails onb093d63402.Device: this change was in the #20489 build I ran on a physical Galaxy Z Fold7 (Android 16). That build also contained #20489's other changes. This branch on its own has not been rebuilt into an APK.
AI Disclosure
OpenAI Codex (GPT-5.6 Sol and GPT-5.6 Luna) assisted with the original investigation and implementation in #20489. The rebase, the review fixes and this split were done with Claude Code (Claude Opus 5.5). The author ran the combined build on a physical device.
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
No README, environment-variable, API, deployment, privacy or remote-wire contract changed.
Author
X (Twitter): @kargnas
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred): mobile typecheck, tests-typecheck, lint, format and tests pass locally, apart from the twomainfailures above; root lint, typecheck and build are left to CI