Skip to content

Commit 48f325a

Browse files
authored
fix(pi-extension): wire PLANNOTATOR_PASTE_URL through all servers (#356)
The pi extension reads PLANNOTATOR_SHARE_URL but never reads or passes PLANNOTATOR_PASTE_URL to the browser UI. This means self-hosted paste service configurations are ignored and the browser always falls back to the hardcoded default (plannotator-paste.plannotator.workers.dev). This patch wires PLANNOTATOR_PASTE_URL through all three server types in the pi extension: - startPlanReviewServer: adds sharingEnabled, shareBaseUrl, pasteApiUrl to options and includes them in the /api/plan response - startReviewServer: adds pasteApiUrl to options and includes it in the /api/diff response - startAnnotateServer: adds sharingEnabled, shareBaseUrl, pasteApiUrl to options and includes them in the /api/plan response Also passes the mode option through startAnnotateServer so the annotate-last mode is correctly forwarded to the browser UI.
1 parent 29f09d3 commit 48f325a

2 files changed

Lines changed: 40 additions & 2 deletions

File tree

apps/pi-extension/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ export default function plannotator(pi: ExtensionAPI): void {
291291
htmlContent: reviewHtmlContent,
292292
sharingEnabled: process.env.PLANNOTATOR_SHARE !== "disabled",
293293
shareBaseUrl: process.env.PLANNOTATOR_SHARE_URL || undefined,
294+
pasteApiUrl: process.env.PLANNOTATOR_PASTE_URL || undefined,
294295
});
295296
} catch (err) {
296297
ctx.ui.notify(`Failed to start code review UI: ${getStartupErrorMessage(err)}`, "error");
@@ -340,6 +341,9 @@ export default function plannotator(pi: ExtensionAPI): void {
340341
filePath: absolutePath,
341342
origin: "pi",
342343
htmlContent: planHtmlContent,
344+
sharingEnabled: process.env.PLANNOTATOR_SHARE !== "disabled",
345+
shareBaseUrl: process.env.PLANNOTATOR_SHARE_URL || undefined,
346+
pasteApiUrl: process.env.PLANNOTATOR_PASTE_URL || undefined,
343347
});
344348
} catch (err) {
345349
ctx.ui.notify(`Failed to start annotation UI: ${getStartupErrorMessage(err)}`, "error");
@@ -394,6 +398,9 @@ export default function plannotator(pi: ExtensionAPI): void {
394398
origin: "pi",
395399
mode: "annotate-last",
396400
htmlContent: planHtmlContent,
401+
sharingEnabled: process.env.PLANNOTATOR_SHARE !== "disabled",
402+
shareBaseUrl: process.env.PLANNOTATOR_SHARE_URL || undefined,
403+
pasteApiUrl: process.env.PLANNOTATOR_PASTE_URL || undefined,
397404
});
398405
} catch (err) {
399406
ctx.ui.notify(`Failed to start annotation UI: ${getStartupErrorMessage(err)}`, "error");
@@ -497,6 +504,9 @@ export default function plannotator(pi: ExtensionAPI): void {
497504
plan: planContent,
498505
htmlContent: planHtmlContent,
499506
origin: "pi",
507+
sharingEnabled: process.env.PLANNOTATOR_SHARE !== "disabled",
508+
shareBaseUrl: process.env.PLANNOTATOR_SHARE_URL || undefined,
509+
pasteApiUrl: process.env.PLANNOTATOR_PASTE_URL || undefined,
500510
});
501511
} catch (err) {
502512
const message = `Failed to start plan review UI: ${getStartupErrorMessage(err)}`;

apps/pi-extension/server.ts

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,17 @@ export async function startPlanReviewServer(options: {
614614
plan: string;
615615
htmlContent: string;
616616
origin?: string;
617+
sharingEnabled?: boolean;
618+
shareBaseUrl?: string;
619+
pasteApiUrl?: string;
617620
}): Promise<PlanServerResult> {
621+
const sharingEnabled =
622+
options.sharingEnabled ?? process.env.PLANNOTATOR_SHARE !== "disabled";
623+
const shareBaseUrl =
624+
(options.shareBaseUrl ?? process.env.PLANNOTATOR_SHARE_URL) || undefined;
625+
const pasteApiUrl =
626+
(options.pasteApiUrl ?? process.env.PLANNOTATOR_PASTE_URL) || undefined;
627+
618628
// Version history
619629
const slug = generateSlug(options.plan);
620630
const project = detectProjectName();
@@ -659,7 +669,7 @@ export async function startPlanReviewServer(options: {
659669
} else if (url.pathname === "/api/plan/history") {
660670
json(res, { project, plans: listProjectPlans(project) });
661671
} else if (url.pathname === "/api/plan") {
662-
json(res, { plan: options.plan, origin: options.origin ?? "pi", previousPlan, versionInfo });
672+
json(res, { plan: options.plan, origin: options.origin ?? "pi", previousPlan, versionInfo, sharingEnabled, shareBaseUrl, pasteApiUrl });
663673
} else if (url.pathname === "/api/approve" && req.method === "POST") {
664674
const body = await parseBody(req);
665675
resolveDecision({ approved: true, feedback: body.feedback as string | undefined });
@@ -751,6 +761,7 @@ export async function startReviewServer(options: {
751761
error?: string;
752762
sharingEnabled?: boolean;
753763
shareBaseUrl?: string;
764+
pasteApiUrl?: string;
754765
}): Promise<ReviewServerResult> {
755766
const draftKey = contentHash(options.rawPatch);
756767
const repoInfo = getRepoInfo();
@@ -763,6 +774,8 @@ export async function startReviewServer(options: {
763774
options.sharingEnabled ?? process.env.PLANNOTATOR_SHARE !== "disabled";
764775
const shareBaseUrl =
765776
(options.shareBaseUrl ?? process.env.PLANNOTATOR_SHARE_URL) || undefined;
777+
const pasteApiUrl =
778+
(options.pasteApiUrl ?? process.env.PLANNOTATOR_PASTE_URL) || undefined;
766779

767780
let resolveDecision!: (result: {
768781
approved: boolean;
@@ -791,6 +804,7 @@ export async function startReviewServer(options: {
791804
gitContext: options.gitContext,
792805
sharingEnabled,
793806
shareBaseUrl,
807+
pasteApiUrl,
794808
repoInfo,
795809
...(currentError ? { error: currentError } : {}),
796810
});
@@ -991,7 +1005,18 @@ export async function startAnnotateServer(options: {
9911005
filePath: string;
9921006
htmlContent: string;
9931007
origin?: string;
1008+
mode?: string;
1009+
sharingEnabled?: boolean;
1010+
shareBaseUrl?: string;
1011+
pasteApiUrl?: string;
9941012
}): Promise<AnnotateServerResult> {
1013+
const sharingEnabled =
1014+
options.sharingEnabled ?? process.env.PLANNOTATOR_SHARE !== "disabled";
1015+
const shareBaseUrl =
1016+
(options.shareBaseUrl ?? process.env.PLANNOTATOR_SHARE_URL) || undefined;
1017+
const pasteApiUrl =
1018+
(options.pasteApiUrl ?? process.env.PLANNOTATOR_PASTE_URL) || undefined;
1019+
9951020
let resolveDecision!: (result: { feedback: string }) => void;
9961021
const decisionPromise = new Promise<{ feedback: string }>((r) => {
9971022
resolveDecision = r;
@@ -1004,8 +1029,11 @@ export async function startAnnotateServer(options: {
10041029
json(res, {
10051030
plan: options.markdown,
10061031
origin: options.origin ?? "pi",
1007-
mode: "annotate",
1032+
mode: options.mode || "annotate",
10081033
filePath: options.filePath,
1034+
sharingEnabled,
1035+
shareBaseUrl,
1036+
pasteApiUrl,
10091037
});
10101038
} else if (url.pathname === "/api/feedback" && req.method === "POST") {
10111039
const body = await parseBody(req);

0 commit comments

Comments
 (0)