Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion apps/hook/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,14 @@ if (isInteractiveNoArgInvocation(args, process.stdin.isTTY)) {
// Ensure session cleanup on exit
process.on("exit", () => unregisterSession());

// Route fatal signals through process.exit() so "exit" handlers run — by
// default a SIGINT/SIGTERM death skips them, leaking background-warmup
// children and stale `git worktree` registrations (the --local PR checkout
// cleanup below is registered on "exit"). `once` keeps a second Ctrl-C as a
// force-quit escape hatch if cleanup ever hangs.
process.once("SIGINT", () => process.exit(130));
process.once("SIGTERM", () => process.exit(143));

// Check if URL sharing is enabled (default: true)
const sharingEnabled = process.env.PLANNOTATOR_SHARE !== "disabled";

Expand Down Expand Up @@ -842,7 +850,11 @@ if (args[0] === "sessions") {
console.log(getReviewApprovedPrompt(detectedOrigin));
} else {
console.log(result.feedback);
if (!isPRMode) {
// Append the triage-first suffix whenever the reviewer sent annotations to
// act on — in PR mode too. Platform PR actions (approve/comment posted to
// the host) come back with an empty annotation set and a status message;
// those must NOT get the "triage and don't change code" instruction.
if (result.annotations.length > 0) {
console.log(getReviewDeniedSuffix(detectedOrigin));
}
}
Expand Down
9 changes: 6 additions & 3 deletions apps/opencode-plugin/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,14 @@ export async function handleReviewCommand(
const shouldSwitchAgent = result.agentSwitch && result.agentSwitch !== "disabled";
const targetAgent = result.agentSwitch || "build";

// Append the triage-first suffix when the reviewer sent annotations to
// act on (PR mode included). Platform PR actions post a status message
// with no annotations — those go through verbatim, no suffix.
const message = result.approved
? getReviewApprovedPrompt("opencode")
: isPRMode
? result.feedback
: `${result.feedback}${getReviewDeniedSuffix("opencode")}`;
: result.annotations.length > 0
? `${result.feedback}${getReviewDeniedSuffix("opencode")}`
: result.feedback;

try {
await client.session.prompt({
Expand Down
23 changes: 9 additions & 14 deletions apps/pi-extension/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,6 @@ export default function plannotator(pi: ExtensionAPI): void {

try {
const reviewArgs = parseReviewArgs(args ?? "");
const isPRReview = reviewArgs.prUrl !== undefined;
const session = await startCodeReviewBrowserSession(ctx, {
prUrl: reviewArgs.prUrl,
vcsType: reviewArgs.vcsType,
Expand Down Expand Up @@ -437,21 +436,17 @@ export default function plannotator(pi: ExtensionAPI): void {
safeNotify(ctx, "Code review closed (no feedback).", "info", origin);
return;
}
if (isPRReview) {
// Platform PR actions (approve/comment) return approved:false with a
// status message — don't tell the agent to "address" a platform action.
sendUserMessageWithCurrentSessionFallback(
pi,
result.feedback,
{ deliverAs: "followUp" },
"Plannotator code review feedback could not be sent",
origin,
);
return;
}
// Append the triage-first suffix when the reviewer sent
// annotations to act on (PR mode included). Platform PR actions
// (approve/comment posted to the host) come back with an empty
// annotation set and a status message — don't tell the agent to
// "address" a platform action.
const reviewFeedback = (result.annotations?.length ?? 0) > 0
? `${result.feedback}${getReviewDeniedSuffix("pi", loadConfig())}`
: result.feedback;
sendUserMessageWithCurrentSessionFallback(
pi,
`${result.feedback}${getReviewDeniedSuffix("pi", loadConfig())}`,
reviewFeedback,
{ deliverAs: "followUp" },
"Plannotator code review feedback could not be sent",
origin,
Expand Down
Loading