Repository navigation
Wait for hided to accept every click of a burst before typing into the last pane - #575
Merged
Merged
Conversation
…e last pane The keys-after-a-burst test counted the clicks the page had sent, not the focus changes hided had accepted, so under load a confirmation of an earlier request in the burst satisfied its barrier while the rest were still queued: a lagging snapshot then moved the browser's focus to the other pane and the typed marker went there. The test now counts every pane.focus.requested diagnostic against the changes the page sent, waits for the page to have applied every frame Playwright saw and for the keyboard to be on the pane's terminal, and is split from the held-request and external-focus contracts it shared a stack with.
This was referenced Oct 6, 2026
yansfil
added a commit
that referenced
this pull request
Oct 6, 2026
…hat click (#589) Refs #585 ## Summary A snapshot that was already on its way when the operator's last click was sent still names the pane clicked before, and the page moved DOM focus to it, so keys typed right after landed in the wrong pane until the snapshot that includes the click arrived. The page now numbers each operator `focus_pane` it sends (a per-page-load `client_id` and a `sequence`), the core records the last number it applied per page in the snapshot's `focused.operator_focus`, and a pane follows the snapshot's focused pane only once that number has caught up with the last one sent. After it has caught up, a snapshot naming another pane is a real move (the core followed Herdr, or refused the click and kept its value) and is followed as before. There is no time window, and no input is dropped or delayed. ## Review - **판단해 주세요**: A remote pane's focus (`remote_control`) is not numbered, because the local core never applies it; a stale device session can still pull focus there. Is that follow-up acceptable? - **판단해 주세요**: For a moment after a click the header (`data-focused`) can still follow the older snapshot while the keys stay on the clicked pane; the header settles with the next snapshot. - **조심해서 볼 파일**: `herdr-core/src/model.rs` and `herdr-core/src/runtime/session.rs` - snapshot wire: new `focused.operator_focus` list, skipped when empty, capped at 16 pages with a logged eviction. - **조심해서 볼 파일**: `herdr-core/src/runtime/events.rs` - the ack is recorded for every operator focus before the core decides, so a refused or redundant click still answers the page. - **조심해서 볼 파일**: `web/src/ws.ts`, `web/src/PaneView.tsx` - the number counts only once the frame has left the socket, and a new connection awaits nothing. - **비용 검토**: per click one small struct update in the core and one `{client_id, sequence}` entry (about 60 bytes) in the next snapshot's rest section. - **비용 검토**: no new notification, subprocess, lock or timer; the page adds one store write per click and one boolean selector per pane view. The list is capped at 16 entries. ## Evidence - **확인한 것**: `web/e2e/stale-snapshot-focus.spec.ts` holds the daemon's frames at the WebSocket: with the last click sent and only an older snapshot delivered the keys stay on the clicked pane, then the snapshot that includes the click keeps them. With the gate removed it fails 3 of 3 at that assertion; with it, 6 of 6. - **확인한 것**: A move Herdr makes with nothing pending still takes the keys (second spec of the same file). - **확인한 것**: `operator_focus.rs` (5 core tests) covers refused clicks, newest number kept, restore origin and unnumbered events not recorded, the cap and eviction, and the delta carrying the field; `operatorFocus.test.ts` (4 tests) covers the store rule and a lost socket. Core lib 1455 passed, web unit 1041 passed, clippy, fmt, eslint, typecheck and the e2e size budget pass. - **확인한 것**: `pane-focus-ordering` "rapid pane clicks" as it is on main (without the wait for hided to accept every click from #575): 40 of 40 passed locally with 4 `yes` processes saturating the CPU. - **확인한 것**: Click-to-snapshot latency (focus_pane sent until a snapshot with its number arrives, macOS, 3 runs each). Idle one click: 19, 26, 22 ms. Idle 40 clicks queued back to back: p50 95-106 ms, p95 103-122 ms, max 105-124 ms. Four `yes` processes: one click 12-19 ms; 40 clicks p50 99-167 ms, p95 106-264 ms, max 109-267 ms. - **확인하지 못한 것**: Linux and Windows were not repeated locally; the new specs run in CI. - **확인하지 못한 것**: #575's barrier in `pane-focus-ordering.spec.ts` is left alone; once this lands the test would pass without it, but removing the wait is a separate change after main's runs confirm it.
This was referenced Oct 6, 2026
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.
Refs #467
Summary
The test typed a marker right after a burst of 40 clicks and sometimes found it in the other pane's input.
Its barrier counted the clicks the page had sent, and treated any "Pane 1 focus confirmed" as the burst's end.
Under load hided still held a dozen of those focus messages, an earlier request's confirmation satisfied the check, and lagging snapshots then moved the browser's focus to the other pane before the keys arrived.
The test now counts every
pane.focus.requestedthe page was sent against the focus changes it sent, waits until the page has applied every frame Playwright saw, and until the pane's terminal holds the keyboard.The one test is split into three contracts on a shared
startFocusStackhelper: one held request, keys after a burst, an external focus.Review
PaneView.tsxeffect,terminals.tsfocusTerminal), a few hundred ms under load. It is not changed here; an issue draft is ready to file once you agree it is a product bug and not an accepted limit.web/e2e/pane-focus-ordering.spec.ts-observeDiagnostics(...).addedcounts entries across a capped list that drops from its front.web/e2e/test-size-baseline.json- the recorded entry goes away because the split test fits the budget.Evidence
yesx4, load average above 60 from other work), old barrier: marker failed in 2 of 107 runs, and in 2 of 42 instrumented runs it returned with hided having accepted 24 and 36 of the 40 changes the page sent.weblint, size budget and typecheck pass.