[PIR #793] vscode: generalize viewPlanFile to viewSpecFile + viewReviewFile - #908
Merged
Conversation
- 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).
…expand review file
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
added a commit
that referenced
this pull request
May 28, 2026
amrmelsayed
added a commit
that referenced
this pull request
May 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Generalises the existing
codev.viewPlanFilecommand (previously PIR-only) into a sibling trio with protocol-aware right-click menu visibility on the Builders tree:codev.viewSpecFile(new) — visible on SPIR / ASPIRcodev.viewPlanFile— extended from PIR-only to SPIR / ASPIR / PIRcodev.viewReviewFile(new) — visible on SPIR / ASPIR / AIR always; PIR only when an on-disk review file existsCloses #793 and unblocks #792.
Design notes
view-artifact.tswas already kind-generic — most of the change is declarative (ArtifactKindwidened, two thin wrappers, two new command registrations, threeview/item/contextwhenclauses).-reviewsuffix on the Builders-tree row'scontextValue, driven by areaddirSyncagainst<worktree>/codev/reviews/. TheviewReviewFilewhenclause 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 theviewItemstring to work with —setContextis global and can't express per-row state.)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 newview/item/contextentries (replacing the old single PIR-onlyviewPlanFileentry)packages/vscode/src/__tests__/menu-when-clauses.test.ts— new visibility-matrix test (97 LOC, 38 cases)packages/vscode/src/commands/view-artifact.ts— widenedArtifactKind, addedviewSpecFile/viewReviewFilewrappers, rewrote stale docblockpackages/vscode/src/extension.ts— registered the two new commandspackages/vscode/src/views/builders.ts—-reviewsuffix oncontextValue+builderHasReviewFilehelperTest plan
pnpm check-types) ✓pnpm test:unit) ✓ — 75/75 including the 38 new matrix casesafx dev pir-793and exercised the menu visibility on live builder rowsOut of scope
packages/codev/(adopt.test.ts,update.test.ts,consult.test.ts,session-manager.test.tsreal-shellper integration) — none touch any file in this diff, none have failure traces throughpackages/vscode/. Noted in the review's Lessons Learned for follow-up.See
codev/plans/793-vscode-generalize-viewplanfile.mdandcodev/reviews/793-vscode-generalize-viewplanfile.mdon this branch for the full plan and review.