Repository navigation
perf(list): plan background tasks from the columns being rendered - #3274
Conversation
worktrunk-bot
left a comment
There was a problem hiding this comment.
The column→task mapping is solid — I traced ColumnKind::Status's 11 required tasks against refresh_status_symbols (the five gates plus the four check_integration_state signals) and they match exactly, and the two drift guards (requires_task superset + full-TaskKind union) pin it against future drift. Nice.
One correctness gap: the prune also fires on the JSON path, which silently nulls fields the docs promise --format json always emits. Detail inline.
`[list] columns` filtered only at the layout layer: a narrowed selection hid columns but still ran every per-worktree git task (status, diffs, ahead/behind, merge probes), then discarded the results. On many dirty worktrees that is the bulk of the wall-clock cost (#3133). Map each column to the tasks it consumes (`ColumnKind::required_tasks`), and when `columns` names an explicit subset, add every task no selected column needs to the collect skip set. The Status column aggregates almost all status-feeding tasks; identity columns (branch, path, commit, age, message) and custom columns need none, so a branch/path-only view now runs no `git status`, diffs, or ahead/behind walks. Additive only: it never un-skips a task gated off elsewhere (`--full`, missing template/LLM), matching the layout's "select narrows, never forces" rule. The picker is exempt — it fetches CI/PR data for its preview panes regardless of which columns render. Closes #3133 Co-Authored-By: Claude Opus 4.8 <[email protected]>
28ca0f4 to
c718104
Compare
`wt list --format json` flows through `collect()` with no progressive handler, so the column→task prune fired on it too — silently dropping `working_tree`/`main`/`main_state` from JSON whenever `[list] columns` named a subset. That breaks the documented contract (`after_long_help`): `--format json` ignores the selection and always emits every field. Gate the prune on `render_table` so only the rendered table (progressive or buffered) prunes; JSON keeps running every task. The picker stays exempt via the existing `progressive_handler.is_none()` clause. Adds `test_list_json_ignores_columns_selection`: a narrowed selection must emit the same `working_tree` field JSON as the default set. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…note The `[list] columns` "narrows the work" note added to dev/config.example.toml is embedded into `wt config create` via include_str!, but the rendered help snapshot wasn't regenerated. Sync it. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
|
||
| Narrowing the selection also narrows the work: `wt list` skips the git commands | ||
| that feed only hidden columns, so a branch/path-only view runs no `git status`, | ||
| diffs, or ahead/behind walks. A minimal `ls`-style alias stays fast across many |
There was a problem hiding this comment.
cut verbosity by 30-50% please
There was a problem hiding this comment.
Tightened ~36% in src/cli/mod.rs (the help-page source) — dropped the ls-alias example and trimmed the picker caveat to one clause. Regenerated the config.md mirrors and the help_config_long snapshot. Pushed in c7abe6a.
Cut the paragraph ~36% per review feedback, dropping the ls-alias example and trimming the picker caveat. Regenerates the config help page mirrors and the help_config_long snapshot. Co-Authored-By: Claude Opus 4.8 <[email protected]>
The same columns-narrow-work paragraph is mirrored as a comment in dev/config.example.toml; tighten it to match and regenerate the help_config_create snapshot. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Replace the scattered `skip_tasks` denylist with a single stage that derives the task set from the columns the table will render: the union of each rendered column's `required_tasks()`, gated by `column_renders` (`--full`, `[list] summary` + `[commit.generation]`, a url template). `effective_skip_tasks` is now just that set's complement, so the spawn loop fires exactly the tasks some rendered column needs. This collapses four separate skip mutations — the `--full` base set, the `UrlStatus` and `SummaryGenerate` inserts, and the selection prune — into one union-and-invert, and unifies the two column->task maps: `ColumnSpec::requires_task` is deleted and the layout visibility filter now reads the same `required_tasks()` via `ColumnKind::renders_given_skipped`. The maps can no longer drift, so the reconciliation test is gone (it is now unrepresentable); the `cover_every_task` drift guard stays and gains teeth, since an unconsumed task would never run rather than merely be computed and discarded. The picker joins the model instead of carrying a bespoke empty skip set: `ShowConfig::Resolved` carries `show_full` (forced true for the picker) and the picker feeds `all_columns`, ignoring the column selection for tasks because its preview tabs need the full data set. JSON likewise takes the full set. The resulting skip set is identical to the previous behavior across default/selection x full/non-full x table/JSON/picker, so no snapshots move. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…n set Follow-on to the planning cutover: the plan now flows through the whole pipeline as a positive set of tasks to run, derived from the columns each caller renders — no skip-list, no inversion, no blanket default. - `CollectOptions.skip_tasks` -> `tasks` (the run set). `collect` threads the planned `needed_tasks` straight into `max_pr_number`, the layout, and the options; the `TaskKind::iter().filter(!contains)` complement is gone. - Consumers flip to membership checks: the two `execution.rs` spawn loops, the `include_url` gate, and the layout's visibility filter (`renders_given_skipped` -> `renders_given_run`) and `data_flags`. - `CollectOptions` has no blanket `Default`. The new `for_columns(columns, gates)` constructor derives `tasks` via `required_tasks_for_render`; nothing hand-writes a task set. The statusline declares what it renders (the full column set under full gates, no LLM summary) instead of leaning on a "default everything". `all_tasks()` is now test-only. - Drop the per-item `SummaryGenerate && llm_command.is_none()` spawn guard. The column plan is the single authority on whether Summary runs, and `SummaryGenerateTask` already returns a clean error on a missing command, so the guard was redundant in production and only reachable via a contrived gates/command mismatch. Behaviour is unchanged across default/selection x full/non-full x table/JSON/ picker/statusline; the full pre-merge gate (incl. PTY picker snapshots) is green. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
worktrunk-bot
left a comment
There was a problem hiding this comment.
The positive-task-plan refactor reads cleanly — the column→task map with its two drift guards (test_required_tasks_cover_every_task pinning the exact union, plus renders_given_run reading the same map that chose the plan) makes the spawn-loop/layout-filter agreement structural rather than a thing to keep in sync by hand. The JSON exemption (render_table && progressive_handler.is_none()) and its regression test land the prior review's concern.
One stale docstring from an earlier shape of the refactor: required_tasks_for_render still says collect inverts the result into a skip set, but the whole point of this PR is that it no longer does — collect stores the positive set on CollectOptions::tasks and both consumers read it directly. Inline suggestion to match the code.
The docstring still described the pre-refactor skip-set inversion. collect stores the positive task set directly on CollectOptions::tasks; the spawn loops and layout filter consume it as-is. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…wing note
List `[list] columns`'s valid built-in names as a bulleted list with a one-line
gloss each (and the table header for the cryptic diff columns: `HEAD±`, `main↕`,
`main…±`), replacing the inline comma-separated sentence. Remove the "Narrowing
the selection narrows the work" paragraph — it restated what is now obvious from
the column-driven task planning.
Regenerated the mirrors and help snapshots from the src/cli/mod.rs source:
config.example.toml, docs/content/config.md, skills/worktrunk/reference/config.md,
and help_config_{long,create}.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
worktrunk-bot
left a comment
There was a problem hiding this comment.
The bulleted column list reads well, and I spot-checked the glosses against the code: status matches (ColumnKind::Status pulls TaskKind::UserMarker, so "plus any user-defined status" is right), and the three diff headers (HEAD±, main↕, main…±) line up with the canonical table further up in this same after_long_help.
One inaccuracy: upstream renders ahead/behind counts under the Remote⇅ header (ColumnKind::Upstream → render_diff_cell(active.ahead, active.behind)), not the tracking-branch name. The canonical table in this file already calls it "Commits ahead/behind tracking branch". The current gloss "The upstream tracking branch" reads as if the column shows origin/feature. Suggestion inline; mirrors (config.md, dev/config.example.toml) and the help snapshots regenerate from this source.
The `upstream` column (header `Remote⇅`) renders commits ahead of and behind the upstream tracking branch — `format_diff_plain(active.ahead, active.behind)`, matching the canonical "Commits ahead/behind tracking branch" row in the same help — not the tracking branch name. Correct the bullet gloss accordingly and regenerate the mirrors and help snapshots. Addresses the auto-reviewer's feedback on this PR. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Cut the `[list] columns` prose roughly a third per review feedback: fold the alias intent and static-config tradeoff into two sentences, drop the "intended use" framing, compress the custom-column/exhaustive/collision notes, and state the gate condition once. Every behavioral fact (alias-driven views, exhaustive selection, header collisions, the gutter indicator, gated columns, and the table/picker/JSON split) stays; the bulleted name list is unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
worktrunk 0.63.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 - **`[list] columns` can force a column on past `--full`**: Listing a column now overrides the `--full` / `[list] summary` presets — `columns = ["branch", "ci"]` shows the CI column without `--full`. Hard data-source prerequisites still apply: a listed `summary` with no `[commit.generation]` command, or `url` with no template, stays hidden, since listing can't conjure data that isn't configured. ([#3295](max-sixty/worktrunk#3295)) - **`Alt-r` in the picker refreshes the preview panes, not just the rows**: `Alt-r` re-collected the rows but kept serving cached preview content, so editing a tracked file and refreshing still showed the pre-edit diff. It now clears the preview cache too, recomputing the working-tree / log / branch-diff / upstream / summary tabs and re-fetching `pr` / `comments`. Unchanged branches re-read from the content-keyed on-disk cache, so only genuinely changed content pays a recompute. ([#3293](max-sixty/worktrunk#3293)) - **A narrowed `wt list` is now actually faster**: A narrowed `[list] columns` selection (e.g. `["branch", "path"]`) now runs only the git work its columns need. It previously ran every per-worktree `git status`, diff, and ahead/behind walk regardless, then discarded the unselected results — so a trimmed view was no faster than the full table, and on a repo with many dirty worktrees that discarded work was the bulk of the wall-clock cost. ([#3274](max-sixty/worktrunk#3274), thanks @jtaby for reporting) - **Fewer duplicate git calls in `wt list --full`**: The two integration probes per row (the conflict bit for `main-state` and the clean-merge tree for the integration column) issued a byte-identical `git merge-tree`, and the shared default-branch tip was peeled to its tree once per row. Both are now deduplicated through the in-memory cache, so each resolves once per run instead of once per worktree. ([#3288](max-sixty/worktrunk#3288), [#3289](max-sixty/worktrunk#3289)) - **Picker `comments` tab avoids redundant forge fetches**: The picker's `comments` preview tab gained an on-disk cache keyed by the PR's `updatedAt` (which rides for free on the CI fetch the picker already makes), so a repeat `wt switch` skips the per-row `gh pr view --json comments` fetch when the thread is unchanged and paints the tab instantly instead of showing "Loading comments…". The cache is also primed from the `gh pr list` call the picker already makes, so the tab skips its own fetch even on a session's first open (including PRs with no comments). GitHub only. ([#3294](max-sixty/worktrunk#3294), [#3299](max-sixty/worktrunk#3299)) - **Statusline width comes from `COLUMNS`, not a parent-process walk**: `wt list statusline` used to spawn up to 10 `ps` calls plus `stty` per render to recover a terminal width, because Claude Code piped the subprocess with no inherited TTY. Claude Code now sets `COLUMNS`/`LINES` to the terminal dimensions before running the script (since v2.1.153), so the width comes straight from there — less a fixed 5-column margin for Claude Code's own UI — and the `ps`/`stty` walk is gone. On an older Claude Code that doesn't set `COLUMNS`, the line renders untruncated rather than walking the process tree. ([#3286](max-sixty/worktrunk#3286), closes [#2950](max-sixty/worktrunk#2950)) ### Fixed - **`wt list` diff and ahead/behind columns use the upstream default tip**: The `main↕` (ahead/behind) and `main…±` (diff) columns measured every branch against the *local* default-branch tip, so in a fork whose local `main` lagged its upstream they reported inflated counts — one fork branch showed `↑44` and `+∞ / -5K` when it was ~2 commits past the real upstream tip. They now diff against the same upstream-aware base the integration column already uses. ([#3280](max-sixty/worktrunk#3280)) - **Integrated branches no longer flash `✗` in `wt list`**: A squash-merged branch whose default branch later re-edited the same lines showed `✗` (would-conflict), even though `wt step prune` classified it as `⊂` (fully integrated) and removed it. The list now ranks the integration verdict above the downstream conflict, matching prune; a genuinely un-integrated conflict still shows `✗`. ([#3278](max-sixty/worktrunk#3278)) - **`wt list` divergence-overflow marker uses one emphasis level**: When an ahead/behind count overflows its digit budget, the `main↕` column's compact `C`/`K`/`∞` marker rendered the "behind" subcolumn as dim + bold (reading as bold red) instead of a clean one-level step. It now steps exactly one level — dim red → normal red — matching the "ahead" subcolumn, across `wt list` and the picker. ([#3303](max-sixty/worktrunk#3303)) - **Branch deletion on removal is atomic**: `wt remove` and prune now delete a branch with a compare-and-swap (`git update-ref -d <ref> <expected-sha>`) against the SHA the integration check already read, closing the window where a branch whose tip moved in between (e.g. a hook landing a commit) could be deleted. Such a branch is now retained with a clear message and a `wt remove -D <branch>` recovery hint. This also unifies the previously divergent safe-delete paths; explicit force-delete still uses `git branch -D`. ([#2903](max-sixty/worktrunk#2903)) - **`wt list` and picker Age/Message columns paint as soon as the commit batch lands**: These columns carry no async task — their data arrives with the initial `git log` batch — but stayed on the `·` placeholder until some slower task happened to redraw the row, so the commit message lagged behind a cache-warm Summary preview. They now paint the moment the batch lands. ([#3287](max-sixty/worktrunk#3287)) - **Picker `Alt-x` removal: no cursor flash, `--prs` rows preserved**: Removing a row with `Alt-x` flashed the `>` pointer to the top of the list for a frame, and in `--prs` mode made the streamed PR/MR rows vanish until the next `Alt-r`. Removal is now a synchronous in-place pool resync: the cursor lands on the row that slid up with no flash, and the PR/MR rows survive. ([#3268](max-sixty/worktrunk#3268), [#3275](max-sixty/worktrunk#3275)) - **Removable rows stay gray when selected in the picker**: A safe-to-delete worktree (integrated, or clean and even with the default branch) renders its row gray, but the gray vanished under the selection highlight — exactly when you're about to act on it. The gray now survives selection (selected row only; `wt list` and unselected rows are unchanged). ([#3267](max-sixty/worktrunk#3267)) - **Picker preview keeps its scroll when CI status arrives**: Scrolling down a diff and waiting a couple of seconds snapped it back to the top when the live CI fetch landed and re-rendered the pane. The re-render is now precise — a tab re-runs only when its own content would actually change — so a CI update no longer throws away the scroll position of an unrelated tab. ([#3292](max-sixty/worktrunk#3292)) - **Picker summary tab dims when there's nothing to summarize**: The summary preview tab (`5`) stayed lit on a clean branch with no commits ahead, unlike the diff tabs (1/3/4), which dim once their diff is known empty. It now dims in concert with them once both the branch diff and working tree are known empty. ([#3291](max-sixty/worktrunk#3291)) - **Picker default view keeps collect order**: With no query typed, the `wt switch` picker reordered rows by where each name's last `/` falls, so slash-bearing branches (`feature/…`, `perf/…`) sank toward the bottom and intermixed with other row kinds. The default view now preserves collect order. ([#3301](max-sixty/worktrunk#3301)) - **Picker branch-diff preview and summary use the upstream-aware base**: Like the `wt list` columns above, the picker's branch-diff preview pane and the LLM branch summary diffed against the raw local default branch, so a fork whose local default lagged upstream made them describe dozens of already-merged commits. They now use the same upstream-aware comparison base. ([#3305](max-sixty/worktrunk#3305)) - **Picker comment previews render fenced code blocks cleanly**: A fenced code block inside a PR/MR comment rendered as a garbled double gutter in the `wt switch` comments preview — alternating bar/no-bar lines with broken alignment. The code block now renders without the nested gutter. ([#3306](max-sixty/worktrunk#3306)) - **First-run hints show the config path wt actually loads from**: The picker's disabled-summary tab and the commit-generation setup prompt hardcoded `~/.config/worktrunk/config.toml`, so a user with `--config`, `WORKTRUNK_CONFIG_PATH`, or a non-default `$XDG_CONFIG_HOME` was told to edit a file wt never reads. Both now show the resolved path. ([#3290](max-sixty/worktrunk#3290), [#3298](max-sixty/worktrunk#3298)) ### Internal - **`-vv` trace and profiler accuracy**: `trace.log` is now purely human-readable, with the machine-parseable `[wt-trace]` fields living only in `trace.jsonl`; and the performance profile's cache analysis no longer reports stdin-driven commands (LLM `claude -p` calls, `git patch-id`) as duplicate re-runs, since their real input isn't captured in the command string. ([#3296](max-sixty/worktrunk#3296), [#3297](max-sixty/worktrunk#3297)) ## Install worktrunk 0.63.0 ### Install prebuilt binaries via shell script ` See merge request: Harmonybrew/homebrew-core!13092
Problem
[list] columnsfiltered purely at the layout layer. A narrowed selection likecolumns = ["branch", "path"]hid the unselected columns but still ran every per-worktree git task —git status, working/branch diffs, ahead/behind walks, merge-conflict probes — then threw the results away. On the kind of repo that motivated #3133 (27 dirty worktrees) that discarded work is the bulk of the wall-clock cost, so a "just branch and path" view was no faster than the full table.This was flagged in the trace-based diagnosis on the issue:
columns = ["branch","path"]and the default set produced an identical command list. @max-sixty confirmed it's a bug and asked for the fix.Solution
wt listdecides which background tasks to run in one canonical stage, driven by the columns it will render. The plan flows through the whole pipeline as a positive set of tasks to run — no skip-list, no inversion, no blanket default.collectcomputestasks= the union of each rendered column'srequired_tasks(), gated by the conditions that turn a column off (--full,[list] summary+[commit.generation], a url template). The spawn loop fires exactly that set; the layout renders exactly the columns it feeds. The rendered set is the[list] columnsselection for the table; the picker and--format jsonplan from every column, because their consumers — the picker's preview tabs, JSON's every-field contract — need the full data set, not just what renders.This started as additive pruning layered on the old
skip_tasksdenylist; review (thanks @max-sixty) pushed it to the canonical, positive form:ColumnSpec::requires_taskis deleted;ColumnKind::required_tasks()is the single source, driving both the spawn plan and the layout visibility filter (renders_given_run— a column renders iff one of its tasks is in the plan). The two maps can no longer drift, so the reconciliation test is gone; thecover_every_taskdrift guard stays and gains teeth (an unconsumed task would never run, not merely be computed and discarded).CollectOptionscarriestasks(the run set), not a skip set —collectthreads the plan straight into the spawn loops, the layout, andmax_pr_numberwith no complement step.CollectOptions::for_columns(columns, gates)derives the plan; nothing hand-writes a task set. The statusline declares what it renders (the full column set under full gates, no LLM summary) instead of leaning on "default everything". The picker ridesshow_fullonShowConfig::Resolved.SummaryGenerate && llm.is_none()spawn guard is dropped: the column plan is the single authority on whether the summary runs, andSummaryGenerateTaskalready returns a clean error on a missing command.A branch/path
lsalias over many dirty worktrees now runs nogit status, diffs, or ahead/behind walks (#3133), while a column gated off elsewhere stays off. Behaviour is otherwise unchanged across default/selection × full/non-full × table/JSON/picker/statusline — no rendered-output snapshots move (thehelp_config_*snapshots move only from the columns-doc rewrite).Testing
test_required_tasks_for_render(the default set needs every task; a branch/path or custom-column view needs none;Statuspulls in every status-feeding task; the gates dropci/url/summaryeven when those columns are explicitly selected) andtest_renders_given_run(the "render iff a task is planned" filter, includingStatussurviving while any signal runs).test_required_tasks_cover_every_taskdrift guard retained: the union ofrequired_tasks()across all built-ins equals the fullTaskKindset, so no task can fall out of the now-load-bearing map.test_list_config_columns_prune_unused_tasks(default set runsgit status --porcelain;columns = ["branch", "age"]runs none) andtest_list_json_ignores_columns_selection(--format jsonemits every field regardless of selection).pre-mergegate (all suites, fmt, clippy, docs-sync, PTY picker snapshots) green after mergingmain.Closes #3133