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(renderer): presence facepile + first-connect name prompt
enes95f8628e71c1
diff --git a/src/renderer/components/Facepile.tsx b/src/renderer/components/Facepile.tsxnew file mode 100644index 000000000..ccaf7fddd--- /dev/null+++ b/src/renderer/components/Facepile.tsx@@ -0,0 +1,73 @@+import { useShallow } from 'zustand/react/shallow'+import { selectFaces, usePresence } from '../state/presence'+import { useProjects } from '../state/projects'+import { faceClickTarget, facepileEntries } from '../lib/facepile'++/**+ * Who is connected, top-right, in their colors. THE ONE SURFACE THAT SHOWS OFF-PROJECT PEERS:+ * cursors and node chips are hard-filtered to the active project (a project is a separate canvas+ * with its own coordinate space), but the facepile shows everybody — a peer on another project is+ * dimmed and labelled with that project's name ("Ada · api"). Clicking takes you to them: to their+ * focused node when they have one (focusNodeById switches projects on its own), else to their+ * project. Cursorless peers (phones) get a phone glyph — the facepile and the node chip are their+ * only surfaces, so being invisible here would mean being invisible entirely.+ *+ * PERF: subscribes to `selectFaces`, NOT `selectOthers` — the face projection is cursor-immune+ * (see state/presence.ts), so a peer moving their mouse at 20 Hz does not re-render this. The+ * peer's `focus` is deliberately not part of a face either; it is read from the store at CLICK+ * time (getState — no subscription).+ *+ * Renders nothing when you are alone: presence is silent, and costs nothing, solo.+ */+export function Facepile({+ onJump,+ onSwitchProject+}: {+ onJump: (nodeId: string) => void+ onSwitchProject: (projectId: string) => void+}): JSX.Element | null {+ // useShallow: the selector derives a new array each call (its ELEMENTS are cached — that is what+ // makes cursor traffic invisible here). See PresenceLayer for the same pattern.+ const faces = usePresence(useShallow(selectFaces))+ const activeProjectId = useProjects((s) => s.activeProjectId)+ // Only id+name: recomputing on every projects-store write is fine, re-rendering on one is not.+ const projects = useProjects(useShallow((s) => s.projects.map((p) => ({ id: p.id, name: p.name }))))+ if (faces.length === 0) return null++ const entries = facepileEntries(faces, projects, activeProjectId || null)++ return (+ <div className="presence-facepile">+ {entries.map((e) => (+ <button+ key={e.clientId}+ className={`presence-face${e.away ? ' presence-face--away' : ''}`}+ style={{ background: e.color }}+ title={e.title}+ disabled={!e.actionable}+ onClick={() => {+ // Read focus live: it is not part of a face (see PERF above), and by click time the+ // peer may well have moved to another node anyway.+ const focus = usePresence.getState().peers[e.clientId]?.focus ?? null+ const target = faceClickTarget(e, focus)+ if (target?.kind === 'node') onJump(target.nodeId)+ else if (target?.kind === 'project') onSwitchProject(target.projectId)+ }}+ >+ {e.isPhone ? (+ <span className="presence-face__phone" aria-hidden>+ ▯+ </span>+ ) : (+ e.initials+ )}+ {e.away && e.projectName ? (+ <span className="presence-face__where">{e.projectName}</span>+ ) : null}+ </button>+ ))}+ </div>+ )+}++export default Facepilediff --git a/src/renderer/components/PresenceNamePrompt.tsx b/src/renderer/components/PresenceNamePrompt.tsxnew file mode 100644index 000000000..c1598b941--- /dev/null+++ b/src/renderer/components/PresenceNamePrompt.tsx@@ -0,0 +1,77 @@+import { useState } from 'react'+import { NAME_MAX_LEN, PRESENCE_COLORS } from '@shared/presence'+import { selectOthers, suggestIdentity, usePresence } from '../state/presence'++/**+ * First-connect identity prompt: pick a name + color. Saved to localStorage+ * (`nodeterm.presence.me`, the only persisted thing in the whole feature), so it is asked exactly+ * once per browser/device.+ *+ * Shown only when someone else is actually connected — a solo user is never interrupted by a+ * dialog for a feature they cannot see. Skipping it leaves you as the hub's default "Someone" with+ * the color it assigned you: presence still works, you are just anonymous.+ *+ * PERF: the peer count is a NUMBER derived from the store, so cursor traffic (which never changes+ * the count) cannot re-render this.+ */+export function PresenceNamePrompt(): JSX.Element | null {+ const needsName = usePresence((s) => s.needsName)+ const otherCount = usePresence((s) => selectOthers(s).length)+ const setMe = usePresence((s) => s.setMe)+ // suggestIdentity is read ONCE (lazy initializer): a peer joining later must not swap the+ // suggested color out from under a user who is mid-typing.+ const [draft] = useState(suggestIdentity)+ const [name, setName] = useState(draft.name)+ const [color, setColor] = useState(draft.color)+ const [dismissed, setDismissed] = useState(false)++ if (!needsName || dismissed || otherCount === 0) return null++ const submit = (): void => {+ const trimmed = name.trim()+ if (!trimmed) return+ setMe({ name: trimmed, color }) // saves + says hello again, which renames us on the hub+ }++ return (+ <div className="presence-prompt nodrag nowheel">+ <div className="presence-prompt__title">Someone else is on this canvas</div>+ <div className="presence-prompt__body">Pick a name so they know who is who.</div>+ <input+ className="presence-prompt__input"+ autoFocus+ value={name}+ maxLength={NAME_MAX_LEN}+ placeholder="Your name"+ onChange={(e) => setName(e.target.value)}+ onKeyDown={(e) => {+ if (e.key === 'Enter') submit()+ if (e.key === 'Escape') setDismissed(true)+ e.stopPropagation() // never let canvas shortcuts (delete, ⌘K, "/") see this typing+ }}+ />+ <div className="presence-prompt__colors">+ {PRESENCE_COLORS.map((c) => (+ <button+ key={c}+ className={`presence-prompt__swatch${c === color ? ' presence-prompt__swatch--on' : ''}`}+ style={{ background: c }}+ title={c}+ aria-label={`Color ${c}`}+ onClick={() => setColor(c)}+ />+ ))}+ </div>+ <div className="presence-prompt__actions">+ <button className="presence-prompt__skip" onClick={() => setDismissed(true)}>+ Skip+ </button>+ <button className="presence-prompt__ok" disabled={!name.trim()} onClick={submit}>+ Join+ </button>+ </div>+ </div>+ )+}++export default PresenceNamePromptdiff --git a/src/renderer/styles.css b/src/renderer/styles.cssindex 43a0a6fb8..ac9ab4dc9 100644--- a/src/renderer/styles.css+++ b/src/renderer/styles.css@@ -5218,7 +5218,7 @@ body,border-radius: 10px;background: rgba(28, 28, 30, 0.95);border: 1px solid rgba(255, 255, 255, 0.14);- color: var(--label);+ color: var(--text);font-size: 12px;white-space: pre-wrap;overflow-wrap: anywhere;@@ -5232,7 +5232,153 @@ body,border-radius: 10px;border: 1px solid var(--accent);background: rgba(28, 28, 30, 0.96);- color: var(--label);+ color: var(--text);font-size: 13px;outline: none;}++/* ---- facepile: who is connected (the one surface that shows off-project peers) ---- */+.presence-facepile {+ position: absolute;+ top: 12px;+ right: 12px;+ z-index: 6;+ display: flex;+ gap: 4px;+}++.presence-face {+ width: 26px;+ height: 26px;+ border-radius: 50%;+ border: 1.5px solid rgba(0, 0, 0, 0.45);+ color: #000;+ font-size: 10px;+ font-weight: 700;+ letter-spacing: 0.02em;+ cursor: pointer;+ display: inline-flex;+ align-items: center;+ justify-content: center;+}++.presence-face:disabled {+ cursor: default;+}++/* On another project (canvas): dimmed, with the project name pinned under the avatar. Their+ cursor is deliberately NOT drawn here — see PresenceLayer. */+.presence-face--away {+ opacity: 0.45;+ position: relative;+ overflow: visible;+}++.presence-face--away:hover:enabled {+ opacity: 0.75;+}++.presence-face__where {+ position: absolute;+ top: 100%;+ left: 50%;+ transform: translate(-50%, 2px);+ max-width: 64px;+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+ font-size: 9px;+ font-weight: 600;+ color: var(--muted);+}++.presence-face__phone {+ font-size: 13px;+ line-height: 1;+}++/* ---- first-connect name/color prompt ---- */+.presence-prompt {+ position: absolute;+ top: 46px;+ right: 12px;+ z-index: 14;+ width: 260px;+ padding: 12px;+ border-radius: 12px;+ background: var(--panel);+ border: 1px solid var(--border);+ box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);+}++.presence-prompt__title {+ font-size: 13px;+ font-weight: 600;+ color: var(--text);+}++.presence-prompt__body {+ margin: 4px 0 10px;+ font-size: 12px;+ color: var(--muted);+}++.presence-prompt__input {+ width: 100%;+ padding: 6px 8px;+ border-radius: 8px;+ border: 1px solid var(--border);+ background: var(--panel-header);+ color: var(--text);+ font-size: 13px;+ outline: none;+}++.presence-prompt__colors {+ display: flex;+ gap: 6px;+ margin: 10px 0;+}++.presence-prompt__swatch {+ width: 18px;+ height: 18px;+ border-radius: 50%;+ border: 2px solid transparent;+ cursor: pointer;+}++.presence-prompt__swatch--on {+ border-color: var(--text);+}++.presence-prompt__actions {+ display: flex;+ justify-content: flex-end;+ gap: 8px;+}++.presence-prompt__ok,+.presence-prompt__skip {+ padding: 4px 12px;+ border-radius: 8px;+ font-size: 12px;+ cursor: pointer;+}++.presence-prompt__ok {+ background: var(--accent);+ color: #fff;+ border: none;+}++.presence-prompt__ok:disabled {+ opacity: 0.5;+ cursor: default;+}++.presence-prompt__skip {+ background: transparent;+ color: var(--muted);+ border: 1px solid var(--border);+}