Skip to content
Open
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "module",
"scripts": {
"check": "tsgo --noEmit",
"prepare": "husky"
"prepare": "husky || true"
},
"pi": {
"extensions": [
Expand Down
15 changes: 9 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default function (pi: ExtensionAPI) {
];
return [
borderTop,
...lines.map((line) => `${theme.fg("border", "│")}${truncateToWidth(line, innerWidth, "...", true).padEnd(innerWidth, " ")}${theme.fg("border", "│")}`),
...lines.map((line) => `${theme.fg("border", "│")}${truncateToWidth(line, innerWidth, "...", true)}${theme.fg("border", "│")}`),
borderBottom,
];
},
Expand Down Expand Up @@ -111,10 +111,10 @@ export default function (pi: ExtensionAPI) {
});
activeWindow = window;

const waitingUI = showWaitingUI(ctx);

ctx.ui.notify("Opened native diff review window.", "info");

const waitingUI = showWaitingUI(ctx);

try {
const windowMessagePromise = new Promise<ReviewWindowMessage | null>((resolve, reject) => {
let settled = false;
Expand Down Expand Up @@ -184,10 +184,13 @@ export default function (pi: ExtensionAPI) {
}

const prompt = composeReviewPrompt(files, message);
ctx.ui.setEditorText(prompt);
ctx.ui.notify("Inserted diff review feedback into the editor.", "info");
if (prompt.length > 0) {
ctx.ui.setEditorText(prompt);
ctx.ui.notify("Inserted diff review feedback into the editor.", "info");
}
} catch (error) {
activeWaitingUIDismiss?.();
waitingUI.dismiss();
await waitingUI.promise;
closeActiveWindow();
const message = error instanceof Error ? error.message : String(error);
ctx.ui.notify(`Diff review failed: ${message}`, "error");
Expand Down
9 changes: 6 additions & 3 deletions src/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ export function composeReviewPrompt(files: DiffReviewFile[], payload: ReviewSubm
const fileMap = new Map(files.map((file) => [file.id, file]));
const lines: string[] = [];

lines.push("Please address the following feedback");
lines.push("");

const overallComment = payload.overallComment.trim();
const hasFeedback = overallComment.length > 0 || payload.comments.length > 0;
if (hasFeedback) {
lines.push("Address the following code review feedback:");
lines.push("");
}

if (overallComment.length > 0) {
lines.push(overallComment);
lines.push("");
Expand Down