Skip to content

[#1727] vscode: declare untrustedWorkspaces support so Codev activates in Restricted Mode - #1728

Merged
amrmelsayed merged 7 commits into
mainfrom
builder/air-1727
Sep 28, 2026
Merged

amrmelsayed merged 7 commits into
mainfrom
builder/air-1727

Conversation

@amrmelsayed

Copy link
Copy Markdown
Collaborator

What & why

apps/vscode/package.json declared no capabilities.untrustedWorkspaces, so VS Code treated codev-vscode as unsupported in Restricted Mode and did not activate it until the folder was trusted. On first open of any untrusted repo the Codev sidebar was inert, the status-bar item absent, and the Workspace Trust dialog counted Codev among the disabled extensions — the wrong first impression for the extension that is the point of the product.

This is a manifest-only change (plus tests). It declares "limited" untrusted-workspace support so the extension activates immediately, and marks the four settings a hostile cloned repo could weaponize as restricted so their workspace-scope values are ignored until the folder is trusted. The sidebar, Tower status, agent list and spawn all work in Restricted Mode using user/global settings; only the four workspace-scoped values below are withheld.

Closes #1727.

Manifest changes (apps/vscode/package.json)

"capabilities": {
  "virtualWorkspaces": false,
  "untrustedWorkspaces": {
    "supported": "limited",
    "description": "Codev works in Restricted Mode. Workspace-provided Tower connection and auto-start settings are ignored until the folder is trusted.",
    "restrictedConfigurations": [
      "codev.towerHost", "codev.towerPort", "codev.workspacePath", "codev.autoStartTower"
    ]
  }
}

Plus "restricted": true on each of those four property definitions under contributes.configuration (so the Settings UI shows the lock and VS Code withholds workspace-scope values while untrusted). The restriction is declared in both places; a test keeps the two lists in sync.

virtualWorkspaces: false — explicit decision

false is the honest value. The extension shells out to afx/git child processes and reads the local filesystem (workspace detection, worktree config, PTY-backed terminals). A virtual workspace has no local FS — no codev CLI, no Tower, no PTYs — so the sidebar genuinely cannot function there. Declaring true would promise something the extension cannot deliver.

Settings audit (re-derived, not remembered)

All 22 codev.* keys, checked against every getConfiguration(...) read in apps/vscode/src. A setting is restricted only if a workspace-scope value from a cloned repo could redirect an endpoint, re-root the workspace, or launch a process. Exactly four qualify:

Setting Restricted? Why
codev.towerHost yes Redirects the Tower endpoint (every client call, PTY websocket, auth key)
codev.towerPort yes Redirects the Tower endpoint
codev.workspacePath yes Re-roots the workspace; is the cwd for afx spawn/cleanup/approve child processes
codev.autoStartTower yes Launches a process on activation (tower-starter.ts)
codev.autoConnect no Only connects to the already-restricted host; changes no target
codev.cliVersionTimeoutMs no Bounds the preflight codev --version call; cannot change what is run
codev.terminalPosition no UI: editor vs panel
codev.terminalLinks.issueTarget no UI: where a #N link opens
codev.diffCodelensMode no UI: codelens action
codev.maxTerminals no Threshold
codev.terminal.repaintOnRefocus no UI toggle
codev.autoOpenBuilderTerminal no UI toggle
codev.gateToasts.enabled no UI toggle
codev.mailboxEscalationToasts.enabled no UI toggle
codev.overviewRefreshSeconds no Interval
codev.buildersAutoCollapse no UI toggle
codev.buildersFileViewAsTree no UI toggle
codev.buildersAutoReveal no UI toggle
codev.backlogShowAll no UI toggle
codev.buildersGroupBy no UI axis
codev.markdownPreview.fontSize no Font size
codev.markdownPreview.lineHeight no Line height

The 18 non-restricted keys are UI toggles, intervals, thresholds and font sizes; none resolves to a command, path or endpoint, so they keep working from workspace scope even while untrusted.

Tests

  • src/__tests__/contributes-untrusted-workspace.test.ts — manifest parity: supported: "limited", the description, the exact restrictedConfigurations list, virtualWorkspaces: false, "restricted": true on the four property defs, list↔flags sync, and the audit assertion that no other codev.* key is restricted.
  • src/__tests__/untrusted-workspace-config.test.ts — runtime behavior: getTowerAddress() reads the safe global endpoint while untrusted (workspace-scope evil.example:6666 is ignored) and the workspace endpoint once trusted; detectWorkspacePath() resolves a real codev project to itself, not $HOME, while untrusted, and never adopts a workspace for a plain untrusted project (guard against a vscode: an empty window adopts $HOME as the workspace and badges unrelated held mail #1722 regression — the two fixes cannot regress each other; vscode: an empty window adopts $HOME as the workspace and badges unrelated held mail #1722 is not fixed here).

Full vscode unit suite: 85 files / 1035 tests pass. check-types and lint clean. (The suite needs pnpm --filter 'codev-vscode^...' build first to build the codev-sdk subpath exports — a build-prerequisite artifact, unrelated to this change.)

Packaging

Standard schema field since VS Code 1.57; engine is already ^1.105.0. vsce package / ovsx publish are unaffected. Behavior is host-independent (stock VS Code, Cursor, any fork).

Scope / fences

package.json hunk limited to the capabilities block and the four restricted flags (shared file with pir-1566). No changes to views/tower*.ts, workspace-label.ts, fleet-order.ts, attention-format.ts, switch-workspace.ts, or icons/tower.svg. Changelog is the vscode architect's on the changelog branch after merge. AIR: no spec/plan/review files; this review lives in the PR body.

…v activates in Restricted Mode

Without a capabilities.untrustedWorkspaces declaration VS Code treats the
extension as unsupported in Restricted Mode and does not activate it until the
folder is trusted, leaving the sidebar and status bar dead on first open of any
untrusted repo and counting Codev among the disabled extensions in the Trust
dialog.

Declare "limited" support so the extension activates immediately. The four
settings a hostile cloned repo could weaponize via .vscode/settings.json are
marked restricted (both in restrictedConfigurations and with "restricted": true
on each property definition), so their workspace-scope values are ignored while
untrusted: towerHost/towerPort (redirect the Tower endpoint), workspacePath
(re-roots the workspace / afx child-process cwd), autoStartTower (launches a
process on activation). The other 18 codev.* keys are UI toggles, intervals,
thresholds and font sizes and keep working from workspace scope.

virtualWorkspaces is false: the extension shells out to afx/git and reads the
local filesystem, so it cannot function without one.

Tests: manifest parity for the declaration and the exact restricted set, plus
runtime coverage that getTowerAddress reads the safe global endpoint while
untrusted and that workspace-path resolution stays trust-independent and never
adopts $HOME (#1722 guard).
@amrmelsayed
amrmelsayed merged commit 2817c2f into main Sep 28, 2026
7 checks passed
@amrmelsayed
amrmelsayed deleted the builder/air-1727 branch September 28, 2026 22:22
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: declare untrustedWorkspaces support so Codev activates in Restricted Mode (currently disabled until the folder is trusted)

1 participant