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.

fix(claude): flag unread unless actively viewing that node

enes1379f4fb8d98
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index 87af5e60e..fe958c64a 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -817,8 +817,13 @@ export function Canvas() {
if (e.sessionId) cs.setSessionId(e.nodeId, e.sessionId)
// REF-style: "<folder> — Claude finished" + last assistant message as the body.
const alert = (statusText: string, fallbackBody: string) => {
+ // Unread unless the user is actively in this node's terminal (focused window +
+ // this node is the active terminal). So a finish while you're in another terminal,
+ // or with nothing focused, still flags unread.
+ const watching = document.hasFocus() && cs.activeId === e.nodeId
+ if (!watching) cs.markUnread(e.nodeId)
+ // OS notification only when the whole window is in the background.
if (document.hasFocus()) return
- cs.markUnread(e.nodeId)
const s = useSettings.getState().settings
if (!(s.notifyOnClaudeDone && s.notifyConsentAsked)) return
const now = Date.now()
diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsx
index bfc476b80..e50fda6e7 100644
--- a/src/renderer/nodes/TerminalNode.tsx
+++ b/src/renderer/nodes/TerminalNode.tsx
@@ -124,6 +124,7 @@ export function TerminalNode({ id, data, selected }: NodeProps<CanvasNode>) {
observer.disconnect()
if (dwellRef.current) clearTimeout(dwellRef.current)
cleanups.forEach((fn) => fn())
+ useClaudeStatus.getState().setActive(id, false)
useClaudeStatus.getState().remove(id)
if (sessionId) transport.kill(sessionId)
term.dispose()
@@ -170,6 +171,7 @@ export function TerminalNode({ id, data, selected }: NodeProps<CanvasNode>) {
dwellRef.current = setTimeout(() => {
setArmed(false)
termRef.current?.focus()
+ useClaudeStatus.getState().setActive(id, true)
useClaudeStatus.getState().clearUnread(id)
}, settings.panHoverDelay)
}
@@ -177,6 +179,7 @@ export function TerminalNode({ id, data, selected }: NodeProps<CanvasNode>) {
if (dwellRef.current) clearTimeout(dwellRef.current)
setArmed(true)
termRef.current?.blur()
+ useClaudeStatus.getState().setActive(id, false)
}
// While armed, a mousedown might start a node drag — pause the dwell timer so the
// terminal doesn't grab focus mid-drag; restart it on release.
diff --git a/src/renderer/state/claudeStatus.ts b/src/renderer/state/claudeStatus.ts
index 4780724d0..1882345cb 100644
--- a/src/renderer/state/claudeStatus.ts
+++ b/src/renderer/state/claudeStatus.ts
@@ -20,6 +20,9 @@ export interface ClaudeNodeStatus {
interface ClaudeStatusState {
byId: Record<string, ClaudeNodeStatus>
+ /** The terminal node the user is currently focused in (for unread decisions). */
+ activeId: string | null
+ setActive(id: string, active: boolean): void
setState(id: string, state: ClaudeState | undefined): void
setSession(id: string, session: string): void
setSessionId(id: string, sessionId: string): void
@@ -63,6 +66,13 @@ function save(byId: Record<string, ClaudeNodeStatus>): void {
export const useClaudeStatus = create<ClaudeStatusState>((set) => ({
byId: load(),
+ activeId: null,
+
+ setActive: (id, active) =>
+ set((s) => {
+ if (active) return s.activeId === id ? s : { activeId: id }
+ return s.activeId === id ? { activeId: null } : s
+ }),
setState: (id, state) =>
set((s) => {