Skip to content

feat(update): name the workspace projects each interactive row came from - #13337

Merged
zkochan merged 6 commits into
mainfrom
update-interactive-workspace-column
Jul 25, 2026
Merged

zkochan merged 6 commits into
mainfrom
update-interactive-workspace-column

Conversation

@zkochan

@zkochan zkochan commented Jul 25, 2026 •

Copy link
Copy Markdown
Member

Summary

The remaining half of the interactive parity item in #12101. #13298 grouped the list by dependency type; this adds the Workspace column upstream shows when workspaces are enabled.

Inside a workspace the list gave no way to tell which project an outdated dependency belonged to, so the same package outdated in two projects rendered as two indistinguishable rows. Every outdated entry now records the name of the project it was collected from:

dependencies
Package Current   Target Workspace URL
react    18.2.0 ❯ 19.1.0 web       https://react.dev/
devDependencies
Package    Current   Target Workspace URL
typescript   5.4.2 ❯ 5.4.5  tooling

The column is present only when workspaces are enabled, matching upstream's workspacesEnabled gate — the recursive entry point always runs inside one, the single-project entry point asks config.workspace_dir.

The name is read where collect_outdated_for_importer already has the manifest in hand, so no new parameter is threaded through, and it goes through sanitize_inline with the rest of the row.

Tests cover the column's presence and absence, that it names the right project per row, and — on the existing collector test, which already builds two fixture projects — that the field is actually populated end to end rather than only rendered.

Also in this PR: two label fixes, in both stacks

Review raised two ways the column named a project poorly. Both were true of the TypeScript CLI as well, so both are fixed on each side rather than letting pacquet diverge.

A collapsed row named only one project. A dependency outdated at the same version in several projects is offered as a single choice, because selecting it updates the package in every one of them — that is how both stacks resolve the selection, which is a flat list of package names. The surviving row named whichever project was seen first, reading as though only that one was affected. Collapsed entries now contribute their projects to the row:

Package Current   Target Workspace    URL
foo      1.0.0 ❯ 2.0.0  web, tooling

An unnamed project got a blank cell. A workspace project need not declare a name, and both stacks took the name verbatim, so such a project rendered as an empty cell and several were indistinguishable. The label now falls back to the path that identifies the project in the lockfile — which pnpm already computes as importerId, and pacquet already has as importer_id.

The column itself remains a pacquet-only addition; the TypeScript CLI already had it.

Squash Commit Body

Inside a workspace the interactive update list showed no way to tell
which project an outdated dependency belonged to, so the same package
outdated in two projects rendered as two indistinguishable rows.

Every outdated entry now records the name of the project it was
collected from, and the interactive list gains the `Workspace` column
upstream shows when workspaces are enabled. The name is read where the
collector already has the manifest in hand, so nothing new is threaded
through; it is stripped of control characters with the rest of the row.

This completes the interactive parity item of pnpm/pnpm#12101, whose
remaining half after the grouping landed was this column.

Related to pnpm/pnpm#12101.

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust
    pnpm/ port, or the description notes what still needs porting.
  • Added a changeset (pnpm changeset) if this PR changes any published
    package. Keep it short and written for pnpm users — it becomes a release note.
  • Added or updated tests.

Written by an agent (Claude Code, claude-opus-5).

Summary by CodeRabbit

  • New Features
    • Added a Workspace column to interactive dependency updates in multi-project workspaces.
    • Identifies the project associated with each outdated dependency.
    • Consolidated choices now list all affected workspaces.
    • Unnamed workspace projects display their project path instead of appearing blank.

Inside a workspace the interactive update list showed no way to tell
which project an outdated dependency belonged to, so the same package
outdated in two projects rendered as two indistinguishable rows.

Every outdated entry now records the name of the project it was
collected from, and the interactive list gains the `Workspace` column
upstream shows when workspaces are enabled. The name is read where the
collector already has the manifest in hand, so nothing new is threaded
through; it is stripped of control characters with the rest of the row.

This completes the interactive parity item of #12101, whose
remaining half after the grouping landed was this column.

Related to #12101.
Copilot AI review requested due to automatic review settings July 25, 2026 12:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@zkochan, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 5 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 1af5ef0a-2777-44cd-b08b-37d66b21ed2b

📥 Commits

Reviewing files that changed from the base of the PR and between 13f5681 and 45e38b3.

📒 Files selected for processing (8)
  • pnpm/crates/cli/src/cli_args/outdated.rs
  • pnpm/crates/cli/src/cli_args/update_interactive.rs
  • pnpm/crates/cli/src/cli_args/update_interactive/choices.rs
  • pnpm/crates/cli/src/cli_args/update_interactive/tests.rs
  • pnpm11/deps/inspection/outdated/src/outdated.ts
  • pnpm11/deps/inspection/outdated/test/outdated.spec.ts
  • pnpm11/installing/commands/src/update/getUpdateChoices.ts
  • pnpm11/installing/commands/test/update/getUpdateChoices.test.ts
📝 Walkthrough

Walkthrough

pnpm outdated entries now include workspace labels, with fallbacks for unnamed projects. Interactive update choices aggregate labels across deduplicated dependencies and conditionally render a Workspace column. Tests and changesets cover the new behavior.

Changes

Workspace-aware outdated data

Layer / File(s) Summary
Workspace label propagation
pnpm/crates/cli/src/cli_args/outdated.rs, pnpm11/deps/inspection/outdated/src/outdated.ts, pnpm/crates/cli/src/cli_args/outdated/tests.rs, pnpm/crates/cli/src/cli_args/update_interactive/tests.rs
Outdated dependency records now carry workspace names, falling back to importer IDs or paths when project names are unavailable; GitHub Actions entries remain unlabeled.
Interactive workspace choice rendering
pnpm/crates/cli/src/cli_args/update_interactive.rs, pnpm/crates/cli/src/cli_args/update_interactive/choices.rs, pnpm/crates/cli/src/cli_args/update_interactive/choices/tests.rs
Interactive update flow passes workspace-mode state, aggregates workspaces during deduplication, and conditionally renders the Workspace column.
Collapsed choice aggregation and release validation
pnpm11/installing/commands/src/update/getUpdateChoices.ts, pnpm11/installing/commands/test/update/getUpdateChoices.test.ts, .changeset/*interactive-update-workspace*.md
Collapsed choices now display all contributing workspaces, with tests and patch changesets documenting the behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant WorkspaceProject
  participant OutdatedCollector
  participant InteractiveUpdater
  participant ChoiceRenderer
  WorkspaceProject->>OutdatedCollector: provide manifest name or importer path
  OutdatedCollector->>InteractiveUpdater: attach workspace to outdated package
  InteractiveUpdater->>ChoiceRenderer: pass deduplicated choices and workspace sets
  ChoiceRenderer-->>InteractiveUpdater: render optional Workspace column
Loading

Possibly related PRs

  • pnpm/pnpm#13202: Both changes enhance workspace-aware outdated dependency aggregation in outdated.rs.

Suggested labels: product: pnpm@11, product: pacquet

Suggested reviewers: copilot

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch update-interactive-workspace-column

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Add Workspace column to interactive update list

✨ Enhancement 🧪 Tests ⚙️ Configuration changes 🕐 20-40 Minutes

Grey Divider

AI Description

• Record the workspace project name on each outdated dependency entry.
• Render an optional Workspace column in pnpm update --interactive when workspaces are enabled.
• Add unit/integration tests and a changeset for the new interactive output.
Diagram

graph TD
  M["package.json manifest"] --> C["collect_outdated_for_importer"] --> O["OutdatedPackage (workspace)"] --> P["prompt_for_packages"] --> U["update_choices / render_rows"] --> UI["MultiSelect prompt"]
  CFG["Config.workspace_dir"] --> D{"Workspaces enabled?"} --> P
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Use importer ID / relative path as the workspace identifier
  • ➕ Always available even when package.json lacks a name
  • ➕ Often more actionable for monorepos than a display name
  • ➖ Less user-friendly than project names (longer/noisier output)
  • ➖ Would diverge from upstream UI expectations if they prefer names
2. Compute workspace label at render time via an importer→name map
  • ➕ Keeps OutdatedPackage smaller and avoids coupling collector output to UI needs
  • ➕ Could provide richer fallbacks (name, then path) without changing collector
  • ➖ Requires threading importer identity through the interactive update pipeline
  • ➖ More plumbing and state for a relatively small UX change
3. Always show the column, leaving it blank outside workspaces
  • ➕ Simplifies prompt API (no workspaces_enabled parameter)
  • ➕ Stable columns across contexts
  • ➖ Adds a mostly-empty column in single-project runs
  • ➖ Does not match upstream’s conditional display behavior described in the PR

Recommendation: Current approach is a good fit: capture the workspace name where the manifest is already available (minimal plumbing) and gate the column on workspace enablement to match upstream behavior. The main potential improvement to consider is a fallback for unnamed projects (e.g., importer id or relative path) to avoid blank Workspace cells when name is missing.

Files changed (7) +95 / -29

Enhancement (3) +40 / -19
outdated.rsAdd workspace provenance to 'OutdatedPackage' and populate during collection +12/-0

Add workspace provenance to 'OutdatedPackage' and populate during collection

• Extends 'OutdatedPackage' with an optional 'workspace' field. During importer collection, reads the project name from the manifest and attaches it to every collected outdated entry; GitHub Actions entries explicitly set 'workspace: None'.

pnpm/crates/cli/src/cli_args/outdated.rs

update_interactive.rsGate Workspace column based on workspace enablement +4/-3

Gate Workspace column based on workspace enablement

• Threads a 'workspaces_enabled' boolean into 'prompt_for_packages', using 'config.workspace_dir.is_some()' for single-project runs and always 'true' for recursive/workspace project selection.

pnpm/crates/cli/src/cli_args/update_interactive.rs

choices.rsRender optional 'Workspace' column and sanitize workspace names +24/-16

Render optional 'Workspace' column and sanitize workspace names

• Extends interactive choice rendering to conditionally include a 'Workspace' column in the header and each row. Workspace names are sanitized with the same inline sanitizer as package names and homepages to prevent control-character injection into the terminal UI.

pnpm/crates/cli/src/cli_args/update_interactive/choices.rs

Tests (3) +50 / -10
tests.rsUpdate outdated test helpers for new 'workspace' field +1/-0

Update outdated test helpers for new 'workspace' field

• Adjusts the 'OutdatedPackage' test fixture builder to initialize the new 'workspace' field as 'None', keeping existing tests compiling and semantically unchanged.

pnpm/crates/cli/src/cli_args/outdated/tests.rs

tests.rsAdd coverage for Workspace column presence/absence and values +43/-10

Add coverage for Workspace column presence/absence and values

• Updates existing tests to pass the new 'workspaces_enabled' flag. Adds new tests verifying the Workspace column appears only in workspace mode and correctly displays per-row project names.

pnpm/crates/cli/src/cli_args/update_interactive/choices/tests.rs

tests.rsAssert end-to-end population of 'workspace' on collected choices +6/-0

Assert end-to-end population of 'workspace' on collected choices

• Extends the workspace importer collection test to verify 'choice.workspace' is populated with the originating project name, ensuring the field is set end-to-end (not just rendered).

pnpm/crates/cli/src/cli_args/update_interactive/tests.rs

Other (1) +5 / -0
interactive-update-workspace-column.mdAdd changeset entry for interactive Workspace column +5/-0

Add changeset entry for interactive Workspace column

• Introduces a patch changeset documenting that interactive update now shows a 'Workspace' column inside workspaces to disambiguate identical outdated dependencies across projects.

.changeset/interactive-update-workspace-column.md

@greptile-apps

greptile-apps Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Reviews (6): Last reviewed commit: "perf(update): key the choice deduplicati..." | Re-trigger Greptile

@github-actions

github-actions Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                          main                                   pr
-----                          ----                                   --
lockfile/parse_pnpm_lock       1.00     11.6±0.04ms    32.4 MB/sec    1.02     11.8±0.03ms    31.8 MB/sec
packument/parse                1.05     37.8±0.14µs  1753.4 MB/sec    1.00     35.9±0.03µs  1847.7 MB/sec
tarball/download_dependency    1.05      2.3±0.06ms  1880.7 KB/sec    1.00      2.2±0.10ms  1980.7 KB/sec

@qodo-code-review

qodo-code-review Bot commented Jul 25, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (3) 📘 Rule violations (1) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 24 rules

Grey Divider


Action required

1. Workspace terminal injection ✓ Resolved 🐞 Bug ⛨ Security
Description
In the TS CLI, workspace labels (from package.json name/importerId) are concatenated into the
interactive update table without stripping VT/control characters, allowing a malicious workspace
name to inject escape sequences or newlines into the prompt output. This can corrupt the prompt UI
and potentially forge terminal/CI output during pnpm update --interactive runs.
Code

pnpm11/installing/commands/src/update/getUpdateChoices.ts[R123-126]

+function buildPkgChoice (outdatedPkg: UpdateChoiceDependency, workspacesEnabled: boolean, workspaces?: Set<string>): RawChoice {
  const sdiff = semverDiff(outdatedPkg.wanted, outdatedPkg.latestManifest!.version)
  const nextVersion = sdiff.change === null
    ? outdatedPkg.latestManifest!.version
Relevance

⭐⭐⭐ High

They’ve recently accepted sanitizing untrusted manifest-derived strings to prevent terminal
control-sequence injection.

PR-#13287
PR-#13202

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Workspace names flow from project manifests into the interactive prompt row text without any
sanitization step; the prompt renderer prints that row text directly, so control characters in
workspace names can affect terminal output.

pnpm11/deps/inspection/outdated/src/outdated.ts[82-90]
pnpm11/installing/commands/src/update/getUpdateChoices.ts[34-56]
pnpm11/installing/commands/src/update/getUpdateChoices.ts[123-145]
pnpm11/installing/commands/src/update/index.ts[255-291]
PR-#13202

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`getUpdateChoices()` renders workspace labels directly into interactive prompt rows. Because `workspace` originates from user-controlled project manifests, it must be sanitized to prevent terminal escape/control-character injection (including newlines).

### Issue Context
- `workspace` is populated from `opts.manifest.name ?? importerId`.
- The prompt uses the rendered table row (`choice.message`) directly as the checkbox `name`.

### Fix Focus Areas
- pnpm11/installing/commands/src/update/getUpdateChoices.ts[34-56]
- pnpm11/installing/commands/src/update/getUpdateChoices.ts[123-145]

### Recommended fix
- Introduce a small local sanitizer for prompt cells, e.g.:
 - `stripVTControlCharacters(value)`
 - then replace remaining control chars (including `\n`, `\r`, `\t`, etc.) with spaces (similar to `sanitizeManifestValue()` in config/reader).
- Apply it to each workspace label **before** joining (and ideally to the joined string too).
- Add/extend a unit test to ensure workspace names containing `\u001b` and `\n` do not survive into `dataRow.message` (after *no* stripping), i.e. verify the message itself contains no escape/newline characters.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. TS whitespace bypass fallback 🐞 Bug ≡ Correctness ⭐ New
Description
The workspace label in outdated/output selection uses opts.manifest.name || importerId (or an
equivalent empty-string check) so whitespace-only or control-only manifest names are treated as
present and won’t fall back to importerId. Later, interactive rendering strips control characters
(but not whitespace), so these “effectively blank” names can produce an empty or visually ambiguous
Workspace cell and fail to disambiguate rows.
Code

pnpm11/deps/inspection/outdated/src/outdated.ts[R88-90]

+  // `||` rather than `??`: a project that declares an empty name gives
+  // just as blank a label as one that declares none.
+  const workspace = opts.manifest.name || importerId
Relevance

⭐⭐⭐ High

Team has recent precedent accepting sanitization/robustness fixes for user-controlled strings; this
aligns with PR’s “avoid blank workspace” intent.

PR-#13230
PR-#13195

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The cited logic chooses the workspace label via a simple truthy/empty check (|| / is_empty()),
which only rejects falsy/empty strings and therefore accepts whitespace-only and control-only names
as valid labels. The interactive renderer subsequently removes control characters from workspace
cells, so a control-only manifest name that passed the earlier selection can become empty at display
time, while whitespace-only names remain visually blank because whitespace is not trimmed, resulting
in an ambiguous or empty workspace label rather than falling back to importerId for
disambiguation.

pnpm11/deps/inspection/outdated/src/outdated.ts[82-92]
pnpm11/installing/commands/src/update/getUpdateChoices.ts[149-158]
pnpm/crates/cli/src/cli_args/outdated.rs[183-195]
pnpm/crates/cli/src/cli_args/sanitize.rs[17-23]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The workspace label fallback used by outdated/interactive output only rejects falsy/empty manifest names, so whitespace-only and control-only `manifest.name` values bypass the fallback to `importerId`/`importer_id`. Because interactive rendering strips control characters (and does not trim whitespace), these names can display as empty or visually blank `Workspace` cells, undermining the column’s purpose of disambiguating rows.

## Issue Context
The label is derived from `opts.manifest.name` when present, otherwise it should fall back to the importer identifier; however, the current predicate treats whitespace/control-only strings as usable. The interactive update UI sanitizes control characters for display, so a control-only name can become empty at render time, and whitespace-only names can appear blank, creating ambiguous workspace labels.

## Fix Focus Areas
- pnpm11/deps/inspection/outdated/src/outdated.ts[88-90]
- pnpm/crates/cli/src/cli_args/outdated.rs[192-193]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Unicode spoofing not stripped 🐞 Bug ⛨ Security
Description
sanitizeCell() only removes C0/C1 control bytes, so Unicode bidi/formatting characters (e.g.
RLO/LRO/RLI/LRI/PDF isolates) can still reach the interactive update table via attacker-controlled
workspace names or registry metadata and visually spoof/mislead rows without using ESC/newline.
Code

pnpm11/installing/commands/src/update/getUpdateChoices.ts[R149-158]

+/**
+ * Strip control characters from text that goes into a single-line table
+ * cell. Package names, workspace labels, and homepages come out of
+ * manifests and registry metadata, so an escape sequence there would
+ * corrupt the prompt's redraw and a newline would split the row.
+ */
+function sanitizeCell (text: string): string {
+  // eslint-disable-next-line no-control-regex
+  return text.replace(/[\u0000-\u001F\u007F-\u009F]/g, '')
+}
Relevance

⭐⭐⭐ High

Repo has accepted sanitization/escape hardening for attacker-controlled strings; extending sanitizer
to strip bidi controls is low-risk.

PR-#13195

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new sanitizer only removes C0/C1 control ranges; it does not cover common Unicode bidi control
characters, allowing attacker-controlled manifest/registry strings to visually reorder/spoof
terminal output. The new test asserts ESC and \n are removed but does not cover bidi characters.

pnpm11/installing/commands/src/update/getUpdateChoices.ts[149-158]
pnpm11/installing/commands/test/update/getUpdateChoices.test.ts[222-248]
REVIEW_GUIDE.md[30-46]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`sanitizeCell()` is intended to make table cells safe for terminal/prompt rendering, but it only strips ASCII control ranges. Unicode bidirectional override/isolate characters (and some Unicode line/paragraph separators) are not removed, which can allow display spoofing in `pnpm update --interactive` output when workspace names or registry fields contain those characters.

### Issue Context
- Workspace labels come from manifests / lockfile identifiers.
- URL/homepage comes from registry metadata.
Both are attacker-controlled inputs per repo security rules.

### Fix Focus Areas
- pnpm11/installing/commands/src/update/getUpdateChoices.ts[149-159]
- pnpm11/installing/commands/test/update/getUpdateChoices.test.ts[221-248]

### Suggested fix
- Extend `sanitizeCell` to also remove Unicode bidi control characters at minimum:
 - `\u200E\u200F` (LRM/RLM)
 - `\u202A-\u202E` (embedding/override + PDF)
 - `\u2066-\u2069` (isolates + PDI)
- Optionally also strip Unicode line/paragraph separators `\u2028\u2029` to keep cells single-line across renderers.
- Add a regression test that sets `workspace` and/or `homepage` to include one of these characters (e.g. `"web\u202Eevil"`) and asserts it does not appear in the rendered row.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


4. Workspace rows deduped away ✓ Resolved 🐞 Bug ≡ Correctness
Description
In workspace-enabled interactive update runs, dependencies collected from multiple projects can be
deduplicated without considering the new workspace field, so identical outdated entries from
different projects collapse into one row and the Workspace column may show only one (potentially
misleading) project. This undermines the feature’s goal of distinguishing which workspace project
each row came from.
Code

pnpm/crates/cli/src/cli_args/update_interactive/choices.rs[R118-145]

+fn render_rows(packages: &[&OutdatedPackage], workspaces_enabled: bool) -> Vec<ChoiceRow> {
+    let mut header =
+        vec!["Package".to_string(), "Current".to_string(), String::new(), "Target".to_string()];
+    if workspaces_enabled {
+        header.push("Workspace".to_string());
+    }
+    header.push("URL".to_string());

    let mut cells = vec![header];
    for package in packages {
-        // The name and homepage are registry metadata, so they are
-        // stripped of control characters before reaching the terminal:
-        // an escape sequence would corrupt the prompt's redraw, and a
-        // newline would break the row apart.
-        let row = vec![
+        // The name, workspace, and homepage are read out of manifests
+        // and registry metadata, so they are stripped of control
+        // characters before reaching the terminal: an escape sequence
+        // would corrupt the prompt's redraw, and a newline would break
+        // the row apart.
+        let mut row = vec![
            sanitize_inline(&package.package_name).into_owned(),
            package.current.to_string(),
            "❯".to_string(),
            colorize_target(package),
-            package.homepage.as_deref().map(sanitize_inline).unwrap_or_default().into_owned(),
        ];
+        if workspaces_enabled {
+            row.push(
+                package.workspace.as_deref().map(sanitize_inline).unwrap_or_default().into_owned(),
+            );
+        }
+        row.push(package.homepage.as_deref().map(sanitize_inline).unwrap_or_default().into_owned());
        cells.push(row);
Relevance

⭐⭐⭐ High

Very similar accepted precedent: dedupe key fixes in interactive update to prevent collapsing
distinct rows.

PR-#13298

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
OutdatedPackage.workspace is populated per importer, but both the cross-project collector and the
prompt grouping layer dedupe without including it, so two projects with the same
alias/package/current/target can collapse into one displayed row even though the UI now claims to
show per-project origin.

pnpm/crates/cli/src/cli_args/outdated.rs[171-247]
pnpm/crates/cli/src/cli_args/update_interactive.rs[141-179]
pnpm/crates/cli/src/cli_args/update_interactive/choices.rs[79-105]
pnpm/crates/cli/src/cli_args/update_interactive/choices.rs[118-145]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
In workspace runs, outdated entries may originate from multiple workspace projects. The new `Workspace` column renders a single project name per row, but upstream code still deduplicates choices using keys that omit `OutdatedPackage.workspace`, causing entries that only differ by workspace to be dropped and/or misrepresented.

## Issue Context
Two separate dedupe steps can drop workspace-distinct entries:
1) `update_interactive::collect_choices()` dedupes across projects.
2) `update_interactive::choices::update_choices()` dedupes again before grouping.

To make the new column reliable, either:
- include `workspace` (or importer id) in the dedupe keys when `workspaces_enabled` is true, OR
- aggregate multiple workspace names into a single rendered cell (e.g., `app, lib`) while still offering a single selectable row.

## Fix Focus Areas
- pnpm/crates/cli/src/cli_args/update_interactive.rs[163-176]
- pnpm/crates/cli/src/cli_args/update_interactive/choices.rs[79-105]
- pnpm/crates/cli/src/cli_args/update_interactive/choices.rs[118-145]
- pnpm/crates/cli/src/cli_args/outdated.rs[171-247]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (1)
5. Extra cloning in dedupe ✓ Resolved 🐞 Bug ➹ Performance
Description
The Rust interactive choice dedupe now clones alias/package_name into the HashMap key and uses
Vec::contains() to de-duplicate workspace labels, adding avoidable allocations and linear scans
for large monorepos with many collapsed workspace entries. This is unlikely to be user-visible in
typical workspaces but can be optimized cheaply.
Code

pnpm/crates/cli/src/cli_args/update_interactive/choices.rs[R85-116]

+    let mut seen: HashMap<ChoiceKey, usize> = HashMap::new();
+    let mut choices: Vec<Choice<'_>> = Vec::new();
+    let mut grouped: Vec<(ChoiceGroupKind, Vec<usize>)> = Vec::new();
    for package in outdated {
        // Keyed by alias as well as package name, because the alias is
        // what a selected row updates: two manifest entries aliasing one
        // package (`"a": "npm:foo@1"`, `"b": "npm:foo@1"`) are separate
        // dependencies and both have to be offered.
        let key = (
-            package.alias.as_str(),
-            package.package_name.as_str(),
+            package.alias.clone(),
+            package.package_name.clone(),
            package.current.to_string(),
            package.target.to_string(),
            package.github_action,
        );
-        if !seen.insert(key) {
-            continue;
-        }
-        let kind = ChoiceGroupKind::of(package);
-        match grouped.iter_mut().find(|(group, _)| *group == kind) {
-            Some((_, packages)) => packages.push(package),
-            None => grouped.push((kind, vec![*package])),
+        let index = *seen.entry(key).or_insert_with(|| {
+            let index = choices.len();
+            choices.push(Choice { package, workspaces: Vec::new() });
+            let kind = ChoiceGroupKind::of(package);
+            match grouped.iter_mut().find(|(group, _)| *group == kind) {
+                Some((_, indices)) => indices.push(index),
+                None => grouped.push((kind, vec![index])),
+            }
+            index
+        });
+        // Collect every project the collapsed entries came from, so the
+        // `Workspace` column names all of them rather than whichever was
+        // seen first — selecting the row updates the package in each.
+        if let Some(workspace) = &package.workspace
+            && !choices[index].workspaces.contains(workspace)
+        {
+            choices[index].workspaces.push(workspace.clone());
Relevance

⭐⭐ Medium

Perf micro-optimization; team accepts efficiency fixes sometimes but no close precedent on
cloning/Vec::contains here.

PR-#13207

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new key construction explicitly clones owned strings for hashing, and workspace aggregation uses
a linear scan on a growing Vec; both increase per-item overhead compared to a borrowed-key or
set-based approach.

pnpm/crates/cli/src/cli_args/update_interactive/choices.rs[81-118]
pnpm/crates/cli/src/cli_args/outdated.rs[70-79]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`update_choices()` allocates/clones multiple strings per processed package while deduplicating and aggregating workspaces, and uses an O(k) `Vec::contains()` check per added workspace label.

### Issue Context
- `OutdatedPackage.alias` and `.package_name` are already `String`s; cloning them into a temporary key is avoidable if the dedupe map can use borrowed keys.
- For a dependency outdated across many workspace projects, workspace aggregation can become noticeably more expensive due to repeated linear scans.

### Fix Focus Areas
- pnpm/crates/cli/src/cli_args/update_interactive/choices.rs[81-118]
- pnpm/crates/cli/src/cli_args/outdated.rs[70-92]

### Recommended fix
- Change the dedupe key to borrow where possible, e.g. `type ChoiceKey<'a> = (&'a str, &'a str, VersionOrString, VersionOrString, bool)` (or borrow `&Version` if it implements `Hash + Eq`) so `alias`/`package_name` aren’t cloned just to hash.
- Replace `Vec<String>` + `contains()` with an order-preserving set approach:
 - either `HashSet<String>` alongside `Vec<String>` to preserve first-seen order, or
 - `indexmap::IndexSet` if already available/acceptable.
- Keep output ordering stable (first-seen) to avoid snapshot/test churn.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational

6. Version key stringifies Versions ✓ Resolved 🐞 Bug ➹ Performance
Description
ChoiceKey stores current/target as String, forcing per-package to_string() allocations
when building the dedupe map; using Version values directly would avoid formatting/allocation
overhead in large interactive runs.
Code

pnpm/crates/cli/src/cli_args/update_interactive/choices.rs[138]

+type ChoiceKey<'a> = (&'a str, &'a str, String, String, bool);
Relevance

⭐⭐ Medium

Perf-only micro-optimization; no close precedent. Team accepted dedupe-key fixes but rejected
broader refactors in same area.

PR-#13298

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
OutdatedPackage.current and .target are already Version, so converting them to String for
hashing is extra work; the key construction currently uses to_string().

pnpm/crates/cli/src/cli_args/update_interactive/choices.rs[81-99]
pnpm/crates/cli/src/cli_args/update_interactive/choices.rs[138-138]
pnpm/crates/cli/src/cli_args/outdated.rs[70-79]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`ChoiceKey` uses `String` for `current` and `target`, so each key construction formats versions into new heap strings. This is avoidable because the underlying fields are already strongly typed as `Version`.

### Issue Context
This code runs on the interactive-update path and can process many outdated entries in a monorepo.

### Fix Focus Areas
- pnpm/crates/cli/src/cli_args/update_interactive/choices.rs[138-138]

### Suggested fix
- Change `ChoiceKey` to store `Version` (owned) instead of `String`:
 - `type ChoiceKey<'a> = (&'a str, &'a str, Version, Version, bool);`
- Update the key construction to clone `package.current`/`package.target` instead of calling `to_string()`.
- Ensure `Version` implements `Hash`/`Eq` (it typically does); if it does not, consider a lightweight borrowed representation that avoids formatting.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


7. Workspace name cloned per entry 🐞 Bug ➹ Performance
Description
collect_outdated_for_importer_with_cache clones the same workspace name string into every
emitted OutdatedPackage, adding avoidable per-entry allocations proportional to the number of
outdated dependencies in an importer. This is likely minor, but it is extra overhead on a
potentially large interactive-update set.
Code

pnpm/crates/cli/src/cli_args/outdated.rs[R183-187]

+    // Recorded on every entry so the interactive update list can say
+    // which workspace project each outdated dependency came from.
+    let workspace =
+        manifest.value().get("name").and_then(serde_json::Value::as_str).map(str::to_string);
+    let workspace = &workspace;
Relevance

⭐⭐ Medium

Micro-optimization; team sometimes accepts allocation reductions, but no close precedent for cloning
workspace name per row.

PR-#13300

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The workspace name is computed once from the manifest and then cloned into each OutdatedPackage
produced in the loop, which means repeated String allocations when workspace is Some and
multiple packages are emitted.

pnpm/crates/cli/src/cli_args/outdated.rs[180-247]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The workspace project name is identical for all outdated entries collected from the same importer, but it is cloned into each `OutdatedPackage`, allocating/copying repeatedly.

## Issue Context
This is a micro-optimization (network/registry fetches dominate), but if you want to keep the new field cheap for very large outdated sets, consider sharing ownership.

## Fix Focus Areas
- pnpm/crates/cli/src/cli_args/outdated.rs[180-247]

## Possible approach
- Change `OutdatedPackage.workspace` to `Option<Arc<str>>` (or similar) and set it once per importer.
- Keep terminal sanitization at the render boundary (as it is now).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


8. Changeset missing pnpm entry 📘 Rule violation § Compliance
Description
The new changeset only lists pacquet and omits a pnpm entry, and it marks the change as patch
even though the text describes a new user-visible feature (Workspace column). This violates the
changeset requirements and can lead to incorrect release/version planning.
Code

.changeset/interactive-update-workspace-column.md[R1-3]

+---
+"pacquet": patch
+---
Relevance

⭐ Low

Precedent: adding required "pnpm" entry to pacquet-only changesets was rejected; team keeps
pacquet-only changesets.

PR-#13304
PR-#13086

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713436 requires changesets to explicitly include pnpm with a valid bump type, and
for the bump type to match the described change. The added changeset front-matter lists only
pacquet: patch, omitting pnpm and using patch for a user-visible feature described in the
body.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/interactive-update-workspace-column.md[1-5]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The changeset front-matter omits the required `pnpm` package entry, and the bump type appears inconsistent with the described user-visible feature.

## Issue Context
The changeset currently contains only:
- `"pacquet": patch`

But the changeset text describes a new user-visible behavior (`Workspace` column), which should be reflected with the correct package entries and bump type.

## Fix Focus Areas
- .changeset/interactive-update-workspace-column.md[1-3]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@codecov-commenter

codecov-commenter commented Jul 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.06349% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.04%. Comparing base (d478870) to head (45e38b3).
⚠️ Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
pnpm/crates/cli/src/cli_args/update_interactive.rs 20.00% 4 Missing ⚠️
pnpm/crates/cli/src/cli_args/outdated.rs 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13337      +/-   ##
==========================================
+ Coverage   87.02%   87.04%   +0.02%     
==========================================
  Files         532      535       +3     
  Lines       91642    91853     +211     
==========================================
+ Hits        79750    79956     +206     
- Misses      11892    11897       +5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zkochan

zkochan commented Jul 25, 2026

Copy link
Copy Markdown
Member Author

Triage of the Qodo findings — none changing, reasons below.

1. Workspace rows deduped away — same as Greptile's P1; answered in detail on that thread. Short version: upstream's deduplication key is [packageName, latestManifest?.version, current, dependencyType] with no workspace and no earlier stage, so pnpm collapses these rows identically; and the prompt returns a flat list of package names applied to every selected project in both stacks, so splitting the row would yield two rows with the same effect rather than independent selection.

2. Workspace name cloned per entry — one short String per outdated dependency, allocated in the same async block that has just finished a network round-trip for that dependency's packument. The clone is invisible next to the fetch it follows, and removing it means either an Arc in OutdatedPackage or a lifetime on it, both of which cost more in readability than they save. Qodo rates it minor itself; I agree and would rather not carry the complexity.

3. Changeset missing pnpm entry — required by pnpm/AGENTS.md: "Do not add "pnpm" to a Rust-only changeset: in changesets, pnpm always means the TypeScript CLI package." This change is pacquet-only, so the changeset targets pacquet alone.

Greptile has withdrawn its second finding (the blank cell for unnamed projects) on the same match-upstream grounds.


Written by an agent (Claude Code, claude-opus-5).

Two ways the column named a project poorly, both fixed in each stack
since the column exists in both.

A dependency outdated at the same version in several workspace projects
collapses into one choice, because selecting it updates the package in
every project. The surviving row named whichever project was seen first,
reading as though only that one was affected. The collapsed entries now
contribute their projects to the row, which lists them.

A workspace project is not required to declare a `name`, and the column
took the name verbatim, so such a project got an empty cell and several
of them were indistinguishable. The label now falls back to the path
that identifies the project in the lockfile.

Raised in review of #13337.
Copilot AI review requested due to automatic review settings July 25, 2026 12:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@zkochan zkochan changed the title feat(update): name the workspace project each interactive row came from feat(update): name the workspace projects each interactive row came from Jul 25, 2026
@zkochan

zkochan commented Jul 25, 2026

Copy link
Copy Markdown
Member Author

Thanks — "Workspace rows deduped away" is marked resolved, which matches the fix in 13f5681 (the row still collapses, but now names every project it covers).

The remaining two stand as answered earlier:

  • Workspace name cloned per entry — one short String per outdated dependency, allocated in the same async block that just completed a network round-trip for that dependency's packument. Removing it costs an Arc or a lifetime on OutdatedPackage for no measurable gain.
  • Changeset missing pnpm entry — the flagged file is interactive-update-workspace-column.md, which is the pacquet-only half of this PR, and pnpm/AGENTS.md is explicit: "Do not add "pnpm" to a Rust-only changeset: in changesets, pnpm always means the TypeScript CLI package." This PR carries a second changeset, interactive-update-workspace-labels.md, for the half that does change the TypeScript CLI — and that one names @pnpm/deps.inspection.outdated, @pnpm/installing.commands, and pnpm. So the split is deliberate: one changeset per stack, each naming only what it actually bumps.

Written by an agent (Claude Code, claude-opus-5).

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 13f5681

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pnpm/crates/cli/src/cli_args/update_interactive/tests.rs`:
- Around line 72-77: Extend the test around the interactive choices’ Workspace
assertions to include an importer whose manifest omits the name field, using an
importer ID such as “packages-a”. Verify that its workspace value falls back to
the importer_id while preserving the existing named-manifest expectations for
the other entry.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: c23c3964-f26c-4f3d-996e-a93d0ecd58e8

📥 Commits

Reviewing files that changed from the base of the PR and between 352125d and 13f5681.

📒 Files selected for processing (11)
  • .changeset/interactive-update-workspace-column.md
  • .changeset/interactive-update-workspace-labels.md
  • pnpm/crates/cli/src/cli_args/outdated.rs
  • pnpm/crates/cli/src/cli_args/outdated/tests.rs
  • pnpm/crates/cli/src/cli_args/update_interactive.rs
  • pnpm/crates/cli/src/cli_args/update_interactive/choices.rs
  • pnpm/crates/cli/src/cli_args/update_interactive/choices/tests.rs
  • pnpm/crates/cli/src/cli_args/update_interactive/tests.rs
  • pnpm11/deps/inspection/outdated/src/outdated.ts
  • pnpm11/installing/commands/src/update/getUpdateChoices.ts
  • pnpm11/installing/commands/test/update/getUpdateChoices.test.ts

@blacksmith-sh

blacksmith-sh Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Found 1 test failure on Blacksmith runners:

Failure

Test View Logs
test/licenses/index.ts/index View Logs

Fix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

…hem all

`update_choices` merges the workspaces of entries that collapse into one
row, but `collect_choices` deduplicated before it without considering
the workspace, so in a recursive interactive update the second project's
entry was already gone and the row could only ever name the first. Its
key now includes the workspace.

`one_dependency_in_two_projects_keeps_both_workspaces` covers the whole
path rather than `update_choices` alone, which is what let the gap
through, and `a_nameless_project_is_labelled_with_its_importer_path`
covers the fallback.

On the TypeScript side, the labels the table renders are read out of
manifests and registry metadata and went in verbatim, so a crafted
workspace name or homepage could emit escape sequences into the prompt
or a newline that splits a row — the same exposure already closed on the
Rust side. They now go through a cell sanitizer; the colorized target is
left alone, since its escapes are deliberate.
Copilot AI review requested due to automatic review settings July 25, 2026 12:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jul 25, 2026
Rename the two fixture manifests off single-letter bindings, which the
`perfectionist::single-letter-let-binding` rule rejects — the rename was
made but never committed, so CI caught what the pre-push hook had
already flagged locally.

Also key the choice deduplication on borrowed names: the outdated set
outlives the map, so the alias and package name need not be cloned.
kairosci added a commit to kairosci/pnpm that referenced this pull request Jul 27, 2026
…rom (pnpm#13337)

Inside a workspace the interactive update list showed no way to tell
which project an outdated dependency belonged to, so the same package
outdated in two projects rendered as two indistinguishable rows.

Every outdated entry now records the name of the project it was
collected from, and the interactive list gains the `Workspace` column
upstream shows when workspaces are enabled. The name is read where the
collector already has the manifest in hand, so nothing new is threaded
through; it is stripped of control characters with the rest of the row.

This completes the interactive parity item of pnpm#12101, whose
remaining half after the grouping landed was this column.

Related to pnpm#12101.
kairosci added a commit to kairosci/pnpm that referenced this pull request Jul 27, 2026
)

The `Workspace` column falls back to the project's lockfile path when a
workspace project declares no `name` or an empty one, because either
renders a blank label. A name of `"   "` is truthy and non-empty, so it
slipped past that guard and rendered just as blank.

Both stacks now trim before deciding, and the fallback tests cover the
absent, empty, and whitespace-only shapes together.

Follow-up to pnpm#13337, which landed the column and the first two
shapes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product: pacquet product: pnpm@11 reviewed: coderabbit CodeRabbit submitted an approving review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants