Skip to content

Fix: Referenced files not displaying. - #16696

Merged
wangq8 merged 2 commits into
infiniflow:mainfrom
dcc123456:fix/agent-log-0707
Jul 7, 2026
Merged

wangq8 merged 2 commits into
infiniflow:mainfrom
dcc123456:fix/agent-log-0707

Conversation

@dcc123456

Copy link
Copy Markdown
Collaborator

Summary

fix: convert agent-log reference chunks to IReferenceObject for MessgeItem

…geItem

The agent log detail modal passed the raw reference prop straight to
MessageItem, but the runtime per-message reference is a flat chunks
array (carrying citation_id) that does not match the IReferenceObject
shape MessageItem/MarkdownContent expect. Citations, reference images
and the document list therefore failed to render.

Add a buildReferenceObject utility that maps the chunks array into
{ chunks: Record<citation_id, IReferenceChunk>, doc_aggs: Record<doc_id, Docagg> }
so citation markers resolve correctly and document aggregates are
derived by grouping chunks per document.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jul 7, 2026
@dcc123456
dcc123456 requested a review from wangq8 July 7, 2026 07:52
@dcc123456 dcc123456 added 🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration labels Jul 7, 2026
@dcc123456
dcc123456 marked this pull request as draft July 7, 2026 07:52
@dcc123456
dcc123456 marked this pull request as ready for review July 7, 2026 07:52
@coderabbitai

coderabbitai Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Modifies AgentLogDetailModal to derive per-message reference data instead of using a modal-level reference prop. Adds internal types and a buildReferenceObject helper that converts message reference chunks into an IReferenceObject with chunks and doc_aggs, then wires this into MessageItem's reference prop.

Changes

Reference object construction

Layer / File(s) Summary
Reference chunk types and builder
web/src/pages/agents/agent-log-detail-modal.tsx
Imports Docagg and IReferenceChunk, defines IAgentLogReferenceChunk and an extended message type, and implements buildReferenceObject to convert chunk arrays into chunks and doc_aggs with defaulted numeric fields.
Wire per-message reference into MessageItem
web/src/pages/agents/agent-log-detail-modal.tsx
Casts each iterated message to the runtime type and passes buildReferenceObject(msg.reference) to MessageItem's reference prop, removing the reference prop from the modal's destructuring.

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

Possibly related PRs

  • infiniflow/ragflow#16571: Both PRs modify how MessageItem receives/constructs its reference data from agent-log message content.

Suggested reviewers: wangq8

Poem

A rabbit hopped through chunks of text,
Building doc_aggs, doing its best,
No more props from far away,
Each message's own reference holds sway,
Hop, hop, hooray! 🐰📄

🚥 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 is concise and accurately reflects the main fix: referenced files not displaying.
Description check ✅ Passed The description matches the required Summary section and states the fix, though it is brief.

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

🤖 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/agents/agent-log-detail-modal.tsx`:
- Line 69: Normalize the chunk positions before assigning them in
agent-log-detail-modal so IReferenceChunk.positions always receives a flat
number[] rather than the nested number[][] allowed by IAgentLogReferenceChunk.
Update the mapping logic in the chunk-to-reference conversion (where positions
is set) to transform or select a single flat position array instead of casting
chunk.positions ?? [] directly, so downstream citation/rendering code gets the
expected shape.
🪄 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: 961b6a35-3b68-4dc6-a1fe-e2d85b1187c9

📥 Commits

Reviewing files that changed from the base of the PR and between 9eba452 and 8bfde7c.

📒 Files selected for processing (1)
  • web/src/pages/agents/agent-log-detail-modal.tsx

similarity: chunk.similarity ?? 0,
vector_similarity: chunk.vector_similarity ?? 0,
term_similarity: chunk.term_similarity ?? 0,
positions: (chunk.positions ?? []) as IReferenceChunk['positions'],

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

Normalize nested positions before assigning to IReferenceChunk.

IAgentLogReferenceChunk allows number[][], but IReferenceChunk.positions is number[]; this cast can pass nested arrays to downstream citation/reference consumers and break position-based rendering.

Proposed fix
-      positions: (chunk.positions ?? []) as IReferenceChunk['positions'],
+      positions: Array.isArray(chunk.positions?.[0])
+        ? (chunk.positions as number[][]).flat()
+        : ((chunk.positions ?? []) as number[]),
📝 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
positions: (chunk.positions ?? []) as IReferenceChunk['positions'],
positions: Array.isArray(chunk.positions?.[0])
? (chunk.positions as number[][]).flat()
: ((chunk.positions ?? []) as number[]),
🤖 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/agents/agent-log-detail-modal.tsx` at line 69, Normalize the
chunk positions before assigning them in agent-log-detail-modal so
IReferenceChunk.positions always receives a flat number[] rather than the nested
number[][] allowed by IAgentLogReferenceChunk. Update the mapping logic in the
chunk-to-reference conversion (where positions is set) to transform or select a
single flat position array instead of casting chunk.positions ?? [] directly, so
downstream citation/rendering code gets the expected shape.

@wangq8
wangq8 merged commit b7945f3 into infiniflow:main Jul 7, 2026
3 of 6 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants