Skip to content

The agent that grows with you

fix(desktop): address review feedback on Command Center load-more

zqy1-19e81bed00931
diff --git a/apps/desktop/src/app/command-center/index.tsx b/apps/desktop/src/app/command-center/index.tsx
index f36f1b1f41f..3b15b5e070e 100644
--- a/apps/desktop/src/app/command-center/index.tsx
+++ b/apps/desktop/src/app/command-center/index.tsx
@@ -29,7 +29,7 @@ import { fmtDateTime } from '@/lib/time'
import { useStoreSelector } from '@/lib/use-session-slice'
import { cn } from '@/lib/utils'
import { upsertDesktopActionTask } from '@/store/activity'
-import { $pinnedSessionIds, pinSession, unpinSession } from '@/store/layout'
+import { $pinnedSessionIds, pinSession, SIDEBAR_SESSIONS_PAGE_SIZE, unpinSession } from '@/store/layout'
import { notify } from '@/store/notifications'
import { $sessionProfilesTruncated, $sessions, sessionPinId } from '@/store/session'
import { confirmSharedGatewayRestart } from '@/store/system-actions'
@@ -57,6 +57,7 @@ type UsagePeriod = (typeof USAGE_PERIODS)[number]
// component never re-renders from $sessions ticks while on System/Usage/etc.
const EMPTY_SESSIONS: readonly never[] = []
const EMPTY_PINNED: readonly string[] = []
+const EMPTY_TRUNCATED: Record<string, boolean> = {}
interface CommandCenterViewProps {
initialSection?: CommandCenterSection
@@ -155,9 +156,16 @@ export function CommandCenterView({
const [section, setSection] = useRouteEnumParam('section', SECTIONS, initialSection ?? 'sessions')
const sessions = useStoreSelector($sessions, s => (section === 'sessions' ? s : EMPTY_SESSIONS))
const pinnedSessionIds = useStoreSelector($pinnedSessionIds, s => (section === 'sessions' ? s : EMPTY_PINNED))
+
// Mirrors the sidebar: any profile whose backend page was capped means there
// is more to load, so the Sessions list gets a "load more" affordance.
- const sessionProfilesTruncated = useStore($sessionProfilesTruncated)
+ // Gate like the other selectors: only subscribe on the Sessions tab so
+ // System/Usage/Maintenance don't re-render when $sessionProfilesTruncated
+ // ticks on every session fetch.
+ const sessionProfilesTruncated = useStoreSelector(
+ $sessionProfilesTruncated,
+ s => (section === 'sessions' ? s : EMPTY_TRUNCATED)
+ )
const [query, setQuery] = useState('')
const [pendingDelete, setPendingDelete] = useState<SessionInfo | null>(null)
@@ -457,12 +465,12 @@ export function CommandCenterView({
</ul>
)}
</div>
- {hasMoreSessions && !debouncedQuery && (
+ {hasMoreSessions && !!onLoadMoreSessions && !debouncedQuery && (
<div className="flex shrink-0 items-end justify-end">
<SidebarLoadMoreRow
loading={loadMorePending}
onClick={() => void onLoadMore()}
- step={0}
+ step={SIDEBAR_SESSIONS_PAGE_SIZE}
/>
</div>
)}