Skip to content

Ingest a session update before the stream focus readback is answered - #468

Merged
yansfil merged 5 commits into
mainfrom
fix/focus-readback-blocks-ingest
Oct 5, 2026
Merged

yansfil merged 5 commits into
mainfrom
fix/focus-readback-blocks-ingest

Conversation

@yansfil

@yansfil yansfil commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

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 Send local Herdr tab and pane controls through one ordered lane #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 (Flaky e2e: s2가 checkout, 탭, split 여정 중 탭 수를 놓침 (Linux) #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 Send local Herdr tab and pane controls through one ordered lane #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.

@yansfil
yansfil merged commit 60f95e0 into main Oct 5, 2026
28 checks passed
@yansfil
yansfil deleted the fix/focus-readback-blocks-ingest branch October 5, 2026 06:03
yansfil added a commit that referenced this pull request Oct 5, 2026
…t, removing two @flaky tags (#492)

Closes #287
Related: #416 (열어 둠: main 연속 2회 녹색 뒤 닫음)

## Summary

두 e2e의 `@flaky`를 지웁니다. 제품 코드는 바꾸지 않습니다.

- #287: 원인은 테스트의 준비 조건이었습니다. chip 클릭 직후 자식 pane view가 먼저 focus되지만 코어가 그려
주는 canvas는 아직 부모 탭이라, 그 탭을 누르는 일은 아무것도 보내지 않습니다. 곧이어 Herdr 확인이 오면
canvas가 자식으로 바뀌어 `data-pane-view=<parent>`가 안 보입니다. 이제 부모 탭이
`aria-selected=false`가 될 때(위임 canvas가 그려질 때)까지 기다린 뒤 누릅니다.
- #287의 순서 계약은 별도 test로 분리했습니다. chip의 `pane.focus`를 `herdrGate`로 붙잡고,
그동안 부모 탭을 눌러 `agent_layout.focus`가 한 번 가고 부모가 남는지 봅니다. 풀어 준 뒤에는 대기하던
`tab.focus`가 Herdr에 닿을 때까지 기다려 늦은 답이 처리된 뒤의 상태를 읽습니다.
- #416: 계약 세 개로 쪼갰습니다(폭 180 유지, 단계별 축소와 되돌림 대칭, 선택 탭 제목 이동과 스크롤 중 선택 탭
보임). 단언은 그대로이고 helper(`startStrip`, `check`)를 공유합니다.

## Review

- **판단해 주세요**: #416은 시그니처 A(Linux, 탭 15/16)의 원인을 찾지 못해 `Closes`가 아니라
`Related`로 두었고, issue는 main 연속 2회 녹색 뒤 닫습니다.
- **판단해 주세요**: #416 시그니처 B(macOS rAF 정지)는 두 run 모두 headless WebGL
비활성화(`236fb6f4`) 이전입니다. 그 수정으로 설명된다는 근거는 시점 비교뿐이고, 같은 SHA 대조는 없습니다.
- **조심해서 볼 파일**: `web/e2e/agent-tab-groups.spec.ts` - 새 gate test가 늦은
`pane.focus` 답과 대기 중인 `tab.focus`의 순서를 단언합니다.

## Evidence

- **확인한 것**: 같은 test를 CPU 부하(`yes` 4개) 아래에서 반복했습니다. #287 두 test 40/40(수정
전 변형은 부하 없이 3/10 실패), #416 세 test 24/24, 리뷰 반영 뒤 네 파일 묶음 50/50. eslint와
tsc 통과.
- **확인한 것**: #416 A 재현 시도는 탭 16개 생성만 30/30(부하), 원본 전체 5/5(부하)로 모두
통과했습니다.
- **확인하지 못한 것**: #416 시그니처 A의 원인. 해당 run들은 control lane(#438)과 ingest
수정(#468) 이전이라 그 수정들로 사라졌을 가능성이 있지만 확인하지 못했습니다. 재발하면 retry 1회 분류가 새 flaky
issue를 만듭니다.
- **확인하지 못한 것**: macOS와 Windows, CI 러너 부하에서의 반복. gate가 요청을 붙잡는 구간이
`pane.focus` 5초 기한 안인지는 로컬에서만 봤습니다.
- 쪼갠 대가: #416 16탭 test 두 개가 각각 스택을 새로 시작하고 탭 13개를 만듭니다. 대신 한 계약이 흔들려도 다른
계약과 분리돼 실패합니다.
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