vscode: IDE-mode foundation: dual-mode activation, workspace/IDE context keys, empty-window surfaces#1148
Merged
Conversation
…ys, empty-window surfaces
…ivation welcome flash
…(drop ancestor walk)
Collaborator
Author
Architect Integration ReviewRisk triage: +877/−37 over 15 files, confined to
Open cross-repo item (non-blocking): the codev-ide fork's rebrand must set Approving the pr gate. Architect integration review |
amrmelsayed
added a commit
that referenced
this pull request
Jul 8, 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.
PIR Review: VSCode IDE-mode foundation (dual-mode activation, context keys, empty-window surfaces)
Fixes #1144
Summary
The extension now has an explicit workspace-free layer model. A pure activation-tier decision (
full/ide-empty/dormant, computed in the newsrc/ide-mode.tsfromvscode.env.appNameplus codev-workspace detection) gates every activation side effect, soonStartupFinishedcan safely runactivate()in every window of every marketplace install: a guest window with no codev workspace is provably inert (no Tower auto-start, no preflight, no focus steal, no status bar, no state writes). IDE mode (appName === CODEV_IDE_APP_NAME, a single-sourced cross-repo contract with the fork's product.json) gets the empty-window onboarding surface: container focus, per-quadrantviewsWelcomecontent, and a one-time first-run notification that opens the existing Getting Started walkthrough. The original Part 1 bug (dead Spawn Builder / New Shell rows in a no-workspace window) is fixed bywhen-gating the workspace-bound views on the newcodev.hasWorkspacecontext key.Deviations From the Approved Plan (agreed at the dev-approval gate)
Three changes emerged from the human's hands-on review of the running worktree, each explicitly agreed before implementation:
codev.stateKnowncontext key + "Loading Codev…" welcome. Unset context keys evaluate to false, so during the workbench-restore-to-activation gap the guest welcome ("Open a folder…") flashed inside real codev workspaces, and VS Code's raw "no data provider registered" message showed afterwards. BothviewsWelcomequadrants now requirecodev.stateKnown(set first-thing inactivate()), and a!codev.stateKnown"Loading Codev…" entry covers the pre-activation window.findProjectRootwalked up to the filesystem root; any folder under a codev-enabled home directory (the reviewer's real setup:~/codev+~/.codevexist) inherited that workspace, connected to Tower, and rendered live workspace rows in unrelated projects. Detection is now "the opened folder itself containscodev/or.codev/", with thecodev.workspacePathsetting as the escape hatch. This matches CLI semantics (afx runs from the workspace root; worktrees carry their owncodev/copy so they still match directly). Trade-off accepted: a window opened on a subfolder of a codev repo is now dormant.codev.hasWorkspacemeans codev-workspace-presence, not folder-presence. The issue's literal definition (workspaceFolders?.length > 0) would still render the Workspace view's static action rows in a non-codev folder window (the Part 1 bug, one level up). The key is nowdetectWorkspacePath() !== null.Files Changed
packages/vscode/src/ide-mode.ts(+124 / -0) — new:CODEV_IDE_APP_NAME,detectIdeMode(with the Development-mode-onlyCODEV_SIMULATE_IDE=1seam),decideActivationTier,activationPolicypackages/vscode/src/extension.ts(+113 / -9) — tier computed before any side effect; three context keys; five gated side effects; IDE first-run surface;codev.openGettingStartedpackages/vscode/src/workspace-detector.ts(+25 / -16) — ancestor walk removed;isCodevWorkspaceRootpackages/vscode/package.json(+25 / -7) —onStartupFinished; viewwhengates;viewsWelcome(loading + two quadrants)packages/vscode/src/preflight/preflight.ts(+9 / -3) — exportopenWalkthrough/maybeOpenWalkthroughpackages/vscode/src/__tests__/ide-mode.test.ts(+99),contributes-view-gating.test.ts(+144),workspace-detector.test.ts(+95) — new test filescodev/resources/arch.md(+3 / -1),codev/resources/lessons-learned.md(+2 / -0) — governance updates (below)codev/plans/1144-…md(+107),codev/state/pir-1144_thread.md(+29),codev/projects/…/status.yaml(+22) — protocol artifactsCommits
18eb3da0[PIR vscode: IDE-mode foundation: dual-mode activation, workspace/IDE context keys, empty-window surfaces #1144] Dual-mode activation: tier-gated side effects, context keys, empty-window surfaces57f1531d[PIR vscode: IDE-mode foundation: dual-mode activation, workspace/IDE context keys, empty-window surfaces #1144] Tests: behavior-matrix policy + package.json gating invariantsc18f3a01[PIR vscode: IDE-mode foundation: dual-mode activation, workspace/IDE context keys, empty-window surfaces #1144] Gate viewsWelcome on codev.stateKnown to kill the pre-activation welcome flash3a4b2e51[PIR vscode: IDE-mode foundation: dual-mode activation, workspace/IDE context keys, empty-window surfaces #1144] Replace the raw no-provider message with a Loading Codev placeholder40028e77[PIR vscode: IDE-mode foundation: dual-mode activation, workspace/IDE context keys, empty-window surfaces #1144] Detection: the opened folder must itself be a codev root (drop ancestor walk)555633a4[PIR vscode: IDE-mode foundation: dual-mode activation, workspace/IDE context keys, empty-window surfaces #1144] codev.hasWorkspace means codev-workspace-presence, not folder-presenceTest Results
pnpm compile(check-types + lint + esbuild): ✓ passpnpm test:unit: ✓ pass — 578 tests, 31 new across the three new filespnpm --filter @cluesmith/codev-types --filter @cluesmith/codev-core --filter @cluesmith/codev-artifact-canvas buildbefore the extension compiles (known pattern, lesson From vscode: builder briefly appears under 'Uncategorized' area group after cleanup before disappearing #907).Architecture Updates
Routed to COLD
codev/resources/arch.md(VS Code Extension → Key Design Decisions): a new "IDE-mode dual activation + layer model (#1144)" entry covering the runtime appName contract, the activation-tier/policy model and its inertness guarantee, the three context keys and their exact semantics, and the runtime-code-only constraint on first-launch surfaces. Also corrected the architecture diagram's WorkspaceDetector line (it described the now-removed ancestor walk). Nothing routed to the HOT tier: the layer model is load-bearing but extension-scoped, not a cross-cutting fact that should displace an existing hot entry.Lessons Learned Updates
Routed to COLD
codev/resources/lessons-learned.md:when/viewsWelcomeclauses assert wrong states during the pre-activation gap; thestateKnown-key + loading-welcome pattern.Nothing routed to the HOT tier: both lessons are situation-specific recipes, not behavior-changing cross-cutting rules worth a displacement.
Things to Look At During PR Review
ide-mode.ts:32—CODEV_IDE_APP_NAME = 'Codev'is the cross-repo contract with the fork's product.jsonnameLong. The fork rebrand has not landed and the final string ('Codev' vs 'Codev IDE') is still being confirmed; it is single-sourced so a differing confirmed value is a one-line edit (tests import the constant).connectionManager.initialize(). Anything added toactivate()in the future that has a side effect must consultactivationPolicy— the policy object is the checklist.workspace-detector.ts) affects which Tower workspace every window attaches to, not just view visibility. Subfolder-of-repo windows now go dormant by design; thecodev.workspacePathsetting override is the documented escape hatch.ide-mode.ts.How to Test Locally
packages/vscode, F5):afx tower stop, launch EDH with no folder → no process on port 4100, no status bar, no toasts; Codev icon shows Agents with the guest welcome only.CODEV_SIMULATE_IDE=1, no folder → container focused, IDE welcome (Open Folder / Open Recent / Get Started), first-run toast + walkthrough once, not on relaunch.pnpm --filter codev-vscode test:unit