Skip to content

Read a dropped focus acknowledgement as nothing in flight - #602

Merged
yansfil merged 1 commit into
mainfrom
fix/focus-ack-eviction
Oct 6, 2026
Merged

yansfil merged 1 commit into
mainfrom
fix/focus-ack-eviction

Conversation

@yansfil

@yansfil yansfil commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Refs #585

Summary

The core's acknowledgement list drops the oldest page when 16 others have spoken, and its comment says that page then reads as having nothing in flight.
The web store did not: with its own entry gone it kept the previous applied number, so a page with numbers still sent ignored the snapshot's focus until its next click.
A page that saw its own entry and no longer finds it now takes everything it sent as applied, the reading the core's comment describes. Before its first answer an absent entry still means "not applied yet".

Review

  • 조심해서 볼 파일: web/src/operatorFocus.ts - appliedAfter is the one rule; the store only calls it. The "seen once" test is applied > 0, since an entry is never removed except by the cap.

Evidence

  • 확인한 것: operatorFocus.test.ts (5 tests): an absent entry before the first answer still waits; after an answer, a snapshot without the entry reads as caught up; web typecheck, eslint and unit tests pass.
  • 확인하지 못한 것: No e2e drives 16 pages through the cap; the core side of the cap is covered by operator_focus.rs.

The core drops the oldest page's acknowledgement when 16 others have
spoken and says the page then reads as having nothing in flight, but the
page kept its previous applied number, so a page with numbers pending
ignored the snapshot's focus until its next click. A page that saw its own
entry and no longer finds it now takes everything it sent as applied; before
its first answer an absent entry still means the core has not applied one.

Refs #585
@yansfil
yansfil merged commit af09e76 into main Oct 6, 2026
18 checks passed
@yansfil
yansfil deleted the fix/focus-ack-eviction branch October 6, 2026 03:55
yansfil added a commit that referenced this pull request Oct 6, 2026
Refs #594
Related: #600 (같은 `session.rs`, 그 위에 rebase)

## Summary

Agent cycle(⌃Tab)을 commit한 직후 다시 cycle을 열면 순서가 틀어지던 core 결함을 고칩니다.
`keys.spec.ts` "⌃Tab and ⌥Tab commit once"가 macOS에서 가끔 첫 시도에 실패하던 원인입니다.

- 기전: 다른 tab의 pane으로 가는 `focus_pane`은 Herdr에 `pane.focus`를 보냅니다. Herdr는
바로 답하고, 그 때문에 바뀐 active tab은 session stream으로 나중에 알립니다.
- core에는 그 tab 이동을 기다리는 기록이 없어서, 늦게 온 이동을 Herdr 자신의 이동으로 보고
따라갔습니다(`tab.focus.followed`가 지나온 tab 순서대로 남음).
- 화면이 이전 tab으로 돌아가고 shell이 그 pane을 방문으로 기록해, 다음 cycle의 순서가 틀어졌습니다(CI:
cycle 2가 `w1:p1` 대신 `w1:p4`).
- 고침: Herdr가 보이지 않는 tab의 pane focus는 그 tab을 기존 tab
기다림(`pending_tab_focus`)에 기록합니다. 새 장부는 없습니다.
- pane focus와 함께 sent가 되고, 그 pane control이 도는 동안 만료되지 않으며, Herdr의 답부터 같은
3초 deadline을 받습니다.
- 다음 이동이 대체하면 기존 규칙대로 `superseded_tab_focus`가 되어 늦은 답이 소비됩니다. 거절, 보내기 전
대체, lane이 받지 못함이면 지웁니다.
  - Herdr가 이미 그 tab에 있으면(또는 Hide의 남은 tab 요청이 그 tab이면) 아무것도 기록하지 않습니다.
- `docs/ARCHITECTURE.md`의 pending model 문단에 이 기다림을 적었습니다. test
파일(`keys.spec.ts`)은 바꾸지 않았고 retry, timeout, sleep, allow를 더하지 않았습니다.

## Review

- **판단해 주세요**: "Herdr가 tab을 옮기는가"를 `herdr_active_tab_ids`와 Hide의 남은 tab
요청으로 판단합니다. 남은 요청이 있으면 그 tab을 Herdr가 곧 보일 tab으로 봅니다.
- **조심해서 볼 파일**: `herdr-core/src/runtime/session.rs` - runtime mutex 안.
추가된 일은 navigator에서 pane의 tab을 찾고 기다림 하나를 쓰는 것뿐이고 I/O는 없습니다.
- **조심해서 볼 파일**: `session.rs` `expire_pending_view_focus` - failure
path. pane control이 도는 동안 그 pane이 건 tab 기다림은 만료하지 않습니다(pane 쪽 규칙과 같음).
- **비용 검토**: `focus_pane`마다 navigator의 tab과 pane을 한 번 훑습니다. 새 상시 작업, 알림,
queue는 없습니다.

## Evidence

- **확인한 것 (수정 전 실패)**: 새 core test 2개는 기다림을 거는 함수를 비우면 실패하고 되돌리면 통과합니다.
- **확인한 것 (#600 위)**: main af09e76(#600, #602 포함)에 rebase한 162c1b54에서
`nextest -p herdr-core` 1491개 통과, clippy `-D warnings`, fmt 통과.
- **확인한 것 (부하 아래 e2e, 162c1b5)**: `yes` x6, 3 workers, retries 0으로
`agent-tab-groups` 120/120(12개 x10), `recent`(Recent와 area cycle) 20/20.
- **확인한 것 (재현 probe)**: commit 직후 다시 cycle하는 15 round probe를 같은 부하에서
12번: 수정 전 9개 cycle 불일치와 run 1개 실패, 수정 후(rebase 뒤 포함) 360개 cycle 모두 일치.
- **확인하지 못한 것**: `keys.spec.ts`(desktop native focus)는 로컬에서 돌리지 않습니다. 이
PR의 CI desktop lane으로 봅니다. 원래 실패는 run 몇 번에 한 번이라 녹색 run 하나로 재발 없음을 증명하지
못합니다.
- **확인하지 못한 것**: core test
`usage_activity_hints_are_accepted_without_persisting_ui_state`가 e2e 부하
중 전체 실행에서 한 번 실패했습니다. 단독 60번 반복에서 main 코드 1/60, 이 브랜치 2/60과 1/60이라 이 변경과
무관한 기존 경합으로 봅니다.

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

- 새 test:
`view_authority_a_pane_focus_s_late_tab_move_is_its_answer_not_an_outside_focus`(pane
focus 4번 뒤 stream이 t3, t1, t2, t1을 늦게 알려도 화면은 t1, 그 뒤 Herdr 자신의 t3 이동은
따라감).
- 새 test:
`view_authority_a_pane_focus_tab_wait_ends_when_no_tab_move_will_arrive`(거절,
Herdr가 이미 그 tab, stream이 끝내 알리지 않음의 세 경우 모두 기다림이 끝나고 이후 Herdr의 이동을 따라감).
- 수정 전 실패 메시지: "Herdr naming w-order:t3 does not move the tab the
operator chose last", "a focus in another tab moves Herdr's tab".
- probe는 조사용이라 커밋하지 않았습니다.

</details>
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