You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(workspace): return the post-reposition node when assigning to a Space - #756
When the Space explorer opens a file into a Space (or a document opens from a terminal link), repositionCreatedExplorerNode may move the created node to a free spot and write the new position to the store — but assignNodeToSpaceAndExpand was then called with the pre-move created object. The push-away replaces the store's copy of the created node with the createdNode it is given when that one has a usable rect, so it grew the Space and pushed neighbours around the node's old position while the node sat at the new one.
This PR has repositionCreatedExplorerNode return the node as stored after the reposition (the moved node, or the created node itself when it did not move), and both call sites — useSpaceExplorer.ts (image materialization) and useWorkspaceDocumentOpening.ts (document opening) — now hand that returned node to the push-away and return it to their callers, so the Space is grown and neighbours are pushed around the rect the node actually occupies.
🏗️ Large Change Spec (Required if "Large Change" is checked)
Not applicable — this is a Small Change.
🔗 Co-change partners left untouched
src/contexts/workspace/presentation/renderer/components/workspaceCanvas/hooks/useInteractions.spaceAssignment.ts (assignNodeToSpaceAndExpand) — no change needed: the push-away itself is correct; only the node handed to it was stale.
The other assignNodeToSpaceAndExpand callers (useAgentLauncher, useCanvasImageImport, useFilesystemNodes, useInteractions.noteCreation, useInteractions.paneNodeCreation, useRoleActions, useTaskActions.agentSession.shared, useTaskNodeCreation) — no change needed: none of them calls repositionCreatedExplorerNode, so the stale-node pattern does not apply there.
src/contexts/workspace/presentation/renderer/utils/collision.ts (findNearestFreePositionOnRight) — no change needed: the scan itself returns the right spot; only its result was discarded by the callers.
✅ Delivery & Compliance Checklist
The local quick gate passes: pnpm verify:quick / pnpm pre-commit is green; any additional focused tests are reported above.
Full CI passes on the final revision before merge; local quick checks are not reported as full regression.
I have signed the CLA if required (see CLA.md).
I have locked down the behavior with the strongest asset that fits, in this order: type or structure, mechanical check, runtime assertion, scenario test (or explicitly stated why none applies).
I have strictly adhered to the DEVELOPMENT.md architectural boundaries.
I have attached a screenshot or screen recording (if this touches the UI).
I have updated the documentation accordingly (if adding a feature or changing a contract).
📸 Screenshots / Visual Evidence
Not applicable — no UI change.
Verification (targeted gates run locally; full verify:quick left for pre-submit/CI)
New failing-first tests, then the fix (TDD red → green): repositionCreatedExplorerNode returns the moved node; the document-opening caller and the explorer image caller hand the push-away the moved rect.
Adjacent suites, 66 tests, all green: pnpm vitest run tests/unit/contexts/useSpaceExplorer.materializePlacement.spec.ts tests/unit/contexts/workspaceDocumentOpening.spec.tsx tests/unit/contexts/spaceAssignment.callers.documents.spec.tsx tests/unit/contexts/spaceAssignment.callers.spec.tsx tests/unit/contexts/workspaceSpaceAssignment.spec.ts tests/unit/contexts/spaceAssignment.document.spec.tsx
pnpm check (tsc) — clean.
oxlint --max-warnings=0 on the 6 touched files — 0 warnings, 0 errors.
prettier --check on the 6 touched files — clean.
pnpm test-gates:check — counts match the baseline.
node scripts/check-max-lines.mjs — all files within 1000 lines.
Note: pnpm impact could not run in this sandbox (fails with EMFILE: too many open files); the co-change section above was compiled by hand from the callers of the touched functions. The verify:quick box is left unchecked until that gate is run before submit.
Merged, thanks @anhnt256. Checked: repositionCreatedExplorerNode now returns the node with the position it just wrote to the store, both callers hand that node to the push-away, and the new tests put the reposition and the push-away in the same scenario, as #725 asked. CI was green on the final revision, which was based on current main.
On the asset: a structural fix is stronger than a test here. createdNode was added in #326 because the push-away read a stale nodesRef projection. Since #647 the push-away reads the document when the write runs, so the parameter is now just a way for a caller to hand in a stale node. Removing it touches all eleven callers, which is beyond a bug fix, so it is tracked in #758. Your tests stay there as the regression for #725.
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
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 #725.
When the Space explorer opens a file into a Space (or a document opens from a terminal link),
repositionCreatedExplorerNodemay move the created node to a free spot and write the new position to the store — butassignNodeToSpaceAndExpandwas then called with the pre-movecreatedobject. The push-away replaces the store's copy of the created node with thecreatedNodeit is given when that one has a usable rect, so it grew the Space and pushed neighbours around the node's old position while the node sat at the new one.This PR has
repositionCreatedExplorerNodereturn the node as stored after the reposition (the moved node, or the created node itself when it did not move), and both call sites —useSpaceExplorer.ts(image materialization) anduseWorkspaceDocumentOpening.ts(document opening) — now hand that returned node to the push-away and return it to their callers, so the Space is grown and neighbours are pushed around the rect the node actually occupies.🏗️ Large Change Spec (Required if "Large Change" is checked)
Not applicable — this is a Small Change.
🔗 Co-change partners left untouched
src/contexts/workspace/presentation/renderer/components/workspaceCanvas/hooks/useInteractions.spaceAssignment.ts(assignNodeToSpaceAndExpand) — no change needed: the push-away itself is correct; only the node handed to it was stale.assignNodeToSpaceAndExpandcallers (useAgentLauncher,useCanvasImageImport,useFilesystemNodes,useInteractions.noteCreation,useInteractions.paneNodeCreation,useRoleActions,useTaskActions.agentSession.shared,useTaskNodeCreation) — no change needed: none of them callsrepositionCreatedExplorerNode, so the stale-node pattern does not apply there.src/contexts/workspace/presentation/renderer/utils/collision.ts(findNearestFreePositionOnRight) — no change needed: the scan itself returns the right spot; only its result was discarded by the callers.✅ Delivery & Compliance Checklist
pnpm verify:quick/pnpm pre-commitis green; any additional focused tests are reported above.CLA.md).DEVELOPMENT.mdarchitectural boundaries.📸 Screenshots / Visual Evidence
Not applicable — no UI change.
Verification (targeted gates run locally; full
verify:quickleft for pre-submit/CI)repositionCreatedExplorerNodereturns the moved node; the document-opening caller and the explorer image caller hand the push-away the moved rect.pnpm vitest run tests/unit/contexts/useSpaceExplorer.materializePlacement.spec.ts tests/unit/contexts/workspaceDocumentOpening.spec.tsx tests/unit/contexts/spaceAssignment.callers.documents.spec.tsx tests/unit/contexts/spaceAssignment.callers.spec.tsx tests/unit/contexts/workspaceSpaceAssignment.spec.ts tests/unit/contexts/spaceAssignment.document.spec.tsxpnpm check(tsc) — clean.oxlint --max-warnings=0on the 6 touched files — 0 warnings, 0 errors.prettier --checkon the 6 touched files — clean.pnpm test-gates:check— counts match the baseline.node scripts/check-max-lines.mjs— all files within 1000 lines.pnpm impactcould not run in this sandbox (fails withEMFILE: too many open files); the co-change section above was compiled by hand from the callers of the touched functions. Theverify:quickbox is left unchecked until that gate is run before submit.