pi-fabric 0.122.0 → 0.123.0

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.
@@ -1679,13 +1679,13 @@ var terminalCallTitle = (audit, core) => terminalTitleText(nestedCallTitle(
1679
1679
  // A window title that counted seconds would flicker; the card keeps timing.
1680
1680
  core ? { cwd: core.cwd, settings: { ...core.settings, toolCallTiming: false } } : void 0
1681
1681
  ));
1682
- var liveRuns = /* @__PURE__ */ new Set();
1683
1682
  var applyTitle = (setTitle, text) => {
1684
1683
  try {
1685
1684
  setTitle(text);
1686
1685
  } catch {
1687
1686
  }
1688
1687
  };
1688
+ var titleOwner;
1689
1689
  var withTerminalTitle = async (title, intent, body) => {
1690
1690
  title?.show(intent);
1691
1691
  try {
@@ -1710,22 +1710,43 @@ var FabricTerminalTitle = class {
1710
1710
  const text = terminalTitleText(title);
1711
1711
  if (!text || text === this.#applied) return;
1712
1712
  this.#applied = text;
1713
- liveRuns.add(this);
1713
+ titleOwner = this;
1714
1714
  applyTitle(setTitle, text);
1715
1715
  }
1716
1716
  /** Hand the window title back to Pi once this run has stopped. */
1717
1717
  async restore() {
1718
1718
  if (this.#settled) return;
1719
1719
  this.#settled = true;
1720
- if (this.#applied === void 0) return;
1721
- liveRuns.delete(this);
1722
- if (liveRuns.size > 0) return;
1720
+ if (titleOwner !== this) return;
1721
+ titleOwner = void 0;
1723
1722
  const setTitle = this.#setTitle;
1724
1723
  const base = await this.#base?.();
1725
- if (!setTitle || liveRuns.size > 0) return;
1724
+ if (!setTitle || titleOwner !== void 0) return;
1726
1725
  const text = terminalTitleText(base);
1727
1726
  if (text) applyTitle(setTitle, text);
1728
1727
  }
1728
+ /** Give the title up without writing: a session boundary released it. */
1729
+ detach() {
1730
+ this.#settled = true;
1731
+ this.#applied = void 0;
1732
+ if (titleOwner === this) titleOwner = void 0;
1733
+ }
1734
+ };
1735
+ var releaseTerminalTitle = (context) => {
1736
+ const held = titleOwner;
1737
+ if (!held) return false;
1738
+ held.detach();
1739
+ const text = terminalTitleText(piTerminalTitle(context));
1740
+ if (text) applyTitle((title) => context.ui.setTitle(title), text);
1741
+ return true;
1742
+ };
1743
+ var installTerminalTitleRelease = (pi) => {
1744
+ const release = (_event, context) => {
1745
+ if (context?.mode !== "tui" || !context.hasUI) return;
1746
+ releaseTerminalTitle(context);
1747
+ };
1748
+ pi.on("session_shutdown", release);
1749
+ pi.on("agent_settled", release);
1729
1750
  };
1730
1751
 
1731
1752
  // src/fabric-exec-tool.ts
@@ -6028,6 +6049,7 @@ ${guidance}`,
6028
6049
  if (!state.initialized) return;
6029
6050
  state.dispatchHostEvent(eventName, event, context);
6030
6051
  });
6052
+ installTerminalTitleRelease(pi);
6031
6053
  pi.on("session_shutdown", async (_event, context) => {
6032
6054
  entropyStopping = true;
6033
6055
  clearEntropyRetry();
@@ -6118,4 +6140,4 @@ export {
6118
6140
  FABRIC_MANAGED_HOST_VERSION,
6119
6141
  createFabricExtension
6120
6142
  };
6121
- //# sourceMappingURL=chunk-264TBT7A.js.map
6143
+ //# sourceMappingURL=chunk-S73PXXO6.js.map