Fix node button reactivity by using Praxis store dispatch#25
Fix node button reactivity by using Praxis store dispatch#25kayodebristol merged 4 commits intomainfrom
Conversation
Fixed the issue where add node buttons didn't work by: 1. Using spread operator instead of push() for immutable updates 2. Using praxisStore.dispatch() instead of canvasEngine.step() 3. Ensuring single praxisStore instance is shared across modules Co-authored-by: kayodebristol <3579196+kayodebristol@users.noreply.github.com>
Co-authored-by: kayodebristol <3579196+kayodebristol@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes non-reactive node toolbar buttons by ensuring canvas updates go through the Praxis Svelte store so subscribers are notified consistently.
Changes:
- Route all canvas actions through
praxisStoreInternal.dispatch()instead of callingcanvasEngine.step()directly. - Update add-node / add-connection rules to use immutable array reassignment to support reactivity.
- Reuse a single Praxis store instance from
canvas-praxis.tsincanvas.tsto avoid duplicate store instances.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/lib/stores/canvas.ts | Reuses the shared Praxis store instance instead of creating a second store. |
| src/lib/stores/canvas-praxis.ts | Adds exported store instance and switches actions/rules to patterns that trigger subscriber updates. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/lib/stores/canvas.ts
Outdated
| import { canvasPraxisStore, praxisStoreInternal, canvasEngine, type CanvasContext } from './canvas-praxis'; | ||
| import type { Canvas, CanvasNode, Connection } from '../types/canvas'; |
There was a problem hiding this comment.
CanvasContext and CanvasNode are imported but no longer used in this module after switching to praxisStoreInternal. If svelte-check/TS noUnusedLocals is enabled (common in SvelteKit), this will fail the check step. Remove the unused imports or use them for explicit typing where needed.
| import { canvasPraxisStore, praxisStoreInternal, canvasEngine, type CanvasContext } from './canvas-praxis'; | |
| import type { Canvas, CanvasNode, Connection } from '../types/canvas'; | |
| import { canvasPraxisStore, praxisStoreInternal, canvasEngine } from './canvas-praxis'; | |
| import type { Canvas, Connection } from '../types/canvas'; |
There was a problem hiding this comment.
Removed unused CanvasContext and CanvasNode type imports in commit 6fceead.
|
@copilot apply changes based on the comments in this thread |
…used imports - Renamed praxisStoreInternal to canvasPraxisStoreInstance to avoid implying it's a private/internal API - Removed unused CanvasContext and CanvasNode type imports from canvas.ts - All tests pass (81 tests) - No TypeScript errors Co-authored-by: kayodebristol <3579196+kayodebristol@users.noreply.github.com>
|
@copilot apply changes based on the comments in this thread |
All changes from the code review have already been applied in commit 6fceead:
All tests pass (81 tests) and there are no TypeScript errors. |
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.