Repository navigation
feat(design): run the workspace's dev server after a consent card (design mode v2 Phase 2b) - #916
sambitcreate wants to merge 39 commits into
Conversation
The renderer's capability record now carries designLive, so 2c's chip can read it. DM's flag helper and tests already match the binding definition.
Design jobs belong to a workspace's app root, not a chat: they spawn an argv with no shell, never reach a chat's list, notice or settlement, have their own cap of 8, and rotate their log at 25 MB instead of stopping. Reads take byte offsets over the whole output.
designSockets lists every listening socket of each design job's process group and descendants, from one ps and one lsof (or /proc pass) for all jobs. A timeout, an overrun, an unreadable table or fd folder, or too many fds fails the read instead of returning nothing.
renderer/shared/design-app.ts holds the status, problem and consent types 2c and 3a build on, the fixed problem messages and the card's display escapes. app-launch-core.ts is pure: the run argv and scrubbed environment per framework, the ready port, exposed sockets, the install rule and the launch fingerprint's canonical form.
readLaunchSurface hashes every script, rc, workspace, lockfile, yarnPath and framework config file that changes what installing or starting does, with bounded no-follow reads that refuse links and special files. The records file keeps consents, install stamps and sticky ports and fails closed. saveCanvasConfigApp merges a monorepo choice through writeConfinedWorkspaceText, write_file's confined writer, with no link followed on the path.
The sticky port, then the framework default, then an OS port. Free means no answer on 127.0.0.1 or [::1] within 250 ms and a test listen on 127.0.0.1 succeeds, so a wildcard or IPv6-only server elsewhere counts as in use.
…se a forced install above the workspace A-m4: AWS_BEARER_TOKEN_BEDROCK is a fixed extra provider key, and the card's hidden-character class adds Default_Ignorable_Code_Point (U+034F, U+17B4). A-m2: restart with install on an app whose lockfile is above the workspace answers install-outside-workspace instead of silently skipping.
…thout IPv6 A-m1: with ipv6.disable=1 every start was not-ready. A missing tcp table, or any other read failure, still fails closed.
…d and in the tool B-M1: the attempt's first read, the pre-spawn read, the gate-abort read and the running check all refuse a workspace without a folder or with none or read-only access; design_app refuses start, restart and choose on a read-only or no-access turn without reaching the service. B-M2: tests cover a folder, access or removal change while the card waits and after the install; deleting either pre-spawn check fails them.
A-M1: npm install writes a lockfile, which changed the fingerprint and the lock hash, so a second card and a second install followed. After Aiden's install the surface is read again; when only the install root's lockfile and the install argv changed, the consent moves to the new fingerprint with its installShown kept, and the install stamp takes the new lock hash.
…test run from its start B-M3: DesignAppLogs carries the run (the dev server's job id) and the end of its output; logs take a run. A cursor that names another run, or points past this run's end, reads the latest run from its oldest kept byte with truncated set. design_app reads its last window from the run it probed.
…red card answers unanswered B2: the wait while a card is open is the card's time plus a 5 s grace.
B3: a [::1] origin a running server holds later, and forgetting a workspace whose servers already stopped, now fire onOriginsChanged.
…ns on B5: each root's card shows at once, so one unanswered card no longer holds the others back.
…s missing-module hint is covered B6: the moved-chat test shows the same workspace does start once design mode is turned on, so its negative isn't vacuous; a crashed start or restart on a missing module answers the restart-with-install hint; the tool-description change detector is gone.
…ment visibility B8: macOS can report an occluded window's document hidden, which stopped the dev server under a window the person could still see. The renderer now reports only whether the canvas pane is shown; main counts a canvas while its window is visible and not minimized, and re-counts on minimize, restore, hide and show.
…sion's, are ended by marker A-m3: a setsid child leaves the job's group, and once its parent is gone no parent-pid walk reaches it. When a design job's leader exits, and when the next launch reaps the record's design jobs, every live process of this user carrying the job's AIDEN_BACKGROUND_JOB marker is ended, politely then forced (/proc/*/environ on Linux, ps -E on macOS, which hides the environment of Apple's platform binaries).
…ons on screen, and shows every waiting card A-M2: each script well shows its text in full with every line break marked (↵), runs of three or more blank lines and eight or more spaces as their count, and a multi-line script's line count in its label; no well scrolls on its own. B1: the card's details scroll in one region capped at half the window, with a Scroll for more cue, so the question and Allow and Not now stay visible. B4: waiting cards are kept by request id and every one for the chat shows, oldest first, so none times out unseen behind another.
…and the plan's as-built notes
…ked and counted, with Allow on screen
There was a problem hiding this comment.
Three correctness/safety issues need changes before merge. Focused state-machine and socket-reader suites pass, but they do not cover the failing branches described inline.
Validation: app-server-main.test.ts 55/55; listening-ports.test.ts 21/21. A combined run including canvas-config.test.ts reached 89/94 because the native confined writer was unavailable in this environment; those environment failures are not an additional finding.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏
There was a problem hiding this comment.
Important
- One stop-ordering regression remains in the deferred choice flow.
- Focused app-server, socket-monitoring, and shared design-app suites pass.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏
A deferred choose (behind a pending attempt, or restarting a running app) no longer reopens its card after a later explicit stop. Addresses Pullfrog review on #916.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the stop-generation fix added since the prior Pullfrog review and rechecked the complete PR in its final state.
- Preserved choice/stop ordering:
stop()now advances a per-entry generation synchronously, andbegin()rechecks its captured generation before queued work, after pending consent settles, and after stopping an already running server. Choices invoked before a later stop are dropped; choices invoked after it remain eligible. - Added race coverage: Focused tests now exercise the deferred-choice ordering behind both a pending consent attempt and a running app server.
Validation
npx tsx --test main/services/design-canvas/app-server/app-server-main.test.ts passed 60/60.
Review metadata
- Base commit:
138d6aa - Head commit:
459ad52 - Files reviewed: 74
- Commits reviewed: 1
- Reviewed commits:
459ad52fix(design-canvas): cancel deferred choices after explicit stop
- Head ref:
t3/design-mode-v2-p2b - Prior Pullfrog review: #916 (review)
@v0 or keep the SHA fresh with Dependabot | View workflow run | Using GPT Sol | 𝕏
…nApp channels' chat guard chatRunsDesignApps (no botId, no owner) is now the one check every app start for a chat goes through: the designApp:* channels, the toggle's designModeEntered call and Enter on Aiden's design-mode card.
…files The fingerprint (v3) hashes the workspace folder's real path, so a workspace re-pointed at another checkout with identical launch files, or a moved folder, shows the Run app again card. The same folder reached through a link keeps its consent.
There was a problem hiding this comment.
Important
The checkout-binding change still permits a workspace-root symlink retarget between fingerprint validation and process spawn, so the consent boundary is not complete yet.
Reviewed changes
Reviewed the two commits added since the prior Pullfrog review and rechecked their behavior in the complete PR context.
- Unified chat eligibility: Routed the
designApp:*IPC handlers, Design toggle, and design-mode consent-card entry throughchatRunsDesignApps, consistently excluding Bot and feature-owned chats. - Bound fingerprints to checkout paths: Added the workspace folder's canonical realpath to fingerprint v3, making identical files in distinct physical checkouts require separate consent while preserving aliases to the same folder.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏
…overs The spawn cwd comes from the fingerprinted surface's real path, not the configured workspace path, so a workspace link retargeted after the read can't move a consented launch into another checkout. Addresses Pullfrog review on #916.
There was a problem hiding this comment.
Important
The workspace-root retarget is fixed, but nested app and install roots can still redirect a spawn outside the fingerprinted launch surface.
Reviewed changes Reviewed the checkout-binding commit added since the prior Pullfrog review and rechecked it in the complete PR context.
- Bound jobs to the canonical checkout: Changed install and server
cwdvalues to use the real checkout captured by the current launch surface rather than the mutable configured workspace path. - Added focused checkout coverage: Added a state-machine test asserting that both install and server jobs stay in the canonical checkout when the workspace path is an alias.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏
… read validated The launch-surface read now reports the real app and install directories it checked and hashed, and the install and server run in those, so a nested root swapped for a link after the read can't redirect a spawn. Addresses Pullfrog review on #916.

This is stacked on #915 (Phase DM), then #911 (2a), #908 (1b) and #894 (1a). Merge them in order; GitHub retargets each PR when its base merges.
This PR is Phase 2b of design mode v2.
docs/superpowers/specs/2026-11-23-design-mode-live-app-design.md§6.2 and §8.docs/superpowers/plans/2026-11-24-design-mode-v2-p2b-dev-server.md, including its "As built" notes.Aiden can now run the workspace's own dev server so design mode can show the real app. It does this only after a consent card, and everything is behind
AIDEN_EXPERIMENTAL_DESIGN_LIVE. With the flag off, the tool, card, IPC and processes don't exist. 2c adds the status chip and attach; 3a adds the live frames.Consent card
Card with a multi-line
predevscript:What the card shows
npm run dev) and each script it runs, with itspre/postscripts and install-lifecycle scripts when an install will run.↵, runs of blank lines or spaces collapsed into visible[N blank lines]and[N spaces]tokens, and a line count in the header.How it behaves
.aiden/canvas.jsonwhen they picked an app in a monorepo.What changes
When a new card is needed
Consent is bound to a fingerprint of everything that decides what runs:
pre/postscripts;packageManageranddevEngines;.npmrc,.yarnrc,.yarnrc.ymland itsyarnPathtarget,pnpm-workspace.yaml,.pnpmfile.cjsandbunfig.toml, in every folder from the app up to the lockfile;A changed fingerprint shows a new "changed" card. An install the card never showed asks again.
Before every spawn, including after consent and after an install, detection, toolchain, fingerprint, folder and permission are read again. An app with no lockfile asks once and installs once: the consent moves to the lockfile the install creates.
Where the server runs
http://127.0.0.1:<port>, on a sticky free port.psand onelsof(or/proc) per tick, reads every socket the job's process group and descendants hold. It ticks every 500 ms while the server starts and every 2 s while it runs.exposed./proc/net, or more fds than the cap all count as failures, and three in a row stop the server./proc/net/tcp6(kernel booted withipv6.disable=1) counts as an empty table.Environment and install
AWS_BEARER_TOKEN_BEDROCK),AIDEN_*,npm_*,npm_config_*andINIT_CWDare removed.NEXT_,ASTRO_,NUXT_andGATSBY_TELEMETRY_DISABLED,NG_CLI_ANALYTICS=falseandDO_NOT_TRACK=1).install-outside-workspace), including a forced install.Lifecycle
workspaceMutationGate.admit;no-access;setsidare found by the job marker and stopped.Tool, approval, IPC and analytics
design_apphasstart | stop | restart | choose | statusactions, up to 4 starts per turn. It refuses Remote and windowless turns (desktop-only) and waits for the card's own timeout plus 5 s.via: "reviewed-exception"; a hook or rules-page Block still blocks.designApp:*call goes throughrendererDocumentOwner, and a subframe sender is refused. The log cursor carries its run's id; a stale cursor reads from the oldest byte withtruncated: true.design_app_startedevent, with its registry entry, docs row and test. It sends only enums and buckets, andmanageris optional.Review
0.0.0.0,setsidchildren, swapped-in links, and a no-lockfile app.Pullfrog review fixes
choosealways gets its own choose card.choosecancels it.choice-not-saved.chatRunsDesignApps(nobotId, noowner) is the one check for every app start: thedesignApp:*channels, the Design toggle and Enter on Aiden's design-mode card. The chat store already refuses design mode for a Bot's or a feature-owned chat, so this was not reachable today; the shared guard keeps the paths aligned if that changes.Tests
test:design-modetest:follow-throughtest:analyticstest:approval-gatetest:ci-policyapp-server-process(real processes, macOS host and Linux)design-app-serveranddesign-canvas)npx tsc --noEmit -p .,npm run lint,npm run buildandnpm run cli:buildpass.Notes
design-md/tool.test.ts"export over 64 KiB is refused with its size" timed out once while the Space E2E loaded the machine. It passes 17/17 alone. It's DM's test and 2b doesn't touch it.packages/cli/tests/server-visuals.test.mjs"an installed browser draws a chart offline into a picture and leaves no profile behind" timed out at 15 s on 459ad52 (run 45404937046). The headless browser didn't finish drawing in time, so the reply said "Not shown". The same test failed the same way on feat(design): DESIGN.md read, lint and draft behind the live flag (design mode v2 Phase DM) #915 (d5083ab), and 2b doesn't touch the CLI's visuals. I'll rerun it once, after the run finishes.ps -Ecan't read the environment of Apple's own programs, so a leftover/bin/shorsleepthat left the group withsetsidisn't found by the marker sweep. The person's ownnodeprocesses are found.ipv6.disable=1now works. Other/proc/netread errors still fail closed.🤖 Generated with Claude Code