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(sessions): SessionsSidebar shell with groups, search, pin, branch, add

enes6ba4c30e8360
diff --git a/src/renderer/components/SessionsSidebar.tsx b/src/renderer/components/SessionsSidebar.tsx
new file mode 100644
index 000000000..446221fe3
--- /dev/null
+++ b/src/renderer/components/SessionsSidebar.tsx
@@ -0,0 +1,157 @@
+import { useEffect, useMemo, useState } from 'react'
+import { buildSessionList, type SessionNodeInput } from '../lib/sessionList'
+import { SessionRow } from './SessionRow'
+import { IconPin } from './icons'
+import { useProjects } from '../state/projects'
+import { useAgentStatus } from '../state/agentStatus'
+
+const COLLAPSE_KEY = 'nodeterm.sessionsCollapsed'
+
+function loadCollapsed(): Set<string> {
+ try {
+ const raw = localStorage.getItem(COLLAPSE_KEY)
+ return new Set(raw ? (JSON.parse(raw) as string[]) : [])
+ } catch {
+ return new Set()
+ }
+}
+
+export interface SessionsSidebarProps {
+ open: boolean
+ pinned: boolean
+ liveActiveNodes: SessionNodeInput[] | null
+ onTogglePin(): void
+ onClose(): void
+ onFocusNode(id: string): void
+ onCloseSession(projectId: string, id: string): void
+ onRenameSession(projectId: string, id: string, title: string): void
+ onRowContextMenu(e: React.MouseEvent, projectId: string, id: string): void
+ onAddToProject(projectId: string): void
+}
+
+export function SessionsSidebar(props: SessionsSidebarProps): JSX.Element | null {
+ const { open, pinned, liveActiveNodes } = props
+ const projects = useProjects((s) => s.projects)
+ const activeProjectId = useProjects((s) => s.activeProjectId)
+ const statusById = useAgentStatus((s) => s.byId)
+
+ const [filter, setFilter] = useState('')
+ const [collapsed, setCollapsed] = useState<Set<string>>(loadCollapsed)
+ const [branches, setBranches] = useState<Record<string, string>>({})
+
+ // Look up the current git branch for each project cwd (best-effort, cached).
+ useEffect(() => {
+ let cancelled = false
+ projects.forEach((p) => {
+ if (!p.cwd || branches[p.id] !== undefined) return
+ window.nodeTerminal.git
+ .status(p.cwd)
+ .then((st) => {
+ if (!cancelled && st && typeof st.branch === 'string') {
+ setBranches((b) => ({ ...b, [p.id]: st.branch }))
+ }
+ })
+ .catch(() => {})
+ })
+ return () => {
+ cancelled = true
+ }
+ }, [projects, branches])
+
+ const groups = useMemo(
+ () => buildSessionList(projects, liveActiveNodes, activeProjectId, statusById, filter),
+ [projects, liveActiveNodes, activeProjectId, statusById, filter]
+ )
+
+ const total = groups.reduce((n, g) => n + g.sessions.length, 0)
+
+ const toggleCollapse = (id: string): void => {
+ setCollapsed((prev) => {
+ const next = new Set(prev)
+ if (next.has(id)) next.delete(id)
+ else next.add(id)
+ try {
+ localStorage.setItem(COLLAPSE_KEY, JSON.stringify([...next]))
+ } catch {
+ // ignore
+ }
+ return next
+ })
+ }
+
+ if (!open) return null
+
+ return (
+ <aside className="sessions-sidebar" onMouseLeave={pinned ? undefined : props.onClose}>
+ <div className="sessions-sidebar__head">
+ <span className="sessions-sidebar__title">Sessions</span>
+ <span className="sessions-sidebar__count">{total}</span>
+ <div className="sessions-sidebar__head-actions">
+ <button
+ className={pinned ? 'is-on' : ''}
+ title={pinned ? 'Unpin' : 'Pin'}
+ onClick={props.onTogglePin}
+ >
+ <IconPin />
+ </button>
+ <button title="Close" onClick={props.onClose}>
+ ×
+ </button>
+ </div>
+ </div>
+
+ <div className="sessions-sidebar__search">
+ <input
+ placeholder="Filter sessions…"
+ value={filter}
+ onChange={(e) => setFilter(e.target.value)}
+ />
+ </div>
+
+ <div className="sessions-sidebar__body">
+ {groups.length === 0 && <div className="sessions-sidebar__empty">No sessions yet.</div>}
+ {groups.map((g) => {
+ const isCollapsed = collapsed.has(g.projectId)
+ return (
+ <div key={g.projectId} className={`ss-group${g.isActive ? ' is-active' : ''}`}>
+ <div className="ss-group__head" onClick={() => toggleCollapse(g.projectId)}>
+ <span className="ss-group__chev">{isCollapsed ? '▶' : '▼'}</span>
+ <span className="ss-group__dot" style={{ background: g.projectColor }} />
+ <span className="ss-group__name">{g.projectName}</span>
+ {branches[g.projectId] && (
+ <span className="ss-group__branch">⎇ {branches[g.projectId]}</span>
+ )}
+ <span className="ss-group__count">{g.sessions.length}</span>
+ <button
+ className="ss-group__add"
+ title="New terminal in this project"
+ onClick={(e) => {
+ e.stopPropagation()
+ props.onAddToProject(g.projectId)
+ }}
+ >
+ +
+ </button>
+ </div>
+ {!isCollapsed &&
+ (g.sessions.length === 0 ? (
+ <div className="ss-group__empty">No sessions</div>
+ ) : (
+ g.sessions.map((row) => (
+ <SessionRow
+ key={row.id}
+ row={row}
+ onClick={() => props.onFocusNode(row.id)}
+ onClose={() => props.onCloseSession(g.projectId, row.id)}
+ onRename={(title) => props.onRenameSession(g.projectId, row.id, title)}
+ onContextMenu={(e) => props.onRowContextMenu(e, g.projectId, row.id)}
+ />
+ ))
+ ))}
+ </div>
+ )
+ })}
+ </div>
+ </aside>
+ )
+}
diff --git a/src/renderer/styles.css b/src/renderer/styles.css
index 75ec9f311..e6dc40672 100644
--- a/src/renderer/styles.css
+++ b/src/renderer/styles.css
@@ -3750,3 +3750,44 @@ body,
.ss-row__close { margin-left: auto; opacity: 0; border: none; background: transparent; color: var(--text); cursor: pointer; font-size: 14px; line-height: 1; padding: 0 2px; flex: 0 0 auto; }
.ss-row:hover .ss-row__close { opacity: 0.6; }
.ss-row__close:hover { opacity: 1 !important; color: #ff453a; }
+
+/* Sessions sidebar — shell */
+.sessions-sidebar {
+ position: absolute;
+ top: 54px;
+ left: 14px;
+ z-index: 12;
+ width: 300px;
+ max-height: calc(100vh - 96px);
+ display: flex;
+ flex-direction: column;
+ background: rgba(28, 28, 30, 0.96);
+ border: 1px solid var(--border);
+ border-radius: 12px;
+ box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
+ overflow: hidden;
+}
+.sessions-sidebar__head { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
+.sessions-sidebar__title { font-size: 12.5px; font-weight: 600; color: var(--text); }
+.sessions-sidebar__count { font-size: 10.5px; color: rgba(180, 180, 185, 0.85); }
+.sessions-sidebar__head-actions { margin-left: auto; display: flex; gap: 4px; }
+.sessions-sidebar__head-actions button { width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; background: transparent; border: none; color: var(--text); cursor: pointer; border-radius: 6px; }
+.sessions-sidebar__head-actions button:hover { background: var(--panel-header); }
+.sessions-sidebar__head-actions button.is-on { color: var(--accent); }
+.sessions-sidebar__search { margin: 8px 10px 4px; }
+.sessions-sidebar__search input { width: 100%; box-sizing: border-box; font-size: 12px; padding: 5px 8px; background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 7px; }
+.sessions-sidebar__body { overflow-y: auto; padding: 4px 6px 8px; }
+.sessions-sidebar__empty { padding: 18px 12px; text-align: center; font-size: 12px; color: rgba(180, 180, 185, 0.8); }
+
+.ss-group__head { display: flex; align-items: center; gap: 6px; padding: 6px 6px; cursor: pointer; border-radius: 6px; }
+.ss-group__head:hover { background: var(--panel-header); }
+.ss-group__chev { font-size: 9px; color: rgba(180, 180, 185, 0.85); width: 10px; }
+.ss-group__dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
+.ss-group__name { font-size: 12px; font-weight: 600; color: var(--text); }
+.ss-group.is-active .ss-group__name { color: var(--accent); }
+.ss-group__branch { font-size: 10px; color: rgba(180, 180, 185, 0.8); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.ss-group__count { font-size: 10px; color: rgba(180, 180, 185, 0.8); }
+.ss-group__add { margin-left: auto; opacity: 0; border: none; background: transparent; color: var(--text); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 4px; }
+.ss-group__head:hover .ss-group__add { opacity: 0.7; }
+.ss-group__add:hover { opacity: 1 !important; color: var(--accent); }
+.ss-group__empty { padding: 4px 8px 6px 22px; font-size: 11px; color: rgba(180, 180, 185, 0.6); }