Repository navigation
Give Overview's focus return the late hand-back guard - #450
Merged
Merged
Conversation
yansfil
added a commit
that referenced
this pull request
Oct 5, 2026
Related: #433 (retried interactions), #437 (Rust sleeps), #430 (guide), #434 (clock injection and Rust waits), #429 (headless renderer), #438 (shared gate), #419 (retries) ## Summary Playwright specs in `web/e2e` and `desktop/e2e` now pass `eslint-plugin-playwright` plus two repository rules, an e2e test size budget runs in the same `lint` script, and clippy refuses `std::thread::sleep` in Rust. All of it runs in the existing lanes (`web lint`, `desktop lint`, `clippy`); no new job or workflow step. Existing violations were fixed where a state exists to wait for, and the rest carry a reasoned allow, listed below. ## Review - **판단해 주세요**: `quietFor` is the only sleep an e2e spec may use for a window in which something must not happen; its 30 call sites each state the claim. Is a time window the right form for those, or should some become a counted check? - **판단해 주세요**: `no-conditional-in-test` (98 hits, mostly `process.platform` and fold toggles) and `max-expects` (2409 hits at the default of 5) are not enabled; the size budget replaces `max-expects`. Enable either? - **조심해서 볼 파일**: `web/eslint-rules/hide-e2e.mjs` - two hand-written rules; `web/scripts/check-e2e-test-size.mjs` - the baseline logic; `web/e2e/wait.ts` - the one `eslint-disable` for `waitForTimeout`. - **조심해서 볼 파일**: `web/e2e/s3.spec.ts` (two draft recovery tests) - they must not reload the page, so they carry a line allow with the reason; adding `about:blank` made both fail. - **조심해서 볼 파일**: `web/e2e/theme.spec.ts` - `networkidle` replaced by asserting hided's empty 404 for `/gallery`; `web/e2e/agent-tab-groups.spec.ts` - a 300 ms sleep between two `tab focus` calls was removed (the CLI returns after Herdr applied it, events reach the core in order; a probe showed the first focus changes nothing visible); `web/e2e/s3.spec.ts` - the offline window now also asserts the file was not written. - **질문**: #434 merged first; this branch took main and dropped the `#437` allows on the five functions it fixed (`hide-ai/src/router.rs` x3, `usage.rs`, `live.rs`). ## Evidence - **확인한 것**: `pnpm lint` in `web` and `desktop` pass (ESLint plus the size budget); `cargo clippy --workspace --all-targets -- -D warnings` and `cargo fmt --check` pass; `scripts/tests` 108 pass; the identity and attribution checks pass. - **확인한 것**: each rule fires on a planted violation (`waitForTimeout`, an action inside `toPass`, `goto` of `#token=` after `restart()`); the size budget fails when a baselined test grows (it caught this branch's own 9-line addition to the Overview test, which moved into a helper). - **확인한 것**: ran the changed specs against a local `hided` and the pinned Herdr, all pass: theme (gallery and restart), start-panel, agent-tab-groups external focus, sidebar-pr-start, cmdk recents, both s3 draft recovery tests, s6 Main/Overview (failed once on the first run at the File Views open, passed on the immediate rerun; this PR only relabels a wait in that test), and the Overview graph test. - **확인한 것**: a reviewer found the labels above too loose in a first pass (a settle wait named `quietFor`, native captures without `compositorPresents`, Rust allows with the wrong reason); all were fixed before this PR. - **확인하지 못한 것**: known gaps in the new lint: `expect.soft(fn).toPass()`, a poll that calls an action through a helper, and a `goto` through a local `url` variable after `restart()` are not seen; a hand-written `new Promise((r) => setTimeout(r, ms))` is not seen either (mobile.spec x2, remote-workspace, browser, workspace-columns x2 exist today); clippy covers `std::thread::sleep` only, not `park_timeout`, `wait_timeout` as a delay or a spawned `sleep`. #437 lists the Rust gap. - **확인하지 못한 것**: the other edited specs (digit, keys, browser, terminal-links, session-labels, the macOS desktop specs) were not run; desktop e2e needs the macOS lane. Windows and Linux lanes run in CI. - **확인한 것**: macOS clippy does not compile `cfg(windows)` or Linux-only code, which is how the two Windows named-pipe waits in `hide-platform/src/ipc.rs` slipped through (found by the Windows OS contract job). A source scan of every `sleep(` call in the tree, regardless of cfg, now finds none outside an allowed function; a Windows-target clippy run reached `hide-platform` and `hide-ai` before `ring` failed to build on this Mac, so the Windows lane in CI is the check for the rest. - **확인하지 못한 것**: `Instant::now` and `SystemTime::now` bans in clock-injected modules. Clippy cannot scope a method to a module and #434 has injected no module yet; once it has, a per-crate `clippy.toml` or a module-level `deny` with those two methods is the follow-up. ### Sleeps and waits, before and after | | Before | After | | --- | --- | --- | | `waitForTimeout` in `web/e2e` and `desktop/e2e` | 53 | 1 (`web/e2e/wait.ts`, behind three named helpers) | | `quietFor`: a window in which something must not happen | - | 30 | | `compositorPresents`: native capture on macOS | - | 6 | | `measureFor`: idle measurement and sample pacing | - | 5 | | `animationsFinished`: waits for finite animations, not time | - | 10 | | `unchangedForFrames`: waits until a value stops changing for 30 animation frames (bounded) | - | 3 | | Waits on time removed or replaced by a state or a stronger assertion | - | 3 (agent-tab-groups ordering sleep, `networkidle`, s3 offline window) | | `no-action-in-poll` allows, all #433 | - | 10 | | `reopen-after-restart-through-blank` allows (reconnect is the subject) | - | 2 | | Rust allow (`#[allow(clippy::disallowed_methods)]`) | Count | | --- | --- | | Bounded polling helper or inline bounded poll (sleeps between observations of a state, with a deadline) | 26 | | The sleep is the subject (a slow fake peer or backend) | 1 | | A child process kept alive for the test to kill | 6 | | Production wait, not test code | 31 | | Test that sleeps for a state, tracked in #437 | 59 | The production waits are allowed line by line rather than by a crate-root allow with `deny` in test modules: that form would leave every new `mod tests` and `tests/*.rs` file unguarded until someone adds the attribute, whereas the line allows fail closed. ### Size budget `web/e2e/test-size-baseline.json` (20 tests; #447 split three of them) and `desktop/e2e/test-size-baseline.json` (13) record the tests over 120 lines or 40 `expect` calls as a ceiling that only shrinks. ## Pending guide sentences `docs/TESTING.md` names #429, #438 and #434 as pending, and #419 for retries and nextest; each of those pull requests fixes its own sentence when it takes main. <details><summary>Verification record</summary> Base `origin/main` 4df25a0. Local runs: `pnpm lint` (web, desktop), `scripts/verify-cargo.sh clippy --workspace --all-targets -- -D warnings`, `fmt-check`, `python3 -m unittest discover -s scripts/tests`, Playwright specs listed above. Review by a separate reviewer: see the PR comments. </details> Main merge (#434, #435, #431, #450): baselines were refreshed after it. Two `browser-cdp.spec.ts` tests added by main were already over the budget and are baselined (172 and 121 lines); the Overview test grew 9 lines on main and its ceiling moved with it. Rust allows: 123 in total after the merge.
yansfil
added a commit
that referenced
this pull request
Oct 5, 2026
…468) Related: #424 (s2 flaky, closing condition below); #438 (control lane; its CI showed the same delay and it is not the cause); #447, #449, #450 are independent. ## Summary The local session coordinator read Herdr's focus (`pane.layout` then `workspace.get`, 5 s each) before it ingested a session update whose focused pane differed from Hide's. That read ran on the coordinator thread, so a pane close, a zoom or a resize behind it reached the screen only after Herdr answered, up to ten seconds late, and the next stream delta waited behind it too. Now the update is ingested at once, and only the differing focus (with the zoom of the pane it names) stays Hide's until the read answers. The read runs on its own worker outside `Mutex<Runtime>`, one at a time, and a confirmed answer applies the layout the session already stored. The 5 s deadline is unchanged and nothing waits longer: the order of read and ingest is state now (`pane_focus_readback`, one slot the runtime takes under the lock and the worker frees on every way out). Separate commit `0c2a2f35` (asked for in review of #438): a lost answer that discards waiting tab or pane focus controls now records the number dropped and the request whose answer was lost in the diagnostics. ## Review - **조심해서 볼 파일**: - `herdr-core/src/runtime/session.rs` - runtime mutex and ownership: `ingest_session_awaiting_focus_readback` takes the slot under the lock, `finish_pane_focus_readback` re-checks serial, generation and pending requests before it adopts, and hands the worker the next read only when the stored layout still shows a move. - `herdr-core/src/session_sync/coordinator.rs` - failure path: `spawn_focus_readback` frees the slot on a panic, a poisoned lock, a dropped runtime and a failed thread start; the read itself is the same `confirm_pane_focus`. - `herdr-core/src/runtime/control_lane.rs` - failure path (separate commit, asked for in review of #438): a lost answer that discards waiting focus controls now records how many (`tab.focus.unknown`, `pane.focus.dropped`, including the pane-after-pane case that recorded nothing) and whose answer it was (target, request id, serial in the diagnostic line); `control_order.rs` asserts the counts. - **비용 검토**: no new work per input; the thread is spawned only when a stream move differs from Hide's selection, one is outstanding at most (cap 1, owner: the runtime slot), each lives at most two 5 s reads per answer and ends with its answer; an unconfirmed answer is not repeated until the next session update, so there is no retry loop. - **판단해 주세요**: while the read is out, Herdr's zoom is not shown, because a zoom's subject is the focused pane Hide has not adopted yet; the geometry (panes, splits) is shown at once. ## Evidence - **확인한 것**: - The failing test came first (commit `Test that a pane close is ingested ...`): with FakeHerdr holding `pane.layout`, the runtime's layout still had the closed pane after Herdr had been asked (`["w1:p1","w1:p2","w1:p3"]` against `["w1:p1","w1:p2"]`). It passes with the fix, and the same test locks `Mutex<Runtime>` while Herdr still holds the answer, then releases and checks the focus and zoom are followed. - 6 core tests: that one, an unconfirmed readback keeps Hide's focus and frees the slot (`session_sync/coordinator.rs`), and four in `runtime/tests/session_navigation.rs` (stale stream, a new selection or connection outlives an answer, one read outstanding and a superseded one hands on, an answer for another tab than the selected one cannot pull focus back; the last fails without its guard). The old three readback tests were rewritten onto the new calls. - `scripts/verify-cargo.sh test -p herdr-core --lib`: 1397 passed; `lint` and `fmt-check` clean; `scripts/check-capability-readers-off-lock.sh` passes. - **확인하지 못한 것**: - **Whether this resolves s2:55 (#424).** The core test proves the ingest was held behind the read and no longer is. The CI logs of the s2:55 failures show a gap of about 4.5 s before the core's authoritative update on macOS and Windows, which matches the old blocking read, but they carry no hided diagnostics, so the match is a hypothesis. The control lane in #438 is ruled out (core tests show close, zoom and resize start while it is busy). Only CI can show it. - No native, Linux or Windows run of the web e2e, and no live Herdr; the read is covered by FakeHerdr. - A zoom behind a held focus appears when the read confirms, not before; not asserted against a real Herdr. **Closing conditions.** #424 and the s2:55 flaky issue are not closed by this PR. Close them when `main` is green on the same lane (web e2e, retry 0, existing deadlines) for 2 consecutive runs after this merges and the `@flaky` tag is gone; if s2:55 fails again after that, the cause stays open on #424 and this PR is not the cause to blame twice.
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: follows #431, which gave
useReturnFocusa count of opened layers so a late hand-back cannot take the keyboard from a newer layer.Summary
Overview's modal closed with its own
onCloseAutoFocusthat calledrestoreFocuson the stored return target with no such guard, so the same race stayed there: Radix hands focus back from a timer, and under load that timer can run after the next layer opened and closed.DialogContentnow takesreturnFocusTo, the place the owner names, anduseReturnFocusaccepts it (named), so Overview goes through the same opened-layer count as every other layer; Overview's own handler is gone.Focus still sitting inside the dialog's own surface is not read as the operator having moved on; focus anywhere else is.
Review
namedlives onuseReturnFocusandreturnFocusToonDialogContentrather than a second hook;AddProjectDialogand otheronCloseAutoFocususers were left as they were.web/src/components/ui/layer.ts- the hand-back order guard shared by every layer.Evidence
web/src/components/ui/layer.test.tsx, each deciding the order by calling the hand-back itself: the named target is used, a late hand-back after a newer layer opened and closed leaves the keyboard alone, focus outside the layer is kept while focus on its own surface is taken back.bash scripts/verify-web.shpasses (994 and 99 unit tests, typecheck, lint, builds);overview-modal.spec.ts2 of 2 on macOS.