Skip to content

fix: forward workspace root approval to worker on Add Project#173

Merged
DeadWaveWave merged 1 commit intoDeadWaveWave:mainfrom
liusining:fix/forward-approve-root-to-worker
Apr 15, 2026
Merged

fix: forward workspace root approval to worker on Add Project#173
DeadWaveWave merged 1 commit intoDeadWaveWave:mainfrom
liusining:fix/forward-approve-root-to-worker

Conversation

@liusining
Copy link
Copy Markdown
Contributor

💡 Change Scope

  • Small Change: Fast feedback, localized UI/logic, low-risk.
  • Large Change: New feature, cross-boundary logic, runtime-risk (persistence, IPC, lifecycle, recovery).

📝 What Does This PR Do?

Fixes a bug where adding a new project in the packaged (release) build and then running an agent fails with:

Agent launch failed: The selected path is outside approved workspaces.

The same flow works fine in pnpm dev because dev mode runs in standalone mode (no worker process).

Root Cause

In packaged builds, the desktop spawns a local worker process (effectiveMode: 'local'). The desktop and the worker each own a separate ApprovedWorkspaceStore instance. When the user adds a project via the native directory picker, workspaceSelectDirectory only calls registerRoot on the desktop's local store. Agent launches are forwarded to the worker via registerRemoteAgentIpcHandlerssession.launchAgent, where the worker checks its own store — which doesn't know about the newly added root.

Compare with the web canvas AddProjectDialog, which correctly calls workspace.approveRoot on the worker control surface.

Fix

Wrap the ApprovedWorkspaceStore passed to registerWorkspaceIpcHandlers so that registerRoot also forwards the call to the worker's workspace.approveRoot control surface endpoint when a workerEndpointResolver is present. Gracefully degrades if the worker isn't ready — the shared JSON file ensures the worker picks up the root on its next cold load.

Key changes

  • src/app/main/ipc/registerIpcHandlers.ts: Create a forwarding wrapper around approvedWorkspaces that calls both the local store and the worker control surface on registerRoot.

✅ Delivery & Compliance Checklist

  • My code passes the ultimate gatekeeper: pnpm pre-commit is completely green.
  • TypeScript type check: 0 errors
  • oxlint: 0 warnings, 0 errors
  • Full test suite: 191 files, 661 tests passed
  • I have included new tests to lock down the behavior.
  • I have strictly adhered to the DEVELOPMENT.md architectural boundaries.

🤖 Generated with Claude Code

In packaged builds the desktop runs agents through a worker process
that owns its own ApprovedWorkspaceStore.  When the user adds a new
project via the native directory picker, the root was only registered
in the desktop's local store — the worker never learned about it, so
the subsequent agent launch was rejected with "The selected path is
outside approved workspaces."

Wrap the ApprovedWorkspaceStore passed to registerWorkspaceIpcHandlers
so that registerRoot also calls workspace.approveRoot on the worker
control surface, keeping both stores in sync at runtime.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@DeadWaveWave DeadWaveWave merged commit ee1b7cc into DeadWaveWave:main Apr 15, 2026
7 checks passed
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.

2 participants