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
42 changes: 42 additions & 0 deletions apps/pi-extension/plannotator-browser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,48 @@ describe("shouldUseLocalPrCheckout", () => {
});
});

describe("browser URL notification", () => {
test("notifies RPC sessions even when the browser launcher reports success", async () => {
const previousRemote = process.env.PLANNOTATOR_REMOTE;
const previousPlannotatorBrowser = process.env.PLANNOTATOR_BROWSER;
const previousBrowser = process.env.BROWSER;
const notifications: string[] = [];

process.env.PLANNOTATOR_REMOTE = "0";
delete process.env.PLANNOTATOR_BROWSER;
process.env.BROWSER = process.execPath;

try {
const ctx = {
mode: "rpc",
hasUI: true,
ui: {
notify(message: string) {
notifications.push(message);
},
},
} as any;
const session = startBrowserDecisionSession(
{ url: "http://localhost:4321", stop() {} },
ctx,
() => new Promise<never>(() => {}),
);

await new Promise((resolve) => setTimeout(resolve, 0));
session.stop();

expect(notifications).toEqual(["[Plannotator] http://localhost:4321"]);
} finally {
if (previousRemote === undefined) delete process.env.PLANNOTATOR_REMOTE;
else process.env.PLANNOTATOR_REMOTE = previousRemote;
if (previousPlannotatorBrowser === undefined) delete process.env.PLANNOTATOR_BROWSER;
else process.env.PLANNOTATOR_BROWSER = previousPlannotatorBrowser;
if (previousBrowser === undefined) delete process.env.BROWSER;
else process.env.BROWSER = previousBrowser;
}
});
});

describe("browser session cleanup", () => {
const ctx = {
hasUI: true,
Expand Down
2 changes: 1 addition & 1 deletion apps/pi-extension/plannotator-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export async function startServerWithSelfPreemption<T>(

async function openBrowserForServer(serverUrl: string, ctx: ExtensionContext): Promise<void> {
const browserResult = await openBrowser(serverUrl);
if (isRemoteSession()) {
if (ctx.mode === "rpc" || isRemoteSession()) {
ctx.ui.notify(`[Plannotator] ${serverUrl}`, "info");
} else if (!browserResult.opened) {
ctx.ui.notify(`Open this URL to review: ${serverUrl}`, "info");
Expand Down