@firstpick/pi-package-webui 0.6.8 → 0.6.9

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.
package/public/app.js CHANGED
@@ -1,7 +1,8 @@
1
1
  const $ = (selector) => document.querySelector(selector);
2
2
 
3
3
  const elements = {
4
- webuiVersionBadge: $("#webuiVersionBadge"),
4
+ piVersionButton: $("#piVersionButton"),
5
+ webuiVersionButton: $("#webuiVersionButton"),
5
6
  webuiDevBadge: $("#webuiDevBadge"),
6
7
  tabBar: $("#tabBar"),
7
8
  terminalTabsToggleButton: $("#terminalTabsToggleButton"),
@@ -256,9 +257,14 @@ const elements = {
256
257
  confirmationSummary: $("#confirmationSummary"),
257
258
  confirmationAffected: $("#confirmationAffected"),
258
259
  confirmationUndo: $("#confirmationUndo"),
259
- confirmationAlternative: $("#confirmationAlternative"),
260
260
  confirmationCancelButton: $("#confirmationCancelButton"),
261
261
  confirmationConfirmButton: $("#confirmationConfirmButton"),
262
+ piReleaseNotesDialog: $("#piReleaseNotesDialog"),
263
+ piReleaseNotesTitle: $("#piReleaseNotesTitle"),
264
+ piReleaseNotesStatus: $("#piReleaseNotesStatus"),
265
+ piReleaseNotesBody: $("#piReleaseNotesBody"),
266
+ piReleaseNotesGithubLink: $("#piReleaseNotesGithubLink"),
267
+ piReleaseNotesCloseButton: $("#piReleaseNotesCloseButton"),
262
268
  dialog: $("#extensionDialog"),
263
269
  dialogTitle: $("#dialogTitle"),
264
270
  dialogMessage: $("#dialogMessage"),
@@ -320,6 +326,8 @@ const elements = {
320
326
  statsOverlayCloseButton: $("#statsOverlayCloseButton"),
321
327
  };
322
328
 
329
+ const PI_WEBUI_NPM_URL = "https://www.npmjs.com/package/@firstpick/pi-package-webui";
330
+
323
331
  let currentState = null;
324
332
  let tabs = [];
325
333
  let activeTabId = null;
@@ -443,6 +451,7 @@ let latestRemoteWebuiQrUrl = "";
443
451
  let remoteQrAutoPopupShown = false;
444
452
  let networkStatusLoaded = false;
445
453
  let webuiVersion = "";
454
+ let piVersion = "";
446
455
  let webuiDevServer = false;
447
456
  let latestCodexUsage = null;
448
457
  let codexUsageError = null;
@@ -1621,7 +1630,7 @@ function terminalTabsLayoutStatusText(layout = terminalTabsLayout) {
1621
1630
  function renderTerminalTabsLayoutControl() {
1622
1631
  const layout = normalizeTerminalTabsLayout(terminalTabsLayout);
1623
1632
  if (elements.terminalTabsLayoutSelect) elements.terminalTabsLayoutSelect.value = layout;
1624
- if (elements.terminalTabsLayoutStatus) elements.terminalTabsLayoutStatus.textContent = terminalTabsLayoutStatusText(layout);
1633
+ if (elements.terminalTabsLayoutStatus) elements.terminalTabsLayoutStatus.textContent = `${terminalTabsLayoutStatusText(layout)} · saved in this browser`;
1625
1634
  }
1626
1635
 
1627
1636
  function setTerminalTabsLayout(layout, { persist = true, announce = false } = {}) {
@@ -2686,16 +2695,15 @@ function finishApplicationConfirmation(confirmed) {
2686
2695
  resolve?.(!!confirmed);
2687
2696
  }
2688
2697
 
2689
- function appConfirm({ title = "Confirm action", summary = "Continue?", affected = "The selected item", undoable = false, alternative = "Cancel and review the action first.", confirmLabel = "Continue", danger = true } = {}) {
2698
+ function appConfirm({ title = "Confirm action", summary = "Continue?", affected = "The selected item", undoable = false, confirmLabel = "Continue", danger = true } = {}) {
2690
2699
  if (!elements.confirmationDialog?.showModal) {
2691
- return Promise.resolve(window.confirm([title, summary, affected, undoable ? "This can be undone." : "This cannot be undone.", alternative].filter(Boolean).join("\n\n")));
2700
+ return Promise.resolve(window.confirm([title, summary, affected, undoable ? "This can be undone." : "This cannot be undone."].filter(Boolean).join("\n\n")));
2692
2701
  }
2693
2702
  if (activeConfirmationResolve) finishApplicationConfirmation(false);
2694
2703
  elements.confirmationTitle.textContent = title;
2695
2704
  elements.confirmationSummary.textContent = summary;
2696
2705
  elements.confirmationAffected.textContent = affected;
2697
2706
  elements.confirmationUndo.textContent = undoable ? "This action can be undone." : "This action cannot be undone.";
2698
- elements.confirmationAlternative.textContent = alternative;
2699
2707
  elements.confirmationConfirmButton.textContent = confirmLabel;
2700
2708
  elements.confirmationConfirmButton.classList.toggle("danger", danger);
2701
2709
  elements.confirmationConfirmButton.classList.toggle("primary", !danger);
@@ -2714,7 +2722,6 @@ function appConfirmText(message, options = {}) {
2714
2722
  summary: options.summary || rest.join("\n").trim() || firstLine || "Continue?",
2715
2723
  affected: options.affected || "The current workspace, session, or server state described above",
2716
2724
  undoable: options.undoable === true,
2717
- alternative: options.alternative || "Cancel and review the affected state before continuing.",
2718
2725
  confirmLabel: options.confirmLabel || "Continue",
2719
2726
  danger: options.danger !== false,
2720
2727
  });
@@ -3449,27 +3456,51 @@ function isWebuiDevMetadata(data) {
3449
3456
  return data?.webuiDev === true || String(data?.webuiMode || "").toLowerCase() === "dev";
3450
3457
  }
3451
3458
 
3452
- function renderWebuiVersion() {
3453
- const badge = elements.webuiVersionBadge;
3454
- if (!badge) return;
3459
+ function renderPiVersionButton() {
3460
+ const button = elements.piVersionButton;
3461
+ if (!button) return;
3462
+ const label = formatWebuiVersion(piVersion);
3463
+ button.hidden = !label;
3464
+ button.textContent = label ? `Pi ${label}` : "";
3465
+ if (label) {
3466
+ button.title = `View Pi ${label} release notes`;
3467
+ button.setAttribute("aria-label", `View Pi ${label} release notes`);
3468
+ }
3469
+ }
3470
+
3471
+ function renderWebuiVersionButton() {
3472
+ const button = elements.webuiVersionButton;
3473
+ if (!button) return;
3455
3474
  const label = formatWebuiVersion(webuiVersion);
3456
- badge.hidden = !label;
3457
- badge.textContent = label;
3458
- if (label) badge.title = `Pi Web UI ${label}`;
3475
+ button.hidden = !label;
3476
+ button.textContent = label ? `Web UI ${label}` : "";
3477
+ if (label) {
3478
+ button.title = `Open Pi Web UI ${label} on npm`;
3479
+ button.setAttribute("aria-label", `Open Pi Web UI ${label} package page`);
3480
+ }
3459
3481
  }
3460
3482
 
3461
3483
  function renderWebuiDevBadge() {
3462
3484
  const badge = elements.webuiDevBadge;
3463
3485
  if (!badge) return;
3464
3486
  badge.hidden = !webuiDevServer;
3465
- badge.title = "Pi Web UI dev server";
3487
+ const version = formatWebuiVersion(webuiVersion);
3488
+ badge.title = `Pi Web UI${version ? ` ${version}` : ""} dev server`;
3466
3489
  }
3467
3490
 
3468
3491
  function setWebuiVersion(version) {
3469
3492
  const text = String(version || "").trim();
3470
3493
  if (text === webuiVersion) return;
3471
3494
  webuiVersion = text;
3472
- renderWebuiVersion();
3495
+ renderWebuiVersionButton();
3496
+ renderWebuiDevBadge();
3497
+ }
3498
+
3499
+ function setPiVersion(version) {
3500
+ const text = String(version || "").trim().replace(/^v/i, "");
3501
+ if (text === piVersion) return;
3502
+ piVersion = text;
3503
+ renderPiVersionButton();
3473
3504
  }
3474
3505
 
3475
3506
  function setWebuiDevServer(dev) {
@@ -3479,9 +3510,90 @@ function setWebuiDevServer(dev) {
3479
3510
  renderWebuiDevBadge();
3480
3511
  }
3481
3512
 
3513
+ function piReleasePageUrl(version = piVersion) {
3514
+ const cleanVersion = String(version || "").trim().replace(/^v/i, "");
3515
+ if (!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(cleanVersion)) return "";
3516
+ return `https://github.com/earendil-works/pi/releases/tag/v${encodeURIComponent(cleanVersion)}`;
3517
+ }
3518
+
3519
+ function formatPiReleaseDate(value) {
3520
+ const date = new Date(value);
3521
+ if (!value || Number.isNaN(date.getTime())) return "";
3522
+ return new Intl.DateTimeFormat(undefined, { dateStyle: "medium" }).format(date);
3523
+ }
3524
+
3525
+ function setPiReleaseNotesLink(value) {
3526
+ const link = elements.piReleaseNotesGithubLink;
3527
+ if (!link) return;
3528
+ const href = safeHttpUrl(value);
3529
+ link.hidden = !href;
3530
+ if (href) link.href = href;
3531
+ else link.removeAttribute("href");
3532
+ }
3533
+
3534
+ function openWebuiNpmPageInNewTab() {
3535
+ const href = safeHttpUrl(PI_WEBUI_NPM_URL);
3536
+ if (!href) return false;
3537
+ const anchor = document.createElement("a");
3538
+ anchor.href = href;
3539
+ anchor.target = "_blank";
3540
+ anchor.rel = "noopener noreferrer";
3541
+ anchor.hidden = true;
3542
+ document.body.append(anchor);
3543
+ anchor.click();
3544
+ anchor.remove();
3545
+ return true;
3546
+ }
3547
+
3548
+ async function confirmOpenWebuiNpmPage() {
3549
+ const confirmed = await appConfirm({
3550
+ title: "Open npm package page?",
3551
+ summary: "Open @firstpick/pi-package-webui on npm in a new browser tab?",
3552
+ affected: "A new tab will open to the public Pi Web UI package page.",
3553
+ undoable: true,
3554
+ confirmLabel: "Open npm",
3555
+ danger: false,
3556
+ });
3557
+ if (!confirmed) return;
3558
+ if (!openWebuiNpmPageInNewTab()) addEvent("Pi Web UI npm package URL is unavailable", "error");
3559
+ }
3560
+
3561
+ async function openPiReleaseNotes() {
3562
+ const dialog = elements.piReleaseNotesDialog;
3563
+ if (!dialog) return;
3564
+ const requestedVersion = piVersion;
3565
+ const label = formatWebuiVersion(requestedVersion);
3566
+ elements.piReleaseNotesTitle.textContent = label ? `Pi ${label} release notes` : "Pi release notes";
3567
+ elements.piReleaseNotesStatus.textContent = "Loading release notes from GitHub…";
3568
+ elements.piReleaseNotesBody.setAttribute("aria-busy", "true");
3569
+ elements.piReleaseNotesBody.replaceChildren(make("p", "muted", "Loading…"));
3570
+ setPiReleaseNotesLink(piReleasePageUrl(requestedVersion));
3571
+ if (!dialog.open) dialog.showModal();
3572
+
3573
+ try {
3574
+ const response = await api("/api/pi-release-notes", { scoped: false });
3575
+ if (requestedVersion !== piVersion) return;
3576
+ const release = response.data || {};
3577
+ const releaseVersion = String(release.version || "").trim().replace(/^v/i, "");
3578
+ if (requestedVersion && releaseVersion !== requestedVersion) throw new Error(`Expected Pi ${formatWebuiVersion(requestedVersion)} release notes but received ${formatWebuiVersion(releaseVersion) || "an unknown version"}`);
3579
+ const releaseLabel = formatWebuiVersion(releaseVersion || requestedVersion);
3580
+ elements.piReleaseNotesTitle.textContent = releaseLabel ? `Pi ${releaseLabel} release notes` : (release.title || "Pi release notes");
3581
+ renderMarkdown(elements.piReleaseNotesBody, release.body || "No release notes were provided for this release.");
3582
+ const published = formatPiReleaseDate(release.publishedAt);
3583
+ elements.piReleaseNotesStatus.textContent = `${published ? `Published ${published}` : "Loaded from GitHub"}${release.truncated ? " · Long notes were truncated" : ""}`;
3584
+ setPiReleaseNotesLink(release.url || piReleasePageUrl(release.version));
3585
+ } catch (error) {
3586
+ elements.piReleaseNotesStatus.textContent = "Release notes could not be loaded.";
3587
+ elements.piReleaseNotesBody.replaceChildren(make("p", "pi-release-notes-error", error.message || String(error)));
3588
+ } finally {
3589
+ elements.piReleaseNotesBody.removeAttribute("aria-busy");
3590
+ }
3591
+ }
3592
+
3482
3593
  async function refreshWebuiVersion() {
3483
3594
  const health = await api("/api/health", { scoped: false });
3484
3595
  setWebuiVersion(health.webuiVersion);
3596
+ setPiVersion(health.piVersion);
3485
3597
  setWebuiDevServer(isWebuiDevMetadata(health));
3486
3598
  }
3487
3599
 
@@ -4308,7 +4420,7 @@ function renderBackgroundControl() {
4308
4420
  : `${themeLabel}: theme default`;
4309
4421
  if (elements.backgroundChooseButton) {
4310
4422
  elements.backgroundChooseButton.disabled = customBackgroundLoading;
4311
- elements.backgroundChooseButton.textContent = active ? "Change background" : "Add background";
4423
+ elements.backgroundChooseButton.textContent = active ? "Change image" : "Choose image";
4312
4424
  }
4313
4425
  if (elements.backgroundInput) elements.backgroundInput.disabled = customBackgroundLoading;
4314
4426
  if (elements.backgroundClearButton) {
@@ -6711,7 +6823,6 @@ async function deleteFileTreeEntry(entry = fileContextMenuState?.entry) {
6711
6823
  summary: `${sourcePath}${recursiveWarning}${dirtyWarning}`,
6712
6824
  affected: typeLabel === "directory" ? "The directory and all files beneath it" : sourcePath,
6713
6825
  undoable: false,
6714
- alternative: "Cancel and move or rename it instead.",
6715
6826
  confirmLabel: `Delete ${typeLabel}`,
6716
6827
  }))) return;
6717
6828
  const tabContext = activeTabContext();
@@ -8363,11 +8474,6 @@ async function confirmCloseTerminalTabs(targetTabs, label) {
8363
8474
  summary: `${base}\n\n${warning}`,
8364
8475
  affected: tabList || label || `${count} terminal ${noun}`,
8365
8476
  undoable: false,
8366
- alternative: activeAgentTabs.length
8367
- ? "Cancel and wait for or abort the running work first."
8368
- : count === 1
8369
- ? "Cancel and keep this tab open."
8370
- : "Cancel and close individual tabs instead.",
8371
8477
  confirmLabel: activeAgentTabs.length ? "Close and stop work" : count === 1 ? "Close tab" : "Close tabs",
8372
8478
  });
8373
8479
  }
@@ -9659,7 +9765,7 @@ function renderGitFooterVisibilityDialog() {
9659
9765
  if (!gitFooterVisibilityDirty) {
9660
9766
  setGitFooterVisibilityStatus(
9661
9767
  gitFooterVisibilityCommandAvailable()
9662
- ? "Runtime changes last until Pi/package restart. Use PI_GIT_FOOTER_WEBUI_HIDE or per-key env vars for persistence."
9768
+ ? "Changes are saved globally and reused by every Pi session. Reset WebUI removes the saved WebUI overrides."
9663
9769
  : commandUnavailableMessage("git-footer-visibility"),
9664
9770
  gitFooterVisibilityCommandAvailable() ? "muted" : "warn",
9665
9771
  );
@@ -9706,7 +9812,7 @@ async function applyGitFooterVisibilityDialog() {
9706
9812
  if (hide.length) await runGitFooterVisibilityCommand("hide", hide);
9707
9813
  if (show.length) await runGitFooterVisibilityCommand("show", show);
9708
9814
  gitFooterVisibilityDirty = false;
9709
- setGitFooterVisibilityStatus(`Applied ${hide.length + show.length} WebUI footer visibility change${hide.length + show.length === 1 ? "" : "s"}.`, "success");
9815
+ setGitFooterVisibilityStatus(`Saved ${hide.length + show.length} global WebUI footer visibility change${hide.length + show.length === 1 ? "" : "s"}.`, "success");
9710
9816
  requestGitFooterWebuiPayload(activeTabContext(), { force: true, allowDuringRun: true });
9711
9817
  renderFooter();
9712
9818
  } catch (error) {
@@ -9723,7 +9829,7 @@ async function resetGitFooterVisibilityDialog() {
9723
9829
  try {
9724
9830
  await runGitFooterVisibilityCommand("reset");
9725
9831
  gitFooterVisibilityDirty = false;
9726
- setGitFooterVisibilityStatus("Reset WebUI footer visibility overrides.", "success");
9832
+ setGitFooterVisibilityStatus("Removed the saved global WebUI footer visibility overrides.", "success");
9727
9833
  requestGitFooterWebuiPayload(activeTabContext(), { force: true, allowDuringRun: true });
9728
9834
  } catch (error) {
9729
9835
  setGitFooterVisibilityStatus(error.message || String(error), "error");
@@ -14158,16 +14264,24 @@ function subagentOverlayOutputLines(data = subagentOverlayData) {
14158
14264
  return tools;
14159
14265
  }
14160
14266
 
14267
+ function subagentOverlayOutputText(data = subagentOverlayData) {
14268
+ return subagentOverlayOutputLines(data).join("\n").trimEnd();
14269
+ }
14270
+
14161
14271
  function appendSubagentOutputWaitingIndicator(parent) {
14162
- const row = make("div", "release-npm-line subagent-output-waiting");
14163
- row.setAttribute("role", "status");
14164
- row.setAttribute("aria-label", "Waiting for agent output");
14272
+ const bubble = make("article", "message runIndicator run-indicator-message streaming subagent-output-waiting");
14273
+ bubble.setAttribute("role", "status");
14274
+ bubble.setAttribute("aria-label", "Waiting for agent output");
14275
+ const body = make("div", "message-body");
14276
+ const row = make("div", "run-indicator-row");
14165
14277
  row.append(
14166
14278
  make("span", "subagent-output-waiting-dot", "."),
14167
14279
  make("span", "subagent-output-waiting-dot", "."),
14168
14280
  make("span", "subagent-output-waiting-dot", "."),
14169
14281
  );
14170
- parent.append(row);
14282
+ body.append(row);
14283
+ bubble.append(body);
14284
+ parent.append(bubble);
14171
14285
  }
14172
14286
 
14173
14287
  function subagentOverlayStateFacts(data = subagentOverlayData) {
@@ -14204,8 +14318,9 @@ function renderSubagentOverlayWidget() {
14204
14318
  const agent = data?.agent || selection.agent || {};
14205
14319
  const tab = tabs.find((item) => item.id === selection.tabId) || selection.tab;
14206
14320
  const running = !selection.finished && (agent.status === "running" || agent.status === "queued" || agent.status === "pending" || !agent.status);
14207
- const lines = subagentOverlayOutputLines(data);
14208
- const shownLines = lines.length ? lines : running && agent.currentTool ? [] : [running ? "Waiting for the first agent activity…" : "No recent output was captured."];
14321
+ const outputText = subagentOverlayOutputText(data);
14322
+ const shownText = outputText || (running && agent.currentTool ? "" : running ? "Waiting for the first agent activity…" : "No recent output was captured.");
14323
+ const shownLineCount = shownText ? shownText.split("\n").length : 0;
14209
14324
  const widget = make("section", `widget release-npm-widget app-runner-widget subagent-overlay-widget${running ? " app-runner-live-widget" : " app-runner-log-widget"}`);
14210
14325
  widget.setAttribute("aria-label", `Live output for subagent ${agent.name || "subagent"}`);
14211
14326
 
@@ -14216,17 +14331,26 @@ function renderSubagentOverlayWidget() {
14216
14331
  for (const fact of subagentOverlayStateFacts(data)) meta.append(make("span", "release-npm-pill", fact));
14217
14332
  header.append(titleWrap, meta);
14218
14333
 
14219
- const streamHeader = releaseNpmStreamHeader(running ? "Live agent output" : "Agent output", shownLines.length, { live: running });
14220
- const terminal = make("div", "release-npm-terminal subagent-overlay-terminal");
14221
- terminal.setAttribute("role", "log");
14222
- terminal.setAttribute("aria-live", running ? "polite" : "off");
14223
- for (const line of shownLines) appendReleaseNpmTerminalLine(terminal, line);
14224
- if (running && agent.currentTool) appendSubagentOutputWaitingIndicator(terminal);
14334
+ const streamHeader = releaseNpmStreamHeader(running ? "Live agent output" : "Agent output", shownLineCount, { live: running });
14335
+ const output = make("div", "subagent-overlay-transcript");
14336
+ output.setAttribute("role", "log");
14337
+ output.setAttribute("aria-live", running ? "polite" : "off");
14338
+ if (shownText) {
14339
+ const { bubble } = createMessageBubble({
14340
+ role: "assistant",
14341
+ title: "final output",
14342
+ timestamp: data?.updatedAt || Date.now(),
14343
+ content: shownText,
14344
+ }, { streaming: running, transient: true });
14345
+ bubble.classList.add("subagent-overlay-message");
14346
+ output.append(bubble);
14347
+ }
14348
+ if (running && agent.currentTool) appendSubagentOutputWaitingIndicator(output);
14225
14349
 
14226
14350
  const controls = make("div", "release-npm-controls subagent-overlay-output-controls");
14227
14351
  const actions = make("div", "app-runner-output-actions");
14228
14352
  const copyButton = appRunnerActionButton("Copy output", copySubagentOverlayOutput, "subagent-overlay-copy-action");
14229
- copyButton.disabled = subagentOverlayOutputLines(data).length === 0;
14353
+ copyButton.disabled = !outputText;
14230
14354
  const refreshButton = appRunnerActionButton(subagentOverlayLoading ? "Refreshing…" : "Refresh", () => {
14231
14355
  refreshSubagentOverlay().finally(() => scheduleSubagentOverlayRefresh());
14232
14356
  }, "subagent-overlay-refresh-action");
@@ -14240,9 +14364,9 @@ function renderSubagentOverlayWidget() {
14240
14364
  subagentOverlayError,
14241
14365
  ].filter(Boolean);
14242
14366
  controls.append(actions, make("span", `app-runner-output-meta${subagentOverlayError ? " warning" : ""}`, details.join(" · ")));
14243
- const outputDetails = renderReleaseNpmOutputDetails(`subagent:${selection.tabId}:${selection.agentId}`, streamHeader, terminal, controls);
14367
+ const outputDetails = renderReleaseNpmOutputDetails(`subagent:${selection.tabId}:${selection.agentId}`, streamHeader, output, controls);
14244
14368
  widget.append(header, outputDetails);
14245
- requestAnimationFrame(() => { if (outputDetails.open) terminal.scrollTop = terminal.scrollHeight; });
14369
+ requestAnimationFrame(() => { if (outputDetails.open) output.scrollTop = output.scrollHeight; });
14246
14370
  return widget;
14247
14371
  }
14248
14372
 
@@ -14317,7 +14441,7 @@ function closeSubagentOverlay() {
14317
14441
  }
14318
14442
 
14319
14443
  async function copySubagentOverlayOutput() {
14320
- const text = subagentOverlayOutputLines().join("\n").trimEnd();
14444
+ const text = subagentOverlayOutputText();
14321
14445
  if (!text) {
14322
14446
  addEvent("subagent output is empty", "warn");
14323
14447
  return;
@@ -21738,12 +21862,7 @@ function jumpToStickyUserPrompt() {
21738
21862
  requestAnimationFrame(updateStickyUserPromptButton);
21739
21863
  }
21740
21864
 
21741
- function appendMessage(message, { streaming = false, messageIndex = -1, transient = false, animateEntry = false, reusableToolCards = null, itemKey = "" } = {}) {
21742
- const reused = reuseToolExecutionBubble(reusableToolCards, message, { streaming, messageIndex, transient });
21743
- if (reused) {
21744
- if (itemKey) reused.bubble.dataset.itemKey = itemKey;
21745
- return reused;
21746
- }
21865
+ function createMessageBubble(message, { streaming = false, messageIndex = -1, transient = false, animateEntry = false, itemKey = "" } = {}) {
21747
21866
  const role = String(message.role || "message");
21748
21867
  const safeRole = role.replace(/[^a-z0-9_-]/gi, "");
21749
21868
  const bubble = make("article", `message ${safeRole}${message.level ? ` ${message.level}` : ""}${streaming ? " streaming" : ""}${animateEntry ? " action-enter" : ""}`);
@@ -21802,10 +21921,27 @@ function appendMessage(message, { streaming = false, messageIndex = -1, transien
21802
21921
  attachMessageCopyButton(bubble, message, body);
21803
21922
  attachMessageEditRetryButton(bubble, message, messageIndex, { streaming, transient });
21804
21923
  if (!streaming && !transient) renderActionFeedbackControls(bubble, message, messageIndex);
21805
- appendChatMessageBubble(bubble);
21806
21924
  return { bubble, body };
21807
21925
  }
21808
21926
 
21927
+ function appendMessage(message, options = {}) {
21928
+ const {
21929
+ streaming = false,
21930
+ messageIndex = -1,
21931
+ transient = false,
21932
+ reusableToolCards = null,
21933
+ itemKey = "",
21934
+ } = options;
21935
+ const reused = reuseToolExecutionBubble(reusableToolCards, message, { streaming, messageIndex, transient });
21936
+ if (reused) {
21937
+ if (itemKey) reused.bubble.dataset.itemKey = itemKey;
21938
+ return reused;
21939
+ }
21940
+ const created = createMessageBubble(message, options);
21941
+ appendChatMessageBubble(created.bubble);
21942
+ return created;
21943
+ }
21944
+
21809
21945
  function appendTranscriptMessage(message, { streaming = false, messageIndex = -1, transient = false, animateEntry = false, reusableToolCards = null, itemKey = "" } = {}) {
21810
21946
  if (streaming || transient || message?.role !== "assistant") {
21811
21947
  return appendMessage(message, { streaming, messageIndex, transient, animateEntry, reusableToolCards, itemKey });
@@ -23119,9 +23255,9 @@ function syncRemoteWebuiControlVisibility(hasRemoteWebuiCommand = isOptionalFeat
23119
23255
  if (!elements.networkControlField) return;
23120
23256
  elements.networkControlField.hidden = !hasRemoteWebuiCommand;
23121
23257
  elements.networkControlField.classList.toggle("feature-unavailable", !hasRemoteWebuiCommand);
23122
- const label = elements.networkControlField.querySelector("label");
23258
+ const heading = elements.networkControlField.querySelector("#remoteAccessControlsTitle");
23123
23259
  const payload = remoteWebuiControlsPayload();
23124
- if (label) label.textContent = payload?.title || "Remote WebUI";
23260
+ if (heading) heading.textContent = payload?.title || "Remote access";
23125
23261
  elements.networkControlField.title = hasRemoteWebuiCommand
23126
23262
  ? payload?.description || "Remote WebUI controls are provided by @firstpick/pi-package-remote-webui."
23127
23263
  : optionalFeatureUnavailableMessage("remoteWebui");
@@ -23304,7 +23440,6 @@ function closeNativeCommandDialog({ force = false } = {}) {
23304
23440
  summary: "Your changes have not been applied.",
23305
23441
  affected: "All changed fields in this settings window",
23306
23442
  undoable: false,
23307
- alternative: "Cancel and choose Apply to keep the changes.",
23308
23443
  confirmLabel: "Discard changes",
23309
23444
  }).then((confirmed) => {
23310
23445
  if (!confirmed) return;
@@ -26443,7 +26578,6 @@ async function openToNetwork() {
26443
26578
  summary: "This changes Pi Web UI from local-only to reachable by devices on your network.",
26444
26579
  affected: `${interfaceName}, port ${port}, ${latestNetwork?.auth?.enabled ? "PIN authentication enabled" : "PIN authentication disabled"}`,
26445
26580
  undoable: true,
26446
- alternative: "Keep local-only access and use this browser on the host machine.",
26447
26581
  confirmLabel: "Open remote access",
26448
26582
  });
26449
26583
  if (!confirmed) return;
@@ -26543,7 +26677,6 @@ async function restartServer() {
26543
26677
  summary: "Browser clients disconnect briefly while the server restarts.",
26544
26678
  affected: "All connected browser clients and Pi tabs managed by this Web UI",
26545
26679
  undoable: false,
26546
- alternative: "Cancel and continue using the current server process.",
26547
26680
  confirmLabel: "Restart server",
26548
26681
  }))) return;
26549
26682
 
@@ -26591,7 +26724,6 @@ async function stopServer() {
26591
26724
  summary: "The Web UI becomes unavailable until the server is started again.",
26592
26725
  affected: "All connected browser clients and Pi tabs managed by this Web UI",
26593
26726
  undoable: false,
26594
- alternative: "Cancel, or restart instead if you only need to reload the server.",
26595
26727
  confirmLabel: "Stop server",
26596
26728
  }))) return;
26597
26729
 
@@ -27155,6 +27287,7 @@ function handleEvent(event) {
27155
27287
  switch (event.type) {
27156
27288
  case "webui_connected":
27157
27289
  setWebuiVersion(event.version);
27290
+ setPiVersion(event.piVersion);
27158
27291
  setWebuiDevServer(isWebuiDevMetadata(event));
27159
27292
  if (Object.prototype.hasOwnProperty.call(event, "activeRun")) {
27160
27293
  setAppRunnerData(event.tabId || activeTabId, { cwd: event.cwd, activeRun: event.activeRun });
@@ -27168,6 +27301,12 @@ function handleEvent(event) {
27168
27301
  applyTabMetadata(event.tab || { id: event.tabId, title: event.tabTitle, activity: event.tabActivity });
27169
27302
  addEvent(`${event.previousTabTitle || "terminal"} renamed to ${event.tabTitle || "terminal"}`);
27170
27303
  break;
27304
+ case "webui_recovery_opened":
27305
+ addEvent(`opened ${event.recoveryTabTitle || "recovery plan"}`);
27306
+ refreshTabs()
27307
+ .then(() => switchTab(event.recoveryTabId))
27308
+ .catch((error) => addEvent(error.message, "error"));
27309
+ break;
27171
27310
  case "pi_process_start":
27172
27311
  addEvent(`started pi rpc pid ${event.pid}`);
27173
27312
  refreshTabs().catch((error) => addEvent(error.message, "error"));
@@ -28097,7 +28236,6 @@ elements.newSessionButton.addEventListener("click", async () => {
28097
28236
  summary: "The active tab switches to a fresh conversation.",
28098
28237
  affected: "The active tab; the previous session remains resumable.",
28099
28238
  undoable: false,
28100
- alternative: "Cancel and open a separate tab to keep both sessions visible.",
28101
28239
  confirmLabel: "Start new session",
28102
28240
  }))) return;
28103
28241
  try {
@@ -28266,6 +28404,13 @@ if (elements.terminalTabsLayoutSelect) {
28266
28404
  setTerminalTabsLayout(elements.terminalTabsLayoutSelect.value, { announce: true });
28267
28405
  });
28268
28406
  }
28407
+ elements.piVersionButton?.addEventListener("click", () => {
28408
+ openPiReleaseNotes().catch((error) => addEvent(error.message || String(error), "error"));
28409
+ });
28410
+ elements.webuiVersionButton?.addEventListener("click", () => {
28411
+ confirmOpenWebuiNpmPage().catch((error) => addEvent(error.message || String(error), "error"));
28412
+ });
28413
+ elements.piReleaseNotesCloseButton?.addEventListener("click", () => elements.piReleaseNotesDialog?.close());
28269
28414
  elements.toggleSidePanelButton.addEventListener("click", () => {
28270
28415
  setSidePanelCollapsed(true);
28271
28416
  });