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(breadcrumbs): resume card offers distinct places, keyed per occurrence
Mina Sameh1851fd3619f6
diff --git a/src/renderer/components/ResumeCard.test.tsx b/src/renderer/components/ResumeCard.test.tsxindex f7fb49cf5..d08b64c2a 100644--- a/src/renderer/components/ResumeCard.test.tsx+++ b/src/renderer/components/ResumeCard.test.tsx@@ -95,6 +95,61 @@ describe('ResumeCard', () => {expect(rows()[2].textContent).toContain('terminal · A')})+ it('offers a revisited node once, at its newest position', async () => {+ // A breadcrumb list is a HISTORY: recordBreadcrumb appends the same node again once the dedupe+ // window has passed, so an ordinary A → B → A round trip lists 'a' twice. Two rows for one+ // place would spend a slot saying nothing new (and collide as React keys).+ const breadcrumbs: NavStop[] = [+ { nodeId: 'a', at: 1000, note: 'terminal · A' },+ { nodeId: 'b', at: 2000, note: 'terminal · B' },+ { nodeId: 'a', at: 3000, note: 'terminal · A again' },+ { nodeId: 'c', at: 4000, note: 'terminal · C' }+ ]+ await renderCard(project(breadcrumbs), [{ id: 'a' }, { id: 'b' }, { id: 'c' }], () => {})+ expect(rows()).toHaveLength(3)+ expect(rows()[0].textContent).toContain('terminal · C')+ // 'a' takes the newest occurrence's slot (ahead of 'b'), carrying that occurrence's note.+ expect(rows()[1].textContent).toContain('terminal · A again')+ expect(rows()[2].textContent).toContain('terminal · B')+ })++ it('fills all 3 slots from further back when a node is revisited', async () => {+ // De-duping must not COST a row: the card still offers three distinct places when the trail+ // holds them, even though its newest four entries only name three nodes.+ const breadcrumbs: NavStop[] = [+ { nodeId: 'a', at: 1000, note: 'terminal · A' },+ { nodeId: 'b', at: 2000, note: 'terminal · B' },+ { nodeId: 'c', at: 3000, note: 'terminal · C' },+ { nodeId: 'b', at: 4000, note: 'terminal · B again' }+ ]+ await renderCard(project(breadcrumbs), [{ id: 'a' }, { id: 'b' }, { id: 'c' }], () => {})+ expect(rows()).toHaveLength(3)+ expect(rows()[0].textContent).toContain('terminal · B again')+ expect(rows()[1].textContent).toContain('terminal · C')+ expect(rows()[2].textContent).toContain('terminal · A')+ })++ it('does not warn about duplicate React keys when a node is revisited', async () => {+ // The de-dupe is a behavior rule; the keys must be unique on their own terms. A console.error+ // here is React's "Encountered two children with the same key" — the app console and this+ // suite's output are both meant to be pristine.+ const spy = vi.spyOn(console, 'error').mockImplementation(() => {})+ try {+ await renderCard(+ project([+ { nodeId: 'a', at: 1000, note: 'terminal · A' },+ { nodeId: 'a', at: 2000, note: 'terminal · A again' }+ ]),+ [{ id: 'a' }],+ () => {}+ )+ expect(rows()).toHaveLength(1)+ expect(spy).not.toHaveBeenCalled()+ } finally {+ spy.mockRestore()+ }+ })+it('clicking a row calls onOpen with the node id', async () => {const onOpen = vi.fn<(id: string) => void>()await renderCard(diff --git a/src/renderer/components/ResumeCard.tsx b/src/renderer/components/ResumeCard.tsxindex 0a218c26b..7bea6c87d 100644--- a/src/renderer/components/ResumeCard.tsx+++ b/src/renderer/components/ResumeCard.tsx@@ -1,5 +1,5 @@import { useMemo, useState } from 'react'-import type { Project } from '@shared/types'+import type { NavStop, Project } from '@shared/types'import { relativeTime } from '../lib/relativeTime'/** How many stops the card offers. Small on purpose: this is "where was I?", not the whole trail. */@@ -22,20 +22,30 @@ interface ResumeCardProps {* the parent with a new `project` object, and without a local flag that would resurrect a card the* user just closed in the same activation.*- * The rows are filtered BEFORE they are capped: slicing the raw tail first would show fewer than- * `RESUME_CARD_COUNT` rows whenever the newest stops point at nodes that have since been deleted.+ * The rows are filtered and de-duplicated BEFORE they are capped: slicing the raw tail first would+ * show fewer than `RESUME_CARD_COUNT` rows whenever the newest stops point at nodes that have since+ * been deleted, or at a node the trail already offers. A breadcrumb list is a HISTORY, not a set —+ * `recordBreadcrumb` appends the same node again once `BREADCRUMB_DEDUPE_MS` has passed, so an+ * ordinary A → B → A round trip (the exact pattern this feature exists for) puts A in the list+ * twice. The card offers the last few DISTINCT places, newest occurrence of each: re-offering a+ * place already on the card would spend one of three slots saying nothing new.*/export function ResumeCard({ project, nodes, onOpen }: ResumeCardProps): JSX.Element | null {const [dismissed, setDismissed] = useState(false)const liveIds = useMemo(() => new Set(nodes.map((n) => n.id)), [nodes])- const rows = useMemo(- () =>- (project.breadcrumbs ?? [])- .filter((stop) => liveIds.has(stop.nodeId))- .slice(-RESUME_CARD_COUNT)- .reverse(),- [project.breadcrumbs, liveIds]- )+ const rows = useMemo(() => {+ const all = project.breadcrumbs ?? []+ const picked: NavStop[] = []+ const seen = new Set<string>()+ // Newest first, so the occurrence kept for a revisited node is its most recent one.+ for (let i = all.length - 1; i >= 0 && picked.length < RESUME_CARD_COUNT; i--) {+ const stop = all[i]+ if (!liveIds.has(stop.nodeId) || seen.has(stop.nodeId)) continue+ seen.add(stop.nodeId)+ picked.push(stop)+ }+ return picked+ }, [project.breadcrumbs, liveIds])if (dismissed || rows.length === 0) return null@@ -55,7 +65,9 @@ export function ResumeCard({ project, nodes, onOpen }: ResumeCardProps): JSX.Ele<div className="resume-card__rows">{rows.map((stop) => (<button- key={stop.nodeId}+ // Keyed by OCCURRENCE (`at` is unique per stop), not by node: a node id is not unique+ // in a history, and the de-dupe above is a behavior rule, not a key guarantee.+ key={`${stop.nodeId}:${stop.at}`}className="resume-card__row"data-testid="resume-card-row"onClick={() => onOpen(stop.nodeId)}