Skip to content

[PIR #793] vscode: generalize viewPlanFile to viewSpecFile + viewReviewFile - #908

Merged
amrmelsayed merged 17 commits into
mainfrom
builder/pir-793
May 28, 2026
Merged

[PIR #793] vscode: generalize viewPlanFile to viewSpecFile + viewReviewFile#908
amrmelsayed merged 17 commits into
mainfrom
builder/pir-793

Conversation

@amrmelsayed

Copy link
Copy Markdown
Collaborator

Summary

Generalises the existing codev.viewPlanFile command (previously PIR-only) into a sibling trio with protocol-aware right-click menu visibility on the Builders tree:

  • codev.viewSpecFile (new) — visible on SPIR / ASPIR
  • codev.viewPlanFile — extended from PIR-only to SPIR / ASPIR / PIR
  • codev.viewReviewFile (new) — visible on SPIR / ASPIR / AIR always; PIR only when an on-disk review file exists

Closes #793 and unblocks #792.

Design notes

  • The dispatcher in view-artifact.ts was already kind-generic — most of the change is declarative (ArtifactKind widened, two thin wrappers, two new command registrations, three view/item/context when clauses).
  • The one piece of real new logic is a -review suffix on the Builders-tree row's contextValue, driven by a readdirSync against <worktree>/codev/reviews/. The viewReviewFile when clause keys off that suffix so PIR rows hide the menu entry until the review phase produces the file. (Per-row VSCode menu gating has only the viewItem string to work with — setContext is global and can't express per-row state.)
  • A new vitest matrix (src/__tests__/menu-when-clauses.test.ts) pins the visibility table across protocol × state-family × has-review-file (38 cases). The three regexes are the only gate on menu visibility — no compile-time or runtime error catches a drift, so the matrix is the source of truth.

Files changed

  • packages/vscode/package.json — two new command declarations + three new view/item/context entries (replacing the old single PIR-only viewPlanFile entry)
  • packages/vscode/src/__tests__/menu-when-clauses.test.ts — new visibility-matrix test (97 LOC, 38 cases)
  • packages/vscode/src/commands/view-artifact.ts — widened ArtifactKind, added viewSpecFile / viewReviewFile wrappers, rewrote stale docblock
  • packages/vscode/src/extension.ts — registered the two new commands
  • packages/vscode/src/views/builders.ts-review suffix on contextValue + builderHasReviewFile helper

Test plan

  • Type-check (pnpm check-types) ✓
  • vitest unit suite (pnpm test:unit) ✓ — 75/75 including the 38 new matrix cases
  • Reviewer ran the worktree via afx dev pir-793 and exercised the menu visibility on live builder rows
  • CMAP-2 (single advisory pass at PR, per PIR protocol) — triggered post-PR

Out of scope

  • 23 pre-existing test failures in packages/codev/ (adopt.test.ts, update.test.ts, consult.test.ts, session-manager.test.ts real-shellper integration) — none touch any file in this diff, none have failure traces through packages/vscode/. Noted in the review's Lessons Learned for follow-up.

See codev/plans/793-vscode-generalize-viewplanfile.md and codev/reviews/793-vscode-generalize-viewplanfile.md on this branch for the full plan and review.

- Widen ArtifactKind to plan | spec | review and extend ARTIFACT_SUBDIR.
- Add viewSpecFile and viewReviewFile wrappers next to viewPlanFile.
- Register codev.viewSpecFile and codev.viewReviewFile in extension.ts.
- Declare the two new commands in package.json.
- Rewrite view-artifact.ts docblock: drop the PIR-specific framing and the
  stale 'View Review File was intentionally not added' note; document
  that the PIR menu-hide rule for missing review files lives in the row's
  contextValue (views/builders.ts) and the matching when clause.
…ew menu

views/builders.ts: add builderHasReviewFile() — a sync readdir on the
worktree's codev/reviews/ filtered by builder-ID prefix. When a review
file exists the row's contextValue gets a '-review' suffix, which the
package.json view/item/context when clauses use to:

  - viewSpecFile:    show for SPIR / ASPIR (any -review suffix optional)
  - viewPlanFile:    show for SPIR / ASPIR / PIR (-review optional)
  - viewReviewFile:  show for SPIR / ASPIR / AIR always; for PIR only
                     when -review is present (rather than fallback-
                     opening the GitHub PR URL — explicitly rejected in
                     the issue).

The non-PIR protocols always show the entry; the existing missing-file
toast in view-artifact.ts handles the rare absence (e.g. pre-review-phase).

Adds menu-when-clauses.test.ts which parses package.json, extracts the
three viewItem regexes, and asserts the full visibility matrix across
(protocol × state-family × has-review-file) — including the two
PIR-specific cases (no review file hides; with review file shows).
Integrate area-grouping refactor from main into makeBuilderRow:
keep main's per-row method structure, apply this branch's family
if/else chain + -review contextValue suffix into it. No behavior
change beyond the union of both branches.

Verified: pnpm check-types + pnpm test:unit (95/95 pass, including
the 41 menu-when-clauses cases from this branch and main's new
area-grouping tests).
@amrmelsayed
amrmelsayed merged commit 230f78d into main May 28, 2026
6 checks passed
amrmelsayed added a commit that referenced this pull request May 28, 2026
amrmelsayed added a commit that referenced this pull request May 28, 2026
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.

vscode: generalize viewPlanFile to siblings (viewSpecFile, viewReviewFile) with protocol-aware menu visibility

1 participant