Repository navigation
refactor(workspace): a Space assignment takes its node from the document (S7 PR 1, #758) - #762
Merged
Merged
Conversation
…ument (#758) assignNodeToSpaceAndExpand loses its createdNode parameter. Its recipe reads the node by createdNodeId when the write runs, so a node that moved or grew after its creator returned it is measured where the document holds it. A node that the document no longer holds changes nothing: no membership, no snapshot Space, no growth, no push. A node without a usable rect gets membership and the stored nodes are laid out as before. assignAgentNodeToTaskSpace loses assignedNode, and the 12 call sites drop the argument. repositionCreatedExplorerNode still returns the placed node: its two callers return it to their own callers. Tests: a moved node is measured from the store, a removed node leaves the document unchanged (also at the recipe, because the store prunes ids of nodes it does not hold), a type test that createdNode and assignedNode are gone, and a guard in the caller specs that the document held the node when each caller assigned it. Specs whose mocked creator did not write its node now have the document hold it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VeCRdryKK6NJBHjH889un3
…ved keys exactly Review round for S7 PR 1: - Every creator of the real node store has written its node to the document when it returns or resolves (10 creators). The caller guard proved only the call order, with stand-in creators. - The type test also checks that neither `createdNode` nor `assignedNode` is a key of the parameter: a `@ts-expect-error` is consumed by any error on its line, so an optional `createdNode?: string` passed `pnpm check` before. - The second directive names `assignedNode`, the parameter it is about. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VeCRdryKK6NJBHjH889un3
12 tasks
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.
💡 Change Scope
📝 What Does This PR Do?
Fixes #758. Part of #761 (S7 of #647): this is S7's PR 1.
A Space assignment now measures the node the document holds, never a copy its caller passes. A caller can no longer make the push-away lay out a rect the node does not occupy.
assignNodeToSpaceAndExpand(workspaceCanvas/hooks/useInteractions.spaceAssignment.ts) loses itscreatedNodeparameter. Its recipe takes the node from the document bycreatedNodeIdwhen the write runs.hasUsableLayoutRectis gone.assignAgentNodeToTaskSpace(useTaskActions.agentSession.shared.ts) losesassignedNodethe same way.repositionCreatedExplorerNode(fix(workspace): return the post-reposition node when assigning to a Space #756) keeps its return value: its two callers return the placed node to their own callers, andworkspaceDocumentOpening.specasserts it. Only its comments changed.What changes at runtime:
Nothing else changes: every caller already wrote its node before assigning (checked below), so in every other case the stored node and the caller's object are the same.
🏗️ Large Change Spec (Required if "Large Change" is checked)
1. Context & Business Logic
The Spec is #761 (S7 of #647): Decision 9, Invariant 2, "#758: the design", and the Plan's "PR 1" in its first comment. The issue itself is #758, written by the repository owner. Its "To check first" and "Guard" items are both done here.
2. State Ownership & Invariants
The workspace document owns the node. A Space assignment computes from the document when its write runs, and from nothing else (Invariant 2 of #761).
Risks that were checked:
setNodes(…, { flush: true })before returning. A guard test checks it per call site (below).3. Verification Plan & Regression Layer
Tests written first, each red on the base for its reason:
spaceAssignment.document.spec"measures the node the store holds when it moved after creation". It replaces the row that pinned the override; on the base, the stale copy's rect was laid out.workspaceSpaceAssignment.spec: the row that passed a caller copy now measures from the store.hooks/useInteractions.spaceAssignment.spec.ts, undersrc/so thatpnpm checkcompiles it. Two@ts-expect-errorlines with the reason, one for each removed parameter. On the base they failed with TS2578 (unused directive).The precondition guard, green on the base. For each call site, the mocked assignment records what the document held when it was called, and the test asserts that the node was there. The pane terminal and the three task-agent sites (run, reused linked agent, resume) run their real functions in a new file,
spaceAssignment.callers.direct.spec.tsx.The Explorer and document opening hand the push-away the created node from before its reposition #725/fix(workspace): return the post-reposition node when assigning to a Space #756 tests keep their intent in a stronger form: they assert the document holds the node at the placed position when the assignment runs, instead of comparing the caller's object.
Specs whose mocked creator returned a node the document did not hold now seed the document, since a missing node is now a no-op. They are
taskRoleHarness, the threecreateTerminalNodeAtFlowPositionspecs andspaceMountLaunchContext.Mutations (7, all killed):
Review. An independent review approved the change with nothing to change in
src. It probed BASE and HEAD with the same calls:It also checked the precondition at all 15 call sites itself, and 15 of 15 too-early mutations were killed. The second commit adds two of its proposals:
@ts-expect-erroris consumed by any error on its line, socreatedNode?: stringpassedpnpm checkbefore. Now it fails with TS2344.It also fixes the second directive's reason, which named the wrong parameter.
Not taken: a row pinning the layout of a created node without a finite rect. It would pin an accidental behaviour, a non-finite rect stopping its Space from growing, rather than an intended one; the row that pins membership stays.
Local runs besides the quick gate in the checklist:
d044c66b: 17 Desktop files, 29 passed. The second commit changes tests only. One test is skipped by atest.skipthat exists onmain(space-explorer.spec.ts:17). The files are:spaces.auto-resize-on-create,node-create.push-away,spaces.note-avoid-overlap,creation-collapsed-space;space-explorer,.layout,.media,.operations;filesystem-drop-position,filesystem-nodes,image-paste;tasks.create-run,tasks.agent-session-menu,tasks.double-click-create;agent-launcher,roles,terminal-links.documents.🔗 Co-change partners left untouched
src/contexts/workspace/presentation/renderer/components/workspaceCanvas/hooks/useAgentNodeLifecycle.ts(withsrc/contexts/workspace/presentation/renderer/components/workspaceCanvas/hooks/useTaskActions.agentSession.run.ts, 6/10): it launches and restarts agents but never assigns a node to a Space. It calls neither function whose parameter this PR removes.✅ Delivery & Compliance Checklist
pnpm verify:quick/pnpm pre-commitis green; any additional focused tests are reported above. On7280f216(onmainat67412e77): 32 files; the repository checks, lint (0 warnings), format and typecheck pass; 1556 related unit tests passed and 131 skipped by declarations that exist onmain(this change adds no skip); 374 native recovery contract tests passed; 17 E2E tests passed with 1 skipped by a declaration that exists onmain.7280f216: every job passed on its first attempt. No manual macOS run: the Spec's Plan marks this PR as not needing one (no rendering, terminal or platform path changes).CLA.md). The commits were written in a Claude Code cloud session and carry the repository owner's git identity as author, at the owner's request.pnpm checkif it comes back, as a directive or as a key.DEVELOPMENT.mdarchitectural boundaries.DEVELOPMENT.mdchange is needed for this step.📸 Screenshots / Visual Evidence
Not applicable: no visual change is intended.
🤖 Generated with Claude Code
https://claude.ai/code/session_01VeCRdryKK6NJBHjH889un3