Repository navigation
perf: resize a terminal's grid the moment its pane is drawn - #1283
Merged
Merged
Conversation
The core held a pane's PTY size while its tab was drawn ahead of Herdr and sent it only once Herdr's layout confirmed the drawing, so a zoom reflowed the terminal about 150 ms after the request and a pane close left its sibling at the old grid until Herdr's close answer (0.7 to 4.3 s measured). The hold rested on the belief that Herdr sizes the PTY from the layout it applied; on the pinned Herdr 0.9.3 the PTY is the controller's size alone, through a split, a sibling's close and a zoom, so the hold had nothing to protect against. - Delete the grid hold: the core sends every changed view size to the pane's node at once, the terminal snapshot no longer carries grid_held, the shell no longer keeps a held grid set, and the node link's Resize carries no force flag. - A pane operation's timing record counts the resized pane's first frame after its resize went out rather than after Herdr applied the layout; the record's fields and stage names are unchanged. - Rewrite the pane geometry tests to the new contract: one resize at the drawing, none when Herdr confirms the same layout, one more when it differs, none for a size the pane already runs at. - Add the contract test on the pinned Herdr asserting the controller's PTY size survives a zoom and a sibling's close, so a pin bump learns when that changes. - State the new contract in ARCHITECTURE.md, UI_BEHAVIOR.md, PERFORMANCE_TESTING.md and AGENTS.md.
The pane zoom chord moved to ⇧⌘↩ with the right-lane expand chord, but the topology measurement still pressed ⌥⌘↩, so every zoom and unzoom sample timed out and the nightly's zoom latency row has been empty since.
A split or a new tab publishes at once with a sibling's cwd, or the tab's checkout, standing in for the pane's unconfirmed cwd, and the worker's pane.get answer then republished the whole projection even when it only confirmed that stand-in: at operator scale on the topology fixture, 21 of 21 answers changed nothing and each cost a full publish. The answer now publishes only when it moved a cwd or the publish before it was held for the pane it answers; the coordinator's publish state remembers that hold.
The frame watch of a geometry operation starts when the resized pane's PTY size goes out. A resize sent before the operation's layout was drawn belongs to the pane's previous size and must not start the watch, so the timing record now requires the drawn stage as well as the resize. The pinned-Herdr contract test judged every frame a step produced, and a frame queued before the resize still carried the old size. It now types a marker after each step (on Unix with the PTY's own stty size) and judges only the frame that shows it, so the test holds on every operating system in the os contract lane. Stale comments that still described the force flag and the grid hold are removed from events.rs, terminal.rs and ARCHITECTURE.md.
A pane split beside a confirmed one is shown at that sibling's cwd until Herdr confirms its own. The answer that confirms the cwd the pane was announced with changes nothing in the replica, so the publish skip added for D-12 left the pane at the sibling's folder on the screen whenever the two differed. The catalog state now keeps the stand-ins the last publish showed, bounded by the unconfirmed-cwd cap, and the answer publishes when any of them is not the cwd the replica holds for that pane. A timing record's resize starts its frame watch once the shell has the layout, drawn ahead or applied from Herdr, so an operation with no prediction still completes.
Contributor
Author
|
Follow-up for D-12/B12 (split and new-tab layout→applied on the operator's app, not reproduced by the fixture): with-hide/hide-private#42. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Related: PRD grid-ahead-of-herdr (local), follows instant-pane-topology (#743)
Summary
In a tab with several panes, a zoom, divider drag, pane close or split moved the pane rectangles at once, but the text inside kept its old grid until Herdr confirmed the layout and the core sent the PTY size: the terminal looked like it stretched slowly.
The core held that size on purpose, on the belief that Herdr sizes the PTY from the geometry it applies. On the pinned Herdr 0.9.3 it does not: the PTY is the controlling client's size through a zoom, a split and a sibling's close, which a new contract test pins.
The hold is gone. The shell fits each terminal to the rectangle drawn for it the moment it is drawn, the node sends that size at once, and Herdr's later layout changes nothing when it matches. A timing record's frame watch now starts at that resize instead of at Herdr's confirmation.
Two measurement fixes ride along: the topology scenario presses the current zoom chord, and a new pane's cwd answer republishes only when it would change the screen (one full publish saved per split or new tab at operator scale).
Review
hide-herdr-client/tests/it/real_herdr.rsis where the D-14 contract test lives (theos contractlane runs on all three systems); the PRD namedhided/tests/it/real_herdr.rs, which runs on Windows only.herdr-core/src/runtime/events.rs-TerminalResizeno longer has a held branch; a resize now reaches the node whenever the core's recorded size differs (high-frequency path, under the runtime mutex).herdr-core/src/runtime/op_timing.rs- a resize marks every record on that pane that is drawn or applied; two operations on one pane share one resize (timing only, no behaviour).herdr-core/src/session_sync/coordinator.rs-pane_cwds_answer_publishesskips a publish; the skip is wrong if a pane the screen shows at a stand-in could stay there, whichCatalogState::stand_insguards (failure path: a pane left in the wrong folder).hide-node-link/src/lib.rs-TerminalControl::Resizelostforce; the enum does not deny unknown fields, so an older node reading a newer link and the reverse both parse.OpTimings::resize_sentscans at most 64 open records with no allocation, and oneWatchFramegoes out only when a record starts waiting;stand_insholds at mostUNCONFIRMED_CWD_LIMIT(64) entries and is replaced per publish; nothing new runs per tick or per frame.Evidence
stty sizeafter each step and by the frame size the controller receives (new contract test, passed locally withHIDE_E2E_HERDR_BIN; the code reviewer ran it 42 times, 6 sequential and 36 concurrent, all green).pane_geometrytests pin one PTY size per zoom at the drawing and none when Herdr confirms the same layout, a resize before the drawing starts no frame watch, and a refused operation sends nothing more.0.4.1-main.e8c08186by its Info.plist and the sha256 of itshided, which now sits beside the app ashide-previous-0.4.1-main.e8c08186.app.bak; it is main five commits past the merge base 7f02ba5, and that range touches no terminal, node or shell path, onlydelivery.rs; the installed app has since moved to0.4.1-main.fdc68c74, so a rerun against it is a different baseline) and after (release build of this branch),MEASURE_SCENARIO=topology --isolated-headless, operator scale (43 workspaces, 62 tabs, 66 panes, 30 agents, 5 printing), 10 rounds each, page clock from the key press to the first frame with the new grid:After the change the first frame with the new grid arrives in the same frame as the rectangle (frame = screen for zoom, unzoom and close); split and new_tab wait for a pane that does not exist yet, so their path is unchanged and the difference is load noise.
pane_op.timingin the after run, operator scale: zoom first_frame p50 22 ms with the resize at the drawing (drawn p50 8 ms), and oneterminal.resize_settledper operation (40 for 40), none on Herdr's confirmation;pane.prediction_mismatch0.os contractlane on macOS, Linux and Windows (verify run 38922022691); the Windows branch asserts the frame size after each step but notstty.drawn_msprecedingherdr_ack_ms, not by a PTY-side read; the fixture's close ack is 36 ms, not the 0.7-4.3 s the operator saw.Verification record
agents/prd/grid-ahead-of-herdr/prd.md(sha256 d297b23b6fc270cf96e410bfcb6a81adf775e7a9cbd73fb6b85b1da7a45bcf1f)agents/runs/grid-ahead-of-herdr/verification-report.jsonandagents/runs/grid-ahead-of-herdr/verification-report.md; source fingerprint d6f3d096ef55aca1a20af4d5c9ba0183736a567b9bbbb4babff8e1f69fde2cc1bash scripts/verify-cargo.sh test(exit 0)bash scripts/verify-cargo.sh lint(exit 0)forcecomments in events.rs and terminal.rs (fixed, 2bdedef); the cwd-answer skip left a stand-in on screen when the announced cwd differed (fixed, c3ca056, closure confirmed). Follow-up improvements: two timing records on one pane share a resize; the unchanged-gridincompletecase is not asserted; no shell-layer test that a drawn zoom reports a resize before Herdr confirms; the contract test reads the PTY size at one instant.grid-ahead-of-herdr, basemain