Skip to content

Unify review core across Bun and Pi#310

Merged
backnotprop merged 4 commits intomainfrom
fix/pi-cr-untracked
Mar 16, 2026
Merged

Unify review core across Bun and Pi#310
backnotprop merged 4 commits intomainfrom
fix/pi-cr-untracked

Conversation

@backnotprop
Copy link
Owner

Summary

  • extract a runtime-agnostic review core for diff assembly, file-content lookup, worktree handling, and stage/unstage operations
  • switch the Bun review path to the shared core and copy the same source into the Pi package at build time
  • bring the Pi review server up to the shared review API surface, including diff switching, file content, drafts, uploads/images, agents, and editor annotations
  • add regression coverage for the shared review core and the Pi review server endpoints

Fixes #307.

Testing

  • bun test packages/shared/review-core.test.ts apps/pi-extension/server.test.ts
  • bun test

Notes

  • The full test run still has one unrelated pre-existing failure in packages/ui/components/diagramLanguages.test.ts because @viz-js/viz is not installed in this environment.

@backnotprop
Copy link
Owner Author

Code review

Found 1 issue:

  1. Pi plannotator-review handler silently drops inline annotations. The review server's waitForDecision() returns { approved, feedback, annotations, agentSwitch } (line 693-699 of server.ts), but the command handler in index.ts only reads result.feedback and ignores result.annotations. Since this PR adds the full annotation API surface to the Pi review server, users can now create inline code annotations in the review UI that are accepted by the server but never forwarded to the agent — the annotations are silently lost.

const result = await runBrowserReview(server, ctx);
if (result.feedback) {
if (result.approved) {
pi.sendUserMessage(`# Code Review\n\nCode review completed — no changes requested.`);
} else {
pi.sendUserMessage(`# Code Review Feedback\n\n${result.feedback}\n\nPlease address this feedback.`);
}
} else {
ctx.ui.notify("Code review closed (no feedback).", "info");
}
},

The Bun hook server avoids this because it bakes annotations into the feedback string via exportAnnotations() before submission. The Pi handler needs equivalent logic — either call exportAnnotations() to merge annotations into the feedback text, or handle result.annotations separately.

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

backnotprop and others added 3 commits March 16, 2026 07:52
- Handle unborn HEAD in runGitDiff("uncommitted") via rev-parse check
  instead of assertGitSuccess, so fresh repos fall through to untracked diffs
- Bind Pi server to 0.0.0.0 for remote sessions (regression from e47eda0)
- Update CLAUDE.md: packages/shared/ description, PLANNOTATOR_SHARE env var,
  /api/diff response shape

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@backnotprop backnotprop force-pushed the fix/pi-cr-untracked branch from 7b4f492 to be872b4 Compare March 16, 2026 14:53
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@backnotprop backnotprop merged commit ea689d9 into main Mar 16, 2026
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.

Bug: still missing untracked files in pi-extension

1 participant