Skip to content

Tower activate adopts silently on extension reconnect; make adopt an explicit request #1864

Open

Description

@amrmelsayed

Problem

Opening a folder in VS Code with the Codev extension can write a full Codev scaffold into that folder without anyone asking for it. The write recurs on every reconnect to Tower for as long as the folder has no codev/ directory.

Observed on a repository that was being stripped of an old Codev install: the old codev/, .codev/, .claude/skills/ and .codex/ were deleted on purpose; two minutes later Tower's event stream to that window dropped, the extension reconnected, and .claude/skills/*, .codex/skills/*, codev/, .codev/config.json and .codev-new copies of CLAUDE.md and AGENTS.md reappeared, followed by a Claude merge session nobody launched. Nothing in the window said a scaffold had been written, and Tower's log carried no trace because the step failed on a timeout after the files were already on disk.

Root cause

Two pieces that were each reasonable on their own:

  1. Tower's activate route adopts implicitly. launchInstance in packages/codev/src/agent-farm/servers/tower-instances.ts runs npx codev adopt --yes in any activated folder that lacks codev/ (30s exec timeout). This was added for the web dashboard's clickable Recent Projects rows, where a human had just clicked the folder and a "Codev adopted!" toast reported the write.
  2. The extension activates automatically. apps/vscode/src/connection-manager.ts posts activate for the open folder on every connect and reconnect so overview fetches never race registration. It ignores the adopted flag in the response and logs only "Workspace activated".

The Switch Workspace command (#1566, apps/vscode/src/commands/switch-workspace.ts) already recognised the hazard and confirms before activating a folder without codev/. That guard is scoped to the command; the connect path inherited the silent adopt.

Two secondary defects compound it:

  • codev adopt --yes still launches the CLAUDE.md/AGENTS.md merge session and the adopt process outlives Tower's 30s timeout when that session runs long. Tower then reports "Failed to adopt codev" to the caller, logs nothing, and leaves the half-adopted tree behind.
  • Adopt failures are not logged by Tower at all, only returned, so a silent write is also an untraceable one.

Fix

  • Tower: the activate route takes an explicit adopt: true in the request body. Without it, a folder lacking codev/ is refused with a distinct, machine-readable error (for example needs_adopt) instead of being adopted. The dashboard's row click and the extension's Switch Workspace flow pass the flag after their existing confirmation. Log adopt attempts, successes and failures. Do not leave a partial tree on timeout: either run adopt without the merge session when invoked by Tower, or raise the timeout and surface the merge step separately.
  • Extension connect path: on a needs_adopt refusal, do not adopt. Show one non-modal notice offering "Adopt this folder" (which re-activates with the flag, reusing the Switch Workspace confirmation text) or "Not now", remembered per workspace so the prompt does not repeat on every reconnect. Honour the adopted flag in a successful response with a visible notice.
  • Docs: note in the extension and Tower docs that activation never writes into a folder without an explicit adopt.

Testing

  • Tower route test: activate on a folder without codev/ and no flag returns the refusal and writes nothing; with the flag it adopts and logs.
  • Tower route test: an adopt that exceeds the timeout is logged and reported; assert the on-disk outcome the fix chooses.
  • Extension unit test on the connect flow: needs_adopt produces the prompt, never an adopt; "Not now" is remembered across reconnects.
  • Manual: open a non-Codev folder in VS Code with the extension, drop and restore Tower, confirm no files are written until "Adopt this folder" is chosen.

Activity

  1. added
    area/cross-cutting
    on Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/cross-cutting

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions