Skip to content

Resolve shortened transcript file paths - #177

Open
yankawai wants to merge 1 commit into
hardbeat920:mainfrom
yankawai:fix/transcript-file-path-resolution
Open

yankawai wants to merge 1 commit into
hardbeat920:mainfrom
yankawai:fix/transcript-file-path-resolution

Conversation

@yankawai

@yankawai yankawai commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Pull request

Title: Resolve shortened transcript file paths

What changed

Shortened file links in a transcript now carry exact paths previously surfaced by structured tool events into the file resolver. Indexed files in the current project still take precedence, and ambiguous transcript matches are left unresolved instead of guessing.

Why

When a session starts in one directory but an agent edits a file in another project, a later backup.yaml chip was resolved as <session cwd>/backup.yaml. The editor then showed an ENOENT error even though the transcript already contained the exact tool path.

With this change, a unique exact tool path is used as the fallback. Direct file links, navigation locations, project-index matches, and tool-preview clicks keep their existing behavior.

UI

No layout change.

Before: a shortened chip could open a nonexistent path under the session cwd.

After: the chip opens the unique matching path already recorded by the transcript.

Checklist

  • I ran npm run check (1,781 web tests and 236 Rust tests)
  • This PR is small and focused
  • I did not mix unrelated changes

Summary by CodeRabbit

  • New Features

    • Improved file links in transcripts to open the correct workspace file, including files referenced by external tools.
    • Added smarter handling for shortened or ambiguous file paths, with safe fallback behavior.
    • File references are now matched using available transcript context.
  • Bug Fixes

    • Indexed project files now take precedence over less-specific transcript paths.
  • Tests

    • Added coverage for unique, ambiguous, and transcript-based file references.

@coderabbitai

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 4573b97a-b027-46f1-8ece-f024b740b791

📥 Commits

Reviewing files that changed from the base of the PR and between 4dec426 and e9f300c.

📒 Files selected for processing (9)
  • src/App.tsx
  • src/lib/fileIndex.test.ts
  • src/lib/fileIndex.ts
  • src/lib/search.ts
  • src/surfaces/AgentTranscript.tsx
  • src/surfaces/AgentTranscriptFileLinks.test.ts
  • src/surfaces/SessionPane.tsx
  • src/surfaces/transcriptActivity.test.ts
  • src/surfaces/transcriptActivity.ts

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The change adds candidate path hints to file opening. Transcript tool paths are collected and forwarded to workspace-aware resolution, which uses unambiguous referenced paths when indexed project lookup cannot resolve a short link.

Changes

Transcript File Resolution

Layer / File(s) Summary
Shared opening contract
src/lib/search.ts, src/surfaces/transcriptActivity.ts, src/surfaces/transcriptActivity.test.ts
OpenFileFn accepts optional candidate paths. transcriptFilePaths collects unique tool preview paths and has test coverage.
Transcript link candidate forwarding
src/surfaces/AgentTranscript.tsx, src/surfaces/AgentTranscriptFileLinks.test.ts
AgentTranscript matches transcript paths after workspace resolution and forwards unmatched paths as candidate metadata. The component test verifies the forwarded arguments.
Referenced path resolution
src/lib/fileIndex.ts, src/lib/fileIndex.test.ts
resolveOpenablePath uses candidate paths for exact, suffix, or base-name matching when indexed project lookup does not resolve the path. Tests cover unique, ambiguous, and indexed paths.
Application opener integration
src/App.tsx, src/surfaces/SessionPane.tsx
The application passes candidate hints to resolveOpenablePath. SessionPane and AgentTranscript use the shared OpenFileFn type.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant AgentTranscript
  participant App
  participant resolveOpenablePath
  AgentTranscript->>App: Pass requested path and candidatePaths
  App->>resolveOpenablePath: Resolve path against cwd and candidates
  resolveOpenablePath-->>App: Return referenced or fallback path
Loading

Suggested reviewers: hardbeat920

Merge Risk: ⚪ Minimal · up to e9f30

The transcript file-link resolution update preserves existing indexed-file behavior and avoids guessing among ambiguous transcript paths. No actionable merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 9 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: resolving shortened transcript file paths.
Description check ✅ Passed The description includes all required sections, explains the change and reason, documents the UI impact, and completes the checklist. It is focused and consistent with the pull request objectives.
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@hardbeat920

Copy link
Copy Markdown
Owner

Thanks @yankawai the intent makes sense but I noticed two issues before merging:

  1. filePaths is recreated whenever blocks changes, which recreates handleOpenFile. Since sameActivity compares
    onOpenFile by identity, every visible historical activity group will rerender during streaming. Could this use a ref or another stable-callback approach so the existing long-transcript optimization remains effective?

  2. transcriptFilePaths only collects preview.path. Codex multi-file edit events provide all affected files in event.paths, but those paths are not retained when the event becomes a transcript block. Consequently, shortened links for every file except the first one can still resolve incorrectly. Could we preserve all structured paths and add a multi-file test?

One smaller follow-up, right-click actions such as “Open in Default App” and “Reveal” bypass
onOpenFile, so they still use the unresolved session-relative path.

The overall approach looks good once these cases are addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants