pi-chrome 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -218,7 +218,12 @@ class ChromeProfileBridge {
218
218
  body: JSON.stringify({ action, params, timeoutMs }),
219
219
  signal: controller.signal,
220
220
  });
221
- const payload = (await response.json()) as { ok: boolean; result?: unknown; error?: string };
221
+ const payload = (await response.json().catch(() => ({}))) as { ok?: boolean; result?: unknown; error?: string };
222
+ if (response.status === 404) {
223
+ throw new Error(
224
+ "A running Pi session owns the Chrome bridge but is using an older pi-chrome without multi-session support. Restart that Pi session after `pi update`, then retry.",
225
+ );
226
+ }
222
227
  if (!response.ok || !payload.ok) throw new Error(payload.error ?? `Chrome bridge owner HTTP ${response.status}`);
223
228
  return payload.result;
224
229
  } catch (error) {
@@ -313,9 +318,12 @@ export default function (pi: ExtensionAPI): void {
313
318
 
314
319
  pi.on("session_start", async (_event, ctx) => {
315
320
  await bridge.start();
321
+ const status = bridge.status();
316
322
  ctx.ui.setStatus("chrome", `Chrome bridge :${DEFAULT_PORT}`);
317
323
  ctx.ui.notify(
318
- `Chrome profile bridge listening at ${bridge.url}. Run /chrome-onboard to load the bundled browser extension in your normal Chrome profile.`,
324
+ status.mode === "client"
325
+ ? `Chrome profile bridge connected to shared bridge at ${bridge.url}.`
326
+ : `Chrome profile bridge listening at ${bridge.url}. Run /chrome-onboard to load the bundled browser extension in your normal Chrome profile.`,
319
327
  "info",
320
328
  );
321
329
  });
@@ -346,8 +354,8 @@ If chrome_* tools time out, ask the user to run /chrome-onboard, then load the b
346
354
  : "Chrome profile bridge connected",
347
355
  "info",
348
356
  );
349
- } catch {
350
- ctx.ui.notify("Chrome bridge health check timed out. Run /chrome-onboard to connect Chrome.", "warning");
357
+ } catch (error) {
358
+ ctx.ui.notify(`Chrome bridge health check failed: ${(error as Error).message}`, "warning");
351
359
  }
352
360
  },
353
361
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-chrome",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Control your existing authenticated Chrome profile from one or more Pi sessions with tabs, snapshots, clicks, typing, JS evaluation, waits, and screenshots.",
5
5
  "keywords": [
6
6
  "pi-package",