The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): keep project previews visible on drill-in
Gille9dffcc431a7a
diff --git a/apps/desktop/src/app/chat/sidebar/index.tsx b/apps/desktop/src/app/chat/sidebar/index.tsxindex cc675ac4dbe..e6afa1247f2 100644--- a/apps/desktop/src/app/chat/sidebar/index.tsx+++ b/apps/desktop/src/app/chat/sidebar/index.tsx@@ -161,6 +161,7 @@ import {ProjectBackRow,ProjectMenu,projectTreeCwd,+ reconcileEnteredProjectSessions,sessionRecency as sessionTime,type SidebarProjectTree,type SidebarSessionGroup,@@ -1006,14 +1007,22 @@ export function ChatSidebar({)}, [overviewEnteredProject, enteredProjectTree, orderRepos, isHiddenFromProjects])+ const enteredProjectOverlaySessions = useMemo(+ () => reconcileEnteredProjectSessions(agentSessions, overviewEnteredProject?.previewSessions),+ [agentSessions, overviewEnteredProject?.previewSessions]+ )+// Overlay live `$sessions` onto the entered project so a just-created session// (which the backend snapshot hasn't folded in yet) counts as content and- // renders immediately — same optimistic layer as the overview previews. The- // backend now seeds each project folder as an (empty) repo, so the overlay- // always has a lane to place a new in-project session into.+ // renders immediately. Also carry over the overview's current preview rows:+ // its project tree and the separately hydrated drill-in can resolve at+ // different times, but a row visible in the overview must not disappear on+ // entry. The backend seeds each project folder as an (empty) repo, so the+ // overlay always has a lane to place a missing in-project session into.const enteredProjectContent = useMemo(- () => (enteredProject ? overlayLiveLanes(enteredProject, agentSessions, removedSessionIds) : undefined),- [enteredProject, agentSessions, removedSessionIds]+ () =>+ enteredProject ? overlayLiveLanes(enteredProject, enteredProjectOverlaySessions, removedSessionIds) : undefined,+ [enteredProject, enteredProjectOverlaySessions, removedSessionIds])const scopedRepoPaths = useMemo(@@ -1804,7 +1813,7 @@ export function ChatSidebar({) : undefined) : undefined}- liveSessions={inProject ? agentSessions : undefined}+ liveSessions={inProject ? enteredProjectOverlaySessions : undefined}manualOrderIds={agentOrderManual ? agentOrderIds : sortOrderIds}onArchiveSession={onArchiveSession}onBranchSession={onBranchSession}diff --git a/apps/desktop/src/app/chat/sidebar/projects/index.ts b/apps/desktop/src/app/chat/sidebar/projects/index.tsindex fb242fe7344..0c8374a6531 100644--- a/apps/desktop/src/app/chat/sidebar/projects/index.ts+++ b/apps/desktop/src/app/chat/sidebar/projects/index.ts@@ -15,6 +15,7 @@ export {liveSessionProjectId,overlayLiveLanes,overlayLivePreviews,+ reconcileEnteredProjectSessions,sessionRecency,type SidebarProjectTree,type SidebarSessionGroup,diff --git a/apps/desktop/src/app/chat/sidebar/projects/workspace-groups.test.ts b/apps/desktop/src/app/chat/sidebar/projects/workspace-groups.test.tsindex 34041664e6e..a1ea42858a3 100644--- a/apps/desktop/src/app/chat/sidebar/projects/workspace-groups.test.ts+++ b/apps/desktop/src/app/chat/sidebar/projects/workspace-groups.test.ts@@ -13,6 +13,7 @@ import {NO_PROJECT_ID,overlayLiveLanes,overlayLivePreviews,+ reconcileEnteredProjectSessions,sessionProjectColor,type SidebarProjectTree,type SidebarSessionGroup,@@ -613,6 +614,59 @@ describe('sessionProjectColor', () => {})describe('overlayLiveLanes', () => {+ it('keeps an overview preview visible when the hydrated drill-in is stale', () => {+ const staleHistory = makeCwdSession('/www/app', {+ id: 'stale-history',+ git_branch: 'main',+ last_active: 10+ })++ const currentPreview = makeCwdSession('/www/app', {+ id: 'current-preview',+ git_branch: 'main',+ last_active: 20+ })++ const project = projectNode({+ id: '/www/app',+ isAuto: true,+ previewSessions: [currentPreview],+ repos: [+ {+ id: '/www/app',+ label: 'app',+ path: '/www/app',+ sessionCount: 1,+ groups: [+ lane({+ id: '/www/app::branch::main',+ label: 'main',+ isMain: true,+ path: '/www/app',+ sessions: [staleHistory]+ })+ ]+ }+ ]+ })++ const overlaySessions = reconcileEnteredProjectSessions([], project.previewSessions)+ const overlaid = overlayLiveLanes(project, overlaySessions)++ expect(overlaid.repos[0].groups[0].sessions.map(session => session.id)).toEqual([+ 'current-preview',+ 'stale-history'+ ])+ })++ it('keeps the live row when it is also present in the overview preview', () => {+ const live = makeCwdSession('/www/app', { id: 'same', title: 'live title' })+ const preview = makeCwdSession('/www/app', { id: 'same', title: 'preview title' })+ const reconciled = reconcileEnteredProjectSessions([live], [preview])++ expect(reconciled).toEqual([live])+ })+it('injects a live session into the matching main lane instantly', () => {const project = projectNode({id: '/www/app',diff --git a/apps/desktop/src/app/chat/sidebar/projects/workspace-groups.ts b/apps/desktop/src/app/chat/sidebar/projects/workspace-groups.tsindex 184561dd9aa..d654d5d869c 100644--- a/apps/desktop/src/app/chat/sidebar/projects/workspace-groups.ts+++ b/apps/desktop/src/app/chat/sidebar/projects/workspace-groups.ts@@ -741,6 +741,26 @@ export function overlayLiveLanes(return { ...project, repos, sessionCount: repos.reduce((n, repo) => n + repo.sessionCount, 0) }}+/**+ * Keep the project drill-in consistent with the overview while its separate+ * full-tree request is stale or still loading. The live cache remains the+ * freshest copy when both sources contain a row; overview previews only fill+ * sessions that are missing from that cache.+ */+export function reconcileEnteredProjectSessions(+ live: SessionInfo[],+ previewSessions: SessionInfo[] | undefined+): SessionInfo[] {+ if (!previewSessions?.length) {+ return live+ }++ const liveIds = new Set(live.map(session => session.id))+ const missingPreviews = previewSessions.filter(session => !liveIds.has(session.id))++ return missingPreviews.length ? [...live, ...missingPreviews] : live+}+interface PreviewOverlayOptions {removed?: ReadonlySet<string>/** The active sort key as an id order; recency when empty. */