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(sessions): collapse non-active project groups by default
enescc129f3e46a8
diff --git a/src/renderer/components/SessionsSidebar.tsx b/src/renderer/components/SessionsSidebar.tsxindex 9adb600ef..aa565e7c8 100644--- a/src/renderer/components/SessionsSidebar.tsx+++ b/src/renderer/components/SessionsSidebar.tsx@@ -1,5 +1,5 @@import { useEffect, useMemo, useState } from 'react'-import { buildSessionList, type SessionNodeInput } from '../lib/sessionList'+import { buildSessionList, isGroupCollapsed, type SessionNodeInput } from '../lib/sessionList'import { SessionRow } from './SessionRow'import { IconPin } from './icons'import { useProjects } from '../state/projects'@@ -7,12 +7,22 @@ import { useAgentStatus } from '../state/agentStatus'const COLLAPSE_KEY = 'nodeterm.sessionsCollapsed'-function loadCollapsed(): Set<string> {+// Explicit per-project collapse choices (true = collapsed, false = expanded). Absent = follow+// the default (active project expanded, others collapsed — see isGroupCollapsed).+function loadOverrides(): Record<string, boolean> {try {const raw = localStorage.getItem(COLLAPSE_KEY)- return new Set(raw ? (JSON.parse(raw) as string[]) : [])+ if (!raw) return {}+ const data = JSON.parse(raw)+ if (Array.isArray(data)) {+ // Legacy format: a flat list of collapsed project ids.+ const out: Record<string, boolean> = {}+ for (const id of data as string[]) out[id] = true+ return out+ }+ return data && typeof data === 'object' ? (data as Record<string, boolean>) : {}} catch {- return new Set()+ return {}}}@@ -38,7 +48,7 @@ export function SessionsSidebar(props: SessionsSidebarProps): JSX.Element | nullconst statusById = useAgentStatus((s) => s.byId)const [filter, setFilter] = useState('')- const [collapsed, setCollapsed] = useState<Set<string>>(loadCollapsed)+ const [overrides, setOverrides] = useState<Record<string, boolean>>(loadOverrides)const [branches, setBranches] = useState<Record<string, string>>({})// Look up the current git branch for each project cwd (best-effort, cached).@@ -67,13 +77,11 @@ export function SessionsSidebar(props: SessionsSidebarProps): JSX.Element | nullconst 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)+ const toggleCollapse = (id: string, currentlyCollapsed: boolean): void => {+ setOverrides((prev) => {+ const next = { ...prev, [id]: !currentlyCollapsed }try {- localStorage.setItem(COLLAPSE_KEY, JSON.stringify([...next]))+ localStorage.setItem(COLLAPSE_KEY, JSON.stringify(next))} catch {// ignore}@@ -117,10 +125,10 @@ export function SessionsSidebar(props: SessionsSidebarProps): JSX.Element | null<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)+ const isCollapsed = isGroupCollapsed(overrides, g.projectId, g.isActive)return (<div key={g.projectId} className={`ss-group${g.isActive ? ' is-active' : ''}`}>- <div className="ss-group__head" onClick={() => toggleCollapse(g.projectId)}>+ <div className="ss-group__head" onClick={() => toggleCollapse(g.projectId, isCollapsed)}><span className="ss-group__chev">{isCollapsed ? '▶' : '▼'}</span><span className="ss-group__dot" style={{ background: g.projectColor }} /><span className="ss-group__name">{g.projectName}</span>diff --git a/src/renderer/lib/sessionList.test.ts b/src/renderer/lib/sessionList.test.tsindex 1a813a94a..6aec1d55e 100644--- a/src/renderer/lib/sessionList.test.ts+++ b/src/renderer/lib/sessionList.test.ts@@ -1,5 +1,5 @@import { describe, it, expect } from 'vitest'-import { buildSessionList, sessionStatusKind, type ProjectInput } from './sessionList'+import { buildSessionList, sessionStatusKind, isGroupCollapsed, type ProjectInput } from './sessionList'import type { AgentNodeStatus } from '../state/agentStatus'const node = (id: string, over: Partial<ProjectInput['nodes'][number]> = {}) => ({@@ -25,6 +25,18 @@ describe('sessionStatusKind', () => {})})+describe('isGroupCollapsed', () => {+ it('defaults to expanded for the active project and collapsed for the rest', () => {+ expect(isGroupCollapsed({}, 'p1', true)).toBe(false)+ expect(isGroupCollapsed({}, 'p2', false)).toBe(true)+ })++ it('lets an explicit override win over the default', () => {+ expect(isGroupCollapsed({ p1: true }, 'p1', true)).toBe(true) // active but user collapsed+ expect(isGroupCollapsed({ p2: false }, 'p2', false)).toBe(false) // inactive but user expanded+ })+})+describe('buildSessionList', () => {it('groups by project with the active project first', () => {const groups = buildSessionList(projects(), null, 'p2', {}, '')diff --git a/src/renderer/lib/sessionList.ts b/src/renderer/lib/sessionList.tsindex 815387877..5dc367b3b 100644--- a/src/renderer/lib/sessionList.ts+++ b/src/renderer/lib/sessionList.ts@@ -31,6 +31,20 @@ const STATE_LABEL: Record<StatusKind, string> = {idle: 'Idle'}+/**+ * Whether a project group is collapsed in the sessions sidebar. The default keeps the active+ * project expanded and every other project collapsed (so the list stays uncluttered); an+ * explicit user toggle, recorded in `overrides` (true = collapsed, false = expanded), wins+ * over that default.+ */+export function isGroupCollapsed(+ overrides: Record<string, boolean>,+ projectId: string,+ isActive: boolean+): boolean {+ return projectId in overrides ? overrides[projectId] : !isActive+}+export function sessionStatusKind(state: AgentNodeStatus['state']): StatusKind {switch (state) {case 'working':