The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): honor show all sessions in projects
KoNit-K38a4e909c63a
diff --git a/apps/desktop/src/app/chat/sidebar/projects/entered-content.tsx b/apps/desktop/src/app/chat/sidebar/projects/entered-content.tsxindex ad970ec0ddd..0ede7d4fe2e 100644--- a/apps/desktop/src/app/chat/sidebar/projects/entered-content.tsx+++ b/apps/desktop/src/app/chat/sidebar/projects/entered-content.tsx@@ -37,7 +37,8 @@ export function EnteredProjectContent({onNewSessionSplit,repoWorktrees,liveSessions,- removedSessionIds+ removedSessionIds,+ showAllSessions = false}: {project: SidebarProjectTreerenderRows: (sessions: SessionInfo[]) => React.ReactNode@@ -46,6 +47,8 @@ export function EnteredProjectContent({repoWorktrees?: Record<string, HermesGitWorktree[]>liveSessions?: SessionInfo[]removedSessionIds?: ReadonlySet<string>+ /** Bypass the lane's ordinary five-session page when the sidebar preference is enabled. */+ showAllSessions?: boolean}) {if (!project.repos.length) {return null@@ -72,6 +75,7 @@ export function EnteredProjectContent({renderRows={renderRows}repo={repo}showHeader={!single}+ showAllSessions={showAllSessions}/>))}</>@@ -86,7 +90,8 @@ function RepoFlatSection({onNewSessionSplit,discoveredWorktrees,liveSessions,- removedSessionIds+ removedSessionIds,+ showAllSessions}: {repo: SidebarWorkspaceTreeshowHeader: boolean@@ -96,6 +101,7 @@ function RepoFlatSection({discoveredWorktrees?: HermesGitWorktree[]liveSessions?: SessionInfo[]removedSessionIds?: ReadonlySet<string>+ showAllSessions: boolean}) {const { t } = useI18n()const s = t.sidebar@@ -177,6 +183,7 @@ function RepoFlatSection({onNewSessionSplit={group.isKanban ? undefined : onNewSessionSplit}onRemove={group.isMain || group.isKanban ? undefined : () => setRemoveTarget(group)}renderRows={renderRows}+ showAllSessions={showAllSessions}/>))}</>diff --git a/apps/desktop/src/app/chat/sidebar/projects/workspace-group.tsx b/apps/desktop/src/app/chat/sidebar/projects/workspace-group.tsxindex 619759d05e8..8968dfb4c13 100644--- a/apps/desktop/src/app/chat/sidebar/projects/workspace-group.tsx+++ b/apps/desktop/src/app/chat/sidebar/projects/workspace-group.tsx@@ -37,6 +37,8 @@ interface SidebarWorkspaceGroupProps {// When set (linked worktree rows), shows a remove affordance that runs a real// `git worktree remove`.onRemove?: () => void+ /** Render all loaded workspace sessions instead of the ordinary page. */+ showAllSessions?: boolean}export function SidebarWorkspaceGroup({@@ -44,7 +46,8 @@ export function SidebarWorkspaceGroup({renderRows,onNewSession,onNewSessionSplit,- onRemove+ onRemove,+ showAllSessions = false}: SidebarWorkspaceGroupProps) {const { t } = useI18n()const s = t.sidebar@@ -65,7 +68,10 @@ export function SidebarWorkspaceGroup({const sessions = rankSessions(group.sessions, rankIds)// A profile previews the same handful a project does, and clicking its label// is how you see the rest. Workspace groups page within what's loaded.- const visibleSessions = sessions.slice(0, isProfileGroup ? PROJECT_PREVIEW_COUNT : visibleCount)+ const visibleSessions = sessions.slice(+ 0,+ isProfileGroup ? PROJECT_PREVIEW_COUNT : showAllSessions ? undefined : visibleCount+ )const hiddenCount = isProfileGroup ? 0 : sessions.length - visibleSessions.lengthconst nextCount = Math.min(SIDEBAR_GROUP_PAGE, hiddenCount)diff --git a/apps/desktop/src/app/chat/sidebar/sessions-section-new-session-drag.test.tsx b/apps/desktop/src/app/chat/sidebar/sessions-section-new-session-drag.test.tsxindex 89c5482aead..6ca8e82f992 100644--- a/apps/desktop/src/app/chat/sidebar/sessions-section-new-session-drag.test.tsx+++ b/apps/desktop/src/app/chat/sidebar/sessions-section-new-session-drag.test.tsx@@ -3,7 +3,7 @@ import type { ReactNode } from 'react'import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'import type { SessionInfo } from '@/hermes'-import { $dismissedWorktreeIds, dismissWorktree, restoreWorktree } from '@/store/layout'+import { $dismissedWorktreeIds, $sidebarShowAllSessions, dismissWorktree, restoreWorktree } from '@/store/layout'import { removeWorktreePath, switchBranchInRepo } from '@/store/projects'import {@@ -16,6 +16,7 @@ import { SidebarSessionsSection, VIRTUALIZE_THRESHOLD } from './sessions-sectionimport type { VirtualSessionListProps } from './virtual-session-list'const startNewSessionDrag = vi.hoisted(() => vi.fn())+const workspaceOpen = vi.hoisted(() => ({ value: false }))vi.mock('../new-session-drag', () => ({ startNewSessionDrag }))@@ -83,9 +84,9 @@ vi.mock('@/i18n', () => ({vi.mock('./projects/model', () => ({PROJECT_PREVIEW_COUNT: 3,- SIDEBAR_GROUP_PAGE: 20,+ SIDEBAR_GROUP_PAGE: 5,latestProjectSessions: () => [],- useWorkspaceNodeOpen: () => [false, vi.fn()]+ useWorkspaceNodeOpen: () => [workspaceOpen.value, vi.fn()]}))vi.mock('./projects/project-menu', () => ({@@ -167,12 +168,65 @@ afterEach(cleanup)beforeEach(() => {$dismissedWorktreeIds.set([])+ $sidebarShowAllSessions.set(false)+ workspaceOpen.value = falsevi.mocked(removeWorktreePath).mockReset()noop.mockClear()startNewSessionDrag.mockReset()vi.mocked(switchBranchInRepo).mockReset()})+describe('Show all sessions', () => {+ const sessions = Array.from({ length: 6 }, (_, index) => ({ id: `session-${index + 1}` }) as SessionInfo)+ const renderRows = (items: SessionInfo[]) => (+ <>+ {items.map(item => (+ <div key={item.id}>{item.id}</div>+ ))}+ </>+ )++ it('keeps the five-session page by default and renders every loaded workspace session when enabled', () => {+ workspaceOpen.value = true++ const { rerender } = render(+ <SidebarWorkspaceGroup group={group({ sessions })} renderRows={renderRows} showAllSessions={false} />+ )++ expect(screen.getByText('session-5')).toBeTruthy()+ expect(screen.queryByText('session-6')).toBeNull()++ rerender(<SidebarWorkspaceGroup group={group({ sessions })} renderRows={renderRows} showAllSessions />)++ expect(screen.getByText('session-6')).toBeTruthy()+ expect(screen.queryByRole('button', { name: /Show .* more in feature/ })).toBeNull()+ })++ it('does not cap expanded project previews at two date groups', () => {+ workspaceOpen.value = true+ $sidebarShowAllSessions.set(true)+ const now = Math.floor(Date.now() / 1000)+ const previewSessions = [0, 2, 10, 40].map(+ days =>+ ({+ id: `day-${days}`,+ last_active: now - days * 24 * 60 * 60,+ started_at: now - days * 24 * 60 * 60+ }) as SessionInfo+ )++ render(+ <SidebarSessionsSection+ {...baseProps()}+ projectOverview={[project()]}+ projectOverviewPreviews={{ 'project-1': previewSessions }}+ />+ )++ expect(screen.getByText('day-40')).toBeTruthy()+ })+})+describe('project-associated new-session drag sources', () => {it('drags from the project overview + with the project cwd', () => {const onNewSessionSplit = vi.fn()diff --git a/apps/desktop/src/app/chat/sidebar/sessions-section.tsx b/apps/desktop/src/app/chat/sidebar/sessions-section.tsxindex 393f2126e4f..46ce448a79c 100644--- a/apps/desktop/src/app/chat/sidebar/sessions-section.tsx+++ b/apps/desktop/src/app/chat/sidebar/sessions-section.tsx@@ -378,15 +378,18 @@ export function SidebarSessionsSection({// together. Compute boundaries from the whole pool, just like Updated.const renderPreviewRows = useCallback((items: SessionInfo[], projectId: string) => {- const rows = groupEntriesByRecency(flattenSessionsWithBranches(items), undefined, undefined, 2).map(row =>- row.kind === 'divider' ? { ...row, key: `project:${projectId}:${row.key}` } : row- )+ const rows = groupEntriesByRecency(+ flattenSessionsWithBranches(items),+ undefined,+ undefined,+ showAllSessions ? Infinity : 2+ ).map(row => (row.kind === 'divider' ? { ...row, key: `project:${projectId}:${row.key}` } : row))const ordered = manualOrderIds?.length ? orderRowsWithinGroups(rows, manualOrderIds) : rowsreturn hideCollapsedGroupRows(ordered, isListGroupOpen).map(row => renderListRow(row, false))},- [isListGroupOpen, manualOrderIds, renderListRow]+ [isListGroupOpen, manualOrderIds, renderListRow, showAllSessions])// Same as `renderRows`, but with date dividers folded in — used for@@ -489,6 +492,7 @@ export function SidebarSessionsSection({removedSessionIds={removedSessionIds}renderRows={renderRowsDated}repoWorktrees={projectRepoWorktrees}+ showAllSessions={showAllSessions}/>) : (emptyState