Skip to content

refactor(api): remove dead legacy /api/vm-events route - #5174

Merged
pedrofrxncx merged 1 commit into
mainfrom
refactor/remove-dead-legacy-vm-events-w1
Jul 24, 2026
Merged

pedrofrxncx merged 1 commit into
mainfrom
refactor/remove-dead-legacy-vm-events-w1

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Jul 24, 2026 •

Copy link
Copy Markdown
Collaborator

Part of the org-scoped /:org route-prefix migration (#3256): finds a mount that was left dangling after the migration finished elsewhere.

apps/api/src/api/app.ts still mounted /api/vm-events (legacy, with a deprecation log) pointing at apps/api/src/api/routes/vm-events.ts, with a comment saying "the new /api/:org/vm-events mount is wired in a later task." That task already happened, just under a different URL shape: the VM-events SSE was consolidated into the unified sandbox proxy (sandbox-proxy.ts, handleVmEvents/sandbox-events-handler.ts) and now lives at /api/:org/sandbox/:virtualMcpId/:branch/events. The frontend (apps/web/src/components/sandbox/hooks/sandbox-events-context.tsx:249) already builds only that URL. So the legacy /api/vm-events mount and its route file have zero remaining callers.

Net reduction: -644 lines (app.ts -17, vm-events.ts deleted, -627). Confirmed zero references: grep -rn "routes/vm-events\|createVmEventsRoutes" across apps/api/src returns nothing after the change, and no e2e/test file imports it.

To confirm: cd apps/api && bunx tsc --noEmit (passes), and rg "routes/vm-events|createVmEventsRoutes" apps/api/src (no hits).

Locally ran: bun run fmt and cd apps/api && bunx tsc --noEmit (both clean). No test file existed for the deleted route (pure dead-code delete, not a behavior change), so no test needed removal. Full CI validates the rest.


Summary by cubic

Removed the dead legacy /api/vm-events route and handler. VM event streaming now lives at /api/:org/sandbox/:virtualMcpId/:branch/events, so this cleanup has no behavior impact and completes the org-scoped route migration.

  • Refactors
    • Unmounted /api/vm-events in apps/api/src/api/app.ts.
    • Deleted apps/api/src/api/routes/vm-events.ts (legacy SSE handler).

Written for commit c13c806. Summary will update on new commits.

Review in cubic

The org-scoped route migration already superseded this: the browser now
opens `/api/:org/sandbox/:virtualMcpId/:branch/events` (sandbox-proxy.ts's
handleVmEvents, sharing sandbox-events-handler.ts), so the legacy
`/api/vm-events` mount in app.ts and its route file have no remaining
caller.
@pedrofrxncx
pedrofrxncx merged commit 5c7a9e2 into main Jul 24, 2026
15 of 16 checks passed
@pedrofrxncx
pedrofrxncx deleted the refactor/remove-dead-legacy-vm-events-w1 branch July 24, 2026 14:24
pedrofrxncx pushed a commit that referenced this pull request Jul 27, 2026
#5240)

Reverts #5112 (share agent sandboxes by branch), #5116 (always share
agent sandboxes) and #5132 (use shared staging branch), restoring the
pre-#5112 behaviour: hosted agent sandboxes are per-user again, and a
new GitHub-backed thread gets a generated branch instead of `staging`.

Reconstructed against current paths rather than reverted: #5120 split
apps/mesh into apps/api + apps/web and hoisted branch-name.ts,
runtime-defaults.ts and thread/schema.ts into packages/shared, and #5174
deleted vm-events.ts outright, so none of the three commits reverse-apply.

Core change: SandboxId goes back to a flat `{ userId, projectRef }` and
sandboxIdKey back to `userId:projectRef`, so every hosted claim handle
changes. Live shared claims must be drained BEFORE this deploys.

Also reverted, because they only exist inside the shared model:
- #5225 withoutLegacyAgentSandboxEntries — left in place it would strip
  the sandboxMap entries the reverted server writes back, leaving
  shouldAutoStart permanently true (silent, compiles fine)
- #5219 resolveSharedThreadVm and the shared-scope branch
- #5183 stale-provisioning reset (lived inside the deleted storage)

Deliberately preserved:
- migrations 137/138 and their index.ts entries — Kysely's
  #ensureNoMissingMigrations runs unconditionally, so deleting an applied
  migration crash-loops every pod. The tables are dropped by a follow-up
  forward migration after the drain, not by this commit.
- #5114/#5118 withClaimGitLock, #5126 org-context guard, #5143 analytics
  gate, #5171 owner-keyed thread graft, #5195/#5207/#5210/#5221 client
  auto-retry, the daemon status-code train and the settings-validation train
- #5112's org-fs least-privilege narrowing and the start dedup key fix
- #5116's squashed queue-tray pluralization (en + pt-br)
- the remote-branch-name validations #5132 deleted, since this restores
  the dynamic origin/HEAD lookup that made them load-bearing

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Co-authored-by: Pedro França <[email protected]>
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.

1 participant