Skip to content

fix(switch): suppress skim's alt-l/alt-h horizontal scroll in the picker - #3226

Merged
max-sixty merged 1 commit into
mainfrom
picker-alt-l-gutter
Jun 25, 2026
Merged

max-sixty merged 1 commit into
mainfrom
picker-alt-l-gutter

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

What

alt-l (and its mirror alt-h) horizontally scrolled the wt switch picker's list, sliding each row left under the fixed cursor gutter and clipping the leading worktree-status sigil (@/^/+/⊂) and the branch name — with no ellipsis to mark the cut. This binds both keys to skim's ignore no-op so the carefully laid-out table stops sliding.

Why it happened

The picker never bound alt-l/alt-h, so they fell through to skim 4.8's default keymap, where they map to ScrollRight(1) / ScrollLeft(1). Those actions mutate skim's manual_hscroll offset. no_hscroll(true) (added in #3213 specifically to keep the sigil gutter stable) only zeros the automatic, match-following shift — calc_hscroll_for_width still adds manual_hscroll on top, so the manual-scroll keys escaped the guard entirely.

Two visible symptoms, both reproduced live in a real picker:

  • One alt-l press shifts every row's content left by a column; the leading sigil scrolls off and one extra char appears on the right. Repeated presses chew further into the branch name (picker-alt-l-gutter → er-alt-l-gutter). The skim > cursor lives in a separate prefix gutter that is not scrolled, so it visibly detaches from the content it normally sits beside.
  • manual_hscroll is an i32 clamped to >= 0 only at render time (.max(0)), not at the state level, so alt-h drives it negative. After scrolling back you must "pay off" that negative backlog with alt-l before scrolling resumes — the keys feel unresponsive.

Fix

"alt-h:ignore".to_string(),
"alt-l:ignore".to_string(),

alt-h/alt-l are the only default keys that produce ScrollLeft/ScrollRight, and skim's query word-navigation uses alt-b/alt-f/alt-d instead — so suppressing these two fully closes the manual-hscroll path with no collateral to query editing. The preview-tab keys (alt-1…alt-7, Tab) are unaffected (verified live).

This is the manual-scroll counterpart to #3213's no_hscroll(true); that PR closed the automatic path, this one closes the manual path the same guard left open.

Testing

Adds test_switch_picker_alt_l_does_not_hscroll, a PTY test that drives alt-l/alt-l/alt-h and snapshots the list with its gutter sigils intact. Verified the test fails when the fix is removed (the @/+ sigils clip: > @ main → > main) and passes with it. Full pre-merge gate green (4199 tests, all lints, --features shell-integration-tests).

This was written by Claude Code on behalf of max

alt-l and alt-h were never bound by the picker, so they fell through to
skim's default keymap, where they map to ScrollRight(1)/ScrollLeft(1).
Those actions push skim's `manual_hscroll` offset, which `no_hscroll(true)`
does not gate — it only zeros the automatic match-following shift. The
result: pressing alt-l slid every row's `display()` left under the fixed
2-column cursor gutter, clipping the leading worktree-status sigil
(@/^/+/⊂) and the branch name, with no ellipsis. alt-h scrolled it back,
but its offset goes negative (clamped to >=0 only at render), so the keys
felt unresponsive after a few presses.

The row table is laid out to fit the pane; there is nothing to scroll to.
Bind both keys to skim's `ignore` no-op. Adds a PTY regression test that
drives alt-l/alt-h and snapshots the list with its gutter intact.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@max-sixty
max-sixty merged commit 7ac7656 into main Jun 25, 2026
37 checks passed
@max-sixty
max-sixty deleted the picker-alt-l-gutter branch June 25, 2026 04:40
max-sixty added a commit that referenced this pull request Jun 25, 2026
`switch_picker_alt_l_ignored_list` (added by #3226) recorded `…main↕ CI Age`,
inconsistent with its sibling `switch_picker_multiple_worktrees_list`
(`…main↕ Remote⇅ CI`) — even though the alt-l test binds alt-l/alt-h to ignore
and asserts it captures "the same frame `test_switch_picker_with_multiple_worktrees`
snapshots." The render has since settled on the sibling-consistent frame (the
Remote⇅ column), but #3226's snapshot was never regenerated, so it fails on
current main HEAD too (verified by building origin/main and running the test —
same `Remote⇅ CI` diff). This is a pre-existing stale snapshot surfaced by
merging main, not a regression from this branch.

Regenerate it to match the current frame, which is byte-identical to the
multiple-worktrees frame as the test intends.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
max-sixty added a commit that referenced this pull request Jun 25, 2026
…3227)

Follow-up to #3226. The picker list gained a `Remote⇅` column and
dropped `Age` (from concurrent picker work) in the window between when
`test_switch_picker_alt_l_does_not_hscroll`'s snapshot was generated and
when #3226 merged. Both PRs were green independently, but main ended up
with the new columns plus the old-column snapshot, so the test fails on
main.

This regenerates the snapshot for the current layout. The assertion is
unchanged in spirit — the worktree-status gutter sigils (`@`/`+`) stay
intact after `alt-l`/`alt-h`, proving the keys still don't horizontally
scroll the list; only the surrounding column header/data moved.

> _This was written by Claude Code on behalf of max_

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
max-sixty added a commit that referenced this pull request Jun 25, 2026
The merge of main left switch_picker_alt_l_ignored_list.snap showing the
old Age column while every sibling picker snapshot already renders the
Remote⇅ column. The snapshot (added in #3226) missed the Remote-column
regeneration; main pushes don't run the full suite, so it slipped in stale
and now fails `test (linux)` on any PR that merges with main. Regenerated
to match the intended rendering — unrelated to this PR's statusline change,
but it blocks CI.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
max-sixty added a commit that referenced this pull request Jun 25, 2026
…rity (#3229)

The statusline pace segment (the rate-limit warning, e.g.
`1.4×(10am–3pm)`) was a flat yellow whenever it showed. This grades its
color by how bad the projected hit actually is, deepening dim →
dim-yellow → yellow.

## Two axes, separated

The segment already gated its appearance on **confidence** — `P(over)`,
the Bayesian probability of crossing the cap before the window resets.
But `P(over)` saturates near 1, so it can't also grade *severity*: a
near-certain cross in the last hour and one halfway through the week
both read ≈1.

Color is now driven by a second metric, **`expected_lockout`**: the
expected fraction of the window that will be spent throttled, integrated
over the posterior on the consumption rate (7-point Gauss–Hermite). It
keeps discriminating after `P(over)` has flat-lined, and degrades to ~0
on thin early-window bursts — so a 5× burst on Monday doesn't light up
the segment. The displayed number stays the raw `u/t` pace; only the
color carries the Bayesian severity.

## Per-window thresholds from duration, not magic numbers

The same lockout *fraction* costs very different real time across
windows: 0.30 of the 5-hour window is 90 min, 0.30 of the weekly window
is ~2 days. So `colorize_pace` compares a **duration-weighted cost** `=
lockout · √(window / 5h)` against one shared cutoff pair, rather than
two hand-tuned per-window pairs. The 5-hour window keeps its existing
calibration (weight 1); the weekly window is sensitized ~5.8×,
escalating on real time forfeited. Duration drives this (known exactly,
33.6× apart) — not σ, which is only 1.17× apart and already folded into
the posterior integral.

## Reviewing

Start at `src/commands/statusline.rs`: `expected_lockout` (the severity
metric + its module-header rationale), `lockout_cost` (the √-duration
weighting), and `colorize_pace`. The `-vv` trace now logs `lockout` and
the weighted `cost` for future threshold tuning.

Well-covered: the metric (bounds/monotonicity), the color tiers, the
cross-window weighting, and the refactor's behavioral equivalence of
`p_over` are all unit-tested; the 5-hour window is unchanged (snapshots
confirm). The threshold anchors (dim-yellow 0.10, yellow 0.30, exponent
0.5) are feel-calibrated and meant to be tuned from real traces.

## Note: included an unrelated CI fix

Merging main surfaced a pre-existing failure in `test (linux)`:
`switch_picker_alt_l_ignored_list.snap` was left stale by the #3226
merge race (it still rendered the old `Age` column while every sibling
picker snapshot already shows `Remote⇅`). Main pushes don't run the full
suite, so it slipped in and blocks any PR that merges with main. This PR
regenerates that one snapshot — it's unrelated to the statusline change
but required to get CI green.

> _This was written by Claude Code on behalf of max_

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
worktrunk 0.62.0

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre>## Release Notes

### Improved

- **Browse open PRs/MRs in the `wt switch` picker, with live CI**: The picker now streams a live CI/review-status column per row — priming from the local cache, then fetching live (it previously showed only cached numbers with no network). A new `--prs` flag adds the repository's open PRs (GitHub) / MRs (GitLab) as rows alongside your worktrees, each with `pr` / `comments` / `log` preview tabs loaded from the forge in the background; selecting one fetches its branch and switches. Rows whose branch is already shown aren't duplicated, so `--prs` differs from plain `wt switch` only by the extra rows. [Docs](https://worktrunk.dev/switch/) ([#3128](max-sixty/worktrunk#3128), [#3169](max-sixty/worktrunk#3169), [#3189](max-sixty/worktrunk#3189), [#3252](max-sixty/worktrunk#3252))

- **`main…±` diff column shows by default in `wt list`**: The `main…±` column (lines changed since the merge-base with the default branch) now renders in the default `wt list` and picker, served from a persistent cache rather than a history walk. `--full` now adds only the columns that reach off-machine — CI status and LLM branch summaries — and `wt list --format=json` populates `main.diff` for every item, not just under `--full`. ([#3236](max-sixty/worktrunk#3236))

- **`[list] columns` selects and orders the columns `wt list` shows**: A new `[list] columns` user-config key (also settable via `--config-set`) takes an ordered array of column names — built-in (`branch`, `status`, `ci`, `path`, …) and `[list.custom-columns]` headers alike — and renders exactly those, in that order. Where v0.61.0's custom columns *add* columns, this *selects and reorders* the whole set; omit the key for the default layout. (`WORKTRUNK__LIST__COLUMNS` isn't supported yet and warns if set.) ([#3141](max-sixty/worktrunk#3141))

- **Picker PR preview shows full PR/MR detail**: The `pr` tab now renders the PR/MR title, markdown description, author, draft state, comment count, bold branch name, and underlined URL for any row whose branch has an open PR — not just `--prs` rows — and the `comments` tab fetches the real thread. The title and description ride the CI fetch the picker already makes; the comment thread is fetched lazily in the background, once per row. ([#3167](max-sixty/worktrunk#3167), [#3197](max-sixty/worktrunk#3197), [#3223](max-sixty/worktrunk#3223), [#3195](max-sixty/worktrunk#3195), [#3231](max-sixty/worktrunk#3231))

- **Interactive picker runs on Windows**: The `wt switch` picker was Unix-only because its preview-tab keys shelled out through a per-process state file `cmd.exe` lacks; tab state moved to an in-memory atomic with native skim callbacks, lifting the platform gate. ([#3217](max-sixty/worktrunk#3217))

- **Picker keyboard shortcuts**: `Alt-y` copies the selected branch name, `Alt-o` opens the row's PR/MR in the browser, and `Alt-r` refreshes the list (picking up worktrees created or removed elsewhere). (Breaking: in the picker, remove moved from `Alt-r` to `Alt-x`) ([#3233](max-sixty/worktrunk#3233))

- **Picker uses the full terminal**: List height scales with the terminal (a roughly even split with the preview, minimum 3 rows) instead of a fixed 12-row cap, the table lays out at full width so toggling the preview off with `Alt-p` reveals the freed columns with no reflow, and a scrollbar appears when the list overflows. ([#3205](max-sixty/worktrunk#3205), [#3214](max-sixty/worktrunk#3214), [#3198](max-sixty/worktrunk#3198))

- **Picker filters on more of each row**: Typing a gutter sigil filters by row kind (`+` for linked worktrees, `@` for the current one), the fuzzy matcher ranks on the distinguishing path segment rather than the shared parent prefix, and rows with a PR/MR also match on its number, title, and author. ([#3143](max-sixty/worktrunk#3143), [#3208](max-sixty/worktrunk#3208), [#3252](max-sixty/worktrunk#3252))

- **Picker visual polish**: The legend recolored to dim-cyan and reordered so navigation leads, and preview loading placeholders moved to the dim-hint style (`↳` transient, `○` settled, `▲` failed). ([#3237](max-sixty/worktrunk#3237), [#3253](max-sixty/worktrunk#3253))

- **"Still waiting" status for slow commit-message generation**: A configured `commit.generation` command captures stdout, so a slow or hung LLM previously showed nothing while `wt step commit`/`squash` waited. After a 2s delay worktrunk now shows a dim, in-place `○ Waiting for the commit message (Ns)` status, escalating at 10s to reveal the exact shell-escaped invocation in a gutter beneath it; the block clears on completion, mirroring `wt list`'s stall footer. ([#3178](max-sixty/worktrunk#3178))

- **"Still waiting" status extended to more slow commands**: The same waiting status now covers three more foreground commands that were silent while a captured subprocess ran — the `wt config show --full` commit-generation self-test, the `wt switch pr:`/`mr:` host lookup, and the `wt config show --full` version check. The version check no longer caps its fetch at an aggressive 5s, instead showing the status while a slow-but-working request completes (with a generous ceiling so a non-interactive run can't hang). ([#3183](max-sixty/worktrunk#3183))

- **`wt config state logs profile` performance profiler**: A new subcommand turns a `-vv` `[wt-trace]` capture (a path argument, `-` for stdin, or the default `trace.log`) into a performance profile: subprocess time by command shape, the slowest calls, parallelism and peak concurrency, redundant cache-miss re-runs, and — for `wt list`/picker captures — derived latencies and a collect timeline. `--format=json` emits the same data, and every `-vv` bug-report bundle now inlines a rendered profile. ([#3184](max-sixty/worktrunk#3184), [#3186](max-sixty/worktrunk#3186))

- **`WORKTRUNK_VERBOSE` env var**: `WORKTRUNK_VERBOSE=0|1|2` mirrors `-v`/`-vv`, combined with any flag via `max` (the env sets a floor the flag can raise). Unlike the flags it's honored on the shell-completion path, which returns before flag parsing — so a slow tab-completion can be profiled for the first time. ([#3166](max-sixty/worktrunk#3166))

- **Aliases inherit the wrapped command's completion**: An alias that forwards `{{ args }}` to a single `wt` command (`co = "wt switch {{ args }}"`) now completes that command's arguments and flags — `wt co <Tab>` completes branches like `wt switch <Tab>` — instead of a generic stub. Bare dispatchers and multi-`{{ args }}` aliases keep the stub. ([#3172](max-sixty/worktrunk#3172), thanks @yzx9)

- **`wt step copy-ignored --require-include`**: A new `--require-include` flag makes the copy a no-op unless a `.worktreeinclude` file exists in the source worktree (matching Claude Code desktop, where that file is required), reporting why it skipped as a hint in text mode and a `reason` field in `--format=json`. ([#3196](max-sixty/worktrunk#3196), thanks @yzx9)

- **`wt step tether` honors `-C`**: The global `-C <path>` flag now sets the tethered command's working directory (`wt step tether -C frontend -- npm run dev`); teardown still watches the worktree root, so the command is reaped when the worktree is removed. ([#3207](max-sixty/worktrunk#3207))

- **Statusline rate-limit pace color grades by severity**: The pace segment's color now deepens (dim → dim-yellow → yellow) with the projected throttling severity, so an early-window burst stays muted while a costly projected lockout stands out. The displayed pace number is unchanged. ([#3229](max-sixty/worktrunk#3229))

### Fixed

- **Picker `Alt-x` removal updates the row in place**: Removing a worktree no longer re-collects the whole list (a flicker that reset the cursor to the top): an unmerged worktree's row morphs into a branch-only row while the worktree is removed in the background, and a merged worktree's row drops with the cursor landing on the row that slid up. A removal that can't safely happen — the current or main worktree, or a dirty or locked one — is declined with the same diagnostic `wt remove` prints, rather than a dead keypress or a disruptive `cd` home. The post-removal cursor lands by row identity, so it stays correct even under an active filter. ([#3262](max-sixty/worktrunk#3262), [#3199](max-sixty/worktrunk#3199), [#3211](max-sixty/worktrunk#3211), [#3225](max-sixty/worktrunk#3225))

- **Picker preview refreshes when its background fetch lands**: A diff/log/PR-view fetch that completed after its triggering keystroke used to sit unshown until the next keypress; the pane now updates on its own when the fetch lands. ([#3247](max-sixty/worktrunk#3247))

- **Picker rows stay aligned while filtering**: Typing a filter no longer slides the matched row left and drops its leading sigil, and `Alt-l`/`Alt-h` no longer scroll the list off its gutter. ([#3213](max-sixty/worktrunk#3213), [#3226](max-sixty/worktrunk#3226))

- **fish completions no longer recurse to the call-stack limit**: With worktrunk's fish lazy-load wrapper installed, co

See merge request: Harmonybrew/homebrew-core!12862
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants