Skip to content

[AGE-4116] fix(frontend): stop bare filename mentions in chat from linking to the wrong file - #6008

Merged
mmabrouk merged 2 commits into
release/v0.112.1from
fix/age-4116-chat-file-link-wrong-file
Aug 13, 2026
Merged

[AGE-4116] fix(frontend): stop bare filename mentions in chat from linking to the wrong file#6008
mmabrouk merged 2 commits into
release/v0.112.1from
fix/age-4116-chat-file-link-wrong-file

Conversation

@bekossy

@bekossy bekossy commented Aug 13, 2026

Copy link
Copy Markdown
Member

Summary

A chat mention like `README.md` was treated as a known, linkable file whenever ANY file with that basename existed anywhere in the session, even if the real file lived in a subfolder (e.g. notes/README.md). Clicking the mention opened the wrong path and showed "Couldn't load this file's content" (#6004).

The root cause is in knownFromRecords (chatFileRefs.tsx): it tail-matched the raw mention text against every file the agent had written, so a bare basename always matched the first written file sharing that name, regardless of where it actually lived. The fix stops bare (no /) mentions from taking that unverified shortcut. They now always go through the existing on-demand path, which reads the real file at that exact location and only renders a link when it actually resolves.

Testing

Verified locally

  • Reproduced on localhost:3000: created notes/README.md, got the agent to reference it by bare filename, confirmed the mention now renders as plain text instead of a broken link.
  • Confirmed a file created directly at the mount root still links and opens correctly (no regression).

Added or updated tests

  • chatFileRefs.test.ts: unit tests on knownFromRecords covering the false-positive case (nested file, bare mention), a still-working qualified mention, a mount-root file correctly deferring to on-demand verification, and an unmatched mention.

QA follow-up

  • Markdown-link-style mentions share the same resolver but weren't separately spot-checked.

Demo

Screenshot 2026-08-13 at 1 18 39 PM

Checklist

  • I have included a video or screen recording for UI changes, or marked Demo as N/A
  • Relevant tests pass locally
  • Relevant linting and formatting pass locally
  • I have signed the CLA, or I will sign it when the bot prompts me

@linear-code

linear-code Bot commented Aug 13, 2026

Copy link
Copy Markdown

AGE-4116

@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Aug 13, 2026
@vercel

vercel Bot commented Aug 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agenta-documentation Blocked Blocked Aug 13, 2026 11:06am

Request Review

@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: f14ec479-438b-454e-b4cc-5761fa574057

📥 Commits

Reviewing files that changed from the base of the PR and between 728f39f and d678972.

📒 Files selected for processing (2)
  • web/oss/src/components/Drives/chatFileRefs.test.ts
  • web/oss/src/components/Drives/chatFileRefs.tsx

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Improved file-reference detection so bare filenames are verified before being recognized.
    • Prevented unverified mount-root filenames and unwritten file mentions from being treated as known references.
  • Tests

    • Added coverage for qualified paths, basename verification, mount-root names, and unwritten mentions.

Walkthrough

The change exports knownFromRecords and rejects bare basenames before recorded-path checks. Tests cover qualified paths, mount-root names, deferred basenames, and unknown references.

Changes

File Reference Verification

Layer / File(s) Summary
Recorded path verification
web/oss/src/components/Drives/chatFileRefs.tsx, web/oss/src/components/Drives/chatFileRefs.test.ts
knownFromRecords is now exported and returns false for candidates without a slash. Tests cover qualified matches, mount-root names, deferred basenames, and unwritten mentions.

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

Mergeability Score: ⚪ Minimal · up to d6789

The change makes bare filename mentions verify the exact path before linking and includes coverage for nested, root-level, and unmatched files; no actionable merge-blocking risk remains beyond normal checks.

Possibly related PRs

🚥 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.
Description check ✅ Passed The description clearly explains the bare filename linking bug, the fix, and the related tests.
Title check ✅ Passed The title clearly and concisely identifies the frontend fix for incorrect bare filename links in chat.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/age-4116-chat-file-link-wrong-file

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d678972dd9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread web/oss/src/components/Drives/chatFileRefs.test.ts
@bekossy
bekossy requested review from ardaerzin and mmabrouk August 13, 2026 11:17
@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Railway Preview Environment

Status Destroyed (PR closed)

Updated at 2026-08-13T11:38:52.769Z

@mmabrouk
mmabrouk changed the base branch from main to release/v0.112.1 August 13, 2026 11:38
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Aug 13, 2026
@mmabrouk
mmabrouk merged commit a5d3ef9 into release/v0.112.1 Aug 13, 2026
67 of 69 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug frontend lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants