Repository navigation
fix(chat): count each container's first member in the /btw item cap - #3133
Conversation
The pre-parse JSON item count missed the first member of every non-empty container, so nested single-item arrays could pass at about twice the 20,000-item cap. Part of #3024.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 15 minutes. View limit details
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. |
|
Reviews at 3999510:
Unresolved review threads: 0. The LOW items of #3024 stay open there, as listed in the PR body. |
Local merge gate: PASS
The Linux suites of the required checks (Fast checks, Integration and browser), run on main 39be94d with this PR's head 3999510 merged in (local merge e6c173e0b78d, not pushed), as groups side by side in the self-hosted CI runner image on
Reruns:
Total 623s. |
|
Merge note (merge pass) at head 3999510:
|
…er reflow with no scrollback (#3140) ## Problem Browser regressions on unrelated PRs (#3130 twice on GitHub, #3133 once locally) failed with the page error `Cannot set properties of undefined (setting 'isWrapped')`, first seen in `scripts/notification-view-regression.ts` (the pane split, then the agent pane closing, resizes the terminal). ## Cause Two bugs in xterm 6.0.0 itself, both still on xterm's `master`: 1. `Buffer._reflowSmaller`: when a narrower width wraps rows and the cursor's row is pushed to the bottom, the `ybase === 0` branch raises `ybase` with no bound. The other branch keeps `ybase` under `min(maxLength, length + inserted) - rows`; this one does not. With Ovis's `scrollback: 0` (`maxLength === rows`), `ybase` becomes 1 on a buffer of exactly `rows` lines, so the cursor's row `ybase + y` is past the buffer's end. Writes there land on the top row (the circular list wraps around), and after the next taller resize the row is `undefined`, so `lineFeed` or `print` throws on `.isWrapped`. Reproduced with `bun test`: 40x5 terminal with three 35-cell rows, `resize(10, 5)` leaves `baseY + rows = 6` on a 5-line buffer; `resize(5, 8)` and a write throw. 2. `InputHandler.eraseInDisplay` case 1 (`ESC[1J` from a row's last column) unwraps `lines.get(j + 1)`, where `j` is a screen row, not a buffer row (`ybase` is missing). In a scrolled buffer it unwraps a history row instead of the screen row below the cursor. From the screen's last row it reaches past the buffer's end, which throws the same error once the buffer keeps history (herdr-core panes, `terminal-history`). Not a write/dispose race: writes after `dispose()` and writes interleaved with resizes on a sound buffer were checked and do not throw. ## Change `patches/@XTerm%[email protected]` (regenerated with `bun patch`): - `Buffer.ts`: the `ybase === 0` branch uses the same bound as the other branch. With no scrollback, the reflow then trims the top row instead. - `InputHandler.ts`: `ESC[1J` unwraps `lines.get(ybase + j + 1)` only when that row is on screen, except after a selective erase (`CSI ? 1 J`, DECSED) that left protected cells on the cursor's row, which the next row still continues. ## Tests - New `src/lib/terminalReflow.test.ts` (patched xterm, as `terminalWidths.test.ts` uses it): - The narrower-reflow case keeps `baseY + rows <= length`, the cursor stays on its own row, and a taller resize plus a write works. On origin/main's patch it fails with `Expected: <= 5, Received: 6`. - `ESC[1J` in a scrolled buffer unwraps the screen row below the cursor. On main it fails with `isWrapped` still `true`. - `ESC[1J` from the last row does not throw. On main it throws the `isWrapped` TypeError. - `ESC[?1J` over a protected row keeps the next row wrapped (failed on this PR's first head; found by the Codex review). - `ESC[?1J` over a row with nothing protected unwraps the next row (failed on the second head; found by CodeRabbit). - A throwaway grid (every pair of 14 resizes and scrollback changes around 19 control sequences, starting from the broken state) threw 7 distinct `undefined` errors on main and none with this patch. - The notification-view step looped 30 times on the host passed every time, so the browser loop does not reproduce the flake reliably. The unit tests above are the deterministic reproduction. ## Validation - `bun run check fast` at this head (run on old-desktop through the heavy runner): ok, 12643 unit tests passing. - `bun test src/lib/terminalReflow.test.ts src/lib/terminalWidths.test.ts src/lib/ghostty/ scripts/xterm-composition.test.ts src/lib/terminalFileLinks.test.ts src/lib/inputRow.test.ts`: 155 pass at this head. - `scripts/ui-contexts-regression.ts` in the CI runner image (`herdr-ci-runner:local`, on old-desktop): exit 0, 121 PASS lines, notification-view included (first head; the later commits change only `ESC[?1J`, which these scripts do not send). - Not run: the full integration and browser suites (CI runs them). ## Reviews - omo (`dori review`) on the first head `95a7edd0`: CLEAR. On the final head `a305d475`: CLEAR. - Codex (Terra, xhigh): no regression from the reflow bound. It compared 20,000 generated resize cases against the pre-PR code, scrollback > 0 included; contents, cursor, markers and saved positions matched, and the only difference was the intended viewport correction. One MEDIUM was reproduced and fixed in the second commit: a selective erase above (DECSED) unwrapped the next row although protected cells survived. - Left as is, not changed by this PR: a marker can point to a stale row after a narrower reflow with no scrollback (Codex reproduced the same result before this PR). On a random resize fuzz, the unpatched xterm leaves `baseY + rows > length` 48 times and this patch leaves it 0 times. Cursor, marker and savedY counts stay at the same level as upstream. - CodeRabbit on the second head: one Minor (a selective erase that leaves the cursor's row empty must still unwrap the next row), fixed in the third commit.
Part of #3024 (follow-up of #3019, opt-in Side conversations chip for OMP
/btw).What
GET /api/pane/btwskips a topic file of more than 20,000 JSON items before parsing it. The pre-parse count took{,[and,outside strings, so the first member of every non-empty container went uncounted: nested single-item arrays could carry about twice the cap (Codex's MEDIUM on #3024). The count now also counts a container's first member where it starts (skipping whitespace;[]and{}add nothing), so it counts every member and container.Only reached with hand-made history files while a device has Settings → Chat → Composer → Side conversations chip (experimental) turned on (off by default). No changelog fragment: the feature is unreleased, and its changelog entry is unchanged.
Not changed (LOW on #3024, left as they are)
.titlefiles included, so a topic past that point in a session of more than 1,000 topics stays unseen.Validation
server/omp-btw.test.ts(1,500 chains of eleven nested single-item containers, about 34,500 items, about 18,000 when counted the old way) failed on main (the topic was listed), then passed.bun test server/omp-btw.test.ts: 13 pass, 0 fail.bun run typecheck: pass.bun run check fast: all green (workflow syntax, generated types and themes, typecheck, build, unit 12618 pass / 0 fail / 50 skip).