Skip to content

wt switch picker panics with exit 101 when a diff preview exceeds 65,535 lines (skim total_lines is u16) #3958

Description

@sandertammesoo

Summary

wt switch (interactive picker) panics and exits 101 a few seconds after it opens, whenever a branch's diff preview is longer than 65,535 lines.

thread 'main' panicked at .../skim-5.6.5/src/tui/preview.rs:229:56:
called `Result::unwrap()` on an `Err` value: TryFromIntError(PosOverflow)

The preview loads asynchronously, so the picker paints normally first and dies 3-5 seconds later. On screen the panic is overwritten by the shell prompt almost immediately, which makes it look like the picker just closes by itself. No diagnostic.md is written, because the process aborts rather than returning an error.

Cause

skim 5.6.5 stores the preview line count in a u16:

// skim/src/tui/preview.rs:229
self.total_lines = text.lines.len().try_into().unwrap();

Any preview over 65,535 lines panics. wt switch's diff preview passes the full git diff <default>...<branch> output, so this is reachable on any long-lived branch.

Reproduction

In a repo where a branch diffs more than 65,535 lines against the default branch:

$ wt switch          # picker opens, then dies ~3-5s later
$ echo $?
101

Line counts in the repo where I hit it:

branch git diff master...<branch> lines picker
A 126,021 panics
B 106,009 panics
C 99,758 panics

A second repo whose largest branch diff is 39,547 lines never panics — consistent with the 65,535 boundary.

Not a pager issue: --config-set 'switch.picker.pager = "cat"' panics identically, so it is the raw line count rather than anything delta emits.

Workaround

Capping the pager output keeps the picker alive (verified running 90+ seconds with previews rendering):

[switch.picker]
pager = "delta --paging=never | head -n 20000"

Possible fixes

  • Truncate preview content in worktrunk before handing it to skim, so a large diff renders a capped preview instead of aborting the process.
  • Upstream: skim could clamp or widen total_lines instead of unwrap()-ing the conversion. I found no existing issue for this in skim-rs/skim.

Environment

  • worktrunk v0.75.0 (Homebrew bottle, which vendors skim 5.6.5)
  • macOS 26.4, Apple Silicon
  • zsh, TERM=xterm-256color, run inside a terminal multiplexer (herdr) under WezTerm

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions