Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
fix(canvas): make in-place project reload actually reload
enesca2cf463c95c
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex 98198f300..75f9261f2 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -990,6 +990,9 @@ export function Canvas() {}, [getViewport, setViewport])const activeProjectId = useProjects((s) => s.activeProjectId)+ // Bumped by `requestReload()`; a dependency of the project-load effect so an in-place reload of+ // the ALREADY-active project actually re-runs it (see reloadActiveProject).+ const reloadNonce = useProjects((s) => s.reloadNonce)// The ACTIVE session + its presence — what the canvas-sync publisher and onMutation subscriber// must follow (Task 4). `sessionForProject` / `presenceForProject` are plain, allocation-free// resolves of the memoized (per-core) session/presence — NOT reactive subscriptions to the peer@@ -1572,7 +1575,8 @@ export function Canvas() {}}, [])- // 2) Whenever the active project changes, load its canvas into React Flow.+ // 2) Whenever the active project changes — or an in-place reload is requested (`reloadNonce`,+ // which changes even when the SAME project is reloaded) — load its canvas into React Flow.useEffect(() => {// Team presence: tell the hub which canvas we are on (this effect fires on load AND on every// tab switch). Peers only draw each other's cursors and node chips when the project matches —@@ -1705,7 +1709,7 @@ export function Canvas() {}, 0)return () => clearTimeout(t)// eslint-disable-next-line react-hooks/exhaustive-deps- }, [activeProjectId, setNodes, setViewport])+ }, [activeProjectId, reloadNonce, setNodes, setViewport])const markDirty = useCallback(() => {if (!loadingRef.current) setDirty(true)@@ -1798,8 +1802,13 @@ export function Canvas() {dirtyRef.current = dirty}, [dirty])- /** Re-runs the active-project load effect by nudging its dependency: flip the active id- * to '' (the effect early-returns) then back to the same id on a microtask.+ /** Re-runs the active-project load effect by bumping the store's `reloadNonce`.+ *+ * This used to flip the active id to '' and back on a microtask. React coalesces both writes+ * into ONE render, so the effect's dependency never actually changed and the reload silently+ * never happened — the store held disk's version while React Flow still showed the old nodes,+ * and the next debounced persist wrote those old nodes straight back over disk (field bug+ * 2026-08-10). A monotonic nonce always changes, so the reload always runs.** An in-place reload PRESERVES the current camera (preserveViewportRef): the incoming* file's viewport is wherever ANOTHER machine/surface last left it, and SSH projects@@ -1807,10 +1816,8 @@ export function Canvas() {* the camera away mid-work, most visibly right after a cross-project focus (the sidebar* click centered the node, then the connect-time reconcile teleported the view). */const reloadActiveProject = useCallback(() => {- const id = useProjects.getState().activeProjectIdpreserveViewportRef.current = true- useProjects.getState().setActive('')- queueMicrotask(() => useProjects.getState().setActive(id))+ useProjects.getState().requestReload()}, [])// Outside edits to a project's .nodeterm file (git pull / sync / teammate / another machine).diff --git a/src/renderer/state/projects.test.ts b/src/renderer/state/projects.test.tsindex f85b17abc..9db42d4a0 100644--- a/src/renderer/state/projects.test.ts+++ b/src/renderer/state/projects.test.ts@@ -71,6 +71,46 @@ describe('toWorkspace', () => {})})+// Regression (field bug 2026-08-10): `reloadActiveProject` used to re-run Canvas's load effect by+// flipping the active id to '' and back on a microtask. React coalesces both writes into ONE+// render, so the effect's dependency never changed and the reload silently never happened: the+// store held disk's version while React Flow still showed the old nodes, and the next debounced+// persist wrote those old nodes back over disk. A monotonic nonce is a dependency that always+// changes, even for a reload of the SAME project.+describe('requestReload', () => {+ it('bumps a monotonic nonce on every call', () => {+ const start = useProjects.getState().reloadNonce+ useProjects.getState().requestReload()+ expect(useProjects.getState().reloadNonce).toBe(start + 1)+ useProjects.getState().requestReload()+ useProjects.getState().requestReload()+ expect(useProjects.getState().reloadNonce).toBe(start + 3)+ })++ it('leaves the active project (and the projects) untouched — it only nudges the effect', () => {+ const p = useProjects.getState().openFolderProject('/Users/me/dev/my-app')+ useProjects.getState().requestReload()+ const s = useProjects.getState()+ expect(s.activeProjectId).toBe(p.id)+ expect(s.projects).toHaveLength(1)+ })++ // hydrate() replaces the persisted dimensions only: a nonce that reset on load would let a+ // pre-hydrate reload request be re-delivered (or lost) after it.+ it('survives hydrate, so the nonce never goes backwards', () => {+ useProjects.getState().requestReload()+ const n = useProjects.getState().reloadNonce+ useProjects.getState().hydrate({ version: 2, activeProjectId: '', projects: [] })+ expect(useProjects.getState().reloadNonce).toBe(n)+ })++ // The nonce is a RUNTIME nudge, never part of the shared workspace file.+ it('is not persisted', () => {+ useProjects.getState().requestReload()+ expect(JSON.stringify(useProjects.getState().toWorkspace())).not.toMatch(/reloadNonce/)+ })+})+describe('setDinoHighScore', () => {it('raises the project record and never lowers it', () => {const p = useProjects.getState().addProject('game', '/tmp/game')diff --git a/src/renderer/state/projects.ts b/src/renderer/state/projects.tsindex 4b493ba48..c0030f171 100644--- a/src/renderer/state/projects.ts+++ b/src/renderer/state/projects.ts@@ -14,8 +14,22 @@ import { applyCanvasMutation, createProject } from './workspace'interface ProjectsState {projects: Project[]activeProjectId: string+ /**+ * Monotonic counter the Canvas project-load effect depends on: bumping it re-runs the load, even+ * for the project that is ALREADY active. Runtime-only (never persisted — see toWorkspace) and+ * never reset, not even by hydrate.+ *+ * Field bug 2026-08-10: an in-place reload used to be faked by setting the active id to '' and+ * back on a microtask. React coalesces both writes into one render, so the effect's dependency+ * never changed and the reload never happened — the store held disk's version while React Flow+ * still showed the old nodes, and the next debounced save wrote those old nodes back over disk.+ */+ reloadNonce: numberhydrate(ws: Workspace): void+ /** Asks Canvas to reload the active project's canvas from the store (external change adopted,+ * conflict resolved as "reload"). See `reloadNonce`. */+ requestReload(): voidgetProject(id: string): Project | undefinedsetActive(id: string): void@@ -133,11 +147,16 @@ function mapProjectNodes(export const useProjects = create<ProjectsState>((set, get) => ({projects: [],activeProjectId: '',+ reloadNonce: 0,hydrate(ws) {set({ projects: ws.projects, activeProjectId: ws.activeProjectId })},+ requestReload() {+ set((s) => ({ reloadNonce: s.reloadNonce + 1 }))+ },+getProject(id) {return get().projects.find((p) => p.id === id)},