Skip to content

Answer tab requests from Herdr's moves, not the folded session - #674

Merged
yansfil merged 5 commits into
mainfrom
fix/flaky-653-tab-moves
Oct 7, 2026
Merged

yansfil merged 5 commits into
mainfrom
fix/flaky-653-tab-moves

Conversation

@yansfil

@yansfil yansfil commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Related: #653, #667 (#667 리뷰 후속, main d13419b 위)
Related: #660 (fixed by #667; this keeps the order as a regression row)

Summary

#667은 checkout의 tab 권한을 "보낸 순서의 미답 tab 이동 목록"에서 유도합니다. 이 PR은 그 목록에 답하는 쪽을 Herdr의 이동 하나하나로 바꿉니다.

  • 문제: session은 Herdr의 event를 하나의 상태로 접습니다.
    • t2로 끝난 session은 Herdr가 t2로 갔는지, t2, t3, t2로 갔는지 말하지 못합니다.
    • 접힌 t2, t3, t2는 첫 t2만 지워 [t3, t2]가 3초간 남았습니다. 그동안 Herdr 스스로의 이동은 따라가지 않았고, agent가 t3로 옮기면 남은 항목이 그 이동을 답으로 먹었습니다.
    • "session이 마지막 요청의 tab을 보이면 모두 지움"(A안)은 e1(t2) | e2(t3) | e3(t2)가 따로 올 때 e2를 따라가 화면과 keyboard가 t3로 갑니다(Typing after an Agent edge drag goes partly to the other area's pane #413 증상).
  • 고침:
    • replica가 적용한 tab_focused 하나를 이동 하나로 기록합니다(SessionTabMoves: 개수와 최근 16개).
    • core는 아직 읽지 않은 이동을 차례로 소비합니다. 이동 하나가 그 tab의 가장 이른 요청에 답하고, 그 앞에 보낸 요청도 함께 빠집니다.
  • 틈 처리: 이동이 16개를 넘어 빠졌거나 reconnect로 replica generation이 바뀌면, 지금의 diff 규칙(새로 active가 된 tab, 새 focus event)으로 물러섭니다. 이때 tab.focus.moves_gap을 log에 남깁니다.
  • event stream 밖에서 읽은 snapshot은 아무 요청에도 답하지 않습니다. 해당하는 것은 close나 creation의 fresh projection, editor status 응답입니다. 이것이 답하면 같은 이동이 replica session에서 한 번 더 세어집니다.
  • (2) "이미 그 tab에 있었나"는 보낼 때 항목에 기록합니다. 값은 앞 요청의 tab이고, 앞 요청이 없으면 마지막 session의 focused tab입니다.
    • 거절, 미발송, pane 소멸로 빠지는 항목은 이 값을 다음 항목에 물려줍니다.
    • 답이 온 시점의 active tab으로 판단하면, 답보다 먼저 Herdr가 스스로 움직인 경우 3초를 기다렸습니다.
  • 격리된 Herdr 0.9.1 probe에서 새로 확인한 사실: 다른 workspace의 active tab으로 tab.focus해도 tab_focused가 나옵니다. 그래서 "보이는 tab"은 workspace마다가 아니라 Herdr의 focused tab 하나입니다. #667의 workspace별 판단은 지웠습니다.
  • (3)
    • 요청 항목이 없을 때 온 거절(deadline이 지난 뒤, lane이 시작하기 전)도 그 뒤에 물은 것이 없으면 tab.focus.refused로 보고합니다.
    • 미결 ask는 reconcile 한 번에 한 번만 모읍니다(TabAsks). 전에는 checkout마다 lane을 다시 훑었습니다.
  • Flaky test: Agent edge drag splits the desktop column into two live tab groups #660(둘째 Agent 영역 입력 글자 유실): CI hided 로그의 순서(click t2 답, click t1 답, Herdr t2, click t2 답, Herdr t1, Herdr t2)를 표 test 한 행으로 넣었습니다. 늦게 온 t1을 따라가 keyboard가 둘째 영역을 떠나던 원인입니다.
  • held replica의 publish: 이동만 바뀐 경우에는 layout을 기다리는 workspace가 있는 상태를 publish하지 않습니다. 이동은 다음 publish에 함께 실립니다. 이전 commit에서는 새 workspace의 tab_focused가 그 workspace를 뺀 상태를 publish했습니다. 그래서 creation worker가 이미 projection한 pane이 retire되었고, Windows CI의 hided_opens_a_pane_on_the_pinned_herdr_and_a_typed_line_echoes가 두 번 모두 실패했습니다.
  • 변경 없음: cap 16(TAB_FOCUS_LIMIT 상수 하나를 요청 목록과 이동 기록이 함께 씁니다), 3초 deadline, shell wire와 snapshot 계약. 새 timeout과 sleep은 없습니다.

Review

  • 판단해 주세요: remote 경로. replica는 local과 remote에 같은 코드라 이동을 똑같이 기록합니다. 다만 remote session(RemoteSessionSnapshot)에는 tab 요청 목록이 없어 이동을 싣지 않았습니다. 소비자가 없는 필드를 만들지 않으려는 선택입니다.
  • 조심해서 볼 파일:
    • herdr-core/src/runtime/tab_focus.rs take_tab_focus_answers, withdraw_tab_move, settle_where_herdr_already_was: Herdr/core ownership 경계입니다.
    • herdr-core/src/session_sync/replica.rs: tab_focused 적용 시 기록합니다. partial publish에는 그때까지의 이동이 실리지만, 이동만 바뀐 것으로는 partial publish가 일어나지 않습니다(refresh_published_state). 이동이 publish를 일으키면 held topology가 creation worker의 projection을 되돌립니다.
    • herdr-core/src/sidebar.rs SessionTabMoves::since: 틈 판정을 맡습니다.
  • 비용 검토:
    • lock 안 추가 작업은 소비하는 이동 수(16 이하)마다 16 이하 목록을 한 번 훑는 정도입니다. 이동은 payload에서 참조로 읽고 복사하지 않습니다.
    • replica는 tab_focused마다 문자열 하나를 넣고 17번째를 버립니다.
    • checkout마다 하던 lane 훑기는 reconcile당 한 번으로 줄었습니다.

Evidence

  • 확인한 것:
    • 표 test view_authority_the_screen_stays_on_the_last_request_whatever_order_herdr_answers_in은 10행입니다. #667의 답 규칙을 그대로 되돌려 돌린 결과:
      • 실패: "t2, t3, t2 folded into one session"(모든 요청이 답해지지 않음), "the shown tab's answer comes after Herdr moved on its own".
      • 통과: "t2, t3, t2 each in its own session".
      • A안을 넣어 돌리면 이 행이 "after Herdr(["t3"]) 화면이 w-order:t3"로 실패합니다. Typing after an Agent edge drag goes partly to the other area's pane #413 회귀를 지키는 행입니다.
    • view_authority_dropped_moves_fall_back_to_the_tabs_newly_active: 16개 초과와 generation 변경 두 경우 모두 diff로 물러서 요청을 답하고, 각각 gap 진단을 하나씩 남기는지 확인합니다. #667에서는 진단이 없어 실패합니다.
    • view_authority_a_refused_tab_focus_keeps_the_tab_and_reports_it: deadline 뒤에 온 거절도 보고합니다. #667에서는 보고 1건으로 실패합니다.
    • replica test every_applied_tab_focus_is_one_move_and_the_latest_are_kept: 순서, cap, 틈 판정, raw snapshot에는 이동이 없음을 확인합니다.
    • Flaky test: Agent edge drag splits the desktop column into two live tab groups #660 재현: 닫은 #673의 core test view_authority_answers_confirmed_ahead_of_their_events_are_not_followed(같은 순서, 옛 session 모양)를 그대로 돌린 결과:
    • Flaky test: Agent edge drag splits the desktop column into two live tab groups #660 e2e(TEMP, macOS agent-tab-groups --repeat-each 60 --retries 0): Derive tab focus authority from one list of sent, unanswered requests #667 직전 main acc80875에서 4/60 실패(TEMP TEMP flaky 660 evidence (do not merge) #671, run 37543522493), Derive tab focus authority from one list of sent, unanswered requests #667 뒤 main d13419b9에서 0/60(TEMP TEMP flaky 660 evidence for #674 (do not merge) #676, run 37545543305). 이 PR head 18788eef를 main 5a8d59b2에 merge한 ref에서 0/60(TEMP TEMP flaky 660 evidence for #674 (do not merge) #676, macos-15-arm64, desktop agent-tab-groups 'edge drag splits'). 4/60의 실패는 모두 둘째 영역의 입력 글자 유실이었습니다. 증상은 #667이 이미 없앴고 이 PR은 회귀가 없습니다. 추가한 표 행은 #660의 순서를 이 PR의 이동 모델에서도 지키는 회귀 test입니다.
    • replica test a_move_into_a_held_workspace_rides_on_the_publish_that_releases_it: layout을 기다리는 새 workspace로의 tab_focused는 publish하지 않고, 그 workspace가 풀리는 publish에 이동 하나가 실리는지 확인합니다. 고침을 되돌리면 "the move waits for the workspace it moved into"로 실패합니다.
    • Windows CI(cfc4c24): hided_opens_a_pane_on_the_pinned_herdr_and_a_typed_line_echoes가 재시도까지 두 번 모두 실패했습니다. hided 로그에 pane.selection_retired("Retired pane w1:p1; the selected checkout is now empty")가 pane_cwd.corrected보다 앞서 찍혔습니다. 같은 test가 통과한 main run에는 retire가 없습니다.
    • 로컬 herdr-core nextest(18788ee): 1604개 중 1603개 통과. github::tests::timed_out_gh_and_its_pipe_holding_helper_are_terminated는 전체 실행의 부하 아래에서 한 번 실패했고, 단독 재실행에서는 통과했습니다. 이 PR이 건드리지 않은 module입니다.
    • Herdr 0.9.1 probe(격리 server): 보이는 tab focus는 event 없음, 다른 tab은 있음, 다른 workspace의 active tab도 있음, pane focus로 tab이 바뀌면 있음, focus와 함께 만든 tab과 workspace.focus도 있음, t1,t2,t1 burst는 순서대로 세 건.
    • 로컬 herdr-core nextest 1553 통과, clippy -D warnings와 fmt 통과. 단 Derive tab focus authority from one list of sent, unanswered requests #667 head(235480b) 위에서 잰 결과입니다. main(d13419b)으로 rebase한 뒤 충돌은 없었고, fmt만 다시 돌렸습니다.
    • 기존 test 10개는 session에 이동을 싣도록 고쳤습니다(HerdrMoves test helper가 replica처럼 이동과 focus event를 붙입니다). 기대값은 바꾸지 않았습니다. 단 split checkout 확인 test의 설명은 "그 workspace가 tab을 보이면 확정"에서 "그 tab으로의 이동이 답"으로 바꿨습니다.
  • 확인하지 못한 것:
    • 18788eef의 clippy는 로컬에서 돌리지 않았습니다(디스크 8GiB 미만). CI가 확인합니다.
    • web e2e(view-bookmarks.spec.ts 등)는 로컬에서 돌리지 않았습니다. 디스크 여유가 8GiB 아래라 hided를 다시 빌드하지 않았고, CI에 맡깁니다.
    • hided와 다른 crate의 테스트도 같은 이유로 CI에 맡깁니다.
    • rebase 뒤의 compile, clippy, herdr-core test도 디스크 규칙(8GiB 미만)에 걸려 로컬에서 다시 돌리지 않았습니다. CI rust workspace lane이 확인합니다.

A session folds Herdr's events into one state, and one that ends on t2
cannot say whether Herdr went t2 or t2, t3, t2: a folded t2, t3, t2
answered only the first t2 and held Herdr's own moves for the deadline.
The replica now keeps each tab_focused it applies as a move (the
latest 16 and a count), and the core consumes the moves it has not read,
each answering the earliest request on its tab. A snapshot read outside
the stream answers nothing; dropped moves (over 16, a new replica) fall
back to the tabs newly active and are logged.

Which tab Herdr shows is one value, not one per workspace: Herdr emits
tab_focused for another workspace's active tab. Each request records it
as it leaves, a withdrawn request hands it to the next, and its answer
settles it when it was already there. A refusal with no request left is
reported, and the outstanding asks are collected once per reconcile.
@yansfil
yansfil merged commit d3e45da into main Oct 7, 2026
19 checks passed
@yansfil
yansfil deleted the fix/flaky-653-tab-moves branch October 7, 2026 00:05
yansfil added a commit that referenced this pull request Oct 7, 2026
…eir own field (#684)

Related: #674 (리뷰 후속), #653

## Summary

#674 리뷰에서 나온 작은 후속입니다. 테스트가 중심이고, 동작은 두 곳만 바뀝니다.

- (1) event stream 밖에서 읽은 snapshot이 아무 tab 요청에도 답하지 않는다는 것을 runtime 수준에서
고정합니다.
- 대상: close나 creation의 fresh projection, editor status 응답처럼 `tab_moves`가
없는 snapshot.
- t2 요청이 미답일 때 그런 snapshot이 t2를 보여도 미답 요청은 그대로입니다. 이동을 실은 다음 stream
session이 답합니다.
- (2) 표 test에 burst 행을 하나 더합니다: t1에서 t2를 두 번 누름(둘째는 lane에서 대기), 답 두 개,
Herdr 이동 t2 하나.
- 둘째 요청은 Herdr가 이미 t2에 있을 때 적용되어 event가 없습니다. 보낼 때 기록한 `herdr_before`로
답에서 정리되고, 3초 deadline을 기다리지 않습니다.
- (3) replica의 이동 기록을 `ProjectionState`의 `Option`이 아니라 replica의 일반
필드(`SessionTabMoves`)로 옮겼습니다.
  - `tab_focused` 적용 때의 `expect` panic 경로가 사라집니다.
- `state`는 Herdr의 topology만 담고, publish할 때 이동을 `published_state`에 얹습니다.
held 상태에서 이동만으로는 publish하지 않는 #674의 규칙은 그대로입니다.
- (4) `tab.focus.moves_gap`은 미답 요청이 있을 때만 남깁니다.
  - 미답 요청이 없으면 diff fallback으로 답할 것도 없습니다. 그래서 재연결마다 gap이 찍히던 것을 없앴습니다.
  - `docs/ARCHITECTURE.md`의 해당 문장도 고쳤습니다.

## Review

- **조심해서 볼 파일**:
- `herdr-core/src/session_sync/replica.rs` `refresh_published_state`:
이동을 얹는 자리가 여기 하나로 모였습니다. ready 경로는 이동만 바뀌어도 publish하고(전과 같음), held 경로는
이동만으로는 publish하지 않습니다.
- `herdr-core/src/runtime/tab_focus.rs` `take_tab_focus_answers`: gap
분기에 미답 요청이 없을 때의 빈 분기가 생겼습니다.
- **고치지 않고 남긴 것**(리뷰 지적, 이 PR 범위 밖):
- held workspace의 hold에는 상한과 진단이 없습니다(`replica.rs`
`refresh_published_state`의 held 경로). layout이 오지 않는 workspace는 그동안 이동을 실은
publish를 계속 막습니다.
- 미리 온 focus(`early_focuses`)는 workspace마다 마지막 하나만 남습니다. 그래서 버려진 focus의
이동은 기록되지 않고, 그 요청은 뒤의 이동이 앞 요청까지 함께 지우지 않는 한 3초 deadline까지 남습니다.

## Evidence

- **확인한 것**:
- CI(97c8660) 19개 check 모두 녹색. rust workspace lane의 nextest는 1912개 통과,
11개 skip입니다. 새 test와 바뀐 test가 모두 이 lane에서 통과했습니다.
- `view_authority_a_snapshot_read_outside_the_stream_answers_no_request`
-
`view_authority_the_screen_stays_on_the_last_request_whatever_order_herdr_answers_in`(11행)
- `view_authority_dropped_moves_fall_back_to_the_tabs_newly_active`(미답
없는 재연결은 gap 없음)
- `a_move_into_a_held_workspace_rides_on_the_publish_that_releases_it`,
`every_applied_tab_focus_is_one_move_and_the_latest_are_kept`(replica 필드
이동 뒤에도 그대로)
  - rustfmt 통과(바뀐 세 Rust 파일).
- **확인하지 못한 것**:
- 로컬 compile, clippy, test는 돌리지 않았습니다. 디스크 여유가 8GiB 아래(6.7GiB)라 이 작업 규칙상
cargo 빌드를 하지 않았고, 위 CI 결과가 유일한 확인입니다.
- 새 test가 수정 전에 실패하는지는 확인하지 않았습니다. (1)과 (2)는 #674 동작을 고정하는 test라 수정 전에도
통과해야 맞습니다. (4)의 마지막 단언만 수정 전에 실패해야 하는데, 이것은 로컬 빌드를 할 수 없어 확인하지 못했습니다.
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