Skip to content

Chat paging with Codex backtracks - #5

Merged
devswha merged 2 commits into
devswha:mainfrom
Yoonwoo-Ha:fix/chat-history-composer-windows
Sep 24, 2026
Merged

devswha merged 2 commits into
devswha:mainfrom
Yoonwoo-Ha:fix/chat-history-composer-windows

Conversation

@Yoonwoo-Ha

@Yoonwoo-Ha Yoonwoo-Ha commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Chat paging only. The four small changes that were bundled here are now separate PRs: #9 (Windows terminal font), #10 (per-window reload), #11 (resizable composer) and #12 (Claude reasoning effort).

  • Paged reads. A transcript is read one page at a time: at most 16MB and 50 prompts, and a page always starts where a turn starts, so no turn is split across pages. Before this, the whole file was re-read on every append. On a 400MB Codex rollout that took 1.1s and 1.7GB of memory, and every poll sent 3.4MB.
  • Scroll-up history. Scrolling near the top loads the page before and keeps the reader in place. A page never makes a poll read more than one page. Once older pages are loaded, the newest page is polled from a held start. When the newest page moves past that start, the chat fetches the turns in between with before + since, one page at a time, and then holds the new start.
  • Codex backtracks (0.156 paginated rollouts). A backtrack or fork starts a new file, and that file's history_base names what it continues as a (thread, ordinal, byte) cut. The rollout that continues is the one with exactly ordinal - first ordinal lines before the byte. That holds however many backtracks there were, and it was checked on a real three-rollout chain against Codex's own thread_history_1.sqlite. Turns discarded by a backtrack don't appear. A cut that no file holds shows less history rather than the wrong history.
  • Claude Code's <pasted_content> wrapper is removed, so the chat, like the TUI, shows only the pasted text.
  • An opened conversation starts at its end instead of smooth-scrolling there from the top.

API

GET /api/pane/conversation takes before, since and from, and returns a cursor (see ConversationResponse). A cursor from another file gets 409 history_changed. Bridges without paging send no cursor, so the chat shows their newest page only.

Testing

  • bun run typecheck passes and bun test passes 265/265.
  • New tests cover:
    • backtracks cutting into earlier and later rollouts
    • a chain with no holder, which isn't cached and is found once its file appears
    • pages that join without gaps or overlaps
    • a held start while the last turn grows, and the gap fill after the newest page moves past it
    • a newest page that stays within one window when no turn starts in it
  • Real Codex-Design session (4 rollouts, about 713MB):
    • the chain resolves to the same 4 files in 0.5s the first time and instantly from cache
    • pages take 55–220ms
    • a held start 2 pages back fills its gap in 2 pages
  • Headless Chrome against a mocked API:
    • scrolling up keeps the reader in place (no shift)
    • growth past the held start fills the gap once
    • all 170 turns show in order with no duplicates, and the beginning is marked
    • a refused cursor resets to the newest page
    • the chat opens at its end in one jump

🤖 Generated with Claude Code

@devswha devswha left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. The paging design looks sound: cursors are checked against the file's inode, and thread ids and paths are validated. A few things before merge:

  1. Codex history can be wrong after more than one backtrack. historyChain (server/codex.ts) chooses the earlier rollout by name order and size alone. After a second backtrack to a turn before the first one, it can pick the intermediate rollout, so the chat shows the wrong earlier history and nothing errors. The result, including an empty chain from a failed lookup, is cached for the life of the process. Please resolve the chain from the rollout's own base reference and add a test with two or more backtracks.
  2. Held-start polling has no size limit. Once an older page is loaded, every 2s poll re-reads and re-parses everything from the held start, up to 64MB. When the growth passes MAX_PAGE_BYTES, the server returns 409 even though nothing changed, and a reader who has scrolled up loses their place. Separately, a large file with no turn markers makes pageBefore read 112MB on every poll.
  3. Please split the PR. The Windows font, per-window reload, resizable composer and Claude effort changes are small and independent. Merged on their own, they would leave paging to be reviewed by itself.

Minor: loadingOlder isn't reset when the pane changes, and the composer grip's aria-valuenow is wrong while the height is automatic. Also, #8 is now merged and touches the same .chat-view rule, so this branch needs a rebase.

Yoonwoo-Ha and others added 2 commits September 23, 2026 16:57
…ktracks

- Transcripts are read a page at a time instead of whole on every append: a
  400MB Codex rollout took 1.1s and 1.7GB per re-read and sent 3.4MB every
  poll. A page is at most 16MB and 50 prompts, and always starts where a turn
  starts, so pages never split a turn.
- Scrolling near the top loads the page before; the reader's place is kept,
  and once older pages show, the newest page is polled from the start it had
  then, so the two always meet. The top shows where the conversation begins.
  A cursor from a replaced transcript answers 409 and the chat starts over
  from the newest page.
- Codex 0.156 writes paginated rollouts: a backtrack or fork starts a new
  file whose session_meta.history_base names the earlier history by thread
  and byte offset. The chat followed only the new, nearly empty file; it now
  reads the whole chain, without the turns a backtrack discarded.
- Claude Code's <pasted_content> wrapper is unwrapped: the chat, like the
  TUI, shows only the pasted text.
- An opened conversation starts at its end instead of smooth-scrolling there
  from the top, and stays at its end when the view shrinks.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…und every poll to a page

Review follow-ups:

- A thread gets one rollout per backtrack, and a later backtrack can cut
  into any of them. The chain took the latest earlier rollout by name and
  size, so after a second backtrack to before the first one it continued the
  wrong file. A cut names (thread, ordinal, byte); every record is one line
  and a rollout's ordinals start at its own first ordinal, so the rollout that
  continues is the one with exactly `ordinal - first` lines before the byte,
  ending a line there (checked on a three-rollout chain against Codex's
  thread_history_1.sqlite). A chain that stops at a cut no file holds shows
  less history, is not cached, and is looked up again next time.
- The newest page is read in one window even when no turn starts in it (it
  then starts mid-turn); only an older page, read once, reaches further back,
  a new chunk at a time.
- A held start no longer makes every poll read everything after it, and no
  longer answers 409 when the conversation outgrows a page: `from` answers
  the newest page once it has moved past the held start, and the chat
  fetches the turns in between with `before` + `since`, a page at a time,
  then holds the new start.
- The earlier-messages row keeps one height while loading, a pane switch
  resets the loading state and ignores a load still in flight, and the
  view-shrink pinning moved to the resizable composer, which needs it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@Yoonwoo-Ha
Yoonwoo-Ha force-pushed the fix/chat-history-composer-windows branch from 31b0c6f to 8d5c8e0 Compare September 23, 2026 08:08
@Yoonwoo-Ha Yoonwoo-Ha changed the title Chat paging with Codex backtracks, resizable composer, per-window reload, Windows terminal font Chat paging with Codex backtracks Sep 23, 2026
@Yoonwoo-Ha

Copy link
Copy Markdown
Contributor Author

Thanks for the review. I've addressed all of it:

  1. Chain after several backtracks. A cut is (thread, ordinal, byte). The rollout that continues is the one whose first byte bytes hold exactly ordinal - first ordinal lines and end a line. I verified that rule against thread_history_1.sqlite on a real three-rollout chain. It never guesses from names or sizes. A chain that stops at a cut no file holds shows less history, isn't cached, and is looked up again next time. The new tests cover backtracks into earlier and later rollouts, and a missing holder that shows up later.
  2. Held-start polling. from now returns the newest page once that page has moved past the held start, so it no longer answers 409 and no longer re-reads from the held start. The chat fills the turns in between with before + since, one page at a time, and then holds the new start. The newest page reads one window even when no turn starts in it (it then starts mid-turn). Only older pages, which are read once, reach further back, a new chunk at a time.
  3. Split. The font, per-window reload, composer and effort changes are now Keep a monospace font sizing the terminal cells on Windows #9, Reopen each window's own pane on reload #10, Resizable composer, remembered per device #11 and Show the reasoning effort Claude Code records #12. This PR is paging only.

Minor: a pane switch now resets loadingOlder and ignores a load still in flight. The grip's aria-valuenow is fixed in #11. The branch is rebased on main after #8. The earlier-messages row also keeps one height while loading, so the reader no longer shifts by 16px when a load starts.

@devswha

devswha commented Sep 24, 2026

Copy link
Copy Markdown
Owner

Merged. Both earlier concerns are fixed: the chain is now verified against history_base, and polling reads at most the newest 16MB. Thanks.

One follow-up for a separate PR: cursors aren't tied to the earlier-rollout chain. The cursor id covers only the live file (conversation.ts:339). If the chain changes between requests, for example when an earlier rollout appears later (your own test allows this) or a cached chain is evicted and the parent has since been archived, old cursor positions point at different messages. parseCursor only checks the range, so it never returns 409. A throwaway test reproduced it: before:6254 returned prompts 0–19 instead of an empty page, and the gap fill then showed turns duplicated and out of order. Suggested fix: fold a fingerprint of the chain (paths plus byte ends) into the cursor, so a changed chain returns 409 and the chat reloads.

Minor: an unresolvable chain isn't cached, so every file change walks sessions/ again.

Yoonwoo-Ha added a commit to Yoonwoo-Ha/herdr-web-ui that referenced this pull request Sep 24, 2026
Follow-up to devswha#5's review. A cursor's id named only the live file, while its
offset counts from the start of the whole Codex chain. When the chain
changed between requests (an earlier rollout found later, or a parent
archived after its chain was evicted), an old cursor pointed at other turns:
`before` answered a page from elsewhere and the gap fill showed turns twice
and out of order, never a 409. The id now also carries a fingerprint of the
earlier rollouts (path, bytes used, file identity), so a cursor from another
chain answers 409 and the chat reloads; older pages are cached under the same
id, and the stream is identified before the cache is consulted.

A chain that stops at a cut no file holds is now remembered for 30s rather
than walked again on every append.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
devswha added a commit that referenced this pull request Nov 6, 2026
…that names a test session (#3155)

## Summary
A standalone script that imported `{ useTestHerdr }` from
`scripts/test-herdr.ts` without using the binding had the import dropped
by Bun's TypeScript transpiler (unused-import elision). `test-herdr.ts`
never ran, `HERDR_SOCKET` was never set, and every call went to herdr's
default socket: the user's own session. This happened during QA for the
herdr -> herdr-core move work (throwaway workspaces were created and
closed in the live session).

herdr's client now refuses its default socket
(`~/.config/herdr/herdr.sock`, `$XDG_CONFIG_HOME/herdr/herdr.sock`, or
the Windows APPDATA one) while `HERDR_TEST_SESSION` is set, with
`live_herdr_refused` and a message saying how to import the helper for
its effect. `OVIS_ALLOW_LIVE_HERDR=1` (or the existing
`HERDR_TEST_LIVE=1`) says the live session is meant. The check sits in
`socketAddress()`, which every herdr connection goes through.

## Validation
- Failing first: `server/herdr/live-guard.test.ts` failed on main with
`connect_failed` (the default socket is under a temp HOME, so nothing
live is reached), passes with the guard.
- `bun test server/herdr/` against an isolated test session: 48 pass.
- `bun run check fast` (on the heavy runner): ok, 12663 pass, 0 fail.


## Review
- omo: CLEAR at b3c19ac (the BLOCK at f75a8e1 named the missing hc
guard, added in b3c19ac).
- Codex (Terra 6.1, xhigh) at f75a8e1, all addressed in b3c19ac except
#5:
- HOME changed after the socket was chosen: both the env HOME and the OS
home's default socket are refused.
- No herdr binary left the default socket in place:
scripts/test-herdr.ts now points HERDR_SOCKET at a socket that does not
exist (fail closed), as unit mode does.
- herdr-core unguarded: spawnHcConnect refuses a core that is neither
named by HC_SOCKET nor a non-default HC_SESSION while HERDR_TEST_SESSION
is set.
- Other spellings of the default socket (`..`, a linked folder, the
Windows pipe prefix and case) are compared as one.
- Test env: HERDR_TEST_LIVE and HC_* are cleared in the test, and the hc
guard is tested too.
- MEDIUM #5 (a user who exports HERDR_TEST_SESSION in their own shell
and then runs a production plugin on the default socket gets refused):
not changed; HERDR_TEST_SESSION is a test-only variable, and the error
says to set OVIS_ALLOW_LIVE_HERDR=1.
devswha added a commit that referenced this pull request Nov 22, 2026
…st screen, always-QR and About update check (#4435)

## 0.5.10 relay/app integration (one combined review)

Owner's method for 0.5.10: every lane put its slice on
`release/relay-0510` (per-slice commits, subject prefixed with the slice
name). This PR runs the one combined pass: check fast + full CI once,
one dori review, one omo gate (anthropic/claude-opus-5-5 high) over the
whole diff, t13r on the security slices, one fix round. A bad slice can
be dropped by reverting its commits.

Base: `860d1b5b6` (main with 0.5.9).

### Slices
| slice | commits | what | t13r |
|---|---|---|---|
| approve-card | fe336dd..112bfd1, b527564 | A PC with no account
member lets its first phone in by a tap in the PC's own window (digits
shown, "allow only if your phone shows this number"); any other window
gets 403. Phone waiting screen: "맥에서 [허용]을 눌러 주세요". QR key confirm: [이
PC에서 확인] opens the existing confirm page (POST
/api/account/confirm-page, own window only); no route approves a key. |
YES |
| uvb-S1, S1b | d32628d, e8a755b, d028865 | Unified sidebar adds
the account PCs by itself; nothing to press (no Check again, digits,
Change PC); header dot. | - |
| uvb-S2 | b9bee3d | Relay drive devices may add account PCs; a
vouched PC join is a WATCH row. | YES |
| uvb-S3, S3b | e84272c, fe760e2 | Shell opens any online PC by
itself, moves off one that goes away; account-only PCs only when
confirmed, past new_until, not introduction-only. | YES |
| uvb-S4 | ddedeb1 | Vouched PC join approved by a plain tap, bound to
the joining server proven in-session and matched against the approver's
own /v1/pcs. | YES |
| phone-first-build | e62c516..80e5620 | Phone native first screen;
Android Tailscale check (manifest `<queries>` com.tailscale.ipn). Owner
OK given. | - |
| desktop-update-about | 31d609b..d1dd8a8 | Settings > About [업데이트
확인] runs the app's own update check. Replaces #4427. | - |
| add-connection-qr | 5ce18df..f7312c0 | Add a connection shows a
phone QR on every tab, drops Phones and devices; PC page link
`#sign-in=` signs in, then joins that PC. Replaces #4431. Owner UI OK
given. | YES |
| control-page-fold | e87df8e..a3a28f0, fixes 44fb77d..30d20c6 |
Removes the app.ovis.sh control page; 기기 끊기 / PC 빼기 (dead PC, any age) /
계정 삭제 under Settings > 기기와 PC > [계정 관리]. 모든 기기 로그아웃 was later pulled
back INTO 0.5.10 by the owner (owner-fix round below). Manage account
also reachable from the signed-in start screen (owner-approved). | YES
(PCR-1: ovis-sh/account#58, not a regression) |

### Replaced PRs
#4428 (closed), #4427 (closed), #4431 (closed).

### Review trail
- Combined gate @f7312c09e BLOCK -> fix round -> delta gate @781e03309
BLOCK (HIGH-2) -> fixes -> delta gate @a4c9bb23b CLEAR -> MEDIUM fix
5438550..fd2e5fb CLEAR.
- control-page-fold gate @fd2e5fbdf BLOCK (hosted leave feedback) ->
fixes 44fb77d..30d20c6 (gate running).
- dori @f7312c09e BLOCK (native #picked) -> fixed 477f3d0/a4c9bb23b;
dori @a3a28f017 CLEAR; dori at the final tip running.
- Fix commits are prefixed by slice ('uvb-fix:', 'approve-card:',
'add-connection-qr:', 'control-page-fold:').

### Merge conditions
- check fast + CI green, dori CLEAR, gate CLEAR, t13r YES on
approve-card, uvb-S2/S3/S4, add-connection-qr, control-page-fold.
- Owner OK on add-connection-qr UI and phone-first-build: both given.
- Owner tests the Mac + phone preview of the final tip and says OK
(lead's condition).



## Owner-fix round (fix/owner-0510, landed as 89c9e26..cccb50f)

The owner tested the 89c9e26 previews and reported findings #1-#10;
the lead added items (a) sign out every device, (c) reconnect speed, (d)
PCR-1 app side + #4440 relay/account items, (e) ovis CLI cleanup (lane
ovis-cli-design), and the PC proof on re-list (#65 condition). All
landed on side branch fix/owner-0510, then fast-forwarded here.

| Item | Commits |
|---|---|
| #1 signed-in 0-PC: 3 tabs + ⋮ menu | 09a09dc |
| #2 confirm an unconfirmed PC (+ two-step line, gaps) | 0325bf6,
ea87f1e, 3cc9d07 |
| #3 setup row = checklist | 164012c |
| #4 Tailscale serve/open (+ owner-login condition) | e614cf1,
ab20c89 |
| #5 phone approve/deny of a join | 701e023, 9cf9b1a, 1dd2c61 |
| #6 Direct = address line + code, no QR | 2caeb4e, e02aedc |
| #7 signed-out account PC one line | 7928083 |
| #8 join notice to the right windows, kept until seen | 6662003,
f718efe, dbd2f68, cccb50f |
| #9 reconnect UI (grey after 1 s, card after 10 s) | 4a6247e |
| #10 Inbox entry beside Settings | 0ec0dbe |
| SSH from hosted Direct -> app's own SSH screen | 1c51cb1, 3f9be0b
|
| (a) sign out every device (account#64 live) | 9b63d95, c8fa0a4,
7b2574f |
| (c) reconnect wins | 84b8ce6, 69b5c1e |
| (d) PCR-1 app retry + #4440 items + Delete account wording |
e26082f, 11c8926..9f60656, e6168df |
| PC proof on re-list after ovis logout (account#65 live) | e66b12b |
| (e) ovis CLI (login/logout/approve/pair --relay) | 11c13e1,
dcae136, f363d42 |
| fake parity with account#62/#63, red-test fixes, B1b | 9a47489,
25ad3d9, bcf5059, 181884b, 2072a04, 15cea4f, 1674ca5,
ea66c62 |

Review trail for the round: security-triage YES per item (Tailscale
routes with the owner-login condition; confirm UI conditions; sign-out
wording; join notice; SSH handoff; Decline; logout/leave with PC proof;
MEDIUM pc-proof scoping ledgered as ovis-sh/account#66, MUST-CLOSE
before Step 2 opens beyond the owner). Opus gate (one pass over the
round): CLEAR at 181884b, delta CLEAR at cccb50f (join-notice MEDIUM
fixed). check fast in the CI image: green at 03fcd4e06 (unit 22471/0).

---------

Co-authored-by: sisyphus-dev-ai <[email protected]>
Co-authored-by: Claude Fable 5.2 <[email protected]>
devswha added a commit that referenced this pull request Nov 23, 2026
… Back, row state

From the adversarial review of #4487:
- #1 Forget sits in a column of its own beside the row's open link (each row a
  subgrid of the list), so a tap on the chevron never lands on Forget.
- #2 The phone app's saved PCs are asked only of an app with getState, and a
  front page waits on the answer for 1.5 s at most; a late answer still lists them.
- #4 What is saved decides only the app's own front page: a PC's own page keeps
  that PC's sign-in, and its Back on a relay with no accounts.
- #5, #10 Add PC over My PCs has an entry of its own in the history
  (useSheetHistory), so Back returns to My PCs; the focus moves to its title and
  back to Add PC.
- #8 A row says first what this device knows: a pairing's saved Ovis too old, a
  check that settled (off or on), then the account's word.
- #11, #12 The acceptance check finds the forgotten laptop's one row; the mixed
  list test has a relay pairing and opens every native row at its own address.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
devswha added a commit that referenced this pull request Nov 23, 2026
…that stay, codes kept

From the adversarial review of #4492:
- #1 #2 #7 #10 One open attempt for the whole connect screen, tracked from the tap
  (before the Tailscale question, whose wait is bounded and takes only an
  explicit off as off): a newer tap, Cancel or leaving drops an earlier one's late
  answer, no second open runs while one does, both panes show the one status,
  open is called only where the app has it, Cancel shows only where it can stop
  it, and the plain wait and the removed screen show a scanned PC's open too.
- #3 #4 My PCs and Add a PC stay mounted under one parent across 1024 px, so the
  tab, what is typed, the focus, the search and an open survive a resize; a
  pairing dialog stays the top of the history when the window narrows under it.
- #5 Each desktop pane scrolls on its own; checked at 1024x400 with the wheel.
- #6 A code is looked up in its own field, kept through a failure to correct.
- #8 Tailscale's IPv6 range counts as a Tailscale address.
- #9 Android's no-answer is explained; an unknown reason never shows the app's words.
- #11 #12 A PC the app keeps open while choosing shows My PCs with its Back, and
  only its own scope on a self-hosted relay's origin is marked.
- #13 One alert for a failed sign-in on a wide screen. #14 The Cancel test presses it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

2 participants