Skip to content

feat(switch): restyle the pr preview pane — flush description, cyan field labels - #3195

Merged
max-sixty merged 6 commits into
mainfrom
pr-preview-trim-body
Jun 25, 2026
Merged

max-sixty merged 6 commits into
mainfrom
pr-preview-trim-body

Conversation

@max-sixty

@max-sixty max-sixty commented Jun 24, 2026 •

Copy link
Copy Markdown
Owner

The pr preview pane (both the worktree row's pr tab and the --prs rows — they share pr_pane) got two presentation fixes: the description renders flush instead of quoted in the house gutter, and every field is labelled in the app's cyan all-caps title style.

Flush description

description no longer wraps the body in format_with_gutter. Prose, headers, and lists already render flush through the markdown renderer; the one place a gutter remained was fenced code blocks, which the shared md_help renderer always quotes in the bar (so a body with a ``` block — test plans, examples — kept a column-2 indent). So this adds md_help::render_markdown_flush: a sibling of `render_markdown_in_help_with_width` that renders fenced code blocks dim and flush instead of in the gutter, leaving the gutter rendering used by `--help` pages and the `summary` tab untouched.

The result: the whole body renders flush at column 0 — headers, prose, lists, and code blocks alike. Empty/whitespace bodies still render nothing; markdown styling (bold, dim code) is preserved.

before (gutter)              after (flush)
▌ Summary                    Summary
▌ Run it with:               Run it with:
▌   wt switch --create foo     wt switch --create foo   ← code block also flush

markdown_in_gutter stays — the --prs comments pane still uses it, where the gutter sets each comment's body off from its author/timestamp header.

Cyan all-caps field labels

Every label in the pane now goes through one shared field_label helper that renders the app's cyan all-caps title style via format_heading — the same convention as wt config show, wt step (PROMPT/COMMAND/MESSAGE), DEFAULT BRANCH, etc. So BRANCH / URL / AUTHOR are provably identical to each other and to the section headings elsewhere in the CLI, and the description block gains a DESCRIPTION heading over its flush body (blank line between).

#3195  feat(switch): render the pr description flush, not in a gutter
BRANCH        pr-preview-trim-body
URL           https://github.com/max-sixty/worktrunk/pull/3195

DESCRIPTION

The pr preview pane (both the worktree row's pr tab and the --prs rows…

Testing

pr_pane/items/prs unit tests pin the contract: the description renders with no gutter bar (\x1b[107m), the whole body survives (no truncation), a fenced code block lands flush at column 0, and a cyan DESCRIPTION label (\x1b[36m) heads the block over a blank line — absent when the body is empty. The md_help gutter-mode tests (help/summary) are unchanged and still pass. Full project gate (hook pre-merge) green: 4200 tests pass. Verified end-to-end in the live wt switch --remotes --prs picker.

This was written by Claude Code on behalf of max

The `pr` preview pane rendered a PR/MR's entire body as markdown in the
house gutter, and the pane scrolled through long ones. That's too much
for a gutter preview — the body is the canonical copy on the forge, and
the pane already shows the `url` one line above.

`description` now keeps the first six rendered gutter rows and closes a
trimmed body with a dim `…` (the picker's truncation marker); a short
body still renders whole, and an empty one still renders nothing. The cut
bounds the rendered height rather than the source, so it lands on
gutter-row boundaries (each self-closes with `\x1b[0m`, no style bleeds
past) and also caps a long single-paragraph body that arrives as one
soft-wrapped source line. Comments are unaffected — `render_comment_blocks`
calls `markdown_in_gutter` directly, not `description`.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trimming logic reads cleanly and the docstring is accurate — both panes render a url metadata line above the description (items.rs, prs.rs), so "the url line reads the rest" holds, and … matches the picker's existing truncation marker. Tests pass locally.

One gap blocks the gate: codecov/patch fails on the trailing-blank-pop loop —

while kept.last().is_some_and(|r| r.ansi_strip().trim().is_empty()) {
    kept.pop();
}

The 3 uncovered lines are kept.pop() and its braces. description_trims_a_long_body feeds 50 single-line list items, so every kept row is non-blank and the loop never runs. The loop only fires when the row at the budget boundary is blank — which happens for paragraph-style bodies, where the markdown render alternates content/blank gutter rows.

I verified a regression test that exercises it (it fails if the pop loop is removed, since the … would then trail a blank gutter bar):

#[test]
fn description_trim_drops_a_trailing_blank_before_the_marker() {
    use ansi_str::AnsiStr;
    // Paragraphs separated by blank lines render as alternating content/blank
    // gutter rows, so the row at the budget boundary is blank. The `…` marker
    // must not trail an empty gutter bar — the blank is popped first.
    let body = (0..7)
        .map(|i| format!("para{i}"))
        .collect::<Vec<_>>()
        .join("\n\n");
    let out = description(&body, 80);
    assert!(out.contains('…'), "truncation marker: {out:?}");
    let rows: Vec<&str> = out.trim_end().lines().collect();
    let marker_idx = rows
        .iter()
        .position(|r| r.ansi_strip().trim().ends_with('…'))
        .expect("marker present");
    // The row immediately above the marker is real content, not a blank bar.
    assert!(
        !rows[marker_idx - 1].ansi_strip().trim().is_empty(),
        "no blank gutter bar above the marker: {out:?}"
    );
}

Want me to push this as a commit on the branch? Holding off on approval until codecov/patch is green.

Reverses the trimming approach: the gutter (the bg-color bar quoting each
line), not the length, was what made the pane feel heavy. The whole body
stays — the forge is the canonical copy, but a preview that scrolls the
full description is wanted — it just renders flush as markdown now, the
way the `summary` tab already does, wrapping at the pane width.

`description` drops `format_with_gutter` and renders the body directly via
`render_markdown_in_help_with_width` at full width (no 2-column gutter
overhead). Empty bodies still render nothing; markdown styling is
preserved. `markdown_in_gutter` stays for the `--prs` comments pane, where
the gutter still sets each comment's body off from its author header.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@max-sixty max-sixty changed the title feat(switch): trim the pr preview description to a short excerpt feat(switch): render the pr preview description flush, not in a gutter Jun 24, 2026
The prose was flush, but fenced code blocks in a body still rendered
quoted in the house gutter — `md_help`'s shared renderer wraps every code
block in the bar, so a body with a ``` block (common: test plans,
examples) kept a column-2 indent. That mixed alignment was the remaining
indentation.

Adds `md_help::render_markdown_flush`, a sibling of
`render_markdown_in_help_with_width` that renders fenced code blocks dim
and flush (no gutter, no language-specific highlighting) while leaving the
gutter rendering — used by `--help` pages and the `summary` tab —
untouched. The `pr` description now renders the whole body flush-left:
headers, prose, lists, and code blocks all at column 0.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@max-sixty max-sixty changed the title feat(switch): render the pr preview description flush, not in a gutter feat(switch): render the pr description flush, not in a gutter Jun 24, 2026

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test (windows) fails to compile on this commit — a real regression, not a flake:

error: function `render_markdown_flush` is never used
error: could not compile `worktrunk` (bin "wt") due to 1 previous error

The whole commands::picker module is #[cfg(unix)] (src/commands/mod.rs), so its only caller of render_markdown_flush — pr_pane::description — isn't compiled on Windows. But render_markdown_flush lives in the un-gated md_help.rs, so on Windows it has zero callers and trips dead_code under -D warnings. (render_markdown_in_help_with_width is fine — it has a cross-platform caller in src/help.rs.)

Gating the helper to match its only caller fixes it, consistent with the existing #[cfg(unix)] // Only used by picker module which is unix-only annotations elsewhere (e.g. src/commands/list/layout.rs). The shared private render_markdown stays cross-platform, and CodeBlocks::Flush is still referenced in its == comparison so it won't itself go dead (verified with a standalone -D warnings compile).

Comment thread src/md_help.rs Resolved
Route every pr-pane label (BRANCH/URL/AUTHOR/DESCRIPTION) through a shared
field_label helper that renders the app's cyan all-caps title style via
format_heading, so the pane matches the section headings across the CLI
(wt config show, wt step, …). The description block gains a DESCRIPTION
heading over its flush body, separated by a blank line.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@max-sixty max-sixty changed the title feat(switch): render the pr description flush, not in a gutter feat(switch): restyle the pr preview pane — flush description, cyan field labels Jun 25, 2026

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test (linux) fails on this commit (also code-coverage and affected tests; macOS is still running but will hit the same case) — commands::picker::items::tests::worktree_pr_pane_shows_comment_count:

comments line with count: "#7  Fix the flaky retry\n\nBRANCH   feature\nURL      https://github.com/o/r/pull/7\nCOMMENTS 3\n"

The cyan all-caps relabel routes every metadata label through field_label, which uppercases — so render_worktree_pr now emits COMMENTS, but this test still asserts the old lowercase comments. The two adjacent panes (preview_assembles_tab_bar_and_pr_pane, the prs.rs pane test) were updated for the new style; this one was missed. Both assertions in the test need the uppercased label:

// A PR with comments adds a `COMMENTS` metadata line carrying the count.
assert!(
    with.lines().any(|l| l.contains("COMMENTS") && l.contains('3')),
    "comments line with count: {with:?}"
);
// …
assert!(
    !without.contains("COMMENTS"),
    "no comments line when absent: {without:?}"
);

The negative case (!without.contains("comments")) passes today only by accident — no other label happens to contain the substring — so it should move to COMMENTS too, otherwise it stops guarding anything. The other comments assertions in items.rs (~1159–1186) are a different rendering and stay as-is.

Want me to push this fix to the branch? It's two lines.

…TS label

Merging main brought #3197's worktree comment-count line and its test, which
asserted the old lowercase `comments N`. Now that every pr-pane label renders
cyan all-caps via field_label, the line reads `COMMENTS N`; update the test's
expectation to match.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit d81ed36 into main Jun 25, 2026
36 checks passed
@max-sixty
max-sixty deleted the pr-preview-trim-body branch June 25, 2026 04:35
max-sixty added a commit that referenced this pull request Jun 25, 2026
…ne (#3231)

Follow-up to #3195. The `pr` preview pane's metadata values rendered
plain after their cyan labels; this gives the two most identifier-like
values the app's own conventions.

- **Branch name → bold** — the convention for branch identifiers across
the CLI (`git`/error messages, the branch summary in `src/summary.rs`).
- **URL → underlined** — the inline-link convention used by hints and
the fork-push notice.

Both panes — the worktree row (`render_worktree_pr`) and the `--prs` row
(`PrSkimItem`) — now route branch/url through shared
`pr_pane::branch_line` / `url_line` helpers, so the styling can't drift
between them. The author handle and comment count stay plain, the draft
state stays yellow, and the header reference stays bold.

Each styled value closes with a full `\x1b[0m` because skim's ANSI
parser drops the SGR 22/24/39 that color_print's `</>` emits — the same
pattern the existing `draft` value and `field_label` already use.
Verified live in the picker that skim renders both the bold branch and
the underlined URL on the real pane.

Also fixes two stale docstrings: a "dim-labeled" reference left from the
cyan-label change in #3195, and a `branch_line` doc that cited a
non-existent `wt summary` command.

> _This was written by Claude Code on behalf of max_

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
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