diff --git a/package.json b/package.json index 4f68fb3..97f64e5 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "type": "module", "scripts": { "check": "tsgo --noEmit", - "prepare": "husky" + "prepare": "husky || true" }, "pi": { "extensions": [ diff --git a/src/index.ts b/src/index.ts index e441bd6..c017f3a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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, ]; }, @@ -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((resolve, reject) => { let settled = false; @@ -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"); diff --git a/src/prompt.ts b/src/prompt.ts index ec1ee99..69d7e8d 100644 --- a/src/prompt.ts +++ b/src/prompt.ts @@ -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("");