Skip to content

feat: pipelineCheck.scanWorkspace + refresh-as-scan (R10, R15)#19

Merged
dmartinochoa merged 3 commits into
mainfrom
scan-workspace-v2
May 19, 2026
Merged

feat: pipelineCheck.scanWorkspace + refresh-as-scan (R10, R15)#19
dmartinochoa merged 3 commits into
mainfrom
scan-workspace-v2

Conversation

@dmartinochoa
Copy link
Copy Markdown
Member

@dmartinochoa dmartinochoa commented May 19, 2026

Summary

Re-applies the stranded `scan-workspace` work cleanly on top of current main. Closes R10 (refresh-as-scan) and R15 (`onCommand:scanWorkspace` activation — handled implicitly by VS Code's auto-generated activation events from `contributes.commands`).

What lands

New `pipelineCheck.scanWorkspace` command

  • Walks every CI/config file in the workspace, matching the same patterns the LSP's `documentSelector` uses.
  • Opens each via `vscode.workspace.openTextDocument` so the LSP's `didOpen` pipeline picks them up — no separate state, no JSON parser to keep in sync with the upstream CLI.
  • Progress toast with cancellation; per-file failures (read errors, unsupported encodings) are counted but don't abort the scan.
  • Surfaced at three places:
    • `$(play)` button on the Findings view title bar (leftmost, `navigation@0`)
    • Command Palette
    • `[Scan workspace]` link in the Findings welcome state

"Refresh Findings" repurposed (R10)

Used to be a tree-only re-render. Now triggers a real scan, matching the user's mental model: a refresh icon should fetch fresh data, not re-render stale data.

Drift eliminated

`workspaceScan.ts` reads `TRIGGER_PATTERNS` from `providers.ts`. Combined with the existing `documentSelector` and `activationEvents`, all three surfaces now share one list.

Files

File Change
src/workspaceScan.ts New — re-applied with `TRIGGER_PATTERNS` import
src/workspaceScan.test.ts 8 tests for `buildScanGlob` + `formatSummary` (pattern-list assertion is redundant with `providers.test.ts`; dropped)
src/extension.ts `registerCommand` for both `scanWorkspace` and the re-pointed `findings.refresh`
package.json Command, view/title `$(play)` button, welcome-state link
src/test/integration/activation.test.ts Expected-commands list grows by `pipelineCheck.scanWorkspace`
CHANGELOG.md New `Unreleased` block with R10 + R15 entries

Test plan

  • `npm run lint` clean
  • `npm run compile` clean
  • `npm test` — 107 tests pass (was 99 on main; +8 workspaceScan)
  • `npm run smoke` clean
  • `npm run test:integration:compile` clean
  • Manual smoke under F5: open the sample-workflow fixture; confirm:
    • Findings welcome state shows the `[Scan workspace]` link
    • Click `$(play)` in the view title bar → progress toast appears → Findings panel populates
    • Clicking "Refresh" (the `$(refresh)` button) re-scans (was a no-op for closed files before)
    • Cancel during scan → toast shows partial-cancelled summary

Notes

  • The old `origin/scan-workspace` branch can be deleted after this lands; its content is preserved in this PR's history.
  • `SCAN_PATTERNS` was removed (renamed to `TRIGGER_PATTERNS` upstream). Any external code referencing it would need to update — but nothing outside this extension does, since it was internal.
  • VS Code 1.74+ auto-generates `onCommand:` activation events from `contributes.commands`. The IDE flagged the explicit entry as redundant; removed.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added "Scan Workspace" command to scan CI/config files across the workspace with progress, cancellation, and graceful partial-failure handling.
    • One-time "What's new" toast shown after upgrades.
    • Status bar background now reflects highest finding severity.
  • Enhancements

    • "Refresh Findings" now triggers a real workspace scan.
    • Activation and view messaging updated to support workspace-based scanning workflow.
  • Documentation

    • Updated changelog and README badges.
  • Tests

    • Added and updated unit/integration tests covering scan, status bar, and upgrade toast.

Review Change Stack

The pre-v0.2.0 `scan-workspace` branch was stranded with merge
conflicts in package.json and src/extension.ts. This commit
re-applies the work cleanly on top of current main, taking advantage
of the v0.2.0 infrastructure (providers.ts as the single source of
truth, the shared test stub, the title-case command convention).

What it does
- New `pipelineCheck.scanWorkspace` command walks every CI/config
  file in the workspace (matching the same patterns the LSP's
  documentSelector uses), opens each via openTextDocument so the
  LSP's didOpen pipeline produces diagnostics, and lets the Findings
  panel re-render as publishes arrive. Progress toast with
  cancellation; per-file failures are counted but never abort the
  whole scan.
- `Refresh Findings` (the title-bar button) now triggers a real scan
  instead of re-rendering the tree from already-published
  diagnostics. Matches the user's mental model: a refresh icon
  should fetch fresh data, not re-paint stale data. (R10)
- `onCommand:pipelineCheck.scanWorkspace` activation event is
  auto-generated by VS Code from the contributes.commands entry —
  no explicit declaration needed in activationEvents. (R15 closed
  by VS Code's own behaviour.)

What it ties together
- workspaceScan.ts imports TRIGGER_PATTERNS from providers.ts, so
  the documentSelector, the activationEvents, and the workspace
  scan all read from one list. No drift.
- The scan command appears at three surfaces: a `$(play)` button on
  the Findings view title bar (group navigation@0, leftmost), the
  Command Palette, and a link in the Findings welcome state.

Files
- src/workspaceScan.ts: re-applied with TRIGGER_PATTERNS import.
- src/workspaceScan.test.ts: 8 tests for buildScanGlob + formatSummary
  (the pattern-list assertion was redundant with providers.test.ts —
  dropped).
- src/extension.ts: registerCommand for both scanWorkspace and the
  re-pointed findings.refresh.
- package.json: command, view/title button (group 0, leftmost),
  Command Palette entry, welcome-state link.
- CHANGELOG.md: new Unreleased block with R10 + R15 entries.
- src/test/integration/activation.test.ts: command-registration
  expected list grows by pipelineCheck.scanWorkspace.

Total: 107 unit tests pass (was 99). Lint, compile, smoke,
integration-compile all green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ef4677d0-6bfa-4173-9fe5-c8d96d88769e

📥 Commits

Reviewing files that changed from the base of the PR and between 863e202 and 14c494e.

📒 Files selected for processing (8)
  • CHANGELOG.md
  • README.md
  • package.json
  • src/extension.ts
  • src/statusBar.test.ts
  • src/statusBar.ts
  • src/whatsNew.test.ts
  • src/whatsNew.ts

📝 Walkthrough

Walkthrough

This PR adds a new Scan Workspace command that discovers CI/config files across the workspace and triggers diagnostics via LSP didOpen. Refresh Findings now performs a real scan. It also adds a one-time “what’s new” upgrade toast and status-bar background color selection; tests and manifest/welcome text are updated.

Changes

Workspace Scan Feature

Layer / File(s) Summary
Workspace scan module and tests
src/workspaceScan.ts, src/workspaceScan.test.ts
buildScanGlob() converts trigger patterns into a brace-glob; ScanResult tracks scanned/failed/cancelled counts; scanWorkspace() finds files, opens each via openTextDocument() to trigger LSP didOpen diagnostics with cancellable progress and per-file failure tolerance; formatSummary() formats results. Unit tests verify glob formatting defaults and summary text variants (pluralization, failures, cancellation, zero files).
Command registration, manifest contributions, activation test, and docs
src/extension.ts, package.json, src/test/integration/activation.test.ts, CHANGELOG.md, README.md
scanWorkspace is imported and pipelineCheck.scanWorkspace registered; pipelineCheck.findings.refresh now invokes scanWorkspace(); package.json adds the command, view-title menu entry, updates viewsWelcome text, and relies on workspaceContains activation globs; activation test asserts the new command is registered; CHANGELOG and README updated.
What's New notification and tests
src/whatsNew.ts, src/whatsNew.test.ts
Adds isUpgrade, composeMessage, and showWhatsNewIfUpgraded() which persist last-seen version, show a one-time information prompt on upgrade, and optionally open release notes. Tests cover semver comparisons, message content, persistence behavior, and UI interactions.
Status-bar background color and tests
src/statusBar.ts, src/statusBar.test.ts
Adds pickBackgroundColor() mapping highest nonzero severity to theme background tokens and wires it into live status-bar updates; tests extend the vscode mock with ThemeColor and assert color selection logic.

Sequence Diagram

sequenceDiagram
  participant User
  participant FindingsView as Findings View
  participant Command as pipelineCheck.scanWorkspace
  participant Scan as scanWorkspace
  participant Workspace as vscode.workspace
  participant Window as vscode.window
  participant LSP as Language Server
  User->>FindingsView: Click Scan workspace (view title)
  FindingsView->>Command: trigger command
  Command->>Scan: scanWorkspace()
  Scan->>Workspace: findFiles(glob, exclude)
  Workspace-->>Scan: candidate URIs
  Scan->>Window: withProgress(cancellableToken)
  loop for each candidate
    Scan->>Workspace: openTextDocument(uri)
    Workspace->>LSP: didOpen (diagnostic request)
    LSP-->>Workspace: diagnostics published
  end
  Scan-->>Window: showInformationMessage / showWarningMessage with counts
  Window-->>User: toast summary
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I hopped through the files, a curious spree,
Opening configs so diagnostics run free,
A toast said hello when the version was new,
The status bar blushed with the severities true,
nibbles a carrot, then hops off with glee

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: introducing the pipelineCheck.scanWorkspace command and implementing refresh-as-scan behavior, with reference to the addressed requirements (R10, R15).
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch scan-workspace-v2

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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
src/workspaceScan.test.ts (1)

11-17: ⚡ Quick win

Add targeted tests for scanWorkspace cancellation/failure accounting.

This suite is strong on pure logic, but the scan loop itself is the highest-risk path. A couple mocked tests for cancel + partial failures would lock down behavior regressions.

🤖 Prompt for 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.

In `@src/workspaceScan.test.ts` around lines 11 - 17, The tests are missing
coverage for scan loop cancellation and partial failure accounting in
scanWorkspace; add targeted unit tests that mock the async scan loop to simulate
a user cancellation and a mix of file-processing failures, then assert that
scanWorkspace returns/throws the expected cancellation signal and that the final
summary counts (failed/cancelled/processed) and user-facing summary text reflect
those outcomes. Locate and exercise the scanWorkspace function (and reuse
buildScanGlob for input shape) while stubbing the file
iteration/openTextDocument/findFiles behavior (or the provider used by
providers.test.ts) to produce controlled errors and an early cancellation, and
assert the summary string and any returned result object reports the correct
failed and cancelled counts. Ensure tests are isolated and deterministic (use
jest mocks/fakes for async timing) and add them alongside the existing
pure-logic suite.
src/workspaceScan.ts (1)

92-94: ⚡ Quick win

Add per-file error context in the failure path.

Right now failures are only counted, so users/devs can’t tell which file failed to open. Logging the URI + error message here makes scan failures actionable.

Suggested diff
-        } catch {
+        } catch (error) {
           failed += 1;
+          console.warn(
+            `[Pipeline-Check] scanWorkspace: failed to open ${uri.fsPath}: ${
+              error instanceof Error ? error.message : String(error)
+            }`,
+          );
         }
🤖 Prompt for 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.

In `@src/workspaceScan.ts` around lines 92 - 94, The catch block that only
increments failed (in src/workspaceScan.ts around the code that opens files—look
for the loop/handler using the failed variable, e.g., the function that scans
files or processes a single file) should log per-file error context: capture the
file URI/identifier (the same variable used to open/read the file, e.g.,
fileUri, uri, or path) and the caught error and emit a clear error message
(using the module's logger or console if no logger exists) instead of silently
incrementing failed; update the catch to accept the error (catch (err)) and call
processLogger.error or console.error with a message like "Failed to process
<fileUri>: <err.message>" and increment failed afterward.
🤖 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.

Nitpick comments:
In `@src/workspaceScan.test.ts`:
- Around line 11-17: The tests are missing coverage for scan loop cancellation
and partial failure accounting in scanWorkspace; add targeted unit tests that
mock the async scan loop to simulate a user cancellation and a mix of
file-processing failures, then assert that scanWorkspace returns/throws the
expected cancellation signal and that the final summary counts
(failed/cancelled/processed) and user-facing summary text reflect those
outcomes. Locate and exercise the scanWorkspace function (and reuse
buildScanGlob for input shape) while stubbing the file
iteration/openTextDocument/findFiles behavior (or the provider used by
providers.test.ts) to produce controlled errors and an early cancellation, and
assert the summary string and any returned result object reports the correct
failed and cancelled counts. Ensure tests are isolated and deterministic (use
jest mocks/fakes for async timing) and add them alongside the existing
pure-logic suite.

In `@src/workspaceScan.ts`:
- Around line 92-94: The catch block that only increments failed (in
src/workspaceScan.ts around the code that opens files—look for the loop/handler
using the failed variable, e.g., the function that scans files or processes a
single file) should log per-file error context: capture the file URI/identifier
(the same variable used to open/read the file, e.g., fileUri, uri, or path) and
the caught error and emit a clear error message (using the module's logger or
console if no logger exists) instead of silently incrementing failed; update the
catch to accept the error (catch (err)) and call processLogger.error or
console.error with a message like "Failed to process <fileUri>: <err.message>"
and increment failed afterward.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8e5789e9-d7fa-41b3-b165-6023d3ab4ee0

📥 Commits

Reviewing files that changed from the base of the PR and between 4507a25 and 863e202.

📒 Files selected for processing (6)
  • CHANGELOG.md
  • package.json
  • src/extension.ts
  • src/test/integration/activation.test.ts
  • src/workspaceScan.test.ts
  • src/workspaceScan.ts

Stacked on scan-workspace-v2 (#19). Two UX improvements from the
post-v0.2.0 review.

1. Status bar severity color
- pickBackgroundColor returns statusBarItem.errorBackground (red)
  when CRITICAL is present, statusBarItem.warningBackground (yellow)
  for HIGH-without-CRITICAL, undefined for MEDIUM/LOW/INFO. Same
  ThemeColor tokens ESLint and Error Lens use, so the visual
  language reads correctly across themes.
- The default fg colour for medium/low/info keeps a "1 medium"
  workspace from shouting.

2. What's-new notification (src/whatsNew.ts)
- First activation after a version bump shows a one-time toast.
  "See release notes" opens the matching GitHub release URL via
  vscode.env.openExternal.
- isUpgrade compares the manifest version against the value stashed
  in globalState; strips a leading 'v' and any pre-release suffix
  (-rc.1) so a stable release after an rc doesn't re-trigger.
- The seen-version persists BEFORE the notification fires, so a
  missed dismissal doesn't loop next launch.
- composeMessage and isUpgrade are pure helpers; the test file
  pins every documented invariant.

Also riding along (user-intentional edits already in the working tree)
- package.json: dropped onStartupFinished from activationEvents — the
  activity-bar slot only appears in CI-relevant workspaces, matching
  the status bar's already-quieter visibility policy.
- package.json: expanded untrustedWorkspaces.description to explain
  the machine-overridable scope on serverCommand/serverArgs. Better
  copy for the trust prompt VS Code shows on first open.
- README.md: Socket supply-chain badge added.

Tests
- statusBar.test.ts: 5 new tests for pickBackgroundColor (critical /
  high-without-critical / medium-only / clean / mixed). Updated the
  inline vscode stub to expose ThemeColor.
- whatsNew.test.ts (new): 17 tests across isUpgrade (first install,
  major/minor/patch upgrades, downgrade, equal, pre-release strip,
  leading-v strip, malformed prev), composeMessage (version
  interpolation, mentions every surface), and showWhatsNewIfUpgraded
  (shows on first install, skips on match, persists before showing,
  opens URL on click, doesn't open on dismiss, supports custom
  openExternal for tests).

Total: 129 unit tests (was 107 on PR #19; +5 status bar, +17 whatsNew).
Lint, compile, smoke all green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ux: status bar severity color + what's-new notification
@dmartinochoa dmartinochoa merged commit 60590c5 into main May 19, 2026
9 checks passed
@dmartinochoa dmartinochoa deleted the scan-workspace-v2 branch May 19, 2026 23:46
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.

1 participant