Repository navigation
Confirm a tab or pane focus only after it has left - #635
Merged
Merged
Conversation
A session that arrived before a queued request left was read as its answer: a queued pane focus was then never sent, leaving Herdr on another tab, and a queued tab focus Herdr reached on its own left anyway and was remembered as superseded, consuming Herdr's next real move to that tab. A focus is now confirmed only once it has left, by a session that shows it or, since Herdr publishes no event for focusing the tab it already shows, by Herdr's success answer when the last session already shows it. Refs #629
This was referenced Oct 6, 2026
yansfil
added a commit
that referenced
this pull request
Oct 6, 2026
…#667) 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`)에서 유도하도록 바꿨습니다. 순서 보장의 근거: - control lane은 Herdr가 앞 요청에 답한 뒤에만 다음 요청을 보냅니다. 그래서 Herdr는 보낸 순서대로 적용합니다. - Herdr [Socket API](https://herdr.dev/docs/socket-api/), Event subscriptions: "Lifecycle and agent-status events are drained in bounded batches, in order within each subscription." 그래서 이동 event도 그 순서로 도착합니다. 모델: - Herdr 이동(workspace에서 새로 active가 된 tab, 또는 새 focus event)은 그 tab의 가장 이른 요청에 대한 답입니다. 그보다 먼저 보낸 요청도 함께 빠집니다. - 이미 그 tab에 있던 요청은 Herdr가 event를 내지 않습니다. 그래서 답이 오면 그 자리에서 끝납니다. "이미 있던 tab"은 같은 workspace의 바로 앞 요청이고, 앞 요청이 없으면 마지막으로 읽은 Herdr입니다. - 확실한 거절은 즉시 빠집니다. 답이 유실되었거나 보고가 없는 요청은 3초 deadline까지 남습니다. 목록 상한은 16개이고, 넘치면 가장 오래된 요청을 내보내며 `tab.focus.request_evicted`를 남깁니다. - checkout에 보냈거나 lane에서 기다리는 요청이 남아 있으면 Herdr 이동을 따라가지 않습니다. 지운 규칙(모두 위 목록이 같은 답을 유도함): - #612 `await_pane_focus_tab` / `drop_pane_focus_tab_wait`: submit 전에 거는 pane focus의 tab 대기. 이제 pane focus가 lane을 떠날 때 그 tab이 목록에 들어가고(`send_pane_focus_tab`), 답이나 거절로 빠집니다. - #631 `mark_tab_focus_sent`: lane을 떠날 때 superseded로 표시하기. 목록은 보낸 요청을 모두 순서대로 갖고 있어서 따로 표시할 필요가 없습니다. - #635 보낸 요청만 session으로 확정하기, `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.rs` `reconcile_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입니다. - **비용 검토**: - session 하나당 추가 작업은 active tab 집합과 지난 집합의 비교, 그리고 16개 이하 목록 순회입니다. subprocess, I/O, 직렬화는 없습니다. - 새 timer, timeout, sleep은 없습니다. 3초 deadline과 16 상한은 그대로입니다. - **질문**: ARCHITECTURE의 역사 문장은 이슈 번호(#413, #594, #629, #635)로 적었습니다. PR 번호로 바꿀지 판단해 주세요. ## 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와 같았습니다. 수정 후에는 통과합니다. - 순서 표 test `view_authority_the_screen_stays_on_the_last_request_whatever_order_herdr_answers_in`은 6행입니다: 정순, 접힌 burst, A-B-A 접힘, 보이는 tab 재focus(event 없음), 다음 요청이 기다리는 중의 거절, deadline. 각 행의 기대값은 "마지막으로 보낸 요청의 tab"입니다. - 상한, 만료, 거절 test 이름을 `view_authority_sent_tab_moves_stop_claiming_their_tab_when_capped_expired_or_refused`로 바꿨습니다. 확실한 거절과 애매한 유실을 모두 다룹니다. - 로컬 herdr-core nextest 1551개, clippy `-D warnings`, fmt를 모두 통과했습니다. - **확인하지 못한 것**: - `web/e2e/view-bookmarks.spec.ts`는 로컬에서 돌리지 않았습니다. 디스크 여유가 부족해 hided를 다시 빌드할 수 없어서, CI web e2e에 맡깁니다. - `scripts/check-runtime-gates.sh`의 `hide-platform --test watch` 1건 실패는 이 diff가 hide-platform을 건드리지 않아서 조사하지 않았습니다.
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.
Refs #629
Related: #631
Summary
나가지 않은 tab focus나 pane focus를 session이 확정하던 core 결함을 고칩니다. #631(늦게 나간 tab focus를 superseded로 기억)과 같은 뿌리입니다.
tab_focused와pane_focused, 같은 tab 재focus는 없음),docs/ARCHITECTURE.md의 Herdr wire boundary 동작 gap에 적었습니다.docs/ARCHITECTURE.mdcontrol lane 문단에 확정 규칙과 그 이유를 더했습니다.Review
herdr-core/src/runtime/session.rsreconcile_visible_tabs,session_confirms_pending_pane- runtime mutex 안. 더한 일은sent확인뿐입니다.session.rsconfirm_tab_focus_already_shown,terminal.rspane focus 답 - failure path가 아닌 성공 답에서만,herdr_active_tab_ids조회 하나. I/O 없음.view_authority_a_late_answer_to_a_superseded_switch_is_not_followed(Typing after an Agent edge drag goes partly to the other area's pane #413): t2의 답 뒤 t1이 나가는 lane 단계를 넣었습니다.a_followed_reopen_seed_that_goes_leaves_the_operator_on_the_restored_tab(Flaky e2e: agent-tab-groups가 요청한 area에 새 탭을 붙이지 못함 (Linux) #425): Herdr가 답하지 않는 fixture라 click이 나가도록 lane을 한 칸 넘깁니다(advance_lane).Evidence
view_authority_a_pane_focus_that_has_not_left_is_not_confirmed_by_an_earlier_session: "the pane focus leaves after the tab focuses ahead of it"(수정 전 None).view_authority_a_tab_focus_that_has_not_left_is_not_confirmed_by_herdr_s_own_move: "Herdr moving to w-order:t3 on its own is followed"(수정 전 t1에 남음).view_authority_a_tab_focus_on_the_tab_herdr_shows_is_confirmed_by_its_answer: "Herdr's own move is followed at once, not after the deadline"(수정 전 t1에 남음).nextest -p herdr-core1498개 통과(Read a pane focus's late tab move as its answer #612 test 2개, Remember a tab focus that leaves after its wait was replaced #631 test 포함), clippy-D warnings, fmt, off-lock reader 검사 통과.keys.spec.ts(desktop)는 로컬에서 돌리지 않습니다. 이 PR의 CI desktop lane으로 봅니다.