lout33/termcanvas/termcanvas-agent-sync-debugging

Claude Code and agent skill by lout33/termcanvas

Trust tier 2
  • community
  • ext:[{"type":"plugin","description":"Custom plugin integration"}]
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Diagnose TermCanvas agentmux nodes that fail to appear and terminal canvases that become janky, resize repeatedly, or show corrupted/unreadable xterm text as terminal count grows, plus duplicate terminal views created after a release relaunch. Use when a child agent is missing, restored terminals duplicate or move to the wrong canvas, a folderless canvas stops syncing, UI or TUI redraws recur every few seconds, WebGL glyphs degrade, a smoke probe reports no text, or an accidentally deleted Open…

Install

npx vskill@latest install lout33/termcanvas/termcanvas-agent-sync-debugging

Semi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard

SKILL.md

The same SKILL.md was published earlier as lout33/termcanvas/termcanvas-agent-sync-debugging.

Debug TermCanvas restore, agent sync, and rendering stability

Use this workflow to identify whether the failing layer is persisted agent identity, restore ordering, renderer polling, terminal geometry, xterm rendering, or PTY/tmux I/O before changing lifecycle code.

Failure pattern: A release relaunch creates and saves duplicate terminal views, sometimes on the wrong canvas, when agent sync races partial session hydration. Related paths include folderless projects being skipped and periodic renderer work changing geometry or exhausting WebGL contexts.

Verified by: Normalizing a real polluted release snapshot reduced 20 nodes to 15 unique nodes; an isolated Electron relaunch restored all 15 with duplicateIdentities: []. npm run build passed and all 249 tests passed. Prior checks also reproduced the folderless sync mismatch, improved scoped polling from about 0.55s to 0.20s, held 10-terminal WebGL use to 8, and preserved tail mount height 486.4609375 and terminal size 116x27. The deleted-session path was verified by restoring two exact OpenCode session IDs, rebuilding their parent chain, and observing both running tmux sessions materialize in TermCanvas.

Procedure

1. Diagnose release-relaunch duplicates from the saved session
  • [ ] Quit or isolate the release app before drawing conclusions from changing

state. Inspect its persisted session first:

```sh jq ' [.canvases[] as $canvas | $canvas.terminalNodes[]? | { canvasId: $canvas.id, canvasProjectTag: $canvas.agentProjectTag, sessionKey, tmuxSessionName, managedProjectTag, managedAgentName }] as $nodes

bySessionKey: ($nodes | group_by(.sessionKey)

byTmuxSession: ($nodes | group_by(.tmuxSessionName)

byProjectAgent: ($nodes | group_by([.managedProjectTag,.managedAgentName])

and .[0].managedAgentName != null and length > 1))) } ' "$HOME/Library/Application Support/TermCanvas/app-session.json" ```

Some development or older bundles use a lowercase termcanvas directory; confirm the running app's Electron userData path rather than assuming case.

  • [ ] Treat sessionKey, tmuxSessionName, and the pair

(managedProjectTag, managedAgentName) as connected identity edges. Deduplicate globally across all canvases, not once per canvas and not independently per field: transitive matches still describe one terminal view identity.

  • [ ] Prefer the correctly owned node within each connected component:
  1. managedProjectTag matches its canvas agentProjectTag;
  2. its tmux name is canonical: termcanvas-${sessionKey};
  3. only then use stable input order as the tie-breaker.

Put this policy in session_snapshot.js normalization so every restore sees a safe snapshot. Test normalization on a copy; do not hand-edit live user data while Electron can save over it.

  • [ ] Trace restoreCanvasSession() and scheduleCanvasAgentSync(). The root

race is agent polling while canvases/nodes are only partially hydrated:

  1. set isSessionHydrating for the entire restore;
  2. while it is true, scheduleCanvasAgentSync() must not start reconciliation;
  3. finish creating every restored canvas and node;
  4. clear the flag in a guaranteed finalization path;
  5. schedule agent sync exactly once after hydration completes.

Otherwise agent sync can materialize an agent before its saved node is restored, then session persistence turns the temporary duplicate into durable pollution—possibly under the canvas active during the partial restore.

  • [ ] In reconcileCanvasAgentProject(), index every existing node by tmux

session, including already-managed nodes. Matching tmux only for unmanaged nodes misses stale or duplicate managed views and creates another node.

  • [ ] Never kill tmux to repair this failure. The duplicate records are renderer

views that can share the same long-lived session; normalization should discard extra views while leaving the underlying shell alive.

2. Classify periodic cadence before blaming tmux
  • [ ] Reproduce with enough visible terminals to expose the issue. Record

whether the symptom repeats near either fixed renderer interval:

  • NODE_TAIL_REFRESH_INTERVAL_MS = 4000
  • CANVAS_AGENT_SYNC_INTERVAL_MS = 6000
  • [ ] If a redraw or stall follows either cadence, inspect renderer.js timers,

DOM writes, layout, ResizeObserver, and xterm fitting first. Terminal output routing is not the default suspect when the symptom is periodic without new PTY output.

  • [ ] Across one tick, capture for an affected node:
  • terminalMount.getBoundingClientRect().height
  • terminal.cols and terminal.rows
  • whether tail.hidden changed
  • whether ResizeObserver, FitAddon.fit(), or resizeTerminal() ran

A changing mount height links renderer layout to tmux/TUI redraws.

3. Keep the tail slot geometrically stable
  • [ ] Inspect .terminal-node-tail in styles.css. The tail participates in a

flex column, so hiding it must not remove it from layout. Reserve a fixed slot:

```css .terminal-node-tail { flex: 0 0 1.35rem; height: 1.35rem; }

.terminal-node-tail[hidden] { display: block; visibility: hidden; } ```

Do not use the browser default [hidden] { display: none; } for this element. Removing and restoring the tail changes the terminal mount height, which can trigger ResizeObserver -> FitAddon -> terminal:resize -> tmux/TUI redraw.

  • [ ] In updateNodeTailLine(), set textContent, title, or hidden only

when the next value differs. Keep quiet state implicit; do not write a changing quiet-duration label on every four-second tick.

  • [ ] Verify a hidden-to-visible tail transition leaves mount height and xterm

rows/columns unchanged. A redraw that merely makes the text look better is not proof that geometry is stable.

4. Treat WebGL contexts as a bounded resource
  • [ ] When text becomes scrambled, incomplete, or unreadable only after many

terminals are visible, inspect active xterm renderers before changing PTY or tmux code. Chromium can evict WebGL contexts under pressure, invalidating xterm glyph atlases.

  • [ ] Keep MAX_TERMINAL_WEBGL_RENDERERS conservative; this checkout uses 8.

Count attached addons across all canvases, attach WebGL only to connected, visible nodes on the active canvas, and let terminals beyond the budget use xterm's DOM renderer.

  • [ ] For each terminal attachment, make WebGL failure sticky:
  1. initialize isWebglRendererDisabled to false when binding a fresh xterm;
  2. on context loss, set it to true, detach/dispose the addon, and refresh;
  3. on addon construction/load failure, set it to true and remain on DOM;
  4. never reattach WebGL for that attachment after either failure.

This prevents a loss/re-attach loop. A newly bound xterm attachment may try WebGL again if the global budget has room.

  • [ ] In an isolated multi-terminal Electron check, assert the WebGL count never

exceeds the budget and verify every remaining terminal still renders through DOM. The observed 10-terminal check reported webglCount: 8 for budget 8.

5. Make periodic agent sync a no-op when nothing changed
  • [ ] setTerminalNodeStatus() and syncTerminalMeta() should compare current

text, title, dataset, and ARIA values before writing. Rewriting equal strings still creates needless renderer work when multiplied across terminals.

  • [ ] In syncManagedNodeState(), compare the previous managed state with the

incoming snapshot and return whether it changed. Only schedule edge rendering when graph identity changes.

  • [ ] In reconcileCanvasAgentProject():
  • index existing nodes once by agent name and tmux session;
  • create/remove nodes in a batch;
  • redraw edges only when the node set, project tag, or edge set changed;
  • schedule attention/session persistence only when nodes, graph, or managed

state changed.

A quiet six-second sync must not rewrite node chrome, edges, or app-session state.

  • [ ] At the CLI layer, agentmux ls --project <project-tag> --json must refresh

only that project's sessions before querying tmux. Do not refresh every stored project and filter afterward.

6. Diagnose a missing agent from live persisted state
  • [ ] On macOS, inspect the live canvas and renderer snapshots first:

``sh jq '.canvases[] | {id,name,workspace,agentProjectTag,terminalNodes}' \ "$HOME/Library/Application Support/termcanvas/app-session.json" jq . "$HOME/Library/Application Support/termcanvas/canvas-snapshot.json" ``

workspace: null is valid when agentProjectTag is persisted.

  • [ ] Query the app-scoped database before assuming spawn failed:

``sh sqlite3 -header -column \ "$HOME/Library/Application Support/termcanvas/agentmux/agentmux.db" \ "select name,project,tmux_session,state,agent_state,json_extract(metadata_json,'$.parent_agent') as parent from sessions order by created_at desc;" ``

If the child record exists under the canvas project, creation succeeded and the defect is downstream: sync gating, IPC, or renderer reconciliation.

  • [ ] Confirm database identity inside the managed terminal by inspecting

AGENTMUX_HOME, AGENTMUX_BIN, and AGENTMUX_PROJECT. The main service, terminal shell, restored tmux environment, and vendored wrapper must resolve the same app-scoped AGENTMUX_HOME. Do not mistake a legacy or development database for the packaged app database.

  • [ ] Trace the sync gate in order:
  1. renderer.js -> syncActiveCanvasAgentProject() syncs when either a

persisted project tag or workspace root exists.

  1. main_agentmux_service.js -> syncCanvasProject() accepts an explicit tag

without a workspace; it derives a tag only when no tag was supplied.

  1. reconcileCanvasAgentProject() matches by agent name or tmux session,

creates missing nodes, and detaches stale PTY views without killing tmux.

7. Recover an accidentally deleted OpenCode terminal
  • [ ] First establish the failure boundary without changing live state:

``sh "$AGENTMUX_BIN" ls --json tmux list-sessions -F '#{session_name}' ``

A forced agentmux delete removes the record, events, graph edges, and tmux session. If all are gone, tmux reattachment is impossible, but OpenCode's native conversation may still survive independently.

  • [ ] Query OpenCode's durable session database by title, directory, and recency:

``sh sqlite3 -json "$HOME/.local/share/opencode/opencode.db" ' SELECT id, title, directory, model, datetime(time_updated / 1000, "unixepoch", "localtime") AS updated_at FROM session WHERE lower(title) LIKE "%search terms%" OR lower(directory) LIKE "%project fragment%" ORDER BY time_updated DESC LIMIT 30; ' ``

Do not select by a vague title alone. Match the working directory and recent activity, then inspect the earliest TermCanvas briefing to recover the exact agent name, project tag, and original parent:

``sh sqlite3 -json "$HOME/.local/share/opencode/opencode.db" ' SELECT s.id, s.title, substr(json_extract(p.data, "$.text"), 1, 600) AS briefing FROM session s JOIN part p ON p.session_id = s.id WHERE s.id = "<session-id>" AND json_extract(p.data, "$.type") = "text" AND json_extract(p.data, "$.text") LIKE "[TermCanvas] You are agent %" ORDER BY p.time_created ASC LIMIT 1; ' ``

  • [ ] Restore parents before children using the same app-scoped AGENTMUX_HOME.

Reuse the model provider/id stored in the OpenCode row; the variant remains part of the native session:

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 96 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
27
Repository forks
1
7-day trend score
16

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Extension points

  • pluginCustom plugin integration

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/lout33/termcanvas/termcanvas-agent-sync-debugging/badge)](https://verified-skill.com/skills/lout33/termcanvas/termcanvas-agent-sync-debugging)

Something wrong with this skill or its page? Tell us.