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(project-settings): dynamic project section ids + render-time Projects nav group
enes66c2e9ff2b24
diff --git a/src/renderer/components/settings/SettingsIcons.tsx b/src/renderer/components/settings/SettingsIcons.tsxindex 3df4e9a6c..afbcbacd1 100644--- a/src/renderer/components/settings/SettingsIcons.tsx+++ b/src/renderer/components/settings/SettingsIcons.tsx@@ -1,8 +1,13 @@import type { SettingsSectionId } from './nav'+import { parseProjectSectionId } from './project-settings-targets'++/** The closed part of `SettingsSectionId` — everything except the dynamic `project-${string}`+ * ids, which don't get their own icon (see the fallback in `SectionIcon`). */+type StaticSettingsSectionId = Exclude<SettingsSectionId, `project-${string}`>/** One small line glyph per settings section, used in the sidebar nav.* 16×16, currentColor stroke — color is driven by the parent (active = accent). */-const PATHS: Record<SettingsSectionId, React.JSX.Element> = {+const PATHS: Record<StaticSettingsSectionId, React.JSX.Element> = {terminal: (<><rect x="2" y="3" width="12" height="10" rx="2" />@@ -137,7 +142,14 @@ const PATHS: Record<SettingsSectionId, React.JSX.Element> = {)}+// A small folder glyph, used for project sections — those ids are dynamic (one per open+// project), so there's no per-project entry in `PATHS`.+const PROJECT_FALLBACK: React.JSX.Element = (+ <path d="M2.5 4.8A1.3 1.3 0 0 1 3.8 3.5h2.6l1.3 1.5h4.5a1.3 1.3 0 0 1 1.3 1.3v5A1.3 1.3 0 0 1 12.2 12.6H3.8a1.3 1.3 0 0 1-1.3-1.3Z" />+)+export function SectionIcon({ id }: { id: SettingsSectionId }): React.JSX.Element {+ const path = parseProjectSectionId(id) !== null ? PROJECT_FALLBACK : PATHS[id as StaticSettingsSectionId]return (<svgwidth="16"@@ -150,7 +162,7 @@ export function SectionIcon({ id }: { id: SettingsSectionId }): React.JSX.ElemenstrokeLinejoin="round"aria-hidden="true">- {PATHS[id]}+ {path}</svg>)}diff --git a/src/renderer/components/settings/SettingsSidebar.tsx b/src/renderer/components/settings/SettingsSidebar.tsxindex 06baeec42..8411dcb10 100644--- a/src/renderer/components/settings/SettingsSidebar.tsx+++ b/src/renderer/components/settings/SettingsSidebar.tsx@@ -1,26 +1,35 @@+import { useMemo } from 'react'import { cn } from '@renderer/ui/cn'import { Input } from '@renderer/ui/Input'-import { visibleSettingsGroups, type SettingsSectionId } from './nav'--const isMac = /Mac/i.test(navigator.platform || navigator.userAgent)-const GROUPS = visibleSettingsGroups(isMac)+import { visibleSettingsGroups, type SettingsGroup, type SettingsSectionId } from './nav'import { matchesQuery } from './search'import { SectionIcon } from './SettingsIcons'+const isMac = /Mac/i.test(navigator.platform || navigator.userAgent)+export function SettingsSidebar({activeSectionId,query,onSelect,onQueryChange,- onClose+ onClose,+ extraGroups}: {activeSectionId: SettingsSectionIdquery: stringonSelect: (id: SettingsSectionId) => voidonQueryChange: (q: string) => voidonClose: () => void+ /** Groups appended after the static nav — e.g. the render-time "Projects" group, which the+ * caller builds from live project state (kept out of the sidebar so it needs no store+ * subscription of its own). */+ extraGroups?: SettingsGroup[]}): React.JSX.Element {const hasQuery = query.trim() !== ''+ const GROUPS = useMemo(+ () => [...visibleSettingsGroups(isMac), ...(extraGroups ?? [])],+ [extraGroups]+ )return (<aside className="flex w-[256px] shrink-0 flex-col border-r border-border bg-panel"><divdiff --git a/src/renderer/components/settings/nav.test.ts b/src/renderer/components/settings/nav.test.tsindex 60acd2e6c..df1d3ad0c 100644--- a/src/renderer/components/settings/nav.test.ts+++ b/src/renderer/components/settings/nav.test.ts@@ -1,5 +1,5 @@import { describe, it, expect } from 'vitest'-import { SETTINGS_GROUPS, allSectionIds, FIRST_SECTION_ID, visibleSettingsGroups } from './nav'+import { SETTINGS_GROUPS, allSectionIds, FIRST_SECTION_ID, visibleSettingsGroups, projectsSettingsGroup } from './nav'describe('SETTINGS_GROUPS', () => {it('lists exactly 24 sections with no duplicates', () => {@@ -19,3 +19,11 @@ describe('SETTINGS_GROUPS', () => {expect(visibleSettingsGroups(false).every((g) => g.sections.length > 0)).toBe(true)})})++describe('projectsSettingsGroup', () => {+ it('derives one row per project and returns null when empty', () => {+ const g = projectsSettingsGroup([{ id: 'p1', name: 'Alpha', color: '#fff' }])+ expect(g?.sections).toEqual([{ id: 'project-p1', title: 'Alpha' }])+ expect(projectsSettingsGroup([])).toBeNull()+ })+})diff --git a/src/renderer/components/settings/nav.ts b/src/renderer/components/settings/nav.tsindex 4c89a2f5a..1873e2cb1 100644--- a/src/renderer/components/settings/nav.ts+++ b/src/renderer/components/settings/nav.ts@@ -1,3 +1,5 @@+import { projectSectionId } from './project-settings-targets'+export type SettingsSectionId =| 'terminal'| 'shell'@@ -23,6 +25,13 @@ export type SettingsSectionId =| 'updates'| 'privacy'| 'debug'+ | `project-${string}`++export interface ProjectNavItem {+ id: string+ name: string+ color: string+}export interface SettingsSectionRef {id: SettingsSectionId@@ -113,3 +122,18 @@ export function visibleSettingsGroups(isMac: boolean): SettingsGroup[] {(g) => g.sections.length > 0)}++/**+ * Render-time only — deliberately NOT part of `SETTINGS_GROUPS`. Open projects change at+ * runtime, so this builds a group from the current project list on every render instead of+ * baking project ids into the static nav (which would break the `nav.test.ts` section-count+ * pins). Returns null when there are no open projects, so callers can skip rendering the group.+ */+export function projectsSettingsGroup(projects: ProjectNavItem[]): SettingsGroup | null {+ if (projects.length === 0) return null+ return {+ id: 'projects',+ title: 'Projects',+ sections: projects.map((p) => ({ id: projectSectionId(p.id), title: p.name }))+ }+}diff --git a/src/renderer/components/settings/project-settings-targets.test.ts b/src/renderer/components/settings/project-settings-targets.test.tsnew file mode 100644index 000000000..705b677c4--- /dev/null+++ b/src/renderer/components/settings/project-settings-targets.test.ts@@ -0,0 +1,10 @@+import { describe, it, expect } from 'vitest'+import { projectSectionId, parseProjectSectionId } from './project-settings-targets'++describe('project section ids', () => {+ it('round-trips and rejects non-project ids', () => {+ expect(parseProjectSectionId(projectSectionId('abc-123'))).toBe('abc-123')+ expect(parseProjectSectionId('terminal')).toBeNull()+ expect(parseProjectSectionId('project-')).toBeNull()+ })+})diff --git a/src/renderer/components/settings/project-settings-targets.ts b/src/renderer/components/settings/project-settings-targets.tsnew file mode 100644index 000000000..5b97442da--- /dev/null+++ b/src/renderer/components/settings/project-settings-targets.ts@@ -0,0 +1,15 @@+import type { SettingsSectionId } from './nav'++const PROJECT_SECTION_PREFIX = 'project-'++/** Builds the dynamic settings section id for a project. */+export function projectSectionId(projectId: string): SettingsSectionId {+ return `${PROJECT_SECTION_PREFIX}${projectId}` as SettingsSectionId+}++/** Inverse of {@link projectSectionId}. Returns null for non-project ids and for an empty project id. */+export function parseProjectSectionId(id: string): string | null {+ if (!id.startsWith(PROJECT_SECTION_PREFIX)) return null+ const projectId = id.slice(PROJECT_SECTION_PREFIX.length)+ return projectId === '' ? null : projectId+}