From cd8e0b2b7babc2132669d04bbea2178877a348ce Mon Sep 17 00:00:00 2001 From: Jinwoo-H Date: Mon, 21 Sep 2026 04:36:01 -0400 Subject: [PATCH] fix(session-search): show more reads the depth its rows came from MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The row inferred "a deeper rescan is running" from the selected depth minus one page, which at the default depth is zero, so every foreground scan with at least one session painted a disabled "Loading more sessions…" footer the scan had room for. The scan now publishes the depth it ran at beside its sessions, and the row compares the two: it survives the rescan because that depth trails the selected one until the deeper scan lands. Drops the stepping arithmetic and nextAiVaultSessionLimit, and moves the row out of the menu file it was sharing. --- .../right-sidebar/AiVaultSessionLimitMenu.tsx | 43 ------------------ ...sx => AiVaultShowMoreSessionsRow.test.tsx} | 34 +++++++++++++- .../AiVaultShowMoreSessionsRow.tsx | 45 +++++++++++++++++++ .../right-sidebar/ai-vault-applied-scan.ts | 27 +++++++++++ .../right-sidebar/ai-vault-session-limit.ts | 5 --- .../right-sidebar/ai-vault-session-refresh.ts | 17 ++++--- 6 files changed, 115 insertions(+), 56 deletions(-) rename src/renderer/src/components/right-sidebar/{AiVaultSessionLimitMenu.test.tsx => AiVaultShowMoreSessionsRow.test.tsx} (59%) create mode 100644 src/renderer/src/components/right-sidebar/AiVaultShowMoreSessionsRow.tsx create mode 100644 src/renderer/src/components/right-sidebar/ai-vault-applied-scan.ts diff --git a/src/renderer/src/components/right-sidebar/AiVaultSessionLimitMenu.tsx b/src/renderer/src/components/right-sidebar/AiVaultSessionLimitMenu.tsx index 45db6caa9c7..39b929732b2 100644 --- a/src/renderer/src/components/right-sidebar/AiVaultSessionLimitMenu.tsx +++ b/src/renderer/src/components/right-sidebar/AiVaultSessionLimitMenu.tsx @@ -7,56 +7,13 @@ import { DropdownMenuSubContent, DropdownMenuSubTrigger } from '@/components/ui/dropdown-menu' -import { Button } from '@/components/ui/button' import { translate } from '@/i18n/i18n' import { - AI_VAULT_SESSION_LIMIT_STEP, AI_VAULT_SESSION_LIMITS, DEFAULT_AI_VAULT_SESSION_LIMIT, - nextAiVaultSessionLimit, type AiVaultSessionLimit } from './ai-vault-session-limit' -/** Footer row once the scan filled its History depth; steps the same setting the menu edits. */ -export function AiVaultShowMoreSessionsRow({ - loaded, - loading, - sessionLimit, - onSessionLimitChange -}: { - loaded: number - loading: boolean - sessionLimit: AiVaultSessionLimit - onSessionLimitChange: (limit: AiVaultSessionLimit) => void -}): React.JSX.Element | null { - const next = nextAiVaultSessionLimit(sessionLimit) - if (next === null || sessionLimit === 'unlimited' || loaded === 0) { - return null - } - // Why: a step raises the depth before the rescan lands, so the row must survive - // that gap in a loading state instead of vanishing until the new rows paint. - const filled = loaded >= sessionLimit - const stepping = loading && loaded >= sessionLimit - AI_VAULT_SESSION_LIMIT_STEP - if (!filled && !stepping) { - return null - } - return ( -
- -
- ) -} - export function AiVaultSessionLimitMenu({ sessionLimit, onSessionLimitChange diff --git a/src/renderer/src/components/right-sidebar/AiVaultSessionLimitMenu.test.tsx b/src/renderer/src/components/right-sidebar/AiVaultShowMoreSessionsRow.test.tsx similarity index 59% rename from src/renderer/src/components/right-sidebar/AiVaultSessionLimitMenu.test.tsx rename to src/renderer/src/components/right-sidebar/AiVaultShowMoreSessionsRow.test.tsx index 11cbfd8d05c..105c021d5d2 100644 --- a/src/renderer/src/components/right-sidebar/AiVaultSessionLimitMenu.test.tsx +++ b/src/renderer/src/components/right-sidebar/AiVaultShowMoreSessionsRow.test.tsx @@ -2,7 +2,7 @@ import { cleanup, render, screen } from '@testing-library/react' import userEvent from '@testing-library/user-event' import { afterEach, expect, it, vi } from 'vitest' -import { AiVaultShowMoreSessionsRow } from './AiVaultSessionLimitMenu' +import { AiVaultShowMoreSessionsRow } from './AiVaultShowMoreSessionsRow' afterEach(cleanup) @@ -11,6 +11,7 @@ it('steps the history depth up by one page once the scan filled it', async () => render( { render( { expect(button.hasAttribute('disabled')).toBe(true) }) +// Why: the old rule inferred "stepping" from the selected depth minus a page, which at the +// default depth is zero, so every foreground rescan claimed more history was coming. +it('stays hidden during a foreground rescan the scan had room for', () => { + render( + + ) + expect(screen.queryByRole('button')).toBeNull() +}) + it('stays hidden while the scan has room or is already unlimited', () => { render(