Skip to content

Serialize pane focus requests and retain the last selection - #377

Merged
yansfil merged 16 commits into
mainfrom
fix/focus-request-ordering
Oct 4, 2026
Merged

yansfil merged 16 commits into
mainfrom
fix/focus-request-ordering

Conversation

@yansfil

@yansfil yansfil commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Related: #299

Summary

Rapid pane clicks could leave an older Herdr response undoing the last selection.
The core now sends one focus request at a time and retains one replaceable latest successor.
Authoritative readback confirms the pane and its owning tab; unknown results stop the automatic burst.
External Herdr focus changes still follow a fresh readback when no request is pending.

Review

  • Judgment: Unknown-result retry behavior and the external focus-follow contract.
  • Files: live.rs and runtime focus handling - request ownership, bounded work and failure outcomes.
  • Files: session_sync/coordinator.rs - reads outside the runtime mutex and stale readback rejection.
  • Files: web/src/terminals.ts - physical focus reaches core ordering without snapshot-driven echo.
  • Fixtures: web/e2e/s2.spec.ts preserves cached terminals in open tabs; web/e2e/pane-focus-ordering.spec.ts waits for core acceptance of the last click before releasing its held request.

Evidence

  • Confirmed: 73 selected Rust focus tests and two isolated real Herdr focus-ordering cases passed.
  • Confirmed: Workspace formatting, all-target Clippy and full Rust workspace CI passed before the fixture corrections.
  • Confirmed: The failed S2 flow now passes locally with unchanged counts, close events and time limits.
  • Diagnosed: The S2 trace shows the closed pane gone; the remaining parked pane belongs to an open fourth tab.
  • Confirmed: The corrected rapid-click case passed locally against isolated real Herdr, retaining the two-request, single-in-flight, final-pane input and external-focus assertions.
  • Diagnosed: macOS CI released the held request before the final click reached core; an earlier snapshot had already drawn that pane.
  • Confirmed: The unchanged desktop cycle passed locally and in the subsequent CI run; current-head required CI is pending.
  • Unrun: Additional native focus, Windows focus and performance checks remain outside the required merge gate.
Verification record
  • Source: 7d1f0bb22be24671c26a2632c4bc317ba5f7e938, clean and fully pushed; PR is ready.
  • Previous required verify: S2 failed on Linux/macOS; desktop cycle failed.
  • Local corrected S2: one passed in 25.1 seconds; all owned process identities exited.
  • Local unchanged desktop cycle: one passed in 44.5 seconds; all owned process identities exited.
  • Prior macOS failure: rapid-click test released the gate 1 ms before the final intent was accepted; the request list contained an intermediate second-pane request.
  • Corrected rapid-click case: one passed in 12.3 seconds; original click counts, time limits and behavior assertions retained. All owned process identities exited.
  • Current required verify: pending on the pushed source.
  • Original S2 RED trace proves closed w1:p6 absent and retained w1:p5 belongs to open w1:t4.
  • Original focus-race RED, incomplete CLI run, prior CI failures and the rejected fixed-count acceptance attempt remain preserved outside source.
  • Only required verify success gates merge; the lead performs the merge.

@yansfil

yansfil commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

Candidate is fully pushed at c325db5cbf03d748b157f70412a9664a09b071b4.
The two original isolated real-Herdr focus cases passed with unchanged assertions, click counts and deadlines; 73 selected Rust focus tests also passed.
All owned test processes exited, and original failure evidence is preserved.

Remaining gates: canonical full Rust lint/test, isolated native desktop focus verification, final independent source review, and required CI against current main.
The Rust lanes are prepared and await automatic FIFO capacity.
Native verification has not run; the last browser connection attempt failed, and the operator app has remained untouched.
Next action is to run those unchanged gates on this candidate, complete native verification and final review, then mark the PR ready only when the required checks are green.
The PR remains draft and issue #299 remains open.

@yansfil

yansfil commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

Canonical Rust lint now passes: workspace formatting and locked workspace all-target Clippy completed with warnings denied.
The owned lane exited zero and its tracked processes and process group are closed; the source remains unchanged and fully pushed.

Remaining verification: full Rust tests, native desktop focus behavior, final independent review and protected current-main CI.
These checks lack completed current evidence, so this remains a draft and issue #299 remains open.
Next action: complete the existing remaining gates and source review through their assigned owners; the coordinator owns the protected merge after current-main CI is green and review is clear.
All original failing runs remain preserved; the two real Herdr focus cases already passed and were not repeated.

Verification record
  • Source: c325db5cbf03d748b157f70412a9664a09b071b4, clean with zero local-only commits.
  • Command: bash scripts/verify-cargo.sh lint, exit 0, 50.4448 seconds.
  • Run: 2026-10-04 02:49:08.421129 to 02:49:58.843175 UTC.
  • Raw log SHA256: 37739305ec98cd4621c8e8b6e1e375133ce21b205ebb57218847f446a8c02b9c.
  • Original source and run evidence remain preserved; no additional source, scope or phase was introduced.

@yansfil

yansfil commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

The current required verify run failed in the unchanged S2 close flow on Linux and macOS.
Both jobs passed the closed-pane disposal check, then failed at web/e2e/s2.spec.ts:366: the global parked-terminal count expected zero but was two on Linux and one on macOS.
The artifacts do not contain hidden-terminal DOM identities or a trace, so these counts do not establish which panes remained parked or a shared cause with #299.

The existing runtime/attach owner is handling this S2 failure; the separate Windows fixture command correction does not cover it.
Next action: obtain the owning source correction supported by the parked-pane and workspace evidence, integrate the compatible source, and verify the unchanged failing cases.
Native focus evidence from an exact isolated candidate and final independent source review remain required before the coordinator's protected merge.
The branch remains clean and fully pushed; no assertion, timeout, test count or retry was waived, and no additional source writer or process was started.

The full Rust workspace suite passed in this same CI run, and both macOS focus-ordering cases passed.
Original passing and failing runs are preserved.

Verification record
  • Head: c325db5cbf03d748b157f70412a9664a09b071b4.
  • Required run: failure.
  • Linux shard 3: S2 failure, 18 other cases passed.
  • macOS web: S2 failure, 13 other cases passed.
  • Rust workspace: full suite passed, 1,858 passed and 13 ignored.
  • Full raw logs and failure artifacts were read and retained outside source; the local full workspace test lane remains unrun.

@yansfil
yansfil marked this pull request as ready for review October 4, 2026 03:43
@yansfil

yansfil commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

7d1f0bb2 push 완료: macOS rapid-click 테스트가 마지막 요청의 core 접수 전에 gate를 해제하던 동기화 오류를 수정했고, 해당 격리 Herdr 케이스 로컬 PASS(1/1, 12.3s); 클릭 횟수·기한 유지, PR Ready, 필수 verify 대기, 추가 네이티브 포커스·Windows 포커스·성능 검증 미실행.

@yansfil
yansfil merged commit 5286f69 into main Oct 4, 2026
39 of 41 checks passed
@yansfil
yansfil deleted the fix/focus-request-ordering branch October 4, 2026 05:10
yansfil added a commit that referenced this pull request Oct 4, 2026
Related: #299, #377

## Summary

- macOS의 순차 클릭 40회가 보류 요청의 기존 5초 제한을 넘겨, coalescing 대신 unknown 이후 동작을
검증했습니다.
- 같은 20쌍의 실제 Chromium 마우스 입력을 순서대로 묶어 보내 브라우저 왕복 지연을 제거합니다.
- 실제 전송된 포커스 변경의 코어 수락을 확인한 뒤 gate를 해제해, 마지막 진단과 시각에 의존하던 판정을 교체합니다.

## Review

- **조심해서 볼 파일**: `web/e2e/pane-focus-ordering.spec.ts` - 입력은 CDP의 실제
mouse events이며 DOM 이벤트나 dispatch를 대체하지 않습니다.
- **비용 검토**: burst당 120개 입력 명령, 관측 프레임 64개, CDP 세션은 `finally`에서 해제합니다.
- 단일 요청 상한, 마지막 pane의 실제 키 입력, Herdr 최종 포커스, 외부 포커스 추종 검증은 유지합니다.
- 클릭 횟수, timeout, retry, skip, quarantine을 변경하지 않습니다.

## Evidence

- **원인 확인**: 세 macOS 실패의 hided 로그 모두에서 첫 요청이 5001~5002ms에 unknown으로 끝난 뒤
클릭이 계속됐습니다.
- [#372
실패](https://github.com/modakbul-gongbang/hide/actions/runs/37179805703/job/111370084688),
[#373
실패](https://github.com/modakbul-gongbang/hide/actions/runs/37179682304/job/111369954345),
[#378
실패](https://github.com/modakbul-gongbang/hide/actions/runs/37179657967/job/111369590200)의
원본 로그와 artifacts를 보존했습니다.
- **macOS 실제 동작**: 격리된 pinned Herdr/hided/Chromium에서 두 focus 사례가 통과했습니다.
rapid 12.6s, unknown 14.4s.
- held burst의 마지막 코어 수락은 첫 요청 후 251ms였고, 첫 요청은 526ms에 superseded, 최종
pane은 confirmed로 끝났습니다.
- `scripts/verify-web.sh` PASS: web 904개, desktop 99개, hcoord unit
59개/e2e 36개와 typecheck/lint/build.
- `scripts/verify-cargo.sh cli`, design contract, workstation identity,
attribution 검사 PASS. 모든 격리 실행 프로세스를 정리했습니다.
- **미실행**: Linux E2E, 전체 Rust suite, native QA. PR의 필수 `verify`는 CI에서
확인합니다.

<details><summary>추가 증거</summary>

- Base: `5286f6958df7af0ea52556451406733d6e2073f2`; tested/pushed head:
`0b87fc5355300f6ebe249451356c2399b8729115`.
- 실행: `pnpm --dir web exec playwright test
e2e/pane-focus-ordering.spec.ts --workers=1 --max-failures=1
--trace=on`.
- 기존 test 30s / assertion 5s 제한을 유지했으며, 두 사례의 trace와 입력 관측은 로컬 ignored
run에 보존했습니다.
- 이번 변경 경로는 위 테스트 파일 하나입니다. 제품 source와 Herdr pin은 변경하지 않았습니다.

</details>
yansfil added a commit that referenced this pull request Oct 4, 2026
## Summary

Every PR ran Rust, the unit suites on three OSes and the full E2E, even
a docs-only PR.
The median time for the required checks to finish was 32.45 min (Orca
16.22, Paseo 20.65).
Now a `plan` job reads the changed paths (`HEAD^1..HEAD` of the PR merge
commit) and plans only the lanes the change needs.
The same plan sets each job's `if:` and is what `verify` checks the
results against.

- `verify` passes only when every **planned** lane is `success` and
every **unplanned** lane is `skipped`. A planned lane that was skipped,
failed or cancelled fails `verify`, and so does a `needs` entry the plan
doesn't know or a failed plan.
- The Windows browser `@platform` smoke moves out of `windows check`
into its own `windows e2e` lane, which calls `web-e2e.yml` the same way
nightly does. Compile, unit tests and the OS contract stay in `windows
check`.
- `checks` is split into `policy` (on every plan), `web checks`,
`desktop checks` and `hcoord`.
- A main push, a comparison that fails (base missing, not a merge
commit, diff parse failure, `cargo metadata` failure) and any
unclassified path all run **every** lane.
- Main pushes no longer cancel each other (`cancel-in-progress` is now
PR-only). `design-contract.yml` also cancels only the same PR's previous
run.
- The rules live in one place, `scripts/ci-plan.py`; the table in
`docs/TESTING.md`, "Which lanes a pull request runs", explains them.

## Review

- **판단해 주세요**: whether it is acceptable that **main's full run is the
safety net** for a lane wrongly left out. A wrongly skipped lane
surfaces as a failure on main after the merge, not on the PR.
- **판단해 주세요**: whether to keep the Windows smoke now skipping `@flaky`
tests, as macOS already did. No `@platform` test is tagged `@flaky`
today, so the behavior is the same for now.
- **판단해 주세요**: web code shared with the desktop host (`SHARED_WEB`) also
runs the desktop lanes and the macOS/Windows `@platform` lanes. That is
broader than the brief's "desktop 연결까지"; I chose it because terminal,
input and shortcut changes are Windows-impacting.
- **조심해서 볼 파일**: `scripts/ci-plan.py` `READERS` and `SHARED_WEB`. These
two hand-kept lists are where a lane can be dropped wrongly (the failure
path). Review found five omissions from tests reading files across
folders and they are fixed (below).
- **조심해서 볼 파일**: the `verify` job in `.github/workflows/pr.yml` and
`aggregate()`. This is the merge gate itself.
- **질문**: `site/`, `tools/`, `spikes/`, `.github/*.md` and `agents/prd`
currently fall under "unknown path → everything". Should a follow-up
narrow them?

## Evidence

**Plan replay over the last 20 merged PRs.** Each row runs the
classifier on the merge commit's `^1..` diff:

| PR | 경로 수 | 계획 | 생략되는 lane | Rust crate |
| --- | ---: | --- | --- | --- |
| #389 | 7 | 전체 (`scripts/web-shell-measure/run.sh`) | - | 전체 |
| #388 | 6 | 부분 | desktop-checks, hcoord, os-contract, windows-check,
windows-e2e, macOS-e2e, desktop-e2e | herdr-core |
| #385 | 125 | 전체 (`.github/pull_request_template.md`) | - | 전체 |
| #387 | 70 | 전체 (`contracts/hided-ws.schema.json`) | - | 전체 |
| #386 | 61 | 전체 (`contracts/hided-ws.schema.json`) | - | 전체 |
| #368 | 2 | 전체 (`.github/workflows/pr.yml`) | - | 전체 |
| #372 | 23 | 전체 (`.github/workflows/nightly.yml`) | - | 전체 |
| #382 | 3 | 부분 | web-checks, desktop-checks, hcoord | herdr-core,
hide-host, hided |
| #383 | 1 | 부분 | rust, desktop-checks, hcoord, os-contract,
windows-check, desktop-e2e | - |
| #384 | 8 | 부분 | web-checks, desktop-checks, hcoord, os-contract,
windows-check, windows-e2e, web-e2e, macOS-e2e, desktop-e2e | herdr-core
|
| #380 | 2 | 부분 | web-checks, desktop-checks, hcoord | herdr-core, hided
|
| #381 | 1 | 부분 | rust, desktop-checks, hcoord, os-contract,
windows-check, desktop-e2e | - |
| #378 | 58 | 전체 (`.github/workflows/nightly.yml`) | - | 전체 |
| #377 | 11 | 부분 | hcoord | herdr-core, hided |
| #361 | 91 | 전체 (`agents/prd/three-column-panel/prd.md`) | - | 전체 |
| #376 | 7 | 부분 | web-checks, desktop-checks, hcoord | herdr-core,
hide-agent-hooks, hide-ai, hide-herdr-client, hide-host, hide-kit,
hide-memory, hide-platform, hide-session, hided |
| #367 | 27 | 부분 | hcoord | herdr-core, hide-host, hided |
| #375 | 2 | 부분 | web-checks, desktop-checks, hcoord | herdr-core,
hide-agent-hooks, hide-host, hide-kit, hide-memory, hided |
| #366 | 8 | 전체 (`.github/workflows/release.yml`) | - | 전체 |
| #362 | 153 | 전체 (`agents/prd/overview-request-view/prd.md`) | - | 전체 |

- **줄어드는 lane**:
- 11 of 20 PRs would run a partial plan; 9 run everything because they
touch `.github/`, `contracts/`, `scripts/` or `agents/`.
- A docs-only PR (#384) runs no E2E, Windows or macOS lane. It still
runs `rust -p herdr-core`, because a herdr-core test reads the root
`AGENTS.md`.
- A web display change (#388) runs no Windows, macOS, desktop or
OS-contract lane.
- A Rust crate change tests only that crate and its reverse
dependencies, from `cargo metadata`. For example #380 tests `herdr-core`
and `hided` only.
- **확인한 것**:
  - `scripts/tests/test_ci_plan.py` passes 19 cases. They cover:
    - Docs-only, which excludes Rust and E2E.
    - A pure web display change, which excludes the Windows smoke.
    - `hide-platform`, which includes Windows and the OS contract.
- Shared web, a `@platform` spec, `desktop/src/main` and leaf-crate
reverse dependencies.
    - Every `READERS` entry.
- Unknown paths, lockfiles and workflows, a type change, an empty diff,
a missing base, a non-merge HEAD and a missing crate graph, which all
run everything.
- The aggregate rejecting a skipped, failed or cancelled planned lane,
an unplanned lane that ran, a missing or extra `needs` entry, a failed
plan and an empty plan.
- The full `python3 -m unittest discover -s scripts/tests` suite passes
(108). That includes the check that every gate a workflow runs is a
tracked script.
- actionlint passes on every workflow. `check-herdr-pin-single-source`,
`check-hide-design-enforcement`, `check-no-workstation-identity`,
`check-harness-ignore-anchor` and `verify-cargo.sh fmt-check` all pass.
- Running `plan` on #388 produced the expected `GITHUB_OUTPUT` (`lanes`,
`full`, `rust-packages`) and the job-summary table.
- Running `aggregate` with a fake `needs` passed when the results
matched the plan and failed when a planned lane was skipped.
- **리뷰 반영**: a code review and a fidelity review against the brief found
these, now fixed:
- Tests read files across folders, so these changes now plan the lanes
that read them: the root `AGENTS.md` (herdr-core test), `web/src` and
`hided/src` (herdr-core structure tests), `wirePath.ts` (imported by web
e2e) and `design/tokens.json` (read by web tests).
  - Every crate change now runs `windows check`.
  - Main pushes no longer cancel each other.
  - `docs/PERFORMANCE_TESTING.md` no longer describes the old lanes.
- **CI ([run
37214808511](https://github.com/modakbul-gongbang/hide/actions/runs/37214808511))**:
- The plan was full (the change touches `.github/` and `scripts/`), and
every lane ran, including the separate `windows e2e`. All passed.
- The first attempt failed in Linux web e2e shard 2/6 on
`home.spec.ts:82` (the location bar read `Home/hde-…` instead of
`Home/~/hide`). This PR touches no web or test code. `verify` reported
exactly `web-e2e: planned, expected success, got failure`.
  - One rerun of the failed jobs passed, and `verify` is green.
- The `home.spec` failure is a flaky-test candidate; it belongs to the
main-green work, not this PR.
- **확인하지 못한 것**:
- Partial plans have never run on Actions. A docs-only or web-only PR
has not been tried; the first one after the merge will show it.
- The cold-cache time of the `windows e2e` lane is unmeasured. It uses
the same path as the nightly Windows lane.
- Main runs now queue instead of cancelling, but GitHub keeps only one
pending run per group. If three merges land in a row, the middle merge's
full run can be dropped.
- **안전망과 위험**: a lane that should have run but was skipped is the risk.
Main's full run catches it after the merge; the fix is then a rule in
`scripts/ci-plan.py` plus a test case.

Does not include: a failure ledger or history, a quarantine registry,
cache changes, a `max-parallel` experiment, or the `package.yml` `paths`
trigger (all out of scope).
If this and the main-green PR overlap in `pr.yml`, whichever merges
later rebases.
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