Skip to content

feat(git-history): page the log by cursor across host, TUI, desktop and mobile - #1668

Merged
huichen merged 14 commits into
mainfrom
pr/huichen
Nov 21, 2026
Merged

huichen merged 14 commits into
mainfrom
pr/huichen

Conversation

@huichen

@huichen huichen commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

The Git history is read a page at a time on all three surfaces, and each page used to be laid out from the top of the log and cut out of it — so page N cost what the whole history above it cost. A page now starts where the page above it stopped: the cursor carries the lanes still open at the seam plus the refs the pages above had not shown, so any page costs what the first one does and the drawing still continues the rows above it instead of restarting every line at the left edge. Because only --date-order can be cut and continued, the log is now read in date order everywhere; see User-visible changes.

Commits

  • feat(git-history): page the log by cursor instead of by offset — the cursor model in host/src/git_history.rs (the picture the phone's sheet and the desktop panel decode) and in the TUI's own copy, reached through remote_host and the Tauri command. A page read from a cursor the client no longer holds is dropped instead of stitched into a list it does not continue. The new the_second_page_is_the_tail_of_one_bigger_read assertion (host and TUI) pins a page read from a cursor to the tail of one bigger read: same commits, same order, same columns.
  • fix(mobile): read the next history page only after a scroll — React Native's list reports its end as soon as it mounts, before it has measured the content, so the sheet read a second page every time it opened: a page nobody asked for, and on a short history the one thing that hid the "load older" entry. A scroll now has to come first.
  • test(screenshots): capture the history's paging entry on all three surfaces — ?gitpaged=1 answers the demo history in two pages cut at a row boundary of one real read, so the second page's lanes continue the first one's; the phone's fixture is a real 37-commit read over five branches (dumped from the host, not typed), cut 31/6 so the first page alone overflows a phone screen. A new scripts/screenshots/scenarios.d/git-paged.json defines the captures.
  • test(screenshots): capture the six-lane window against ten branches of work — the desktop and phone mocks gain a ten-branch history in both layouts, selected with ?gitlanes=window and ?gitlanes=widening (the latter frozen from what the host printed at 091b19e94, a layout no host can produce any more), plus scripts/screenshots/scenarios.d/git-lane-window.json for the four captures and their assertions (one gutter width per picture, rightmost dot on the sixth lane, every subject on one left edge, no box-drawing glyph in the DOM).
  • test(host): pin commit dates so the paged tail is order-stable — the paging fixture now gives every commit an instant of its own (GIT_AUTHOR_DATE/GIT_COMMITTER_DATE, one second apart, including the merges git makes itself), because --date-order only has a total order when the timestamps differ; Windows broke the tie the other way between one big read and two paged reads. A guard test asserts no two commits share a second, so the gap cannot come back silently on the platforms where it happens to pass.
  • style(desktop): sort the git-lane mock imports, style(git-history): format the paged draw signature and fix(tui): exempt git's unborn-branch stderr from the chrome guard — the cleanups ESLint and rustfmt asked for, and the i18n guard's finding that git's own does not have any commits stderr (matched with contains, never drawn) had to be exempted with that reason rather than translated.
  • test(tui,host): stop racing the host for a stream loss and the events lane — the reconnect tests wait for the host's own signal instead of polling on a fixed schedule, so the Windows tui-cli and macOS host-remote lanes no longer depend on scheduler order.
  • test(host): subscribe to the catalogue before the packet that fills it — the first-packet measurement subscribes before the secure channel activates, so the supervisor's counter and the phone compare the same packet; this fixes the Linux host-remote failure on the previous head.

Verification

At 79d9070f8 (this PR's head), with the pinned toolchain (rustup 1.99.1) and ulimit -n 8192:

  • cargo fmt --all -- --check → exit 0
  • cargo check -p future-host -p future-tui --all-targets → exit 0
  • cargo test -p future-tui --test i18n_guard → exit 0 (8 passed; it had failed with chrome_is_drawn_from_the_table before the exemption)
  • cargo test -p future-tui --lib workbench::git_panel → exit 0 (22 passed, 1 ignored)
  • cargo clippy -p future-tui --all-targets -- -D warnings → exit 0
  • npm --prefix desktop run lint → exit 0; ESLint reports 0 errors. The single liveRunProjection.ts:220 jsdoc warning is pre-existing, in a file this branch does not touch, and the desktop lint job in typescript-ci.yml runs the same src/** + shot/** pass.
  • npm --prefix desktop run typecheck and npm --prefix mobile run typecheck (tsc --noEmit) → exit 0
  • make check-docs → exit 0 (425 docs, 13 channel rows)

At 6f2570892 (the head after the CI repairs), with the pinned 1.99.1 toolchain and ulimit -n 8192: cargo fmt --all -- --check exit 0; cargo clippy -p future-host --all-targets -- -D warnings exit 0; cargo test -p future-host --lib remote::verify_e2e:: 21 passed / 4 ignored; the repaired first-packet test passed 20/20 local repetitions with observed == counter, and an injected 50 ms gap reproduced the CI mismatch before the fix.

The branch cuts across host, tui, desktop, mobile and packages/remote-protocol, so the full cargo test / vitest / jest suites are left to CI's matrix rather than run crate by crate here; the PR is therefore merged only after the checks are green.

Notes

  • The screenshot fixtures are read off real repositories; the widening gutters are a frozen copy of host/src/git_history.rs::draw's output at 091b19e94.
  • The new URL switches (?gitlanes=, ?gitpaged=1) are local to the shot harness; nothing in the app reads them.

User-visible changes

  • Git log order: the history is now read in date order on all three surfaces (TUI /git, the desktop Git panel, the phone's Git sheet), where it used to be topological. Parallel branches now interleave by commit time instead of being read branch by branch — the price of a log that can be cut into pages and continued. Revert e541624c3.
  • Paging depth in the TUI: ↓ on the last row keeps reading as far back as the history goes; the old ceiling of 100 pages is gone. Revert e541624c3.
  • Page cost: the Nth page now costs what the first one does, instead of re-laying out and discarding everything above the cut. Revert e541624c3.
  • A stale page is dropped: a page whose cursor the client no longer holds is discarded rather than appended, so a list cannot end up stitched to a page that does not continue it. Revert e541624c3.
  • Phone sheet no longer reads page 2 on open: the second page is read when the reader scrolls to the end, so opening the sheet spends no read nobody asked for and a short history keeps its "load older" entry on screen. Revert 691a5458e.

…f work

The lane window had no capture of its own: every git-history fixture stopped at
three lanes, where a picture that widens with the lane count still fits. These
two scenarios open the same month ten branches wide, so the gutter's width is a
measured number rather than a claim — 91px (six columns) instead of the 133px
nine open lanes produce.

The widening fixture is the grid the host printed *before* the window, read off
a real ten-branch repository at 091b19e. It is unreachable now, which is the
point: a hand-invented "before" would show a picture no reader ever saw.

The assertions are geometric (rect widths, dot positions, the subjects' shared
left edge), so reverting the window turns the window scenario red on the first
check.
The history is read a page at a time, and each page used to be laid out
from the top of the log and cut to the page: the drawing stayed continuous,
but page N cost what the whole history above it cost. `--skip` would be
cheaper per row and worse in total (git walks the commits it discards).

A page now starts where the one above it stopped. The cursor is the log's
frontier — one entry per open lane (the commit that lane waits for) plus
the refs the pages above have not shown — because either half alone loses
something: lanes alone drop a branch tip that is not an ancestor of
anything above the seam, and tips alone cannot continue the drawing.

Only `--date-order` can be cut and continued: a topological order is
computed for the whole graph, so a walk restarted below a cut can queue
two live branches differently from the walk above, and the page after a
seam would hold the right commits in an order one uninterrupted read never
produces. The log is therefore in date order in all three surfaces — a
visible change: parallel branches now interleave by commit time instead of
being read branch-by-branch.

Ported to every surface the read serves: the host (`host/src/git_history.rs`,
which the phone's sheet and the desktop's panel decode through
`remote_host` / the Tauri command), and the TUI's own copy, which keeps its
rows in another shape. Each page carries the cursor on to the next, so a
page that was read from a cursor nobody holds any more is dropped instead
of being stitched into a list it does not continue.

`the_second_page_is_the_tail_of_one_bigger_read` (host and TUI) asserts a
page read from the cursor equals the tail of one read that covered both:
same commits, same order, same columns. Reading the second page from the
refs again — what the old prefix read did — makes it red with the first
page's commits twice.
…rfaces

`?gitpaged=1` answers the demo history in two pages — the last three rows
of the log are the second one, cut at a row boundary of one real read, so
the second page's lanes continue the first one's instead of restarting every
line at the left edge.

The desktop frame holds the entry itself (the panel offers "load older"
under ten rows). The phone reads its second page on mount, because a
fourteen-row log is shorter than a phone screen and the list's end is
already on screen — the frame is therefore of the joined result: fourteen
rows, no commit twice, the footer saying the log ends. The TUI frame is the
`/git` title carrying `↓ 还有更早的提交` against this repository.

Screenshots are gitignored; the fixtures and the scenario file are what
land.
React Native's list reports its end as soon as it mounts, before it has measured the content, so the sheet read a second page every time it opened — a page nobody asked for, and on a short history the one thing that hid the "load older" button. A scroll now has to come first.

The paged screenshot fixture becomes a real 37-commit read over five branches (dumped from the host, not typed), cut 31/6 so the first page alone overflows a phone screen: the capture shows the first page, the entry at the foot of it, and the second page joined after pressing it.
`git_log` compares the log read's stderr against "does not have any commits"
with `contains`, so an unborn branch answers with an empty log; the panel
draws its own empty state from the table (`Key::GitNoMessage`), so the phrase
is never drawn and has nothing to translate.

It had been moved to an in-source `// i18n:` marker, but that marker sat on
the match arm's closing brace rather than on the literal's line, and rustfmt
pushes a trailing marker onto a line of its own when the arm grows — the
guard only honours a marker on the literal's own line. Restore the allowlist
row the budget history already documents ("41 → 42") instead: 55 exemptions,
`BUDGET` unchanged at 55.
The host's Git-history fixture committed everything within one wall-clock
second, so `the_second_page_is_the_tail_of_one_bigger_read` compared two
orders that `--date-order` was free to build differently: the read is cut
and continued, and a tie between commits with the same committer stamp is
broken from the rev set the walk started at, not from the commits alone.
Eight commits in one second therefore read in one order as one page and
another order as two pages — `8ad8075` and `ebd6258` swapped — which passed
on Git for macOS and Linux and failed on Git for Windows
(Rust Windows test / host-core, run 44937037098, job 136945939967).

Every command in the fixture now commits at its own instant (a clock the
fixture advances per invocation, so `commit`, `commit_as` and the merge git
makes itself all get distinct author and committer dates), and a new guard
test asserts no two commits share a committer second — the Windows-only
failure would otherwise return silently on the platforms CI runs first.
The paging assertion is unchanged and stays an exact order comparison.

This matches the TUI's own fixture (`workbench::git_panel`), which pins its
dates for the same reason; the host port of that algorithm dropped it.
… lane

`the_reconnect_poll_grows_the_backoff_while_the_agent_stays_down` and
`..._stops_at_its_loop_top_when_the_flag_is_set_alone` staged the dead agent
with `server.abort()` alone. `Server::serve_with_incoming` spawns every
accepted connection in a task of its own, so aborting the accept loop closes
the listener but leaves the established HTTP/2 stream open: the client only
noticed through its heartbeat's readiness probe, whose latency is the host's
business. Both callers then spent their whole flat 4 s window waiting (Windows
CI, three consecutive heads on 2026-11-21, 4.10 s each) while the growth was
still inside the first probe. End the stream with `EventSource::close_streams`
— the idiom `subscribe_failure_modes` already uses — and give
`wait_for_backoff_above` a window derived from the poll's own sleep plus the
probe's connect/handshake bound instead of a flat 4 s. The assertions are
unchanged; only their tolerance for a slow host is.

`a_supervisor_reconnect_keeps_delivering_to_the_registered_emitter` published
on the events lane right after the supervisor returned, i.e. after the `SUB`
left the client but before the broker had applied it — NATS Core does not
replay, so the event was gone and the wait timed out at 15 s (macOS CI,
2026-11-21). That is the race `wait_for_the_events_lane` exists for and its
siblings call; this test did not.
`measure_catalog_first_packet_over_real_crypto` declared the delta lane and
only then subscribed to the catalogue subject. The publisher's first tick
after activation can publish in between, and a NATS packet published to a
subject with no subscriber is dropped and never retried: the counter kept
that first packet while the phone received the delta lane's full packet
published after the declaration, so their sizes could not match (CI run
44942696681: 10747 on the counter vs 11636 on the wire, where 107298 bytes
of JSON was the snapshot lane's first packet and 108934 the delta lane's).

The fixture now stops before the phone's `secure_ready`
(`E2e::on_broker_seeded_before_ready`), so the test subscribes to a channel
that cannot push yet, then sends the `secure_ready` carrying the delta
declaration — the one command a mobile client sends, and the one that
activates the channel. Every push before it is dropped by the unsealed
channel and retracted from the count; every push after it has a live
subscriber. The first packet the publisher hands the broker is therefore the
first one the phone can receive, which is what the assertion compares.

The readiness exchange is not added to the harness's phone counters
(`phone_rx_*`), matching what `secure_pair` did: those count lane traffic.
@huichen
huichen enabled auto-merge (squash) November 21, 2026 20:37
@huichen
huichen merged commit 282d3c0 into main Nov 21, 2026
52 of 54 checks passed
@huichen
huichen deleted the pr/huichen branch November 21, 2026 21:36
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.

1 participant