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(sidebar): setting to keep expand/collapse choices across project switches

enes9a2d787258c6
diff --git a/src/renderer/components/SessionsSidebar.tsx b/src/renderer/components/SessionsSidebar.tsx
index 5db84f57f..3da2e5773 100644
--- a/src/renderer/components/SessionsSidebar.tsx
+++ b/src/renderer/components/SessionsSidebar.tsx
@@ -8,6 +8,7 @@ import {
import { SessionRow } from './SessionRow'
import { IconBellFilled, IconCircleCheck, IconPin } from './icons'
import { useProjects } from '../state/projects'
+import { useSettings } from '../state/settings'
import { useAgentStatus } from '../state/agentStatus'
import { useSessionNaming } from '../state/sessionNaming'
import { useSession } from '../session/session'
@@ -70,9 +71,13 @@ export function SessionsSidebar(props: SessionsSidebarProps): JSX.Element | null
// Switching the active project resets the manual collapse choices, so the default takes
// over again: the newly active project expands, everything else collapses. Without this,
// one manual toggle stuck forever and project switches stopped re-focusing the list.
+ // Gated on settings.sidebarAutoCollapse — with it OFF, a project switch changes nothing:
+ // every project defaults to expanded (see isGroupCollapsed) and the user's toggles stick.
+ const autoCollapse = useSettings((s) => s.settings.sidebarAutoCollapse)
useEffect(() => {
+ if (!autoCollapse) return
setOverrides((prev) => (Object.keys(prev).length === 0 ? prev : {}))
- }, [activeProjectId])
+ }, [activeProjectId, autoCollapse])
// Look up the current git branch for each project cwd (best-effort, cached). Gated on `open`
// and caches a NEGATIVE result too — without the '' fallback a non-git cwd re-fired a git
@@ -258,7 +263,7 @@ export function SessionsSidebar(props: SessionsSidebarProps): JSX.Element | null
>
{groups.length === 0 && <div className="sessions-sidebar__empty">No sessions yet.</div>}
{groups.map((g) => {
- const isCollapsed = isGroupCollapsed(overrides, g.projectId, g.isActive)
+ const isCollapsed = isGroupCollapsed(overrides, g.projectId, g.isActive, autoCollapse)
const signals = projectSignalCounts(g)
return (
<div
diff --git a/src/renderer/components/settings/sections/BehaviorSection.tsx b/src/renderer/components/settings/sections/BehaviorSection.tsx
index 38b129f85..f10cc0cff 100644
--- a/src/renderer/components/settings/sections/BehaviorSection.tsx
+++ b/src/renderer/components/settings/sections/BehaviorSection.tsx
@@ -14,6 +14,10 @@ const ROWS = {
snap: { title: 'Snap to grid', keywords: ['snap', 'grid', 'align'] },
panHover: { title: 'Pan-hover delay (ms)', keywords: ['pan', 'hover', 'delay', 'focus', 'guard'] },
doubleClick: { title: 'Double-click to focus', keywords: ['double', 'click', 'focus'] },
+ sidebarCollapse: {
+ title: 'Sidebar: focus active project',
+ keywords: ['sidebar', 'sessions', 'collapse', 'expand', 'project', 'switch']
+ },
wheelZoom: { title: 'Scroll wheel zooms', keywords: ['zoom', 'wheel', 'scroll', 'mouse', 'pan'] }
}
const ENTRIES = Object.values(ROWS)
@@ -99,6 +103,19 @@ export function BehaviorSection({ isActive }: { isActive: boolean }): React.JSX.
}
/>
</SearchableRow>
+ <SearchableRow {...ROWS.sidebarCollapse}>
+ <FieldRow
+ label="Sidebar: focus active project"
+ description="Collapse inactive projects in the sessions sidebar when switching projects. Off: everything stays as you left it."
+ control={
+ <Switch
+ checked={settings.sidebarAutoCollapse}
+ onChange={(v) => update({ sidebarAutoCollapse: v })}
+ ariaLabel="Sidebar: focus active project"
+ />
+ }
+ />
+ </SearchableRow>
<SearchableRow {...ROWS.wheelZoom}>
<FieldRow
label="Scroll wheel zooms"
diff --git a/src/renderer/lib/sessionList.test.ts b/src/renderer/lib/sessionList.test.ts
index 69ddb5c0c..92a0d467d 100644
--- a/src/renderer/lib/sessionList.test.ts
+++ b/src/renderer/lib/sessionList.test.ts
@@ -41,6 +41,12 @@ describe('isGroupCollapsed', () => {
expect(isGroupCollapsed({ p1: true }, 'p1', true)).toBe(true) // active but user collapsed
expect(isGroupCollapsed({ p2: false }, 'p2', false)).toBe(false) // inactive but user expanded
})
+
+ it('with autoCollapse off, everything defaults to expanded (overrides still win)', () => {
+ expect(isGroupCollapsed({}, 'p1', true, false)).toBe(false)
+ expect(isGroupCollapsed({}, 'p2', false, false)).toBe(false) // inactive stays expanded
+ expect(isGroupCollapsed({ p2: true }, 'p2', false, false)).toBe(true) // user collapsed
+ })
})
describe('buildSessionList', () => {
diff --git a/src/renderer/lib/sessionList.ts b/src/renderer/lib/sessionList.ts
index f35ed1bab..6d9d27d83 100644
--- a/src/renderer/lib/sessionList.ts
+++ b/src/renderer/lib/sessionList.ts
@@ -34,17 +34,20 @@ const STATE_LABEL: Record<StatusKind, string> = {
}
/**
- * 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.
+ * Whether a project group is collapsed in the sessions sidebar. With `autoCollapse` (the
+ * default, `settings.sidebarAutoCollapse`) the default keeps the active project expanded and
+ * every other project collapsed (so the list stays uncluttered); with it off, every project
+ * defaults to expanded and nothing changes on a project switch. An explicit user toggle,
+ * recorded in `overrides` (true = collapsed, false = expanded), always wins over the default.
*/
export function isGroupCollapsed(
overrides: Record<string, boolean>,
projectId: string,
- isActive: boolean
+ isActive: boolean,
+ autoCollapse = true
): boolean {
- return projectId in overrides ? overrides[projectId] : !isActive
+ if (projectId in overrides) return overrides[projectId]
+ return autoCollapse ? !isActive : false
}
/**
diff --git a/src/shared/types.ts b/src/shared/types.ts
index 40c25f9f9..87bd14359 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -453,6 +453,10 @@ export interface Settings {
* whatever size they were saved with; other node kinds keep their own defaults. */
defaultNodeWidth: number
defaultNodeHeight: number
+ /** Sessions sidebar: collapse inactive projects and re-focus the list on every project
+ * switch (the historical behavior). Off = every project defaults to expanded and a
+ * project switch never touches the user's expand/collapse choices. */
+ sidebarAutoCollapse: boolean
/** ms to dwell over a terminal before it takes pointer focus (pan-across guard). */
panHoverDelay: number
doubleClickFocus: boolean
@@ -510,6 +514,7 @@ export const DEFAULT_SETTINGS: Settings = {
snapToGrid: false,
defaultNodeWidth: 600,
defaultNodeHeight: 400,
+ sidebarAutoCollapse: true,
panHoverDelay: 600,
doubleClickFocus: true,
wheelZoom: false,