Skip to content

feat(design): each chat gets its own page on the workspace canvas (design mode v2, Phase 1b) - #908

Open
sambitcreate wants to merge 17 commits into
t3/design-mode-live-app-planfrom
t3/design-mode-v2-p1b
Open

sambitcreate wants to merge 17 commits into
t3/design-mode-live-app-planfrom
t3/design-mode-v2-p1b

Conversation

@sambitcreate

Copy link
Copy Markdown
Owner

Stacked on #894 (Phase 1a, the shared workspace canvas). Merge #894 first; GitHub will retarget this PR to main.

Phase 1b of design mode v2 (spec docs/superpowers/specs/2026-11-23-design-mode-live-app-design.md §6.1, §8; plan docs/superpowers/plans/2026-11-23-design-mode-v2-p1b-chat-pages.md). 1a made one canvas per workspace and read chatPages; 1b writes it and handles its lifecycle.

What changes

  • A chat claims a page when it enters design mode. If the chat has a live claim, it keeps it. Otherwise it claims the page holding most of the chat's earlier written pages, then the free page on screen. If none of those apply, it claims a new page named after the chat.
  • A page made for a chat follows that chat's title (DesignPage.namedFor) until someone renames the page. This covers every title writer: rename, auto-title, the first-message seed, and the title of a chat started from the phone.
  • canvas_page use lets Aiden switch which page belongs to its chat.
  • canvas_page delete refuses once, naming both counts. It refuses when the person's frames or another chat's page are involved, unless Aiden passes force. Tool answers name other chats only by count, never by title or id.
  • Deleting a page moves its chats to the first page left. The person's delete in the picker still has Undo.
  • A chat with no claim claims the page its first design-turn write lands on. These are chats that were in design mode before the upgrade, or that moved or attached.
  • The page picker shows each page's chats: "This chat", "1 chat", "N chats", "This chat · N more".
  • Lifecycle:
    • Deleting a chat removes its claim, its namedFor marks and its artifact frames. Comments still go before the delete commits, the rest after.
    • Startup recovery finishes the same work, scanning canvases when the chat's metadata is already gone.
    • Moving a chat deletes the empty page made for it, if nothing else uses that page.
    • Attaching a No-workspace chat claims the first page that came over.

Undo and saves

  • Undo now applies page changes one page at a time. In 1a, a page another writer added or renamed after a delete stopped an undo from bringing the deleted page back. Its frames then moved to page 1 and its comments were dropped.
  • A person's save never adds, moves or drops a claim. The store merges claims with what it already holds, using an in-memory record of deleted pages to restore claims on undo. The save's answer returns the stored claims so the canvas that saved stays in step.

Screenshots

Page picker with two chats in one workspace. Chat B is on its own page, named after it; Page 1 belongs to chat A.

Before (1a, #894) After, light After, dark
Picker before Picker after, light Picker after, dark

Review

  • Plan: two adversarial Opus reviews, a revision, then a re-check before building.
  • Build: each task group (1–3, 4–8, 9–11) got two Opus reviews and a fix round, then a final integration review of the whole branch, with fixes. Every fix started with a failing test. Spec amendments S16–S18 record where 1b differs from §6.1.

Tests

  • npm run test:design-mode: 832/832.
  • Nearby suites pass: chat application service, chat store, worktrees, attach, carry and canvas tools.
  • npx tsc --noEmit -p ., npm run type-check:e2e, npm run lint, npm run test:ci-policy and npm run cli:build all pass.
  • E2E in a Cua Space (Linux):
    • tests/e2e/design-canvas.spec.ts: 11/11, including the new two-chats test.
    • tests/e2e/design-mode.spec.ts: 3/3, before the final fix commit.

Notes

  • npx tsc -p main/tsconfig.json reports errors that also fail on the base commit (rootDir and import extensions). None are in files this PR touches.
  • The E2E opens the sidebar row menu with Shift+F10, because the hover-only "•••" button fails Playwright's hit-target check when the row isn't hovered. The button is focusable and works by keyboard.

🤖 Generated with Claude Code

sambitcreate and others added 16 commits November 23, 2026 22:48
Co-Authored-By: Claude <noreply@anthropic.com>
Adds renderer/shared/design-canvas/chat-pages.ts with the pure rules for
each chat's own page: chatsOnPage, uniquePageName, claimPage (2 000-entry
cap, evicting dead chats first), addChatPage, followChatTitle,
forgetChatOnCanvas, forgetChatMove, deletedClaims and mergeSavedChatPages.
DesignPage gains namedFor; deletePage moves its chats to the first page
left; renamePage stops a page following its chat; chatPageId resolves view
page, then claim, then first page.

changesBetween now applies page changes item by item (removals, renames,
namedFor, inserts after the nearest earlier page, reorders among shared
pages) and carries claim changes, so an undo brings back a deleted page
even when another writer changed the page list.

Deviation: the plan lists both "refuses more than 2000 chatPages entries"
and "parse keeps the first 2 000 ... counts the rest in dropped" for
schema.test.ts. The Global Constraints and re-check 5 settle on dropping,
so parse drops and counts; there is no refusal test. chatPageId's test
lives in view.test.ts beside the function rather than chat-pages.test.ts.

Co-Authored-By: Claude <noreply@anthropic.com>
DesignCanvasStore.save merges a person's save with the stored claims
(mergeSavedChatPages) before withRemovedPagePaths. A save never adds or
moves a claim; it gives back a claim on a page it brings back only when
the store's in-memory delete record has that chat on that page and the
chat is still where the delete moved it. The record (per workspace, at
most 200 pages, newest delete of a page id replaces the old one) is
filled by saves and updates after their write lands, emptied of what a
save restored, and cleared on delete(workspaceId).

The save's ok answer carries chatPages and namedFor when the merge
changed what was sent. useDesignCanvas applies them to server and local
(applyStoredClaims) and takes the change in as a carried, non-undo
change, so undoing a turn that used a page keeps the stored claim.

The handler already returned the store's result as is; only the type
in renderer/lib/ipc.ts changed.

Note: the store passes no isLive to the merge, as the plan's interface
gives none. A brought-back page can keep namedFor for a chat deleted or
moved since; D6 calls that harmless, since the title follow resolves the
chat's current workspace.

Co-Authored-By: Claude <noreply@anthropic.com>
designTurnPages now resolves a turn's page as: shown this turn, the
message's page, the kept view page, chatPages[chatId], then the first
page; resolver and view take Pick<DesignCanvas, "pages" | "chatPages">.
useDesignView shows the view page, then the claim, then the newest
earlier page, then the first page, and schedules a view report (through
the 250 ms debounce) whenever the page on screen is a fallback, so main's
kept view matches the screen.

Note: no A12 "1b note" was left in code comments at 19d79bb, so there
was nothing to remove; the canvas-tools pages comment now names the
claim step.

Co-Authored-By: Claude <noreply@anthropic.com>
- changesBetween carries a page's name and namedFor per field, so a
  carry that only drops namedFor keeps a redo step's rename.
- A carry that would pass the 200-page limit drops pages only the step
  has, newest first; parse now counts pages past the limit in dropped.
- Frames only a step has, on a page gone after the carry, are dropped
  like comments (this predates 1b).
- A save's stored claims reach newer unsaved edits through
  changesBetween(sent, stored), so a second undo or a rename made while
  the save was on its way stays.
- useDesignView reports the shown page whenever it changes after load,
  so main hears the view's page coming back after a fallback.
- The store's delete record forgets an older entry for every page a
  write removes, even when the new delete had nothing to record, and
  delete(workspaceId) clears the record only after the files are gone.
- DesignChatCanvases takes chatIsLive(chatId, workspaceId); save asks it
  for the chats the saved pages are named for before the store chain and
  passes a synchronous isLive to the merge, so a brought-back page keeps
  namedFor only for a chat live in this workspace (D6 in the plan now
  says so). Production checks the meta exists and its persisted
  workspace id matches.

Co-Authored-By: Claude <noreply@anthropic.com>
The chat store tells title listeners once after rename,
replaceTitleIfUnchanged, replaceAutoTitle or a first-message seed wrote a
new title, outside the chat lock. createDesignTitleFollow renames the pages
made for the chat in a per-chat queue that reads the title when each run
starts, writing through DesignChatCanvases.

Deviation: the follow takes an optional onError for logging (main passes
logger.warn), and uses only DesignChatCanvases.update, since update already
resolves the chat's workspace.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Entry decides the chat's page by D2's rules in one update on the latest
document: keep a live claim, else the page holding most of its earlier
pages, else the resolved page when it is not another chat's (by namedFor,
claim, or a kept view on a page with frames), else a page named after the
chat. It claims even with no written pages, drops the claims of chats that
are gone in the same write, and always shows the chat's page afterwards
unless design mode turned off. A retraction takes back the added page and
the claim on it. designPagesOnEntry runs the title follow after the claim,
and the consent card's enter awaits entry (setDesignMode awaitEntry).

Deviations:
- entry.isLive takes the workspace id as a second argument, so main checks
  liveness with the same helper DesignChatCanvases uses (designLiveChats)
  instead of resolving the workspace again.
- placeWrittenPagesOnCanvas's store needs get, to read the claimed chats
  before the update.
- A ChatPagesFullError during entry skips the claim (and the new page) and
  still places the chat's earlier pages, like the lazy claim and carry.

Co-Authored-By: Claude <noreply@anthropic.com>
canvas_page use makes a page this chat's own and shows it; on the chat's
own page it only shows, writing nothing. canvas_page delete without force
refuses once, naming the person's or locked frames and the other live
chats using the page, with pluralised counts. delete and use drop the
claims of chats that are gone in the same write. The pages list marks
this chat's page (yours) and counts other live chats (otherChats), naming
none. The prompt line and descriptions say what use does.

Deviations:
- DesignCanvasToolDeps.isLive takes the workspace id as a second argument,
  wired to the same designLiveChats helper entry uses.
- use at the claims cap answers with the cap's message as a tool error.

Co-Authored-By: Claude <noreply@anthropic.com>
A design turn's canvas write (a tool edit, an auto-placed written page, an
artifact or a saved image) claims the page the turn worked on for a chat
with no claim, in the same write (withLazyClaim). The check runs on the
document after the write's own change, so a canvas_page use claim made by
the same write stays and a page the write deleted is not claimed. A
refused or no-change write claims nothing, reads never claim, and a full
chatPages skips only the claim.

Main tracks each chat's running entry (designPendingEntries, set by
designPagesOnEntry whichever path turned design mode on), and the turn's
writes wait for it before resolving the page, so entry's claim comes
first.

Clarification: the page claimed is the page the turn resolved to for the
write (the view before the change), taken only while it still exists after
the change. Resolving on the changed document alone would fall through to
the first page when the write deleted the turn's page, which the plan's own
test ("a write that deletes the turn's page claims nothing") rules out.

Two canvas_page delete tests now also expect chat-1's lazy claim on the
page its turn is on.

Co-Authored-By: Claude <noreply@anthropic.com>
- The lazy claim takes the page the write landed on: the page it shows,
  else the page of the frames it added or changed, else the turn's page,
  always one that exists after the write (landedPageId). A delete lands on
  none. canvas_page answers are built after the claim, so yours is right.
- At a full chatPages the lazy claim asks which claimed chats are live and
  claims in a follow-up write when a gone chat's entry makes room
  (claimWithRoom; withLazyClaim takes isLive). Below the cap nothing extra
  is read.
- The title follow treats a chat with no canvas (gone, or a workspace with
  no record) as nothing to do: DesignCanvasUnavailableError, no warning.
- Entry rule 2 does not count pages another live chat claims.
- A save asks chatIsLive on the workspace's chain, and only for the chats
  the delete record names on pages the save brings back with that
  namedFor; it no longer scans the payload.
- canvas_page reads the canvas and liveness first only for show, use and
  delete.
- The entry wiring moves to createDesignEntry (entry.ts) and is tested with
  a real store, PendingEntries and title follow; tests that could not fail
  are tightened, and the use race is covered.
- Plan: D2 rule 2, D9 and Task 8 say "the page the write landed on".

Deviations: the cap case claims in a second write rather than the same
one, so ordinary writes read nothing extra. canvas_page rename/add/move/
duplicate count every claim in otherChats, since they read no liveness.

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

- forgetChat takes a required scope: "comments" (1a's pass, before a delete
  commits), "all" (adds forgetChatOnCanvas: claim, namedFor marks, artifact
  frames, after the commit) and "move" (adds forgetChatMove for
  moveEmptyToWorkspace). Each skips the write when nothing changes.
- Startup recovery runs through recoverDeletedChatCanvas in cleanup.ts:
  getMeta before the remove, "comments" before it, "all" after it (logged).
- Attach carry claims the first carried page in the same update; a
  ChatPagesFullError skips only the claim.
- Managed-worktree coverage confirmed, no new test: managed delete asserts
  removeWorkspace in workspace-worktree-application-service.test.ts (lines
  191, 371); create rollback removes the record through removeWorkspaceRecord
  (covered in git.test.ts), which the service wires to removeWorkspace.

Deviation: an extra carry test pins that a full chatPages still carries the
pages (no claim), since the task names that skip.

Co-Authored-By: Claude <noreply@anthropic.com>
Each page row carries a trailing tertiary text-small label (the Snooze
submenu's pattern, docs/design-guide.md): "This chat", "This chat · N more",
"1 chat" or "N chats", nothing on a page no chat uses. Counts only, from the
document's chatPages; no titles or ids. The row's accessible name is the page
name, a comma, then the label ("Page 1, This chat"); typeahead still matches
the page name (textValue). The trigger stays "Page: <name>". DesignToolbar
gains a chatId prop from the canvas.

Deviation: before/after screenshots are taken in Task 11's E2E (after only);
the plan's step 4 asks for them at this task.

Co-Authored-By: Claude <noreply@anthropic.com>
- E2E (tests/e2e/design-canvas.spec.ts): two chats on one workspace each
  get their own page (A claims Page 1 as it is, B gets a page named after it
  with namedFor), keep it across sidebar switches, B's picker reads
  "<B's page>, This chat" and "Page 1, 1 chat", B's canvas_page delete of
  Page 1 is refused with "1 other chat", a sidebar rename renames B's page,
  and deleting B drops its claim and mark while its page and note stay.
  savedCanvases' type gains chatPages and namedFor.
- Docs: PRODUCT.md design-mode paragraph (chat pages, picker counts, chat
  delete, attach claim; "the chat's page"), docs/plans/README.md v2 row,
  .memory/design-mode.md Phase 1b section, plan checkboxes.

Deviations:
- B's title is set by sendFirstMessage's rename (the shared helper), so
  it has settled before /design; no auto-title wait was needed.
- The screenshot is taken with B's picker open (step 5), not after the
  delete, so it shows the new labels; it is written light and dark to the
  test's output folder (test.info().outputPath) as well as capture()'s
  AIDEN_DESIGN_SCREENSHOTS folder, so a Cua Space run brings it back.
- The sidebar row menu opens with Shift+F10 on the focused row; the
  hover-revealed ••• button is covered by the row for a pointer click.
- docs/plans/README.md names no 1b PR number yet (none is open).
- No existing E2E expectation needed changing (Risk 11).

Co-Authored-By: Claude <noreply@anthropic.com>
Major:
1. Undo then redo of a turn that added and used a page round-trips. A save
   that removes a chat's page sends the chat to the page the save names for
   it when both documents have it (else the first page); a page a save
   brings back restores every chat the delete record holds that is still
   where the delete moved it, without needing the saved claim. Plan D3 and
   the Saves constraint amended.
2. A restart after a chat delete's remove committed no longer leaves the
   claim, namedFor and artifact frames. Deviation: the workspace id is not
   stored with the pending-deletion record. That record lives in the
   subagent run stores, whose V1 file must have exactly three keys and stay
   readable by rollback builds, so a new field is not backward-compatible.
   Instead recoverDeletedChatCanvas runs "all" on every canvas file
   (DesignCanvasStore.workspaceIds) when the chat's metadata is gone; only
   canvases holding something of the chat's are written. Risk 9 corrected.

Minor:
3. Attaching from a shared legacy No workspace canvas runs forgetChat
   "move" on it.
4. withoutGoneClaims also strips namedFor of chats that are not live;
   entry, canvas_page use and delete check liveness for claimed and named
   chats (chatsOnCanvas), so a gone chat's mark no longer blocks rule 3.
5. The "save lands while the chat is being deleted" claim test is deleted:
   a save captured before the comments pass and sent after "all" is refused
   by the revision check, so it asserted nothing new.
6. Title follow skips chats with no named page without reading the canvas
   once DesignCanvasStore.namedChats (refreshed on every read and write)
   knows the workspace. designLiveChats now does one chat-index list per
   check (liveness.ts, registered test).
7. chatPageId and its test removed; pointers in pages.ts, plan and memory
   fixed.
8. Attach carry asks liveness at a full chatPages so gone chats' entries
   are evicted.
9. Spec §12 gains Phase 1b amendments S16-S18.
10. .memory corrected: only entry, use and delete drop leftover claims.

The reviewers' move.test.ts first-page case is added to the existing
forgetChatMove test; its other cases were already covered.

Co-Authored-By: Claude <noreply@anthropic.com>
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

A delayed design-mode entry can recreate a chat's claim in a workspace after that chat has moved away; the entry write needs workspace-aware admission before merge.

Reviewed changes across the complete 53-file diff, including the shared claim rules, main-process lifecycle, renderer history, picker UI, and behavioral coverage.

  • Claim ownership and entry: main claims a chat's page on entry or first design write, resolves views through the claim, and exposes canvas_page use.
  • Persistence and undo: renderer saves merge with authoritative stored ownership, while deleted-page records and page-wise history preserve claims and named pages through undo and redo.
  • Titles and lifecycle: named pages follow chat titles; delete, move, attach, and startup recovery clean or carry page state and artifact frames.
  • User surface and coverage: the picker reports chat counts without identities, docs describe the new behavior, and focused unit and E2E coverage exercise two-chat workflows. npm run test:design-mode passes all 832 tests locally.

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/entry.ts Resolved
…ay from

Entry and turn placements now ask again on the canvas's chain, before
and after the write, that the chat still belongs to the workspace they
captured. An entry still scanning when its empty chat moves can no
longer recreate its claim, named page or frames on the canvas the move
already cleaned.

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 31d9289e9, including the complete PR diff for context.

  • Workspace-aware placement admission: Rechecked chat workspace membership on the captured canvas chain before writing and after the write, preventing delayed entry or turn placement from restoring state to a workspace the chat left.
  • Race regression coverage: Added a behavioral test that holds entry during asynchronous liveness work, moves the chat, resumes entry, and verifies the old canvas remains unchanged. npm run test:design-mode passes all 833 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 | 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