@aiwayds/dsh-opentui 0.18.2 → 0.18.4

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.
@@ -931,6 +931,7 @@ async function probeHostMux(options) {
931
931
  if (!validAuthority(options.authority))
932
932
  return false;
933
933
  const timeoutMs = options.timeoutMs ?? DEFAULT_HOST_PROBE_TIMEOUT_MS;
934
+ const makeSocket = options.socketFactory ?? (() => new WS(`ws://${options.authority}/api/remote.mux`, { headers: { cookie: options.cookieHeader } }));
934
935
  return await new Promise((resolve) => {
935
936
  let settled = false;
936
937
  let socket;
@@ -942,14 +943,13 @@ async function probeHostMux(options) {
942
943
  clearTimeout(timer);
943
944
  try {
944
945
  socket?.removeAllListeners();
946
+ socket?.on("error", () => {});
945
947
  socket?.terminate();
946
948
  } catch {}
947
949
  resolve(ok);
948
950
  }
949
951
  try {
950
- socket = new WS(`ws://${options.authority}/api/remote.mux`, {
951
- headers: { cookie: options.cookieHeader }
952
- });
952
+ socket = makeSocket();
953
953
  } catch {
954
954
  done(false);
955
955
  return;
@@ -1502,12 +1502,17 @@ var init_cookie_mint = __esm(() => {
1502
1502
  // src/client/lifecycle.ts
1503
1503
  var exports_lifecycle = {};
1504
1504
  __export(exports_lifecycle, {
1505
+ DEFAULT_CONNECT_TIMEOUT_MS: () => DEFAULT_CONNECT_TIMEOUT_MS,
1505
1506
  DEFAULT_IDLE_EXIT_MS: () => DEFAULT_IDLE_EXIT_MS,
1506
1507
  DEFAULT_IDLE_EXIT_SEC: () => DEFAULT_IDLE_EXIT_SEC,
1507
1508
  DEFAULT_PROFILE: () => DEFAULT_PROFILE,
1508
1509
  DEFAULT_READINESS_TIMEOUT_MS: () => DEFAULT_READINESS_TIMEOUT_MS,
1510
+ DEFAULT_SERVE_PROBE_BUDGET_MS: () => DEFAULT_SERVE_PROBE_BUDGET_MS,
1509
1511
  DEFAULT_STALE_PROBE_MS: () => DEFAULT_STALE_PROBE_MS,
1512
+ ENV_BOOT_TIMEOUT_MS: () => ENV_BOOT_TIMEOUT_MS,
1513
+ ENV_CONNECT_TIMEOUT_MS: () => ENV_CONNECT_TIMEOUT_MS,
1510
1514
  ENV_IDLE_EXIT_MS: () => ENV_IDLE_EXIT_MS,
1515
+ ENV_MUX_TIMEOUT_MS: () => ENV_MUX_TIMEOUT_MS,
1511
1516
  HostBootSupersededError: () => HostBootSupersededError,
1512
1517
  HostBootTimeoutError: () => HostBootTimeoutError,
1513
1518
  HostDiedError: () => HostDiedError,
@@ -1522,8 +1527,11 @@ __export(exports_lifecycle, {
1522
1527
  ensureHost: () => ensureHost,
1523
1528
  isListening: () => isListening,
1524
1529
  pidAlive: () => pidAlive,
1530
+ resolveBootTimeoutMs: () => resolveBootTimeoutMs,
1531
+ resolveConnectTimeoutMs: () => resolveConnectTimeoutMs,
1525
1532
  resolveIdleExitMs: () => resolveIdleExitMs,
1526
- resolveIdleExitSec: () => resolveIdleExitSec
1533
+ resolveIdleExitSec: () => resolveIdleExitSec,
1534
+ resolveMuxTimeoutMs: () => resolveMuxTimeoutMs
1527
1535
  });
1528
1536
  import { spawn as spawn2 } from "child_process";
1529
1537
  import { existsSync as existsSync3, linkSync, mkdirSync as mkdirSync3, readFileSync as readFileSync4, renameSync as renameSync3, rmSync, writeFileSync as writeFileSync3 } from "fs";
@@ -1545,6 +1553,29 @@ function resolveIdleExitMs(explicitSec) {
1545
1553
  function resolveIdleExitSec(explicitSec) {
1546
1554
  return resolveIdleExitMs(explicitSec) / 1000;
1547
1555
  }
1556
+ function validBudgetMs(value) {
1557
+ return Number.isFinite(value) && Number.isInteger(value) && value > 0;
1558
+ }
1559
+ function resolveBudgetMs(explicitMs, envName, defaultMs) {
1560
+ if (explicitMs !== undefined && validBudgetMs(explicitMs))
1561
+ return explicitMs;
1562
+ const raw = process.env[envName];
1563
+ if (raw !== undefined && /^\d+$/.test(raw)) {
1564
+ const parsed = Number(raw);
1565
+ if (validBudgetMs(parsed))
1566
+ return parsed;
1567
+ }
1568
+ return defaultMs;
1569
+ }
1570
+ function resolveBootTimeoutMs(explicitMs) {
1571
+ return resolveBudgetMs(explicitMs, ENV_BOOT_TIMEOUT_MS, DEFAULT_READINESS_TIMEOUT_MS);
1572
+ }
1573
+ function resolveMuxTimeoutMs(explicitMs) {
1574
+ return resolveBudgetMs(explicitMs, ENV_MUX_TIMEOUT_MS, DEFAULT_SERVE_PROBE_BUDGET_MS);
1575
+ }
1576
+ function resolveConnectTimeoutMs(explicitMs) {
1577
+ return resolveBudgetMs(explicitMs, ENV_CONNECT_TIMEOUT_MS, DEFAULT_CONNECT_TIMEOUT_MS);
1578
+ }
1548
1579
  function errorTail(outputTail) {
1549
1580
  const lines = outputTail.split(/\r?\n/).filter((line) => line.length > 0);
1550
1581
  if (lines.length === 0)
@@ -1953,7 +1984,8 @@ function resolveOptions(opts) {
1953
1984
  profile,
1954
1985
  dshHome,
1955
1986
  idleExitSec,
1956
- readinessTimeoutMs: opts.readinessTimeoutMs ?? DEFAULT_READINESS_TIMEOUT_MS,
1987
+ readinessTimeoutMs: resolveBootTimeoutMs(opts.readinessTimeoutMs),
1988
+ serveProbeBudgetMs: resolveMuxTimeoutMs(opts.serveProbeBudgetMs),
1957
1989
  ...opts.bootJoinTimeoutMs !== undefined ? { bootJoinTimeoutMs: opts.bootJoinTimeoutMs } : {},
1958
1990
  staleProbeMs: opts.staleProbeMs ?? DEFAULT_STALE_PROBE_MS,
1959
1991
  ...opts.maxAgeMs !== undefined ? { maxAgeMs: opts.maxAgeMs } : {},
@@ -2066,7 +2098,7 @@ async function bootHost(o) {
2066
2098
  host.authority = ready.authority;
2067
2099
  host.cookieHeader = await mintCookieWithRetry(host);
2068
2100
  if (ready.via === "listener") {
2069
- const deadline = Date.now() + SERVE_PROBE_BUDGET_MS;
2101
+ const deadline = Date.now() + o.serveProbeBudgetMs;
2070
2102
  let serving = false;
2071
2103
  while (Date.now() < deadline) {
2072
2104
  serving = await probeHostMux({
@@ -2081,7 +2113,7 @@ async function bootHost(o) {
2081
2113
  await sleep(SERVE_PROBE_POLL_MS);
2082
2114
  }
2083
2115
  if (!serving)
2084
- throw new HostNotServingError(host.outputTail);
2116
+ throw new HostNotServingError(host.outputTail, o.serveProbeBudgetMs);
2085
2117
  }
2086
2118
  if (!bootClaimIntact(o.dshHome, o.profile, claimStartedAt)) {
2087
2119
  throw new HostBootSupersededError;
@@ -2196,7 +2228,7 @@ async function ensureHost(opts = {}) {
2196
2228
  attachHost(host);
2197
2229
  return makeHandle(host);
2198
2230
  }
2199
- var DEFAULT_PROFILE = "opentui", DEFAULT_IDLE_EXIT_MS = 5000, DEFAULT_IDLE_EXIT_SEC, ENV_IDLE_EXIT_MS = "DSH_OPENTUI_HOST_IDLE_MS", DEFAULT_READINESS_TIMEOUT_MS = 30000, DEFAULT_STALE_PROBE_MS = 8000, BOOT_JOIN_MARGIN_MS = 20000, BOOT_JOIN_POLL_MS = 200, RESPAWN_WINDOW_MS = 15000, MAX_RAPID_RESPAWNS = 3, LISTEN_PROBE_TIMEOUT_MS = 750, LISTEN_POLL_MS = 200, ADOPT_PROBE_TIMEOUT_MS = 2000, SERVE_PROBE_POLL_MS = 250, SERVE_PROBE_BUDGET_MS = 20000, ERROR_TAIL_LINES = 12, KILL_GRACE_MS = 5000, KILL_ESCALATE_MS = 2000, OUTPUT_TAIL_CAP = 8000, URL_LINE, HostLifecycleError, HostBootTimeoutError, HostDiedError, HostNotServingError, HostSpawnError, HostRespawnLoopError, HostBootSupersededError, ProfileMissingError, MintUnavailableError, registry, pendingBoots, respawnHistory, sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)), realMintPromise = null, RETRYABLE_MINT_ERRORS, MINT_RETRY_BUDGET_MS = 15000, MINT_RETRY_INTERVAL_MS = 250, FFI_FLAG = "--experimental-ffi", __internals;
2231
+ var DEFAULT_PROFILE = "opentui", DEFAULT_IDLE_EXIT_MS = 5000, DEFAULT_IDLE_EXIT_SEC, ENV_IDLE_EXIT_MS = "DSH_OPENTUI_HOST_IDLE_MS", DEFAULT_READINESS_TIMEOUT_MS = 30000, ENV_BOOT_TIMEOUT_MS = "DSH_OPENTUI_BOOT_TIMEOUT_MS", ENV_MUX_TIMEOUT_MS = "DSH_OPENTUI_MUX_TIMEOUT_MS", DEFAULT_SERVE_PROBE_BUDGET_MS = 20000, ENV_CONNECT_TIMEOUT_MS = "DSH_OPENTUI_CONNECT_TIMEOUT_MS", DEFAULT_CONNECT_TIMEOUT_MS = 30000, DEFAULT_STALE_PROBE_MS = 8000, BOOT_JOIN_MARGIN_MS = 20000, BOOT_JOIN_POLL_MS = 200, RESPAWN_WINDOW_MS = 15000, MAX_RAPID_RESPAWNS = 3, LISTEN_PROBE_TIMEOUT_MS = 750, LISTEN_POLL_MS = 200, ADOPT_PROBE_TIMEOUT_MS = 2000, SERVE_PROBE_POLL_MS = 250, ERROR_TAIL_LINES = 12, KILL_GRACE_MS = 5000, KILL_ESCALATE_MS = 2000, OUTPUT_TAIL_CAP = 8000, URL_LINE, HostLifecycleError, HostBootTimeoutError, HostDiedError, HostNotServingError, HostSpawnError, HostRespawnLoopError, HostBootSupersededError, ProfileMissingError, MintUnavailableError, registry, pendingBoots, respawnHistory, sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)), realMintPromise = null, RETRYABLE_MINT_ERRORS, MINT_RETRY_BUDGET_MS = 15000, MINT_RETRY_INTERVAL_MS = 250, FFI_FLAG = "--experimental-ffi", __internals;
2200
2232
  var init_lifecycle = __esm(() => {
2201
2233
  init_host_probe();
2202
2234
  init_append_system();
@@ -2232,9 +2264,11 @@ var init_lifecycle = __esm(() => {
2232
2264
  };
2233
2265
  HostNotServingError = class HostNotServingError extends HostLifecycleError {
2234
2266
  outputTail;
2235
- constructor(outputTail) {
2236
- super("host-not-serving", `dsh host is listening but never served the client mux (${SERVE_PROBE_BUDGET_MS}ms budget)${errorTail(outputTail)}`);
2267
+ budgetMs;
2268
+ constructor(outputTail, budgetMs = DEFAULT_SERVE_PROBE_BUDGET_MS) {
2269
+ super("host-not-serving", `dsh host is listening but never served the client mux (${budgetMs}ms budget)${errorTail(outputTail)}`);
2237
2270
  this.outputTail = outputTail;
2271
+ this.budgetMs = budgetMs;
2238
2272
  }
2239
2273
  };
2240
2274
  HostSpawnError = class HostSpawnError extends HostLifecycleError {
@@ -4332,7 +4366,7 @@ class ClientConnection {
4332
4366
  };
4333
4367
  this.#recovery = options.recovery;
4334
4368
  this.#maxConnectAttempts = Math.max(0, options.maxConnectAttempts ?? DEFAULT_MAX_CONNECT_ATTEMPTS);
4335
- this.#connectBudgetMs = Math.max(1, options.connectBudgetMs ?? DEFAULT_CONNECT_BUDGET_MS);
4369
+ this.#connectBudgetMs = resolveConnectTimeoutMs(options.connectBudgetMs);
4336
4370
  this.#diagnostics = options.diagnostics;
4337
4371
  this.#pumpCallbacks = {
4338
4372
  onReady: (info) => {
@@ -4487,10 +4521,11 @@ class ClientConnection {
4487
4521
  }
4488
4522
  }
4489
4523
  }
4490
- var RemoteRpcError, RpcTransportError, ConnectionClosedError, ConnectionRetryExhaustedError, DEFAULT_MAX_CONNECT_ATTEMPTS = 3, DEFAULT_CONNECT_BUDGET_MS = 30000;
4524
+ var RemoteRpcError, RpcTransportError, ConnectionClosedError, ConnectionRetryExhaustedError, DEFAULT_MAX_CONNECT_ATTEMPTS = 3;
4491
4525
  var init_transport = __esm(() => {
4492
4526
  init_lib2();
4493
4527
  init_events_source();
4528
+ init_lifecycle();
4494
4529
  RemoteRpcError = class RemoteRpcError extends Error {
4495
4530
  code;
4496
4531
  details;
@@ -5075,13 +5110,16 @@ function parseAskCallArgs(args) {
5075
5110
  const question = typeof item.question === "string" && item.question ? item.question : typeof item.prompt === "string" && item.prompt ? item.prompt : undefined;
5076
5111
  if (question === undefined)
5077
5112
  continue;
5078
- const header = typeof item.header === "string" && item.header ? item.header : undefined;
5113
+ const header = textField(item.header);
5114
+ const detail = textField(item.detail);
5079
5115
  const rawOptions = Array.isArray(item.options) ? item.options : [];
5080
- const options = rawOptions.map((o) => typeof o === "string" ? o : typeof o?.label === "string" ? o.label : "").filter((o) => o !== "");
5116
+ const options = rawOptions.map(optionView).filter((option) => option.label !== "");
5081
5117
  out.push({
5082
5118
  id,
5083
5119
  entry: {
5084
- question: header !== undefined && header !== question ? `${header}: ${question}` : question,
5120
+ question,
5121
+ ...header !== undefined ? { header } : {},
5122
+ ...detail !== undefined ? { detail } : {},
5085
5123
  options,
5086
5124
  selected: [],
5087
5125
  declined: false
@@ -5090,6 +5128,17 @@ function parseAskCallArgs(args) {
5090
5128
  }
5091
5129
  return out.length > 0 ? out : undefined;
5092
5130
  }
5131
+ function textField(value) {
5132
+ return typeof value === "string" && value !== "" ? value : undefined;
5133
+ }
5134
+ function optionView(option) {
5135
+ if (typeof option === "string")
5136
+ return { label: option };
5137
+ const item = typeof option === "object" && option !== null ? option : {};
5138
+ const label = typeof item.label === "string" ? item.label : "";
5139
+ const description = textField(item.description);
5140
+ return description === undefined ? { label } : { label, description };
5141
+ }
5093
5142
  function textBlocks(content) {
5094
5143
  if (!Array.isArray(content))
5095
5144
  return [];
@@ -5860,6 +5909,18 @@ function asRow(value) {
5860
5909
  }
5861
5910
 
5862
5911
  // src/client/remote-waterfall.ts
5912
+ function textField2(value) {
5913
+ return typeof value === "string" && value !== "" ? value : undefined;
5914
+ }
5915
+ function optionView2(option) {
5916
+ if (typeof option !== "object" || option === null)
5917
+ return { label: String(option) };
5918
+ const item = option;
5919
+ const label = String(item.label ?? item.value ?? option);
5920
+ const description = textField2(item.description);
5921
+ return description === undefined ? { label } : { label, description };
5922
+ }
5923
+
5863
5924
  class WaterfallAnswerer {
5864
5925
  #connection;
5865
5926
  #clientId;
@@ -5901,10 +5962,16 @@ class WaterfallAnswerer {
5901
5962
  return questions.map((q) => {
5902
5963
  const item = typeof q === "object" && q !== null ? q : {};
5903
5964
  const options = Array.isArray(item.options) ? item.options : [];
5965
+ const header = textField2(item.header);
5966
+ const description = textField2(item.description);
5967
+ const detail = textField2(item.detail);
5904
5968
  return {
5905
5969
  id: String(item.id ?? ""),
5906
5970
  prompt: String(item.prompt ?? item.question ?? item.header ?? ""),
5907
- options: options.map((o) => String(typeof o === "object" && o !== null ? o.label ?? o.value ?? o : o)),
5971
+ ...header !== undefined ? { header } : {},
5972
+ ...description !== undefined ? { description } : {},
5973
+ ...detail !== undefined ? { detail } : {},
5974
+ options: options.map(optionView2),
5908
5975
  ...item.multiSelect === true || item.multi_select === true ? { multiSelect: true } : {}
5909
5976
  };
5910
5977
  });
@@ -5916,7 +5983,13 @@ class WaterfallAnswerer {
5916
5983
  if (pick?.custom !== undefined && pick.custom !== "") {
5917
5984
  return { id: q.id, selected: [], custom: pick.custom };
5918
5985
  }
5919
- const answer = pick ? { id: q.id, selected: pick.selections?.length ? [...pick.selections] : [pick.selected] } : { id: q.id, selected: [], custom: "declined" };
5986
+ if (pick === undefined || pick.selected === "" && (pick.custom ?? "") === "") {
5987
+ return { id: q.id, selected: [], custom: "declined" };
5988
+ }
5989
+ const answer = {
5990
+ id: q.id,
5991
+ selected: pick.selections?.length ? [...pick.selections] : [pick.selected]
5992
+ };
5920
5993
  return answer;
5921
5994
  })
5922
5995
  };
@@ -10467,6 +10540,61 @@ function mapArray(list, mapFn, options = {}) {
10467
10540
  }
10468
10541
  };
10469
10542
  }
10543
+ function indexArray(list, mapFn, options = {}) {
10544
+ let items = [], mapped = [], disposers = [], signals = [], len = 0, i;
10545
+ onCleanup(() => dispose(disposers));
10546
+ return () => {
10547
+ const newItems = list() || [], newLen = newItems.length;
10548
+ newItems[$TRACK];
10549
+ return untrack(() => {
10550
+ if (newLen === 0) {
10551
+ if (len !== 0) {
10552
+ dispose(disposers);
10553
+ disposers = [];
10554
+ items = [];
10555
+ mapped = [];
10556
+ len = 0;
10557
+ signals = [];
10558
+ }
10559
+ if (options.fallback) {
10560
+ items = [FALLBACK];
10561
+ mapped[0] = createRoot((disposer) => {
10562
+ disposers[0] = disposer;
10563
+ return options.fallback();
10564
+ });
10565
+ len = 1;
10566
+ }
10567
+ return mapped;
10568
+ }
10569
+ if (items[0] === FALLBACK) {
10570
+ disposers[0]();
10571
+ disposers = [];
10572
+ items = [];
10573
+ mapped = [];
10574
+ len = 0;
10575
+ }
10576
+ for (i = 0;i < newLen; i++) {
10577
+ if (i < items.length && items[i] !== newItems[i]) {
10578
+ signals[i](() => newItems[i]);
10579
+ } else if (i >= items.length) {
10580
+ mapped[i] = createRoot(mapper);
10581
+ }
10582
+ }
10583
+ for (;i < items.length; i++) {
10584
+ disposers[i]();
10585
+ }
10586
+ len = signals.length = disposers.length = newLen;
10587
+ items = newItems.slice(0);
10588
+ return mapped = mapped.slice(0, len);
10589
+ });
10590
+ function mapper(disposer) {
10591
+ disposers[i] = disposer;
10592
+ const [s, set] = createSignal(newItems[i]);
10593
+ signals[i] = set;
10594
+ return mapFn(s, i);
10595
+ }
10596
+ };
10597
+ }
10470
10598
  function createComponent(Comp, props) {
10471
10599
  if (hydrationEnabled) {
10472
10600
  if (sharedConfig.context) {
@@ -10619,6 +10747,12 @@ function For(props) {
10619
10747
  };
10620
10748
  return createMemo(mapArray(() => props.each, props.children, fallback || undefined));
10621
10749
  }
10750
+ function Index(props) {
10751
+ const fallback = "fallback" in props && {
10752
+ fallback: () => props.fallback
10753
+ };
10754
+ return createMemo(indexArray(() => props.each, props.children, fallback || undefined));
10755
+ }
10622
10756
  function Show(props) {
10623
10757
  const keyed = props.keyed;
10624
10758
  const conditionValue = createMemo(() => props.when, undefined, undefined);
@@ -42117,6 +42251,55 @@ var require_fuzzysort = __commonJS(function(exports, module) {
42117
42251
  });
42118
42252
  });
42119
42253
 
42254
+ // ../tui-base/src/context/input-ownership.tsx
42255
+ function InputOwnershipProvider(props) {
42256
+ const page = {
42257
+ id: Symbol("page"),
42258
+ kind: "page"
42259
+ };
42260
+ const [stack, setStack] = createSignal([page]);
42261
+ const top = () => stack().at(-1) ?? page;
42262
+ const value = {
42263
+ top,
42264
+ pageFrame: () => page,
42265
+ push(kind) {
42266
+ const frame = {
42267
+ id: Symbol(kind),
42268
+ kind
42269
+ };
42270
+ setStack((items) => [...items, frame]);
42271
+ return frame;
42272
+ },
42273
+ pop(frame) {
42274
+ if (!frame || frame === page)
42275
+ return;
42276
+ setStack((items) => items.some((item) => item.id === frame.id) ? items.filter((item) => item.id !== frame.id) : items);
42277
+ },
42278
+ owns(frame) {
42279
+ return frame !== undefined && top().id === frame.id;
42280
+ }
42281
+ };
42282
+ return createComponent2(Context6.Provider, {
42283
+ value,
42284
+ get children() {
42285
+ return props.children;
42286
+ }
42287
+ });
42288
+ }
42289
+ function useInputOwnershipOptional() {
42290
+ return useContext(Context6);
42291
+ }
42292
+ function useIsPageOwner() {
42293
+ const ownership = useInputOwnershipOptional();
42294
+ return () => ownership === undefined || ownership.owns(ownership.pageFrame());
42295
+ }
42296
+ var Context6;
42297
+ var init_input_ownership = __esm(() => {
42298
+ init_index_bun();
42299
+ init_server();
42300
+ Context6 = createContext(undefined);
42301
+ });
42302
+
42120
42303
  // ../tui-base/src/ui/border.ts
42121
42304
  var EmptyBorder, SplitBorder;
42122
42305
  var init_border = __esm(() => {
@@ -42719,6 +42902,7 @@ function init2() {
42719
42902
  });
42720
42903
  const renderer = useRenderer();
42721
42904
  const keymap = Keymap2.use();
42905
+ const ownership = useInputOwnershipOptional();
42722
42906
  createEffect(() => {
42723
42907
  if (store.stack.length === 0)
42724
42908
  return;
@@ -42751,7 +42935,7 @@ function init2() {
42751
42935
  }
42752
42936
  Keymap2.createLayer(() => ({
42753
42937
  mode: "modal",
42754
- enabled: store.stack.length > 0,
42938
+ enabled: store.stack.length > 0 && (ownership === undefined || ownership.owns(store.stack.at(-1)?.frame)),
42755
42939
  commands: [{
42756
42940
  bind: "escape",
42757
42941
  title: "Close dialog",
@@ -42763,6 +42947,7 @@ function init2() {
42763
42947
  }
42764
42948
  const current = store.stack.at(-1);
42765
42949
  current?.onClose?.();
42950
+ ownership?.pop(current?.frame);
42766
42951
  setStore("stack", store.stack.slice(0, -1));
42767
42952
  refocus();
42768
42953
  }
@@ -42785,6 +42970,7 @@ function init2() {
42785
42970
  }
42786
42971
  const current = store.stack.at(-1);
42787
42972
  current?.onClose?.();
42973
+ ownership?.pop(current?.frame);
42788
42974
  setStore("stack", store.stack.slice(0, -1));
42789
42975
  refocus();
42790
42976
  }
@@ -42795,6 +42981,7 @@ function init2() {
42795
42981
  for (const item of store.stack) {
42796
42982
  if (item.onClose)
42797
42983
  item.onClose();
42984
+ ownership?.pop(item.frame);
42798
42985
  }
42799
42986
  batch(() => {
42800
42987
  setStore("size", "medium");
@@ -42811,6 +42998,7 @@ function init2() {
42811
42998
  for (const item of store.stack) {
42812
42999
  if (item.onClose)
42813
43000
  item.onClose();
43001
+ ownership?.pop(item.frame);
42814
43002
  }
42815
43003
  batch(() => {
42816
43004
  setStore("size", options?.size ?? "medium");
@@ -42819,7 +43007,8 @@ function init2() {
42819
43007
  element: input,
42820
43008
  onClose,
42821
43009
  key: options?.key,
42822
- tone: options?.tone
43010
+ tone: options?.tone,
43011
+ frame: ownership?.push("dialog")
42823
43012
  }]);
42824
43013
  });
42825
43014
  },
@@ -42923,6 +43112,7 @@ var init_dialog = __esm(() => {
42923
43112
  init_index_bun();
42924
43113
  init_server();
42925
43114
  init_keymap();
43115
+ init_input_ownership();
42926
43116
  init_theme3();
42927
43117
  init_server2();
42928
43118
  init_toast();
@@ -46038,6 +46228,7 @@ var init_subagent_markers = __esm(() => {
46038
46228
  function SubagentsPicker(props) {
46039
46229
  const theme = useThemeOptional();
46040
46230
  const dialog = useDialog();
46231
+ const pageOwns = useIsPageOwner();
46041
46232
  const [open, setOpen] = [pickerOpen, setPickerOpen];
46042
46233
  onCleanup(() => setPickerOpen(false));
46043
46234
  const [showAll, setShowAll] = createSignal(false);
@@ -46108,7 +46299,7 @@ function SubagentsPicker(props) {
46108
46299
  }
46109
46300
  Keymap2.createLayer(() => ({
46110
46301
  mode: "global",
46111
- enabled: open() && dialog.stack.length === 0,
46302
+ enabled: open() && pageOwns(),
46112
46303
  priority: 2,
46113
46304
  commands: [{
46114
46305
  bind: "down",
@@ -46142,7 +46333,7 @@ function SubagentsPicker(props) {
46142
46333
  }));
46143
46334
  Keymap2.createLayer(() => ({
46144
46335
  mode: "global",
46145
- enabled: !open() && dialog.stack.length === 0 && pickerToggleEnabled(subagentMarkerViews()),
46336
+ enabled: !open() && pageOwns() && pickerToggleEnabled(subagentMarkerViews()),
46146
46337
  commands: [{
46147
46338
  id: "session.child.first",
46148
46339
  title: t("overlay.picker.keymap.toggle"),
@@ -46224,6 +46415,7 @@ var init_subagents_picker = __esm(() => {
46224
46415
  init_theme3();
46225
46416
  init_semantic();
46226
46417
  init_dialog();
46418
+ init_input_ownership();
46227
46419
  init_dialog_prompt();
46228
46420
  init_i18n();
46229
46421
  init_locale();
@@ -46253,7 +46445,7 @@ var init_dock_visibility = __esm(() => {
46253
46445
 
46254
46446
  // ../tui-base/src/routes/session/seam-rows.ts
46255
46447
  function toStoredRow(stored, index) {
46256
- const kind = stored.kind === "user" || stored.kind === "tool" ? stored.kind : "assistant";
46448
+ const kind = stored.kind === "user" || stored.kind === "tool" || stored.kind === "ask" ? stored.kind : "assistant";
46257
46449
  const key = `stored:${kind}:${index}`;
46258
46450
  if (kind === "tool") {
46259
46451
  return {
@@ -46265,6 +46457,11 @@ function toStoredRow(stored, index) {
46265
46457
  ...typeof stored.output === "string" ? { output: stored.output } : {}
46266
46458
  };
46267
46459
  }
46460
+ if (kind === "ask") {
46461
+ if (stored.entries?.length)
46462
+ return { key, kind: "ask", entries: stored.entries };
46463
+ return { key, kind: "assistant", text: stored.text, final: stored.final };
46464
+ }
46268
46465
  if (kind === "user")
46269
46466
  return { key, kind: "user", text: stored.text, final: true };
46270
46467
  return { key, kind: "assistant", text: stored.text, final: stored.final };
@@ -46661,6 +46858,75 @@ var init_seam_rows = __esm(() => {
46661
46858
  init_motion();
46662
46859
  });
46663
46860
 
46861
+ // ../tui-base/src/routes/session/ask-options.ts
46862
+ function splitRecommended(raw) {
46863
+ const trimmed = raw.trim();
46864
+ const match = TRAILING_PAREN.exec(trimmed);
46865
+ if (match === null)
46866
+ return { label: trimmed, recommended: false };
46867
+ const token = (match[1] ?? "").trim().toLowerCase();
46868
+ if (!RECOMMENDED_TOKENS.has(token))
46869
+ return { label: trimmed, recommended: false };
46870
+ const label = trimmed.slice(0, match.index).trim();
46871
+ if (label === "")
46872
+ return { label: trimmed, recommended: false };
46873
+ return { label, recommended: true };
46874
+ }
46875
+ function recommendedPicks(question) {
46876
+ const recommended = question.options.filter((option) => splitRecommended(option.label).recommended).map((option) => option.label);
46877
+ if (recommended.length === 0)
46878
+ return [];
46879
+ return question.multiSelect === true ? recommended : [recommended[0]];
46880
+ }
46881
+ function askNeedsReview(questions) {
46882
+ return questions.length >= 2 || questions.some((question) => question.multiSelect === true);
46883
+ }
46884
+ function askTabStrip(questions, picks, index, customs) {
46885
+ return questions.map((_, qi) => {
46886
+ const answered = (picks[qi]?.length ?? 0) > 0 || customs?.[qi] !== undefined && customs[qi] !== "";
46887
+ const label = `${qi + 1}${answered ? " \u2713" : ""}`;
46888
+ return qi === index ? `[${label}]` : label;
46889
+ }).join(" \xB7 ");
46890
+ }
46891
+ function hasReviewRow(question, needsReview) {
46892
+ return needsReview && question.options.length > 0;
46893
+ }
46894
+ function questionRowCount(question, needsReview) {
46895
+ return question.options.length + (hasReviewRow(question, needsReview) ? 1 : 0) + 1;
46896
+ }
46897
+ function inlineRowIndex(question, needsReview) {
46898
+ return question.options.length + (hasReviewRow(question, needsReview) ? 1 : 0);
46899
+ }
46900
+ function reviewRowIntent(cursor, questionCount) {
46901
+ return cursor >= questionCount ? { kind: "submit" } : { kind: "edit", question: Math.max(0, cursor) };
46902
+ }
46903
+ function estimateAskRows(ask) {
46904
+ const question = ask.questions[ask.index];
46905
+ if (question === undefined)
46906
+ return 1;
46907
+ let rows = 1;
46908
+ rows += 1;
46909
+ if (question.header !== undefined)
46910
+ rows += 1;
46911
+ if (question.detail !== undefined)
46912
+ rows += 1;
46913
+ if (ask.questions.length >= 2)
46914
+ rows += 1;
46915
+ for (const option of question.options)
46916
+ rows += option.description === undefined ? 1 : 2;
46917
+ if (hasReviewRow(question, askNeedsReview(ask.questions)))
46918
+ rows += 1;
46919
+ rows += 1;
46920
+ rows += 1;
46921
+ rows += 1;
46922
+ return rows;
46923
+ }
46924
+ var TRAILING_PAREN, RECOMMENDED_TOKENS;
46925
+ var init_ask_options = __esm(() => {
46926
+ TRAILING_PAREN = /\s*[(\uFF08]([^()\uFF08\uFF09]*)[)\uFF09]\s*$/;
46927
+ RECOMMENDED_TOKENS = new Set(["recommended", "\u63A8\u8350"]);
46928
+ });
46929
+
46664
46930
  // ../tui-base/src/util/todo.ts
46665
46931
  function parseTodos(value) {
46666
46932
  if (!Array.isArray(value))
@@ -48332,7 +48598,6 @@ function Transcript(props) {
48332
48598
  text: () => theme?.text.base ?? "#e6e6e6",
48333
48599
  user: () => theme?.text.action.primary.base ?? "#7aa2f7",
48334
48600
  reasoningBorder: () => theme?.border.base ?? "#565f89",
48335
- reasoning: () => theme?.text.muted ?? "#9aa5ce",
48336
48601
  done: () => theme?.text.feedback.success.base ?? "#9ece6a",
48337
48602
  running: () => theme?.text.feedback.warning.base ?? "#e0af68",
48338
48603
  failed: () => theme?.text.feedback.error.base ?? "#f7768e",
@@ -48375,6 +48640,9 @@ function Transcript(props) {
48375
48640
  });
48376
48641
  return _el$2;
48377
48642
  })();
48643
+ const askRow = (row) => createComponent2(AskReplayBlock, {
48644
+ row
48645
+ });
48378
48646
  const visibleRows = createMemo(() => projection.rows.filter((row) => row.kind !== "tool" && row.kind !== "reasoning" && row.kind !== "subagents"));
48379
48647
  const rowView = (row) => {
48380
48648
  switch (row.kind) {
@@ -48401,6 +48669,8 @@ function Transcript(props) {
48401
48669
  })();
48402
48670
  case "assistant":
48403
48671
  return assistantRow(row);
48672
+ case "ask":
48673
+ return askRow(row);
48404
48674
  default:
48405
48675
  return null;
48406
48676
  }
@@ -48559,6 +48829,64 @@ function Transcript(props) {
48559
48829
  return _el$4;
48560
48830
  })();
48561
48831
  }
48832
+ function AskReplayBlock(props) {
48833
+ const theme = useThemeOptional();
48834
+ const reasoning = () => theme?.text.muted ?? "#9aa5ce";
48835
+ const answer = () => theme?.text.action.primary.base ?? "#7aa2f7";
48836
+ const askAnswerOf = (entry) => entry.selected.map((label) => splitRecommended(label).label).join(", ") || entry.custom || t("transcript.ask.declined");
48837
+ const askDeclinedOf = (entry) => entry.declined || entry.selected.length === 0 && !entry.custom;
48838
+ return (() => {
48839
+ var _el$13 = createElement("box");
48840
+ setProp(_el$13, "flexDirection", "column");
48841
+ setProp(_el$13, "gap", 1);
48842
+ insert(_el$13, createComponent2(For, {
48843
+ get each() {
48844
+ return props.row.entries;
48845
+ },
48846
+ children: (entry) => (() => {
48847
+ var _el$14 = createElement("box"), _el$15 = createElement("text"), _el$16 = createElement("text");
48848
+ insertNode(_el$14, _el$15);
48849
+ insertNode(_el$14, _el$16);
48850
+ setProp(_el$14, "flexDirection", "column");
48851
+ insert(_el$14, createComponent2(Show, {
48852
+ get when() {
48853
+ return entry.header;
48854
+ },
48855
+ children: (header) => (() => {
48856
+ var _el$17 = createElement("text");
48857
+ insert(_el$17, header);
48858
+ effect((_$p) => setProp(_el$17, "fg", reasoning(), _$p));
48859
+ return _el$17;
48860
+ })()
48861
+ }), _el$15);
48862
+ insert(_el$15, () => `\u2713 ${entry.question}`);
48863
+ insert(_el$14, createComponent2(Show, {
48864
+ get when() {
48865
+ return entry.detail;
48866
+ },
48867
+ children: (detail) => (() => {
48868
+ var _el$18 = createElement("text");
48869
+ insert(_el$18, detail);
48870
+ effect((_$p) => setProp(_el$18, "fg", reasoning(), _$p));
48871
+ return _el$18;
48872
+ })()
48873
+ }), _el$16);
48874
+ insert(_el$16, () => ` \u2192 ${askAnswerOf(entry)}`);
48875
+ effect((_p$) => {
48876
+ var _v$14 = reasoning(), _v$15 = askDeclinedOf(entry) ? reasoning() : answer();
48877
+ _v$14 !== _p$.e && (_p$.e = setProp(_el$15, "fg", _v$14, _p$.e));
48878
+ _v$15 !== _p$.t && (_p$.t = setProp(_el$16, "fg", _v$15, _p$.t));
48879
+ return _p$;
48880
+ }, {
48881
+ e: undefined,
48882
+ t: undefined
48883
+ });
48884
+ return _el$14;
48885
+ })()
48886
+ }));
48887
+ return _el$13;
48888
+ })();
48889
+ }
48562
48890
  var SIDES_RULE, SIDES_FRAME, CODE_RENDER_NODE_CACHE_MAX = 256, codeRenderNodeCache;
48563
48891
  var init_transcript = __esm(() => {
48564
48892
  init_index_bun();
@@ -48573,6 +48901,7 @@ var init_transcript = __esm(() => {
48573
48901
  init_index_bun();
48574
48902
  init_terminal_size();
48575
48903
  init_seam_rows();
48904
+ init_ask_options();
48576
48905
  init_theme3();
48577
48906
  init_i18n();
48578
48907
  init_motion();
@@ -49006,6 +49335,8 @@ function rowSearchText(row) {
49006
49335
  return row.text;
49007
49336
  case "tool":
49008
49337
  return `${row.name}${row.args ? `(${row.args})` : ""}${row.output ? ` ${row.output}` : ""}`;
49338
+ case "ask":
49339
+ return row.entries.map((entry) => `${entry.question}${entry.header ? ` ${entry.header}` : ""} ${entry.selected.join(" ")}${entry.custom ? ` ${entry.custom}` : ""}`).join(" ");
49009
49340
  case "subagents":
49010
49341
  return row.children.map((child) => `${child.label}${child.model ? `(${child.model})` : ""}`).join(" ");
49011
49342
  }
@@ -49054,7 +49385,7 @@ function useSearchOverlayOpenState() {
49054
49385
  }
49055
49386
  function SearchOverlay(props) {
49056
49387
  const theme = useThemeOptional();
49057
- const dialog = useDialog();
49388
+ const pageOwns = useIsPageOwner();
49058
49389
  let configCursorStyle;
49059
49390
  try {
49060
49391
  configCursorStyle = useCursorStyle();
@@ -49114,7 +49445,7 @@ function SearchOverlay(props) {
49114
49445
  }
49115
49446
  Keymap2.createLayer(() => ({
49116
49447
  mode: "global",
49117
- enabled: open() && dialog.stack.length === 0,
49448
+ enabled: open() && pageOwns(),
49118
49449
  priority: 2,
49119
49450
  commands: [{
49120
49451
  bind: "escape",
@@ -49135,7 +49466,7 @@ function SearchOverlay(props) {
49135
49466
  }));
49136
49467
  Keymap2.createLayer(() => ({
49137
49468
  mode: "global",
49138
- enabled: !open() && dialog.stack.length === 0,
49469
+ enabled: !open() && pageOwns(),
49139
49470
  commands: [{
49140
49471
  id: "session.search",
49141
49472
  title: t("overlay.search.commandTitle"),
@@ -49213,9 +49544,9 @@ var init_search_overlay = __esm(() => {
49213
49544
  init_index_bun();
49214
49545
  init_server();
49215
49546
  init_keymap();
49216
- init_dialog();
49217
49547
  init_i18n();
49218
49548
  init_theme3();
49549
+ init_input_ownership();
49219
49550
  init_semantic();
49220
49551
  init_config();
49221
49552
  [panelOpen, setPanelOpen] = createSignal(false);
@@ -49456,6 +49787,14 @@ var init_pane_focus = __esm(() => {
49456
49787
  });
49457
49788
 
49458
49789
  // ../tui-base/src/routes/session/turn-cancel.tsx
49790
+ function armNonArmingInterrupt() {
49791
+ nonArmingInterrupt = true;
49792
+ }
49793
+ function consumeNonArmingInterrupt() {
49794
+ const armed = nonArmingInterrupt;
49795
+ nonArmingInterrupt = false;
49796
+ return armed;
49797
+ }
49459
49798
  function createCtrlCGate(windowMs = CTRL_C_QUIT_WINDOW_MS, now = Date.now) {
49460
49799
  let armedAt;
49461
49800
  return {
@@ -49517,6 +49856,10 @@ function createTurnCancel(props, onArm) {
49517
49856
  ctrlC() {
49518
49857
  if (armedKey === "escape")
49519
49858
  disarm();
49859
+ if (consumeNonArmingInterrupt() && props.busy()) {
49860
+ props.interrupt();
49861
+ return true;
49862
+ }
49520
49863
  if (gate.press() === "quit") {
49521
49864
  disarm();
49522
49865
  props.quit();
@@ -49570,7 +49913,7 @@ function TurnCancelKeys(props) {
49570
49913
  }
49571
49914
  });
49572
49915
  }
49573
- var CTRL_C_QUIT_WINDOW_MS = 500;
49916
+ var CTRL_C_QUIT_WINDOW_MS = 500, nonArmingInterrupt = false;
49574
49917
  var init_turn_cancel = __esm(() => {
49575
49918
  init_index_bun();
49576
49919
  init_index_bun();
@@ -49613,6 +49956,12 @@ class TurnOverlayController {
49613
49956
  get pendingApproval() {
49614
49957
  return this.#approvals[0]?.request;
49615
49958
  }
49959
+ get pendingApprovalCount() {
49960
+ return this.#approvals.length;
49961
+ }
49962
+ get pendingAskCount() {
49963
+ return this.#asks.length;
49964
+ }
49616
49965
  requestApproval(name, args) {
49617
49966
  return new Promise((resolve) => {
49618
49967
  this.#approvals.push({ request: { id: ++this.#seq, name, args }, resolve });
@@ -49643,7 +49992,10 @@ class TurnOverlayController {
49643
49992
  picks: head.picks,
49644
49993
  phase: head.phase,
49645
49994
  customs: [...head.customs],
49646
- customDraft: head.customDraft
49995
+ customDraft: head.customDrafts[head.index] ?? null,
49996
+ cursors: [...head.cursors],
49997
+ listCursors: [...head.listCursors],
49998
+ reviewCursor: head.reviewCursor
49647
49999
  };
49648
50000
  }
49649
50001
  get currentQuestion() {
@@ -49658,12 +50010,15 @@ class TurnOverlayController {
49658
50010
  id: ++this.#seq,
49659
50011
  questions,
49660
50012
  index: 0,
49661
- picks: questions.map(() => []),
49662
- phase: "questions",
50013
+ picks: questions.map((question) => recommendedPicks(question)),
50014
+ phase: questions[0]?.options.length === 0 ? "input" : "questions",
49663
50015
  customs: questions.map(() => {
49664
50016
  return;
49665
50017
  }),
49666
- customDraft: null,
50018
+ customDrafts: questions.map(() => null),
50019
+ cursors: questions.map(() => 0),
50020
+ listCursors: questions.map(() => 0),
50021
+ reviewCursor: 0,
49667
50022
  resolve
49668
50023
  });
49669
50024
  this.#changed();
@@ -49674,9 +50029,10 @@ class TurnOverlayController {
49674
50029
  const question = head?.questions[head.index];
49675
50030
  if (!head || !question || head.phase === "review")
49676
50031
  return;
49677
- if (head.customDraft !== null)
50032
+ if (head.phase === "input")
49678
50033
  return;
49679
50034
  head.customs[head.index] = undefined;
50035
+ head.customDrafts[head.index] = null;
49680
50036
  if (question.multiSelect === true) {
49681
50037
  const current = head.picks[head.index] ?? [];
49682
50038
  head.picks[head.index] = current.includes(option) ? current.filter((label) => label !== option) : [...current, option];
@@ -49692,10 +50048,18 @@ class TurnOverlayController {
49692
50048
  }
49693
50049
  if (this.#allAnswered(head)) {
49694
50050
  head.phase = "review";
50051
+ head.reviewCursor = 0;
49695
50052
  } else {
49696
- const next = head.questions.findIndex((_, qi) => qi > head.index && head.picks[qi]?.length === 0);
50053
+ const next = head.questions.findIndex((_, qi) => qi > head.index && (head.picks[qi]?.length ?? 0) === 0 && !head.customs[qi]);
49697
50054
  if (next >= 0)
49698
50055
  head.index = next;
50056
+ head.phase = head.questions[head.index]?.options.length === 0 ? "input" : "questions";
50057
+ if (head.phase === "input") {
50058
+ const question = head.questions[head.index];
50059
+ if (question !== undefined) {
50060
+ head.cursors[head.index] = inlineRowIndex(question, askNeedsReview(head.questions));
50061
+ }
50062
+ }
49699
50063
  }
49700
50064
  this.#changed();
49701
50065
  }
@@ -49703,35 +50067,73 @@ class TurnOverlayController {
49703
50067
  const head = this.#asks[0];
49704
50068
  if (!head || head.phase === "review" || head.questions.length < 2)
49705
50069
  return;
50070
+ if (head.phase === "input" && (head.questions[head.index]?.options.length ?? 0) > 0)
50071
+ return;
49706
50072
  const next = Math.max(0, Math.min(head.questions.length - 1, head.index + direction));
49707
- if (next !== head.index) {
50073
+ if (next === head.index)
50074
+ return;
50075
+ head.index = next;
50076
+ const question = head.questions[next];
50077
+ head.phase = question?.options.length === 0 ? "input" : "questions";
50078
+ if (head.phase === "input" && question !== undefined) {
50079
+ head.cursors[next] = inlineRowIndex(question, askNeedsReview(head.questions));
50080
+ }
50081
+ this.#changed();
50082
+ }
50083
+ confirmQuestion() {
50084
+ const head = this.#asks[0];
50085
+ if (!head || head.phase === "review" || head.phase === "input")
50086
+ return false;
50087
+ const question = head.questions[head.index];
50088
+ if (question === undefined || !askNeedsReview(head.questions))
50089
+ return false;
50090
+ const next = head.questions.findIndex((_, qi) => qi > head.index && (head.picks[qi]?.length ?? 0) === 0 && !head.customs[qi]);
50091
+ if (next >= 0) {
49708
50092
  head.index = next;
49709
- this.#changed();
50093
+ const target = head.questions[next];
50094
+ head.phase = target?.options.length === 0 ? "input" : "questions";
50095
+ if (head.phase === "input" && target !== undefined) {
50096
+ head.cursors[next] = inlineRowIndex(target, askNeedsReview(head.questions));
50097
+ }
50098
+ } else {
50099
+ head.phase = "review";
50100
+ head.reviewCursor = 0;
49710
50101
  }
50102
+ this.#changed();
50103
+ return true;
49711
50104
  }
49712
50105
  beginCustom() {
49713
50106
  const head = this.#asks[0];
49714
50107
  if (!head || head.phase === "review")
49715
50108
  return false;
49716
- head.customDraft = head.customs[head.index] ?? "";
50109
+ const question = head.questions[head.index];
50110
+ head.customDrafts[head.index] = head.customs[head.index] ?? "";
50111
+ head.phase = "input";
50112
+ if (question !== undefined) {
50113
+ head.cursors[head.index] = inlineRowIndex(question, askNeedsReview(head.questions));
50114
+ }
49717
50115
  this.#changed();
49718
50116
  return true;
49719
50117
  }
49720
50118
  patchCustom(text) {
49721
50119
  const head = this.#asks[0];
49722
- if (!head || head.customDraft === null)
50120
+ if (!head || head.customDrafts[head.index] === null)
49723
50121
  return;
49724
- head.customDraft = text;
50122
+ head.customDrafts[head.index] = text;
49725
50123
  this.#changed();
49726
50124
  }
49727
50125
  commitCustom() {
49728
50126
  const head = this.#asks[0];
49729
50127
  const question = head?.questions[head.index];
49730
- if (!head || !question || head.customDraft === null)
50128
+ if (!head || !question)
50129
+ return;
50130
+ const draft = head.customDrafts[head.index] ?? null;
50131
+ if (draft === null)
49731
50132
  return;
49732
- const text = head.customDraft.trim();
49733
- head.customDraft = null;
50133
+ const text = draft.trim();
50134
+ head.customDrafts[head.index] = null;
49734
50135
  if (text === "") {
50136
+ this.#backToList(head);
49735
50137
  this.#changed();
49736
50138
  return;
49737
50139
  }
@@ -49745,27 +50147,124 @@ class TurnOverlayController {
49745
50147
  }
49746
50148
  if (this.#allAnswered(head)) {
49747
50149
  head.phase = "review";
50150
+ head.reviewCursor = 0;
49748
50151
  } else {
49749
50152
  const next = head.questions.findIndex((_, qi) => qi > head.index && (head.picks[qi]?.length ?? 0) === 0 && !head.customs[qi]);
49750
50153
  if (next >= 0)
49751
50154
  head.index = next;
50155
+ head.phase = head.questions[head.index]?.options.length === 0 ? "input" : "questions";
49752
50156
  }
49753
50157
  this.#changed();
49754
50158
  }
49755
50159
  cancelCustomEdit() {
49756
50160
  const head = this.#asks[0];
49757
- if (!head || head.customDraft === null)
50161
+ if (!head || head.customDrafts[head.index] === null)
50162
+ return;
50163
+ head.customDrafts[head.index] = null;
50164
+ this.#backToList(head);
50165
+ this.#changed();
50166
+ }
50167
+ get inlineText() {
50168
+ const head = this.#asks[0];
50169
+ if (!head)
50170
+ return "";
50171
+ const draft = head.customDrafts[head.index];
50172
+ if (draft !== null && draft !== undefined)
50173
+ return draft;
50174
+ return head.customs[head.index] ?? "";
50175
+ }
50176
+ setInlineText(text) {
50177
+ const head = this.#asks[0];
50178
+ const question = head?.questions[head.index];
50179
+ if (!head || !question || head.phase === "review")
50180
+ return;
50181
+ if ((head.customDrafts[head.index] ?? null) === null && text === "")
50182
+ return;
50183
+ head.customDrafts[head.index] = text;
50184
+ head.phase = "input";
50185
+ head.cursors[head.index] = inlineRowIndex(question, askNeedsReview(head.questions));
50186
+ this.#changed();
50187
+ }
50188
+ focusInput() {
50189
+ const head = this.#asks[0];
50190
+ const question = head?.questions[head.index];
50191
+ if (!head || !question || head.phase === "review")
50192
+ return;
50193
+ head.phase = "input";
50194
+ head.cursors[head.index] = inlineRowIndex(question, askNeedsReview(head.questions));
50195
+ this.#changed();
50196
+ }
50197
+ focusOptions() {
50198
+ const head = this.#asks[0];
50199
+ if (!head || head.phase !== "input")
49758
50200
  return;
49759
- head.customDraft = null;
50201
+ this.#backToList(head);
49760
50202
  this.#changed();
49761
50203
  }
50204
+ setCursor(row) {
50205
+ const head = this.#asks[0];
50206
+ const question = head?.questions[head.index];
50207
+ if (!head || !question || head.phase === "review")
50208
+ return;
50209
+ const needsReview = askNeedsReview(head.questions);
50210
+ const inline = inlineRowIndex(question, needsReview);
50211
+ const next = Math.max(0, Math.min(inline, Math.floor(row)));
50212
+ head.cursors[head.index] = next;
50213
+ head.phase = next === inline ? "input" : "questions";
50214
+ if (next !== inline)
50215
+ head.listCursors[head.index] = next;
50216
+ this.#changed();
50217
+ }
50218
+ moveCursor(delta) {
50219
+ const head = this.#asks[0];
50220
+ const question = head?.questions[head.index];
50221
+ if (!head || !question || head.phase === "review")
50222
+ return;
50223
+ const needsReview = askNeedsReview(head.questions);
50224
+ const last = questionRowCount(question, needsReview) - 1;
50225
+ const next = Math.max(0, Math.min(last, (head.cursors[head.index] ?? 0) + delta));
50226
+ const inline = inlineRowIndex(question, needsReview);
50227
+ head.cursors[head.index] = next;
50228
+ head.phase = next === inline ? "input" : "questions";
50229
+ if (next !== inline)
50230
+ head.listCursors[head.index] = next;
50231
+ this.#changed();
50232
+ }
50233
+ setReviewCursor(row) {
50234
+ const head = this.#asks[0];
50235
+ if (!head || head.phase !== "review")
50236
+ return;
50237
+ const next = Math.max(0, Math.min(head.questions.length, Math.floor(row)));
50238
+ if (next === head.reviewCursor)
50239
+ return;
50240
+ head.reviewCursor = next;
50241
+ this.#changed();
50242
+ }
50243
+ moveReviewCursor(delta) {
50244
+ this.setReviewCursor((this.#asks[0]?.reviewCursor ?? 0) + delta);
50245
+ }
50246
+ #backToList(head) {
50247
+ const question = head.questions[head.index];
50248
+ if (question === undefined)
50249
+ return;
50250
+ if (question.options.length === 0) {
50251
+ head.phase = "input";
50252
+ return;
50253
+ }
50254
+ head.phase = "questions";
50255
+ const inline = inlineRowIndex(question, askNeedsReview(head.questions));
50256
+ const row = Math.max(0, Math.min(inline - 1, head.listCursors[head.index] ?? 0));
50257
+ head.cursors[head.index] = row;
50258
+ head.listCursors[head.index] = row;
50259
+ }
49762
50260
  enterReview() {
49763
50261
  const head = this.#asks[0];
49764
50262
  if (!head || head.phase === "review")
49765
50263
  return false;
49766
- if (!this.#allAnswered(head))
50264
+ if (!askNeedsReview(head.questions))
49767
50265
  return false;
49768
50266
  head.phase = "review";
50267
+ head.reviewCursor = 0;
49769
50268
  this.#changed();
49770
50269
  return true;
49771
50270
  }
@@ -49776,6 +50275,9 @@ class TurnOverlayController {
49776
50275
  head.phase = "questions";
49777
50276
  if (focus !== undefined && focus >= 0 && focus < head.questions.length)
49778
50277
  head.index = focus;
50278
+ const question = head.questions[head.index];
50279
+ if (question !== undefined && question.options.length === 0)
50280
+ head.phase = "input";
49779
50281
  this.#changed();
49780
50282
  }
49781
50283
  submit() {
@@ -49811,6 +50313,9 @@ class TurnOverlayController {
49811
50313
  this.#changed();
49812
50314
  }
49813
50315
  }
50316
+ var init_turn_overlay_controller = __esm(() => {
50317
+ init_ask_options();
50318
+ });
49814
50319
 
49815
50320
  // ../tui-base/src/ui/dialog-confirm.tsx
49816
50321
  import { TextAttributes as TextAttributes7 } from "@opentui/core";
@@ -49963,6 +50468,1108 @@ var init_dialog_confirm = __esm(() => {
49963
50468
  init_turn_overlays();
49964
50469
  });
49965
50470
 
50471
+ // ../tui-base/src/routes/session/ask-keys.ts
50472
+ function printableText(event) {
50473
+ const text = event.sequence;
50474
+ if (text.length !== 1)
50475
+ return;
50476
+ if (event.ctrl || event.meta || event.super === true || event.hyper === true)
50477
+ return;
50478
+ if (text === " ")
50479
+ return;
50480
+ if (text >= "0" && text <= "9")
50481
+ return;
50482
+ const code = text.codePointAt(0) ?? 0;
50483
+ if (code < 32 || code === 127)
50484
+ return;
50485
+ return text;
50486
+ }
50487
+ function useAskKeys(options) {
50488
+ const keymap = Keymap2.useOptional();
50489
+ if (keymap === undefined)
50490
+ return;
50491
+ const renderer = useRenderer();
50492
+ const ownership = useInputOwnershipOptional();
50493
+ const ownsDock = () => ownership === undefined || ownership.top().kind === "dock";
50494
+ const ask = () => options.controller.pendingAsk;
50495
+ const question = () => {
50496
+ const batch = ask();
50497
+ return batch?.questions[batch.index];
50498
+ };
50499
+ const needsReview = () => askNeedsReview(ask()?.questions ?? []);
50500
+ const currentRow = () => {
50501
+ const batch = ask();
50502
+ return batch === undefined ? 0 : batch.cursors[batch.index] ?? 0;
50503
+ };
50504
+ const inputFocused = () => {
50505
+ const input = options.input();
50506
+ return input !== undefined && renderer.currentFocusedRenderable === input;
50507
+ };
50508
+ onCleanup(keymap.intercept("key", ({ event }) => {
50509
+ if (!ownsDock())
50510
+ return;
50511
+ const batch = ask();
50512
+ if (batch === undefined || batch.phase !== "questions")
50513
+ return;
50514
+ if (printableText(event) === undefined)
50515
+ return;
50516
+ options.controller.focusInput();
50517
+ options.input()?.focus();
50518
+ }));
50519
+ function move(delta) {
50520
+ const batch = ask();
50521
+ if (batch === undefined)
50522
+ return false;
50523
+ if (batch.phase === "review") {
50524
+ options.controller.moveReviewCursor(delta);
50525
+ return true;
50526
+ }
50527
+ if (batch.phase === "input")
50528
+ return false;
50529
+ options.controller.moveCursor(delta);
50530
+ return true;
50531
+ }
50532
+ function page(direction) {
50533
+ return move(direction * ASK_PAGE_ROWS);
50534
+ }
50535
+ function boundary(toEnd) {
50536
+ const batch = ask();
50537
+ if (batch === undefined)
50538
+ return false;
50539
+ if (batch.phase === "review") {
50540
+ options.controller.setReviewCursor(toEnd ? batch.questions.length : 0);
50541
+ return true;
50542
+ }
50543
+ if (batch.phase === "input")
50544
+ return false;
50545
+ const current = question();
50546
+ if (current === undefined)
50547
+ return false;
50548
+ options.controller.setCursor(toEnd ? questionRowCount(current, needsReview()) - 1 : 0);
50549
+ return true;
50550
+ }
50551
+ function switchQuestion(direction) {
50552
+ const batch = ask();
50553
+ if (batch === undefined)
50554
+ return false;
50555
+ if (batch.phase === "input")
50556
+ return false;
50557
+ if (batch.phase === "review") {
50558
+ if (direction === -1) {
50559
+ options.controller.backToQuestions(batch.questions.length - 1);
50560
+ return true;
50561
+ }
50562
+ return false;
50563
+ }
50564
+ if (batch.questions.length < 2)
50565
+ return false;
50566
+ options.controller.switchFocus(direction);
50567
+ return true;
50568
+ }
50569
+ function enter() {
50570
+ const batch = ask();
50571
+ if (batch === undefined)
50572
+ return false;
50573
+ if (batch.phase === "input")
50574
+ return false;
50575
+ if (batch.phase === "review") {
50576
+ const intent = reviewRowIntent(batch.reviewCursor, batch.questions.length);
50577
+ if (intent.kind === "submit") {
50578
+ options.controller.submit();
50579
+ return true;
50580
+ }
50581
+ options.controller.backToQuestions(intent.question);
50582
+ return true;
50583
+ }
50584
+ const current = question();
50585
+ if (current === undefined)
50586
+ return false;
50587
+ const row = currentRow();
50588
+ if (hasReviewRow(current, needsReview()) && row === current.options.length) {
50589
+ return options.controller.enterReview();
50590
+ }
50591
+ const option = current.options[row];
50592
+ if (option === undefined)
50593
+ return false;
50594
+ if (current.multiSelect === true)
50595
+ return options.controller.confirmQuestion();
50596
+ options.controller.toggle(option.label);
50597
+ return true;
50598
+ }
50599
+ function space() {
50600
+ const batch = ask();
50601
+ if (batch === undefined || batch.phase !== "questions")
50602
+ return false;
50603
+ const current = question();
50604
+ if (current === undefined || current.multiSelect !== true)
50605
+ return false;
50606
+ if (inputFocused())
50607
+ return false;
50608
+ const option = current.options[currentRow()];
50609
+ if (option === undefined)
50610
+ return false;
50611
+ options.controller.toggle(option.label);
50612
+ return true;
50613
+ }
50614
+ function digit(index) {
50615
+ const batch = ask();
50616
+ if (batch === undefined || batch.phase !== "questions")
50617
+ return false;
50618
+ if (inputFocused())
50619
+ return false;
50620
+ const option = question()?.options[index];
50621
+ if (option === undefined)
50622
+ return false;
50623
+ options.controller.toggle(option.label);
50624
+ return true;
50625
+ }
50626
+ function atOutermost(batch) {
50627
+ if (batch.phase === "review" || batch.index > 0)
50628
+ return false;
50629
+ if (batch.phase === "input")
50630
+ return (batch.questions[batch.index]?.options.length ?? 0) === 0;
50631
+ return true;
50632
+ }
50633
+ function backOut() {
50634
+ const batch = ask();
50635
+ if (batch === undefined)
50636
+ return false;
50637
+ if (batch.phase === "review") {
50638
+ options.controller.backToQuestions(batch.questions.length - 1);
50639
+ return true;
50640
+ }
50641
+ if (batch.phase === "input") {
50642
+ const current = batch.questions[batch.index];
50643
+ if (current !== undefined && current.options.length > 0) {
50644
+ options.controller.focusOptions();
50645
+ return true;
50646
+ }
50647
+ }
50648
+ if (batch.index > 0) {
50649
+ options.controller.switchFocus(-1);
50650
+ return true;
50651
+ }
50652
+ options.controller.decline();
50653
+ return true;
50654
+ }
50655
+ function interrupt() {
50656
+ const batch = ask();
50657
+ if (batch === undefined)
50658
+ return false;
50659
+ if (atOutermost(batch))
50660
+ armNonArmingInterrupt();
50661
+ return backOut();
50662
+ }
50663
+ Keymap2.createLayer(() => ({
50664
+ mode: "global",
50665
+ enabled: ownsDock,
50666
+ commands: [
50667
+ { bind: "up,ctrl+p", run: () => move(-1) },
50668
+ { bind: "down,ctrl+n", run: () => move(1) },
50669
+ { bind: "pageup", run: () => page(-1) },
50670
+ { bind: "pagedown", run: () => page(1) },
50671
+ { bind: "home", run: () => boundary(false) },
50672
+ { bind: "end", run: () => boundary(true) },
50673
+ { bind: "return", run: enter },
50674
+ { bind: "space", run: space },
50675
+ ...Array.from({ length: 9 }, (_, index) => ({
50676
+ bind: `${index + 1}`,
50677
+ enabled: () => !inputFocused(),
50678
+ run: () => digit(index)
50679
+ })),
50680
+ { bind: "left", run: () => switchQuestion(-1) },
50681
+ { bind: "right", run: () => switchQuestion(1) },
50682
+ { bind: "escape", run: backOut },
50683
+ { bind: "ctrl+c", run: interrupt }
50684
+ ]
50685
+ }));
50686
+ }
50687
+ var ASK_PAGE_ROWS = 5;
50688
+ var init_ask_keys = __esm(() => {
50689
+ init_index_bun();
50690
+ init_server();
50691
+ init_keymap();
50692
+ init_input_ownership();
50693
+ init_ask_options();
50694
+ init_turn_cancel();
50695
+ });
50696
+
50697
+ // ../tui-base/src/routes/session/dock-host.tsx
50698
+ function firstFocusable(node) {
50699
+ if (node === undefined)
50700
+ return;
50701
+ for (const child of node.getChildren()) {
50702
+ if (child.focusable)
50703
+ return child;
50704
+ const nested = firstFocusable(child);
50705
+ if (nested !== undefined)
50706
+ return nested;
50707
+ }
50708
+ return;
50709
+ }
50710
+ function DockProvider(props) {
50711
+ const renderer = useRenderer();
50712
+ const ownership = useInputOwnershipOptional();
50713
+ const [queue, setQueue] = createSignal([]);
50714
+ let frame;
50715
+ let composerFocus;
50716
+ let focusTarget;
50717
+ let cancelAfterLayout;
50718
+ const hasRequests = () => queue().length > 0;
50719
+ function afterLayout(callback) {
50720
+ cancelAfterLayout?.();
50721
+ if (renderer.isDestroyed)
50722
+ return;
50723
+ let done = false;
50724
+ const handler = () => {
50725
+ if (done)
50726
+ return;
50727
+ done = true;
50728
+ renderer.off("frame", handler);
50729
+ if (cancelAfterLayout === cancel)
50730
+ cancelAfterLayout = undefined;
50731
+ callback();
50732
+ };
50733
+ const cancel = () => {
50734
+ if (done)
50735
+ return;
50736
+ done = true;
50737
+ renderer.off("frame", handler);
50738
+ if (cancelAfterLayout === cancel)
50739
+ cancelAfterLayout = undefined;
50740
+ };
50741
+ cancelAfterLayout = cancel;
50742
+ renderer.on("frame", handler);
50743
+ }
50744
+ function focusDock() {
50745
+ afterLayout(() => {
50746
+ if (!hasRequests())
50747
+ return;
50748
+ const target = focusTarget?.();
50749
+ if (target !== undefined) {
50750
+ target.focus();
50751
+ return;
50752
+ }
50753
+ renderer.currentFocusedRenderable?.blur();
50754
+ });
50755
+ }
50756
+ function remove(entry) {
50757
+ const before = queue();
50758
+ if (!before.includes(entry))
50759
+ return;
50760
+ const next = before.filter((item) => item !== entry);
50761
+ setQueue(next);
50762
+ if (next.length > 0) {
50763
+ if (before[0] !== next[0])
50764
+ focusDock();
50765
+ return;
50766
+ }
50767
+ if (frame !== undefined) {
50768
+ ownership?.pop(frame);
50769
+ frame = undefined;
50770
+ }
50771
+ afterLayout(() => {
50772
+ if (hasRequests())
50773
+ return;
50774
+ composerFocus?.();
50775
+ });
50776
+ }
50777
+ const api = {
50778
+ open(render, options = {}) {
50779
+ const id = ++ordinal2;
50780
+ const entry = {
50781
+ id,
50782
+ kind: options.kind,
50783
+ options,
50784
+ close: () => remove(entry),
50785
+ render
50786
+ };
50787
+ const before = queue();
50788
+ setQueue([...before, entry]);
50789
+ if (before.length === 0) {
50790
+ frame = ownership?.push("dock");
50791
+ focusDock();
50792
+ }
50793
+ return {
50794
+ id,
50795
+ close: entry.close
50796
+ };
50797
+ },
50798
+ queueDepth: () => Math.max(0, queue().length - 1),
50799
+ isOpen: () => hasRequests(),
50800
+ currentKind: () => queue()[0]?.kind,
50801
+ current: () => queue()[0],
50802
+ bindComposerFocus(refocus) {
50803
+ composerFocus = refocus;
50804
+ },
50805
+ bindFocusTarget(resolve) {
50806
+ focusTarget = resolve;
50807
+ }
50808
+ };
50809
+ onCleanup(() => {
50810
+ cancelAfterLayout?.();
50811
+ if (frame !== undefined) {
50812
+ ownership?.pop(frame);
50813
+ frame = undefined;
50814
+ }
50815
+ setQueue([]);
50816
+ });
50817
+ return createComponent2(Context7.Provider, {
50818
+ value: api,
50819
+ get children() {
50820
+ return props.children;
50821
+ }
50822
+ });
50823
+ }
50824
+ function useDock() {
50825
+ const value = useContext(Context7);
50826
+ if (!value)
50827
+ throw new Error("Dock.Provider is missing");
50828
+ return value;
50829
+ }
50830
+ function DockSeat(props) {
50831
+ const dock = useDock();
50832
+ const dimensions = useTerminalSize();
50833
+ const theme = useThemeOptional();
50834
+ let scroll;
50835
+ let body;
50836
+ let disposed = false;
50837
+ const [measured, setMeasured] = createSignal(undefined);
50838
+ const resolveFocus = () => {
50839
+ const designated = dock.current()?.options.focusRef?.();
50840
+ return designated ?? firstFocusable(body);
50841
+ };
50842
+ dock.bindFocusTarget(resolveFocus);
50843
+ onCleanup(() => {
50844
+ disposed = true;
50845
+ dock.bindFocusTarget(undefined);
50846
+ });
50847
+ const capRows = () => Math.max(1, Math.floor(dimensions().height * DOCK_MAX_ROWS_RATIO));
50848
+ const contentRows = () => measured() ?? dock.current()?.options.contentRows ?? capRows();
50849
+ const overflows = () => contentRows() > capRows() && capRows() > 1;
50850
+ const viewportRows = () => Math.max(1, Math.min(contentRows(), capRows() - (overflows() ? 1 : 0)));
50851
+ const hiddenRows = () => Math.max(0, contentRows() - viewportRows());
50852
+ const indicatorText = () => {
50853
+ const label = dock.current()?.options.overflowLabel;
50854
+ return label ? label(hiddenRows()) : `\u2191\u2193 ${hiddenRows()}`;
50855
+ };
50856
+ const muted = () => theme?.text.muted ?? "#9aa5ce";
50857
+ const background = () => theme?.background.base ?? "black";
50858
+ createEffect(on(() => dock.current()?.id, () => {
50859
+ if (scroll !== undefined && !scroll.isDestroyed)
50860
+ scroll.scrollTo(0);
50861
+ }, {
50862
+ defer: true
50863
+ }));
50864
+ createEffect(on(capRows, () => {
50865
+ if (scroll === undefined || scroll.isDestroyed)
50866
+ return;
50867
+ scroll.afterLayout(() => {
50868
+ if (scroll === undefined || scroll.isDestroyed)
50869
+ return;
50870
+ const max = Math.max(0, scroll.scrollHeight - scroll.viewport.height);
50871
+ if (scroll.scrollTop > max)
50872
+ scroll.scrollTo(max);
50873
+ });
50874
+ }, {
50875
+ defer: true
50876
+ }));
50877
+ return (() => {
50878
+ var _el$ = createElement("box"), _el$2 = createElement("box");
50879
+ insertNode(_el$, _el$2);
50880
+ setProp(_el$, "width", "100%");
50881
+ setProp(_el$, "flexShrink", 0);
50882
+ setProp(_el$, "flexDirection", "column");
50883
+ setProp(_el$2, "width", "100%");
50884
+ setProp(_el$2, "flexShrink", 0);
50885
+ insert(_el$2, () => props.composer());
50886
+ insert(_el$, createComponent2(Show, {
50887
+ get when() {
50888
+ return dock.current();
50889
+ },
50890
+ children: (request) => (() => {
50891
+ var _el$3 = createElement("box"), _el$4 = createElement("scrollbox"), _el$5 = createElement("box");
50892
+ insertNode(_el$3, _el$4);
50893
+ setProp(_el$3, "width", "100%");
50894
+ setProp(_el$3, "flexShrink", 0);
50895
+ setProp(_el$3, "flexDirection", "column");
50896
+ insertNode(_el$4, _el$5);
50897
+ use((value) => {
50898
+ scroll = value;
50899
+ }, _el$4);
50900
+ setProp(_el$4, "width", "100%");
50901
+ setProp(_el$4, "flexShrink", 0);
50902
+ setProp(_el$4, "focusable", false);
50903
+ setProp(_el$4, "scrollY", true);
50904
+ setProp(_el$4, "scrollX", false);
50905
+ setProp(_el$4, "overflow", "hidden");
50906
+ setProp(_el$4, "verticalScrollbarOptions", {
50907
+ visible: false
50908
+ });
50909
+ use((value) => {
50910
+ body = value;
50911
+ }, _el$5);
50912
+ setProp(_el$5, "width", "100%");
50913
+ setProp(_el$5, "flexDirection", "column");
50914
+ setProp(_el$5, "onSizeChange", function() {
50915
+ if (disposed)
50916
+ return;
50917
+ const next = Math.max(0, Math.floor(this.height));
50918
+ if (next !== measured())
50919
+ setMeasured(next);
50920
+ });
50921
+ insert(_el$5, () => request().render({
50922
+ id: request().id,
50923
+ close: request().close,
50924
+ width: () => dimensions().width,
50925
+ maxHeight: capRows
50926
+ }));
50927
+ insert(_el$3, createComponent2(Show, {
50928
+ get when() {
50929
+ return memo2(() => !!overflows())() && hiddenRows() > 0;
50930
+ },
50931
+ get children() {
50932
+ var _el$6 = createElement("text");
50933
+ setProp(_el$6, "wrapMode", "none");
50934
+ setProp(_el$6, "paddingLeft", 1);
50935
+ insert(_el$6, indicatorText);
50936
+ effect((_$p) => setProp(_el$6, "fg", muted(), _$p));
50937
+ return _el$6;
50938
+ }
50939
+ }), null);
50940
+ effect((_p$) => {
50941
+ var _v$ = background(), _v$2 = viewportRows();
50942
+ _v$ !== _p$.e && (_p$.e = setProp(_el$3, "backgroundColor", _v$, _p$.e));
50943
+ _v$2 !== _p$.t && (_p$.t = setProp(_el$4, "height", _v$2, _p$.t));
50944
+ return _p$;
50945
+ }, {
50946
+ e: undefined,
50947
+ t: undefined
50948
+ });
50949
+ return _el$3;
50950
+ })()
50951
+ }), null);
50952
+ effect((_$p) => setProp(_el$2, "visible", !dock.isOpen(), _$p));
50953
+ return _el$;
50954
+ })();
50955
+ }
50956
+ var DOCK_MAX_ROWS_RATIO = 0.6, Context7, ordinal2 = 0;
50957
+ var init_dock_host = __esm(() => {
50958
+ init_index_bun();
50959
+ init_index_bun();
50960
+ init_index_bun();
50961
+ init_index_bun();
50962
+ init_index_bun();
50963
+ init_index_bun();
50964
+ init_index_bun();
50965
+ init_index_bun();
50966
+ init_server();
50967
+ init_index_bun();
50968
+ init_input_ownership();
50969
+ init_theme3();
50970
+ init_terminal_size();
50971
+ Context7 = createContext(undefined);
50972
+ });
50973
+
50974
+ // ../tui-base/src/routes/session/ask-panel.tsx
50975
+ function resolveFocus(ask, list, input) {
50976
+ if (ask === undefined)
50977
+ return;
50978
+ if (ask.phase === "input")
50979
+ return input;
50980
+ return list ?? input;
50981
+ }
50982
+ function nearestScroller(node) {
50983
+ let current = node;
50984
+ while (current !== null && current !== undefined) {
50985
+ const candidate = current;
50986
+ if (typeof candidate.scrollChildIntoView === "function")
50987
+ return current;
50988
+ current = current.parent;
50989
+ }
50990
+ return;
50991
+ }
50992
+ function AskPanel(props) {
50993
+ const theme = useThemeOptional();
50994
+ const dock = useDock();
50995
+ let configCursorStyle;
50996
+ try {
50997
+ configCursorStyle = useCursorStyle();
50998
+ } catch {
50999
+ configCursorStyle = undefined;
51000
+ }
51001
+ const [version, setVersion] = createSignal(0);
51002
+ onMount(() => {
51003
+ const unsubscribe = props.controller.subscribe(() => setVersion((value) => value + 1));
51004
+ onCleanup(unsubscribe);
51005
+ });
51006
+ const ask = () => {
51007
+ version();
51008
+ return props.controller.pendingAsk;
51009
+ };
51010
+ const questions = () => ask()?.questions ?? [];
51011
+ const question = () => {
51012
+ const batch = ask();
51013
+ return batch?.questions[batch.index];
51014
+ };
51015
+ const index = () => ask()?.index ?? 0;
51016
+ const phase = () => ask()?.phase ?? "questions";
51017
+ const phaseOf = () => {
51018
+ if (phase() === "review")
51019
+ return "review";
51020
+ return phase() === "input" ? "input" : "options";
51021
+ };
51022
+ const picks = () => {
51023
+ const batch = ask();
51024
+ return batch ? batch.picks[batch.index] ?? [] : [];
51025
+ };
51026
+ const cursor = () => {
51027
+ const batch = ask();
51028
+ return batch ? batch.cursors[batch.index] ?? 0 : 0;
51029
+ };
51030
+ const listCursor = () => {
51031
+ const batch = ask();
51032
+ return batch ? batch.listCursors[batch.index] ?? 0 : 0;
51033
+ };
51034
+ const markedRow = () => phaseOf() === "input" ? listCursor() : cursor();
51035
+ const reviewCursor = () => ask()?.reviewCursor ?? 0;
51036
+ const multi = () => question()?.multiSelect === true;
51037
+ const compact = () => props.width() < ASK_COMPACT_COLUMNS;
51038
+ const needsReview = () => askNeedsReview(questions());
51039
+ const eyebrow = () => {
51040
+ if (phaseOf() === "review")
51041
+ return;
51042
+ const current = question();
51043
+ if (current?.header === undefined || current.header === current.prompt)
51044
+ return;
51045
+ return current.header;
51046
+ };
51047
+ const muted = () => theme?.text.muted ?? "#9aa5ce";
51048
+ const faint = () => theme?.text.faint ?? "#565f89";
51049
+ const base = () => theme?.text.base ?? "#e6e6e6";
51050
+ const accent = () => theme?.hue.interactive[500] ?? "#7aa2f7";
51051
+ const currentBg = () => theme?.background.action.primary.focused;
51052
+ const currentFg = () => theme?.text.action.primary.focused ?? accent();
51053
+ const rule = () => theme?.border.base ?? "#565f89";
51054
+ const cursorShape = () => {
51055
+ try {
51056
+ return configCursorStyle?.()?.style;
51057
+ } catch {
51058
+ return;
51059
+ }
51060
+ };
51061
+ let listEl;
51062
+ let inputEl;
51063
+ let inlineRowEl;
51064
+ useAskKeys({
51065
+ controller: props.controller,
51066
+ input: () => inputEl
51067
+ });
51068
+ const queuedCount = () => {
51069
+ version();
51070
+ return props.queued?.() ?? dock.queueDepth();
51071
+ };
51072
+ props.onFocusTarget?.(() => resolveFocus(ask(), listEl, inputEl));
51073
+ function revealRow(row) {
51074
+ if (row === undefined || row.isDestroyed)
51075
+ return;
51076
+ const scroller = nearestScroller(row);
51077
+ if (scroller === undefined)
51078
+ return;
51079
+ scroller.scrollChildIntoView(row, {
51080
+ align: "nearest"
51081
+ });
51082
+ }
51083
+ function focusInputRow() {
51084
+ const input = inputEl;
51085
+ if (input === undefined || input.isDestroyed)
51086
+ return;
51087
+ input.focus();
51088
+ revealRow(inlineRowEl);
51089
+ }
51090
+ createEffect(on(() => phase(), (next) => {
51091
+ if (next === "input") {
51092
+ focusInputRow();
51093
+ return;
51094
+ }
51095
+ if (next !== "questions")
51096
+ return;
51097
+ const focusList = () => {
51098
+ if (listEl !== undefined && !listEl.isDestroyed)
51099
+ listEl.focus();
51100
+ };
51101
+ if (listEl !== undefined && !listEl.isDestroyed)
51102
+ focusList();
51103
+ else
51104
+ queueMicrotask(focusList);
51105
+ }));
51106
+ createEffect(on(() => index(), () => phase() === "input" ? focusInputRow() : undefined, {
51107
+ defer: true
51108
+ }));
51109
+ createEffect(on([() => index(), cursor], () => {
51110
+ if (phaseOf() !== "options")
51111
+ return;
51112
+ revealRow(listEl?.getChildren()[cursor()]);
51113
+ }));
51114
+ const optionRows = () => (question()?.options ?? []).map((option, position) => ({
51115
+ option,
51116
+ number: position + 1,
51117
+ selected: picks().includes(option.label)
51118
+ }));
51119
+ const labelColumn = (row) => GUTTER + CURSOR_CELLS + STATE_CELLS + `${row.number}. `.length;
51120
+ const footerHint = () => {
51121
+ if (phaseOf() === "review")
51122
+ return t("overlay.ask.footer.review", {
51123
+ esc: t("overlay.ask.esc.review")
51124
+ });
51125
+ if (phaseOf() === "input") {
51126
+ const escKey = question()?.options.length === 0 ? index() > 0 ? "overlay.ask.esc.prevQuestion" : "overlay.ask.esc.decline" : "overlay.ask.esc.back";
51127
+ return t("overlay.ask.footer.input", {
51128
+ esc: t(escKey)
51129
+ });
51130
+ }
51131
+ const escKey = questions().length > 1 && index() > 0 ? "overlay.ask.esc.prevQuestion" : "overlay.ask.esc.decline";
51132
+ return t(multi() ? "overlay.ask.footer.multi" : "overlay.ask.footer.options", {
51133
+ esc: t(escKey)
51134
+ });
51135
+ };
51136
+ const answerText = (qi) => {
51137
+ const batch = ask();
51138
+ if (!batch)
51139
+ return "";
51140
+ const custom = batch.customs[qi];
51141
+ if (custom !== undefined && custom !== "")
51142
+ return custom;
51143
+ return (batch.picks[qi] ?? []).map((label) => splitRecommended(label).label).join(", ");
51144
+ };
51145
+ const reviewRowActive = (qi) => reviewCursor() === qi;
51146
+ const reviewSubmitActive = () => reviewRowIntent(reviewCursor(), questions().length).kind === "submit";
51147
+ return (() => {
51148
+ var _el$ = createElement("box"), _el$2 = createElement("box"), _el$3 = createElement("box"), _el$4 = createElement("text"), _el$1 = createElement("box"), _el$10 = createElement("text"), _el$12 = createElement("box");
51149
+ insertNode(_el$, _el$2);
51150
+ insertNode(_el$, _el$3);
51151
+ insertNode(_el$, _el$1);
51152
+ insertNode(_el$, _el$12);
51153
+ setProp(_el$, "flexDirection", "column");
51154
+ setProp(_el$, "width", "100%");
51155
+ setProp(_el$, "flexShrink", 0);
51156
+ setProp(_el$2, "width", "100%");
51157
+ setProp(_el$2, "flexShrink", 0);
51158
+ setProp(_el$2, "border", ["top"]);
51159
+ setProp(_el$2, "borderStyle", "single");
51160
+ insert(_el$, createComponent2(Show, {
51161
+ get when() {
51162
+ return eyebrow();
51163
+ },
51164
+ children: (header) => (() => {
51165
+ var _el$13 = createElement("box"), _el$14 = createElement("text");
51166
+ insertNode(_el$13, _el$14);
51167
+ setProp(_el$13, "paddingLeft", 2);
51168
+ setProp(_el$13, "paddingRight", 2);
51169
+ setProp(_el$14, "wrapMode", "none");
51170
+ insert(_el$14, header);
51171
+ effect((_$p) => setProp(_el$14, "fg", muted(), _$p));
51172
+ return _el$13;
51173
+ })()
51174
+ }), _el$3);
51175
+ insertNode(_el$3, _el$4);
51176
+ setProp(_el$3, "paddingLeft", 2);
51177
+ setProp(_el$3, "paddingRight", 2);
51178
+ setProp(_el$4, "wrapMode", "word");
51179
+ insert(_el$4, (() => {
51180
+ var _c$ = memo2(() => phaseOf() === "review");
51181
+ return () => _c$() ? t("overlay.ask.reviewTitle") : question()?.prompt ?? "";
51182
+ })());
51183
+ insert(_el$, createComponent2(Show, {
51184
+ get when() {
51185
+ return questions().length >= 2;
51186
+ },
51187
+ get children() {
51188
+ var _el$5 = createElement("box"), _el$6 = createElement("text");
51189
+ insertNode(_el$5, _el$6);
51190
+ setProp(_el$5, "paddingLeft", 2);
51191
+ setProp(_el$5, "paddingRight", 2);
51192
+ setProp(_el$6, "wrapMode", "none");
51193
+ insert(_el$6, () => askTabStrip(questions(), ask()?.picks ?? [], index(), ask()?.customs));
51194
+ effect((_$p) => setProp(_el$6, "fg", muted(), _$p));
51195
+ return _el$5;
51196
+ }
51197
+ }), _el$1);
51198
+ insert(_el$, createComponent2(Show, {
51199
+ get when() {
51200
+ return memo2(() => phaseOf() !== "review")() ? question()?.detail : undefined;
51201
+ },
51202
+ children: (detail) => (() => {
51203
+ var _el$15 = createElement("box"), _el$16 = createElement("text");
51204
+ insertNode(_el$15, _el$16);
51205
+ setProp(_el$15, "paddingLeft", 2);
51206
+ setProp(_el$15, "paddingRight", 2);
51207
+ setProp(_el$16, "wrapMode", "word");
51208
+ insert(_el$16, detail);
51209
+ effect((_$p) => setProp(_el$16, "fg", muted(), _$p));
51210
+ return _el$15;
51211
+ })()
51212
+ }), _el$1);
51213
+ insert(_el$, createComponent2(Show, {
51214
+ get when() {
51215
+ return phaseOf() === "review";
51216
+ },
51217
+ get fallback() {
51218
+ return [(() => {
51219
+ var _el$17 = createElement("box");
51220
+ use((value) => {
51221
+ listEl = value;
51222
+ }, _el$17);
51223
+ setProp(_el$17, "flexDirection", "column");
51224
+ setProp(_el$17, "width", "100%");
51225
+ setProp(_el$17, "flexShrink", 0);
51226
+ setProp(_el$17, "focusable", true);
51227
+ insert(_el$17, createComponent2(Index, {
51228
+ get each() {
51229
+ return optionRows();
51230
+ },
51231
+ children: (row, position) => createComponent2(OptionRow, {
51232
+ row,
51233
+ cursor: () => phaseOf() !== "input" && position === cursor(),
51234
+ marked: () => position === markedRow(),
51235
+ multi: () => multi(),
51236
+ compact: () => compact(),
51237
+ width: () => props.width(),
51238
+ labelColumn: () => labelColumn(row())
51239
+ })
51240
+ }), null);
51241
+ insert(_el$17, createComponent2(Show, {
51242
+ get when() {
51243
+ return memo2(() => question() !== undefined)() && hasReviewRow(question(), needsReview());
51244
+ },
51245
+ get children() {
51246
+ var _el$18 = createElement("box"), _el$19 = createElement("text"), _el$20 = createElement("text");
51247
+ insertNode(_el$18, _el$19);
51248
+ insertNode(_el$18, _el$20);
51249
+ setProp(_el$18, "flexDirection", "row");
51250
+ setProp(_el$18, "width", "100%");
51251
+ setProp(_el$18, "flexShrink", 0);
51252
+ setProp(_el$18, "paddingLeft", 2);
51253
+ insert(_el$19, () => markedRow() === (question()?.options.length ?? 0) ? "\u203A " : " ");
51254
+ setProp(_el$20, "wrapMode", "word");
51255
+ insert(_el$20, () => t("overlay.ask.reviewRow"));
51256
+ effect((_p$) => {
51257
+ var _v$8 = phaseOf() !== "input" && markedRow() === (question()?.options.length ?? 0) ? currentBg() : undefined, _v$9 = phaseOf() !== "input" && markedRow() === (question()?.options.length ?? 0) ? accent() : faint(), _v$0 = phaseOf() !== "input" && markedRow() === (question()?.options.length ?? 0) ? currentFg() : muted();
51258
+ _v$8 !== _p$.e && (_p$.e = setProp(_el$18, "backgroundColor", _v$8, _p$.e));
51259
+ _v$9 !== _p$.t && (_p$.t = setProp(_el$19, "fg", _v$9, _p$.t));
51260
+ _v$0 !== _p$.a && (_p$.a = setProp(_el$20, "fg", _v$0, _p$.a));
51261
+ return _p$;
51262
+ }, {
51263
+ e: undefined,
51264
+ t: undefined,
51265
+ a: undefined
51266
+ });
51267
+ return _el$18;
51268
+ }
51269
+ }), null);
51270
+ return _el$17;
51271
+ })(), (() => {
51272
+ var _el$21 = createElement("box"), _el$22 = createElement("text"), _el$24 = createElement("input");
51273
+ insertNode(_el$21, _el$22);
51274
+ insertNode(_el$21, _el$24);
51275
+ use((value) => {
51276
+ inlineRowEl = value;
51277
+ }, _el$21);
51278
+ setProp(_el$21, "flexDirection", "row");
51279
+ setProp(_el$21, "width", "100%");
51280
+ setProp(_el$21, "flexShrink", 0);
51281
+ setProp(_el$21, "paddingLeft", 2);
51282
+ insertNode(_el$22, createTextNode(`\u270E `));
51283
+ use((value) => {
51284
+ inputEl = value;
51285
+ }, _el$24);
51286
+ setProp(_el$24, "flexGrow", 1);
51287
+ setProp(_el$24, "onInput", (value) => props.controller.setInlineText(value));
51288
+ setProp(_el$24, "onSubmit", () => props.controller.commitCustom());
51289
+ effect((_p$) => {
51290
+ var _v$1 = phaseOf() === "input" ? currentBg() : undefined, _v$10 = phaseOf() === "input" ? currentFg() : muted(), _v$11 = props.controller.inlineText, _v$12 = t("overlay.ask.inputPlaceholder"), _v$13 = muted(), _v$14 = base(), _v$15 = currentFg(), _v$16 = phaseOf() === "input" ? currentFg() : accent(), _v$17 = cursorShape();
51291
+ _v$1 !== _p$.e && (_p$.e = setProp(_el$21, "backgroundColor", _v$1, _p$.e));
51292
+ _v$10 !== _p$.t && (_p$.t = setProp(_el$22, "fg", _v$10, _p$.t));
51293
+ _v$11 !== _p$.a && (_p$.a = setProp(_el$24, "value", _v$11, _p$.a));
51294
+ _v$12 !== _p$.o && (_p$.o = setProp(_el$24, "placeholder", _v$12, _p$.o));
51295
+ _v$13 !== _p$.i && (_p$.i = setProp(_el$24, "placeholderColor", _v$13, _p$.i));
51296
+ _v$14 !== _p$.n && (_p$.n = setProp(_el$24, "textColor", _v$14, _p$.n));
51297
+ _v$15 !== _p$.s && (_p$.s = setProp(_el$24, "focusedTextColor", _v$15, _p$.s));
51298
+ _v$16 !== _p$.h && (_p$.h = setProp(_el$24, "cursorColor", _v$16, _p$.h));
51299
+ _v$17 !== _p$.r && (_p$.r = setProp(_el$24, "cursorStyle", _v$17, _p$.r));
51300
+ return _p$;
51301
+ }, {
51302
+ e: undefined,
51303
+ t: undefined,
51304
+ a: undefined,
51305
+ o: undefined,
51306
+ i: undefined,
51307
+ n: undefined,
51308
+ s: undefined,
51309
+ h: undefined,
51310
+ r: undefined
51311
+ });
51312
+ return _el$21;
51313
+ })()];
51314
+ },
51315
+ get children() {
51316
+ var _el$7 = createElement("box"), _el$8 = createElement("box"), _el$9 = createElement("text"), _el$0 = createElement("text");
51317
+ insertNode(_el$7, _el$8);
51318
+ setProp(_el$7, "flexDirection", "column");
51319
+ setProp(_el$7, "width", "100%");
51320
+ setProp(_el$7, "flexShrink", 0);
51321
+ insert(_el$7, createComponent2(Index, {
51322
+ get each() {
51323
+ return questions();
51324
+ },
51325
+ children: (item, qi) => (() => {
51326
+ var _el$25 = createElement("box"), _el$26 = createElement("box"), _el$27 = createElement("text"), _el$28 = createElement("text"), _el$30 = createElement("text"), _el$31 = createElement("box"), _el$32 = createElement("text");
51327
+ insertNode(_el$25, _el$26);
51328
+ insertNode(_el$25, _el$31);
51329
+ setProp(_el$25, "flexDirection", "column");
51330
+ setProp(_el$25, "width", "100%");
51331
+ setProp(_el$25, "flexShrink", 0);
51332
+ insertNode(_el$26, _el$27);
51333
+ insertNode(_el$26, _el$28);
51334
+ insertNode(_el$26, _el$30);
51335
+ setProp(_el$26, "flexDirection", "row");
51336
+ setProp(_el$26, "width", "100%");
51337
+ setProp(_el$26, "flexShrink", 0);
51338
+ setProp(_el$26, "paddingLeft", 2);
51339
+ insert(_el$27, () => reviewRowActive(qi) ? "\u203A " : " ");
51340
+ insertNode(_el$28, createTextNode(`\u2713 `));
51341
+ setProp(_el$30, "wrapMode", "word");
51342
+ insert(_el$30, () => item().prompt);
51343
+ insertNode(_el$31, _el$32);
51344
+ setProp(_el$31, "paddingLeft", 6);
51345
+ setProp(_el$32, "wrapMode", "word");
51346
+ insert(_el$32, () => `\u2192 ${answerText(qi) !== "" ? answerText(qi) : t("overlay.ask.unanswered")}`);
51347
+ effect((_p$) => {
51348
+ var _v$18 = reviewRowActive(qi) ? currentBg() : undefined, _v$19 = reviewRowActive(qi) ? currentFg() : accent(), _v$20 = reviewRowActive(qi) ? currentFg() : muted(), _v$21 = reviewRowActive(qi) ? currentFg() : base(), _v$22 = answerText(qi) !== "" ? accent() : faint();
51349
+ _v$18 !== _p$.e && (_p$.e = setProp(_el$26, "backgroundColor", _v$18, _p$.e));
51350
+ _v$19 !== _p$.t && (_p$.t = setProp(_el$27, "fg", _v$19, _p$.t));
51351
+ _v$20 !== _p$.a && (_p$.a = setProp(_el$28, "fg", _v$20, _p$.a));
51352
+ _v$21 !== _p$.o && (_p$.o = setProp(_el$30, "fg", _v$21, _p$.o));
51353
+ _v$22 !== _p$.i && (_p$.i = setProp(_el$32, "fg", _v$22, _p$.i));
51354
+ return _p$;
51355
+ }, {
51356
+ e: undefined,
51357
+ t: undefined,
51358
+ a: undefined,
51359
+ o: undefined,
51360
+ i: undefined
51361
+ });
51362
+ return _el$25;
51363
+ })()
51364
+ }), _el$8);
51365
+ insertNode(_el$8, _el$9);
51366
+ insertNode(_el$8, _el$0);
51367
+ setProp(_el$8, "flexDirection", "row");
51368
+ setProp(_el$8, "width", "100%");
51369
+ setProp(_el$8, "flexShrink", 0);
51370
+ setProp(_el$8, "paddingLeft", 2);
51371
+ insert(_el$9, () => reviewSubmitActive() ? "\u203A " : " ");
51372
+ setProp(_el$0, "wrapMode", "none");
51373
+ insert(_el$0, () => t("overlay.ask.submitRow"));
51374
+ effect((_p$) => {
51375
+ var _v$ = reviewSubmitActive() ? currentBg() : undefined, _v$2 = reviewSubmitActive() ? currentFg() : accent(), _v$3 = reviewSubmitActive() ? currentFg() : base();
51376
+ _v$ !== _p$.e && (_p$.e = setProp(_el$8, "backgroundColor", _v$, _p$.e));
51377
+ _v$2 !== _p$.t && (_p$.t = setProp(_el$9, "fg", _v$2, _p$.t));
51378
+ _v$3 !== _p$.a && (_p$.a = setProp(_el$0, "fg", _v$3, _p$.a));
51379
+ return _p$;
51380
+ }, {
51381
+ e: undefined,
51382
+ t: undefined,
51383
+ a: undefined
51384
+ });
51385
+ return _el$7;
51386
+ }
51387
+ }), _el$1);
51388
+ insertNode(_el$1, _el$10);
51389
+ setProp(_el$1, "flexDirection", "row");
51390
+ setProp(_el$1, "width", "100%");
51391
+ setProp(_el$1, "justifyContent", "space-between");
51392
+ setProp(_el$1, "paddingLeft", 2);
51393
+ setProp(_el$1, "paddingRight", 2);
51394
+ setProp(_el$10, "wrapMode", "none");
51395
+ insert(_el$10, footerHint);
51396
+ insert(_el$1, createComponent2(Show, {
51397
+ get when() {
51398
+ return queuedCount() > 0;
51399
+ },
51400
+ get children() {
51401
+ var _el$11 = createElement("text");
51402
+ setProp(_el$11, "wrapMode", "none");
51403
+ insert(_el$11, () => t("overlay.ask.queued", {
51404
+ count: queuedCount()
51405
+ }));
51406
+ effect((_$p) => setProp(_el$11, "fg", muted(), _$p));
51407
+ return _el$11;
51408
+ }
51409
+ }), null);
51410
+ setProp(_el$12, "width", "100%");
51411
+ setProp(_el$12, "flexShrink", 0);
51412
+ setProp(_el$12, "border", ["bottom"]);
51413
+ setProp(_el$12, "borderStyle", "single");
51414
+ effect((_p$) => {
51415
+ var _v$4 = rule(), _v$5 = warningColor(theme), _v$6 = muted(), _v$7 = rule();
51416
+ _v$4 !== _p$.e && (_p$.e = setProp(_el$2, "borderColor", _v$4, _p$.e));
51417
+ _v$5 !== _p$.t && (_p$.t = setProp(_el$4, "fg", _v$5, _p$.t));
51418
+ _v$6 !== _p$.a && (_p$.a = setProp(_el$10, "fg", _v$6, _p$.a));
51419
+ _v$7 !== _p$.o && (_p$.o = setProp(_el$12, "borderColor", _v$7, _p$.o));
51420
+ return _p$;
51421
+ }, {
51422
+ e: undefined,
51423
+ t: undefined,
51424
+ a: undefined,
51425
+ o: undefined
51426
+ });
51427
+ return _el$;
51428
+ })();
51429
+ }
51430
+ function OptionRow(props) {
51431
+ const theme = useThemeOptional();
51432
+ const muted = () => theme?.text.muted ?? "#9aa5ce";
51433
+ const faint = () => theme?.text.faint ?? "#565f89";
51434
+ const base = () => theme?.text.base ?? "#e6e6e6";
51435
+ const accent = () => theme?.hue.interactive[500] ?? "#7aa2f7";
51436
+ const success = () => theme?.text.feedback.success.base ?? "#9ece6a";
51437
+ const currentBg = () => theme?.background.action.primary.focused;
51438
+ const currentFg = () => theme?.text.action.primary.focused ?? accent();
51439
+ const label = () => splitRecommended(props.row().option.label);
51440
+ const number = () => `${props.row().number}. `;
51441
+ const badge = () => `[${t("overlay.ask.recommended")}]`;
51442
+ const stateGlyph = () => {
51443
+ if (props.multi())
51444
+ return props.row().selected ? "\u25A0 " : "\u25A1 ";
51445
+ return props.row().selected ? "\u25CF " : "\u25CB ";
51446
+ };
51447
+ const stateColor = () => {
51448
+ if (props.cursor())
51449
+ return currentFg();
51450
+ return props.row().selected ? success() : faint();
51451
+ };
51452
+ const badgeInline = () => {
51453
+ if (!label().recommended || props.compact())
51454
+ return false;
51455
+ const used = props.labelColumn() + stringWidth(label().label) + BADGE_GAP + stringWidth(badge());
51456
+ return used <= props.width();
51457
+ };
51458
+ const labelColor = () => props.cursor() ? currentFg() : base();
51459
+ return (() => {
51460
+ var _el$33 = createElement("box"), _el$34 = createElement("box"), _el$35 = createElement("text"), _el$36 = createElement("text"), _el$37 = createElement("text"), _el$38 = createElement("text");
51461
+ insertNode(_el$33, _el$34);
51462
+ setProp(_el$33, "flexDirection", "column");
51463
+ setProp(_el$33, "width", "100%");
51464
+ setProp(_el$33, "flexShrink", 0);
51465
+ insertNode(_el$34, _el$35);
51466
+ insertNode(_el$34, _el$36);
51467
+ insertNode(_el$34, _el$37);
51468
+ insertNode(_el$34, _el$38);
51469
+ setProp(_el$34, "flexDirection", "row");
51470
+ setProp(_el$34, "width", "100%");
51471
+ setProp(_el$34, "flexShrink", 0);
51472
+ setProp(_el$34, "paddingLeft", 2);
51473
+ insert(_el$35, () => props.marked() ? "\u203A " : " ");
51474
+ insert(_el$36, stateGlyph);
51475
+ insert(_el$37, number);
51476
+ setProp(_el$38, "wrapMode", "word");
51477
+ insert(_el$38, () => label().label);
51478
+ insert(_el$34, createComponent2(Show, {
51479
+ get when() {
51480
+ return badgeInline();
51481
+ },
51482
+ get children() {
51483
+ var _el$39 = createElement("text");
51484
+ insert(_el$39, () => ` ${badge()}`);
51485
+ effect((_$p) => setProp(_el$39, "fg", props.cursor() ? currentFg() : success(), _$p));
51486
+ return _el$39;
51487
+ }
51488
+ }), null);
51489
+ insert(_el$33, createComponent2(Show, {
51490
+ get when() {
51491
+ return memo2(() => !!label().recommended)() && !badgeInline();
51492
+ },
51493
+ get children() {
51494
+ var _el$40 = createElement("box"), _el$41 = createElement("text");
51495
+ insertNode(_el$40, _el$41);
51496
+ setProp(_el$41, "wrapMode", "none");
51497
+ insert(_el$41, badge);
51498
+ effect((_p$) => {
51499
+ var _v$23 = props.labelColumn(), _v$24 = success();
51500
+ _v$23 !== _p$.e && (_p$.e = setProp(_el$40, "paddingLeft", _v$23, _p$.e));
51501
+ _v$24 !== _p$.t && (_p$.t = setProp(_el$41, "fg", _v$24, _p$.t));
51502
+ return _p$;
51503
+ }, {
51504
+ e: undefined,
51505
+ t: undefined
51506
+ });
51507
+ return _el$40;
51508
+ }
51509
+ }), null);
51510
+ insert(_el$33, createComponent2(Show, {
51511
+ get when() {
51512
+ return props.row().option.description;
51513
+ },
51514
+ children: (description) => (() => {
51515
+ var _el$42 = createElement("box"), _el$43 = createElement("text");
51516
+ insertNode(_el$42, _el$43);
51517
+ setProp(_el$43, "wrapMode", "word");
51518
+ insert(_el$43, description);
51519
+ effect((_p$) => {
51520
+ var _v$31 = props.labelColumn(), _v$32 = muted();
51521
+ _v$31 !== _p$.e && (_p$.e = setProp(_el$42, "paddingLeft", _v$31, _p$.e));
51522
+ _v$32 !== _p$.t && (_p$.t = setProp(_el$43, "fg", _v$32, _p$.t));
51523
+ return _p$;
51524
+ }, {
51525
+ e: undefined,
51526
+ t: undefined
51527
+ });
51528
+ return _el$42;
51529
+ })()
51530
+ }), null);
51531
+ effect((_p$) => {
51532
+ var _v$25 = props.cursor() ? currentBg() : undefined, _v$26 = props.cursor() ? currentFg() : faint(), _v$27 = stateColor(), _v$28 = props.cursor() ? currentFg() : faint(), _v$29 = labelColor(), _v$30 = badgeInline() ? 0 : 1;
51533
+ _v$25 !== _p$.e && (_p$.e = setProp(_el$34, "backgroundColor", _v$25, _p$.e));
51534
+ _v$26 !== _p$.t && (_p$.t = setProp(_el$35, "fg", _v$26, _p$.t));
51535
+ _v$27 !== _p$.a && (_p$.a = setProp(_el$36, "fg", _v$27, _p$.a));
51536
+ _v$28 !== _p$.o && (_p$.o = setProp(_el$37, "fg", _v$28, _p$.o));
51537
+ _v$29 !== _p$.i && (_p$.i = setProp(_el$38, "fg", _v$29, _p$.i));
51538
+ _v$30 !== _p$.n && (_p$.n = setProp(_el$38, "flexGrow", _v$30, _p$.n));
51539
+ return _p$;
51540
+ }, {
51541
+ e: undefined,
51542
+ t: undefined,
51543
+ a: undefined,
51544
+ o: undefined,
51545
+ i: undefined,
51546
+ n: undefined
51547
+ });
51548
+ return _el$33;
51549
+ })();
51550
+ }
51551
+ var ASK_COMPACT_COLUMNS = 64, GUTTER = 2, CURSOR_CELLS = 2, STATE_CELLS = 2, BADGE_GAP = 2;
51552
+ var init_ask_panel = __esm(() => {
51553
+ init_index_bun();
51554
+ init_index_bun();
51555
+ init_index_bun();
51556
+ init_index_bun();
51557
+ init_index_bun();
51558
+ init_index_bun();
51559
+ init_index_bun();
51560
+ init_index_bun();
51561
+ init_index_bun();
51562
+ init_server();
51563
+ init_i18n();
51564
+ init_theme3();
51565
+ init_config();
51566
+ init_semantic();
51567
+ init_ask_options();
51568
+ init_ask_keys();
51569
+ init_dock_host();
51570
+ init_string_width();
51571
+ });
51572
+
49966
51573
  // ../tui-base/src/routes/session/turn-overlays.tsx
49967
51574
  function summarizeArgs(name, args, limit = 160) {
49968
51575
  let body = JSON.stringify(args);
@@ -50015,408 +51622,41 @@ function ReminderBadge() {
50015
51622
  return _el$;
50016
51623
  })();
50017
51624
  }
50018
- function askTabStrip(questions, picks, index, customs) {
50019
- return questions.map((_, qi) => {
50020
- const answered = (picks[qi]?.length ?? 0) > 0 || customs?.[qi] !== undefined && customs[qi] !== "";
50021
- const label = `${qi + 1}${answered ? "\u2713" : ""}`;
50022
- return qi === index ? `[${label}]` : label;
50023
- }).join(" \xB7 ");
50024
- }
50025
- function askSentinelTitle(custom) {
50026
- return custom ? t("overlay.ask.customMark", {
50027
- answer: custom
50028
- }) : t("overlay.ask.sentinelLabel");
50029
- }
50030
- function askProgressTitle(questions, index) {
50031
- if (questions.length < 2)
50032
- return t("overlay.ask.question");
50033
- return t("overlay.ask.questionProgress", {
50034
- index: String(index + 1),
50035
- total: String(questions.length)
50036
- });
50037
- }
50038
- function askNeedsReview(questions) {
50039
- return questions.length >= 2 || questions.some((question) => question.multiSelect === true);
50040
- }
50041
- function truncate70(text) {
50042
- return text.length > 70 ? text.slice(0, 69) + "\u2026" : text;
50043
- }
50044
- function AskPicker(props) {
50045
- const [version, setVersion] = createSignal(0);
50046
- onMount(() => {
50047
- const unsubscribe = props.controller.subscribe(() => setVersion((v) => v + 1));
50048
- onCleanup(unsubscribe);
50049
- });
50050
- const ask = () => {
50051
- version();
50052
- return props.controller.pendingAsk;
50053
- };
50054
- return createComponent2(Show, {
50055
- get when() {
50056
- return memo2(() => ask() !== undefined)() && ask()?.customDraft !== null;
50057
- },
50058
- get fallback() {
50059
- return createComponent2(Show, {
50060
- get when() {
50061
- return ask()?.phase === "review";
50062
- },
50063
- get fallback() {
50064
- return createComponent2(AskQuestionsView, {
50065
- ask,
50066
- get controller() {
50067
- return props.controller;
50068
- },
50069
- get onDecline() {
50070
- return props.onDecline;
50071
- }
50072
- });
50073
- },
50074
- get children() {
50075
- return createComponent2(AskReviewView, {
50076
- ask,
50077
- get controller() {
50078
- return props.controller;
50079
- },
50080
- get onDecline() {
50081
- return props.onDecline;
50082
- }
50083
- });
50084
- }
50085
- });
50086
- },
50087
- get children() {
50088
- return createComponent2(AskCustomInputView, {
50089
- ask,
50090
- get controller() {
50091
- return props.controller;
50092
- },
50093
- get onDecline() {
50094
- return props.onDecline;
50095
- }
50096
- });
50097
- }
50098
- });
50099
- }
50100
- function askQuestionRows(question, picks, custom, review) {
50101
- const multi = question.multiSelect === true;
50102
- const rows = question.options.map((option) => ({
50103
- title: multi ? picks.includes(option) ? t("overlay.ask.checkedOption", {
50104
- option
50105
- }) : t("overlay.ask.uncheckedOption", {
50106
- option
50107
- }) : option,
50108
- value: option
50109
- }));
50110
- rows.push({
50111
- title: askSentinelTitle(custom),
50112
- value: {
50113
- kind: "custom"
50114
- }
50115
- });
50116
- if (review)
50117
- rows.push({
50118
- title: t("overlay.ask.reviewRow"),
50119
- value: {
50120
- kind: "review"
50121
- }
50122
- });
50123
- return rows;
50124
- }
50125
- function AskQuestionsView(props) {
50126
- const batch = () => props.ask();
50127
- const question = () => {
50128
- const b = batch();
50129
- return b?.questions[b.index];
50130
- };
50131
- const multi = () => question()?.multiSelect === true;
50132
- const picked = () => {
50133
- const b = batch();
50134
- return b?.picks[b.index] ?? [];
50135
- };
50136
- const bIndex = () => batch()?.index ?? 0;
50137
- const options = () => {
50138
- const q = question();
50139
- if (!q)
50140
- return [];
50141
- return askQuestionRows(q, picked(), batch()?.customs[bIndex()], askNeedsReview(batch()?.questions ?? []));
50142
- };
50143
- const description = () => {
50144
- const b = batch();
50145
- if (!b)
50146
- return;
50147
- const parts = [];
50148
- if (b.questions.length >= 2)
50149
- parts.push(askTabStrip(b.questions, b.picks, b.index, b.customs));
50150
- if (multi())
50151
- parts.push(t("overlay.ask.spaceToggle"));
50152
- return parts.join(" \xB7 ") || undefined;
50153
- };
50154
- const toggleHighlighted = () => {
50155
- const option = selectRefRef?.selected;
50156
- if (option && typeof option.value === "string")
50157
- props.controller.toggle(option.value);
50158
- };
50159
- const bindings = () => {
50160
- const b = batch();
50161
- return [...b && b.questions.length >= 2 ? [{
50162
- id: "ask.prev_question",
50163
- title: t("overlay.ask.prevQuestion"),
50164
- group: "Dialog",
50165
- bind: "left",
50166
- run: () => props.controller.switchFocus(-1)
50167
- }, {
50168
- id: "ask.next_question",
50169
- title: t("overlay.ask.nextQuestion"),
50170
- group: "Dialog",
50171
- bind: "right",
50172
- run: () => props.controller.switchFocus(1)
50173
- }] : [], {
50174
- id: "ask.toggle",
50175
- title: t("overlay.ask.toggleOption"),
50176
- group: "Dialog",
50177
- bind: "space",
50178
- run: toggleHighlighted
50179
- }];
50180
- };
50181
- const title = () => {
50182
- const b = batch();
50183
- const q = question();
50184
- if (!b || !q)
50185
- return "";
50186
- return t("overlay.ask.title", {
50187
- title: askProgressTitle(b.questions, b.index),
50188
- prompt: truncate70(q.prompt)
50189
- });
50190
- };
50191
- let selectRefRef;
50192
- return createComponent2(DialogSelect, {
50193
- get titleView() {
50194
- return (() => {
50195
- var _el$3 = createElement("box");
50196
- setProp(_el$3, "flexDirection", "row");
50197
- insert(_el$3, createComponent2(ReminderBadge, {}), null);
50198
- insert(_el$3, createComponent2(AskTitleText, {
50199
- get title() {
50200
- return title();
50201
- }
50202
- }), null);
50203
- return _el$3;
50204
- })();
50205
- },
50206
- get title() {
50207
- return title();
50208
- },
50209
- get description() {
50210
- return description();
50211
- },
50212
- renderFilter: false,
50213
- get options() {
50214
- return options();
50215
- },
50216
- get current() {
50217
- return memo2(() => !!multi())() ? undefined : picked()[0];
50218
- },
50219
- ref: (r) => selectRefRef = r,
50220
- get bindings() {
50221
- return bindings();
50222
- },
50223
- onSelect: (option) => {
50224
- if (typeof option.value === "string")
50225
- props.controller.toggle(option.value);
50226
- else if (option.value.kind === "custom")
50227
- props.controller.beginCustom();
50228
- else
50229
- props.controller.enterReview();
50230
- },
50231
- get onCancel() {
50232
- return props.onDecline;
50233
- }
50234
- });
50235
- }
50236
- function AskCustomInputView(props) {
50237
- const theme = useThemeOptional();
50238
- const cursorStyle = useCursorStyle();
50239
- Keymap2.createLayer(() => ({
50240
- mode: "modal",
50241
- commands: [{
50242
- id: "ask.custom_cancel",
50243
- title: t("overlay.ask.customBackToOptions"),
50244
- group: "Dialog",
50245
- bind: "escape",
50246
- run: () => props.controller.cancelCustomEdit()
50247
- }]
50248
- }));
50249
- return createComponent2(DialogLayout, {
50250
- get header() {
50251
- return (() => {
50252
- var _el$5 = createElement("box"), _el$6 = createElement("text");
50253
- insertNode(_el$5, _el$6);
50254
- setProp(_el$5, "paddingLeft", DIALOG_LIST_INSET - 1);
50255
- setProp(_el$5, "paddingRight", DIALOG_LIST_INSET - 1);
50256
- insert(_el$5, createComponent2(DialogHeader, {
50257
- get titleView() {
50258
- return (() => {
50259
- var _el$7 = createElement("box");
50260
- setProp(_el$7, "flexDirection", "row");
50261
- insert(_el$7, createComponent2(ReminderBadge, {}), null);
50262
- insert(_el$7, createComponent2(AskTitleText, {
50263
- get title() {
50264
- return t("overlay.ask.customTitle");
50265
- }
50266
- }), null);
50267
- return _el$7;
50268
- })();
50269
- },
50270
- get title() {
50271
- return t("overlay.ask.customTitle");
50272
- }
50273
- }), _el$6);
50274
- setProp(_el$6, "wrapMode", "word");
50275
- insert(_el$6, () => props.ask()?.questions[props.ask()?.index ?? 0]?.prompt);
50276
- effect((_$p) => setProp(_el$6, "fg", theme?.text.muted, _$p));
50277
- return _el$5;
50278
- })();
50279
- },
50280
- get children() {
50281
- var _el$4 = createElement("input");
50282
- use((r) => {
50283
- setTimeout(() => {
50284
- if (!r.isDestroyed)
50285
- r.focus();
50286
- }, 1);
50287
- }, _el$4);
50288
- setProp(_el$4, "flexGrow", 1);
50289
- setProp(_el$4, "onInput", (text) => props.controller.patchCustom(text));
50290
- setProp(_el$4, "onSubmit", () => props.controller.commitCustom());
50291
- effect((_p$) => {
50292
- var _v$ = props.ask()?.customDraft ?? "", _v$2 = t("overlay.ask.sentinelLabel"), _v$3 = theme?.text.muted, _v$4 = theme?.background.formfield.focused, _v$5 = theme?.text.formfield.focused, _v$6 = theme?.text.formfield.focused, _v$7 = cursorStyle();
50293
- _v$ !== _p$.e && (_p$.e = setProp(_el$4, "value", _v$, _p$.e));
50294
- _v$2 !== _p$.t && (_p$.t = setProp(_el$4, "placeholder", _v$2, _p$.t));
50295
- _v$3 !== _p$.a && (_p$.a = setProp(_el$4, "placeholderColor", _v$3, _p$.a));
50296
- _v$4 !== _p$.o && (_p$.o = setProp(_el$4, "focusedBackgroundColor", _v$4, _p$.o));
50297
- _v$5 !== _p$.i && (_p$.i = setProp(_el$4, "focusedTextColor", _v$5, _p$.i));
50298
- _v$6 !== _p$.n && (_p$.n = setProp(_el$4, "cursorColor", _v$6, _p$.n));
50299
- _v$7 !== _p$.s && (_p$.s = setProp(_el$4, "cursorStyle", _v$7, _p$.s));
50300
- return _p$;
50301
- }, {
50302
- e: undefined,
50303
- t: undefined,
50304
- a: undefined,
50305
- o: undefined,
50306
- i: undefined,
50307
- n: undefined,
50308
- s: undefined
50309
- });
50310
- return _el$4;
50311
- }
50312
- });
50313
- }
50314
- function AskTitleText(props) {
50315
- const theme = useThemeOptional();
50316
- return (() => {
50317
- var _el$8 = createElement("text");
50318
- setProp(_el$8, "wrapMode", "none");
50319
- insert(_el$8, () => props.title);
50320
- effect((_$p) => setProp(_el$8, "fg", warningColor(theme), _$p));
50321
- return _el$8;
50322
- })();
50323
- }
50324
- function AskReviewView(props) {
50325
- const options = () => {
50326
- const b = props.ask();
50327
- if (!b)
50328
- return [];
50329
- const rows = b.questions.map((question, qi) => {
50330
- const picks = b.picks[qi] ?? [];
50331
- const custom = b.customs[qi];
50332
- const answer = custom ? t("overlay.ask.customMark", {
50333
- answer: custom
50334
- }) : picks.length > 0 ? picks.join(", ") : "\u2014";
50335
- return {
50336
- title: t("overlay.ask.reviewQuestionRow", {
50337
- prompt: truncate70(question.prompt),
50338
- picks: answer
50339
- }),
50340
- value: {
50341
- kind: "question",
50342
- qi
50343
- }
50344
- };
50345
- });
50346
- rows.push({
50347
- title: t("overlay.ask.submitRow"),
50348
- value: {
50349
- kind: "submit"
50350
- }
50351
- });
50352
- return rows;
50353
- };
50354
- return createComponent2(DialogSelect, {
50355
- get titleView() {
50356
- return (() => {
50357
- var _el$9 = createElement("box");
50358
- setProp(_el$9, "flexDirection", "row");
50359
- insert(_el$9, createComponent2(ReminderBadge, {}), null);
50360
- insert(_el$9, createComponent2(AskTitleText, {
50361
- get title() {
50362
- return t("overlay.ask.reviewTitle");
50363
- }
50364
- }), null);
50365
- return _el$9;
50366
- })();
50367
- },
50368
- get title() {
50369
- return t("overlay.ask.reviewTitle");
50370
- },
50371
- get description() {
50372
- return t("overlay.ask.reviewDescription");
50373
- },
50374
- renderFilter: false,
50375
- get options() {
50376
- return options();
50377
- },
50378
- get bindings() {
50379
- return [{
50380
- id: "ask.back_to_questions",
50381
- title: t("overlay.ask.editAnswers"),
50382
- group: "Dialog",
50383
- bind: "left",
50384
- run: () => props.controller.backToQuestions()
50385
- }];
50386
- },
50387
- onSelect: (option) => {
50388
- if (typeof option.value === "string")
50389
- return;
50390
- if (option.value.kind === "submit")
50391
- props.controller.submit();
50392
- else if (option.value.kind === "question")
50393
- props.controller.backToQuestions(option.value.qi);
50394
- },
50395
- get onCancel() {
50396
- return props.onDecline;
50397
- }
50398
- });
50399
- }
50400
51625
  function TurnOverlayHost(props) {
50401
51626
  const dialog = useDialog();
51627
+ const dock = useDock();
51628
+ const pageOwns = useIsPageOwner();
50402
51629
  const [version, setVersion] = createSignal(0);
50403
51630
  onMount(() => {
50404
- const unsubscribe = props.controller.subscribe(() => setVersion((v) => v + 1));
51631
+ const unsubscribe = props.controller.subscribe(() => setVersion((value) => value + 1));
50405
51632
  onCleanup(unsubscribe);
50406
51633
  });
50407
51634
  props.controller.onIdle(() => {
50408
51635
  setTimeout(() => props.reclaimFocus?.(), 3);
50409
51636
  });
51637
+ let panelFocus;
51638
+ let askHandle;
51639
+ let askId;
50410
51640
  let shown;
51641
+ function closeAsk() {
51642
+ askHandle?.close();
51643
+ askHandle = undefined;
51644
+ askId = undefined;
51645
+ }
50411
51646
  createEffect(() => {
50412
51647
  version();
50413
51648
  const approval = props.controller.pendingApproval;
50414
51649
  const ask = props.controller.pendingAsk;
50415
- const key = approval ? `approval:${approval.id}` : ask ? `ask:${ask.id}` : "";
51650
+ const askShowing = askHandle !== undefined && ask !== undefined && askId === ask.id;
51651
+ const pageOwned = pageOwns();
51652
+ const approvalWins = approval !== undefined && !askShowing;
51653
+ const askAdmitted = ask !== undefined && (askShowing || pageOwned);
51654
+ const key = approvalWins ? `approval:${approval.id}` : askAdmitted ? `ask:${ask.id}` : "";
50416
51655
  if (key === shown)
50417
51656
  return;
50418
51657
  shown = key;
50419
- if (approval) {
51658
+ if (approvalWins) {
51659
+ closeAsk();
50420
51660
  const atOpen = key;
50421
51661
  dialog.replace(() => createComponent2(ApprovalCard, {
50422
51662
  get name() {
@@ -50439,24 +51679,36 @@ function TurnOverlayHost(props) {
50439
51679
  });
50440
51680
  return;
50441
51681
  }
50442
- if (ask) {
50443
- const atOpen = key;
50444
- dialog.replace(() => createComponent2(AskPicker, {
51682
+ if (ask !== undefined && askAdmitted) {
51683
+ if (askHandle !== undefined && askId === ask.id)
51684
+ return;
51685
+ const previous = askHandle;
51686
+ askId = ask.id;
51687
+ askHandle = dock.open((ctx) => createComponent2(AskPanel, {
50445
51688
  get controller() {
50446
51689
  return props.controller;
50447
51690
  },
50448
- onDecline: () => props.controller.decline()
50449
- }), () => {
50450
- if (shown === atOpen)
50451
- props.controller.decline();
50452
- }, {
50453
- tone: "warning"
51691
+ get width() {
51692
+ return ctx.width;
51693
+ },
51694
+ queued: () => Math.max(0, props.controller.pendingAskCount + props.controller.pendingApprovalCount - 1),
51695
+ onFocusTarget: (resolve) => {
51696
+ panelFocus = resolve;
51697
+ }
51698
+ }), {
51699
+ kind: "ask",
51700
+ contentRows: estimateAskRows(ask),
51701
+ focusRef: () => panelFocus?.(),
51702
+ overflowLabel: (hidden) => t("overlay.ask.overflow", {
51703
+ count: hidden
51704
+ })
50454
51705
  });
51706
+ previous?.close();
50455
51707
  return;
50456
51708
  }
50457
- if (untrack(() => dialog.stack.length) > 0)
50458
- dialog.clear();
51709
+ closeAsk();
50459
51710
  });
51711
+ onCleanup(closeAsk);
50460
51712
  return createComponent2(Show, {
50461
51713
  when: false,
50462
51714
  children: null
@@ -50472,21 +51724,19 @@ var init_turn_overlays = __esm(() => {
50472
51724
  init_index_bun();
50473
51725
  init_index_bun();
50474
51726
  init_index_bun();
50475
- init_index_bun();
50476
- init_index_bun();
50477
- init_index_bun();
50478
51727
  init_server();
50479
51728
  init_index_bun();
50480
51729
  init_dialog_confirm();
50481
- init_dialog_select();
50482
51730
  init_dialog();
50483
- init_keymap();
50484
- init_config();
51731
+ init_input_ownership();
50485
51732
  init_theme3();
50486
51733
  init_i18n();
50487
51734
  init_motion();
50488
51735
  init_semantic();
50489
51736
  init_widgets_dock();
51737
+ init_ask_panel();
51738
+ init_ask_options();
51739
+ init_dock_host();
50490
51740
  });
50491
51741
 
50492
51742
  // ../tui-base/src/routes/session/hotkeys.ts
@@ -52549,6 +53799,7 @@ function formatSkillLine(row, selected) {
52549
53799
  function SkillsPanel(props) {
52550
53800
  const theme = useThemeOptional();
52551
53801
  const dialog = useDialog();
53802
+ const pageOwns = useIsPageOwner();
52552
53803
  const [open, setOpen] = useSkillsPanelOpenState();
52553
53804
  const [filterOpen, setFilterOpen] = createSignal(false);
52554
53805
  const [filter, setFilter] = createSignal("");
@@ -52678,7 +53929,7 @@ function SkillsPanel(props) {
52678
53929
  }
52679
53930
  Keymap2.createLayer(() => ({
52680
53931
  mode: "global",
52681
- enabled: open() && dialog.stack.length === 0,
53932
+ enabled: open() && pageOwns(),
52682
53933
  priority: 2,
52683
53934
  commands: [{
52684
53935
  bind: "escape",
@@ -52912,6 +54163,7 @@ var init_skills_panel = __esm(() => {
52912
54163
  init_index_bun();
52913
54164
  init_server();
52914
54165
  init_keymap();
54166
+ init_input_ownership();
52915
54167
  init_i18n();
52916
54168
  init_dialog();
52917
54169
  init_dialog_confirm();
@@ -52958,7 +54210,7 @@ async function resumeSearchHit(options) {
52958
54210
  }
52959
54211
  function SessionsSearch(props) {
52960
54212
  const theme = useThemeOptional();
52961
- const dialog = useDialog();
54213
+ const pageOwns = useIsPageOwner();
52962
54214
  const [open, setOpen] = useSessionsSearchOpenState();
52963
54215
  const [query, setQuery] = createSignal("");
52964
54216
  const [hits, setHits] = createSignal([]);
@@ -53030,7 +54282,7 @@ function SessionsSearch(props) {
53030
54282
  }
53031
54283
  Keymap2.createLayer(() => ({
53032
54284
  mode: "global",
53033
- enabled: open() && dialog.stack.length === 0,
54285
+ enabled: open() && pageOwns(),
53034
54286
  priority: 2,
53035
54287
  commands: [
53036
54288
  {
@@ -53063,7 +54315,7 @@ function SessionsSearch(props) {
53063
54315
  }));
53064
54316
  Keymap2.createLayer(() => ({
53065
54317
  mode: "global",
53066
- enabled: !open() && dialog.stack.length === 0,
54318
+ enabled: !open() && pageOwns(),
53067
54319
  commands: [{
53068
54320
  id: "session.searchSessions",
53069
54321
  title: t("overlay.sessions.keymap.open"),
@@ -53204,9 +54456,9 @@ var init_sessions_search = __esm(() => {
53204
54456
  init_server();
53205
54457
  init_server();
53206
54458
  init_keymap();
53207
- init_dialog();
53208
54459
  init_i18n();
53209
54460
  init_theme3();
54461
+ init_input_ownership();
53210
54462
  [bridgeOpen2, setBridgeOpen2] = createSignal(false);
53211
54463
  [panelOpen3, setPanelOpen3] = createSignal(false);
53212
54464
  sessionsSearchOpen = panelOpen3;
@@ -53309,6 +54561,7 @@ function installPreviewLine(inspection) {
53309
54561
  function PluginsPanel(props) {
53310
54562
  const theme = useThemeOptional();
53311
54563
  const dialog = useDialog();
54564
+ const pageOwns = useIsPageOwner();
53312
54565
  const [open, setOpen] = usePluginsPanelOpenState();
53313
54566
  const [filterOpen, setFilterOpen] = createSignal(false);
53314
54567
  const [filter, setFilter] = createSignal("");
@@ -53555,7 +54808,7 @@ function PluginsPanel(props) {
53555
54808
  }
53556
54809
  Keymap2.createLayer(() => ({
53557
54810
  mode: "global",
53558
- enabled: open() && dialog.stack.length === 0,
54811
+ enabled: open() && pageOwns(),
53559
54812
  priority: 2,
53560
54813
  commands: [{
53561
54814
  bind: "escape",
@@ -53825,6 +55078,7 @@ var init_plugins_panel = __esm(() => {
53825
55078
  init_index_bun();
53826
55079
  init_server();
53827
55080
  init_keymap();
55081
+ init_input_ownership();
53828
55082
  init_i18n();
53829
55083
  init_dialog();
53830
55084
  init_dialog_confirm();
@@ -55961,11 +57215,11 @@ var init_input_row = __esm(() => {
55961
57215
  });
55962
57216
 
55963
57217
  // ../panel-kit/src/kit.tsx
55964
- function createHostKeyAdapter(keymap) {
57218
+ function createHostKeyAdapter(keymap, ownership) {
55965
57219
  const [active, setActive] = createSignal(undefined);
55966
57220
  const disposeLayer = keymap.createLayer(() => ({
55967
57221
  mode: "modal",
55968
- enabled: active() !== undefined,
57222
+ enabled: active() !== undefined && (ownership === undefined || ownership.owns(ownership.topFrame())),
55969
57223
  bindings: PANEL_KEY_IDS.map((id) => ({
55970
57224
  key: id,
55971
57225
  group: "Panel",
@@ -55993,13 +57247,22 @@ function createHostKeyAdapter(keymap) {
55993
57247
  }
55994
57248
  function PanelKitProvider(props) {
55995
57249
  const theme = toAccessor(props.theme);
55996
- const keys = props.keys ?? (props.keymap ? createHostKeyAdapter(props.keymap) : undefined);
57250
+ const [topFrame, setTopFrame] = createSignal(undefined);
57251
+ const ownership = props.ownership ? {
57252
+ push: (kind) => props.ownership.push(kind),
57253
+ pop: (token) => props.ownership.pop(token),
57254
+ owns: (token) => props.ownership.owns(token),
57255
+ topFrame,
57256
+ setTopFrame
57257
+ } : undefined;
57258
+ const keys = props.keys ?? (props.keymap ? createHostKeyAdapter(props.keymap, ownership) : undefined);
55997
57259
  return createComponent2(PanelKitContext.Provider, {
55998
57260
  get value() {
55999
57261
  return {
56000
57262
  theme,
56001
57263
  motion: props.motion,
56002
- keys
57264
+ keys,
57265
+ ownership
56003
57266
  };
56004
57267
  },
56005
57268
  get children() {
@@ -56034,10 +57297,16 @@ function inTree(root, node) {
56034
57297
  function PanelStack(props) {
56035
57298
  const renderer = useRenderer();
56036
57299
  const panelTheme = usePanelTheme();
57300
+ const ownership = usePanelKit()?.ownership;
56037
57301
  const [layers, setLayers] = createSignal([]);
56038
57302
  const handles = new Map;
56039
57303
  let counter = 0;
56040
57304
  let baseFocus = null;
57305
+ onCleanup(() => {
57306
+ for (const entry of layers())
57307
+ ownership?.pop(entry.frame);
57308
+ ownership?.setTopFrame(undefined);
57309
+ });
56041
57310
  const maxDepth = () => props.maxDepth ?? 4;
56042
57311
  const layerScrimAlpha = (index) => {
56043
57312
  const entry = layers()[index];
@@ -56093,6 +57362,8 @@ function PanelStack(props) {
56093
57362
  const next = layers().filter((entry) => entry.id !== id);
56094
57363
  handles.delete(id);
56095
57364
  setLayers(next);
57365
+ ownership?.pop(closing.frame);
57366
+ ownership?.setTopFrame(next.at(-1)?.frame);
56096
57367
  if (next.length === 0)
56097
57368
  restore(baseFocus);
56098
57369
  else
@@ -56103,6 +57374,10 @@ function PanelStack(props) {
56103
57374
  get depth() {
56104
57375
  return Math.max(0, layers().findIndex((item) => item.id === entry.id));
56105
57376
  },
57377
+ get frame() {
57378
+ return entry.frame;
57379
+ },
57380
+ ownsInput: () => ownership !== undefined ? ownership.owns(entry.frame) : layers().at(-1)?.id === entry.id,
56106
57381
  close() {
56107
57382
  if (entry.handle)
56108
57383
  entry.handle.close();
@@ -56131,6 +57406,8 @@ function PanelStack(props) {
56131
57406
  return {
56132
57407
  id,
56133
57408
  depth: 0,
57409
+ frame: undefined,
57410
+ ownsInput: () => false,
56134
57411
  close: () => {},
56135
57412
  closeNow: () => {}
56136
57413
  };
@@ -56139,6 +57416,7 @@ function PanelStack(props) {
56139
57416
  if (layers().length === 0)
56140
57417
  baseFocus = focused;
56141
57418
  focused?.blur();
57419
+ const frame = ownership?.push("panel");
56142
57420
  const entry = {
56143
57421
  id,
56144
57422
  options: {
@@ -56147,9 +57425,11 @@ function PanelStack(props) {
56147
57425
  },
56148
57426
  render,
56149
57427
  focusBefore: focused,
57428
+ frame,
56150
57429
  pendingClose: false
56151
57430
  };
56152
57431
  setLayers((current) => [...current, entry]);
57432
+ ownership?.setTopFrame(frame);
56153
57433
  const handle = makeHandle(entry);
56154
57434
  handles.set(id, handle);
56155
57435
  return handle;
@@ -56170,6 +57450,9 @@ function PanelStack(props) {
56170
57450
  handles.clear();
56171
57451
  setLayers([]);
56172
57452
  });
57453
+ for (const entry of entries)
57454
+ ownership?.pop(entry.frame);
57455
+ ownership?.setTopFrame(undefined);
56173
57456
  restore(baseFocus);
56174
57457
  },
56175
57458
  confirm(options) {
@@ -57929,11 +59212,10 @@ function AgentsPanel(props) {
57929
59212
  return true;
57930
59213
  }
57931
59214
  Keymap2.createLayer(() => {
57932
- const top = panels.top;
57933
59215
  const ownTop = layers().at(-1)?.handle;
57934
59216
  return {
57935
59217
  mode: "global",
57936
- enabled: open() && top !== undefined && top === ownTop,
59218
+ enabled: open() && ownTop?.ownsInput() === true,
57937
59219
  priority: 2,
57938
59220
  commands: [
57939
59221
  {
@@ -58788,6 +60070,7 @@ function HistoryPanel(props) {
58788
60070
  const [sessionCursor, setSessionCursor] = createSignal(0);
58789
60071
  const [showSessions, setShowSessions] = createSignal(false);
58790
60072
  let handle;
60073
+ const [sessionsHandle, setSessionsHandle] = createSignal(undefined);
58791
60074
  let sequence = 0;
58792
60075
  let loadSequence = 0;
58793
60076
  const current = createMemo(() => turns()[cursor()]);
@@ -58901,12 +60184,15 @@ function HistoryPanel(props) {
58901
60184
  setStatus(t("panel.history.status.noSessions"));
58902
60185
  return;
58903
60186
  }
58904
- panels.open(() => renderSessions(), {
60187
+ setSessionsHandle(panels.open(() => renderSessions(), {
58905
60188
  id: `history-sessions-${++sequence}`,
58906
60189
  title: t("panel.history.title.switch"),
58907
60190
  size: "xlarge",
58908
- onClose: () => setShowSessions(false)
58909
- });
60191
+ onClose: () => {
60192
+ setSessionsHandle(undefined);
60193
+ setShowSessions(false);
60194
+ }
60195
+ }));
58910
60196
  } catch (error) {
58911
60197
  setStatus(historyFailureText(t("panel.history.op.sessionList"), error));
58912
60198
  }
@@ -58940,43 +60226,40 @@ function HistoryPanel(props) {
58940
60226
  setStatus(historyFailureText(t("panel.history.op.fork"), error));
58941
60227
  }).finally(() => setBusy(false));
58942
60228
  }
58943
- Keymap2.createLayer(() => {
58944
- const top = panels.top;
58945
- return {
58946
- mode: "global",
58947
- enabled: open() && handle !== undefined && top !== undefined && handle === top,
58948
- priority: 2,
58949
- commands: [{
58950
- bind: "up,k",
58951
- title: t("panel.history.keymap.previousTurn"),
58952
- group: "History",
58953
- run: () => moveCursor(-1)
58954
- }, {
58955
- bind: "down,j",
58956
- title: t("panel.history.keymap.nextTurn"),
58957
- group: "History",
58958
- run: () => moveCursor(1)
58959
- }, {
58960
- bind: "return,c",
58961
- title: showSessions() ? t("panel.history.keymap.pickSession") : t("panel.history.keymap.refill"),
58962
- group: "History",
58963
- run: () => showSessions() ? pickSession(sessionCursor()) : refill()
58964
- }, {
58965
- bind: "s",
58966
- title: t("panel.history.keymap.switchSession"),
58967
- group: "History",
58968
- run: openSessions
58969
- }, {
58970
- bind: "f",
58971
- title: t("panel.history.keymap.fork"),
58972
- group: "History",
58973
- run: fork
58974
- }]
58975
- };
58976
- });
58977
60229
  Keymap2.createLayer(() => ({
58978
60230
  mode: "global",
58979
- enabled: open() && showSessions(),
60231
+ enabled: open() && handle?.ownsInput() === true,
60232
+ priority: 2,
60233
+ commands: [{
60234
+ bind: "up,k",
60235
+ title: t("panel.history.keymap.previousTurn"),
60236
+ group: "History",
60237
+ run: () => moveCursor(-1)
60238
+ }, {
60239
+ bind: "down,j",
60240
+ title: t("panel.history.keymap.nextTurn"),
60241
+ group: "History",
60242
+ run: () => moveCursor(1)
60243
+ }, {
60244
+ bind: "return,c",
60245
+ title: showSessions() ? t("panel.history.keymap.pickSession") : t("panel.history.keymap.refill"),
60246
+ group: "History",
60247
+ run: () => showSessions() ? pickSession(sessionCursor()) : refill()
60248
+ }, {
60249
+ bind: "s",
60250
+ title: t("panel.history.keymap.switchSession"),
60251
+ group: "History",
60252
+ run: openSessions
60253
+ }, {
60254
+ bind: "f",
60255
+ title: t("panel.history.keymap.fork"),
60256
+ group: "History",
60257
+ run: fork
60258
+ }]
60259
+ }));
60260
+ Keymap2.createLayer(() => ({
60261
+ mode: "global",
60262
+ enabled: open() && showSessions() && sessionsHandle()?.ownsInput() === true,
58980
60263
  priority: 3,
58981
60264
  commands: [{
58982
60265
  bind: "up,k",
@@ -59454,77 +60737,71 @@ function SubagentsViewer(props) {
59454
60737
  }
59455
60738
  });
59456
60739
  });
59457
- Keymap2.createLayer(() => {
59458
- const top = panels.top;
59459
- return {
59460
- mode: "global",
59461
- enabled: open() && transcriptHandle === undefined && handle !== undefined && handle === top && dialog.stack.length === 0,
59462
- priority: 2,
59463
- commands: [{
59464
- bind: "up,k",
59465
- title: t("panel.subagents.keymap.previous"),
59466
- group: "Subagents",
59467
- run: () => moveCursor(-1)
59468
- }, {
59469
- bind: "down,j",
59470
- title: t("panel.subagents.keymap.next"),
59471
- group: "Subagents",
59472
- run: () => moveCursor(1)
59473
- }, {
59474
- bind: "return",
59475
- title: t("panel.subagents.keymap.openTranscript"),
59476
- group: "Subagents",
59477
- run: () => {
59478
- const row = rows()[cursor()];
59479
- if (row !== undefined)
59480
- openTranscript(row.id);
59481
- return true;
59482
- }
59483
- }, {
59484
- bind: "s",
59485
- title: t("panel.subagents.keymap.sort"),
59486
- group: "Subagents",
59487
- run: () => {
59488
- setSortByRounds((value) => !value);
59489
- return true;
59490
- }
59491
- }, {
59492
- bind: "shift+k",
59493
- title: t("panel.subagents.keymap.stopAll"),
59494
- group: "Subagents",
59495
- run: stopAll
59496
- }]
59497
- };
59498
- });
59499
- Keymap2.createLayer(() => {
59500
- const top = panels.top;
59501
- return {
59502
- mode: "global",
59503
- enabled: open() && transcriptHandle !== undefined && transcriptHandle === top && dialog.stack.length === 0,
59504
- priority: 2,
59505
- commands: [{
59506
- bind: "up,k",
59507
- title: t("panel.subagents.keymap.scrollUp"),
59508
- group: "Subagents",
59509
- run: () => scrollBy(-1)
59510
- }, {
59511
- bind: "down,j",
59512
- title: t("panel.subagents.keymap.scrollDown"),
59513
- group: "Subagents",
59514
- run: () => scrollBy(1)
59515
- }, {
59516
- bind: "return",
59517
- title: t("panel.subagents.keymap.steer"),
59518
- group: "Subagents",
59519
- run: openSteer
59520
- }, {
59521
- bind: "x",
59522
- title: t("panel.subagents.keymap.stopTwice"),
59523
- group: "Subagents",
59524
- run: stopChild
59525
- }]
59526
- };
59527
- });
60740
+ Keymap2.createLayer(() => ({
60741
+ mode: "global",
60742
+ enabled: open() && transcriptHandle === undefined && handle?.ownsInput() === true && dialog.stack.length === 0,
60743
+ priority: 2,
60744
+ commands: [{
60745
+ bind: "up,k",
60746
+ title: t("panel.subagents.keymap.previous"),
60747
+ group: "Subagents",
60748
+ run: () => moveCursor(-1)
60749
+ }, {
60750
+ bind: "down,j",
60751
+ title: t("panel.subagents.keymap.next"),
60752
+ group: "Subagents",
60753
+ run: () => moveCursor(1)
60754
+ }, {
60755
+ bind: "return",
60756
+ title: t("panel.subagents.keymap.openTranscript"),
60757
+ group: "Subagents",
60758
+ run: () => {
60759
+ const row = rows()[cursor()];
60760
+ if (row !== undefined)
60761
+ openTranscript(row.id);
60762
+ return true;
60763
+ }
60764
+ }, {
60765
+ bind: "s",
60766
+ title: t("panel.subagents.keymap.sort"),
60767
+ group: "Subagents",
60768
+ run: () => {
60769
+ setSortByRounds((value) => !value);
60770
+ return true;
60771
+ }
60772
+ }, {
60773
+ bind: "shift+k",
60774
+ title: t("panel.subagents.keymap.stopAll"),
60775
+ group: "Subagents",
60776
+ run: stopAll
60777
+ }]
60778
+ }));
60779
+ Keymap2.createLayer(() => ({
60780
+ mode: "global",
60781
+ enabled: open() && transcriptHandle?.ownsInput() === true && dialog.stack.length === 0,
60782
+ priority: 2,
60783
+ commands: [{
60784
+ bind: "up,k",
60785
+ title: t("panel.subagents.keymap.scrollUp"),
60786
+ group: "Subagents",
60787
+ run: () => scrollBy(-1)
60788
+ }, {
60789
+ bind: "down,j",
60790
+ title: t("panel.subagents.keymap.scrollDown"),
60791
+ group: "Subagents",
60792
+ run: () => scrollBy(1)
60793
+ }, {
60794
+ bind: "return",
60795
+ title: t("panel.subagents.keymap.steer"),
60796
+ group: "Subagents",
60797
+ run: openSteer
60798
+ }, {
60799
+ bind: "x",
60800
+ title: t("panel.subagents.keymap.stopTwice"),
60801
+ group: "Subagents",
60802
+ run: stopChild
60803
+ }]
60804
+ }));
59528
60805
  function clip(text, width) {
59529
60806
  if (width <= 0)
59530
60807
  return "";
@@ -59745,7 +61022,7 @@ var init_subagents_viewer = __esm(() => {
59745
61022
  import { TextAttributes as TextAttributes12 } from "@opentui/core";
59746
61023
  function resolveVersion() {
59747
61024
  try {
59748
- return "0.18.2";
61025
+ return "0.18.4";
59749
61026
  } catch {
59750
61027
  return "dev";
59751
61028
  }
@@ -60530,7 +61807,7 @@ function SettingsModalBody(props) {
60530
61807
  scrollRowInto(action === "pagedown" ? (page + 1) * size : (page - 1) * size);
60531
61808
  return true;
60532
61809
  }
60533
- const ownsTop = () => props.layerHandle !== undefined && panels.top === props.layerHandle;
61810
+ const ownsTop = () => props.layerHandle?.ownsInput() === true;
60534
61811
  Keymap2.createLayer(() => ({
60535
61812
  mode: "global",
60536
61813
  priority: 2,
@@ -61459,9 +62736,17 @@ function createTuiPanelKeymapHost(keymap) {
61459
62736
  }
61460
62737
  };
61461
62738
  }
62739
+ function createTuiPanelOwnership(ownership) {
62740
+ return {
62741
+ push: (kind) => ownership.push(kind),
62742
+ pop: (token) => ownership.pop(token),
62743
+ owns: (token) => ownership.owns(token)
62744
+ };
62745
+ }
61462
62746
  function PanelKitHost(props) {
61463
62747
  const theme = useTheme();
61464
62748
  const keymap = Keymap2.use();
62749
+ const ownership = useInputOwnershipOptional();
61465
62750
  const panelTheme = () => projectPanelTheme(theme);
61466
62751
  return createComponent2(PanelKitProvider, {
61467
62752
  theme: panelTheme,
@@ -61471,6 +62756,9 @@ function PanelKitHost(props) {
61471
62756
  get keymap() {
61472
62757
  return createTuiPanelKeymapHost(keymap);
61473
62758
  },
62759
+ get ownership() {
62760
+ return ownership ? createTuiPanelOwnership(ownership) : undefined;
62761
+ },
61474
62762
  get children() {
61475
62763
  return createComponent2(PanelStack, {
61476
62764
  get children() {
@@ -61481,9 +62769,11 @@ function PanelKitHost(props) {
61481
62769
  });
61482
62770
  }
61483
62771
  var init_panel_kit_host = __esm(() => {
62772
+ init_index_bun();
61484
62773
  init_index_bun();
61485
62774
  init_src3();
61486
62775
  init_motion();
62776
+ init_input_ownership();
61487
62777
  init_keymap();
61488
62778
  init_theme3();
61489
62779
  });
@@ -61778,12 +63068,7 @@ class RemoteSessionSeam {
61778
63068
  const rows = await this.#session.storedTranscript(id, skip);
61779
63069
  return rows.map((row) => {
61780
63070
  if (row.kind === "ask") {
61781
- const text = row.entries.map((entry) => {
61782
- const picked = entry.selected.length > 0 ? entry.selected.join(", ") : entry.custom ?? "declined";
61783
- return `${entry.question} \u2192 ${picked}`;
61784
- }).join(`
61785
- `);
61786
- return { kind: row.kind, text, final: true };
63071
+ return { kind: row.kind, text: "", final: true, entries: row.entries };
61787
63072
  }
61788
63073
  if (row.kind === "tool") {
61789
63074
  return { kind: "tool", text: row.name, final: true, args: row.args, output: row.brief, ok: row.ok };
@@ -62241,6 +63526,13 @@ async function loadShell() {
62241
63526
  return { shared, lifecycle, transport, rhs, adapter, git };
62242
63527
  }
62243
63528
  function V2SessionPage(props) {
63529
+ return createComponent2(DockProvider, {
63530
+ get children() {
63531
+ return createComponent2(V2SessionPageBody, props);
63532
+ }
63533
+ });
63534
+ }
63535
+ function V2SessionPageBody(props) {
62244
63536
  const seam = props.seam;
62245
63537
  const projection = createSeamRows(seam, () => seam.currentSessionId() ?? "", {
62246
63538
  onApprove: (name, args) => overlays.requestApproval(name, args),
@@ -62248,6 +63540,8 @@ function V2SessionPage(props) {
62248
63540
  onToolRun: () => setTools((n) => n + 1)
62249
63541
  });
62250
63542
  const dialog = useDialog();
63543
+ const pageOwns = useIsPageOwner();
63544
+ const dock = useDock();
62251
63545
  const theme = useTheme();
62252
63546
  const themeService = useThemes();
62253
63547
  const themeSeam = createThemeSeam(themeService);
@@ -62283,6 +63577,10 @@ function V2SessionPage(props) {
62283
63577
  Promise.all([face.list(), face.currentId()]).then(([rows, id]) => setPresetLabel(presetLabelFor(rows, id))).catch(() => {});
62284
63578
  };
62285
63579
  let composerRef;
63580
+ dock.bindComposerFocus(() => {
63581
+ if (composerRef && !composerRef.focused())
63582
+ composerRef.focus();
63583
+ });
62286
63584
  let transcriptScroll;
62287
63585
  const renderer = useRenderer();
62288
63586
  const dimensions = useTerminalSize();
@@ -62744,48 +64042,48 @@ function V2SessionPage(props) {
62744
64042
  },
62745
64043
  turnActive: () => busy()
62746
64044
  }),
62747
- footer: createComponent2(LastRequestDock, {
62748
- get rows() {
62749
- return projection.rows;
62750
- },
62751
- get lastRequest() {
62752
- return lastRequest();
62753
- }
62754
- }),
62755
- pending: () => composerPending(),
62756
- notices: createComponent2(NoticesDock, {}),
62757
- get children() {
62758
- return [
62759
- createComponent2(ComposerContext, {
62760
- cwd: () => props.workspace,
62761
- probeBranch: props.probeBranch,
62762
- revision: () => contextRevision(),
62763
- steer: () => composerBusy(),
62764
- attachTitle: (get) => {
62765
- contextFrameTitle = get;
62766
- }
62767
- }),
62768
- createComponent2(SessionComposer, {
62769
- seam,
62770
- send,
62771
- footerHint: false,
62772
- frameTitle: () => contextFrameTitle?.() ?? "",
62773
- onBusyChange: setComposerBusy,
62774
- ref: (r) => composerRef = r,
62775
- chooseDelivery: (text) => openDeliveryChoice(dialog, text),
62776
- onPendingChange: (rows) => setComposerPending(rows),
62777
- onQueuePaused: (info) => showNotice(`\u961F\u5217\u5DF2\u4FDD\u7559 ${info.remaining} \u6761:\u672C\u56DE\u5408${info.reason === "failed" ? "\u5931\u8D25" : "\u5DF2\u4E2D\u6B62"},\u4E0B\u56DE\u5408\u7ED3\u675F\u540E\u7EE7\u7EED\u53D1\u9001`, 8000),
62778
- isTurnAborted: () => turnAborted,
62779
- slashKeyFilter: slash.slashKeyFilter,
62780
- slashSync: (buffer) => slash.controller.sync(buffer, slash.commands),
62781
- interceptSubmit: slash.interceptSubmit,
62782
- slashComplete: (buffer, cursor) => dialog.stack.length > 0 ? undefined : slash.slashComplete(buffer, cursor),
62783
- slashPalette: () => createComponent2(SlashPalette, { controller: slash.controller, commands: () => slash.commands }),
62784
- slashHeight: () => slash.controller.rows()
62785
- })
62786
- ];
64045
+ pending: () => composerPending()
64046
+ }),
64047
+ createComponent2(DockSeat, {
64048
+ composer: () => [
64049
+ createComponent2(ComposerContext, {
64050
+ cwd: () => props.workspace,
64051
+ probeBranch: props.probeBranch,
64052
+ revision: () => contextRevision(),
64053
+ steer: () => composerBusy(),
64054
+ attachTitle: (get) => {
64055
+ contextFrameTitle = get;
64056
+ }
64057
+ }),
64058
+ createComponent2(SessionComposer, {
64059
+ seam,
64060
+ send,
64061
+ footerHint: false,
64062
+ frameTitle: () => contextFrameTitle?.() ?? "",
64063
+ onBusyChange: setComposerBusy,
64064
+ ref: (r) => composerRef = r,
64065
+ chooseDelivery: (text) => openDeliveryChoice(dialog, text),
64066
+ onPendingChange: (rows) => setComposerPending(rows),
64067
+ onQueuePaused: (info) => showNotice(`\u961F\u5217\u5DF2\u4FDD\u7559 ${info.remaining} \u6761:\u672C\u56DE\u5408${info.reason === "failed" ? "\u5931\u8D25" : "\u5DF2\u4E2D\u6B62"},\u4E0B\u56DE\u5408\u7ED3\u675F\u540E\u7EE7\u7EED\u53D1\u9001`, 8000),
64068
+ isTurnAborted: () => turnAborted,
64069
+ slashKeyFilter: slash.slashKeyFilter,
64070
+ slashSync: (buffer) => slash.controller.sync(buffer, slash.commands),
64071
+ interceptSubmit: slash.interceptSubmit,
64072
+ slashComplete: (buffer, cursor) => dialog.stack.length > 0 ? undefined : slash.slashComplete(buffer, cursor),
64073
+ slashPalette: () => createComponent2(SlashPalette, { controller: slash.controller, commands: () => slash.commands }),
64074
+ slashHeight: () => slash.controller.rows()
64075
+ })
64076
+ ]
64077
+ }),
64078
+ createComponent2(LastRequestDock, {
64079
+ get rows() {
64080
+ return projection.rows;
64081
+ },
64082
+ get lastRequest() {
64083
+ return lastRequest();
62787
64084
  }
62788
64085
  }),
64086
+ createComponent2(NoticesDock, {}),
62789
64087
  createComponent2(SubagentsPicker, {
62790
64088
  get seam() {
62791
64089
  return seam;
@@ -62793,11 +64091,11 @@ function V2SessionPage(props) {
62793
64091
  }),
62794
64092
  createComponent2(TranscriptScrollKeys, {
62795
64093
  scroll: () => transcriptScroll,
62796
- enabled: () => dialog.stack.length === 0
64094
+ enabled: pageOwns
62797
64095
  }),
62798
64096
  createComponent2(PaneFocusKeys, {
62799
64097
  pane: paneFocus.pane,
62800
- keysEnabled: () => dialog.stack.length === 0,
64098
+ keysEnabled: pageOwns,
62801
64099
  slashOpen: () => slash.controller.open,
62802
64100
  pickerOpen: subagentsPickerOpen,
62803
64101
  busy,
@@ -62815,7 +64113,7 @@ function V2SessionPage(props) {
62815
64113
  confirmStopAll();
62816
64114
  },
62817
64115
  quit: props.quit,
62818
- enabled: () => dialog.stack.length === 0,
64116
+ enabled: pageOwns,
62819
64117
  escapeYields: () => slash.controller.open
62820
64118
  }),
62821
64119
  createComponent2(PowerlineFooter, {
@@ -62964,24 +64262,28 @@ async function bootClientV2(options = {}) {
62964
64262
  get children() {
62965
64263
  return createComponent2(ClipboardHost, {
62966
64264
  get children() {
62967
- return createComponent2(DialogProvider, {
64265
+ return createComponent2(InputOwnershipProvider, {
62968
64266
  get children() {
62969
- return createComponent2(ErrorBoundaryDiagnostics, {
64267
+ return createComponent2(DialogProvider, {
62970
64268
  get children() {
62971
- return createComponent2(PanelKitHost, {
64269
+ return createComponent2(ErrorBoundaryDiagnostics, {
62972
64270
  get children() {
62973
- return createComponent2(V2SessionPage, {
62974
- seam,
62975
- themeName,
62976
- quit: () => process.exit(0),
62977
- workspace,
62978
- profileName: profile,
62979
- probeBranch: (cwd) => git.probeGitBranchOrSha(cwd),
62980
- initialSessionId,
62981
- resumeNotice,
62982
- skills: skillRows,
62983
- skillsSource: skillsManagerRoots.source,
62984
- skillsCurated: skillsManagerRoots.curated
64271
+ return createComponent2(PanelKitHost, {
64272
+ get children() {
64273
+ return createComponent2(V2SessionPage, {
64274
+ seam,
64275
+ themeName,
64276
+ quit: () => process.exit(0),
64277
+ workspace,
64278
+ profileName: profile,
64279
+ probeBranch: (cwd) => git.probeGitBranchOrSha(cwd),
64280
+ initialSessionId,
64281
+ resumeNotice,
64282
+ skills: skillRows,
64283
+ skillsSource: skillsManagerRoots.source,
64284
+ skillsCurated: skillsManagerRoots.curated
64285
+ });
64286
+ }
62985
64287
  });
62986
64288
  }
62987
64289
  });
@@ -63055,7 +64357,9 @@ var init_v2_entry = __esm(() => {
63055
64357
  init_pane_focus();
63056
64358
  init_subagents_picker();
63057
64359
  init_turn_cancel();
64360
+ init_turn_overlay_controller();
63058
64361
  init_turn_overlays();
64362
+ init_dock_host();
63059
64363
  init_slash_palette();
63060
64364
  init_slash_deps();
63061
64365
  init_commands();
@@ -63079,6 +64383,7 @@ var init_v2_entry = __esm(() => {
63079
64383
  init_keymap();
63080
64384
  init_theme3();
63081
64385
  init_panel_kit_host();
64386
+ init_input_ownership();
63082
64387
  init_config();
63083
64388
  init_selection();
63084
64389
  init_theme2();
@@ -63222,3 +64527,6 @@ export {
63222
64527
  spawnIdleReaper,
63223
64528
  themeNameFromConfig
63224
64529
  };
64530
+
64531
+ //# debugId=2E46D145BFA38F7364756E2164756E21
64532
+ //# sourceMappingURL=index.js.map