Skip to content

The agent that grows with you

feat(desktop): show expanded recent sessions in project grouping

brooklyn!a6474766c8bd
diff --git a/apps/desktop/src/app/chat/sidebar/filter-menu.tsx b/apps/desktop/src/app/chat/sidebar/filter-menu.tsx
index 293d6b5d939..e593ebec6f8 100644
--- a/apps/desktop/src/app/chat/sidebar/filter-menu.tsx
+++ b/apps/desktop/src/app/chat/sidebar/filter-menu.tsx
@@ -31,6 +31,7 @@ import {
$sidebarProfileFilter,
$sidebarProjectFilter,
$sidebarRowMeta,
+ $sidebarShowAllSessions,
$sidebarShowArchived,
$sidebarStatusFilter,
$sidebarViewCustomized,
@@ -39,6 +40,7 @@ import {
setSidebarCardRows,
setSidebarGrouping,
setSidebarOrdering,
+ setSidebarShowAllSessions,
setSidebarShowArchived,
setWorkspaceNodesOpen,
type SidebarGrouping,
@@ -155,6 +157,7 @@ export function SidebarFilterMenu({ className }: { className?: string }) {
const ordering = useStore($sidebarOrdering)
const rowMeta = useStore($sidebarRowMeta)
const cardRows = useStore($sidebarCardRows)
+ const showAllSessions = useStore($sidebarShowAllSessions)
const statusFilter = useStore($sidebarStatusFilter)
const projectFilter = useStore($sidebarProjectFilter)
const profileFilter = useStore($sidebarProfileFilter)
@@ -288,6 +291,14 @@ export function SidebarFilterMenu({ className }: { className?: string }) {
</DropdownMenuSubContent>
</DropdownMenuSub>
+ {grouping === 'project' && (
+ <OptionCheckbox
+ checked={showAllSessions}
+ onCheck={() => setSidebarShowAllSessions(!showAllSessions)}
+ option={{ icon: 'list-unordered', id: 'all-sessions', label: t.sidebar.projects.showAllSessions }}
+ />
+ )}
+
{/* A render variant, not a grouping: three-line cards (project · age /
title / model · size) compose with whichever grouping is active. */}
<OptionCheckbox
diff --git a/apps/desktop/src/app/chat/sidebar/index.tsx b/apps/desktop/src/app/chat/sidebar/index.tsx
index d01f31e90fc..f5b7ed2cb60 100644
--- a/apps/desktop/src/app/chat/sidebar/index.tsx
+++ b/apps/desktop/src/app/chat/sidebar/index.tsx
@@ -51,6 +51,7 @@ import {
$sidebarRecentsOpen,
$sidebarSessionOrderIds,
$sidebarSessionOrderManual,
+ $sidebarShowAllSessions,
$sidebarShowArchived,
$sidebarStatusFilter,
$sidebarWorkspaceOrderIds,
@@ -383,6 +384,7 @@ export function ChatSidebar({
// dividers; groups apply it to their own lanes.
const sortOrderIds = useStore($sidebarSessionRankIds)
const agentsGrouped = grouping === 'project'
+ const showAllSessions = useStore($sidebarShowAllSessions)
const pinnedSessionIds = useStore($pinnedSessionIds)
const unconfirmedPinWrites = useStore($unconfirmedPinWrites)
const pinsOpen = useStore($sidebarPinsOpen)
@@ -788,6 +790,18 @@ export function ChatSidebar({
return () => window.clearTimeout(warm)
}, [activeConnectionId, worktreeGroupingActive, showAllProfiles, profileScope, gatewayReady])
+ // Widen the existing tree query when the user expands previews, without
+ // repeating repo discovery. Initial load/scope changes use the effect above.
+ useEffect(
+ () =>
+ $sidebarShowAllSessions.listen(() => {
+ if (gatewayReady && worktreeGroupingActive) {
+ void refreshProjectTree()
+ }
+ }),
+ [gatewayReady, worktreeGroupingActive]
+ )
+
// Sessions the branch join can't answer for get one look at their own
// transcript — a `gh pr create` in there names the PR outright. Backfills
// whatever is loaded, whether or not the badge is on: gating it on the badge
@@ -1132,13 +1146,19 @@ export function ChatSidebar({
// matching the flat Recents list. Keyed by project id for the rows.
const overviewPreviews = useMemo<Record<string, SessionInfo[]>>(
() =>
- overlayLivePreviews(projectOverview ?? [], agentSessions, projects, PROJECT_PREVIEW_COUNT, {
- removed: removedSessionIds,
- // Rank before the trim, so "3 priciest in this project" isn't "3 most
- // recent, priciest first".
- rankIds: sortOrderIds
- }),
- [projectOverview, agentSessions, projects, removedSessionIds, sortOrderIds]
+ overlayLivePreviews(
+ projectOverview ?? [],
+ agentSessions,
+ projects,
+ showAllSessions ? Infinity : PROJECT_PREVIEW_COUNT,
+ {
+ removed: removedSessionIds,
+ // Rank before the trim, so "3 priciest in this project" isn't "3 most
+ // recent, priciest first".
+ rankIds: sortOrderIds
+ }
+ ),
+ [projectOverview, agentSessions, projects, removedSessionIds, sortOrderIds, showAllSessions]
)
const onEnterProject = useCallback(
diff --git a/apps/desktop/src/app/chat/sidebar/projects/overview-row.tsx b/apps/desktop/src/app/chat/sidebar/projects/overview-row.tsx
index 88577de1e56..bb0612fe4f0 100644
--- a/apps/desktop/src/app/chat/sidebar/projects/overview-row.tsx
+++ b/apps/desktop/src/app/chat/sidebar/projects/overview-row.tsx
@@ -1,3 +1,4 @@
+import { useStore } from '@nanostores/react'
import type * as React from 'react'
import { useRef } from 'react'
@@ -7,6 +8,7 @@ import { Tip } from '@/components/ui/tooltip'
import type { SessionInfo } from '@/hermes'
import { useI18n } from '@/i18n'
import { cn } from '@/lib/utils'
+import { $sidebarShowAllSessions } from '@/store/layout'
import {
SIDEBAR_LEAD_ICON_SIZE,
@@ -106,8 +108,10 @@ export function ProjectOverviewRow({
// The appearance popover anchors here (the full row) so it opens flush with
// the sidebar's content edge regardless of which side the sidebar is on.
const rowRef = useRef<HTMLDivElement>(null)
- const fetched = (previewSessions ?? []).slice(0, PROJECT_PREVIEW_COUNT)
- const preview = renderRows ? (fetched.length ? fetched : latestProjectSessions(project, PROJECT_PREVIEW_COUNT)) : []
+ const showAllSessions = useStore($sidebarShowAllSessions)
+ const limit = showAllSessions ? Infinity : PROJECT_PREVIEW_COUNT
+ const fetched = (previewSessions ?? []).slice(0, limit)
+ const preview = renderRows ? (fetched.length ? fetched : latestProjectSessions(project, limit)) : []
const lead = reorderable ? (
<SidebarRowGrab
diff --git a/apps/desktop/src/app/chat/sidebar/sessions-section.tsx b/apps/desktop/src/app/chat/sidebar/sessions-section.tsx
index f8b4e350812..393f2126e4f 100644
--- a/apps/desktop/src/app/chat/sidebar/sessions-section.tsx
+++ b/apps/desktop/src/app/chat/sidebar/sessions-section.tsx
@@ -22,6 +22,7 @@ import { sessionBucketLabel } from '@/lib/time'
import { cn } from '@/lib/utils'
import {
$sidebarListGroupIds,
+ $sidebarShowAllSessions,
$sidebarWorkspaceNodeOpen,
listGroupNodeId,
toggleWorkspaceNodeCollapsed
@@ -227,6 +228,7 @@ export function SidebarSessionsSection({
card = false
}: SidebarSessionsSectionProps) {
const { t } = useI18n()
+ const showAllSessions = useStore($sidebarShowAllSessions)
const dividerLabels = t.sidebar.dateDivider
const statusDividerLabels = t.sidebar.statusDivider
const dotStates = useStore($sessionDotStateById)
@@ -372,6 +374,21 @@ export function SidebarSessionsSection({
[renderRow]
)
+ // Limit complete groups, not sessions, so a burst and its branches stay
+ // 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 ordered = manualOrderIds?.length ? orderRowsWithinGroups(rows, manualOrderIds) : rows
+
+ return hideCollapsedGroupRows(ordered, isListGroupOpen).map(row => renderListRow(row, false))
+ },
+ [isListGroupOpen, manualOrderIds, renderListRow]
+ )
+
// Same as `renderRows`, but with date dividers folded in — used for
// entered-project lanes so a lane spanning multiple days reads
// chronologically, matching the flat recents list.
@@ -503,7 +520,7 @@ export function SidebarSessionsSection({
// preview rows instead of the live overlay.
previewSessions={projectOverviewPreviews?.[project.id]}
project={project}
- renderRows={renderRows}
+ renderRows={showAllSessions ? items => renderPreviewRows(items, project.id) : renderRows}
/>
)
diff --git a/apps/desktop/src/i18n/ar.ts b/apps/desktop/src/i18n/ar.ts
index 5d7975ed94b..04143931323 100644
--- a/apps/desktop/src/i18n/ar.ts
+++ b/apps/desktop/src/i18n/ar.ts
@@ -1779,6 +1779,7 @@ export const ar = defineLocale({
noSessions: 'لا توجد جلسات بعد',
noFilterMatches: 'لا توجد جلسات تطابق عوامل التصفية هذه',
projects: {
+ showAllSessions: 'عرض جميع الجلسات',
sectionLabel: 'المشاريع',
home: 'الرئيسية',
autoDiscovered: 'مكتشف تلقائيًا',
diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.ts
index 55daa44c461..8ee28c337e7 100644
--- a/apps/desktop/src/i18n/en.ts
+++ b/apps/desktop/src/i18n/en.ts
@@ -2437,6 +2437,7 @@ export const en: Translations = {
noSessions: 'No sessions yet',
noFilterMatches: 'No sessions match these filters',
projects: {
+ showAllSessions: 'Show all sessions',
sectionLabel: 'Projects',
home: 'Home',
autoDiscovered: 'Auto-discovered',
diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.ts
index 3f5e2afe098..8dd6c83a864 100644
--- a/apps/desktop/src/i18n/ja.ts
+++ b/apps/desktop/src/i18n/ja.ts
@@ -2086,6 +2086,7 @@ export const ja = defineLocale({
noSessions: 'セッションはまだありません',
noFilterMatches: 'このフィルターに一致するセッションはありません',
projects: {
+ showAllSessions: 'すべてのセッションを表示',
sectionLabel: 'プロジェクト',
home: 'ホーム',
autoDiscovered: '自動検出',
diff --git a/apps/desktop/src/i18n/ru.ts b/apps/desktop/src/i18n/ru.ts
index 2d5a5b2f625..d35e78d7aca 100644
--- a/apps/desktop/src/i18n/ru.ts
+++ b/apps/desktop/src/i18n/ru.ts
@@ -2431,6 +2431,7 @@ export const ru = defineLocale({
noSessions: 'Сеансов пока нет',
noFilterMatches: 'Нет сеансов по этим фильтрам',
projects: {
+ showAllSessions: 'Показать все сессии',
sectionLabel: 'Проекты',
home: 'Главная',
newButton: 'Новый проект',
diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.ts
index df11084293c..10012cdd38e 100644
--- a/apps/desktop/src/i18n/types.ts
+++ b/apps/desktop/src/i18n/types.ts
@@ -2078,6 +2078,7 @@ export interface Translations {
noSessions: string
noFilterMatches: string
projects: {
+ showAllSessions: string
sectionLabel: string
home: string
autoDiscovered: string
diff --git a/apps/desktop/src/i18n/zh-hant.ts b/apps/desktop/src/i18n/zh-hant.ts
index e7c4bc046a4..6655bf96f25 100644
--- a/apps/desktop/src/i18n/zh-hant.ts
+++ b/apps/desktop/src/i18n/zh-hant.ts
@@ -2010,6 +2010,7 @@ export const zhHant = defineLocale({
noSessions: '尚無工作階段',
noFilterMatches: '沒有工作階段符合這些篩選條件',
projects: {
+ showAllSessions: '顯示所有工作階段',
sectionLabel: '專案',
home: '主頁',
autoDiscovered: '自動探索',
diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.ts
index 3e582ef03be..b6964de3cc4 100644
--- a/apps/desktop/src/i18n/zh.ts
+++ b/apps/desktop/src/i18n/zh.ts
@@ -2600,6 +2600,7 @@ export const zh: Translations = {
noSessions: '暂无会话',
noFilterMatches: '没有会话符合这些筛选条件',
projects: {
+ showAllSessions: '显示所有会话',
sectionLabel: '项目',
home: '主页',
autoDiscovered: '自动发现',
diff --git a/apps/desktop/src/store/layout-sidebar-view.test.ts b/apps/desktop/src/store/layout-sidebar-view.test.ts
index 7c675667e6d..74754993918 100644
--- a/apps/desktop/src/store/layout-sidebar-view.test.ts
+++ b/apps/desktop/src/store/layout-sidebar-view.test.ts
@@ -4,10 +4,12 @@ import {
$sidebarGrouping,
$sidebarOrdering,
$sidebarRowMeta,
+ $sidebarShowAllSessions,
$sidebarViewCustomized,
resetSidebarView,
setSidebarGrouping,
setSidebarOrdering,
+ setSidebarShowAllSessions,
toggleSidebarRowMeta,
toggleSidebarStatusFilter
} from './layout'
@@ -19,6 +21,23 @@ beforeEach(() => {
})
describe('the sidebar as it ships', () => {
+ it('remembers expanded project previews across grouping changes and clears them on reset', () => {
+ expect($sidebarShowAllSessions.get()).toBe(false)
+ setSidebarGrouping('project')
+ setSidebarShowAllSessions(true)
+ setSidebarGrouping('date')
+
+ expect($sidebarShowAllSessions.get()).toBe(true)
+ expect($sidebarViewCustomized.get()).toBe(true)
+ expect(window.localStorage.getItem('hermes.desktop.sidebarShowAllSessions')).toBe('true')
+
+ resetSidebarView()
+
+ expect($sidebarShowAllSessions.get()).toBe(false)
+ expect($sidebarViewCustomized.get()).toBe(false)
+ expect(window.localStorage.getItem('hermes.desktop.sidebarShowAllSessions')).toBe('false')
+ })
+
it('groups by date, sorts by recency, and pins the timestamp and preview', () => {
expect($sidebarGrouping.get()).toBe('date')
expect($sidebarOrdering.get()).toBe('updated')
diff --git a/apps/desktop/src/store/layout.ts b/apps/desktop/src/store/layout.ts
index e9b2676a225..a94e9101413 100644
--- a/apps/desktop/src/store/layout.ts
+++ b/apps/desktop/src/store/layout.ts
@@ -40,6 +40,7 @@ const SIDEBAR_ALL_PROFILES_AGENTS_GROUPED_STORAGE_KEY = 'hermes.desktop.sidebarA
const SIDEBAR_SORT_KEY_STORAGE_KEY = 'hermes.desktop.sidebarSortKey'
const SIDEBAR_ROW_META_STORAGE_KEY = 'hermes.desktop.sidebarRowMeta'
const SIDEBAR_CARD_ROWS_STORAGE_KEY = 'hermes.desktop.sidebarCardRows'
+const SIDEBAR_SHOW_ALL_SESSIONS_STORAGE_KEY = 'hermes.desktop.sidebarShowAllSessions'
const SIDEBAR_STATUS_FILTER_STORAGE_KEY = 'hermes.desktop.sidebarStatusFilter'
const SIDEBAR_SHOW_ARCHIVED_STORAGE_KEY = 'hermes.desktop.sidebarShowArchived'
const SIDEBAR_PROJECT_FILTER_STORAGE_KEY = 'hermes.desktop.sidebarProjectFilter'
@@ -320,6 +321,13 @@ export const $sidebarRowMeta = persistentAtom<SidebarRowMeta[]>(
* grouping is active. Off by default; dense tree surfaces never use it. */
export const $sidebarCardRows = persistentAtom(SIDEBAR_CARD_ROWS_STORAGE_KEY, false, Codecs.bool)
+/** Project overview: two complete recency groups instead of three preview rows. */
+export const $sidebarShowAllSessions = persistentAtom(SIDEBAR_SHOW_ALL_SESSIONS_STORAGE_KEY, false, Codecs.bool)
+
+export function setSidebarShowAllSessions(on: boolean) {
+ $sidebarShowAllSessions.set(on)
+}
+
export function setSidebarCardRows(on: boolean) {
$sidebarCardRows.set(on)
}
@@ -387,12 +395,13 @@ export const $sidebarFiltersActive: ReadableAtom<boolean> = computed(
* offering. Broader than `$sidebarFiltersActive`, which only knows about what
* hides rows, not about how they're grouped, sorted or labelled. */
export const $sidebarViewCustomized: ReadableAtom<boolean> = computed(
- [$sidebarGrouping, $sidebarOrdering, $sidebarRowMeta, $sidebarCardRows, $sidebarFiltersActive],
- (grouping, ordering, rowMeta, cardRows, filtersActive) =>
+ [$sidebarGrouping, $sidebarOrdering, $sidebarRowMeta, $sidebarCardRows, $sidebarShowAllSessions, $sidebarFiltersActive],
+ (grouping, ordering, rowMeta, cardRows, showAllSessions, filtersActive) =>
grouping !== SIDEBAR_DEFAULT_GROUPING ||
ordering !== SIDEBAR_DEFAULT_ORDERING ||
!sameRowMeta(rowMeta, SIDEBAR_DEFAULT_ROW_META) ||
cardRows ||
+ showAllSessions ||
filtersActive
)
@@ -696,6 +705,7 @@ export function resetSidebarView() {
setSidebarOrdering(SIDEBAR_DEFAULT_ORDERING)
$sidebarRowMeta.set(SIDEBAR_DEFAULT_ROW_META)
$sidebarCardRows.set(false)
+ $sidebarShowAllSessions.set(false)
clearSidebarFilters()
}
diff --git a/apps/desktop/src/store/projects.ts b/apps/desktop/src/store/projects.ts
index 8e2e2643731..9caab3a1168 100644
--- a/apps/desktop/src/store/projects.ts
+++ b/apps/desktop/src/store/projects.ts
@@ -15,7 +15,7 @@ import { isMissingRestEndpoint, isMissingRpcMethod } from '@/lib/gateway-rpc'
import { isUnderPath } from '@/lib/path-compare'
import { persistentAtom } from '@/lib/persisted'
import { $gateway, activeGateway, ensureActiveGatewayOpen } from '@/store/gateway'
-import { setSidebarAgentsGrouped } from '@/store/layout'
+import { $sidebarShowAllSessions, setSidebarAgentsGrouped } from '@/store/layout'
import { notify } from '@/store/notifications'
import {
$activeGatewayProfile,
@@ -379,7 +379,9 @@ interface ProjectTreePayload {
scoped_session_ids: string[]
}
-const PROJECT_TREE_PREVIEW_LIMIT = 3
+// Expanded previews need the complete existing tree window before the renderer
+// finds its two recency groups. Keep the normal three-row payload unchanged.
+const projectTreePreviewLimit = () => ($sidebarShowAllSessions.get() ? 2000 : 3)
// The all-profiles fan-out reads one database per profile, so it is allowed the
// same headroom as the cross-profile session list rather than the interactive
// default.
@@ -421,7 +423,7 @@ async function refreshProjectTreeOn(context: ActiveProjectsContext): Promise<voi
res = await gatewayRequestOn<ProjectTreePayload>(
gateway,
'projects.tree',
- projectParams({ preview_limit: PROJECT_TREE_PREVIEW_LIMIT }, profile)
+ projectParams({ preview_limit: projectTreePreviewLimit() }, profile)
)
} catch (error) {
// A remote source switch can leave the first read RPC on a newly-opened
@@ -435,7 +437,7 @@ async function refreshProjectTreeOn(context: ActiveProjectsContext): Promise<voi
res = await gatewayRequestOn<ProjectTreePayload>(
gateway,
'projects.tree',
- projectParams({ preview_limit: PROJECT_TREE_PREVIEW_LIMIT }, profile)
+ projectParams({ preview_limit: projectTreePreviewLimit() }, profile)
)
}
@@ -483,7 +485,7 @@ async function refreshProjectTreeAcrossProfiles(): Promise<void> {
try {
const res = await hermesApi<ProjectTreePayload>({
- path: `/api/profiles/projects/tree?preview_limit=${PROJECT_TREE_PREVIEW_LIMIT}`,
+ path: `/api/profiles/projects/tree?preview_limit=${projectTreePreviewLimit()}`,
timeoutMs: PROJECT_TREE_REQUEST_TIMEOUT_MS
})