The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(desktop): derive SidebarGrouping from the grouping order; invariant cycle test
kshitijk4poor1450c7fcfb5c
diff --git a/apps/desktop/src/store/layout-sidebar-view.test.ts b/apps/desktop/src/store/layout-sidebar-view.test.tsindex 56b83d96433..2a3c7f941ff 100644--- a/apps/desktop/src/store/layout-sidebar-view.test.ts+++ b/apps/desktop/src/store/layout-sidebar-view.test.ts@@ -11,6 +11,8 @@ import {setSidebarGrouping,setSidebarOrdering,setSidebarShowAllSessions,+ SIDEBAR_GROUPING_ORDER,+ type SidebarGrouping,toggleSidebarRowMeta,toggleSidebarStatusFilter} from './layout'@@ -96,20 +98,20 @@ describe('the sidebar as it ships', () => {expect($sidebarGrouping.get()).toBe('profile')})- it('cycles through every grouping in the filter-menu order', () => {- expect($sidebarGrouping.get()).toBe('date')+ it('visits every grouping once per lap and comes back to where it started', () => {+ const start = $sidebarGrouping.get()+ const visited: SidebarGrouping[] = []- cycleSidebarGrouping()- expect($sidebarGrouping.get()).toBe('project')+ for (let step = 0; step < SIDEBAR_GROUPING_ORDER.length; step++) {+ cycleSidebarGrouping()+ visited.push($sidebarGrouping.get())- cycleSidebarGrouping()- expect($sidebarGrouping.get()).toBe('status')+ if ($sidebarGrouping.get() === 'profile') {+ expect($showAllProfiles.get()).toBe(true)+ }+ }- cycleSidebarGrouping()- expect($sidebarGrouping.get()).toBe('profile')- expect($showAllProfiles.get()).toBe(true)-- cycleSidebarGrouping()- expect($sidebarGrouping.get()).toBe('date')+ expect(new Set(visited)).toEqual(new Set(SIDEBAR_GROUPING_ORDER))+ expect($sidebarGrouping.get()).toBe(start)})})diff --git a/apps/desktop/src/store/layout.ts b/apps/desktop/src/store/layout.tsindex 2893c689543..2f5d86a5f03 100644--- a/apps/desktop/src/store/layout.ts+++ b/apps/desktop/src/store/layout.ts@@ -252,10 +252,10 @@ export const $sidebarAgentsGrouped: ReadableAtom<boolean> = computed(/** How the recents list is divided. `date` is the sidebar's long-standing* default (Today / Yesterday / Last week dividers). `profile` only means* anything while the sidebar is showing every profile at once. */-export type SidebarGrouping = 'date' | 'profile' | 'project' | 'status'-/** The one ordering of groupings: the filter menu lists them in it and the- * `view.cycleSidebarGrouping` keybind walks it, so the two cannot drift. */-export const SIDEBAR_GROUPING_ORDER: readonly SidebarGrouping[] = ['date', 'project', 'status', 'profile']+export const SIDEBAR_GROUPING_ORDER = ['date', 'project', 'status', 'profile'] as const+/** Derived from the order so a new grouping cannot exist without a slot in the+ * filter menu and the `view.cycleSidebarGrouping` keybind, which both walk it. */+export type SidebarGrouping = (typeof SIDEBAR_GROUPING_ORDER)[number]/** What ranks rows within whatever grouping is active. */export type SidebarOrdering = 'cost' | 'created' | 'manual' | 'status' | 'tokens' | 'updated'/** The sort keys the menu offers; `manual` is entered by dragging, not picked. */