Skip to content

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.

feat(breadcrumbs): record a stop on every deliberate goToNode landing

Mina Sameh7bd477bdffcf
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index ff6f5bf77..1036d36de 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -214,6 +214,11 @@ import {
viewportForRect,
type FocusableNode
} from '../lib/nodeFocus'
+import {
+ recordBreadcrumb,
+ type BreadcrumbState,
+ type BreadcrumbTarget
+} from '../lib/breadcrumbs'
import { planSessionKill } from '../lib/sessionKill'
import { RemoteAccessDialog } from '../components/RemoteAccessDialog'
import { SshProjectDialog } from '../components/SshProjectDialog'
@@ -1112,6 +1117,11 @@ export function Canvas() {
const pastRef = useRef<CanvasNode[][]>([])
const futureRef = useRef<CanvasNode[][]>([])
const committedRef = useRef<CanvasNode[]>([])
+ // Camera navigation history — a SEPARATE stack from pastRef/futureRef (those replay node-array
+ // state; this replays camera position only). NOT persisted itself: only navRef.current.list
+ // rides IndexEntryV3.breadcrumbs; the cursor resets to the tip on every project activation
+ // (see the active-project effect below), same as pastRef/futureRef resetting there.
+ const navRef = useRef<BreadcrumbState>({ list: [], index: -1 })
const draggingRef = useRef(false)
// Canvas sync (emitting side) — see the publish effect below.
const publisherRef = useRef<CanvasPublisher | null>(null)
@@ -1927,6 +1937,10 @@ export function Canvas() {
pastRef.current = []
futureRef.current = []
bumpHist((v) => v + 1)
+ // Camera navigation history is per-project; reset the cursor to the tip on every activation
+ // (a project reactivated after being away starts "at the end" of its own trail).
+ const bc = project.breadcrumbs ?? []
+ navRef.current = { list: bc, index: bc.length - 1 }
if (preserveViewportRef.current) {
// In-place reload (external change / SSH reconcile): keep the user's current camera —
// the file's viewport is where another machine last saved, not where this user looks.
@@ -5591,6 +5605,27 @@ export function Canvas() {
const goToNode = useCallback(
(node: Node) => {
+ // Record the landing FIRST, and unconditionally: this is the one funnel every deliberate
+ // node focus goes through (notification click, sessions sidebar, ⌘K jump, presence travel,
+ // minimap double-click), and recording is independent of which framing branch runs below —
+ // including the branch that deliberately leaves the camera where it is.
+ const activeId = useProjects.getState().activeProjectId
+ if (activeId) {
+ const target: BreadcrumbTarget = {
+ id: node.id,
+ kind: node.type as BreadcrumbTarget['kind'],
+ title: (node.data as { title?: string } | undefined)?.title ?? node.id,
+ agentId: (node.data as { agentId?: BreadcrumbTarget['agentId'] } | undefined)?.agentId
+ }
+ const status = useAgentStatus.getState().byId[node.id]
+ const next = recordBreadcrumb(navRef.current, target, status, Date.now())
+ // recordBreadcrumb returns the SAME object on a dedupe no-op, so identity is the skip test.
+ if (next !== navRef.current) {
+ navRef.current = next
+ useProjects.getState().setProjectBreadcrumbs(activeId, next.list)
+ markDirty()
+ }
+ }
// Fit the node in view instead of centering at a fixed zoom — `zoom: max(current, 1)`
// overshot large terminals (their body never fit the viewport). fitView sizes the zoom
// to the node and resolves group-relative positions itself; the clamp keeps a small
@@ -5636,7 +5671,7 @@ export function Canvas() {
// teleporting the user to the origin, which is the bug this branch exists for.
if (viewport) void setViewport(viewport, { duration: 300 })
},
- [fitView, setViewport, getInternalNode]
+ [fitView, setViewport, getInternalNode, markDirty]
)
const onNodeDoubleClick = useCallback(
diff --git a/src/renderer/state/projects.breadcrumbs.test.ts b/src/renderer/state/projects.breadcrumbs.test.ts
new file mode 100644
index 000000000..b85235b75
--- /dev/null
+++ b/src/renderer/state/projects.breadcrumbs.test.ts
@@ -0,0 +1,31 @@
+import { describe, it, expect, beforeEach } from 'vitest'
+import { useProjects } from './projects'
+
+const baseProject = {
+ id: 'p1',
+ name: 'p',
+ color: '#fff',
+ viewport: { x: 0, y: 0, zoom: 1 },
+ nodes: []
+}
+
+describe('setProjectBreadcrumbs', () => {
+ beforeEach(() => {
+ useProjects.getState().hydrate({
+ version: 2,
+ activeProjectId: 'p1',
+ projects: [{ ...baseProject }]
+ })
+ })
+
+ it("replaces the project's breadcrumb list", () => {
+ const stop = { nodeId: 'n1', at: 1000, note: 'terminal · t' }
+ useProjects.getState().setProjectBreadcrumbs('p1', [stop])
+ expect(useProjects.getState().getProject('p1')?.breadcrumbs).toEqual([stop])
+ })
+
+ it('is a no-op for an unknown project id', () => {
+ useProjects.getState().setProjectBreadcrumbs('nope', [{ nodeId: 'n1', at: 1, note: '' }])
+ expect(useProjects.getState().getProject('p1')?.breadcrumbs).toBeUndefined()
+ })
+})
diff --git a/src/renderer/state/projects.ts b/src/renderer/state/projects.ts
index f12be87a6..9bee46b63 100644
--- a/src/renderer/state/projects.ts
+++ b/src/renderer/state/projects.ts
@@ -4,6 +4,7 @@ import type {
BridgeLink,
CanvasMutation,
CanvasNodeState,
+ NavStop,
Project,
ProjectKanban,
Viewport,
@@ -90,6 +91,9 @@ interface ProjectsState {
setDinoHighScore(id: string, score: number): void
/** Replaces the project's kanban board (the UI computes the next board via lib/kanban). */
setProjectKanban(id: string, kanban: ProjectKanban): void
+ /** Replaces the project's breadcrumb (navigation history) list wholesale — the UI computes the
+ * next list via lib/breadcrumbs and hands it over whole, same convention as setProjectKanban. */
+ setProjectBreadcrumbs(id: string, breadcrumbs: NavStop[]): void
/** Writes the serialized canvas (nodes + viewport + bridge links + control ropes) back into a project. */
commitCanvas(
id: string,
@@ -394,6 +398,12 @@ export const useProjects = create<ProjectsState>((set, get) => ({
}))
},
+ setProjectBreadcrumbs(id, breadcrumbs) {
+ set((s) => ({
+ projects: s.projects.map((p) => (p.id === id ? { ...p, breadcrumbs } : p))
+ }))
+ },
+
commitCanvas(id, nodes, viewport, bridges, ropes) {
set((s) => ({
projects: s.projects.map((p) =>