Repository navigation
Derive tab focus authority from one list of sent, unanswered requests - #667
Merged
Merged
Conversation
A checkout's screen tab now follows one model: the tab moves hide sent to Herdr and Herdr has not answered, in send order. Herdr applies requests in the order the control lane sends them, so a Herdr move answers the earliest request on that tab and everything sent before it; a session from before an earlier request can no longer confirm a later one. Herdr's own moves are followed only with nothing outstanding. The single pending slot, the superseded list with its same-tab dedup, the sent-only session confirmation, the pane-focus tab wait armed before submit, and the supersede-on-leave rule are removed; the list derives each of their answers.
# Conflicts: # herdr-core/src/runtime.rs
yansfil
added a commit
that referenced
this pull request
Oct 7, 2026
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로 갑니다(#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을 다시 훑었습니다. - #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"로 실패합니다. #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에는 이동이 없음을 확인합니다. - #660 재현: 닫은 #673의 core test `view_authority_answers_confirmed_ahead_of_their_events_are_not_followed`(같은 순서, 옛 session 모양)를 그대로 돌린 결과: - acc8087(#667 이전): 실패. "Herdr naming w-order:t1 does not move the tab the operator chose", 화면이 t1. - main d13419b(#667): 통과. session에 replica처럼 focus event를 실어도 통과합니다. - 이 PR: 같은 순서의 표 행("a click back and a click forward each answered before the move before it") 통과. - #660 e2e(TEMP, macOS `agent-tab-groups` `--repeat-each 60 --retries 0`): #667 직전 main acc80875에서 4/60 실패(TEMP #671, run 37543522493), #667 뒤 main d13419b9에서 0/60(TEMP #676, run 37545543305). 이 PR head 18788eef를 main 5a8d59b2에 merge한 ref에서 0/60(TEMP #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 통과. 단 #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이 확인합니다.
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.
Closes #653
Related: #612, #631, #635 (같은 장치의 이전 수정, 이 PR이 대체)
Summary
view-bookmarks.spec.ts의 Agent tab View 복원이 t2, t1, t2 빠른 클릭 뒤 화면을 t1에 남기는 문제입니다.CI hided 로그(run 37508081360)의 순서는
tab.focus.late_answer->tab.focus.confirmed_by_answer->tab.focus.followed였습니다.첫 t2 클릭 시점의 session이 마지막 t2 요청의 확정으로 읽혔고, 그 뒤 도착한 t1, t2 이동이 Herdr 스스로의 이동으로 따라가졌습니다.
규칙을 하나 더 얹는 대신 checkout의 tab 권한을 "보낸 순서의 미답 tab 이동 목록" 하나(
tab_focus_requests,herdr-core/src/runtime/tab_focus.rs)에서 유도하도록 바꿨습니다.순서 보장의 근거:
모델:
tab.focus.request_evicted를 남깁니다.지운 규칙(모두 위 목록이 같은 답을 유도함):
await_pane_focus_tab/drop_pane_focus_tab_wait: submit 전에 거는 pane focus의 tab 대기. 이제 pane focus가 lane을 떠날 때 그 tab이 목록에 들어가고(send_pane_focus_tab), 답이나 거절로 빠집니다.mark_tab_focus_sent: lane을 떠날 때 superseded로 표시하기. 목록은 보낸 요청을 모두 순서대로 갖고 있어서 따로 표시할 필요가 없습니다.confirm_tab_focus_already_shown: session만으로는 아무것도 확정하지 않습니다. 이것이 이번 결함의 원인이었습니다. "이미 보이는 tab" 확정은 앞 요청이나 마지막 Herdr에서 유도합니다(settle_where_herdr_already_was).superseded_tab_focus목록과 같은 tab 중복 제거(retain): 같은 tab 요청이 둘이면 이른 것이 먼저 답을 받습니다. 중복 제거가 그 순서를 지웠습니다.pending_tab_focus슬롯,PendingViewFocus의scope_id/already_sent,await_tab_focus,supersede_tab_focus,agent_areas와 events의 pending 비우기. pane focus 슬롯(pending_pane_focus)은 pane 확정용으로 남깁니다.Review
herdr-core/src/runtime/tab_focus.rs: 새 모델 전체. runtime mutex 안에서 도는 작업이며 목록 상한은 16입니다.herdr-core/src/runtime/session.rsreconcile_visible_tabs: Herdr/core ownership 경계입니다. 따라갈지, 답으로 읽을지를 여기서 정합니다.herdr-core/src/runtime/control_lane.rs: lane을 떠나는 시점(start_job)과 보내지 않은 claim을 되돌리는 시점입니다.herdr-core/src/runtime/terminal.rs: pane focus 답과 거절이 목록에 닿는 failure path입니다.Evidence
view_authority_a_session_from_before_an_earlier_request_does_not_answer_a_later_one은 수정 전 main에서 실패했습니다(left t2, right t1). 로그 순서 late_answer -> confirmed_by_answer -> followed가 CI와 같았습니다. 수정 후에는 통과합니다.view_authority_the_screen_stays_on_the_last_request_whatever_order_herdr_answers_in은 6행입니다: 정순, 접힌 burst, A-B-A 접힘, 보이는 tab 재focus(event 없음), 다음 요청이 기다리는 중의 거절, deadline. 각 행의 기대값은 "마지막으로 보낸 요청의 tab"입니다.view_authority_sent_tab_moves_stop_claiming_their_tab_when_capped_expired_or_refused로 바꿨습니다. 확실한 거절과 애매한 유실을 모두 다룹니다.-D warnings, fmt를 모두 통과했습니다.web/e2e/view-bookmarks.spec.ts는 로컬에서 돌리지 않았습니다. 디스크 여유가 부족해 hided를 다시 빌드할 수 없어서, CI web e2e에 맡깁니다.scripts/check-runtime-gates.sh의hide-platform --test watch1건 실패는 이 diff가 hide-platform을 건드리지 않아서 조사하지 않았습니다.