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(sidebar): add projectIdAtIndex helper for the project-number shortcut
Mina Sameha9ca95bde0de
diff --git a/src/renderer/lib/sessionList.test.ts b/src/renderer/lib/sessionList.test.tsindex 92a0d467d..e648e2869 100644--- a/src/renderer/lib/sessionList.test.ts+++ b/src/renderer/lib/sessionList.test.ts@@ -2,6 +2,7 @@ import { describe, it, expect } from 'vitest'import {buildSessionList,sessionStatusKind,+ projectIdAtIndex,isGroupCollapsed,projectSignalCounts,type ProjectInput@@ -31,6 +32,28 @@ describe('sessionStatusKind', () => {})})+describe('projectIdAtIndex', () => {+ const list = [{ id: 'p1' }, { id: 'p2' }, { id: 'p3' }]++ it('maps a 1-based index to the project at that position', () => {+ expect(projectIdAtIndex(list, 1)).toBe('p1')+ expect(projectIdAtIndex(list, 3)).toBe('p3')+ })++ it('returns null past the end of the list', () => {+ expect(projectIdAtIndex(list, 4)).toBeNull()+ })++ it('returns null for index 0 or above 9', () => {+ expect(projectIdAtIndex(list, 0)).toBeNull()+ expect(projectIdAtIndex(list, 10)).toBeNull()+ })++ it('returns null for an empty project list', () => {+ expect(projectIdAtIndex([], 1)).toBeNull()+ })+})+describe('isGroupCollapsed', () => {it('defaults to expanded for the active project and collapsed for the rest', () => {expect(isGroupCollapsed({}, 'p1', true)).toBe(false)diff --git a/src/renderer/lib/sessionList.ts b/src/renderer/lib/sessionList.tsindex 6d9d27d83..e52690eaf 100644--- a/src/renderer/lib/sessionList.ts+++ b/src/renderer/lib/sessionList.ts@@ -80,6 +80,17 @@ export function sessionStatusKind(state: AgentNodeStatus['state']): StatusKind {}}+/**+ * Resolves the Cmd/Ctrl+N project shortcut: N is 1-based, matches sidebar/store array order.+ * Only 1-9 are addressable — out of range (including an empty or short project list) is null,+ * a silent no-op at the call site rather than a wraparound or error.+ */+export function projectIdAtIndex(projects: { id: string }[], oneBasedIndex: number): string | null {+ if (oneBasedIndex < 1 || oneBasedIndex > 9) return null+ const project = projects[oneBasedIndex - 1]+ return project ? project.id : null+}+export interface SessionRowVM {id: stringtitle: string