From fd3d402e9d193348104cc0d3cd3546df9d92030c Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Tue, 7 Oct 2025 20:44:22 -0700 Subject: [PATCH] fix: use session count instead of message count --- gui/src/components/CliInstallBanner.test.tsx | 26 ++++++++++---------- gui/src/components/CliInstallBanner.tsx | 18 +++++++------- gui/src/pages/gui/Chat.tsx | 12 ++++----- 3 files changed, 27 insertions(+), 29 deletions(-) diff --git a/gui/src/components/CliInstallBanner.test.tsx b/gui/src/components/CliInstallBanner.test.tsx index 5904df50d..134b5aae2 100644 --- a/gui/src/components/CliInstallBanner.test.tsx +++ b/gui/src/components/CliInstallBanner.test.tsx @@ -351,10 +351,10 @@ describe("CliInstallBanner", () => { }); }); - describe("Message threshold logic", () => { - const renderWithMessageCount = async ( - messageCount?: number, - messageThreshold?: number, + describe("Session threshold logic", () => { + const renderWithSessionCount = async ( + sessionCount?: number, + sessionThreshold?: number, ) => { vi.spyOn(mockIdeMessenger.ide, "subprocess").mockResolvedValue([ "", @@ -365,8 +365,8 @@ describe("CliInstallBanner", () => { render( , ), @@ -374,7 +374,7 @@ describe("CliInstallBanner", () => { }; it("shows banner when no threshold is set", async () => { - await renderWithMessageCount(0, undefined); + await renderWithSessionCount(0, undefined); await waitFor(() => { expect( @@ -383,8 +383,8 @@ describe("CliInstallBanner", () => { }); }); - it("does not show banner when message count is below threshold", async () => { - await renderWithMessageCount(2, 3); + it("does not show banner when session count is below threshold", async () => { + await renderWithSessionCount(2, 3); await waitFor(() => { expect( @@ -393,8 +393,8 @@ describe("CliInstallBanner", () => { }); }); - it("shows banner when message count meets threshold", async () => { - await renderWithMessageCount(3, 3); + it("shows banner when session count meets threshold", async () => { + await renderWithSessionCount(3, 3); await waitFor(() => { expect( @@ -403,8 +403,8 @@ describe("CliInstallBanner", () => { }); }); - it("shows banner when message count exceeds threshold", async () => { - await renderWithMessageCount(5, 3); + it("shows banner when session count exceeds threshold", async () => { + await renderWithSessionCount(5, 3); await waitFor(() => { expect( diff --git a/gui/src/components/CliInstallBanner.tsx b/gui/src/components/CliInstallBanner.tsx index a6ceaa312..36662309a 100644 --- a/gui/src/components/CliInstallBanner.tsx +++ b/gui/src/components/CliInstallBanner.tsx @@ -10,17 +10,17 @@ import { RunInTerminalButton } from "./StyledMarkdownPreview/StepContainerPreToo import { Card } from "./ui"; interface CliInstallBannerProps { - /** Current message count - banner shows only if >= messageThreshold */ - messageCount?: number; - /** Minimum messages before showing banner (default: always show) */ - messageThreshold?: number; + /** Number of sessions user has had - banner shows only if >= sessionThreshold */ + sessionCount?: number; + /** Minimum sessions before showing banner (default: always show) */ + sessionThreshold?: number; /** If true, dismissal is permanent via localStorage (default: session only) */ permanentDismissal?: boolean; } export function CliInstallBanner({ - messageCount, - messageThreshold, + sessionCount, + sessionThreshold, permanentDismissal = false, }: CliInstallBannerProps = {}) { const ideMessenger = useContext(IdeMessengerContext); @@ -90,13 +90,13 @@ export function CliInstallBanner({ // - Still loading CLI status // - CLI is already installed // - User has dismissed it - // - Message threshold not met (if threshold is set) + // - Session threshold not met (if threshold is set) if ( cliInstalled === null || cliInstalled === true || dismissed || - (messageThreshold !== undefined && - (messageCount === undefined || messageCount < messageThreshold)) + (sessionThreshold !== undefined && + (sessionCount === undefined || sessionCount < sessionThreshold)) ) { return null; } diff --git a/gui/src/pages/gui/Chat.tsx b/gui/src/pages/gui/Chat.tsx index d0c2f45b4..61fc0a859 100644 --- a/gui/src/pages/gui/Chat.tsx +++ b/gui/src/pages/gui/Chat.tsx @@ -119,6 +119,9 @@ export function Chat() { const isInEdit = useAppSelector((store) => store.session.isInEdit); const lastSessionId = useAppSelector((state) => state.session.lastSessionId); + const allSessionMetadata = useAppSelector( + (state) => state.session.allSessionMetadata, + ); const hasDismissedExploreDialog = useAppSelector( (state) => state.ui.hasDismissedExploreDialog, ); @@ -381,11 +384,6 @@ export function Chat() { const showScrollbar = showChatScrollbar ?? window.innerHeight > 5000; - // Count user messages for CLI banner threshold - const userMessageCount = useMemo(() => { - return history.filter((item) => item.message.role === "user").length; - }, [history]); - return ( <> {!!showSessionTabs && !isInEdit && } @@ -428,8 +426,8 @@ export function Chat() { />