Skip to content

Fix: Deleting temporary chat resulted in an error. - #17694

Merged
wangq8 merged 2 commits into
infiniflow:mainfrom
cike8899:fix-0.27
Aug 3, 2026
Merged

wangq8 merged 2 commits into
infiniflow:mainfrom
cike8899:fix-0.27

Conversation

@cike8899

@cike8899 cike8899 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix: Deleting temporary chat resulted in an error.

@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. 🧰 typescript Pull requests that update Typescript code labels Aug 3, 2026
@cike8899 cike8899 added the ci Continue Integration label Aug 3, 2026
@cike8899
cike8899 marked this pull request as draft August 3, 2026 02:11
@cike8899
cike8899 marked this pull request as ready for review August 3, 2026 02:11
@coderabbitai

coderabbitai Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The web chat code now handles missing message content safely. Conversation-list synchronization also handles unavailable data, preserves temporary conversations, and removes duplicate fetched entries.

Changes

Chat safety and synchronization

Layer / File(s) Summary
Null-safe message content handling
web/src/components/next-message-item/utils.ts, web/src/pages/next-chats/utils.ts
Citation matching and assistant-message error filtering now tolerate missing content.
Conversation-list synchronization
web/src/pages/next-chats/hooks/use-select-conversation-list.ts
Prologue lookup handles unavailable chat-list data. Synchronization preserves temporary conversations and excludes fetched entries with duplicate IDs.

Estimated code review effort: 2 (Simple) | ~10 minutes

Poem

A rabbit checked the chat list twice,
Found empty content, fixed it nice.
Temporary chats stay in view,
Duplicate paths are filtered too.
Safe little hops through every slice.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly describes the main fix for errors when deleting temporary chats.
Description check ✅ Passed The description includes the required Summary section and clearly states the issue addressed by the pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
web/src/components/next-message-item/utils.ts (1)

4-4: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Align the helper type with the null-safe behavior.

extractNumbersFromMessageContent now handles a nullish runtime value, but its parameter is still typed as string. If IMessage.content is nullable, typed callers cannot pass it to this exported helper without a guard or cast. Widen the parameter type, or verify that callers narrow content before calling the helper. This nullable runtime contract is also used in web/src/pages/next-chats/utils.ts Lines 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

📥 Commits

Reviewing files that changed from the base of the PR and between 288be80 and c089525.

📒 Files selected for processing (3)
  • web/src/components/next-message-item/utils.ts
  • web/src/pages/next-chats/hooks/use-select-conversation-list.ts
  • web/src/pages/next-chats/utils.ts

Comment on lines +37 to +38
x.role === MessageType.Assistant &&
!x.content?.startsWith('**ERROR**:'), // Exclude error messages

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 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.

Suggested change
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.

@wangq8
wangq8 merged commit 5aa60cb into infiniflow:main Aug 3, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:S This PR changes 10-29 lines, ignoring generated files. 🧰 typescript Pull requests that update Typescript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants