Improve local file link validation and add inline text file preview/edit UX#53
Conversation
ⓘ You are approaching your monthly quota for Qodo. Upgrade your plan Review Summary by QodoImprove local file link validation and add inline text file preview
WalkthroughsDescription• Add server-backed local path probing to validate file existence before linkifying • Create inline text preview pages for text/code files with syntax highlighting • Expand language support for preview/edit to include Rust, Vue, Lua, Bazel, C/C++ • Preserve readable fallback text for unresolved markdown file references • Align local file browsing behavior between dev and production environments Diagramflowchart LR
A["Chat Message Text"] -->|"Parse file paths"| B["Collect Path Candidates"]
B -->|"Probe server"| C["Local Path Probe Endpoint"]
C -->|"Check existence"| D["File System"]
D -->|"Return results"| E["Update Link State"]
E -->|"Render conditionally"| F["Linkified or Plain Text"]
G["Browse File Link"] -->|"Check file type"| H["Text File?"]
H -->|"Yes"| I["Text Preview Page"]
H -->|"No"| J["Download"]
I -->|"Load Ace Editor"| K["Syntax Highlighted View"]
K -->|"Fallback"| L["Plain Text Rendering"]
I -->|"Actions"| M["Raw / Download / Edit"]
File Changes1. src/api/codexGateway.ts
|
Code Review by Qodo
|
7027fd2 to
eb8bce7
Compare
This PR improves the local file browsing experience in chat messages and the built-in local file browser.
It addresses two core UX issues:
File not foundpagesWith this change:
Problems addressed
False-positive local file links
Previously, the chat renderer would eagerly convert many path-like strings into browse links even when they did not point to a real file on the current machine.
This produced misleading UI for cases such as:
some/file.rs --flagThe result was a poor interaction loop: users clicked what looked like a valid local file link and landed on a
File not foundresponse.This PR changes file-link rendering to depend on server-side path existence checks.
Source files opening as downloads
Valid text/code files were often handled as downloads rather than opening in a useful in-browser view.
That behavior is inconvenient for common workflows like:
This PR adds a proper inline text preview page for text-like files, with actions for
Raw,Download, andEdit.Weak fallback behavior
There were also a couple of failure modes that degraded poorly:
This PR keeps unresolved references readable and adds a plain-text fallback preview.
Dev/prod drift
The Vite dev server and the main HTTP server did not fully match for local browsing behavior, which creates review and maintenance risk.
This PR aligns the relevant local-path probe, raw-file, browse, and edit behaviors in both environments.
Changes
1. Add server-backed local path probing
Introduced a local path probe endpoint and client-side probe flow so the UI can confirm whether candidate file paths actually exist before rendering them as links.
After this change:
2. Preserve readable fallback text for unresolved markdown file references
Adjusted file-segment rendering so unresolved markdown file references do not collapse to incomplete or misleading text.
For unresolved references, the UI now preserves both:
Example:
will remain readable as plain text rather than becoming a broken local file link.
3. Add inline text preview pages for local files
Text-like files now open in an HTML preview page instead of forcing immediate browser download behavior.
The preview page includes:
RawactionDownloadactionEditactionNon-text files continue to use download-oriented behavior.
4. Add plain-text fallback when Ace is unavailable
If Ace fails to load, the preview page still renders the file contents in a plain
<pre>block.This preserves a useful read-only experience even when the CDN is blocked or unavailable.
5. Expand language coverage for preview/edit
Preview and edit pages now support a broader set of text/code file types, including:
Additional JS/TS module variants are also covered:
.mjs.cjs.mts.cts6. Make preview fill remaining viewport height
The preview container no longer stops at a short fixed-height region. It now stretches to fill the remaining viewport height below the toolbar, which makes code browsing significantly more usable.
7. Align Vite dev middleware with main server behavior
Updated Vite dev-server route handling to match the main server for:
POST /codex-api/local-paths/probe/codex-local-file/codex-local-browse/*path/codex-local-edit/*pathThis avoids fixing the feature in production while leaving development behavior inconsistent.
User-visible behavior after this PR
Rawserves plain text directly.Downloadforces file download.Editopens the text editor for supported text-like files.Testing
Verified with:
Manual test coverage was also updated in
tests.mdfor:Why this is useful
This change makes local file references in chat much more trustworthy and much easier to use.
Before this PR:
After this PR: