Skip to content

Fixed an issue where cited webpages could not be opened during online searches. - #16840

Merged
wangq8 merged 2 commits into
infiniflow:mainfrom
dcc123456:fix/chat-web-error
Jul 13, 2026
Merged

Fixed an issue where cited webpages could not be opened during online searches.#16840
wangq8 merged 2 commits into
infiniflow:mainfrom
dcc123456:fix/chat-web-error

Conversation

@dcc123456

Copy link
Copy Markdown
Contributor

Summary

Fixed an issue where cited webpages could not be opened during online searches.

@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. labels Jul 13, 2026
@dcc123456
dcc123456 requested a review from wangq8 July 13, 2026 02:46
@dcc123456 dcc123456 added the ci Continue Integration label Jul 13, 2026
@dcc123456
dcc123456 marked this pull request as draft July 13, 2026 02:47
@dcc123456
dcc123456 marked this pull request as ready for review July 13, 2026 02:47
@dosubot dosubot Bot added the 🧰 typescript Pull requests that update Typescript code label Jul 13, 2026
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Document URL preview

Layer / File(s) Summary
Chunk URL contract and wiring
web/src/interfaces/database/dataset.ts, web/src/components/next-message-item/reference-document-list.tsx
IChunk accepts an optional document_url, and the selected document URL is passed to PdfDrawer.
Preview URL and title handling
web/src/pages/next-search/document-preview-modal/index.tsx
PdfDrawer accepts flexible chunk data, uses document URLs for web pages, and renders web-page names as external links.

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

Suggested reviewers: wangq8

Poem

A rabbit hops through links so bright,
Carrying URLs into sight.
The drawer opens pages far and wide,
With document names linked outside.
“A tidy trail!” the bunny cried.

🚥 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 matches the core change: fixing online search citations so webpages open correctly.
Description check ✅ Passed The description includes the required Summary section and explains the fix in one sentence.

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: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
web/src/components/next-message-item/reference-document-list.tsx (1)

24-32: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Remove commented-out code.

Per coding guidelines, commented-out code should be removed. The NewDocumentLink JSX block at lines 24-32 is dead code.

♻️ Proposed cleanup
             <FileIcon id={item.doc_id} name={item.doc_name}></FileIcon>
-            {/* <NewDocumentLink
-              documentId={item.doc_id}
-              documentName={item.doc_name}
-              prefix="document"
-              link={item.url}
-              className="text-text-sub-title-invert"
-            >
-              {middleEllipsis(item.doc_name)}
-            </NewDocumentLink> */}
             <div className="text-text-sub-title-invert">

As per coding guidelines: "Remove dead tests, commented-out code, stale documentation, and 'move later' notes."

🤖 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/reference-document-list.tsx` around
lines 24 - 32, Remove the commented-out NewDocumentLink JSX block from the
reference document list, leaving the surrounding component structure unchanged.

Source: Coding guidelines

🤖 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-search/document-preview-modal/index.tsx`:
- Around line 38-39: Remove the commented-out useRef and useState declarations
near the document preview modal implementation, leaving the surrounding active
code unchanged.
- Around line 15-22: Replace the chunk type’s broad [key: string]: any index
signature with a dedicated PreviewChunk interface containing the currently
supported fields, and add document_url explicitly with its appropriate type.
Update the document-preview modal to use PreviewChunk so accesses such as
document_url remain type-safe without accepting arbitrary properties.
- Around line 42-43: Update the isWebPage calculation in the document preview
URL selection to detect web pages from the chunk’s explicit web-page
discriminator, such as doc_type, or directly from document_url presence, rather
than requiring fileType to be empty. Preserve getDocumentUrl() for non-web
documents and use document_url for web pages regardless of dots in their titles.

---

Outside diff comments:
In `@web/src/components/next-message-item/reference-document-list.tsx`:
- Around line 24-32: Remove the commented-out NewDocumentLink JSX block from the
reference document list, leaving the surrounding component structure unchanged.
🪄 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

Run ID: 81bd8d29-0313-465f-b611-c91491ba4d99

📥 Commits

Reviewing files that changed from the base of the PR and between 347a459 and f9b1b6d.

📒 Files selected for processing (3)
  • web/src/components/next-message-item/reference-document-list.tsx
  • web/src/interfaces/database/dataset.ts
  • web/src/pages/next-search/document-preview-modal/index.tsx

Comment on lines +15 to +22
chunk: {
docnm_kwd?: string;
document_name?: string;
positions?: number[][];
content_with_weight?: string;
content?: string | null;
[key: string]: any;
};

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.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Add document_url explicitly and avoid [key: string]: any index signature.

The catch-all [key: string]: any weakens type safety — any property access compiles without error, masking bugs. Since document_url is accessed at lines 42-43, it should be explicitly declared. Consider defining a dedicated PreviewChunk interface instead of relying on an index signature.

♻️ Proposed type improvement
   chunk: {
     docnm_kwd?: string;
     document_name?: string;
+    document_url?: string;
     positions?: number[][];
     content_with_weight?: string;
     content?: string | null;
-    [key: string]: any;
   };

As per coding guidelines: "Reduce public surface area when a helper can be made private or internal." The index signature expands the accepted type surface unnecessarily.

📝 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
chunk: {
docnm_kwd?: string;
document_name?: string;
positions?: number[][];
content_with_weight?: string;
content?: string | null;
[key: string]: any;
};
chunk: {
docnm_kwd?: string;
document_name?: string;
document_url?: string;
positions?: number[][];
content_with_weight?: string;
content?: string | null;
};
🤖 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-search/document-preview-modal/index.tsx` around lines 15 -
22, Replace the chunk type’s broad [key: string]: any index signature with a
dedicated PreviewChunk interface containing the currently supported fields, and
add document_url explicitly with its appropriate type. Update the
document-preview modal to use PreviewChunk so accesses such as document_url
remain type-safe without accepting arbitrary properties.

Source: Coding guidelines

Comment on lines 38 to 39
// const ref = useRef<(highlight: IHighlight) => void>(() => {});
// const [loaded, setLoaded] = useState(false);

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.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Remove commented-out code.

Per coding guidelines, commented-out code should be removed. These useRef and useState lines are dead code.

♻️ Proposed cleanup
-  // const ref = useRef<(highlight: IHighlight) => void>(() => {});
-  // const [loaded, setLoaded] = useState(false);
  const documentName = chunk.docnm_kwd || chunk.document_name;

As per coding guidelines: "Remove dead tests, commented-out code, stale documentation, and 'move later' notes."

📝 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
// const ref = useRef<(highlight: IHighlight) => void>(() => {});
// const [loaded, setLoaded] = useState(false);
const documentName = chunk.docnm_kwd || chunk.document_name;
🤖 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-search/document-preview-modal/index.tsx` around lines 38 -
39, Remove the commented-out useRef and useState declarations near the document
preview modal implementation, leaving the surrounding active code unchanged.

Source: Coding guidelines

Comment on lines +42 to +43
const isWebPage = !fileType && !!chunk.document_url;
const url = isWebPage ? (chunk.document_url as string) : getDocumentUrl();

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

isWebPage heuristic fails for web page titles containing dots.

getFileExtensionRegex extracts text after the last dot, so a web page title like "Welcome to Example.com" yields fileType = "com", making isWebPage false. This prevents the external link from rendering and falls back to getDocumentUrl(), which won't work for web pages — the exact bug this PR aims to fix.

Consider a more robust check, such as explicitly marking web pages via a doc_type field or checking document_url presence directly rather than inferring from filename extensions.

🐛 Proposed fix: prefer explicit web-page detection
-  const fileType = documentName ? getFileExtensionRegex(documentName) : '';
-  const isWebPage = !fileType && !!chunk.document_url;
-  const url = isWebPage ? (chunk.document_url as string) : getDocumentUrl();
+  const fileType = documentName ? getFileExtensionRegex(documentName) : '';
+  const isWebPage = !!chunk.document_url && !fileType;
+  const url = isWebPage ? (chunk.document_url as string) : getDocumentUrl();

Alternatively, if a doc_type or similar discriminator is available on the chunk, use that instead of the extension heuristic:

-  const isWebPage = !fileType && !!chunk.document_url;
+  const isWebPage = chunk.doc_type_kwd === 'webpage' || (!fileType && !!chunk.document_url);
🤖 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-search/document-preview-modal/index.tsx` around lines 42 -
43, Update the isWebPage calculation in the document preview URL selection to
detect web pages from the chunk’s explicit web-page discriminator, such as
doc_type, or directly from document_url presence, rather than requiring fileType
to be empty. Preserve getDocumentUrl() for non-web documents and use
document_url for web pages regardless of dots in their titles.

@wangq8
wangq8 merged commit 547bc86 into infiniflow:main Jul 13, 2026
4 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:M This PR changes 30-99 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