fix(preview): honor allocated project ports - #119
Merged
Conversation
Remap requested dev-server ports to each project stable slot. Require managed preview tools and remount stale iframes only after real sandbox wakeups.
7 tasks
iamjr15
added a commit
that referenced
this pull request
Aug 3, 2026
## Summary - Route high-confidence first-run web/mobile build imperatives through the managed app-builder path. - Treat `/workspace` as a virtual project root across file, shell, inline-code, and preview commands. - Run genuinely projectless calculations and environment probes from `/tmp` so they cannot leave orphaned durable files. - Persist the resolved builder mode when lazy project materialization creates the project. ## Context A production DeepSeek run wrote a complete site into `/workspace/beautiful-site` without attaching a project or registering a managed preview, then claimed the result was available in Computer. Files therefore had no project to open and Browser had no preview record. No Linear issue or standalone plan document is linked; this is a production QA follow-up to the preview recovery work in #118 and #119. ## Architecture A narrowly matched imperative first message (for example, “build a website”) is promoted from general mode into the existing app-builder path before model execution. The builder creates the canonical project and managed preview first. Tool execution then remaps the model-facing virtual `/workspace` namespace into that project root. Commands with no workspace intent remain projectless and use `/tmp`. ## Decisions Made | Decision | Choice | Alternatives considered | Reasoning | | --- | --- | --- | --- | | Model variance | Enforce the invariant in runtime code | More prompt wording | Weaker models may ignore descriptions; project/preview correctness cannot depend on compliance. | | Build inference | Only first-run, projectless, imperative web/mobile prompts | Classify every website mention | Avoids creating projects for informational questions or existing-project follow-ups. | | Projectless cwd | `/tmp` | Shared `/workspace` root | Environment probes stay ephemeral and cannot create unindexed durable files. | | Workspace paths | Remap virtual paths into the canonical project | Reject common `/workspace/*` inputs | Keeps models compatible while preventing sibling-project writes. | ## Edge Cases Handled | Scenario | Handling | | --- | --- | | DeepSeek writes an absolute `/workspace/*` path in argv or inline code | The path binds and remaps to the active project. | | A throwaway calculation uses no project path | It runs in `/tmp` without creating a project. | | A model requests a familiar preview port | Workspace remapping happens before stable port remapping. | | A project already exists or the run is a follow-up | No inferred builder bootstrap occurs. | | UI explicitly selected app-builder mode | Explicit mode remains authoritative. | ## How to Review 1. Start with `agent-run-path.ts` for the high-confidence first-run builder routing. 2. Review `workspace-paths.ts` and the code-tool adapters for confinement/remapping. 3. Review `runs.ts` for persisted resolved project mode. 4. Skim README updates for the documented runtime contract. ## Test Plan - [x] Full monorepo typecheck, including scripts - [x] Full monorepo lint - [x] Forced production build for all 19 packages and Worker dry-runs - [x] Dependency architecture check - [x] Dead-code check - [ ] Production DeepSeek first-run build after merge/deploy - [ ] Confirm Files and Browser both open the materialized project and managed preview
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.
Summary
code_start_dev_serverthe explicit Computer-preview contract and distinguish generic shell processes.Production QA on the first recovery release exposed both cases: the affected project owns 5174 because an old allocation occupies 5173, and a long-hidden iframe retained an expired auth document after the sandbox was force-stopped and restored.
Architecture
The dynamic allocator remains authoritative. Models may request the familiar 5173, but prepared process commands and readiness probes now always target the same allocated port. Only the canonical
app-preview:<workspaceSlug>process is Computer-visible and idle-recoverable.Verification notes
pnpm lintpnpm typecheckpnpm turbo build --forcepnpm deadcodepnpm architecture:checkpnpm turbo skills:buildThe forced production build completed uncached for all 19 packages and every Worker dry-run. Architecture analysis reported 847 modules and 1,752 dependencies with no violations. Knip exited cleanly with only four existing configuration hints.
Direct production browser QA already reproduced the port mismatch, created the canonical 5174 process, rendered the VOLTA site, force-stopped the exact Daytona sandbox, and confirmed the same process recovered. Final acceptance after deployment will repeat the hard stop and verify the new automatic iframe remount.
Review focus
remapRequestedDevServerPortkeeps command binding aligned with the allocator and readiness probe.No Linear issue or plan document exists; this follows a directly reproduced production incident.