Repository navigation
Description
Follow-up to #1818.
Current behavior
An explicit pane swap preserves herdr's focused pane by snapshotting focus, running the native swap, then restoring only after a real change if focus still belongs to the swapped source. Ovis serializes its focus-changing calls per socket, so a newer Ovis focus choice runs after restoration. Restore failures are logged without failing an already committed swap.
The browser retains its request-only movingHerdrFocus guard. With Follow herdr focus enabled:
- A focus event arriving while a swap is pending can be ignored, including a legitimate same-PC choice.
- A restore event arriving after the reply can still move the browser to the restored pane.
These limitations are deliberately left visible rather than risking the loss of genuine focus events through an exact-event filter that cannot identify its target.
Why a client-only filter is insufficient
Six ordering failure cases were found while attempting held-event replay, pane-name restore tokens, expiry bounds, overlapping requests, and per-request event boundaries. A server-stamped sequence also cannot identify the restore reliably: native herdr focus events carry no RPC correlation, and an older unread source/restore pair can look like the current swap's events.
Root fix
Prefer upstream support for an explicit pane.swap with focus:false, so the swap never changes focus and needs no restoration. Alternatively, expose a correlated event identifier or request identifier upstream that proves which focus event a restore produced.
Do not infer identity from pane names, arrival timing, sleeps, or a presumed-empty event backlog.
Acceptance
- Swapping preserves native and browser pane/tab/workspace selection without a temporary focus move, or suppresses only a provably correlated restore event.
- Genuine same-PC focus events are delivered in order, including during overlapping swaps and after an HTTP reply.
- Both event-before-answer and event-after-answer orderings are covered deterministically.
- A missed event, disconnect, or delayed reply never causes a later genuine same-pane event to be dropped.
- The native TUI's own focus changes are not overwritten by an Ovis check/restore window; a no-focus native swap should eliminate that window entirely.
Activity
devswha commentedon Oct 29, 2026
Re-checked on
origin/main@ cbe3436 against herdr 0.9.5 (latest stable, protocol 22; newest preview is 2026-10-14). Still blocked on upstream, so this stays open.What I tried (isolated herdr: its own
XDG_CONFIG_HOMEin a mkdtemp dir and its own session, never the live one):pane.swap {source_pane_id: B, target_pane_id: C}. herdr moves its focus to the source (A → B) and emitspane_focused {pane_id: B}.focus: false. herdr 0.9.5 accepts the request but ignores the parameter, so focus still moves to B.paneSwapWith(B, C). The restore works (herdr ends on A), but the subscription sees two frames,pane_focused Bthenpane_focused A. Each frame carries onlytype,pane_idandworkspace_id, with no request or correlation id. These are the framesserver/collector.ts(parseFocusFrame→onFocus) relays to the browser, so the restore event still cannot be told apart from a genuine focus change.Upstream source (herdrdev/herdr
master@ ee5bfb5, 2026-10-29):PaneSwapParams(src/api/schema/panes.rs) still has onlypane_id,direction,source_pane_idandtarget_pane_id.handle_pane_swap(src/app/api/panes.rs) callstab.layout.focus_pane(source_pane_id)andrecord_pane_focus_changeunconditionally on every swap. ThePaneFocusedevent is still{pane_id, workspace_id}. By contrast,pane.movealready has afocusflag. I found no upstream issue asking for a no-focuspane.swapor for correlated focus events.So the root fix described above (native
pane.swap focus:false, or a correlated event id) is still unavailable. Nothing changed on the Ovis side either: the restore path and themovingHerdrFocusguard are as DESIGN.md describes.Repro script (run from an Ovis checkout:
XDG_CONFIG_HOME=$(mktemp -d) bun repro-1950.ts "$PWD")Output
devswha commentedon Oct 30, 2026
Filed upstream as herdrdev/herdr#5677:
pane.swapignoresfocus: false, and the restore emits apane_focusedwith no correlation id. It includes a standalone repro (re-run today on herdr 0.9.5). This stays blocked on that.devswha commentedon Nov 4, 2026
Re-checked on
origin/main@ 7a923ab against herdr 0.9.5 (still the latest stable; upstreammasteris still ee5bfb5). Same isolated repro as above (ownXDG_CONFIG_HOMEin a mkdtemp dir, own session):Upstream closed herdrdev/herdr#5677 on 2026-10-30 as a feature request (a focus-preserving swap or correlated focus events would extend the API). So neither root fix in this issue is available, and the issue itself rules out a client-only filter. No Ovis change is made for now.
devswha commentedon Nov 4, 2026
Closing as a known limit: herdr reports no request id on the two focus events of a focus-preserving swap, so the restore event can't be told apart without guessing, which this issue rules out. Repro is in the comment above.