Skip to content

fix(ui): code file and linked doc resolution in annotate-last mode#647

Merged
backnotprop merged 2 commits intomainfrom
fix/code-file-detection-annotate
May 1, 2026
Merged

fix(ui): code file and linked doc resolution in annotate-last mode#647
backnotprop merged 2 commits intomainfrom
fix/code-file-detection-annotate

Conversation

@backnotprop
Copy link
Copy Markdown
Owner

Summary

  • In annotate-last mode, imageBaseDir is set to "last-message" — a truthy non-path string that gets sent as the base query param to /api/doc, causing a 404
  • Guard both the code file popout and linked doc URL builders to skip non-path imageBaseDir values and fall back to projectRoot

Test plan

  • Open annotate-last view on a message containing code file paths (e.g. apps/pi-extension/plannotator-events.ts)
  • Click a code file path — should open the code file popout without 404
  • Click a linked markdown doc — should navigate without 404
  • Verify plan mode still works (imageBaseDir is undefined, falls through to projectRoot)
  • Verify annotate mode with a real file still resolves relative paths correctly

In annotate-last mode, imageBaseDir is set to "last-message" (a
non-path string), which gets sent as the base query param to /api/doc
and causes a 404. Guard both the code file popout and linked doc
URL builders to skip non-path imageBaseDir values and fall back to
projectRoot instead.
Sending base=projectRoot bypasses the isWithinProjectRoot check in
/api/doc for code files (line 80) and skips containment entirely for
markdown (lines 40-57). Fall back to undefined instead, which omits
the base param and lets the server resolve paths against its own cwd
with sandbox checks intact — matching plan mode behavior.
@backnotprop backnotprop merged commit 4b8ffcf into main May 1, 2026
7 checks passed
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