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(chat): ChatPanel component + styles
enes5181100227af
diff --git a/src/renderer/nodes/ChatPanel.tsx b/src/renderer/nodes/ChatPanel.tsxnew file mode 100644index 000000000..78d95e9ad--- /dev/null+++ b/src/renderer/nodes/ChatPanel.tsx@@ -0,0 +1,118 @@+import { useCallback, useEffect, useRef, useState, type KeyboardEvent } from 'react'+import { renderMarkdown } from '../lib/markdown'+import { useAgentStatus } from '../state/agentStatus'+import type { ChatMessage } from '@shared/types'++interface ChatPanelProps {+ nodeId: string+ sessionId?: string+ cwd?: string+}++/**+ * Chat view for a chat-capable agent node (Cmd+M). Renders the session transcript as+ * markdown bubbles with collapsible tool calls, and sends new prompts into the running tmux+ * session via pty.sendText. Phase 1 reloads the transcript whenever a turn finishes+ * (working -> idle); live streaming is a later phase. Replaces the markdown-of-output overlay.+ */+export function ChatPanel({ nodeId, sessionId, cwd }: ChatPanelProps) {+ const [messages, setMessages] = useState<ChatMessage[]>([])+ const [input, setInput] = useState('')+ const [readonly, setReadonly] = useState(false)+ const state = useAgentStatus((s) => s.byId[nodeId]?.state)+ const msgsRef = useRef<HTMLDivElement>(null)+ const prevState = useRef(state)++ const load = useCallback(() => {+ void window.nodeTerminal.chat.readTranscript(sessionId, cwd).then(setMessages)+ }, [sessionId, cwd])++ // Initial load.+ useEffect(() => {+ load()+ }, [load])++ // Reload when a turn completes (working -> not working).+ useEffect(() => {+ if (prevState.current === 'working' && state !== 'working') load()+ prevState.current = state+ }, [state, load])++ // Keep pinned to the latest message.+ useEffect(() => {+ const el = msgsRef.current+ if (el) el.scrollTop = el.scrollHeight+ }, [messages])++ const working = state === 'working'++ const send = useCallback(async () => {+ const text = input.trim()+ if (!text || working) return+ const ok = await window.nodeTerminal.pty.sendText(nodeId, text)+ if (!ok) {+ setReadonly(true)+ return+ }+ // Optimistic: show the prompt immediately; the next load() reconciles from the transcript.+ setMessages((m) => [...m, { role: 'user', parts: [{ kind: 'text', text }] }])+ setInput('')+ }, [input, working, nodeId])++ const onKeyDown = (e: KeyboardEvent<HTMLTextAreaElement>) => {+ if (e.key === 'Enter' && !e.shiftKey) {+ e.preventDefault()+ void send()+ }+ }++ return (+ <div className="term-chat nodrag nowheel">+ <div className="term-chat__bar">+ <span>Chat</span>+ <span className="term-chat__hint">⌘M to exit</span>+ </div>+ <div className="term-chat__msgs" ref={msgsRef}>+ {messages.length === 0 && <div className="term-chat__empty">No conversation yet.</div>}+ {messages.map((m, i) => (+ <div key={i} className={`term-chat__msg term-chat__msg--${m.role}`}>+ {m.parts.map((p, j) =>+ p.kind === 'text' ? (+ <div+ key={j}+ className="term-chat__text"+ dangerouslySetInnerHTML={{ __html: renderMarkdown(p.text) }}+ />+ ) : (+ <details key={j} className="term-chat__tool">+ <summary>+ <span className="term-chat__tool-name">{p.name}</span>+ {p.arg && <span className="term-chat__tool-arg">{p.arg}</span>}+ </summary>+ {p.result && <pre className="term-chat__tool-result">{p.result}</pre>}+ </details>+ )+ )}+ </div>+ ))}+ </div>+ <div className="term-chat__compose">+ <textarea+ className="term-chat__input"+ value={input}+ onChange={(e) => setInput(e.target.value)}+ onKeyDown={onKeyDown}+ placeholder={+ readonly+ ? "Can't write to this session"+ : working+ ? 'Claude is working…'+ : 'Message Claude… (Enter to send, Shift+Enter for newline)'+ }+ disabled={readonly || working}+ rows={2}+ />+ </div>+ </div>+ )+}diff --git a/src/renderer/styles.css b/src/renderer/styles.cssindex 436deb05b..3f9aff093 100644--- a/src/renderer/styles.css+++ b/src/renderer/styles.css@@ -912,6 +912,132 @@ body,padding: 4px 8px;}+/* Chat panel — replaces the markdown overlay on chat-capable agent nodes (Cmd+M). */+.term-chat {+ position: absolute;+ inset: 0;+ display: flex;+ flex-direction: column;+ background: var(--bg, #0a0a0a);+ z-index: 5;+}+.term-chat__bar {+ display: flex;+ justify-content: space-between;+ align-items: center;+ flex: 0 0 auto;+ padding: 4px 8px;+ font-size: 11px;+ color: var(--label-secondary, rgba(255, 255, 255, 0.55));+ border-bottom: 1px solid rgba(255, 255, 255, 0.08);+}+.term-chat__hint {+ opacity: 0.6;+}+.term-chat__msgs {+ flex: 1 1 auto;+ overflow-y: auto;+ padding: 10px;+ display: flex;+ flex-direction: column;+ gap: 10px;+}+.term-chat__empty {+ margin: auto;+ font-size: 12px;+ color: var(--label-secondary, rgba(255, 255, 255, 0.4));+}+.term-chat__msg {+ max-width: 92%;+ padding: 8px 10px;+ border-radius: 10px;+ font-size: 13px;+ line-height: 1.5;+ word-break: break-word;+}+.term-chat__msg--user {+ align-self: flex-end;+ background: var(--accent, #0a84ff);+ color: #fff;+}+.term-chat__msg--assistant {+ align-self: flex-start;+ background: rgba(255, 255, 255, 0.06);+ color: var(--label, rgba(255, 255, 255, 0.92));+}+.term-chat__text > :first-child {+ margin-top: 0;+}+.term-chat__text > :last-child {+ margin-bottom: 0;+}+.term-chat__text pre {+ background: rgba(0, 0, 0, 0.35);+ padding: 8px;+ border-radius: 6px;+ overflow-x: auto;+}+.term-chat__text a {+ color: inherit;+ text-decoration: underline;+}+.term-chat__tool {+ margin: 4px 0;+ padding: 4px 6px;+ font-size: 12px;+ background: rgba(0, 0, 0, 0.25);+ border-radius: 6px;+}+.term-chat__tool summary {+ display: flex;+ gap: 6px;+ align-items: baseline;+ cursor: pointer;+ list-style: none;+}+.term-chat__tool-name {+ font-weight: 600;+ color: var(--accent, #0a84ff);+}+.term-chat__tool-arg {+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+ opacity: 0.7;+ font-family: var(--mono, ui-monospace, monospace);+}+.term-chat__tool-result {+ margin: 6px 0 0;+ white-space: pre-wrap;+ font-family: var(--mono, ui-monospace, monospace);+ font-size: 11px;+ opacity: 0.85;+}+.term-chat__compose {+ flex: 0 0 auto;+ padding: 8px;+ border-top: 1px solid rgba(255, 255, 255, 0.08);+}+.term-chat__input {+ box-sizing: border-box;+ width: 100%;+ resize: none;+ padding: 8px;+ font-family: inherit;+ font-size: 13px;+ color: var(--label, #fff);+ background: rgba(255, 255, 255, 0.06);+ border: 1px solid rgba(255, 255, 255, 0.12);+ border-radius: 8px;+}+.term-chat__input:focus {+ outline: none;+ border-color: var(--accent, #0a84ff);+}+.term-chat__input:disabled {+ opacity: 0.5;+}+/* Transparent overlay that lets you pan across a terminal until you dwell/click. */.term-hover-guard {position: absolute;