Skip to content

Design mode v2 Phase 1a: one canvas per workspace, a page per chat - #894

Open
sambitcreate wants to merge 23 commits into
mainfrom
t3/design-mode-live-app-plan
Open

sambitcreate wants to merge 23 commits into
mainfrom
t3/design-mode-live-app-plan

Conversation

@sambitcreate

Copy link
Copy Markdown
Owner

Phase 1a of Design mode v2: the live app canvas, following the 1a plan and its review amendments A1–A26. It also includes the spec and plan updates from three rounds of adversarial review (spec §11 "Resolved before build" and §12 S1–S15).

What changes

The canvas belongs to the workspace. Every chat in a workspace now shares one canvas document (version 3), stored per workspace. The first launch on this build moves canvases to the new layout with a one-time wipe, marked by .layout-v3 in design-canvases/. Each No workspace chat keeps its own hidden workspace, so it still has a canvas of its own. Only legacy chats with no workspaceId share default.

Each chat has its own view. The page on screen and where the chat looks on each page are no longer stored in the document:

  • Where views live. Main keeps them in DesignCanvasViews, persisted to userData/design-canvas-views/<workspaceId>.json. The renderer reads its view on mount (designCanvas:view:get) and reports changes 250 ms after the last one (designCanvas:view).
  • Not saves, not undo steps. Panning, zooming and switching pages never save the document and never become undo steps.
  • Aiden's page changes. Each one carries an increasing focusId, and main drops reports that haven't seen the newest. Every tool in a turn uses one page resolver (chatPageFor / designTurnPages), in this order: shown this turn, then the message, then the registry, then the first page.

Who owns what.

  • Frames. Artifact frames record the chat that made them. A visual made by another chat loads through that chat, and only an attended chat can do so. If that chat no longer has the visual, the frame says "Visual no longer available" and offers Remove frame.
  • Comments. Comments record their chat. The comment tray, canvas_read and canvas_comment work per chat, and queuing another chat's comment moves it to your tray.
  • Broadcasts. designCanvas:updated now carries {workspaceId, chatId, revision}.
  • Saves. A save must name its workspace. A save for a workspace the chat has left is answered {ok: false, reason: "moved", workspaceId}, and only that chat's canvas reopens on the new workspace.

Lifecycle.

  • Attaching. A No workspace chat that attaches to a workspace brings its pages along, named " · ". Frame paths and comment source stamps follow the copied files, and nothing happens when the files are only moved to Trash.
  • Cleanup. Removing a workspace removes its canvas and views. A chat moved to another workspace is forgotten in the old one.

Page fallback. When the page on screen goes away (an undone add or duplicate, or another chat deleting it), the chat returns to the page it showed before, not to page 1. A pan that ends after Aiden switched pages isn't stored on the new page.

Screenshots

Chat A in the workspace is on Page 2, which it added:

Light Dark
Chat A on Page 2, light Chat A on Page 2, dark

Chat B, a new chat in the same workspace, opens the same canvas on its own page (Page 1, which has A's first note):

Light Dark
Chat B on Page 1, light Chat B on Page 1, dark

Chat B's page picker lists the workspace's shared pages:

Light Dark
Page picker, light Page picker, dark

There's no "before" pair: on main, every chat had its own canvas, so chat B would open on an empty canvas.

Review

  • Three rounds of adversarial plan and spec review, each with two Opus reviewers. The blocking findings went 3 → 2 → 1 → 0, and the fixes are recorded as amendments in the plan.
  • An adversarial code review of the build: all 9 main-side findings are fixed in d5b1b14e9, and all 10 renderer findings in f78a6b0ef. Each of those behavioral fixes has a test that fails without it.

Tests

  • npx tsc --noEmit, npm run lint and npm run test:ci-policy pass.
  • npm run test:design-mode passes 722 of 722.
  • The design E2E (tests/e2e/design-canvas.spec.ts and tests/e2e/design-mode.spec.ts) passes 13 of 13 in a Cua Space.
  • In npm run test, 4 tests fail here, and they fail the same way on this branch's merge base, so this change doesn't cause them:
    • guest-driver-install.test.ts:330;
    • prompt-prefix-stability.test.ts:1068 (three tests).

Notes

  • The live app work (Phases 2b–5) stays behind AIDEN_EXPERIMENTAL_DESIGN_LIVE until Phase 7. This PR changes no Remote protocol, iOS, Android or CLI contract.
  • The release notes need a line about the one-time canvas reset (.layout-v3) when the version is cut.

Spec for the next design mode: the workspace's running web app as live,
interactive frames (localhost-only network), one canvas per workspace
with a page per chat, an Aiden-controlled dev server, an Inspect tool
with measure and drift checks, element chips, error frames with Fix
with Aiden, live directions with Adopt, Google's DESIGN.md as the
design-system source, React mock apps for non-web React projects, and
later *.canvas.tsx component cards. Seven phases, no code yet.
Records the pre-build findings in spec §11 (design.md package, v1
design-system module, default-session webRequest, offline E2E fixture,
React 19 source mapping, cleared v1 canvases, 3a security review),
splits the build into reviewable PRs, fixes the decision numbering,
and adds the Phase 1a implementation plan.
Plan amendments A1-A12 (origin chatId on updates, chat-filtered comment
tray in 1a, per-window ordered views, immediate page change in main,
attach merges hidden canvases, single workspace id per operation).
Spec amendments S1-S15 (subframe redirects, dev-server start consent,
fail-closed null-frame rule, file:// cookies, design job owner, install
stamp, permission dispatcher, untrusted bridge output, loopback binding,
resequenced PRs behind AIDEN_EXPERIMENTAL_DESIGN_LIVE).
Replace the seq scheme with main-issued focusIds and mount-time view
reads; define page precedence; key views by chat (one main window);
narrow the attach merge to copied files with path remapping and kept ids;
a 'moved' save answer; first-entry page for a second chat; move
workspace-remove cleanup and comment pruning into 1a; per-chat comment
tools; S2 permission and fingerprint fixes; S7 non-chat job key.
Move each chat's view out of renderer localStorage into a main-owned,
per-workspace views file (removes the two-copy races), reset viewports
on page change, echo the highest focusId, one page resolver per turn,
no duplicate pages on entry, exact attach path pairs, 'moved' carries
the new workspace, workspace-checked view reports, race-proof cleanup,
and a wider S2 fingerprint.
Round-3 amendments A17, A18, A24 and A26: DesignCanvasViews keeps each
chat's page, per-page viewports and focusId, persisted per workspace
under userData/design-canvas-views/ (written at most once a second,
flushed on quit). showPage takes that page's own viewport. View reports
name their workspace and are dropped when the chat has moved; a reload,
crash or destroy of the window unmounts every view. designTurnPages
resolves a turn's page in A4/A20 order.
Task 5 with A1, A14, A18 and A20: the tools resolve the turn's page
through designTurnPages (a page Aiden showed this turn, the message's
page, the chat's kept page, the first page), measured from where the
chat last looked at that page. Showing a page changes only main's view
of the chat and sends designCanvas:focus with the page and a focusId;
it never writes the shared document. canvas_read lists and canvas_comment
answers only the acting chat's comments. Every store call, broadcast and
focus in a call names the one workspace it resolved.
Main owns each chat's view; the canvas reads it on mount and reports
changes with its workspace and newest focusId. Pans, zooms and page
switches never save the shared document or make undo steps. Updates are
filtered by workspace, another chat's change is never an undo step here,
and a moved save reopens the canvas on the chat's new workspace.
Also refuses a canvas whose workspace record is gone (A25).
Artifact frames load through the chat that made them, within the workspace.
Chat delete prunes the chat's comments and view instead of deleting a canvas;
workspace remove deletes the canvas and views. A No workspace chat attached
with its files copied brings its canvas pages along (canvasCarried: false and
a toast when too large). E2E reads the v3 canvas and the views file.
- Managed-worktree delete and its startup recovery remove the
  worktree's canvas, corrupt copies and views file.
- Attach carries comment anchors' source stamps to the copied files,
  dropping a stamp whose file stayed behind.
- Attach brings the canvas along whenever the hidden folder is the
  chat's own, so trashing files no longer silently deletes notes,
  visuals and comments.
- A canvas save must name its workspace.
- Another chat's visual is read only through an attended chat.
- Entry reads whether the chat had a view before reading its files, and
  a take-back also removes the empty page entry added.
- Moving an empty chat clears its view and comments on the old
  workspace's canvas.
- A visual whose chat no longer has it shows a removable missing state
  instead of loading forever.
- Queuing another chat's comment moves it to the queuing chat's tray.
- A save answered moved applies only to the chat it was found for.
- When the page on screen goes (an undone add or duplicate, or another
  chat's delete), the view goes back to the page shown before it.
- A pan that ends after Aiden showed another page is not kept.
- Main handles a chat's view reports in order, so an unmount is never
  overtaken by the last report.
- Tests: early expired focus, A to B to A chat switch, cross-chat page
  delete; trimmed tests that covered unreachable paths.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Two asynchronous ordering gaps can restore state after workspace cleanup or replace a chat's latest focused page, so these should be fixed before merge.

Reviewed changes covered the complete 78-file Phase 1a diff that moves Design mode to a shared workspace canvas with per-chat views.

  • Workspace document model: Introduces the v3 workspace-keyed canvas store, one-time layout reset, shared revisions, and workspace-aware broadcasts and saves.
  • Per-chat view model: Adds main-owned persisted page/view state, focus sequencing, renderer reporting, page fallback, and workspace/chat remount behavior.
  • Ownership and lifecycle: Associates artifacts and comments with chats, carries canvases during workspace attachment, and cleans canvas state on chat or workspace removal.
  • Tooling and renderer synchronization: Resolves each turn's page consistently, replays local edits over shared conflicts, and preserves per-chat undo semantics across external updates.
  • Coverage and documentation: Reviewed the expanded unit/E2E coverage and product, plan, spec, and project-memory updates; npm run test:design-mode passes all 722 tests.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏

Comment thread main/services/design-canvas/store.ts Resolved
Comment thread renderer/design/use-design-view.ts Resolved
…ounted fits on screen

- DesignChatCanvases asks whether the workspace still exists again on the
  workspace's store chain just before a save or update writes, so a write
  that saw the workspace live before its removal no longer recreates the
  deleted canvas file.
- A focus without a focusId only fits frames on the page on screen; it no
  longer changes the page, so a late fit cannot bring back a page a later
  numbered page change left (and main never persists it).

Co-Authored-By: Claude <noreply@anthropic.com>

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

One page-ordering path remains incomplete: an unversioned frame-only focus can still supersede a newer numbered page change.

Reviewed changes since the prior Pullfrog review at 3d6d9ded3, focusing on the follow-up fix in c5db7883d.

  • Workspace cleanup ordering: Rechecked workspace liveness inside the canvas store's serialized write boundary and added a race test that proves deletion cannot be undone by a pending save.
  • Focus ordering: Prevented late unversioned requests with an explicit stale page from moving the canvas and added renderer coverage for that variant.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏

Comment thread renderer/design/design-canvas.tsx Resolved
A focus without a focusId that names only frames no longer switches to
the frames' page; only a counted focus may change the page.

Co-Authored-By: Claude <noreply@anthropic.com>

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes since the prior Pullfrog review at c5db7883d, focusing on the frame-only focus-ordering correction.

  • Held uncounted fits to the visible page: Inferred a frame-only request's target page before deciding whether it may navigate, while preserving ordered page changes for counted requests.
  • Strengthened behavioral coverage: Updated the cross-page focus test to use a counted request and verified that both explicit-page and frame-only late uncounted fits remain on the current page without stale reports.
  • Validated the focused suite: npm run test:design-mode passes all 724 tests at this head.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | View workflow run | Using GPT Sol | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes since the prior Pullfrog review at 19d79bbb7, focusing on the merge of current main into the PR branch.

  • Reconciled shutdown sequencing: Combined background follow-through shutdown with the Design view flush so background work settles before the final persisted canvas-view write.
  • Retired model pace persistence: Removed the retired pace recorder's shutdown budget and flush while preserving the bounded shutdown sequence.
  • Validated the focused suite: npm run test:design-mode passes all 724 tests at this head.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | View workflow run | Using GPT Sol | 𝕏

This branch has not been deployed

No deployments
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