@narumitw/pi-btw 0.48.0 → 0.49.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@narumitw/pi-btw",
3
- "version": "0.48.0",
3
+ "version": "0.49.0",
4
4
  "description": "Pi extension that adds a /btw side-question command.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -40,7 +40,7 @@
40
40
  "directory": "extensions/pi-btw"
41
41
  },
42
42
  "dependencies": {
43
- "@narumitw/pi-tui-kit": "^0.42.0"
43
+ "@narumitw/pi-tui-kit": "^0.46.0"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "@earendil-works/pi-ai": "*",
package/src/btw.ts CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  type Theme,
13
13
  } from "@earendil-works/pi-coding-agent";
14
14
  import type { Component, TUI } from "@earendil-works/pi-tui";
15
- import { defineMenu, type MenuContext, type RunMenuResult, runMenu } from "@narumitw/pi-tui-kit";
15
+ import type { MenuContext, RunMenuResult } from "@narumitw/pi-tui-kit";
16
16
  import {
17
17
  type BtwBringToMainSegment,
18
18
  type BtwBringToMainSummary,
@@ -600,6 +600,8 @@ async function showBringToMainPreview(
600
600
  draft: string,
601
601
  summary: BtwBringToMainSummary,
602
602
  ): Promise<BtwBringToMainPreviewAction> {
603
+ const { defineMenu, runMenu } = await import("@narumitw/pi-tui-kit");
604
+ if (ctx.signal?.aborted) return { kind: "close" };
603
605
  let confirmed = false;
604
606
  const count = summary.messages === 1 ? "1 message" : `${summary.messages} messages`;
605
607
  const lineCount = summary.lines === 1 ? "1 line" : `${summary.lines} lines`;
@@ -637,6 +639,8 @@ async function showBtwMenu(
637
639
  options: readonly string[],
638
640
  initialValue?: string,
639
641
  ): Promise<BtwMenuSelectorAction> {
642
+ const { defineMenu, runMenu } = await import("@narumitw/pi-tui-kit");
643
+ if (ctx.signal?.aborted) return { kind: "close" };
640
644
  const items = options.map((label, index) => ({ id: `option-${index}`, label }));
641
645
  const initialIndex = initialValue === undefined ? -1 : options.indexOf(initialValue);
642
646
  let selectedValue: string | undefined;
package/src/menu.ts CHANGED
@@ -4,7 +4,7 @@ import type {
4
4
  Theme,
5
5
  } from "@earendil-works/pi-coding-agent";
6
6
  import type { Component, TUI } from "@earendil-works/pi-tui";
7
- import { defineMenu, type MenuContext, type RunMenuResult, runMenu } from "@narumitw/pi-tui-kit";
7
+ import type { MenuContext, RunMenuResult } from "@narumitw/pi-tui-kit";
8
8
  import {
9
9
  type BtwSettings,
10
10
  btwSettingsPath,
@@ -51,6 +51,8 @@ export async function showBtwCommandMenu(
51
51
  options: ShowBtwCommandMenuOptions,
52
52
  ): Promise<BtwCommandMenuResult> {
53
53
  if (ctx.mode !== "tui") return "closed";
54
+ const { defineMenu, runMenu } = await import("@narumitw/pi-tui-kit");
55
+ if (ctx.signal?.aborted) return "closed";
54
56
  const settingsPath = options.settingsPath ?? btwSettingsPath();
55
57
  const readSettings = options.readSettings ?? readBtwSettings;
56
58
  const updateSettings = options.updateSettings ?? updateBtwSettings;