Skip to content

feat(list): show PR/MR number in the CI column - #3041

Merged
max-sixty merged 7 commits into
mainfrom
ci-pr
Jun 12, 2026
Merged

max-sixty merged 7 commits into
mainfrom
ci-pr

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

The CI column in wt list --full (and the statusline) previously showed a single colored dot. It now shows the branch's open PR/MR reference — #3035 on GitHub/Gitea/Azure DevOps, !3035 on GitLab — colored by CI status, dimmed when stale, and hyperlinked to the PR. When no number is available (branch workflows without a PR/MR, pre-number cache entries, or a number wider than the allocated column), the cell shows a bare # in the same colors. Fetch errors always render ⚠, even when a number is known — Error and Conflicts share yellow, so a yellow #3035 would read as a conflicted PR.

The branch merges main's review-state feature (#3044): review colors (magenta/cyan) and draft dimming apply to the number cells exactly as they did to the dot, and the --help legend shows colored # samples for all seven states (the interim version had dropped the colored samples from the legend entirely).

The width problem

wt list renders skeleton-first: column widths are fixed before any CI data arrives, and the table never resizes mid-render. The PR number's width therefore has to be known up front. The solution is a repo-level ratchet cache (.git/wt/cache/pr-number/max.json) holding the largest PR number any fetch has seen — PR numbers are monotonic per repo, so the value needs no invalidation. Pre-skeleton, collect reads that one file and sizes the column exactly; on a cold cache the estimate is 5 chars (#9999). A number that outgrows the estimate renders as the bare # for that run and sizes correctly on the next run once the ratchet records it. The ratchet is deliberately separate from the per-branch ci-status/ entries so the width hint isn't coupled to branch-entry retention, and detect re-ratchets on cache hits too, so a deleted or racily regressed max.json heals from locally cached numbers instead of waiting out the TTL.

Reviewer's map

  • src/commands/list/ci_status/mod.rs — PrRef (number + forge sigil, PrRef::pr/PrRef::mr constructors), PrStatus.number (serde-default so pre-existing cache entries still deserialize, rendering # until their 30–60s TTL expires), format_cell width-aware renderer with the Error guard, ratchet in detect (both cache-hit and fetch paths)
  • src/commands/list/ci_status/cache.rs — MaxPrNumber ratchet (read/ratchet/clear)
  • src/commands/list/ci_status/{github,gitlab,gitea,azure}.rs — each fetcher populates the number (gh --json number, iid, Gitea number, pullRequestId); GitLab's mr-view-failure path carries the iid/URL/review state into the error status so the ⚠ stays clickable
  • src/commands/list/layout.rs, collect/mod.rs — width estimate threading
  • src/commands/list/render.rs, model/item.rs — table cell and statusline both go through format_cell
  • src/commands/list/json_output.rs — ci.number field
  • src/commands/config/state.rs — ratchet shown by state get/cache get (table + JSON) and swept with the CI cache category, including the deprecated ci-status clear --all path
  • src/md_help.rs, src/help.rs — legend colorization rules rewritten from ● to # (terminal + website)

Most of the diff is snapshot churn from the column width and glyph changes plus regenerated docs mirrors.

Known trade-offs: concurrent statusline ratchet writes can transiently lose an update (monotonic, re-learns on the next render, documented at the write site); one anomalously high PR number widens the column until wt config state cache clear; an open Azure DevOps PR still shows gray NoCI instead of its pipeline status — a pre-existing gap, now marked TODO(azure-pr-pipeline).

Testing: unit tests for format_cell (including the Error-with-number and oversized-number link cases)/pr_ref_width/ratchet/width estimates; integration coverage for all four forges with real numbers (the Gitea mocks now exercise the number path too), review-state × number composition, the GitLab mr-view-failure ⚠ and branch-pipeline success paths, cache-TTL expiry → refetch, the statusline number view, and the wt config state surfaces.

This was written by Claude Code on behalf of max

The CI column in wt list --full and the statusline now show the branch's
open PR/MR reference (#3035 on GitHub/Gitea/Azure, !3035 on GitLab),
colored by CI status and hyperlinked. Branch pipelines without a PR/MR
keep the ● indicator.

Column width is fixed at skeleton time, before CI data arrives, so a new
repo-level ratchet cache (.git/wt/cache/pr-number/max.json) stores the
largest PR number seen and sizes the column on the next run; the cold-
cache fallback is 5 chars (#9999). A number that outgrows the allocated
width renders as the dot for that run instead of resizing mid-render.

Also: ci.number in wt list --json; the ratchet is part of the CI cache
category in wt config state (get/clear, including the deprecated
ci-status clear --all path); old cache entries deserialize via
serde(default) and show dots until their TTL expires.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The CI cell now falls back to a bare # (colored by status) instead of ●
when no PR number is available — branch workflows, pre-number cache
entries, or a number wider than the allocated column. The column reads
uniformly as a PR marker. ⚠ for fetch errors is unchanged, as is stale
dimming. Docs drop the column-sizing details in favor of a one-line
fallback statement.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@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 ●→# indicator swap is clean and well-covered (tests, snapshots, and the list.md prose all updated together). One spot the diff doesn't reach: the Claude Code statusline example still shows the old ● CI glyph, which this PR removes from the rendered output.

docs/content/claude-code.md (the hand-edited source; skills/worktrunk/reference/claude-code.md mirrors it via test_docs_are_in_sync) renders the statusline as:

~/w/myproject.feature-auth  !🤖  +42 -8  ↑3  ⇡1  ●  Opus  🌔 65%  1.4×pace(10am–3pm)

After this change the CI cell never emits ● — format_cell (statusline passes usize::MAX) shows #3035 when a PR number is cached, or a bare # otherwise. Showing a PR reference there (#1234) fits the example's other concrete values and matches the feature's headline behavior.

It's outside the diff, so no inline suggestion — happy to push a one-line fix updating that glyph (and re-run the sync test) if you'd like.

max-sixty and others added 4 commits June 11, 2026 19:31
…het on cache hits

- format_cell: Error always renders ⚠, even when a PR number is known
  (Error and Conflicts share yellow; a yellow #N read as a conflict)
- gitlab: carry MR iid + web_url into the detail-fetch error status so the
  ⚠ stays clickable and the iid feeds the width ratchet
- detect(): ratchet the width hint on cache hits too, healing a deleted
  or racily regressed max.json without waiting out the TTL
- PrRef::pr()/PrRef::mr() constructors replace per-adapter sigil literals
- inline format_indicator into format_cell; fold tests
- layout: derive the cold-cache CI estimate via pr_ref_width(9999)
- gitea test mocks gain PR numbers (the Some(number) path was untested)
- azure: correct the false pipelines-fallback comment (+ TODO)
- sweep stale ●/'indicator dot' references from comments, docs, demos
- correct MaxPrNumber monotonicity claims; document the accepted race

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
# Conflicts:
#	docs/content/list.md
#	skills/worktrunk/reference/list.md
#	src/cli/mod.rs
#	src/commands/list/ci_status/azure.rs
#	src/commands/list/ci_status/gitea.rs
#	src/commands/list/ci_status/github.rs
#	src/commands/list/ci_status/gitlab.rs
#	src/commands/list/ci_status/mod.rs
#	src/commands/list/json_output.rs
#	tests/snapshots/integration__integration_tests__help__help_list_long.snap
#	tests/snapshots/integration__integration_tests__help__help_list_narrow_80.snap
…te paths

The legend rewrite had replaced the colored ● samples with bare color
words that matched no colorization rule, so wt list --help and the
website showed an uncolored legend. The legend now uses `#` samples —
matching the new cell rendering — and both help pipelines (md_help
terminal colorizer, help.rs HTML spans) recolor them; the dead
legacy ● rules are gone.

Also post-merge composition fixes: review-state mocks gain PR numbers,
the GitLab error path carries review_state, and docs mirrors regenerate.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…t-update

A future PrStatus field would silently take error()'s default through the
spread; the explicit literal forces a per-site decision.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
worktrunk-bot
worktrunk-bot previously approved these changes Jun 12, 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.

codecov/patch is red, so I'm dismissing my approval — worktrunk's CLAUDE.md treats it as a merge gate even though GitHub marks it non-required. But the gap looks like a measurement artifact rather than new untested logic, so this is likely a knowing-merge call rather than a real test to write.

The patch flags exactly five added lines, none of which are new behavior:

  • src/commands/list/ci_status/mod.rs:536–541 — the log::debug!("Cache expired …") block. It already existed on main (mod.rs#L469 at 96c3af485); the cache refactor relocated it into the cached => match arm, so codecov scores the moved lines as added even though the logic is unchanged and was equally uncovered before.
  • src/commands/list/ci_status/gitlab.rs:267 — the new number: None, field in detect_gitlab_pipeline's success-path PrStatus. That construction was already untested before this PR; only the is_retriable_error early-return path has a test (ci_status.rs:925). The field add just made the pre-existing gap visible.

The genuinely new code this PR adds — the GitLab MR-error path that now carries PrRef::mr(iid) + review_state, the format_cell Error-glyph branch, and the cache/ratchet rework — is all covered (codecov scores those lines as hits).

Happy to push a small test exercising detect_gitlab_pipeline's happy path (mock a glab pipeline response) to clear the patch bar if you'd like it formally green; otherwise this reads as safe to merge past.

@worktrunk-bot
worktrunk-bot dismissed their stale review June 12, 2026 03:12

codecov/patch is red — worktrunk CLAUDE.md gates merge on it. See my comment: the gap is a measurement artifact (relocated debug-log lines + one field in an already-untested function), not new untested logic. Re-approve/merge knowingly, or I can add a detect_gitlab_pipeline test.

codecov/patch flagged the only two uncovered slices of the patch: the
GitLab branch-pipeline success construction and the relocated cache-
expired diagnostics. The pipeline test locks in the bare-# rendering for
MR-less branches; the expiry test proves a stale entry past its TTL is
refetched rather than served (and evaluates the expiry log's format args
under RUST_LOG=debug).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@max-sixty
max-sixty merged commit c511d3f into main Jun 12, 2026
36 checks passed
@max-sixty
max-sixty deleted the ci-pr branch June 12, 2026 03:36
@max-sixty max-sixty mentioned this pull request Jun 13, 2026
max-sixty added a commit that referenced this pull request Jun 13, 2026
Release v0.58.0.

Highlights since v0.57.0:

- **Table-form `pre-*` hooks run concurrently** (#3052) — completes the
cut-over announced in v0.37.0. Breaking for configs relying on serial
ordering; pipeline form (`[[pre-merge]]`) stays serial.
- **CI column shows the PR/MR number and review state** (#3041, #3044) —
`wt list --full` and the statusline show the open PR/MR reference
colored by CI status, with review state folded in.
- **Hooks/aliases share one lazy template model** (#3042, #3047) —
templates render per-step; `{{ vars.* }}` reads fresh.
- **`wt config state cache`** (#3027) — consolidates regenerable caches;
`state clear` now confirms first.
- Statusline rate-limit display, `/wt-switch-create` optional branch
name, plugin worktree-hook hardening, and a batch of config-deprecation
and snapshot-determinism fixes.

Full notes in `CHANGELOG.md`.

The release tag is pushed to the squash-merge commit after this lands;
`release.yaml` then publishes to crates.io, Homebrew, and winget.

> _This was written by Claude Code on behalf of max_
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
worktrunk 0.58.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

- **Table-form `pre-*` hooks run concurrently**: A multi-entry table hook (`[pre-merge]` with several keys) now runs its commands concurrently, completing the cut-over announced in v0.37.0: every hook type has one execution semantic, where table form is concurrent and pipeline form (`[[pre-merge]]` blocks) is serial. Configs that need ordering should use pipeline form; affected configs have warned on every invocation since v0.37.0, with `wt config update` offering a serial-preserving migration. Two adjacent inconsistencies are also gone: `wt hook <post-type>` foreground runs of multi-entry table hooks now run concurrently like their background counterpart, and single-entry table aliases write to stdout like the other alias spellings, so `wt <alias> | …` works for that spelling too. (Breaking: multi-entry table-form `pre-*` hooks no longer run serially) ([#3052](max-sixty/worktrunk#3052))

- **CI column shows the PR/MR number and review state**: The CI column in `wt list --full` and the statusline shows the branch's open PR/MR reference (`#3041` on GitHub/Gitea/Azure DevOps, `!3041` on GitLab) instead of a plain dot: colored by CI status, hyperlinked to the PR, dimmed when stale or draft. Review state folds into the color, with magenta for changes requested and cyan for awaiting review. `wt list --format=json` gains `ci.number` and `ci.review_state`. ([#3041](max-sixty/worktrunk#3041), [#3044](max-sixty/worktrunk#3044))

- **Hook and alias templates render when each step runs**: Templates are syntax-checked before the first step runs and rendered as each step executes, so `{{ vars.* }}` always reads fresh values and hooks and aliases share one expansion model. Two consequences: a pipeline step with an undefined variable fails when that step is reached (earlier steps run first), and a template error in a background hook surfaces in the hook log rather than failing the foreground command. The background runner also labels template errors the way the foreground does. ([#3042](max-sixty/worktrunk#3042), [#3047](max-sixty/worktrunk#3047))

- **`wt config state cache`**: The regenerable caches (CI status, branch summaries, git-command caches, hints, the `wt switch -` target) are consolidated under `wt config state cache`; `cache clear` drops them all without prompting, since everything regenerates. `wt config state clear`, which also wipes hand-authored markers and vars, now asks for confirmation; `--yes` skips, and non-interactive runs without `--yes` cancel. The `ci-status`, `hints`, and `previous-branch` subcommands are deprecated but still work. ([#3027](max-sixty/worktrunk#3027))

- **Statusline rate-limit segment**: Above 90% of the binding window the segment shows the used percentage (`95%(8:30am–1:30pm)`) instead of the pace ratio; near the cap, what's left matters more than the rate. The pace form drops the word "pace" (`2.9×(Tue–Tue 5pm)`), and `-vv` logs each window's inputs and selection to `.git/wt/logs/trace.log` so the binding-window choice can be reconstructed. ([#3057](max-sixty/worktrunk#3057), [#3053](max-sixty/worktrunk#3053), [#3029](max-sixty/worktrunk#3029))

- **`/wt-switch-create` branch name is optional**: The Claude Code plugin command picks a branch name from the task when none is given, and the skill's workflow is one route (create, then enter) with an error-driven fallback instead of three guarded paths. Worktrees created mid-session persist after the session ends. ([#3058](max-sixty/worktrunk#3058))

### Fixed

- **Plugin worktree hooks fail before side effects**: The Claude Code plugin's `WorktreeCreate`/`WorktreeRemove` hooks validate the payload before running `wt`; a malformed payload previously created a branch named `null` or could remove the wrong worktree. `wt remove`'s help now documents that the positional argument accepts a worktree path as well as a branch name. ([#3058](max-sixty/worktrunk#3058), [#3060](max-sixty/worktrunk#3060))

- **Waiting-for-input marker covers questions, permission prompts, and turn end**: The Claude Code plugin sets the 💬 marker on `AskUserQuestion`, permission requests, and turn end. Previously only the `Notification` event set it, which never fires for the built-in question picker (and on some platforms not for permission prompts), so the marker stayed 🤖 while Claude waited. Part of [#2916](max-sixty/worktrunk#2916). ([#3023](max-sixty/worktrunk#3023), thanks @Ismael for reporting)

- **`wt list --help` no longer panics when piped**: With no detectable terminal width (output piped, `COLUMNS` unset), `wt list --help` panicked with a capacity overflow, and the post-commit diffstat truncated filenames to ~10 characters. Both now handle unknown width. ([#3040](max-sixty/worktrunk#3040))

- **Deprecation warnings match `wt config update`**: A config deprecation warning now fires exactly when `wt config update` would change the file. The old detection and migration logic had drifted in several places: `ff` and `no-ff` together silently dropped `no-ff`, a scalar `forge` key was overwritten by the `[ci]` migration, an empty `[ci] platform` migrated without warning, and an empty `approved-commands = []` could be removed by an unrelated update. ([#3055](max-sixty/worktrunk#3055))

- **Migrated `[forge]` keeps `[ci]`'s spot**: The `[ci]` → `[forge]` migration rendered the new section at the end of the file and could drop comments above `[ci]`; it now takes over `[ci]`'s position, comments included, so `wt config show` and `wt config update` diffs stay minimal. ([#3051](max-sixty/worktrunk#3051))

- **`wt config state get` is read-only**: The aggregate dump resolved (and re-cached) the default branch, so running it right after `clear` silently repopulated the cache, and on a cold clone it could hit the network. It now reports the cached value or `(none)`. `wt config state default-branch get` still resolves and caches. ([#3024](max-sixty/worktrunk#3024))

### Documentation

- **Reading vs resolving cached state**: `wt config state default-branch get` resolves and caches; the aggregate `wt config state get` only reports the cache. The help text and module docs now state the split. ([#3028](max-sixty/worktrunk#3028))

### Internal

- `wt switch`/`wt remove` orchestration moved from `main.rs` to their command modules, and the hook execution call chain lost two delegation layers. ([#3049](max-sixty/worktrunk#3049), [#3036](max-sixty/worktrunk#3036))

- Config deprecations are driven by a single rule table; each rule is one function that migrates and reports what it changed. ([#3045](max-sixty/worktrunk#3045), [#3055](max-sixty/worktrunk#3055))

- `terminal_width()` returns `Option<usize>` instead of a `usize::MAX` sentinel, making the no-width case a compile-time concern. ([#3043](max-sixty/worktrunk#3043))

- Snapshot tests regenerate identically across machines: host-specific paths are guarded, host-dependent env-block markers are normalized, and help snapshots share one settings builder. ([#3009](max-sixty/worktrunk#3009), [#3026](max-sixty/worktrunk#3026), [#3037](max-sixty/worktrunk#3037), [#3061](max-sixty/worktrunk#3061))

- Nightly CI runs lib tests across the full feature powerset. ([#3059](max-sixty/worktrunk#3059))

- MSRV bumped from 1.94 to 1.95. ([#2948](max-sixty/worktrunk#2948))

## Install worktrunk 0.58.0

### Install prebuilt binaries via shell script

```sh
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/max-sixty/worktrunk/releases/download/v0.58.0/worktrunk-installer.sh | sh && wt config shell install
```

### Install prebuilt binaries via powershell script

```sh
powershell -ExecutionPolicy Bypass -c "irm https://github.com/max-sixty/worktrunk/releases/download/v0.58.0/worktrunk-installer.ps1 | iex"; git-wt config shell install
```

### Install prebuilt binaries via Homebrew

```sh
brew install worktrunk && wt config shell install
```

## Download worktrunk 0.58.0

|  File  | Platform | Checksum |
|--------|----------|----------|
| [worktrunk-aarch64-apple-darwin.tar.xz](https://github.com/max-sixty/worktrunk/releases/download/v0.58.0/worktrunk-aarch64-apple-darwin.tar.xz) | Apple Silicon macOS | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.58.0/worktrunk-aarch64-apple-darwin.tar.xz.sha256) |
| [worktrunk-x86_64-apple-darwin.tar.xz](https://github.com/max-sixty/worktrunk/releases/download/v0.58.0/worktrunk-x86_64-apple-darwin.tar.xz) | Intel macOS | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.58.0/worktrunk-x86_64-apple-darwin.tar.xz.sha256) |
| [worktrunk-x86_64-pc-windows-msvc.zip](https://github.com/max-sixty/worktrunk/releases/download/v0.58.0/worktrunk-x86_64-pc-windows-msvc.zip) | x64 Windows | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.58.0/worktrunk-x86_64-pc-windows-msvc.zip.sha256) |
| [worktrunk-aarch64-unknown-linux-musl.tar.xz](https://github.com/max-sixty/worktrunk/releases/download/v0.58.0/worktrunk-aarch64-unknown-linux-musl.tar.xz) | ARM64 MUSL Linux | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.58.0/worktrunk-aarch64-unknown-linux-musl.tar.xz.sha256) |

See merge request: Harmonybrew/homebrew-core!11501
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