fix(layout): return focus to the pane a split was opened from - #2266
Conversation
📝 WalkthroughWalkthrough
ChangesPane focus and layout operations
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Workspace
participant Tab
participant TileLayout
participant Runtime
Workspace->>Tab: Request target-based pane split
Tab->>TileLayout: Create pane near target
Tab->>Runtime: Spawn shell or argv command
Runtime-->>Tab: Return spawn result
Tab->>TileLayout: Remove pane on spawn failure
Tab->>TileLayout: Focus new pane when requested
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Greptile SummaryThe PR makes pane-close focus restoration layout-local and rewires temporary pane operations so they do not corrupt that history.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; the two previously reported focus-history corruption paths now use direct target-based mutations that preserve focus and history during background removal and failed split rollback.
|
| Filename | Overview |
|---|---|
| src/layout.rs | Adds previous-focus tracking, direct target-based tree mutations, and regression tests covering close, split, insert, resize, and rollback behavior. |
| src/workspace/tab.rs | Routes split and removal operations through non-focusing layout primitives and applies focus only after successful runtime creation. |
| src/workspace.rs | Passes split targets and focus intent directly into Tab operations instead of performing temporary focus excursions. |
| src/app/api/panes.rs | Propagates pane-move focus intent into insertion so unfocused moves preserve the destination tab’s focus history. |
Reviews (5): Last reviewed commit: "Merge branch 'master' into focus-on-clos..." | Re-trigger Greptile
3f2dcf1 to
991f29b
Compare
991f29b to
d37a70d
Compare
|
@coderabbitai full review |
✅ Action performedFull review finished. Your included review limit is currently reached under our Fair Usage Limits Policy. This review may still proceed through usage-based billing if eligible. Your next included review will be available in 38 minutes. |
Closing a focused pane handed focus to the next pane in tree order. For a pane opened beside another one -- a plugin split, a file viewer, any transient tool pane -- that is rarely where the user was: it lands on some unrelated neighbour rather than the pane that opened it. Track the pane focus came from in TileLayout and prefer it when the focused pane closes, falling back to tree order when there is no history, when it points at the pane being closed, or when it points at a pane that has since gone away. The history lives in the layout, so it can only ever name a pane in the same tab. A one-slot history is only sound if internal focus excursions never write it, so the tree edits that used to bounce focus around now go through target-taking primitives instead. close_pane removes a background pane directly, so detach_pane and take_pane_for_move stop focus-close-refocusing. split_pane splits a target without moving focus: the runtime split path only focuses the new pane once the spawn succeeds, which makes a failed split a pure rollback, and the targeted and unfocused workspace split paths stop fabricating history. insert_pane_near now takes the focus intent, so an unfocused pane move leaves the target tab's history alone. The layout-level focused-split helpers become test-only; production splits all flow through the target-taking path.
d37a70d to
6943a7f
Compare
|
@coderabbitai full review |
✅ Action performedFull review finished. Your included review limit is currently reached under our Fair Usage Limits Policy. This review may still proceed through usage-based billing if eligible. Your next included review will be available in 15 minutes. |
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 75c49ebb-4e82-42aa-a3d0-60bd2c60fc00
📒 Files selected for processing (4)
src/app/api/panes.rssrc/layout.rssrc/workspace.rssrc/workspace/tab.rs
| } | ||
| let target = self.focus; | ||
| let ids = self.pane_ids(); | ||
| let pos = ids.iter().position(|id| *id == target).unwrap(); |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Handle a stale focus without panicking.
Line 211 panics if focus is absent from the layout tree. Line 341 restores focus without validating that root contains it, so stale saved state can crash pane closing. Handle the missing position before calculating the fallback, or normalize focus in from_saved.
Proposed fix
- let pos = ids.iter().position(|id| *id == target).unwrap();
+ let Some(pos) = ids.iter().position(|id| *id == target) else {
+ return false;
+ };As per coding guidelines, “Do not use unwrap() in production Rust code.”
Also applies to: 338-343
Source: Coding guidelines
#53) * fix(windows): restore system notifications and sound playback (herdrdev#2019) * test(windows): remove flaky sound timing assertion refs herdrdev#1330 * fix: preserve windows path variables during install refs herdrdev#1947 * fix(windows): preserve parent agent ownership refs herdrdev#1514 * docs: update preview manifest * fix: scope agent skill installation refs herdrdev#2022 * ci: allow repository organization migration * chore: update repository links after organization transfer * Update rose pine surface_dim colour to "Overlay" (herdrdev#2002) Co-authored-by: Can Celik <ogulcancelik@gmail.com> * chore: finish repository organization migration * fix: preserve kitty associated text (herdrdev#2051) refs herdrdev#2020 Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com> * fix: add opt-in child-group process detection (herdrdev#2052) * fix: add opt-in child-group process detection refs herdrdev#1982 * fix: preserve lifecycle probes without foreground groups refs herdrdev#1982 * fix: launch argument-free agents on windows (herdrdev#2075) refs herdrdev#2072 * ci: consolidate ai review trigger label * fix: resume agents after headless restore (herdrdev#2088) refs herdrdev#2064 * fix(omp): support Windows session paths (herdrdev#2092) * fix: preserve windows sessions after ssh logout (herdrdev#2098) * fix: preserve windows sessions after ssh logout refs herdrdev#2008 * chore: document windows wmi safety refs herdrdev#2008 * fix(client): restore terminal on sighup and sigterm Enable termination-signal handling so SIGHUP and SIGTERM follow the graceful quit path and restore terminal state. Log handler registration failures and add PTY coverage for direct SIGHUP and server EOF restoration Co-authored-by: Matt Coles <macols@amazon.com> * fix(sidebar): keep worktree groups packed * fix: read alternate-screen agent history * chore: update agentmd for protocol changes * feat: support bottom tab bar placement (herdrdev#2118) * feat: support bottom tab bar placement * fix: preserve mouse cleanup under bottom mode bar refs herdrdev#2117 * chore: remove experiments from settings tui * fix(input): preserve native key lifecycle across routing (herdrdev#2142) refs herdrdev#2077 Co-authored-by: Jonathan Liebig <jonathan.liebig@gmail.com> * fix(windows): preserve semantic escape key taps * fix: report a clear cli error when no herdr server is running (herdrdev#1963) * fix: report a clear cli error when no herdr server is running socket cli commands surfaced a raw io::Error debug string (`Error: Os { code: 2, ... }`) when nothing was listening on the api socket, which read like a bad --cwd path. map dead-socket connect failures to a `server_not_running` json error carrying the resolved socket path, printed once at the edge that surfaces the error; recovering callers (plugin offline registry fallback, agent start polling) recognize the marker and keep their existing behavior. refs herdrdev#1941 * fix: map dead-socket errors on the unchecked cli request path refs herdrdev#1941 * fix: make server-not-running guidance session-aware refs herdrdev#1941 * fix: expand copy-mode word-end window past a final wide glyph (herdrdev#2145) point_is_final_atom compared an atom's terminating column against a word-motion target's starting column. The two are equal for narrow cells but never for wide ones, so the read window stopped expanding and copy-mode `e` halted at the soft-wrap boundary on CJK text. Co-authored-by: Can Celik <ogulcancelik@gmail.com> * feat(ui): make pane scrollbars optional (herdrdev#2166) refs herdrdev#2167 * fix(ci): skip pr gate in forks * feat: add antigravity-cli integration (herdrdev#2087) * feat: add antigravity_cli integration harness Register the `antigravity_cli` target, resolve its configuration directory to `~/.gemini/antigravity-cli/`, wire target actions, and add lifecycle hook scripts for Unix and Windows. * feat: support session resume for antigravity-cli * fix: correct antigravity-cli hook config path, shape, and agent label Antigravity CLI reads global customizations from ~/.gemini/config, keys hooks.json by hook name, and only accepts the matcher/hooks wrapper for the tool events. The previous install wrote event arrays at the top level of ~/.gemini/antigravity-cli/hooks.json, which agy never reads and would reject anyway, so no Herdr hook ever ran. Session reports were dropped for a third reason: the hooks reported the agent as antigravity-cli, but the server normalizes that to the canonical label agy before matching, so is_official_agent_source never matched and agy --conversation resume was unreachable. - Resolve the config dir to ~/.gemini/config - Nest Herdr entries under a Herdr-owned "herdr" block that install rewrites and uninstall removes, leaving other named hooks untouched - Emit grouped entries for PreToolUse/PostToolUse and flat handler lists for PreInvocation/PostInvocation/Stop - Report the canonical agy label from both hook assets and match it in agent_resume - Compile-gate the hook asset constants and stop shadowing $args in the PowerShell hook - Document the real directory, that it must already exist, and the named-block behavior refs herdrdev#1011 refs herdrdev#1571 * fix: make antigravity-cli integration session-only antigravity cli cannot express lifecycle safely: there is no blocked event, postinvocation is skipped on interruption, and stop fires at the end of a turn rather than on process exit, which left stale state and released authority at the wrong time. report only the conversation on preinvocation and let screen detection own agent state. resume via `agy --conversation <id>` is unchanged. * fix: update antigravity session after conversation switch --------- Co-authored-by: Can Celik <ogulcancelik@gmail.com> * fix(input): decode 0x1f as Ctrl+_ not Ctrl+- per ASCII standard (herdrdev#2165) * fix(input): decode 0x1f as Ctrl+_ not Ctrl+- per ASCII standard refs herdrdev#2164 * fix(input): update control-byte matrix test for 0x1f -> Ctrl+_ * fix(socket_paths): remove dead if-branch in derive_client_socket_from_api_socket (herdrdev#2157) * fix(windows): detect agents across git bash exec boundaries (herdrdev#2170) refs herdrdev#2107 * fix: route vscode remote copies through osc52 (herdrdev#2173) refs herdrdev#2015 Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com> * fix(detect): recognize opencode2 as opencode refs herdrdev#2169 * fix: stop advertising worktree json flag (herdrdev#2174) refs herdrdev#2171 Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com> * fix: preserve claude settings formatting (herdrdev#2089) refs herdrdev#2066 Co-authored-by: Ogulcan Celik <ogulcancelik@gmail.com> * fix(client): query host cell size when the ioctl reports no pixels (herdrdev#2160) * fix(cli): report non-UTF-8 arguments instead of panicking (herdrdev#2207) * fix(cli): report non-UTF-8 arguments instead of panicking * fix(cli): avoid echoing malformed arguments --------- Co-authored-by: Ogulcan Celik <ogulcancelik@gmail.com> * fix: avoid blocking on foreground cwd checks (herdrdev#2213) refs herdrdev#2206 * fix(docs): publish only released documentation * fix(docs): support older git in snapshot checks * fix(input): preserve hover during extended-button drags * fix: propagate host color scheme to pane apps (herdrdev#2214) refs herdrdev#714 * fix(pi): restrict state reporting to tui sessions (herdrdev#2159) Co-authored-by: Can Celik <ogulcancelik@gmail.com> * fix: page keys scroll pane scrollback at zsh and REPL prompts (herdrdev#2191) * fix: page keys scroll pane scrollback at zsh and REPL prompts PageUp/PageDown were forwarded to the pane whenever DECCKM (application cursor) was on, assuming only primary-screen pagers enable it, but zsh's line editor also enables DECCKM, as do REPLs such as python3. The result was PageUp scrolling shell history instead of Herdr scrollback. Bracketed paste discriminates the two: it means the app accepts typed or pasted text at a prompt, so line editors enable it and pagers do not. * test: update page key state fixture --------- Co-authored-by: Can Celik <ogulcancelik@gmail.com> * feat(website): rebuild marketing pages on new brand chassis * docs: finalize 0.8.0 release documentation * release: v0.8.0 * docs: update website manifest for v0.8.0 * docs: refine cpu optimization blog post * fix(ui): keep collapsed workspace status visible (herdrdev#2239) refs herdrdev#2216 Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com> Co-authored-by: Can Celik <ogulcancelik@gmail.com> * docs: publish preview documentation * feat(plugins): index marketplace manifests * fix(docs): allow corrections to published versions refs herdrdev#916 * fix(input): preserve shift-tab in pane automation (herdrdev#2259) refs herdrdev#1561 * fix(ui): preserve sidebar scroll across clients (herdrdev#2280) refs herdrdev#2255 Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com> * fix(website): copy heading links to clipboard * fix: detect claude confirmation prompts refs herdrdev#2268 * feat(ui): add distinct status indicators (herdrdev#2282) refs herdrdev#2260 * fix(input): keep pending url clicks across host focus loss (herdrdev#2291) Opening a URL raises the browser, which takes focus away from the host terminal before the mouse release arrives. release_input_source(_headless) cleared pending_url_click_sources on that focus loss, so the release was forwarded to the pane and the agent opened the same URL again. Clear the set in clear_input_source instead, whose only production caller is remove_client. refs herdrdev#2290 Co-authored-by: kataokatsuki <kataokatsuki@users.noreply.github.com> * fix(cli): resolve pane query --current from caller (herdrdev#2298) refs herdrdev#2297 Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com> * fix(input): parse default mouse reports (herdrdev#2312) * fix(input): parse default mouse reports refs herdrdev#2309 * fix(input): preserve split default mouse reports refs herdrdev#2309 --------- Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com> Co-authored-by: Can Celik <ogulcancelik@gmail.com> * fix(ui): search single-tab names in navigator (herdrdev#2320) * fix(layout): return focus to the pane a split was opened from (herdrdev#2266) Closing a focused pane handed focus to the next pane in tree order. For a pane opened beside another one -- a plugin split, a file viewer, any transient tool pane -- that is rarely where the user was: it lands on some unrelated neighbour rather than the pane that opened it. Track the pane focus came from in TileLayout and prefer it when the focused pane closes, falling back to tree order when there is no history, when it points at the pane being closed, or when it points at a pane that has since gone away. The history lives in the layout, so it can only ever name a pane in the same tab. A one-slot history is only sound if internal focus excursions never write it, so the tree edits that used to bounce focus around now go through target-taking primitives instead. close_pane removes a background pane directly, so detach_pane and take_pane_for_move stop focus-close-refocusing. split_pane splits a target without moving focus: the runtime split path only focuses the new pane once the spawn succeeds, which makes a failed split a pure rollback, and the targeted and unfocused workspace split paths stop fabricating history. insert_pane_near now takes the focus intent, so an unfocused pane move leaves the target tab's history alone. The layout-level focused-split helpers become test-only; production splits all flow through the target-taking path. Co-authored-by: Can Celik <ogulcancelik@gmail.com> * fix(terminal): render halfwidth katakana voiced marks (herdrdev#2257) Co-authored-by: oyoguhito <oyoguhito@kamatanoMacBook-Pro.local> Co-authored-by: Can Celik <ogulcancelik@gmail.com> * fix(ci): make issue gate structural * fix(input): preserve modifyOtherKeys key releases (herdrdev#2303) refs herdrdev#2302 Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com> Co-authored-by: Can Celik <ogulcancelik@gmail.com> * fix(config): accept retired agent panel scope (herdrdev#2295) refs herdrdev#2292 Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com> Co-authored-by: Can Celik <ogulcancelik@gmail.com> * feat(theme): add optional sidebar background * docs: refresh readme and sponsors * test(graphics): pin the shrinking-cell symptom against upstream's fix Upstream's cell-size fix prefers the ioctl whenever it reports any nonzero pixels, so a stale SSH ws_xpixel is still divided by a growing column count. HostCellSize::is_plausible is what keeps that off the card path. The sweep covers the widths the defect was measured at and states the bound it does not claim: a stale pty at a low column count is still believed. Also corrects the AGENTS.md cell-size principle, which named the retired HOST_CELL_SIZE_QUERY_SEQUENCE, and records the state-alphabet dispatch. * no-mistakes(review): clamp client cell size at ingress and address review findings * no-mistakes(review): floor sidebar ink separately from shared palette tokens * no-mistakes(review): cache the sidebar palette per frame * no-mistakes(review): resolve sidebar animation ink against the panel's own fill * no-mistakes(review): route every sidebar ground through one panel-fill helper * no-mistakes(document): document sidebar panel-fill palette floor, fix clippy clone-on-copy * no-mistakes: apply CI fixes --------- Co-authored-by: Can Celik <ogulcancelik@gmail.com> Co-authored-by: kangal-bot <285672167+kangal-bot@users.noreply.github.com> Co-authored-by: Bradley <67018167+brabli@users.noreply.github.com> Co-authored-by: akbash <akbash@herdr.dev> Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com> Co-authored-by: Wiedzmin <56316383+art-wiedzmin@users.noreply.github.com> Co-authored-by: Matt Coles <mattjcoles@outlook.com> Co-authored-by: Matt Coles <macols@amazon.com> Co-authored-by: Jonathan Liebig <jonathan.liebig@gmail.com> Co-authored-by: Season Saw <season.saw@gmail.com> Co-authored-by: Akira TSURUDA <jas39.gripen@gmail.com> Co-authored-by: Ludovico Magnocavallo <ludo@qix.it> Co-authored-by: serhat dolmaci <srhtsrht17@gmail.com> Co-authored-by: WakaTaira <50697207+WakaTaira@users.noreply.github.com> Co-authored-by: Florian <13469873+VialFlorian@users.noreply.github.com> Co-authored-by: Rhys <105699450+rhjoh@users.noreply.github.com> Co-authored-by: Michael Hackner <mhackner@gmail.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Kataoka Katsuki <49934462+kataokatsuki@users.noreply.github.com> Co-authored-by: kataokatsuki <kataokatsuki@users.noreply.github.com> Co-authored-by: Jon Kinney <jonkinney@gmail.com> Co-authored-by: Kazunari Kamata <14287197+kazunari-kamata@users.noreply.github.com> Co-authored-by: oyoguhito <oyoguhito@kamatanoMacBook-Pro.local> Co-authored-by: Bchue <bchue@homeserver.tail25a02d.ts.net>
* fix: preserve claude settings formatting (herdrdev#2089) refs herdrdev#2066 Co-authored-by: Ogulcan Celik <ogulcancelik@gmail.com> * fix(client): query host cell size when the ioctl reports no pixels (herdrdev#2160) * fix(cli): report non-UTF-8 arguments instead of panicking (herdrdev#2207) * fix(cli): report non-UTF-8 arguments instead of panicking * fix(cli): avoid echoing malformed arguments --------- Co-authored-by: Ogulcan Celik <ogulcancelik@gmail.com> * fix: avoid blocking on foreground cwd checks (herdrdev#2213) refs herdrdev#2206 * fix(docs): publish only released documentation * fix(docs): support older git in snapshot checks * fix(input): preserve hover during extended-button drags * fix: propagate host color scheme to pane apps (herdrdev#2214) refs herdrdev#714 * fix(pi): restrict state reporting to tui sessions (herdrdev#2159) Co-authored-by: Can Celik <ogulcancelik@gmail.com> * fix: page keys scroll pane scrollback at zsh and REPL prompts (herdrdev#2191) * fix: page keys scroll pane scrollback at zsh and REPL prompts PageUp/PageDown were forwarded to the pane whenever DECCKM (application cursor) was on, assuming only primary-screen pagers enable it, but zsh's line editor also enables DECCKM, as do REPLs such as python3. The result was PageUp scrolling shell history instead of Herdr scrollback. Bracketed paste discriminates the two: it means the app accepts typed or pasted text at a prompt, so line editors enable it and pagers do not. * test: update page key state fixture --------- Co-authored-by: Can Celik <ogulcancelik@gmail.com> * feat(website): rebuild marketing pages on new brand chassis * docs: finalize 0.8.0 release documentation * release: v0.8.0 * docs: update website manifest for v0.8.0 * docs: refine cpu optimization blog post * fix(ui): keep collapsed workspace status visible (herdrdev#2239) refs herdrdev#2216 Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com> Co-authored-by: Can Celik <ogulcancelik@gmail.com> * docs: publish preview documentation * feat(plugins): index marketplace manifests * fix(docs): allow corrections to published versions refs herdrdev#916 * fix(input): preserve shift-tab in pane automation (herdrdev#2259) refs herdrdev#1561 * fix(ui): preserve sidebar scroll across clients (herdrdev#2280) refs herdrdev#2255 Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com> * fix(website): copy heading links to clipboard * fix: detect claude confirmation prompts refs herdrdev#2268 * feat(ui): add distinct status indicators (herdrdev#2282) refs herdrdev#2260 * fix(input): keep pending url clicks across host focus loss (herdrdev#2291) Opening a URL raises the browser, which takes focus away from the host terminal before the mouse release arrives. release_input_source(_headless) cleared pending_url_click_sources on that focus loss, so the release was forwarded to the pane and the agent opened the same URL again. Clear the set in clear_input_source instead, whose only production caller is remove_client. refs herdrdev#2290 Co-authored-by: kataokatsuki <kataokatsuki@users.noreply.github.com> * fix(cli): resolve pane query --current from caller (herdrdev#2298) refs herdrdev#2297 Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com> * fix(input): parse default mouse reports (herdrdev#2312) * fix(input): parse default mouse reports refs herdrdev#2309 * fix(input): preserve split default mouse reports refs herdrdev#2309 --------- Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com> Co-authored-by: Can Celik <ogulcancelik@gmail.com> * fix(ui): search single-tab names in navigator (herdrdev#2320) * fix(layout): return focus to the pane a split was opened from (herdrdev#2266) Closing a focused pane handed focus to the next pane in tree order. For a pane opened beside another one -- a plugin split, a file viewer, any transient tool pane -- that is rarely where the user was: it lands on some unrelated neighbour rather than the pane that opened it. Track the pane focus came from in TileLayout and prefer it when the focused pane closes, falling back to tree order when there is no history, when it points at the pane being closed, or when it points at a pane that has since gone away. The history lives in the layout, so it can only ever name a pane in the same tab. A one-slot history is only sound if internal focus excursions never write it, so the tree edits that used to bounce focus around now go through target-taking primitives instead. close_pane removes a background pane directly, so detach_pane and take_pane_for_move stop focus-close-refocusing. split_pane splits a target without moving focus: the runtime split path only focuses the new pane once the spawn succeeds, which makes a failed split a pure rollback, and the targeted and unfocused workspace split paths stop fabricating history. insert_pane_near now takes the focus intent, so an unfocused pane move leaves the target tab's history alone. The layout-level focused-split helpers become test-only; production splits all flow through the target-taking path. Co-authored-by: Can Celik <ogulcancelik@gmail.com> * fix(terminal): render halfwidth katakana voiced marks (herdrdev#2257) Co-authored-by: oyoguhito <oyoguhito@kamatanoMacBook-Pro.local> Co-authored-by: Can Celik <ogulcancelik@gmail.com> * fix(ci): make issue gate structural * fix(input): preserve modifyOtherKeys key releases (herdrdev#2303) refs herdrdev#2302 Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com> Co-authored-by: Can Celik <ogulcancelik@gmail.com> * fix(config): accept retired agent panel scope (herdrdev#2295) refs herdrdev#2292 Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com> Co-authored-by: Can Celik <ogulcancelik@gmail.com> * feat(theme): add optional sidebar background * docs: refresh readme and sponsors * chore: remove project-local worktree extension refs herdrdev#2325 * fix(website): update author X profile * chore: keep fork docs release metadata at 0.7.5 The upstream merge advanced docs/versions/manifest.json to the snapshot stable source with current 0.8.0 and coupled website/latest.json to the v0.8.0 release. Our fork has no v0.8.0 release tag, so the Website workflow's published-documentation validator failed resolving v0.8.0^{commit}, and manifest.current no longer matched latest.json. Revert both release-metadata files to the pre-merge 0.7.5 legacy state so the fork advertises only releases it actually publishes. This needs no v0.8.0 tag and fires no release workflow. All other upstream merge content, including the docs/versions/0.8.0 snapshot tree, is left intact. * chore: pin fork stable docs snapshot to 0.7.5 The pure legacy-metadata revert could not build: the upstream merge also deleted the committed legacy stable docs source tree (website/src/content/docs and website/src/data/config-reference.json), so docs-versions legacy mode has no source to render and the astro build fails resolving config-reference.json. Keep upstream's snapshot docs machinery but pin current to 0.7.5, the newest release the fork actually publishes. The 0.7.5 entry gains snapshot provenance from the existing v0.7.5 tag (commit ef4c23f) and its committed docs/versions/0.7.5 snapshot tree. This needs no v0.8.0 tag and fires no release workflow, and website/latest.json already advertises 0.7.5, so the manifest current and latest version stay consistent. Validated end to end: docs-versions check, docs-preview check, prepare-docs in published and draft modes, a full astro build (946 pages), and check-built-docs all pass locally. --------- Co-authored-by: akbash <akbash@herdr.dev> Co-authored-by: Ogulcan Celik <ogulcancelik@gmail.com> Co-authored-by: WakaTaira <50697207+WakaTaira@users.noreply.github.com> Co-authored-by: Florian <13469873+VialFlorian@users.noreply.github.com> Co-authored-by: Rhys <105699450+rhjoh@users.noreply.github.com> Co-authored-by: Michael Hackner <mhackner@gmail.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com> Co-authored-by: kangal-bot <285672167+kangal-bot@users.noreply.github.com> Co-authored-by: Kataoka Katsuki <49934462+kataokatsuki@users.noreply.github.com> Co-authored-by: kataokatsuki <kataokatsuki@users.noreply.github.com> Co-authored-by: Jon Kinney <jonkinney@gmail.com> Co-authored-by: Kazunari Kamata <14287197+kazunari-kamata@users.noreply.github.com> Co-authored-by: oyoguhito <oyoguhito@kamatanoMacBook-Pro.local>
Current behavior
Closing a focused pane moves focus to the next pane in tree order:
pane_ids()is a depth-first walk of the BSP tree, so the pane that gets focus has no spatial or temporal relationship to where I was. When I open a split beside the pane I'm working in and then close it, focus lands on some unrelated pane rather than the one I opened it from.Reproduction
Focus goes to whichever pane follows it in the tree, not the pane the split was opened from.
Expected
Focus returns to the pane it came from. herdr already models this elsewhere: it tracks the previous focus and exposes it as
last_pane. The close path just doesn't consult it.The change
TileLayoutrecords the pane focus came from, andclose_focusedprefers it. It falls back to the existing tree-order behavior when there is no history, when the history names the pane being closed, or when it names a pane that has since gone away. The history lives inTileLayoutrather than reusingAppState::previous_pane_focus, because that one can name a pane in another workspace or tab — closing a pane could then throw focus out of the current tab. A layout is per-tab, so that can't happen here.A one-slot history is only sound if internal focus excursions never write it, and review (thanks, Greptile) showed the codebase had several focus-then-restore dances that would corrupt it: removing a background pane, rolling back a failed split, the targeted / unfocused workspace split, and the
focus: falsepane move. Rather than patch each site, those edits now go through target-taking primitives that don't move focus at all:close_pane(id)removes a background pane directly;detach_paneandtake_pane_for_movestop focus-close-refocusing.split_pane(target, ...)splits without focusing. The runtime split path focuses the new pane only after the spawn succeeds, so a failed split is a pure rollback, and targeted / unfocused splits stop fabricating history.insert_pane_neartakes the focus intent, so an unfocused pane move leaves the target tab's history alone.The invariant is documented on the field: only a real focus move writes
prev_focus. Fallout: the layout-levelsplit_focused*helpers are now#[cfg(test)](production splits all flow throughTab, which owns spawn-failure rollback), and threeTabsplit wrappers that lost their last caller are removed.resize_paneswaps focus via direct field writes for its measurement and so never records history.Tests
Eleven cases in
src/layout.rspin the behavior: returning to the previous pane and to the opener of a split; tree-order fallback with no history, spent history, or a removed remembered pane; and one per excursion — background close keeps the focused pane's history, a failed-split rollback preserves it, an unfocused insert and a targetedsplit_paneleave focus and history untouched, and resize does not disturb the target. The excursion tests are constructed so tree order and the expected pane differ, so each fails against the focus-dance code.The existing
api_pane_move_existing_tab_no_focus_preserves_previous_target_focuscharacterization test pins the API-visible behavior of the rewired move path.cargo fmt --checkclean, no compiler warnings in either build. Full suite locally: 2935 passing; the only failures are pre-existing environment-dependent git tests that fail identically on unmodified master on my machine.On classification
I've filed this as a fix because the current target looks like a traversal artifact rather than an intended interaction — nothing picks that pane, it's just where the depth-first walk lands. If you read it as a behavior change instead, say so and I'll move it to a Discussion.