Repository navigation
Fix: Referenced files not displaying. - #16696
Conversation
…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]>
📝 WalkthroughWalkthroughModifies ChangesReference object construction
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 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
🤖 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
📒 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'], |
There was a problem hiding this comment.
🎯 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.
| 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.
Summary
fix: convert agent-log reference chunks to IReferenceObject for MessgeItem