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
feat(context-link): link map carries agent identity; per-agent link messages
enes25820ae5cd91
diff --git a/src/renderer/lib/noteLink.test.ts b/src/renderer/lib/noteLink.test.tsindex d513f4eb4..6879570ab 100644--- a/src/renderer/lib/noteLink.test.ts+++ b/src/renderer/lib/noteLink.test.ts@@ -1,5 +1,5 @@import { describe, it, expect } from 'vitest'-import { buildLinkMap, buildNotePushMessage, classifyLink } from './noteLink'+import { buildContextLinkNote, buildLinkMap, buildNotePushMessage, classifyLink } from './noteLink'const term = (contextCapable = false) => ({ kind: 'terminal', contextCapable })const sticky = () => ({ kind: 'sticky', contextCapable: false })@@ -78,3 +78,47 @@ describe('buildLinkMap', () => {expect(map['t1']).toEqual([{ id: 'noteX', title: 'N', note: '' }])})})++describe('buildLinkMap agent identity', () => {+ it('carries agentId/sessionId/accountId on context entries', () => {+ const infoOf = (id: string) => ({+ id,+ title: `T ${id}`,+ cwd: '',+ sticky: false,+ agentId: id === 'a' ? 'claude' : 'codex',+ sessionId: `sess-${id}`,+ accountId: id === 'a' ? 'acct-1' : undefined+ })+ const map = buildLinkMap([{ source: 'a', target: 'b' }], infoOf)+ expect(map['a'][0]).toMatchObject({ id: 'b', agentId: 'codex', sessionId: 'sess-b' })+ expect(map['a'][0].accountId).toBeUndefined()+ expect(map['b'][0]).toMatchObject({ id: 'a', agentId: 'claude', sessionId: 'sess-a', accountId: 'acct-1' })+ })+})++describe('buildContextLinkNote', () => {+ it('claude gets the skill wording (unchanged legacy text)', () => {+ expect(buildContextLinkNote('claude', 'Builder', '/x/context.sh')).toBe(+ '[nodeterm] You are now linked to "Builder". Use the get-linked-context skill to read its context when you need it.'+ )+ })+ it('codex/gemini get the inline CLI command, single line', () => {+ const msg = buildContextLinkNote('codex', 'Builder', '/x/context.sh')+ expect(msg).toContain('sh "/x/context.sh"')+ expect(msg).toContain('Builder')+ expect(msg).not.toContain('\n')+ })+})++describe('buildNotePushMessage per-agent wording', () => {+ it('keeps the skill pointer for claude and omitted agent', () => {+ expect(buildNotePushMessage('T', 'x'.repeat(3000), 'claude')).toContain('get-linked-context skill')+ expect(buildNotePushMessage('T', 'x'.repeat(3000))).toContain('get-linked-context skill')+ })+ it('points non-claude agents at the CLI instructions', () => {+ const msg = buildNotePushMessage('T', 'x'.repeat(3000), 'codex')!+ expect(msg).toContain('[truncated')+ expect(msg).not.toContain('skill]')+ })+})diff --git a/src/renderer/lib/noteLink.ts b/src/renderer/lib/noteLink.tsindex 94cf0dcc0..87ea205b7 100644--- a/src/renderer/lib/noteLink.ts+++ b/src/renderer/lib/noteLink.ts@@ -1,5 +1,5 @@// Pure helpers for canvas link edges: classify a new connection (context link between two-// Claude nodes vs. note link between a sticky and a terminal), build the one-shot push+// agent nodes vs. note link between a sticky and a terminal), build the one-shot push// message a note link injects into an agent session, and build the link map pushed to main.// Kept free of React/store imports so the connection matrix is unit-testable.import type { ContextLinkInfo, ContextLinkMap } from '@shared/types'@@ -7,7 +7,7 @@ import type { ContextLinkInfo, ContextLinkMap } from '@shared/types'export interface LinkEndpoint {/** React Flow node type: 'terminal' | 'sticky' | 'editor' | … */kind: string- /** Terminal node whose agent is CONTEXT_LINK_CAPABLE (Claude). */+ /** Terminal node whose agent is CONTEXT_LINK_CAPABLE (claude/codex/gemini). */contextCapable: boolean}@@ -31,23 +31,44 @@ const NOTE_PUSH_MAX = 2000* as submits in agent REPLs, so newlines are collapsed to a visible ' ⏎ '.* Returns null when the note is empty (nothing to push).*/-export function buildNotePushMessage(title: string, text: string): string | null {+export function buildNotePushMessage(title: string, text: string, agentId?: string): string | null {if (!text.trim()) return nullconst flat = text.replace(/\s*\r?\n\s*/g, ' ⏎ ').trim()+ const pointer =+ !agentId || agentId === 'claude'+ ? 'read the full note with the get-linked-context skill'+ : 'read the full note with the nodeterm linked-context CLI — see the get-linked-context section in your global agent instructions'const body =- flat.length > NOTE_PUSH_MAX- ? flat.slice(0, NOTE_PUSH_MAX) +- ' … [truncated — read the full note with the get-linked-context skill]'- : flat+ flat.length > NOTE_PUSH_MAX ? flat.slice(0, NOTE_PUSH_MAX) + ` … [truncated — ${pointer}]` : flatreturn `[nodeterm] Sticky note "${title}" linked as context: ${body}`}+/**+ * The one-shot message injected into each endpoint when a context link is drawn.+ * Claude discovers the capability via its installed skill; codex/gemini get the CLI+ * inline (their global-instructions block may not be loaded mid-session). Single-line:+ * pty.sendText appends Enter.+ */+export function buildContextLinkNote(+ agentId: string | undefined,+ otherTitle: string,+ shimPath: string+): string {+ if (!agentId || agentId === 'claude') {+ return `[nodeterm] You are now linked to "${otherTitle}". Use the get-linked-context skill to read its context when you need it.`+ }+ return `[nodeterm] You are now linked to "${otherTitle}". To read its context run: sh "${shimPath}" list — then summary | transcript | terminal --node <id>. Details are in the get-linked-context section of your global agent instructions.`+}+export interface LinkNodeInfo {id: stringtitle: stringcwd?: stringnote?: stringsticky: boolean+ agentId?: string+ sessionId?: string+ accountId?: string}/**@@ -60,8 +81,14 @@ export function buildLinkMap(infoOf: (id: string) => LinkNodeInfo): ContextLinkMap {const map: ContextLinkMap = {}- const entryOf = (n: LinkNodeInfo): ContextLinkInfo =>- n.sticky ? { id: n.id, title: n.title, note: n.note ?? '' } : { id: n.id, title: n.title, cwd: n.cwd ?? '' }+ const entryOf = (n: LinkNodeInfo): ContextLinkInfo => {+ if (n.sticky) return { id: n.id, title: n.title, note: n.note ?? '' }+ const e: ContextLinkInfo = { id: n.id, title: n.title, cwd: n.cwd ?? '' }+ if (n.agentId) e.agentId = n.agentId+ if (n.sessionId) e.sessionId = n.sessionId+ if (n.accountId) e.accountId = n.accountId+ return e+ }for (const e of edges) {const s = infoOf(e.source)const t = infoOf(e.target)diff --git a/src/shared/types.ts b/src/shared/types.tsindex 6fdedca4f..ae8e655ca 100644--- a/src/shared/types.ts+++ b/src/shared/types.ts@@ -640,6 +640,12 @@ export interface ContextLinkInfo {cwd?: string/** Set when the linked node is a sticky note: its current text. Note entries have no transcript/terminal. */note?: string+ /** The linked node's agent CLI ('claude' | 'codex' | 'gemini') — selects the CLI transcript parser. */+ agentId?: string+ /** Latest known provider session id — lets main resolve the transcript via the per-agent locators. */+ sessionId?: string+ /** Managed Claude account of the linked node — scopes the claude locator fallback. */+ accountId?: string}/** Map of node id → the nodes it is context-linked to. Sent to main so it can write link files. */