Repository navigation
Fix: Deleting temporary chat resulted in an error. - #17694
Conversation
📝 WalkthroughWalkthroughThe web chat code now handles missing message content safely. Conversation-list synchronization also handles unavailable data, preserves temporary conversations, and removes duplicate fetched entries. ChangesChat safety and synchronization
Estimated code review effort: 2 (Simple) | ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
web/src/components/next-message-item/utils.ts (1)
4-4: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAlign the helper type with the null-safe behavior.
extractNumbersFromMessageContentnow handles a nullish runtime value, but its parameter is still typed asstring. IfIMessage.contentis nullable, typed callers cannot pass it to this exported helper without a guard or cast. Widen the parameter type, or verify that callers narrowcontentbefore calling the helper. This nullable runtime contract is also used inweb/src/pages/next-chats/utils.tsLines 37-38 and 49-52.Suggested type change
-export const extractNumbersFromMessageContent = (content: string) => { +export const extractNumbersFromMessageContent = ( + content: string | null | undefined, +) => {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@web/src/components/next-message-item/utils.ts` at line 4, Update the exported extractNumbersFromMessageContent helper to accept the same nullable content values handled by its null-safe implementation, or ensure every caller narrows IMessage.content before invoking it. Align the helper signature and callers in next-chats utilities so nullable content passes type checking without casts.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@web/src/pages/next-chats/utils.ts`:
- Around line 37-38: Update the assistant-message filter in the utility’s
assistantMessages construction to require non-empty x.content before excluding
**ERROR** messages, so nullish or incomplete assistant messages are not indexed.
Preserve the existing assistant-role and error-message conditions, and add a
regression test covering a pending assistant message before a completed answer
to verify referenceIndex and citations remain aligned.
---
Nitpick comments:
In `@web/src/components/next-message-item/utils.ts`:
- Line 4: Update the exported extractNumbersFromMessageContent helper to accept
the same nullable content values handled by its null-safe implementation, or
ensure every caller narrows IMessage.content before invoking it. Align the
helper signature and callers in next-chats utilities so nullable content passes
type checking without casts.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: c0c5a713-f93d-4e15-9c31-a88f81d1f9f0
📒 Files selected for processing (3)
web/src/components/next-message-item/utils.tsweb/src/pages/next-chats/hooks/use-select-conversation-list.tsweb/src/pages/next-chats/utils.ts
| x.role === MessageType.Assistant && | ||
| !x.content?.startsWith('**ERROR**:'), // Exclude error messages |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Exclude incomplete assistant messages from the reference index.
When x.content is nullish, !x.content?.startsWith('**ERROR**:') evaluates to true. The message then enters assistantMessages. A pending assistant message before a completed answer shifts referenceIndex and can attach the wrong citation. The isPendingAnswer check does not remove earlier pending messages. Require non-empty content before indexing and add a regression test for this ordering.
Suggested filter change
x.role === MessageType.Assistant &&
- !x.content?.startsWith('**ERROR**:'), // Exclude error messages
+ typeof x.content === 'string' &&
+ x.content.length > 0 &&
+ !x.content.startsWith('**ERROR**:'), // Exclude pending and error messages📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| x.role === MessageType.Assistant && | |
| !x.content?.startsWith('**ERROR**:'), // Exclude error messages | |
| x.role === MessageType.Assistant && | |
| typeof x.content === 'string' && | |
| x.content.length > 0 && | |
| !x.content.startsWith('**ERROR**:'), // Exclude pending and error messages |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@web/src/pages/next-chats/utils.ts` around lines 37 - 38, Update the
assistant-message filter in the utility’s assistantMessages construction to
require non-empty x.content before excluding **ERROR** messages, so nullish or
incomplete assistant messages are not indexed. Preserve the existing
assistant-role and error-message conditions, and add a regression test covering
a pending assistant message before a completed answer to verify referenceIndex
and citations remain aligned.
Summary
Fix: Deleting temporary chat resulted in an error.