Skip to content

Resolve ambiguous CLI-agent file links via repo index + Files palette#2

Merged
jpitchell merged 2 commits into
masterfrom
cli-agent-ambiguous-file-links
Jun 1, 2026
Merged

Resolve ambiguous CLI-agent file links via repo index + Files palette#2
jpitchell merged 2 commits into
masterfrom
cli-agent-ambiguous-file-links

Conversation

@jpitchell

Copy link
Copy Markdown
Owner

Summary

Resolve ambiguous CLI-agent file links via the repo index + Files palette.

When a CLI agent (Claude Code, Codex, etc.) prints a bare filename or shorthand path that doesn't resolve relative to its working directory, fall back to the repo file index instead of producing no link:

  • 0 matches → no link
  • 1 match → linkify; click opens it directly
  • 2+ matches → linkify ("Open file…"); click opens the command-palette Files mode pre-filled so the user disambiguates

Matching is exact-basename + ordered directory-component subsequence, so warp_features/lib.rs resolves to crates/warp_features/src/lib.rs (tolerating omitted intermediates like crates/ and src/). The repo index is snapshotted on the main thread (the background scan thread has no AppContext) and indexed by basename per scan for O(1) candidate lookup, keeping hover detection fast even with hundreds of candidates.

Changes

  • Add a GridHighlightedLink::AmbiguousFile variant and thread an optional pre-fill query through the OpenFilesPalette event
  • Gated by the existing CliAgentFileLinks flag + general.cli_agent_file_links setting — no new flag

Stacking

⚠️ Stacked on top of #1. Base branch is cli-agent-file-links, so this PR shows only its own diff. Merge #1 first (or retarget this to master once #1 lands).

When a CLI agent (Claude Code, Codex, etc.) prints a bare filename or
shorthand path that doesn't resolve relative to its working directory,
fall back to the repo file index instead of producing no link:

- 0 matches  -> no link
- 1 match    -> linkify; click opens it directly
- 2+ matches -> linkify ("Open file…"); click opens the command-palette
                Files mode pre-filled so the user disambiguates

Matching is exact-basename + ordered directory-component subsequence, so
`warp_features/lib.rs` resolves to `crates/warp_features/src/lib.rs`
(tolerating omitted intermediates like `crates/` and `src/`). The repo
index is snapshotted on the main thread (the background scan thread has
no AppContext) and indexed by basename per scan for O(1) candidate
lookup, keeping hover detection fast even with hundreds of candidates.

Gated by the existing CliAgentFileLinks flag + general.cli_agent_file_links
setting; no new flag. Adds a GridHighlightedLink::AmbiguousFile variant
and threads an optional pre-fill query through the OpenFilesPalette event.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jpitchell jpitchell deleted the branch master June 1, 2026 22:30
@jpitchell jpitchell closed this Jun 1, 2026
@jpitchell jpitchell reopened this Jun 1, 2026
@jpitchell jpitchell changed the base branch from cli-agent-file-links to master June 1, 2026 22:33
@jpitchell jpitchell merged commit 9812765 into master Jun 1, 2026
@jpitchell jpitchell deleted the cli-agent-ambiguous-file-links branch June 1, 2026 23:59
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.

1 participant