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(context-link): publish live links without render starvation
enes4519b476d85c
diff --git a/CLAUDE.md b/CLAUDE.mdindex f108819c7..8d0829fa1 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -2681,8 +2681,15 @@ else, and its context links must keep classifying across restarts).**authorization** = the doc is selected by the REQUESTER's node id, so a token-holding callercan only read nodes in its own (directional) link map. Codex/gemini paths resolve via thehandoff locators (`locateCodex`/`locateGemini` by sessionId); claude keeps the hook-fed path +- `locateClaude(sessionId, accountId)` fallback (cwd-newest is claude-only); Canvas rewrites link- files when a linked node's sessionId appears (`linkSessionSig`). **SSH projects:** the shim ++ `locateClaude(sessionId, accountId)` fallback (cwd-newest is claude-only).+ `useContextLinkSync` publishes semantic map changes from live edges and subscribes to+ background project/status changes. Geometry/status render churn cannot postpone publication;+ relay-bound projects never enter the local core's map. A render-captured project epoch prevents+ outgoing live nodes replacing the incoming project's persisted map during a tab switch. Core+ replaces the read authorization map synchronously, then enriches/writes debug documents through+ a recoverable serialized queue; revision checks prevent obsolete enrichment restoring a removed+ link. Transcript paths can be temporarily unavailable while the current snapshot is enriched.+ **SSH projects:** the shim +skill are installed on the remote host at connect (`RemoteHooks.installContextLink`, gated onthe VERIFIED reverse hook tunnel; POSTs ride `--unix-socket` through it); a remote node'stranscript is read over the ControlMaster (`initContextLink(ptyManager, deps)` — `src/main`diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 0223794bd..fec05d526 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -56,6 +56,12 @@ handler needs something only Electron has (an SSH ControlMaster, a native dialog**injected dep** whose absence is a documented degrade — see `registerTranscriptIpc` /`registerContextEnsureIpc` — rather than a reason to keep the whole handler in `src/main`.+Context-link maps authorize reads. Publish changes to edges, linked metadata, and background+projects independently of canvas geometry updates; a debounce reset by every node render can+starve publication indefinitely. Only merge projects owned by the same core, and use the rendered+canvas's project epoch during tab switches. Core must revoke removed links before asynchronous+transcript discovery or debug-file writes finish; an older write must never restore that access.+## Three surfacesA feature is not done until you have decided how it behaves on each — even if the decision is "notdiff --git a/src/core/context-link.handler.test.ts b/src/core/context-link.handler.test.tsindex a2f89cda4..14dc87fb6 100644--- a/src/core/context-link.handler.test.ts+++ b/src/core/context-link.handler.test.ts@@ -2,10 +2,10 @@// The cli test drives the shim against a stand-in handler; this one drives the actual code that// decides WHICH bytes a request may see, which is the part with teeth.import { describe, it, expect, beforeEach, afterAll, vi } from 'vitest'-import { mkdtempSync, rmSync, writeFileSync } from 'node:fs'+import { mkdtempSync, rmSync, writeFileSync, readFileSync, existsSync } from 'node:fs'import { tmpdir } from 'node:os'import { join } from 'node:path'-import { handleContextLinkRequest, initContextLink, type ContextLinkDeps } from './context-link'+import { handleContextLinkRequest, initContextLink, setContextLinks, type ContextLinkDeps } from './context-link'import { setNodeTranscript } from './context-link-core'import { IPC } from '../shared/ipc'import { initPlatform, resetPlatformForTests } from './platform'@@ -180,3 +180,60 @@ describe('handleContextLinkRequest — remote (SSH) reads', () => {)})})++// Hold transcript discovery at a deterministic boundary, without touching real sessions.+vi.mock('./handoff/locate', async (original) => ({+ ...await original<typeof import('./handoff/locate')>(),+ locateCodex: vi.fn(async () => undefined)+}))++it('publishes permissions immediately and cannot resurrect revoked links from an older write', async () => {+ const { locateCodex } = await import('./handoff/locate')+ let release!: (path: undefined) => void+ let entered!: () => void+ const started = new Promise<void>((resolve) => { entered = resolve })+ vi.mocked(locateCodex).mockImplementationOnce(async () => {+ entered()+ return await new Promise<undefined>((resolve) => { release = resolve })+ })+ const old = setContextLinks({ 'node-A': [{ id: 'node-B', title: 'Old', agentId: 'codex', sessionId: 'slow' }] })+ await started+ let releaseNext!: (path: undefined) => void+ let enteredNext!: () => void+ const nextStarted = new Promise<void>((resolve) => { enteredNext = resolve })+ vi.mocked(locateCodex).mockImplementationOnce(async () => {+ enteredNext()+ return await new Promise<undefined>((resolve) => { releaseNext = resolve })+ })+ const map = { 'node-C': [{ id: 'node-D', title: 'New', agentId: 'codex', sessionId: 'slow-next' }] }+ const next = setContextLinks(map)+ // The caller cannot mutate a queued authorization snapshot after submission.+ map['node-C'][0].id = 'node-SECRET'+ try {+ expect(await handleContextLinkRequest({ verb: 'list', nodeId: 'node-C', args: {} })).toContain('node-D')+ expect(await handleContextLinkRequest({ verb: 'terminal', nodeId: 'node-A', args: {} })).toContain('No linked nodes')+ expect(captured).toEqual([])+ release(undefined)+ await nextStarted+ // Old enrichment has finished but the newer enrichment is still blocked. The old ACL+ // must not be visible even temporarily between those completions.+ expect(await handleContextLinkRequest({ verb: 'list', nodeId: 'node-A', args: {} })).toContain('No linked nodes')+ expect(await handleContextLinkRequest({ verb: 'list', nodeId: 'node-C', args: {} })).toContain('node-D')+ } finally {+ release(undefined)+ await nextStarted+ releaseNext(undefined)+ await Promise.all([old, next])+ }+ expect(await handleContextLinkRequest({ verb: 'list', nodeId: 'node-A', args: {} })).toContain('No linked nodes')+ expect(existsSync(join(dir, 'context-links', 'node-A.json'))).toBe(false)+ expect(JSON.parse(readFileSync(join(dir, 'context-links', 'node-C.json'), 'utf8')).links[0].id).toBe('node-D')+})++it('recovers the write queue after enrichment fails', async () => {+ start({ isRemoteNode: () => { throw new Error('lookup failed') } })+ await expect(setContextLinks({ a: [{ id: 'b', title: 'B', agentId: 'codex' }] })).rejects.toThrow('lookup failed')+ await setContextLinks({ a: [{ id: 'note', title: 'Recovered', note: 'safe fixture' }] })+ expect(await handleContextLinkRequest({ verb: 'list', nodeId: 'a', args: {} })).toContain('Recovered')+ expect(JSON.parse(readFileSync(join(dir, 'context-links', 'a.json'), 'utf8')).links[0].note).toBe('safe fixture')+})diff --git a/src/core/context-link.ts b/src/core/context-link.tsindex fbd9349d9..b02d98f63 100644--- a/src/core/context-link.ts+++ b/src/core/context-link.ts@@ -138,21 +138,16 @@ const LINK_LOCATORS = { claude: locateClaude, codex: locateCodex, gemini: locate// The link documents, by node id — the same objects written to disk, kept in memory because they// are what authorizes a read (a node may only ever name a link inside ITS OWN document).-const linkDocs = new Map<string, LinkDoc>()+let linkDocs = new Map<string, LinkDoc>()+let linkRevision = 0// Write one enriched link file per node id present in the map. Removed links should not// linger, so we clear stale per-node files first. Async fs throughout — this runs on edge// changes and scales with node/link count, and sync I/O here sits on the main event loop.-async function writeLinkFiles(map: ContextLinkMap): Promise<void> {+async function writeLinkFiles(map: ContextLinkMap, revision: number): Promise<void> {+ if (revision !== linkRevision) returnconst d = contextLinkDir()const bin = pty?.getTmuxBin() ?? null- try {- for (const f of await fs.promises.readdir(d)) {- if (f.endsWith('.json')) await fs.promises.rm(path.join(d, f), { force: true })- }- } catch {- /* dir may not exist yet */- }// Resolve each linked node's transcript once (hook-fed for claude, locator-by-sessionId// for codex/gemini), so buildLinkDoc stays pure and sync.const resolved = new Map<string, string>()@@ -169,14 +164,26 @@ async function writeLinkFiles(map: ContextLinkMap): Promise<void> {)}}- linkDocs.clear()+ if (revision !== linkRevision) return+ const docs = new Map<string, LinkDoc>()for (const [nodeId, links] of Object.entries(map)) {const doc = buildLinkDoc(nodeId, links, {transcriptOf: (id) => resolved.get(id) ?? '',tmuxBin: bin,tmuxSocket: TMUX_SOCKET})- linkDocs.set(nodeId, doc)+ docs.set(nodeId, doc)+ }+ // Publish all enriched documents together; never expose a partially rebuilt map.+ linkDocs = docs+ try {+ for (const f of await fs.promises.readdir(d)) {+ if (f.endsWith('.json')) await fs.promises.rm(path.join(d, f), { force: true })+ }+ } catch {+ /* dir may not exist yet */+ }+ for (const [nodeId, doc] of docs) {try {await fs.promises.writeFile(path.join(d, `${nodeId}.json`), JSON.stringify(doc, null, 2))} catch (e) {@@ -286,7 +293,15 @@ let writeChain: Promise<void> = Promise.resolve()* (src/server/context-link.ts), which is why the map setter is a function and not only a handler.*/export function setContextLinks(map: ContextLinkMap): Promise<void> {- writeChain = writeChain.then(() => writeLinkFiles(map && typeof map === 'object' ? map : {}))+ const snapshot = structuredClone(map && typeof map === 'object' ? map : {})+ const revision = ++linkRevision+ // Authorization changes immediately, before transcript discovery or debug-file I/O. A slow+ // locator must neither hide a new edge from list nor retain a removed read permission.+ linkDocs = new Map(Object.entries(snapshot).map(([nodeId, links]) => [nodeId, buildLinkDoc(+ nodeId, links, { transcriptOf: () => '', tmuxBin: pty?.getTmuxBin() ?? null, tmuxSocket: TMUX_SOCKET }+ )]))+ const write = () => writeLinkFiles(snapshot, revision)+ writeChain = writeChain.then(write, write)return writeChain}@@ -314,6 +329,7 @@ export function initContextLink(): void {pty = ptyManagerdeps = platformDeps+ linkRevision++linkDocs.clear()hookServer.setContextLinkHandler(handleContextLinkRequest)try {diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex 9cbed6b7a..64f8d5ed6 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -1,4 +1,5 @@import { useCallback, useEffect, useMemo, useRef, useState } from 'react'+import { useContextLinkSync } from './useContextLinkSync'import { useShallow } from 'zustand/react/shallow'import { playSfx, primeSfx } from '@renderer/lib/sfx'import { fanoutStillWorking } from '@renderer/lib/completionAlert'@@ -456,7 +457,7 @@ import {reconnectRelayTab,type RelayTab,} from '../session/relay-tab'-import { buildBackgroundLinkMaps, buildContextLinkNote, buildLinkMap, buildNotePushMessage, classifyLink, hiddenLinkIds, linkIdsCoveredByRopes, pairKey, planBridges, type LinkEndpoint } from '../lib/noteLink'+import { buildContextLinkNote, buildNotePushMessage, classifyLink, hiddenLinkIds, linkIdsCoveredByRopes, pairKey, planBridges, type LinkEndpoint } from '../lib/noteLink'import {launchesToFire,launchRetryDelay,@@ -3623,63 +3624,14 @@ export function Canvas() {})}, [nodes])- // Rewrite link files when a linked node's session starts/changes: main resolves- // codex/gemini transcripts by sessionId, so a session that appears after the edge was- // drawn must trigger a rewrite. agentId is part of the signature for the same reason: a- // plain terminal's identity arrives from hooks after the fact, and the map entry gains- // its agentId/sessionId only once it's known. Primitive signature, not the byId map (see- // loopSig).- const linkSessionSig = useAgentStatus((s) => {- let sig = ''- for (const e of linkEdges) {- const a = s.byId[e.source]- const b = s.byId[e.target]- sig += `${a?.agentId ?? ''}:${a?.sessionId ?? ''}|${b?.agentId ?? ''}:${b?.sessionId ?? ''}|`- }- return sig- })+ useContextLinkSync({ projectId: nodesProjectIdRef.current, nodes, edges: linkEdges })- // Prune links whose endpoints were deleted, then push the link map to main (debounced) so- // it can rewrite the per-node link files the context CLI reads.+ // Pruning is separate from publication: node geometry changes must not postpone link writes.useEffect(() => {const ids = new Set(nodes.map((n) => n.id))const valid = linkEdges.filter((e) => ids.has(e.source) && ids.has(e.target))- if (valid.length !== linkEdges.length) {- setLinkEdges(valid)- return // re-runs with the pruned set- }- const infoOf = (id: string) => {- const n = nodes.find((nn) => nn.id === id)- const sticky = n?.type === 'sticky'- const agentId = sticky ? undefined : agentIdOf(id)- return {- id,- title: (n?.data.title as string) || id,- cwd: (n?.data.cwd as string) || '',- note: sticky ? ((n?.data.text as string) ?? '') : undefined,- sticky,- agentId,- sessionId: agentId ? useAgentStatus.getState().byId[id]?.sessionId : undefined,- accountId: sticky ? undefined : ((n?.data.accountId as string) || undefined)- }- }- // Merge in the link maps of every OTHER project (from their serialized nodes + bridges):- // main clears all link files before writing the pushed map, so pushing only the active- // project's map would sever the links of background projects whose agents keep running.- const { projects, activeProjectId } = useProjects.getState()- const map = {- ...buildBackgroundLinkMaps(- projects,- activeProjectId,- (id) => useAgentStatus.getState().byId[id]?.sessionId,- (id) => useAgentStatus.getState().byId[id]?.agentId- ),- ...buildLinkMap(valid, infoOf)- }- const t = setTimeout(() => void window.nodeTerminal.contextLink.setLinks(map), 150)- return () => clearTimeout(t)- // linkSessionSig is read only as an effect trigger — infoOf re-reads sessionIds via getState().- }, [linkEdges, nodes, setLinkEdges, agentIdOf, linkSessionSig])+ if (valid.length !== linkEdges.length) setLinkEdges(valid)+ }, [linkEdges, nodes, setLinkEdges])// Reflect Claude nodes with unread output as a macOS Dock badge count (across all projects).// Subscribes to the derived count (a primitive), not the byId map, for the same reason asdiff --git a/src/renderer/canvas/useContextLinkSync.test.tsx b/src/renderer/canvas/useContextLinkSync.test.tsxnew file mode 100644index 000000000..72f65f400--- /dev/null+++ b/src/renderer/canvas/useContextLinkSync.test.tsx@@ -0,0 +1,87 @@+// @vitest-environment jsdom+import { act } from 'react'+import { createRoot, type Root } from 'react-dom/client'+import { afterEach, beforeEach, expect, it, vi } from 'vitest'+import { useProjects } from '../state/projects'+import { useAgentStatus } from '../state/agentStatus'+import { useContextLinkSync, type LiveContextLinks } from './useContextLinkSync'+import type { CanvasNodeState, Project } from '@shared/types'++vi.mock('../session/session', () => ({+ sessionForProject: (id: string) => ({ api: id === 'relay' ? {} : window.nodeTerminal })+}))+const setLinks = vi.fn(async (_map: unknown) => {})+const edge = (source: string, target: string) => ({ id: `${source}-${target}`, source, target })+const node = (id: string): LiveContextLinks['nodes'][number] => ({ id, type: 'terminal', data: { title: id, agentId: 'codex' } })+const project = (id: string, ids: string[], bridges = ids.length > 1 ? [edge(ids[0], ids[1])] : []): Project => ({+ id, nodes: ids.map((id) => ({ id, kind: 'terminal', title: id, agentId: 'codex' } as CanvasNodeState)), bridges+} as Project)+let root: Root+function Harness(props: LiveContextLinks) { useContextLinkSync(props); return null }+function render(props: LiveContextLinks) { act(() => root.render(<Harness {...props} />)) }+function lastMap() { return setLinks.mock.calls.at(-1)?.[0] as unknown as Record<string, Array<Record<string, unknown>>> }++beforeEach(() => {+ Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })+ Object.assign(window, { nodeTerminal: { contextLink: { setLinks } } })+ useProjects.setState({ projects: [project('p', ['a', 'b'])], activeProjectId: 'p' })+ useAgentStatus.setState({ byId: {} })+ setLinks.mockClear()+ root = createRoot(document.createElement('div'))+})+afterEach(() => act(() => root.unmount()))++it('publishes a newly drawn/auto-created link during continuous node renders, then removes it', () => {+ const live = { projectId: 'p', nodes: [node('a'), node('b')], edges: [] as LiveContextLinks['edges'] }+ render(live)+ expect(lastMap()).toEqual({})+ render({ ...live, edges: [edge('a', 'b')] })+ expect(lastMap().a[0].id).toBe('b')+ const calls = setLinks.mock.calls.length+ for (let i = 0; i < 30; i++) render({ ...live, nodes: live.nodes.map((n) => ({ ...n, data: { ...n.data, width: i } })), edges: [edge('a', 'b')] })+ expect(setLinks).toHaveBeenCalledTimes(calls)+ render(live)+ expect(lastMap()).toEqual({})+})++it('updates background edges and session identities without a canvas render', () => {+ render({ projectId: 'p', nodes: [node('a'), node('b')], edges: [edge('a', 'b')] })+ act(() => useProjects.setState({ projects: [project('p', ['a', 'b']), project('q', ['c', 'd'])] }))+ expect(lastMap().c[0].id).toBe('d')+ act(() => useAgentStatus.setState({ byId: { d: { agentId: 'codex', sessionId: 'new-session', unread: false } } }))+ expect(lastMap().c[0].sessionId).toBe('new-session')+ act(() => useProjects.setState({ projects: [project('p', ['a', 'b']), project('q', ['c', 'd'], [])] }))+ expect(lastMap().c).toBeUndefined()+ expect(lastMap().a[0].id).toBe('b')+})++it('uses persisted maps while the active id and rendered canvas epoch disagree', () => {+ act(() => useProjects.setState({ projects: [project('p', ['a', 'b']), project('q', ['c', 'd'])] }))+ const old = { projectId: 'p', nodes: [node('a'), node('b')], edges: [edge('a', 'b')] }+ render(old)+ act(() => useProjects.setState({ activeProjectId: 'q' }))+ render(old)+ expect(Object.keys(lastMap()).sort()).toEqual(['a', 'b', 'c', 'd'])+ render({ projectId: 'q', nodes: [node('c'), node('d')], edges: [] })+ expect(Object.keys(lastMap()).sort()).toEqual(['a', 'b'])+})++it('excludes relay projects and refuses edges to a node in another project', () => {+ act(() => useProjects.setState({ projects: [project('p', ['a', 'b']), project('relay', ['secret', 'foreign'])] }))+ render({ projectId: 'p', nodes: [node('a'), node('b')], edges: [edge('a', 'secret')] })+ expect(lastMap()).toEqual({})+ act(() => useProjects.setState({ activeProjectId: 'relay' }))+ render({ projectId: 'relay', nodes: [node('secret'), node('foreign')], edges: [edge('secret', 'foreign')] })+ expect(Object.keys(lastMap()).sort()).toEqual(['a', 'b'])+})++it('refreshes linked notes and titles, and stops subscribing after unmount', () => {+ const nodes = [node('a'), { id: 'note', type: 'sticky', data: { title: 'Brief', text: 'old' } }]+ render({ projectId: 'p', nodes, edges: [edge('a', 'note')] })+ render({ projectId: 'p', nodes: [nodes[0], { ...nodes[1], data: { title: 'New brief', text: 'new' } }], edges: [edge('a', 'note')] })+ expect(lastMap().a).toEqual([{ id: 'note', title: 'New brief', note: 'new' }])+ act(() => root.unmount())+ const count = setLinks.mock.calls.length+ act(() => useProjects.setState({ projects: [] }))+ expect(setLinks).toHaveBeenCalledTimes(count)+})diff --git a/src/renderer/canvas/useContextLinkSync.ts b/src/renderer/canvas/useContextLinkSync.tsnew file mode 100644index 000000000..2ebc0a3f1--- /dev/null+++ b/src/renderer/canvas/useContextLinkSync.ts@@ -0,0 +1,77 @@+import { useEffect, useRef } from 'react'+import { buildBackgroundLinkMaps, buildLinkMap } from '@shared/context-link-map'+import type { ContextLinkMap } from '@shared/types'+import { useProjects } from '../state/projects'+import { useAgentStatus } from '../state/agentStatus'+import { sessionForProject } from '../session/session'++export interface LiveContextLinks {+ // Capture the epoch DURING render, before the project-load effect changes its ref.+ projectId: string | null+ nodes: Array<{ id: string; type?: string; data: Record<string, unknown> }>+ edges: Array<{ source: string; target: string }>+}++/** Publish semantic changes, independent of drag/status render frequency. Subscriptions also+ * cover off-screen edits and sessions which start in a background project. Relay projects belong+ * to another core: never include their ids or transcript identities in the local authorization map.+ */+export function useContextLinkSync(live: LiveContextLinks): void {+ const latest = useRef(live)+ latest.current = live+ const publish = useRef<() => void>(() => {})++ useEffect(() => {+ let last = ''+ const update = () => {+ const { projects, activeProjectId } = useProjects.getState()+ const local = projects.filter((p) => sessionForProject(p.id).api === window.nodeTerminal)+ const snapshot = latest.current+ const liveId = snapshot.projectId === activeProjectId &&+ local.some((p) => p.id === snapshot.projectId) ? snapshot.projectId : null+ const statuses = useAgentStatus.getState().byId+ const map: ContextLinkMap = buildBackgroundLinkMaps(+ local, liveId, (id) => statuses[id]?.sessionId, (id) => statuses[id]?.agentId+ )+ if (liveId) {+ const byId = new Map(snapshot.nodes.map((n) => [n.id, n]))+ const edges = snapshot.edges.filter((e) => byId.has(e.source) && byId.has(e.target))+ Object.assign(map, buildLinkMap(edges, (id) => {+ const n = byId.get(id)!+ const sticky = n.type === 'sticky'+ const agentId = n.type !== 'terminal' ? undefined : (+ n.data.agentId as string | undefined ??+ ((n.data.tags as string[] | undefined)?.includes('claude') ? 'claude' : undefined) ??+ statuses[id]?.agentId+ )+ return {+ id, title: n.data.title as string || id, cwd: n.data.cwd as string || '', sticky,+ note: sticky ? (n.data.text as string ?? '') : undefined,+ agentId, sessionId: agentId ? statuses[id]?.sessionId : undefined,+ accountId: sticky ? undefined : n.data.accountId as string | undefined+ }+ }))+ }+ const sig = JSON.stringify(map)+ if (sig === last) return+ last = sig+ void window.nodeTerminal.contextLink.setLinks(map).catch((error: unknown) => {+ // Permit the next update to retry this snapshot, without rolling back a newer one.+ if (last === sig) last = ''+ console.warn('[context-link] publish failed', error)+ })+ }+ publish.current = update+ const offProjects = useProjects.subscribe(update)+ const offStatus = useAgentStatus.subscribe(update)+ update()+ return () => {+ offProjects()+ offStatus()+ publish.current = () => {}+ }+ }, [])++ // No debounce tied to `nodes`: continuous node measurements used to cancel every write.+ useEffect(() => publish.current())+}diff --git a/src/server/context-link.test.ts b/src/server/context-link.test.tsindex e89b3c9a3..9fcda0383 100644--- a/src/server/context-link.test.ts+++ b/src/server/context-link.test.ts@@ -223,6 +223,13 @@ describe('initServerContextLink', () => {bridges = [bridge('term-a', 'term-b')]await link.refresh()expect(await handler({ verb: 'list', nodeId: 'term-a', args: {} })).toContain('Beta')+ const docPath = join(dir, 'context-links', 'term-a.json')+ expect(JSON.parse(readFileSync(docPath, 'utf8')).links[0].id).toBe('term-b')+ expect(await handler({ verb: 'list', nodeId: 'term-b', args: {} })).toContain('term-a')+ bridges = []+ await link.refresh()+ expect(await handler({ verb: 'list', nodeId: 'term-a', args: {} })).toContain('No linked nodes')+ expect(existsSync(docPath)).toBe(false)await link.stop()})