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(context): renderer store and Canvas wiring for context updates

enesea498b041c63
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index faa7131bd..93066a487 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -63,6 +63,7 @@ import { SubagentNode } from '../nodes/SubagentNode'
import { LoopNode } from '../nodes/LoopNode'
import { branchClaudeSession } from '../lib/claudeBranch'
import { useSettings } from '../state/settings'
+import { useContextWindow } from '../state/contextWindow'
import {
claudeLaunchCommand,
COLLAPSED_HEIGHT,
@@ -569,6 +570,11 @@ export function Canvas() {
window.nodeTerminal.setBadgeCount(count)
}, [claudeById])
+ // Feed per-session context-window fill from main into the transient store.
+ useEffect(() => {
+ return window.nodeTerminal.context.onUpdate((u) => useContextWindow.getState().set(u))
+ }, [])
+
// Prevent a stray file drop (outside a terminal body) from navigating the whole window to
// the dropped file. Terminal nodes handle their own drop and stopPropagation, so this only
// catches drops on empty canvas / other UI.
diff --git a/src/renderer/state/contextWindow.ts b/src/renderer/state/contextWindow.ts
new file mode 100644
index 000000000..ebafc1ade
--- /dev/null
+++ b/src/renderer/state/contextWindow.ts
@@ -0,0 +1,14 @@
+import { create } from 'zustand'
+import type { ContextWindowUsage } from '@shared/types'
+
+// Transient (not persisted): per-session context-window fill, fed by context.onUpdate.
+interface ContextWindowState {
+ bySessionId: Record<string, ContextWindowUsage>
+ set(usage: ContextWindowUsage): void
+}
+
+export const useContextWindow = create<ContextWindowState>((set) => ({
+ bySessionId: {},
+ set: (usage) =>
+ set((s) => ({ bySessionId: { ...s.bySessionId, [usage.sessionId]: usage } }))
+}))