Skip to content

feat(ui): parse file-path candidates with line and column suffixes - #11217

Closed
sylwester-liljegren wants to merge 1 commit into
Kilo-Org:mainfrom
sylwester-liljegren:feat/file-links-1-path-parsing
Closed

feat(ui): parse file-path candidates with line and column suffixes#11217
sylwester-liljegren wants to merge 1 commit into
Kilo-Org:mainfrom
sylwester-liljegren:feat/file-links-1-path-parsing

Conversation

@sylwester-liljegren

@sylwester-liljegren sylwester-liljegren commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Issue

Re-split of #10340 per maintainer feedback (no separate tracking issue exists). Part 1 of 3.

Stack (review/merge in order): #11217 (this PR) → #11218#11219

Context

First slice of the clickable-file-links work from #10340, rebased onto current main and split into smaller reviewable pieces as requested. This PR only changes the path-parsing layer: turning inline code / link hrefs into structured { path, line, column } candidates that a later slice validates against the filesystem.

Implementation

  • Replaces the regex parseFilePath (a "does this look like a file?" matcher) with two small helpers: extractSuffix (strips :line / :line:col / :start-end suffixes) and normalizeCandidatePath (adds a ./ prefix to bare relative paths, strips a/+b/ diff prefixes, leaves absolute/Windows/UNC paths alone).
  • extractFilePathFromHref now returns { path, line, column } instead of a bare string, and preserves file:// decoding and Windows-drive handling.
  • Both copies are updated: packages/ui/src/file-path.ts (shared opencode path, keeps its kilocode_change marker) and packages/kilo-ui/src/file-path.ts (Kilo-only).
  • Detection intentionally shifts to "extract a candidate, let the filesystem confirm it" — confirmation lands in the dependent slices.

Screenshots / Video

N/A — no user-visible change in this slice.

How to Test

Manual/local verification

  • N/A (pure parsing module; covered by unit tests below).

Reviewer test steps

  1. From packages/ui/: bun test src/file-path.test.ts
  2. Confirm 48 tests pass across extractSuffix, normalizeCandidatePath, and extractFilePathFromHref.

Blocked checks and substitute verification

  • A standalone typecheck of just this slice fails on purpose: its consumers (marked.tsx, message-part.tsx) are updated in the dependent UI PR (feat(ui): parse and render clickable file links #11219). The full stack typechecks/tests/builds green. Substitute verification: ran this module's unit tests directly — agent-executed, 48 pass.

Checklist

  • Issue linked above, or exception explained
  • Tests/verification described
  • Screenshots/video included for visual changes, or marked N/A
  • Changeset considered for user-facing changes (the changeset lives in feat(ui): parse and render clickable file links #11219, which carries the user-facing behavior)
  • I personally reviewed the diff and can explain the changes, including any AI-assisted work.

Replace the regex-based parseFilePath with extractSuffix and
normalizeCandidatePath helpers, and make extractFilePathFromHref return
structured { path, line, column } data instead of a bare string.

This shifts inline-code detection from "does this string look like a
file?" to "extract a candidate path so the filesystem can confirm it
later", which also handles :line / :line:col and :start-end line ranges,
a/ and b/ diff prefixes, and Windows drive paths. Unit tests are
rewritten to cover the new helpers and the structured href result.
@sylwester-liljegren

Copy link
Copy Markdown
Contributor Author

Closing in favor of a buildable 2-PR stack. The path-parsing change can't be its own PR: removing/altering the file-path API breaks its only consumers (marked.tsx, message-part.tsx) until the UI commit lands, so this PR's CI failed typecheck (marked.tsx importing the removed parseFilePath). Path-parsing is now combined with the UI in #11219, stacked on the independent filesystem-validation PR #11218. Both of those are green.

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