@narumitw/pi-btw 0.63.2 → 0.63.3

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/README.md CHANGED
@@ -54,6 +54,7 @@ The side thread stays separate until you explicitly bring context to the main ed
54
54
  | `/btw <question>` | Start a new side thread immediately with the supplied question. |
55
55
 
56
56
  Both routes require TUI mode and a model with usable credentials; see [Settings](#-settings).
57
+ Only one BTW flow can be open per session; close it before running `/btw` again.
57
58
  Side questions and selected conversation context are sent to that model's provider.
58
59
  Bringing context back fills the main editor without submitting; replacing an existing draft requires confirmation.
59
60
  Ctrl+C cancels the response and discards the current draft and queued questions, but completed exchanges remain resumable in memory.
@@ -122,7 +123,8 @@ Accepted values are `fullscreen`, `left-pane`, and `right-pane`.
122
123
  The pane names identify the side thread's position; the other pane reuses Pi's native main-thread rendering at pane width and stays current while BTW is open.
123
124
  A single muted divider separates the panes; click either pane or use the pane-switch shortcut to move keyboard focus.
124
125
  The footer below the editor shows **BTW focus** or **Main focus** and the available switch key.
125
- It also shows the selected side model and thinking level when space permits; narrow or short views omit optional fields and hints before the active input row.
126
+ Main-focus submissions use Pi's normal submission and steering behavior without closing BTW, including when the workspace opens while the main agent is idle.
127
+ The footer also shows the selected side model and thinking level when space permits; narrow or short views omit optional fields and hints before the active input row.
126
128
  Drag the divider with the primary mouse button to resize both panes.
127
129
  The side-thread share is limited to 20–80% and saved as `sidePaneRatio` when the button is released, independent of whether the side thread is on the left or right.
128
130
  If the save fails, the workspace restores the last saved ratio and reports the error.
package/dist/index.ts CHANGED
@@ -2037,6 +2037,7 @@ var BtwFullscreenHost = class {
2037
2037
  removeHardCancelListener;
2038
2038
  removeUpstreamAbortListener;
2039
2039
  started = false;
2040
+ splitReady = false;
2040
2041
  disposed = false;
2041
2042
  finished = false;
2042
2043
  parentRestorePromise;
@@ -2458,6 +2459,10 @@ var BtwFullscreenHost = class {
2458
2459
  }
2459
2460
  fullscreen.setFocus(component);
2460
2461
  fullscreen.requestRender();
2462
+ if (splitPane && !this.splitReady && !this.disposed && !this.finished && !this.lifetimeController.signal.aborted) {
2463
+ this.splitReady = true;
2464
+ this.options.onSplitReady?.();
2465
+ }
2461
2466
  }
2462
2467
  }).catch(fail);
2463
2468
  });
@@ -4638,6 +4643,7 @@ function btw(pi, dependencies = {}) {
4638
4643
  const subscribeMainThreadUpdates = registerBtwMainThreadUpdates(pi);
4639
4644
  const getLifetime = registerBtwSessionLifetimes(pi);
4640
4645
  const sessionThreads = /* @__PURE__ */ new WeakMap();
4646
+ const activeCommands = /* @__PURE__ */ new WeakSet();
4641
4647
  let nextThreadNumber = 1;
4642
4648
  const listResumeThreads = (resumableThreads) => [...resumableThreads.values()].reverse().filter((state) => state.thread.turns.length > 0 && state.title || state.thread.updates.length > 0).sort((first, second) => second.updatedAt - first.updatedAt || second.createdAt - first.createdAt).map((state) => ({
4643
4649
  id: state.id,
@@ -4651,14 +4657,28 @@ function btw(pi, dependencies = {}) {
4651
4657
  if (lifetime.signal.aborted) return Promise.resolve();
4652
4658
  const commandCtx = Object.create(ctx);
4653
4659
  Object.defineProperty(commandCtx, "signal", { value: lifetime.signal, configurable: true });
4654
- return lifetime.track(
4655
- handleCommand(args, commandCtx, lifetime).catch((error) => {
4656
- if (!lifetime.signal.aborted) throw error;
4657
- })
4660
+ if (activeCommands.has(lifetime)) {
4661
+ notifySafely3(commandCtx, "A /btw workspace is already open; close it before opening another.", "warning");
4662
+ return Promise.resolve();
4663
+ }
4664
+ activeCommands.add(lifetime);
4665
+ const ready = Promise.withResolvers();
4666
+ let released = false;
4667
+ const task = lifetime.track(
4668
+ handleCommand(args, commandCtx, lifetime, () => {
4669
+ if (lifetime.signal.aborted) return;
4670
+ released = true;
4671
+ ready.resolve();
4672
+ }).catch((error) => {
4673
+ if (lifetime.signal.aborted) return;
4674
+ if (!released) throw error;
4675
+ notifySafely3(commandCtx, `Pi BTW: ${formatError6(error)}`, "error");
4676
+ }).finally(() => activeCommands.delete(lifetime))
4658
4677
  );
4678
+ return Promise.race([task, ready.promise]);
4659
4679
  }
4660
4680
  });
4661
- async function handleCommand(args, ctx, lifetime) {
4681
+ async function handleCommand(args, ctx, lifetime, releaseMainInput) {
4662
4682
  let resumableThreads = sessionThreads.get(lifetime);
4663
4683
  if (!resumableThreads) {
4664
4684
  resumableThreads = /* @__PURE__ */ new Map();
@@ -4749,6 +4769,7 @@ function btw(pi, dependencies = {}) {
4749
4769
  canRestoreParent: lifetime.canRestoreParent,
4750
4770
  copyOnSelect: effectiveFullscreenCopyOnSelect(settings),
4751
4771
  layout: effectiveBtwLayout(settings),
4772
+ ...effectiveBtwLayout(settings) !== "fullscreen" ? { onSplitReady: releaseMainInput } : {},
4752
4773
  sidePaneRatio: effectiveBtwSidePaneRatio(settings),
4753
4774
  persistSidePaneRatio: (ratio, signal) => updateBtwSettings({ sidePaneRatio: ratio }, { signal }).then(() => void 0),
4754
4775
  subscribeMainThreadUpdates: (listener) => subscribeMainThreadUpdates(ctx.sessionManager, listener),