Repository navigation
Read a created tab's birth cwd as its checkout in every reader until the pane settles - #449
Merged
Merged
Conversation
This was referenced Oct 5, 2026
yansfil
added a commit
that referenced
this pull request
Oct 5, 2026
…468) 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 #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 (#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 #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
added a commit
that referenced
this pull request
Oct 6, 2026
…t as the folder a created tab was born for (#573) Closes #461 Related: follows #449 and #420 ## Summary A new pane reports the cwd its shell was born in until it enters the start folder, and #449 made every reader see the folder a Hide-created tab was created for until then. This goes through the cases #449 left out of scope: each has a core test that fixes the expected behavior, and where the behavior was wrong it is fixed. | Case from #461 | Wrong today? | Result | | --- | --- | --- | | Birth cwd inside a linked worktree nested below the checkout | Yes: counted as inside the outer checkout, so the clamp ended at once | A folder in another worktree of the checkout's own repository is not the outer checkout's; the tab stays clamped until a pane reports the checkout proper | | A device's first tab of a worktree it created | Yes: not recorded, so it sat under the birth cwd's project | Recorded from the device's `worktree.create` answer, like a local one | | Device paths compared with local file system rules | Yes: a link on this machine made a device's sibling folder look like the checkout | Compared by names (`hide_platform::path::wire_relative`) | | Device acknowledgment after the session carried the tab | Yes: waited for the device's next publish | The stored session is clamped for the new record and regrouped at once | | Herdr path spelling | No | Probed against the pinned 0.9.1: a link plus trailing `/` is answered resolved, no separator; the comparison reads both sides as the folder, test pins both directions | | 30 s window on `SystemTime` | Fragile: a wall-clock step ends it early | Monotonic `birth_clock`, injected in tests; no wall-clock wait | ## Review - **판단해 주세요**: known limit, documented in `docs/ARCHITECTURE.md`: a tab born inside a nested worktree before the catalog has listed it settles at once and the latch is not undone when the list arrives, because a settled record must not hide a later `cd`. - **판단해 주세요**: a device checkout recorded through a link the device resolves does not settle by path (names only), so it is believed when the 30 s window ends and logged as `created_tab.cwd_unsettled`. I took that over the local-file-system false positives. - **조심해서 볼 파일**: - `herdr-core/src/runtime/session.rs` - runtime mutex: the checkout is read once when the tab is recorded and the catalog's worktrees once when the catalog arrives (`local_worktree_paths`); a session reads each pane cwd once and compares nested worktrees by names, so there is no lookup per nested worktree. A device acknowledgment calls `refresh_device_catalog` once when the session already has the tab. - `herdr-core/src/session_sync/coordinator.rs` - high-frequency path: only the filter type changed. - `herdr-core/src/runtime/agents.rs` is untouched; the device acknowledgment path goes through `record_created_device_tab`. - **비용 검토**: per session, clamps are built once and cost string comparisons over the owning repository's worktrees for at most 64 unsettled records, plus one file system read per pane and agent cwd of those tabs (two before). The catalog arrival reads each worktree path once. No new timers or threads. ## Evidence - **확인한 것**: - 8 new or rewritten core tests in `runtime/tests/birth_cwd.rs` and `device_catalog.rs`. On current main, 3 failed (nested worktree, device first tab, late acknowledgment); the device-path, second-acknowledgment and device-nested tests were then made to fail without their fix by mutation (clamp disabled, one record, empty nested list), and pass with it. - Herdr spelling measured on a private pinned Herdr server with an isolated HOME and socket: `workspace.create` and `tab.create` with `<link>/proj/` answered the resolved path without the trailing `/`. - `scripts/verify-cargo.sh test-scoped -p herdr-core`: 1454 passed; `clippy -p herdr-core --all-targets -D warnings` and `fmt-check` clean; workstation-identity and harness-anchor checks pass. - One code-review subagent and the lead's review: fixed a second acknowledgment settling the first tab, lookups per nested worktree under the lock, a link-spelled checkout missing its nested worktrees, other repositories counted as nested, device paths rewritten with this machine's rules, a repeated acknowledgment restarting a record, and the device window settling a tab with no pane; two weak tests were strengthened and the tests for the rest fail under a mutation of their fix. - **확인하지 못한 것**: - No native, Linux or Windows run, and no live device; device paths are covered by the core fixture and a table test of Windows-style spellings only. - What a Windows or differently cased device Herdr emits for a cwd was not observed; names compare exactly. - Whether `refresh_device_catalog` after an acknowledgment drops the request overlay `ingest_remote_session` lays (`lay_remote_requests`) was not checked; other callers share the pattern.
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.
Related: follows #420 (its "R2" list of other readers of the birth cwd); #438 and #447 are independent.
Summary
A new pane reports the cwd its shell was born in until it enters the start folder, and Herdr sends no event when that settles.
#420 stopped the tab placement from reading it for a tab Hide created.
This PR goes through the other readers in #420's list: where the birth cwd gives the operator a wrong result, every reader now sees the folder the tab was created for until a pane of it reports a cwd inside that checkout; where it does not, the reason is below.
The clamp (
clamp_created_tab_cwds) runs once on the session before anything reads it, and the coordinator applies it before it builds the catalog off the lock, so the rows, the purpose mirror, the pane'scwdand the port attribution cannot disagree.Once a pane has reported a cwd in the checkout the record is
settledand the cwd is read as reported, so a latercdout of the folder is not hidden.worktree_control.rsnew worktree's first tabworktree.create's owntab; test fails without the clampsession.rssession_spaces,pane_cwdruntime.rsproject_layout_panes(ports)device_catalog.rstab_contextreplica.rsreplace_agentsreplica.rsremote projection workspace pathsidebar.rsproject_agentlabels/worker.rsReview
CREATED_TAB_BIRTH_WINDOW_MS) is a judgment from the ~20 s measured in 새 탭을 연달아 두 번 만들면 탭 하나가 유실된다 #400; a shell that starts elsewhere on purpose is believed after it.herdr-core/src/session_sync/coordinator.rs- high-frequency path: one extrapayload.clone()only while a recorded tab is in the session and unsettled; otherwise none.herdr-core/src/runtime/session.rs- runtime mutex: the clamp is a loop over at most 64 records; no subprocess; the settled flag is read from the payload before it is clamped.herdr-core/src/runtime/agents.rs- device acknowledgements record the tab; records leave with the tab or when the device's session fails.path_is_within_checkoutstats paths (as the placement already does under the lock), so the cost is a few stats per unsettled tab in the session for at most 30 s.Evidence
runtime/tests/birth_cwd.rs(worktree first tab, no parent-folder row and purpose mirror input, no sibling listener claimed, a settled tab reads its cwd as reported) anddevice_catalog.rs(device tab stays in its folder, then follows its cwd once settled)./…/T, a row for the parent folder, a claimed listener) and the device test fails with["t1"]against["t1","t2"].scripts/verify-cargo.sh test-scoped -p herdr-core: 1377 passed;clippy -D warningsandfmt-checkclean.last_session_spaces), not the git config.agent.listreports a settled cwd for a plain pane, which would shorten how long the old behavior lasted; the fix does not depend on it.