Skip to content

fix updating title of sessions#164

Open
DinaLaptii wants to merge 6 commits intoNVIDIA-AI-Blueprints:developfrom
DinaLaptii:fix/fix-updating-title-of-sessions
Open

fix updating title of sessions#164
DinaLaptii wants to merge 6 commits intoNVIDIA-AI-Blueprints:developfrom
DinaLaptii:fix/fix-updating-title-of-sessions

Conversation

@DinaLaptii
Copy link
Copy Markdown
Contributor

Uploading a file at the start of a conversation currently prevents the session title from updating correctly. Additionally, following the merge of my previous PRs, I need to add the feature toggle logic for the new UI.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 31, 2026

Greptile Summary

This PR fixes session title generation when a file is uploaded before the first chat message — previously the title was never set because the old check saw the file_upload_status banner and concluded the session already had content. The fix changes addUserMessage in store.ts to check conversation.messages.some(m => m.messageType === 'user') instead of message count, with a matching regression test. The PR also introduces upload-only session auto-cleanup (sessions with no user messages are discarded when navigating away) and wires up the new AppBar Sessions button introduced by prior merged PRs.

Confidence Score: 5/5

Safe to merge — the logic change is small, targeted, and fully covered by a new regression test.

All findings are P2 (test completeness and a theoretical divider edge case); the core bug fix is correct and the new hasNoUserChatMessages predicate makes the intent explicit. No security, data-integrity, or runtime-error concerns.

DataSourcesPanel.spec.tsx has an incomplete useAuth mock that leaves the auth-required banner branch untested, but this does not affect production behavior.

Important Files Changed

Filename Overview
frontends/ui/src/features/chat/store.ts Core title-update fix: shouldUpdateTitle now checks messageType === 'user' instead of message count, so file-upload banners no longer block title generation.
frontends/ui/src/features/chat/lib/session-activity.ts New hasNoUserChatMessages export: returns true when no 'user'-typed message exists; used by the upload-only session cleanup guard.
frontends/ui/src/features/chat/store.spec.ts New regression test verifies title is generated on first user message even when file_upload_status messages already exist; upload-only cleanup scenarios thoroughly covered.
frontends/ui/src/features/documents/discard-session-resources.ts Centralized teardown for upload-only sessions: stops polling, removes persistence markers, clears store state, fires async backend collection delete.
frontends/ui/src/features/documents/orchestrator.ts Adds stopPollingIfCollection to safely stop polling only when it targets the given session, preventing cross-session interference.
frontends/ui/src/features/layout/components/AppBar.tsx Replaces Menu icon with ChatMessage, adds labelled Sessions button; conditionally renders divider and title text based on sessionTitle presence.
frontends/ui/src/features/layout/components/MainLayout.tsx Passes currentConversation?.title directly to AppBar (drops '
frontends/ui/src/features/layout/components/DataSourcesPanel.tsx CSS class updated to side-panel-dock-under-header; data source availability now driven by requiresAuth flag instead of a hardcoded web_search ID.
frontends/ui/src/features/layout/components/SettingsPanel.tsx CSS class updated to side-panel-dock-under-header; no functional changes.
frontends/ui/src/features/layout/components/SessionsPanel.tsx Filters sessions with empty titles from the list; hides Delete All/New Session row when list is empty; rename handler resets to original on empty input.
frontends/ui/src/adapters/ui/icons.tsx Adds ChatMessage icon export used by the new Sessions button in AppBar and SessionsPanel heading.
frontends/ui/src/app/globals.css Adds .side-panel-dock-under-header utility class that aligns panel heading height with the app header via a KUI token override.
frontends/ui/config/vitest/vitest.setup.ts Mocks external-svg-loader to prevent post-teardown document errors; adds a full localStorage polyfill for partial environments.
frontends/ui/src/features/chat/lib/session-activity.spec.ts Comprehensive tests for hasNoUserChatMessages alongside existing activity flag utilities; all edge cases covered.
frontends/ui/src/features/layout/components/MainLayout.spec.tsx Updated title expectations (empty string instead of 'New Session') aligned with the AppBar sessionTitle change.
frontends/ui/src/features/layout/components/DataSourcesPanel.spec.tsx useAuth mock omits authRequired so only the non-auth-required banner branch is exercised; auth-required copy path untested.
frontends/ui/src/features/documents/orchestrator.spec.ts Two focused tests for stopPollingIfCollection: stops on match, no-op on mismatch.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User uploads file] --> B[file_upload_status banner\nadded to messages]
    B --> C[User types first chat message]
    C --> D[addUserMessage called]
    D --> E{messages.some\nm.messageType === 'user'?}
    E -- No user messages yet --> F[shouldUpdateTitle = true]
    E -- User message exists --> G[shouldUpdateTitle = false]
    F --> H[generateTitle from message content]
    H --> I[conversation.title updated in store]
    G --> J[conversation.title unchanged]
    I --> K[AppBar renders session title]
    J --> K
    B --> L{User navigates away\nwithout chatting?}
    L -- Yes --> M[maybeDiscardAbandonedUploadOnlySession]
    M --> N[discardSessionDocumentsResources]
    N --> O[Backend collection deleted]
    N --> P[Session removed from store]
Loading

Reviews (6): Last reviewed commit: "revert text fix test" | Re-trigger Greptile

@AjayThorve
Copy link
Copy Markdown
Collaborator

When trying this i faced a weird edge case:

filteredSessions filters out s.title.trim() !== '', so sessions created by file upload (before a user message) are invisible in the sessions panel. But they still exist in state and storage. If the user navigates away from a file-upload-only session without sending a message, they have an orphaned invisible session. This file uploaded but no message sent session is invisible, but exists in storage.

@DinaLaptii
Copy link
Copy Markdown
Contributor Author

When trying this i faced a weird edge case:

filteredSessions filters out s.title.trim() !== '', so sessions created by file upload (before a user message) are invisible in the sessions panel. But they still exist in state and storage. If the user navigates away from a file-upload-only session without sending a message, they have an orphaned invisible session. This file uploaded but no message sent session is invisible, but exists in storage.

I agree that these sessions are invisible, but I believe that is the correct behavior. If a user hasn't sent a message, the session has no functional use for them yet. We only create the session in the backend because it's a prerequisite for the file upload API; however, we shouldn't clutter the UI with it until a conversation actually begins.

@AjayThorve
Copy link
Copy Markdown
Collaborator

When trying this i faced a weird edge case:
filteredSessions filters out s.title.trim() !== '', so sessions created by file upload (before a user message) are invisible in the sessions panel. But they still exist in state and storage. If the user navigates away from a file-upload-only session without sending a message, they have an orphaned invisible session. This file uploaded but no message sent session is invisible, but exists in storage.

I agree that these sessions are invisible, but I believe that is the correct behavior. If a user hasn't sent a message, the session has no functional use for them yet. We only create the session in the backend because it's a prerequisite for the file upload API; however, we shouldn't clutter the UI with it until a conversation actually begins.

In that case, since there will be no way to go back to this invisible session, can we just remove that session instead of hiding it?

@DinaLaptii
Copy link
Copy Markdown
Contributor Author

When trying this i faced a weird edge case:
filteredSessions filters out s.title.trim() !== '', so sessions created by file upload (before a user message) are invisible in the sessions panel. But they still exist in state and storage. If the user navigates away from a file-upload-only session without sending a message, they have an orphaned invisible session. This file uploaded but no message sent session is invisible, but exists in storage.

I agree that these sessions are invisible, but I believe that is the correct behavior. If a user hasn't sent a message, the session has no functional use for them yet. We only create the session in the backend because it's a prerequisite for the file upload API; however, we shouldn't clutter the UI with it until a conversation actually begins.

In that case, since there will be no way to go back to this invisible session, can we just remove that session instead of hiding it?
Yes, sounds good. I will investigate what I can do

@DinaLaptii
Copy link
Copy Markdown
Contributor Author

@AjayThorve please check

Resolve conflicts in DataSourcesPanel.tsx (comment) and store.spec.ts
(layout mock: knowledge_base vs confluence; keep discard + deep-research mocks).

Made-with: Cursor
AjayThorve
AjayThorve previously approved these changes Apr 7, 2026
Copy link
Copy Markdown
Collaborator

@AjayThorve AjayThorve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AjayThorve AjayThorve self-requested a review April 7, 2026 23:34
@AjayThorve AjayThorve dismissed their stale review April 7, 2026 23:36

facing another issue. When uploading a file: a new session toggle (if no message has been posted), should not work period.

THat's the behavior in gemini or any of the chat apps. We only allow new session if a message has been typed and sent. Currently uploading a file and creating a new session by clicking the logo, just gets rid of the file, which is expected as per the changes, but does not feel intuitive.

@AjayThorve
Copy link
Copy Markdown
Collaborator

@DinaLaptii can you look at my above comment

@exactlyallan
Copy link
Copy Markdown
Collaborator

@DinaLaptii can you look at my above comment

I think this is the case for llamaIndex but for fRAG - the file uploads successfully async the few times I tried it. I think the behavior is tolerable for now.

In the next refactor we can revisit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants