@aiwayds/dsh-opentui 0.18.1 → 0.18.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5075,13 +5075,16 @@ function parseAskCallArgs(args) {
5075
5075
  const question = typeof item.question === "string" && item.question ? item.question : typeof item.prompt === "string" && item.prompt ? item.prompt : undefined;
5076
5076
  if (question === undefined)
5077
5077
  continue;
5078
- const header = typeof item.header === "string" && item.header ? item.header : undefined;
5078
+ const header = textField(item.header);
5079
+ const detail = textField(item.detail);
5079
5080
  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 !== "");
5081
+ const options = rawOptions.map(optionView).filter((option) => option.label !== "");
5081
5082
  out.push({
5082
5083
  id,
5083
5084
  entry: {
5084
- question: header !== undefined && header !== question ? `${header}: ${question}` : question,
5085
+ question,
5086
+ ...header !== undefined ? { header } : {},
5087
+ ...detail !== undefined ? { detail } : {},
5085
5088
  options,
5086
5089
  selected: [],
5087
5090
  declined: false
@@ -5090,6 +5093,17 @@ function parseAskCallArgs(args) {
5090
5093
  }
5091
5094
  return out.length > 0 ? out : undefined;
5092
5095
  }
5096
+ function textField(value) {
5097
+ return typeof value === "string" && value !== "" ? value : undefined;
5098
+ }
5099
+ function optionView(option) {
5100
+ if (typeof option === "string")
5101
+ return { label: option };
5102
+ const item = typeof option === "object" && option !== null ? option : {};
5103
+ const label = typeof item.label === "string" ? item.label : "";
5104
+ const description = textField(item.description);
5105
+ return description === undefined ? { label } : { label, description };
5106
+ }
5093
5107
  function textBlocks(content) {
5094
5108
  if (!Array.isArray(content))
5095
5109
  return [];
@@ -5860,6 +5874,18 @@ function asRow(value) {
5860
5874
  }
5861
5875
 
5862
5876
  // src/client/remote-waterfall.ts
5877
+ function textField2(value) {
5878
+ return typeof value === "string" && value !== "" ? value : undefined;
5879
+ }
5880
+ function optionView2(option) {
5881
+ if (typeof option !== "object" || option === null)
5882
+ return { label: String(option) };
5883
+ const item = option;
5884
+ const label = String(item.label ?? item.value ?? option);
5885
+ const description = textField2(item.description);
5886
+ return description === undefined ? { label } : { label, description };
5887
+ }
5888
+
5863
5889
  class WaterfallAnswerer {
5864
5890
  #connection;
5865
5891
  #clientId;
@@ -5901,10 +5927,16 @@ class WaterfallAnswerer {
5901
5927
  return questions.map((q) => {
5902
5928
  const item = typeof q === "object" && q !== null ? q : {};
5903
5929
  const options = Array.isArray(item.options) ? item.options : [];
5930
+ const header = textField2(item.header);
5931
+ const description = textField2(item.description);
5932
+ const detail = textField2(item.detail);
5904
5933
  return {
5905
5934
  id: String(item.id ?? ""),
5906
5935
  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)),
5936
+ ...header !== undefined ? { header } : {},
5937
+ ...description !== undefined ? { description } : {},
5938
+ ...detail !== undefined ? { detail } : {},
5939
+ options: options.map(optionView2),
5908
5940
  ...item.multiSelect === true || item.multi_select === true ? { multiSelect: true } : {}
5909
5941
  };
5910
5942
  });
@@ -5916,7 +5948,13 @@ class WaterfallAnswerer {
5916
5948
  if (pick?.custom !== undefined && pick.custom !== "") {
5917
5949
  return { id: q.id, selected: [], custom: pick.custom };
5918
5950
  }
5919
- const answer = pick ? { id: q.id, selected: pick.selections?.length ? [...pick.selections] : [pick.selected] } : { id: q.id, selected: [], custom: "declined" };
5951
+ if (pick === undefined || pick.selected === "" && (pick.custom ?? "") === "") {
5952
+ return { id: q.id, selected: [], custom: "declined" };
5953
+ }
5954
+ const answer = {
5955
+ id: q.id,
5956
+ selected: pick.selections?.length ? [...pick.selections] : [pick.selected]
5957
+ };
5920
5958
  return answer;
5921
5959
  })
5922
5960
  };
@@ -10467,6 +10505,61 @@ function mapArray(list, mapFn, options = {}) {
10467
10505
  }
10468
10506
  };
10469
10507
  }
10508
+ function indexArray(list, mapFn, options = {}) {
10509
+ let items = [], mapped = [], disposers = [], signals = [], len = 0, i;
10510
+ onCleanup(() => dispose(disposers));
10511
+ return () => {
10512
+ const newItems = list() || [], newLen = newItems.length;
10513
+ newItems[$TRACK];
10514
+ return untrack(() => {
10515
+ if (newLen === 0) {
10516
+ if (len !== 0) {
10517
+ dispose(disposers);
10518
+ disposers = [];
10519
+ items = [];
10520
+ mapped = [];
10521
+ len = 0;
10522
+ signals = [];
10523
+ }
10524
+ if (options.fallback) {
10525
+ items = [FALLBACK];
10526
+ mapped[0] = createRoot((disposer) => {
10527
+ disposers[0] = disposer;
10528
+ return options.fallback();
10529
+ });
10530
+ len = 1;
10531
+ }
10532
+ return mapped;
10533
+ }
10534
+ if (items[0] === FALLBACK) {
10535
+ disposers[0]();
10536
+ disposers = [];
10537
+ items = [];
10538
+ mapped = [];
10539
+ len = 0;
10540
+ }
10541
+ for (i = 0;i < newLen; i++) {
10542
+ if (i < items.length && items[i] !== newItems[i]) {
10543
+ signals[i](() => newItems[i]);
10544
+ } else if (i >= items.length) {
10545
+ mapped[i] = createRoot(mapper);
10546
+ }
10547
+ }
10548
+ for (;i < items.length; i++) {
10549
+ disposers[i]();
10550
+ }
10551
+ len = signals.length = disposers.length = newLen;
10552
+ items = newItems.slice(0);
10553
+ return mapped = mapped.slice(0, len);
10554
+ });
10555
+ function mapper(disposer) {
10556
+ disposers[i] = disposer;
10557
+ const [s, set] = createSignal(newItems[i]);
10558
+ signals[i] = set;
10559
+ return mapFn(s, i);
10560
+ }
10561
+ };
10562
+ }
10470
10563
  function createComponent(Comp, props) {
10471
10564
  if (hydrationEnabled) {
10472
10565
  if (sharedConfig.context) {
@@ -10619,6 +10712,12 @@ function For(props) {
10619
10712
  };
10620
10713
  return createMemo(mapArray(() => props.each, props.children, fallback || undefined));
10621
10714
  }
10715
+ function Index(props) {
10716
+ const fallback = "fallback" in props && {
10717
+ fallback: () => props.fallback
10718
+ };
10719
+ return createMemo(indexArray(() => props.each, props.children, fallback || undefined));
10720
+ }
10622
10721
  function Show(props) {
10623
10722
  const keyed = props.keyed;
10624
10723
  const conditionValue = createMemo(() => props.when, undefined, undefined);
@@ -42117,6 +42216,55 @@ var require_fuzzysort = __commonJS(function(exports, module) {
42117
42216
  });
42118
42217
  });
42119
42218
 
42219
+ // ../tui-base/src/context/input-ownership.tsx
42220
+ function InputOwnershipProvider(props) {
42221
+ const page = {
42222
+ id: Symbol("page"),
42223
+ kind: "page"
42224
+ };
42225
+ const [stack, setStack] = createSignal([page]);
42226
+ const top = () => stack().at(-1) ?? page;
42227
+ const value = {
42228
+ top,
42229
+ pageFrame: () => page,
42230
+ push(kind) {
42231
+ const frame = {
42232
+ id: Symbol(kind),
42233
+ kind
42234
+ };
42235
+ setStack((items) => [...items, frame]);
42236
+ return frame;
42237
+ },
42238
+ pop(frame) {
42239
+ if (!frame || frame === page)
42240
+ return;
42241
+ setStack((items) => items.some((item) => item.id === frame.id) ? items.filter((item) => item.id !== frame.id) : items);
42242
+ },
42243
+ owns(frame) {
42244
+ return frame !== undefined && top().id === frame.id;
42245
+ }
42246
+ };
42247
+ return createComponent2(Context6.Provider, {
42248
+ value,
42249
+ get children() {
42250
+ return props.children;
42251
+ }
42252
+ });
42253
+ }
42254
+ function useInputOwnershipOptional() {
42255
+ return useContext(Context6);
42256
+ }
42257
+ function useIsPageOwner() {
42258
+ const ownership = useInputOwnershipOptional();
42259
+ return () => ownership === undefined || ownership.owns(ownership.pageFrame());
42260
+ }
42261
+ var Context6;
42262
+ var init_input_ownership = __esm(() => {
42263
+ init_index_bun();
42264
+ init_server();
42265
+ Context6 = createContext(undefined);
42266
+ });
42267
+
42120
42268
  // ../tui-base/src/ui/border.ts
42121
42269
  var EmptyBorder, SplitBorder;
42122
42270
  var init_border = __esm(() => {
@@ -42719,6 +42867,7 @@ function init2() {
42719
42867
  });
42720
42868
  const renderer = useRenderer();
42721
42869
  const keymap = Keymap2.use();
42870
+ const ownership = useInputOwnershipOptional();
42722
42871
  createEffect(() => {
42723
42872
  if (store.stack.length === 0)
42724
42873
  return;
@@ -42751,7 +42900,7 @@ function init2() {
42751
42900
  }
42752
42901
  Keymap2.createLayer(() => ({
42753
42902
  mode: "modal",
42754
- enabled: store.stack.length > 0,
42903
+ enabled: store.stack.length > 0 && (ownership === undefined || ownership.owns(store.stack.at(-1)?.frame)),
42755
42904
  commands: [{
42756
42905
  bind: "escape",
42757
42906
  title: "Close dialog",
@@ -42763,6 +42912,7 @@ function init2() {
42763
42912
  }
42764
42913
  const current = store.stack.at(-1);
42765
42914
  current?.onClose?.();
42915
+ ownership?.pop(current?.frame);
42766
42916
  setStore("stack", store.stack.slice(0, -1));
42767
42917
  refocus();
42768
42918
  }
@@ -42785,6 +42935,7 @@ function init2() {
42785
42935
  }
42786
42936
  const current = store.stack.at(-1);
42787
42937
  current?.onClose?.();
42938
+ ownership?.pop(current?.frame);
42788
42939
  setStore("stack", store.stack.slice(0, -1));
42789
42940
  refocus();
42790
42941
  }
@@ -42795,6 +42946,7 @@ function init2() {
42795
42946
  for (const item of store.stack) {
42796
42947
  if (item.onClose)
42797
42948
  item.onClose();
42949
+ ownership?.pop(item.frame);
42798
42950
  }
42799
42951
  batch(() => {
42800
42952
  setStore("size", "medium");
@@ -42811,6 +42963,7 @@ function init2() {
42811
42963
  for (const item of store.stack) {
42812
42964
  if (item.onClose)
42813
42965
  item.onClose();
42966
+ ownership?.pop(item.frame);
42814
42967
  }
42815
42968
  batch(() => {
42816
42969
  setStore("size", options?.size ?? "medium");
@@ -42819,7 +42972,8 @@ function init2() {
42819
42972
  element: input,
42820
42973
  onClose,
42821
42974
  key: options?.key,
42822
- tone: options?.tone
42975
+ tone: options?.tone,
42976
+ frame: ownership?.push("dialog")
42823
42977
  }]);
42824
42978
  });
42825
42979
  },
@@ -42923,6 +43077,7 @@ var init_dialog = __esm(() => {
42923
43077
  init_index_bun();
42924
43078
  init_server();
42925
43079
  init_keymap();
43080
+ init_input_ownership();
42926
43081
  init_theme3();
42927
43082
  init_server2();
42928
43083
  init_toast();
@@ -46038,6 +46193,7 @@ var init_subagent_markers = __esm(() => {
46038
46193
  function SubagentsPicker(props) {
46039
46194
  const theme = useThemeOptional();
46040
46195
  const dialog = useDialog();
46196
+ const pageOwns = useIsPageOwner();
46041
46197
  const [open, setOpen] = [pickerOpen, setPickerOpen];
46042
46198
  onCleanup(() => setPickerOpen(false));
46043
46199
  const [showAll, setShowAll] = createSignal(false);
@@ -46108,7 +46264,7 @@ function SubagentsPicker(props) {
46108
46264
  }
46109
46265
  Keymap2.createLayer(() => ({
46110
46266
  mode: "global",
46111
- enabled: open() && dialog.stack.length === 0,
46267
+ enabled: open() && pageOwns(),
46112
46268
  priority: 2,
46113
46269
  commands: [{
46114
46270
  bind: "down",
@@ -46142,7 +46298,7 @@ function SubagentsPicker(props) {
46142
46298
  }));
46143
46299
  Keymap2.createLayer(() => ({
46144
46300
  mode: "global",
46145
- enabled: !open() && dialog.stack.length === 0 && pickerToggleEnabled(subagentMarkerViews()),
46301
+ enabled: !open() && pageOwns() && pickerToggleEnabled(subagentMarkerViews()),
46146
46302
  commands: [{
46147
46303
  id: "session.child.first",
46148
46304
  title: t("overlay.picker.keymap.toggle"),
@@ -46224,6 +46380,7 @@ var init_subagents_picker = __esm(() => {
46224
46380
  init_theme3();
46225
46381
  init_semantic();
46226
46382
  init_dialog();
46383
+ init_input_ownership();
46227
46384
  init_dialog_prompt();
46228
46385
  init_i18n();
46229
46386
  init_locale();
@@ -46253,7 +46410,7 @@ var init_dock_visibility = __esm(() => {
46253
46410
 
46254
46411
  // ../tui-base/src/routes/session/seam-rows.ts
46255
46412
  function toStoredRow(stored, index) {
46256
- const kind = stored.kind === "user" || stored.kind === "tool" ? stored.kind : "assistant";
46413
+ const kind = stored.kind === "user" || stored.kind === "tool" || stored.kind === "ask" ? stored.kind : "assistant";
46257
46414
  const key = `stored:${kind}:${index}`;
46258
46415
  if (kind === "tool") {
46259
46416
  return {
@@ -46265,6 +46422,11 @@ function toStoredRow(stored, index) {
46265
46422
  ...typeof stored.output === "string" ? { output: stored.output } : {}
46266
46423
  };
46267
46424
  }
46425
+ if (kind === "ask") {
46426
+ if (stored.entries?.length)
46427
+ return { key, kind: "ask", entries: stored.entries };
46428
+ return { key, kind: "assistant", text: stored.text, final: stored.final };
46429
+ }
46268
46430
  if (kind === "user")
46269
46431
  return { key, kind: "user", text: stored.text, final: true };
46270
46432
  return { key, kind: "assistant", text: stored.text, final: stored.final };
@@ -46661,6 +46823,75 @@ var init_seam_rows = __esm(() => {
46661
46823
  init_motion();
46662
46824
  });
46663
46825
 
46826
+ // ../tui-base/src/routes/session/ask-options.ts
46827
+ function splitRecommended(raw) {
46828
+ const trimmed = raw.trim();
46829
+ const match = TRAILING_PAREN.exec(trimmed);
46830
+ if (match === null)
46831
+ return { label: trimmed, recommended: false };
46832
+ const token = (match[1] ?? "").trim().toLowerCase();
46833
+ if (!RECOMMENDED_TOKENS.has(token))
46834
+ return { label: trimmed, recommended: false };
46835
+ const label = trimmed.slice(0, match.index).trim();
46836
+ if (label === "")
46837
+ return { label: trimmed, recommended: false };
46838
+ return { label, recommended: true };
46839
+ }
46840
+ function recommendedPicks(question) {
46841
+ const recommended = question.options.filter((option) => splitRecommended(option.label).recommended).map((option) => option.label);
46842
+ if (recommended.length === 0)
46843
+ return [];
46844
+ return question.multiSelect === true ? recommended : [recommended[0]];
46845
+ }
46846
+ function askNeedsReview(questions) {
46847
+ return questions.length >= 2 || questions.some((question) => question.multiSelect === true);
46848
+ }
46849
+ function askTabStrip(questions, picks, index, customs) {
46850
+ return questions.map((_, qi) => {
46851
+ const answered = (picks[qi]?.length ?? 0) > 0 || customs?.[qi] !== undefined && customs[qi] !== "";
46852
+ const label = `${qi + 1}${answered ? " \u2713" : ""}`;
46853
+ return qi === index ? `[${label}]` : label;
46854
+ }).join(" \xB7 ");
46855
+ }
46856
+ function hasReviewRow(question, needsReview) {
46857
+ return needsReview && question.options.length > 0;
46858
+ }
46859
+ function questionRowCount(question, needsReview) {
46860
+ return question.options.length + (hasReviewRow(question, needsReview) ? 1 : 0) + 1;
46861
+ }
46862
+ function inlineRowIndex(question, needsReview) {
46863
+ return question.options.length + (hasReviewRow(question, needsReview) ? 1 : 0);
46864
+ }
46865
+ function reviewRowIntent(cursor, questionCount) {
46866
+ return cursor >= questionCount ? { kind: "submit" } : { kind: "edit", question: Math.max(0, cursor) };
46867
+ }
46868
+ function estimateAskRows(ask) {
46869
+ const question = ask.questions[ask.index];
46870
+ if (question === undefined)
46871
+ return 1;
46872
+ let rows = 1;
46873
+ rows += 1;
46874
+ if (question.header !== undefined)
46875
+ rows += 1;
46876
+ if (question.detail !== undefined)
46877
+ rows += 1;
46878
+ if (ask.questions.length >= 2)
46879
+ rows += 1;
46880
+ for (const option of question.options)
46881
+ rows += option.description === undefined ? 1 : 2;
46882
+ if (hasReviewRow(question, askNeedsReview(ask.questions)))
46883
+ rows += 1;
46884
+ rows += 1;
46885
+ rows += 1;
46886
+ rows += 1;
46887
+ return rows;
46888
+ }
46889
+ var TRAILING_PAREN, RECOMMENDED_TOKENS;
46890
+ var init_ask_options = __esm(() => {
46891
+ TRAILING_PAREN = /\s*[(\uFF08]([^()\uFF08\uFF09]*)[)\uFF09]\s*$/;
46892
+ RECOMMENDED_TOKENS = new Set(["recommended", "\u63A8\u8350"]);
46893
+ });
46894
+
46664
46895
  // ../tui-base/src/util/todo.ts
46665
46896
  function parseTodos(value) {
46666
46897
  if (!Array.isArray(value))
@@ -48332,7 +48563,6 @@ function Transcript(props) {
48332
48563
  text: () => theme?.text.base ?? "#e6e6e6",
48333
48564
  user: () => theme?.text.action.primary.base ?? "#7aa2f7",
48334
48565
  reasoningBorder: () => theme?.border.base ?? "#565f89",
48335
- reasoning: () => theme?.text.muted ?? "#9aa5ce",
48336
48566
  done: () => theme?.text.feedback.success.base ?? "#9ece6a",
48337
48567
  running: () => theme?.text.feedback.warning.base ?? "#e0af68",
48338
48568
  failed: () => theme?.text.feedback.error.base ?? "#f7768e",
@@ -48375,6 +48605,9 @@ function Transcript(props) {
48375
48605
  });
48376
48606
  return _el$2;
48377
48607
  })();
48608
+ const askRow = (row) => createComponent2(AskReplayBlock, {
48609
+ row
48610
+ });
48378
48611
  const visibleRows = createMemo(() => projection.rows.filter((row) => row.kind !== "tool" && row.kind !== "reasoning" && row.kind !== "subagents"));
48379
48612
  const rowView = (row) => {
48380
48613
  switch (row.kind) {
@@ -48401,6 +48634,8 @@ function Transcript(props) {
48401
48634
  })();
48402
48635
  case "assistant":
48403
48636
  return assistantRow(row);
48637
+ case "ask":
48638
+ return askRow(row);
48404
48639
  default:
48405
48640
  return null;
48406
48641
  }
@@ -48559,6 +48794,64 @@ function Transcript(props) {
48559
48794
  return _el$4;
48560
48795
  })();
48561
48796
  }
48797
+ function AskReplayBlock(props) {
48798
+ const theme = useThemeOptional();
48799
+ const reasoning = () => theme?.text.muted ?? "#9aa5ce";
48800
+ const answer = () => theme?.text.action.primary.base ?? "#7aa2f7";
48801
+ const askAnswerOf = (entry) => entry.selected.map((label) => splitRecommended(label).label).join(", ") || entry.custom || t("transcript.ask.declined");
48802
+ const askDeclinedOf = (entry) => entry.declined || entry.selected.length === 0 && !entry.custom;
48803
+ return (() => {
48804
+ var _el$13 = createElement("box");
48805
+ setProp(_el$13, "flexDirection", "column");
48806
+ setProp(_el$13, "gap", 1);
48807
+ insert(_el$13, createComponent2(For, {
48808
+ get each() {
48809
+ return props.row.entries;
48810
+ },
48811
+ children: (entry) => (() => {
48812
+ var _el$14 = createElement("box"), _el$15 = createElement("text"), _el$16 = createElement("text");
48813
+ insertNode(_el$14, _el$15);
48814
+ insertNode(_el$14, _el$16);
48815
+ setProp(_el$14, "flexDirection", "column");
48816
+ insert(_el$14, createComponent2(Show, {
48817
+ get when() {
48818
+ return entry.header;
48819
+ },
48820
+ children: (header) => (() => {
48821
+ var _el$17 = createElement("text");
48822
+ insert(_el$17, header);
48823
+ effect((_$p) => setProp(_el$17, "fg", reasoning(), _$p));
48824
+ return _el$17;
48825
+ })()
48826
+ }), _el$15);
48827
+ insert(_el$15, () => `\u2713 ${entry.question}`);
48828
+ insert(_el$14, createComponent2(Show, {
48829
+ get when() {
48830
+ return entry.detail;
48831
+ },
48832
+ children: (detail) => (() => {
48833
+ var _el$18 = createElement("text");
48834
+ insert(_el$18, detail);
48835
+ effect((_$p) => setProp(_el$18, "fg", reasoning(), _$p));
48836
+ return _el$18;
48837
+ })()
48838
+ }), _el$16);
48839
+ insert(_el$16, () => ` \u2192 ${askAnswerOf(entry)}`);
48840
+ effect((_p$) => {
48841
+ var _v$14 = reasoning(), _v$15 = askDeclinedOf(entry) ? reasoning() : answer();
48842
+ _v$14 !== _p$.e && (_p$.e = setProp(_el$15, "fg", _v$14, _p$.e));
48843
+ _v$15 !== _p$.t && (_p$.t = setProp(_el$16, "fg", _v$15, _p$.t));
48844
+ return _p$;
48845
+ }, {
48846
+ e: undefined,
48847
+ t: undefined
48848
+ });
48849
+ return _el$14;
48850
+ })()
48851
+ }));
48852
+ return _el$13;
48853
+ })();
48854
+ }
48562
48855
  var SIDES_RULE, SIDES_FRAME, CODE_RENDER_NODE_CACHE_MAX = 256, codeRenderNodeCache;
48563
48856
  var init_transcript = __esm(() => {
48564
48857
  init_index_bun();
@@ -48573,6 +48866,7 @@ var init_transcript = __esm(() => {
48573
48866
  init_index_bun();
48574
48867
  init_terminal_size();
48575
48868
  init_seam_rows();
48869
+ init_ask_options();
48576
48870
  init_theme3();
48577
48871
  init_i18n();
48578
48872
  init_motion();
@@ -49006,6 +49300,8 @@ function rowSearchText(row) {
49006
49300
  return row.text;
49007
49301
  case "tool":
49008
49302
  return `${row.name}${row.args ? `(${row.args})` : ""}${row.output ? ` ${row.output}` : ""}`;
49303
+ case "ask":
49304
+ return row.entries.map((entry) => `${entry.question}${entry.header ? ` ${entry.header}` : ""} ${entry.selected.join(" ")}${entry.custom ? ` ${entry.custom}` : ""}`).join(" ");
49009
49305
  case "subagents":
49010
49306
  return row.children.map((child) => `${child.label}${child.model ? `(${child.model})` : ""}`).join(" ");
49011
49307
  }
@@ -49054,7 +49350,7 @@ function useSearchOverlayOpenState() {
49054
49350
  }
49055
49351
  function SearchOverlay(props) {
49056
49352
  const theme = useThemeOptional();
49057
- const dialog = useDialog();
49353
+ const pageOwns = useIsPageOwner();
49058
49354
  let configCursorStyle;
49059
49355
  try {
49060
49356
  configCursorStyle = useCursorStyle();
@@ -49114,7 +49410,7 @@ function SearchOverlay(props) {
49114
49410
  }
49115
49411
  Keymap2.createLayer(() => ({
49116
49412
  mode: "global",
49117
- enabled: open() && dialog.stack.length === 0,
49413
+ enabled: open() && pageOwns(),
49118
49414
  priority: 2,
49119
49415
  commands: [{
49120
49416
  bind: "escape",
@@ -49135,7 +49431,7 @@ function SearchOverlay(props) {
49135
49431
  }));
49136
49432
  Keymap2.createLayer(() => ({
49137
49433
  mode: "global",
49138
- enabled: !open() && dialog.stack.length === 0,
49434
+ enabled: !open() && pageOwns(),
49139
49435
  commands: [{
49140
49436
  id: "session.search",
49141
49437
  title: t("overlay.search.commandTitle"),
@@ -49213,9 +49509,9 @@ var init_search_overlay = __esm(() => {
49213
49509
  init_index_bun();
49214
49510
  init_server();
49215
49511
  init_keymap();
49216
- init_dialog();
49217
49512
  init_i18n();
49218
49513
  init_theme3();
49514
+ init_input_ownership();
49219
49515
  init_semantic();
49220
49516
  init_config();
49221
49517
  [panelOpen, setPanelOpen] = createSignal(false);
@@ -49456,6 +49752,14 @@ var init_pane_focus = __esm(() => {
49456
49752
  });
49457
49753
 
49458
49754
  // ../tui-base/src/routes/session/turn-cancel.tsx
49755
+ function armNonArmingInterrupt() {
49756
+ nonArmingInterrupt = true;
49757
+ }
49758
+ function consumeNonArmingInterrupt() {
49759
+ const armed = nonArmingInterrupt;
49760
+ nonArmingInterrupt = false;
49761
+ return armed;
49762
+ }
49459
49763
  function createCtrlCGate(windowMs = CTRL_C_QUIT_WINDOW_MS, now = Date.now) {
49460
49764
  let armedAt;
49461
49765
  return {
@@ -49517,6 +49821,10 @@ function createTurnCancel(props, onArm) {
49517
49821
  ctrlC() {
49518
49822
  if (armedKey === "escape")
49519
49823
  disarm();
49824
+ if (consumeNonArmingInterrupt() && props.busy()) {
49825
+ props.interrupt();
49826
+ return true;
49827
+ }
49520
49828
  if (gate.press() === "quit") {
49521
49829
  disarm();
49522
49830
  props.quit();
@@ -49570,7 +49878,7 @@ function TurnCancelKeys(props) {
49570
49878
  }
49571
49879
  });
49572
49880
  }
49573
- var CTRL_C_QUIT_WINDOW_MS = 500;
49881
+ var CTRL_C_QUIT_WINDOW_MS = 500, nonArmingInterrupt = false;
49574
49882
  var init_turn_cancel = __esm(() => {
49575
49883
  init_index_bun();
49576
49884
  init_index_bun();
@@ -49613,6 +49921,12 @@ class TurnOverlayController {
49613
49921
  get pendingApproval() {
49614
49922
  return this.#approvals[0]?.request;
49615
49923
  }
49924
+ get pendingApprovalCount() {
49925
+ return this.#approvals.length;
49926
+ }
49927
+ get pendingAskCount() {
49928
+ return this.#asks.length;
49929
+ }
49616
49930
  requestApproval(name, args) {
49617
49931
  return new Promise((resolve) => {
49618
49932
  this.#approvals.push({ request: { id: ++this.#seq, name, args }, resolve });
@@ -49643,7 +49957,10 @@ class TurnOverlayController {
49643
49957
  picks: head.picks,
49644
49958
  phase: head.phase,
49645
49959
  customs: [...head.customs],
49646
- customDraft: head.customDraft
49960
+ customDraft: head.customDrafts[head.index] ?? null,
49961
+ cursors: [...head.cursors],
49962
+ listCursors: [...head.listCursors],
49963
+ reviewCursor: head.reviewCursor
49647
49964
  };
49648
49965
  }
49649
49966
  get currentQuestion() {
@@ -49658,12 +49975,15 @@ class TurnOverlayController {
49658
49975
  id: ++this.#seq,
49659
49976
  questions,
49660
49977
  index: 0,
49661
- picks: questions.map(() => []),
49662
- phase: "questions",
49978
+ picks: questions.map((question) => recommendedPicks(question)),
49979
+ phase: questions[0]?.options.length === 0 ? "input" : "questions",
49663
49980
  customs: questions.map(() => {
49664
49981
  return;
49665
49982
  }),
49666
- customDraft: null,
49983
+ customDrafts: questions.map(() => null),
49984
+ cursors: questions.map(() => 0),
49985
+ listCursors: questions.map(() => 0),
49986
+ reviewCursor: 0,
49667
49987
  resolve
49668
49988
  });
49669
49989
  this.#changed();
@@ -49674,9 +49994,10 @@ class TurnOverlayController {
49674
49994
  const question = head?.questions[head.index];
49675
49995
  if (!head || !question || head.phase === "review")
49676
49996
  return;
49677
- if (head.customDraft !== null)
49997
+ if (head.phase === "input")
49678
49998
  return;
49679
49999
  head.customs[head.index] = undefined;
50000
+ head.customDrafts[head.index] = null;
49680
50001
  if (question.multiSelect === true) {
49681
50002
  const current = head.picks[head.index] ?? [];
49682
50003
  head.picks[head.index] = current.includes(option) ? current.filter((label) => label !== option) : [...current, option];
@@ -49692,10 +50013,18 @@ class TurnOverlayController {
49692
50013
  }
49693
50014
  if (this.#allAnswered(head)) {
49694
50015
  head.phase = "review";
50016
+ head.reviewCursor = 0;
49695
50017
  } else {
49696
- const next = head.questions.findIndex((_, qi) => qi > head.index && head.picks[qi]?.length === 0);
50018
+ const next = head.questions.findIndex((_, qi) => qi > head.index && (head.picks[qi]?.length ?? 0) === 0 && !head.customs[qi]);
49697
50019
  if (next >= 0)
49698
50020
  head.index = next;
50021
+ head.phase = head.questions[head.index]?.options.length === 0 ? "input" : "questions";
50022
+ if (head.phase === "input") {
50023
+ const question = head.questions[head.index];
50024
+ if (question !== undefined) {
50025
+ head.cursors[head.index] = inlineRowIndex(question, askNeedsReview(head.questions));
50026
+ }
50027
+ }
49699
50028
  }
49700
50029
  this.#changed();
49701
50030
  }
@@ -49703,35 +50032,73 @@ class TurnOverlayController {
49703
50032
  const head = this.#asks[0];
49704
50033
  if (!head || head.phase === "review" || head.questions.length < 2)
49705
50034
  return;
50035
+ if (head.phase === "input" && (head.questions[head.index]?.options.length ?? 0) > 0)
50036
+ return;
49706
50037
  const next = Math.max(0, Math.min(head.questions.length - 1, head.index + direction));
49707
- if (next !== head.index) {
50038
+ if (next === head.index)
50039
+ return;
50040
+ head.index = next;
50041
+ const question = head.questions[next];
50042
+ head.phase = question?.options.length === 0 ? "input" : "questions";
50043
+ if (head.phase === "input" && question !== undefined) {
50044
+ head.cursors[next] = inlineRowIndex(question, askNeedsReview(head.questions));
50045
+ }
50046
+ this.#changed();
50047
+ }
50048
+ confirmQuestion() {
50049
+ const head = this.#asks[0];
50050
+ if (!head || head.phase === "review" || head.phase === "input")
50051
+ return false;
50052
+ const question = head.questions[head.index];
50053
+ if (question === undefined || !askNeedsReview(head.questions))
50054
+ return false;
50055
+ const next = head.questions.findIndex((_, qi) => qi > head.index && (head.picks[qi]?.length ?? 0) === 0 && !head.customs[qi]);
50056
+ if (next >= 0) {
49708
50057
  head.index = next;
49709
- this.#changed();
50058
+ const target = head.questions[next];
50059
+ head.phase = target?.options.length === 0 ? "input" : "questions";
50060
+ if (head.phase === "input" && target !== undefined) {
50061
+ head.cursors[next] = inlineRowIndex(target, askNeedsReview(head.questions));
50062
+ }
50063
+ } else {
50064
+ head.phase = "review";
50065
+ head.reviewCursor = 0;
49710
50066
  }
50067
+ this.#changed();
50068
+ return true;
49711
50069
  }
49712
50070
  beginCustom() {
49713
50071
  const head = this.#asks[0];
49714
50072
  if (!head || head.phase === "review")
49715
50073
  return false;
49716
- head.customDraft = head.customs[head.index] ?? "";
50074
+ const question = head.questions[head.index];
50075
+ head.customDrafts[head.index] = head.customs[head.index] ?? "";
50076
+ head.phase = "input";
50077
+ if (question !== undefined) {
50078
+ head.cursors[head.index] = inlineRowIndex(question, askNeedsReview(head.questions));
50079
+ }
49717
50080
  this.#changed();
49718
50081
  return true;
49719
50082
  }
49720
50083
  patchCustom(text) {
49721
50084
  const head = this.#asks[0];
49722
- if (!head || head.customDraft === null)
50085
+ if (!head || head.customDrafts[head.index] === null)
49723
50086
  return;
49724
- head.customDraft = text;
50087
+ head.customDrafts[head.index] = text;
49725
50088
  this.#changed();
49726
50089
  }
49727
50090
  commitCustom() {
49728
50091
  const head = this.#asks[0];
49729
50092
  const question = head?.questions[head.index];
49730
- if (!head || !question || head.customDraft === null)
50093
+ if (!head || !question)
50094
+ return;
50095
+ const draft = head.customDrafts[head.index] ?? null;
50096
+ if (draft === null)
49731
50097
  return;
49732
- const text = head.customDraft.trim();
49733
- head.customDraft = null;
50098
+ const text = draft.trim();
50099
+ head.customDrafts[head.index] = null;
49734
50100
  if (text === "") {
50101
+ this.#backToList(head);
49735
50102
  this.#changed();
49736
50103
  return;
49737
50104
  }
@@ -49745,27 +50112,124 @@ class TurnOverlayController {
49745
50112
  }
49746
50113
  if (this.#allAnswered(head)) {
49747
50114
  head.phase = "review";
50115
+ head.reviewCursor = 0;
49748
50116
  } else {
49749
50117
  const next = head.questions.findIndex((_, qi) => qi > head.index && (head.picks[qi]?.length ?? 0) === 0 && !head.customs[qi]);
49750
50118
  if (next >= 0)
49751
50119
  head.index = next;
50120
+ head.phase = head.questions[head.index]?.options.length === 0 ? "input" : "questions";
49752
50121
  }
49753
50122
  this.#changed();
49754
50123
  }
49755
50124
  cancelCustomEdit() {
49756
50125
  const head = this.#asks[0];
49757
- if (!head || head.customDraft === null)
50126
+ if (!head || head.customDrafts[head.index] === null)
50127
+ return;
50128
+ head.customDrafts[head.index] = null;
50129
+ this.#backToList(head);
50130
+ this.#changed();
50131
+ }
50132
+ get inlineText() {
50133
+ const head = this.#asks[0];
50134
+ if (!head)
50135
+ return "";
50136
+ const draft = head.customDrafts[head.index];
50137
+ if (draft !== null && draft !== undefined)
50138
+ return draft;
50139
+ return head.customs[head.index] ?? "";
50140
+ }
50141
+ setInlineText(text) {
50142
+ const head = this.#asks[0];
50143
+ const question = head?.questions[head.index];
50144
+ if (!head || !question || head.phase === "review")
50145
+ return;
50146
+ if ((head.customDrafts[head.index] ?? null) === null && text === "")
50147
+ return;
50148
+ head.customDrafts[head.index] = text;
50149
+ head.phase = "input";
50150
+ head.cursors[head.index] = inlineRowIndex(question, askNeedsReview(head.questions));
50151
+ this.#changed();
50152
+ }
50153
+ focusInput() {
50154
+ const head = this.#asks[0];
50155
+ const question = head?.questions[head.index];
50156
+ if (!head || !question || head.phase === "review")
50157
+ return;
50158
+ head.phase = "input";
50159
+ head.cursors[head.index] = inlineRowIndex(question, askNeedsReview(head.questions));
50160
+ this.#changed();
50161
+ }
50162
+ focusOptions() {
50163
+ const head = this.#asks[0];
50164
+ if (!head || head.phase !== "input")
50165
+ return;
50166
+ this.#backToList(head);
50167
+ this.#changed();
50168
+ }
50169
+ setCursor(row) {
50170
+ const head = this.#asks[0];
50171
+ const question = head?.questions[head.index];
50172
+ if (!head || !question || head.phase === "review")
50173
+ return;
50174
+ const needsReview = askNeedsReview(head.questions);
50175
+ const inline = inlineRowIndex(question, needsReview);
50176
+ const next = Math.max(0, Math.min(inline, Math.floor(row)));
50177
+ head.cursors[head.index] = next;
50178
+ head.phase = next === inline ? "input" : "questions";
50179
+ if (next !== inline)
50180
+ head.listCursors[head.index] = next;
50181
+ this.#changed();
50182
+ }
50183
+ moveCursor(delta) {
50184
+ const head = this.#asks[0];
50185
+ const question = head?.questions[head.index];
50186
+ if (!head || !question || head.phase === "review")
50187
+ return;
50188
+ const needsReview = askNeedsReview(head.questions);
50189
+ const last = questionRowCount(question, needsReview) - 1;
50190
+ const next = Math.max(0, Math.min(last, (head.cursors[head.index] ?? 0) + delta));
50191
+ const inline = inlineRowIndex(question, needsReview);
50192
+ head.cursors[head.index] = next;
50193
+ head.phase = next === inline ? "input" : "questions";
50194
+ if (next !== inline)
50195
+ head.listCursors[head.index] = next;
50196
+ this.#changed();
50197
+ }
50198
+ setReviewCursor(row) {
50199
+ const head = this.#asks[0];
50200
+ if (!head || head.phase !== "review")
50201
+ return;
50202
+ const next = Math.max(0, Math.min(head.questions.length, Math.floor(row)));
50203
+ if (next === head.reviewCursor)
49758
50204
  return;
49759
- head.customDraft = null;
50205
+ head.reviewCursor = next;
49760
50206
  this.#changed();
49761
50207
  }
50208
+ moveReviewCursor(delta) {
50209
+ this.setReviewCursor((this.#asks[0]?.reviewCursor ?? 0) + delta);
50210
+ }
50211
+ #backToList(head) {
50212
+ const question = head.questions[head.index];
50213
+ if (question === undefined)
50214
+ return;
50215
+ if (question.options.length === 0) {
50216
+ head.phase = "input";
50217
+ return;
50218
+ }
50219
+ head.phase = "questions";
50220
+ const inline = inlineRowIndex(question, askNeedsReview(head.questions));
50221
+ const row = Math.max(0, Math.min(inline - 1, head.listCursors[head.index] ?? 0));
50222
+ head.cursors[head.index] = row;
50223
+ head.listCursors[head.index] = row;
50224
+ }
49762
50225
  enterReview() {
49763
50226
  const head = this.#asks[0];
49764
50227
  if (!head || head.phase === "review")
49765
50228
  return false;
49766
- if (!this.#allAnswered(head))
50229
+ if (!askNeedsReview(head.questions))
49767
50230
  return false;
49768
50231
  head.phase = "review";
50232
+ head.reviewCursor = 0;
49769
50233
  this.#changed();
49770
50234
  return true;
49771
50235
  }
@@ -49776,6 +50240,9 @@ class TurnOverlayController {
49776
50240
  head.phase = "questions";
49777
50241
  if (focus !== undefined && focus >= 0 && focus < head.questions.length)
49778
50242
  head.index = focus;
50243
+ const question = head.questions[head.index];
50244
+ if (question !== undefined && question.options.length === 0)
50245
+ head.phase = "input";
49779
50246
  this.#changed();
49780
50247
  }
49781
50248
  submit() {
@@ -49811,6 +50278,9 @@ class TurnOverlayController {
49811
50278
  this.#changed();
49812
50279
  }
49813
50280
  }
50281
+ var init_turn_overlay_controller = __esm(() => {
50282
+ init_ask_options();
50283
+ });
49814
50284
 
49815
50285
  // ../tui-base/src/ui/dialog-confirm.tsx
49816
50286
  import { TextAttributes as TextAttributes7 } from "@opentui/core";
@@ -49963,6 +50433,1108 @@ var init_dialog_confirm = __esm(() => {
49963
50433
  init_turn_overlays();
49964
50434
  });
49965
50435
 
50436
+ // ../tui-base/src/routes/session/ask-keys.ts
50437
+ function printableText(event) {
50438
+ const text = event.sequence;
50439
+ if (text.length !== 1)
50440
+ return;
50441
+ if (event.ctrl || event.meta || event.super === true || event.hyper === true)
50442
+ return;
50443
+ if (text === " ")
50444
+ return;
50445
+ if (text >= "0" && text <= "9")
50446
+ return;
50447
+ const code = text.codePointAt(0) ?? 0;
50448
+ if (code < 32 || code === 127)
50449
+ return;
50450
+ return text;
50451
+ }
50452
+ function useAskKeys(options) {
50453
+ const keymap = Keymap2.useOptional();
50454
+ if (keymap === undefined)
50455
+ return;
50456
+ const renderer = useRenderer();
50457
+ const ownership = useInputOwnershipOptional();
50458
+ const ownsDock = () => ownership === undefined || ownership.top().kind === "dock";
50459
+ const ask = () => options.controller.pendingAsk;
50460
+ const question = () => {
50461
+ const batch = ask();
50462
+ return batch?.questions[batch.index];
50463
+ };
50464
+ const needsReview = () => askNeedsReview(ask()?.questions ?? []);
50465
+ const currentRow = () => {
50466
+ const batch = ask();
50467
+ return batch === undefined ? 0 : batch.cursors[batch.index] ?? 0;
50468
+ };
50469
+ const inputFocused = () => {
50470
+ const input = options.input();
50471
+ return input !== undefined && renderer.currentFocusedRenderable === input;
50472
+ };
50473
+ onCleanup(keymap.intercept("key", ({ event }) => {
50474
+ if (!ownsDock())
50475
+ return;
50476
+ const batch = ask();
50477
+ if (batch === undefined || batch.phase !== "questions")
50478
+ return;
50479
+ if (printableText(event) === undefined)
50480
+ return;
50481
+ options.controller.focusInput();
50482
+ options.input()?.focus();
50483
+ }));
50484
+ function move(delta) {
50485
+ const batch = ask();
50486
+ if (batch === undefined)
50487
+ return false;
50488
+ if (batch.phase === "review") {
50489
+ options.controller.moveReviewCursor(delta);
50490
+ return true;
50491
+ }
50492
+ if (batch.phase === "input")
50493
+ return false;
50494
+ options.controller.moveCursor(delta);
50495
+ return true;
50496
+ }
50497
+ function page(direction) {
50498
+ return move(direction * ASK_PAGE_ROWS);
50499
+ }
50500
+ function boundary(toEnd) {
50501
+ const batch = ask();
50502
+ if (batch === undefined)
50503
+ return false;
50504
+ if (batch.phase === "review") {
50505
+ options.controller.setReviewCursor(toEnd ? batch.questions.length : 0);
50506
+ return true;
50507
+ }
50508
+ if (batch.phase === "input")
50509
+ return false;
50510
+ const current = question();
50511
+ if (current === undefined)
50512
+ return false;
50513
+ options.controller.setCursor(toEnd ? questionRowCount(current, needsReview()) - 1 : 0);
50514
+ return true;
50515
+ }
50516
+ function switchQuestion(direction) {
50517
+ const batch = ask();
50518
+ if (batch === undefined)
50519
+ return false;
50520
+ if (batch.phase === "input")
50521
+ return false;
50522
+ if (batch.phase === "review") {
50523
+ if (direction === -1) {
50524
+ options.controller.backToQuestions(batch.questions.length - 1);
50525
+ return true;
50526
+ }
50527
+ return false;
50528
+ }
50529
+ if (batch.questions.length < 2)
50530
+ return false;
50531
+ options.controller.switchFocus(direction);
50532
+ return true;
50533
+ }
50534
+ function enter() {
50535
+ const batch = ask();
50536
+ if (batch === undefined)
50537
+ return false;
50538
+ if (batch.phase === "input")
50539
+ return false;
50540
+ if (batch.phase === "review") {
50541
+ const intent = reviewRowIntent(batch.reviewCursor, batch.questions.length);
50542
+ if (intent.kind === "submit") {
50543
+ options.controller.submit();
50544
+ return true;
50545
+ }
50546
+ options.controller.backToQuestions(intent.question);
50547
+ return true;
50548
+ }
50549
+ const current = question();
50550
+ if (current === undefined)
50551
+ return false;
50552
+ const row = currentRow();
50553
+ if (hasReviewRow(current, needsReview()) && row === current.options.length) {
50554
+ return options.controller.enterReview();
50555
+ }
50556
+ const option = current.options[row];
50557
+ if (option === undefined)
50558
+ return false;
50559
+ if (current.multiSelect === true)
50560
+ return options.controller.confirmQuestion();
50561
+ options.controller.toggle(option.label);
50562
+ return true;
50563
+ }
50564
+ function space() {
50565
+ const batch = ask();
50566
+ if (batch === undefined || batch.phase !== "questions")
50567
+ return false;
50568
+ const current = question();
50569
+ if (current === undefined || current.multiSelect !== true)
50570
+ return false;
50571
+ if (inputFocused())
50572
+ return false;
50573
+ const option = current.options[currentRow()];
50574
+ if (option === undefined)
50575
+ return false;
50576
+ options.controller.toggle(option.label);
50577
+ return true;
50578
+ }
50579
+ function digit(index) {
50580
+ const batch = ask();
50581
+ if (batch === undefined || batch.phase !== "questions")
50582
+ return false;
50583
+ if (inputFocused())
50584
+ return false;
50585
+ const option = question()?.options[index];
50586
+ if (option === undefined)
50587
+ return false;
50588
+ options.controller.toggle(option.label);
50589
+ return true;
50590
+ }
50591
+ function atOutermost(batch) {
50592
+ if (batch.phase === "review" || batch.index > 0)
50593
+ return false;
50594
+ if (batch.phase === "input")
50595
+ return (batch.questions[batch.index]?.options.length ?? 0) === 0;
50596
+ return true;
50597
+ }
50598
+ function backOut() {
50599
+ const batch = ask();
50600
+ if (batch === undefined)
50601
+ return false;
50602
+ if (batch.phase === "review") {
50603
+ options.controller.backToQuestions(batch.questions.length - 1);
50604
+ return true;
50605
+ }
50606
+ if (batch.phase === "input") {
50607
+ const current = batch.questions[batch.index];
50608
+ if (current !== undefined && current.options.length > 0) {
50609
+ options.controller.focusOptions();
50610
+ return true;
50611
+ }
50612
+ }
50613
+ if (batch.index > 0) {
50614
+ options.controller.switchFocus(-1);
50615
+ return true;
50616
+ }
50617
+ options.controller.decline();
50618
+ return true;
50619
+ }
50620
+ function interrupt() {
50621
+ const batch = ask();
50622
+ if (batch === undefined)
50623
+ return false;
50624
+ if (atOutermost(batch))
50625
+ armNonArmingInterrupt();
50626
+ return backOut();
50627
+ }
50628
+ Keymap2.createLayer(() => ({
50629
+ mode: "global",
50630
+ enabled: ownsDock,
50631
+ commands: [
50632
+ { bind: "up,ctrl+p", run: () => move(-1) },
50633
+ { bind: "down,ctrl+n", run: () => move(1) },
50634
+ { bind: "pageup", run: () => page(-1) },
50635
+ { bind: "pagedown", run: () => page(1) },
50636
+ { bind: "home", run: () => boundary(false) },
50637
+ { bind: "end", run: () => boundary(true) },
50638
+ { bind: "return", run: enter },
50639
+ { bind: "space", run: space },
50640
+ ...Array.from({ length: 9 }, (_, index) => ({
50641
+ bind: `${index + 1}`,
50642
+ enabled: () => !inputFocused(),
50643
+ run: () => digit(index)
50644
+ })),
50645
+ { bind: "left", run: () => switchQuestion(-1) },
50646
+ { bind: "right", run: () => switchQuestion(1) },
50647
+ { bind: "escape", run: backOut },
50648
+ { bind: "ctrl+c", run: interrupt }
50649
+ ]
50650
+ }));
50651
+ }
50652
+ var ASK_PAGE_ROWS = 5;
50653
+ var init_ask_keys = __esm(() => {
50654
+ init_index_bun();
50655
+ init_server();
50656
+ init_keymap();
50657
+ init_input_ownership();
50658
+ init_ask_options();
50659
+ init_turn_cancel();
50660
+ });
50661
+
50662
+ // ../tui-base/src/routes/session/dock-host.tsx
50663
+ function firstFocusable(node) {
50664
+ if (node === undefined)
50665
+ return;
50666
+ for (const child of node.getChildren()) {
50667
+ if (child.focusable)
50668
+ return child;
50669
+ const nested = firstFocusable(child);
50670
+ if (nested !== undefined)
50671
+ return nested;
50672
+ }
50673
+ return;
50674
+ }
50675
+ function DockProvider(props) {
50676
+ const renderer = useRenderer();
50677
+ const ownership = useInputOwnershipOptional();
50678
+ const [queue, setQueue] = createSignal([]);
50679
+ let frame;
50680
+ let composerFocus;
50681
+ let focusTarget;
50682
+ let cancelAfterLayout;
50683
+ const hasRequests = () => queue().length > 0;
50684
+ function afterLayout(callback) {
50685
+ cancelAfterLayout?.();
50686
+ if (renderer.isDestroyed)
50687
+ return;
50688
+ let done = false;
50689
+ const handler = () => {
50690
+ if (done)
50691
+ return;
50692
+ done = true;
50693
+ renderer.off("frame", handler);
50694
+ if (cancelAfterLayout === cancel)
50695
+ cancelAfterLayout = undefined;
50696
+ callback();
50697
+ };
50698
+ const cancel = () => {
50699
+ if (done)
50700
+ return;
50701
+ done = true;
50702
+ renderer.off("frame", handler);
50703
+ if (cancelAfterLayout === cancel)
50704
+ cancelAfterLayout = undefined;
50705
+ };
50706
+ cancelAfterLayout = cancel;
50707
+ renderer.on("frame", handler);
50708
+ }
50709
+ function focusDock() {
50710
+ afterLayout(() => {
50711
+ if (!hasRequests())
50712
+ return;
50713
+ const target = focusTarget?.();
50714
+ if (target !== undefined) {
50715
+ target.focus();
50716
+ return;
50717
+ }
50718
+ renderer.currentFocusedRenderable?.blur();
50719
+ });
50720
+ }
50721
+ function remove(entry) {
50722
+ const before = queue();
50723
+ if (!before.includes(entry))
50724
+ return;
50725
+ const next = before.filter((item) => item !== entry);
50726
+ setQueue(next);
50727
+ if (next.length > 0) {
50728
+ if (before[0] !== next[0])
50729
+ focusDock();
50730
+ return;
50731
+ }
50732
+ if (frame !== undefined) {
50733
+ ownership?.pop(frame);
50734
+ frame = undefined;
50735
+ }
50736
+ afterLayout(() => {
50737
+ if (hasRequests())
50738
+ return;
50739
+ composerFocus?.();
50740
+ });
50741
+ }
50742
+ const api = {
50743
+ open(render, options = {}) {
50744
+ const id = ++ordinal2;
50745
+ const entry = {
50746
+ id,
50747
+ kind: options.kind,
50748
+ options,
50749
+ close: () => remove(entry),
50750
+ render
50751
+ };
50752
+ const before = queue();
50753
+ setQueue([...before, entry]);
50754
+ if (before.length === 0) {
50755
+ frame = ownership?.push("dock");
50756
+ focusDock();
50757
+ }
50758
+ return {
50759
+ id,
50760
+ close: entry.close
50761
+ };
50762
+ },
50763
+ queueDepth: () => Math.max(0, queue().length - 1),
50764
+ isOpen: () => hasRequests(),
50765
+ currentKind: () => queue()[0]?.kind,
50766
+ current: () => queue()[0],
50767
+ bindComposerFocus(refocus) {
50768
+ composerFocus = refocus;
50769
+ },
50770
+ bindFocusTarget(resolve) {
50771
+ focusTarget = resolve;
50772
+ }
50773
+ };
50774
+ onCleanup(() => {
50775
+ cancelAfterLayout?.();
50776
+ if (frame !== undefined) {
50777
+ ownership?.pop(frame);
50778
+ frame = undefined;
50779
+ }
50780
+ setQueue([]);
50781
+ });
50782
+ return createComponent2(Context7.Provider, {
50783
+ value: api,
50784
+ get children() {
50785
+ return props.children;
50786
+ }
50787
+ });
50788
+ }
50789
+ function useDock() {
50790
+ const value = useContext(Context7);
50791
+ if (!value)
50792
+ throw new Error("Dock.Provider is missing");
50793
+ return value;
50794
+ }
50795
+ function DockSeat(props) {
50796
+ const dock = useDock();
50797
+ const dimensions = useTerminalSize();
50798
+ const theme = useThemeOptional();
50799
+ let scroll;
50800
+ let body;
50801
+ let disposed = false;
50802
+ const [measured, setMeasured] = createSignal(undefined);
50803
+ const resolveFocus = () => {
50804
+ const designated = dock.current()?.options.focusRef?.();
50805
+ return designated ?? firstFocusable(body);
50806
+ };
50807
+ dock.bindFocusTarget(resolveFocus);
50808
+ onCleanup(() => {
50809
+ disposed = true;
50810
+ dock.bindFocusTarget(undefined);
50811
+ });
50812
+ const capRows = () => Math.max(1, Math.floor(dimensions().height * DOCK_MAX_ROWS_RATIO));
50813
+ const contentRows = () => measured() ?? dock.current()?.options.contentRows ?? capRows();
50814
+ const overflows = () => contentRows() > capRows() && capRows() > 1;
50815
+ const viewportRows = () => Math.max(1, Math.min(contentRows(), capRows() - (overflows() ? 1 : 0)));
50816
+ const hiddenRows = () => Math.max(0, contentRows() - viewportRows());
50817
+ const indicatorText = () => {
50818
+ const label = dock.current()?.options.overflowLabel;
50819
+ return label ? label(hiddenRows()) : `\u2191\u2193 ${hiddenRows()}`;
50820
+ };
50821
+ const muted = () => theme?.text.muted ?? "#9aa5ce";
50822
+ const background = () => theme?.background.base ?? "black";
50823
+ createEffect(on(() => dock.current()?.id, () => {
50824
+ if (scroll !== undefined && !scroll.isDestroyed)
50825
+ scroll.scrollTo(0);
50826
+ }, {
50827
+ defer: true
50828
+ }));
50829
+ createEffect(on(capRows, () => {
50830
+ if (scroll === undefined || scroll.isDestroyed)
50831
+ return;
50832
+ scroll.afterLayout(() => {
50833
+ if (scroll === undefined || scroll.isDestroyed)
50834
+ return;
50835
+ const max = Math.max(0, scroll.scrollHeight - scroll.viewport.height);
50836
+ if (scroll.scrollTop > max)
50837
+ scroll.scrollTo(max);
50838
+ });
50839
+ }, {
50840
+ defer: true
50841
+ }));
50842
+ return (() => {
50843
+ var _el$ = createElement("box"), _el$2 = createElement("box");
50844
+ insertNode(_el$, _el$2);
50845
+ setProp(_el$, "width", "100%");
50846
+ setProp(_el$, "flexShrink", 0);
50847
+ setProp(_el$, "flexDirection", "column");
50848
+ setProp(_el$2, "width", "100%");
50849
+ setProp(_el$2, "flexShrink", 0);
50850
+ insert(_el$2, () => props.composer());
50851
+ insert(_el$, createComponent2(Show, {
50852
+ get when() {
50853
+ return dock.current();
50854
+ },
50855
+ children: (request) => (() => {
50856
+ var _el$3 = createElement("box"), _el$4 = createElement("scrollbox"), _el$5 = createElement("box");
50857
+ insertNode(_el$3, _el$4);
50858
+ setProp(_el$3, "width", "100%");
50859
+ setProp(_el$3, "flexShrink", 0);
50860
+ setProp(_el$3, "flexDirection", "column");
50861
+ insertNode(_el$4, _el$5);
50862
+ use((value) => {
50863
+ scroll = value;
50864
+ }, _el$4);
50865
+ setProp(_el$4, "width", "100%");
50866
+ setProp(_el$4, "flexShrink", 0);
50867
+ setProp(_el$4, "focusable", false);
50868
+ setProp(_el$4, "scrollY", true);
50869
+ setProp(_el$4, "scrollX", false);
50870
+ setProp(_el$4, "overflow", "hidden");
50871
+ setProp(_el$4, "verticalScrollbarOptions", {
50872
+ visible: false
50873
+ });
50874
+ use((value) => {
50875
+ body = value;
50876
+ }, _el$5);
50877
+ setProp(_el$5, "width", "100%");
50878
+ setProp(_el$5, "flexDirection", "column");
50879
+ setProp(_el$5, "onSizeChange", function() {
50880
+ if (disposed)
50881
+ return;
50882
+ const next = Math.max(0, Math.floor(this.height));
50883
+ if (next !== measured())
50884
+ setMeasured(next);
50885
+ });
50886
+ insert(_el$5, () => request().render({
50887
+ id: request().id,
50888
+ close: request().close,
50889
+ width: () => dimensions().width,
50890
+ maxHeight: capRows
50891
+ }));
50892
+ insert(_el$3, createComponent2(Show, {
50893
+ get when() {
50894
+ return memo2(() => !!overflows())() && hiddenRows() > 0;
50895
+ },
50896
+ get children() {
50897
+ var _el$6 = createElement("text");
50898
+ setProp(_el$6, "wrapMode", "none");
50899
+ setProp(_el$6, "paddingLeft", 1);
50900
+ insert(_el$6, indicatorText);
50901
+ effect((_$p) => setProp(_el$6, "fg", muted(), _$p));
50902
+ return _el$6;
50903
+ }
50904
+ }), null);
50905
+ effect((_p$) => {
50906
+ var _v$ = background(), _v$2 = viewportRows();
50907
+ _v$ !== _p$.e && (_p$.e = setProp(_el$3, "backgroundColor", _v$, _p$.e));
50908
+ _v$2 !== _p$.t && (_p$.t = setProp(_el$4, "height", _v$2, _p$.t));
50909
+ return _p$;
50910
+ }, {
50911
+ e: undefined,
50912
+ t: undefined
50913
+ });
50914
+ return _el$3;
50915
+ })()
50916
+ }), null);
50917
+ effect((_$p) => setProp(_el$2, "visible", !dock.isOpen(), _$p));
50918
+ return _el$;
50919
+ })();
50920
+ }
50921
+ var DOCK_MAX_ROWS_RATIO = 0.6, Context7, ordinal2 = 0;
50922
+ var init_dock_host = __esm(() => {
50923
+ init_index_bun();
50924
+ init_index_bun();
50925
+ init_index_bun();
50926
+ init_index_bun();
50927
+ init_index_bun();
50928
+ init_index_bun();
50929
+ init_index_bun();
50930
+ init_index_bun();
50931
+ init_server();
50932
+ init_index_bun();
50933
+ init_input_ownership();
50934
+ init_theme3();
50935
+ init_terminal_size();
50936
+ Context7 = createContext(undefined);
50937
+ });
50938
+
50939
+ // ../tui-base/src/routes/session/ask-panel.tsx
50940
+ function resolveFocus(ask, list, input) {
50941
+ if (ask === undefined)
50942
+ return;
50943
+ if (ask.phase === "input")
50944
+ return input;
50945
+ return list ?? input;
50946
+ }
50947
+ function nearestScroller(node) {
50948
+ let current = node;
50949
+ while (current !== null && current !== undefined) {
50950
+ const candidate = current;
50951
+ if (typeof candidate.scrollChildIntoView === "function")
50952
+ return current;
50953
+ current = current.parent;
50954
+ }
50955
+ return;
50956
+ }
50957
+ function AskPanel(props) {
50958
+ const theme = useThemeOptional();
50959
+ const dock = useDock();
50960
+ let configCursorStyle;
50961
+ try {
50962
+ configCursorStyle = useCursorStyle();
50963
+ } catch {
50964
+ configCursorStyle = undefined;
50965
+ }
50966
+ const [version, setVersion] = createSignal(0);
50967
+ onMount(() => {
50968
+ const unsubscribe = props.controller.subscribe(() => setVersion((value) => value + 1));
50969
+ onCleanup(unsubscribe);
50970
+ });
50971
+ const ask = () => {
50972
+ version();
50973
+ return props.controller.pendingAsk;
50974
+ };
50975
+ const questions = () => ask()?.questions ?? [];
50976
+ const question = () => {
50977
+ const batch = ask();
50978
+ return batch?.questions[batch.index];
50979
+ };
50980
+ const index = () => ask()?.index ?? 0;
50981
+ const phase = () => ask()?.phase ?? "questions";
50982
+ const phaseOf = () => {
50983
+ if (phase() === "review")
50984
+ return "review";
50985
+ return phase() === "input" ? "input" : "options";
50986
+ };
50987
+ const picks = () => {
50988
+ const batch = ask();
50989
+ return batch ? batch.picks[batch.index] ?? [] : [];
50990
+ };
50991
+ const cursor = () => {
50992
+ const batch = ask();
50993
+ return batch ? batch.cursors[batch.index] ?? 0 : 0;
50994
+ };
50995
+ const listCursor = () => {
50996
+ const batch = ask();
50997
+ return batch ? batch.listCursors[batch.index] ?? 0 : 0;
50998
+ };
50999
+ const markedRow = () => phaseOf() === "input" ? listCursor() : cursor();
51000
+ const reviewCursor = () => ask()?.reviewCursor ?? 0;
51001
+ const multi = () => question()?.multiSelect === true;
51002
+ const compact = () => props.width() < ASK_COMPACT_COLUMNS;
51003
+ const needsReview = () => askNeedsReview(questions());
51004
+ const eyebrow = () => {
51005
+ if (phaseOf() === "review")
51006
+ return;
51007
+ const current = question();
51008
+ if (current?.header === undefined || current.header === current.prompt)
51009
+ return;
51010
+ return current.header;
51011
+ };
51012
+ const muted = () => theme?.text.muted ?? "#9aa5ce";
51013
+ const faint = () => theme?.text.faint ?? "#565f89";
51014
+ const base = () => theme?.text.base ?? "#e6e6e6";
51015
+ const accent = () => theme?.hue.interactive[500] ?? "#7aa2f7";
51016
+ const currentBg = () => theme?.background.action.primary.focused;
51017
+ const currentFg = () => theme?.text.action.primary.focused ?? accent();
51018
+ const rule = () => theme?.border.base ?? "#565f89";
51019
+ const cursorShape = () => {
51020
+ try {
51021
+ return configCursorStyle?.()?.style;
51022
+ } catch {
51023
+ return;
51024
+ }
51025
+ };
51026
+ let listEl;
51027
+ let inputEl;
51028
+ let inlineRowEl;
51029
+ useAskKeys({
51030
+ controller: props.controller,
51031
+ input: () => inputEl
51032
+ });
51033
+ const queuedCount = () => {
51034
+ version();
51035
+ return props.queued?.() ?? dock.queueDepth();
51036
+ };
51037
+ props.onFocusTarget?.(() => resolveFocus(ask(), listEl, inputEl));
51038
+ function revealRow(row) {
51039
+ if (row === undefined || row.isDestroyed)
51040
+ return;
51041
+ const scroller = nearestScroller(row);
51042
+ if (scroller === undefined)
51043
+ return;
51044
+ scroller.scrollChildIntoView(row, {
51045
+ align: "nearest"
51046
+ });
51047
+ }
51048
+ function focusInputRow() {
51049
+ const input = inputEl;
51050
+ if (input === undefined || input.isDestroyed)
51051
+ return;
51052
+ input.focus();
51053
+ revealRow(inlineRowEl);
51054
+ }
51055
+ createEffect(on(() => phase(), (next) => {
51056
+ if (next === "input") {
51057
+ focusInputRow();
51058
+ return;
51059
+ }
51060
+ if (next !== "questions")
51061
+ return;
51062
+ const focusList = () => {
51063
+ if (listEl !== undefined && !listEl.isDestroyed)
51064
+ listEl.focus();
51065
+ };
51066
+ if (listEl !== undefined && !listEl.isDestroyed)
51067
+ focusList();
51068
+ else
51069
+ queueMicrotask(focusList);
51070
+ }));
51071
+ createEffect(on(() => index(), () => phase() === "input" ? focusInputRow() : undefined, {
51072
+ defer: true
51073
+ }));
51074
+ createEffect(on([() => index(), cursor], () => {
51075
+ if (phaseOf() !== "options")
51076
+ return;
51077
+ revealRow(listEl?.getChildren()[cursor()]);
51078
+ }));
51079
+ const optionRows = () => (question()?.options ?? []).map((option, position) => ({
51080
+ option,
51081
+ number: position + 1,
51082
+ selected: picks().includes(option.label)
51083
+ }));
51084
+ const labelColumn = (row) => GUTTER + CURSOR_CELLS + STATE_CELLS + `${row.number}. `.length;
51085
+ const footerHint = () => {
51086
+ if (phaseOf() === "review")
51087
+ return t("overlay.ask.footer.review", {
51088
+ esc: t("overlay.ask.esc.review")
51089
+ });
51090
+ if (phaseOf() === "input") {
51091
+ const escKey = question()?.options.length === 0 ? index() > 0 ? "overlay.ask.esc.prevQuestion" : "overlay.ask.esc.decline" : "overlay.ask.esc.back";
51092
+ return t("overlay.ask.footer.input", {
51093
+ esc: t(escKey)
51094
+ });
51095
+ }
51096
+ const escKey = questions().length > 1 && index() > 0 ? "overlay.ask.esc.prevQuestion" : "overlay.ask.esc.decline";
51097
+ return t(multi() ? "overlay.ask.footer.multi" : "overlay.ask.footer.options", {
51098
+ esc: t(escKey)
51099
+ });
51100
+ };
51101
+ const answerText = (qi) => {
51102
+ const batch = ask();
51103
+ if (!batch)
51104
+ return "";
51105
+ const custom = batch.customs[qi];
51106
+ if (custom !== undefined && custom !== "")
51107
+ return custom;
51108
+ return (batch.picks[qi] ?? []).map((label) => splitRecommended(label).label).join(", ");
51109
+ };
51110
+ const reviewRowActive = (qi) => reviewCursor() === qi;
51111
+ const reviewSubmitActive = () => reviewRowIntent(reviewCursor(), questions().length).kind === "submit";
51112
+ return (() => {
51113
+ 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");
51114
+ insertNode(_el$, _el$2);
51115
+ insertNode(_el$, _el$3);
51116
+ insertNode(_el$, _el$1);
51117
+ insertNode(_el$, _el$12);
51118
+ setProp(_el$, "flexDirection", "column");
51119
+ setProp(_el$, "width", "100%");
51120
+ setProp(_el$, "flexShrink", 0);
51121
+ setProp(_el$2, "width", "100%");
51122
+ setProp(_el$2, "flexShrink", 0);
51123
+ setProp(_el$2, "border", ["top"]);
51124
+ setProp(_el$2, "borderStyle", "single");
51125
+ insert(_el$, createComponent2(Show, {
51126
+ get when() {
51127
+ return eyebrow();
51128
+ },
51129
+ children: (header) => (() => {
51130
+ var _el$13 = createElement("box"), _el$14 = createElement("text");
51131
+ insertNode(_el$13, _el$14);
51132
+ setProp(_el$13, "paddingLeft", 2);
51133
+ setProp(_el$13, "paddingRight", 2);
51134
+ setProp(_el$14, "wrapMode", "none");
51135
+ insert(_el$14, header);
51136
+ effect((_$p) => setProp(_el$14, "fg", muted(), _$p));
51137
+ return _el$13;
51138
+ })()
51139
+ }), _el$3);
51140
+ insertNode(_el$3, _el$4);
51141
+ setProp(_el$3, "paddingLeft", 2);
51142
+ setProp(_el$3, "paddingRight", 2);
51143
+ setProp(_el$4, "wrapMode", "word");
51144
+ insert(_el$4, (() => {
51145
+ var _c$ = memo2(() => phaseOf() === "review");
51146
+ return () => _c$() ? t("overlay.ask.reviewTitle") : question()?.prompt ?? "";
51147
+ })());
51148
+ insert(_el$, createComponent2(Show, {
51149
+ get when() {
51150
+ return questions().length >= 2;
51151
+ },
51152
+ get children() {
51153
+ var _el$5 = createElement("box"), _el$6 = createElement("text");
51154
+ insertNode(_el$5, _el$6);
51155
+ setProp(_el$5, "paddingLeft", 2);
51156
+ setProp(_el$5, "paddingRight", 2);
51157
+ setProp(_el$6, "wrapMode", "none");
51158
+ insert(_el$6, () => askTabStrip(questions(), ask()?.picks ?? [], index(), ask()?.customs));
51159
+ effect((_$p) => setProp(_el$6, "fg", muted(), _$p));
51160
+ return _el$5;
51161
+ }
51162
+ }), _el$1);
51163
+ insert(_el$, createComponent2(Show, {
51164
+ get when() {
51165
+ return memo2(() => phaseOf() !== "review")() ? question()?.detail : undefined;
51166
+ },
51167
+ children: (detail) => (() => {
51168
+ var _el$15 = createElement("box"), _el$16 = createElement("text");
51169
+ insertNode(_el$15, _el$16);
51170
+ setProp(_el$15, "paddingLeft", 2);
51171
+ setProp(_el$15, "paddingRight", 2);
51172
+ setProp(_el$16, "wrapMode", "word");
51173
+ insert(_el$16, detail);
51174
+ effect((_$p) => setProp(_el$16, "fg", muted(), _$p));
51175
+ return _el$15;
51176
+ })()
51177
+ }), _el$1);
51178
+ insert(_el$, createComponent2(Show, {
51179
+ get when() {
51180
+ return phaseOf() === "review";
51181
+ },
51182
+ get fallback() {
51183
+ return [(() => {
51184
+ var _el$17 = createElement("box");
51185
+ use((value) => {
51186
+ listEl = value;
51187
+ }, _el$17);
51188
+ setProp(_el$17, "flexDirection", "column");
51189
+ setProp(_el$17, "width", "100%");
51190
+ setProp(_el$17, "flexShrink", 0);
51191
+ setProp(_el$17, "focusable", true);
51192
+ insert(_el$17, createComponent2(Index, {
51193
+ get each() {
51194
+ return optionRows();
51195
+ },
51196
+ children: (row, position) => createComponent2(OptionRow, {
51197
+ row,
51198
+ cursor: () => phaseOf() !== "input" && position === cursor(),
51199
+ marked: () => position === markedRow(),
51200
+ multi: () => multi(),
51201
+ compact: () => compact(),
51202
+ width: () => props.width(),
51203
+ labelColumn: () => labelColumn(row())
51204
+ })
51205
+ }), null);
51206
+ insert(_el$17, createComponent2(Show, {
51207
+ get when() {
51208
+ return memo2(() => question() !== undefined)() && hasReviewRow(question(), needsReview());
51209
+ },
51210
+ get children() {
51211
+ var _el$18 = createElement("box"), _el$19 = createElement("text"), _el$20 = createElement("text");
51212
+ insertNode(_el$18, _el$19);
51213
+ insertNode(_el$18, _el$20);
51214
+ setProp(_el$18, "flexDirection", "row");
51215
+ setProp(_el$18, "width", "100%");
51216
+ setProp(_el$18, "flexShrink", 0);
51217
+ setProp(_el$18, "paddingLeft", 2);
51218
+ insert(_el$19, () => markedRow() === (question()?.options.length ?? 0) ? "\u203A " : " ");
51219
+ setProp(_el$20, "wrapMode", "word");
51220
+ insert(_el$20, () => t("overlay.ask.reviewRow"));
51221
+ effect((_p$) => {
51222
+ 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();
51223
+ _v$8 !== _p$.e && (_p$.e = setProp(_el$18, "backgroundColor", _v$8, _p$.e));
51224
+ _v$9 !== _p$.t && (_p$.t = setProp(_el$19, "fg", _v$9, _p$.t));
51225
+ _v$0 !== _p$.a && (_p$.a = setProp(_el$20, "fg", _v$0, _p$.a));
51226
+ return _p$;
51227
+ }, {
51228
+ e: undefined,
51229
+ t: undefined,
51230
+ a: undefined
51231
+ });
51232
+ return _el$18;
51233
+ }
51234
+ }), null);
51235
+ return _el$17;
51236
+ })(), (() => {
51237
+ var _el$21 = createElement("box"), _el$22 = createElement("text"), _el$24 = createElement("input");
51238
+ insertNode(_el$21, _el$22);
51239
+ insertNode(_el$21, _el$24);
51240
+ use((value) => {
51241
+ inlineRowEl = value;
51242
+ }, _el$21);
51243
+ setProp(_el$21, "flexDirection", "row");
51244
+ setProp(_el$21, "width", "100%");
51245
+ setProp(_el$21, "flexShrink", 0);
51246
+ setProp(_el$21, "paddingLeft", 2);
51247
+ insertNode(_el$22, createTextNode(`\u270E `));
51248
+ use((value) => {
51249
+ inputEl = value;
51250
+ }, _el$24);
51251
+ setProp(_el$24, "flexGrow", 1);
51252
+ setProp(_el$24, "onInput", (value) => props.controller.setInlineText(value));
51253
+ setProp(_el$24, "onSubmit", () => props.controller.commitCustom());
51254
+ effect((_p$) => {
51255
+ 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();
51256
+ _v$1 !== _p$.e && (_p$.e = setProp(_el$21, "backgroundColor", _v$1, _p$.e));
51257
+ _v$10 !== _p$.t && (_p$.t = setProp(_el$22, "fg", _v$10, _p$.t));
51258
+ _v$11 !== _p$.a && (_p$.a = setProp(_el$24, "value", _v$11, _p$.a));
51259
+ _v$12 !== _p$.o && (_p$.o = setProp(_el$24, "placeholder", _v$12, _p$.o));
51260
+ _v$13 !== _p$.i && (_p$.i = setProp(_el$24, "placeholderColor", _v$13, _p$.i));
51261
+ _v$14 !== _p$.n && (_p$.n = setProp(_el$24, "textColor", _v$14, _p$.n));
51262
+ _v$15 !== _p$.s && (_p$.s = setProp(_el$24, "focusedTextColor", _v$15, _p$.s));
51263
+ _v$16 !== _p$.h && (_p$.h = setProp(_el$24, "cursorColor", _v$16, _p$.h));
51264
+ _v$17 !== _p$.r && (_p$.r = setProp(_el$24, "cursorStyle", _v$17, _p$.r));
51265
+ return _p$;
51266
+ }, {
51267
+ e: undefined,
51268
+ t: undefined,
51269
+ a: undefined,
51270
+ o: undefined,
51271
+ i: undefined,
51272
+ n: undefined,
51273
+ s: undefined,
51274
+ h: undefined,
51275
+ r: undefined
51276
+ });
51277
+ return _el$21;
51278
+ })()];
51279
+ },
51280
+ get children() {
51281
+ var _el$7 = createElement("box"), _el$8 = createElement("box"), _el$9 = createElement("text"), _el$0 = createElement("text");
51282
+ insertNode(_el$7, _el$8);
51283
+ setProp(_el$7, "flexDirection", "column");
51284
+ setProp(_el$7, "width", "100%");
51285
+ setProp(_el$7, "flexShrink", 0);
51286
+ insert(_el$7, createComponent2(Index, {
51287
+ get each() {
51288
+ return questions();
51289
+ },
51290
+ children: (item, qi) => (() => {
51291
+ 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");
51292
+ insertNode(_el$25, _el$26);
51293
+ insertNode(_el$25, _el$31);
51294
+ setProp(_el$25, "flexDirection", "column");
51295
+ setProp(_el$25, "width", "100%");
51296
+ setProp(_el$25, "flexShrink", 0);
51297
+ insertNode(_el$26, _el$27);
51298
+ insertNode(_el$26, _el$28);
51299
+ insertNode(_el$26, _el$30);
51300
+ setProp(_el$26, "flexDirection", "row");
51301
+ setProp(_el$26, "width", "100%");
51302
+ setProp(_el$26, "flexShrink", 0);
51303
+ setProp(_el$26, "paddingLeft", 2);
51304
+ insert(_el$27, () => reviewRowActive(qi) ? "\u203A " : " ");
51305
+ insertNode(_el$28, createTextNode(`\u2713 `));
51306
+ setProp(_el$30, "wrapMode", "word");
51307
+ insert(_el$30, () => item().prompt);
51308
+ insertNode(_el$31, _el$32);
51309
+ setProp(_el$31, "paddingLeft", 6);
51310
+ setProp(_el$32, "wrapMode", "word");
51311
+ insert(_el$32, () => `\u2192 ${answerText(qi) !== "" ? answerText(qi) : t("overlay.ask.unanswered")}`);
51312
+ effect((_p$) => {
51313
+ 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();
51314
+ _v$18 !== _p$.e && (_p$.e = setProp(_el$26, "backgroundColor", _v$18, _p$.e));
51315
+ _v$19 !== _p$.t && (_p$.t = setProp(_el$27, "fg", _v$19, _p$.t));
51316
+ _v$20 !== _p$.a && (_p$.a = setProp(_el$28, "fg", _v$20, _p$.a));
51317
+ _v$21 !== _p$.o && (_p$.o = setProp(_el$30, "fg", _v$21, _p$.o));
51318
+ _v$22 !== _p$.i && (_p$.i = setProp(_el$32, "fg", _v$22, _p$.i));
51319
+ return _p$;
51320
+ }, {
51321
+ e: undefined,
51322
+ t: undefined,
51323
+ a: undefined,
51324
+ o: undefined,
51325
+ i: undefined
51326
+ });
51327
+ return _el$25;
51328
+ })()
51329
+ }), _el$8);
51330
+ insertNode(_el$8, _el$9);
51331
+ insertNode(_el$8, _el$0);
51332
+ setProp(_el$8, "flexDirection", "row");
51333
+ setProp(_el$8, "width", "100%");
51334
+ setProp(_el$8, "flexShrink", 0);
51335
+ setProp(_el$8, "paddingLeft", 2);
51336
+ insert(_el$9, () => reviewSubmitActive() ? "\u203A " : " ");
51337
+ setProp(_el$0, "wrapMode", "none");
51338
+ insert(_el$0, () => t("overlay.ask.submitRow"));
51339
+ effect((_p$) => {
51340
+ var _v$ = reviewSubmitActive() ? currentBg() : undefined, _v$2 = reviewSubmitActive() ? currentFg() : accent(), _v$3 = reviewSubmitActive() ? currentFg() : base();
51341
+ _v$ !== _p$.e && (_p$.e = setProp(_el$8, "backgroundColor", _v$, _p$.e));
51342
+ _v$2 !== _p$.t && (_p$.t = setProp(_el$9, "fg", _v$2, _p$.t));
51343
+ _v$3 !== _p$.a && (_p$.a = setProp(_el$0, "fg", _v$3, _p$.a));
51344
+ return _p$;
51345
+ }, {
51346
+ e: undefined,
51347
+ t: undefined,
51348
+ a: undefined
51349
+ });
51350
+ return _el$7;
51351
+ }
51352
+ }), _el$1);
51353
+ insertNode(_el$1, _el$10);
51354
+ setProp(_el$1, "flexDirection", "row");
51355
+ setProp(_el$1, "width", "100%");
51356
+ setProp(_el$1, "justifyContent", "space-between");
51357
+ setProp(_el$1, "paddingLeft", 2);
51358
+ setProp(_el$1, "paddingRight", 2);
51359
+ setProp(_el$10, "wrapMode", "none");
51360
+ insert(_el$10, footerHint);
51361
+ insert(_el$1, createComponent2(Show, {
51362
+ get when() {
51363
+ return queuedCount() > 0;
51364
+ },
51365
+ get children() {
51366
+ var _el$11 = createElement("text");
51367
+ setProp(_el$11, "wrapMode", "none");
51368
+ insert(_el$11, () => t("overlay.ask.queued", {
51369
+ count: queuedCount()
51370
+ }));
51371
+ effect((_$p) => setProp(_el$11, "fg", muted(), _$p));
51372
+ return _el$11;
51373
+ }
51374
+ }), null);
51375
+ setProp(_el$12, "width", "100%");
51376
+ setProp(_el$12, "flexShrink", 0);
51377
+ setProp(_el$12, "border", ["bottom"]);
51378
+ setProp(_el$12, "borderStyle", "single");
51379
+ effect((_p$) => {
51380
+ var _v$4 = rule(), _v$5 = warningColor(theme), _v$6 = muted(), _v$7 = rule();
51381
+ _v$4 !== _p$.e && (_p$.e = setProp(_el$2, "borderColor", _v$4, _p$.e));
51382
+ _v$5 !== _p$.t && (_p$.t = setProp(_el$4, "fg", _v$5, _p$.t));
51383
+ _v$6 !== _p$.a && (_p$.a = setProp(_el$10, "fg", _v$6, _p$.a));
51384
+ _v$7 !== _p$.o && (_p$.o = setProp(_el$12, "borderColor", _v$7, _p$.o));
51385
+ return _p$;
51386
+ }, {
51387
+ e: undefined,
51388
+ t: undefined,
51389
+ a: undefined,
51390
+ o: undefined
51391
+ });
51392
+ return _el$;
51393
+ })();
51394
+ }
51395
+ function OptionRow(props) {
51396
+ const theme = useThemeOptional();
51397
+ const muted = () => theme?.text.muted ?? "#9aa5ce";
51398
+ const faint = () => theme?.text.faint ?? "#565f89";
51399
+ const base = () => theme?.text.base ?? "#e6e6e6";
51400
+ const accent = () => theme?.hue.interactive[500] ?? "#7aa2f7";
51401
+ const success = () => theme?.text.feedback.success.base ?? "#9ece6a";
51402
+ const currentBg = () => theme?.background.action.primary.focused;
51403
+ const currentFg = () => theme?.text.action.primary.focused ?? accent();
51404
+ const label = () => splitRecommended(props.row().option.label);
51405
+ const number = () => `${props.row().number}. `;
51406
+ const badge = () => `[${t("overlay.ask.recommended")}]`;
51407
+ const stateGlyph = () => {
51408
+ if (props.multi())
51409
+ return props.row().selected ? "\u25A0 " : "\u25A1 ";
51410
+ return props.row().selected ? "\u25CF " : "\u25CB ";
51411
+ };
51412
+ const stateColor = () => {
51413
+ if (props.cursor())
51414
+ return currentFg();
51415
+ return props.row().selected ? success() : faint();
51416
+ };
51417
+ const badgeInline = () => {
51418
+ if (!label().recommended || props.compact())
51419
+ return false;
51420
+ const used = props.labelColumn() + stringWidth(label().label) + BADGE_GAP + stringWidth(badge());
51421
+ return used <= props.width();
51422
+ };
51423
+ const labelColor = () => props.cursor() ? currentFg() : base();
51424
+ return (() => {
51425
+ 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");
51426
+ insertNode(_el$33, _el$34);
51427
+ setProp(_el$33, "flexDirection", "column");
51428
+ setProp(_el$33, "width", "100%");
51429
+ setProp(_el$33, "flexShrink", 0);
51430
+ insertNode(_el$34, _el$35);
51431
+ insertNode(_el$34, _el$36);
51432
+ insertNode(_el$34, _el$37);
51433
+ insertNode(_el$34, _el$38);
51434
+ setProp(_el$34, "flexDirection", "row");
51435
+ setProp(_el$34, "width", "100%");
51436
+ setProp(_el$34, "flexShrink", 0);
51437
+ setProp(_el$34, "paddingLeft", 2);
51438
+ insert(_el$35, () => props.marked() ? "\u203A " : " ");
51439
+ insert(_el$36, stateGlyph);
51440
+ insert(_el$37, number);
51441
+ setProp(_el$38, "wrapMode", "word");
51442
+ insert(_el$38, () => label().label);
51443
+ insert(_el$34, createComponent2(Show, {
51444
+ get when() {
51445
+ return badgeInline();
51446
+ },
51447
+ get children() {
51448
+ var _el$39 = createElement("text");
51449
+ insert(_el$39, () => ` ${badge()}`);
51450
+ effect((_$p) => setProp(_el$39, "fg", props.cursor() ? currentFg() : success(), _$p));
51451
+ return _el$39;
51452
+ }
51453
+ }), null);
51454
+ insert(_el$33, createComponent2(Show, {
51455
+ get when() {
51456
+ return memo2(() => !!label().recommended)() && !badgeInline();
51457
+ },
51458
+ get children() {
51459
+ var _el$40 = createElement("box"), _el$41 = createElement("text");
51460
+ insertNode(_el$40, _el$41);
51461
+ setProp(_el$41, "wrapMode", "none");
51462
+ insert(_el$41, badge);
51463
+ effect((_p$) => {
51464
+ var _v$23 = props.labelColumn(), _v$24 = success();
51465
+ _v$23 !== _p$.e && (_p$.e = setProp(_el$40, "paddingLeft", _v$23, _p$.e));
51466
+ _v$24 !== _p$.t && (_p$.t = setProp(_el$41, "fg", _v$24, _p$.t));
51467
+ return _p$;
51468
+ }, {
51469
+ e: undefined,
51470
+ t: undefined
51471
+ });
51472
+ return _el$40;
51473
+ }
51474
+ }), null);
51475
+ insert(_el$33, createComponent2(Show, {
51476
+ get when() {
51477
+ return props.row().option.description;
51478
+ },
51479
+ children: (description) => (() => {
51480
+ var _el$42 = createElement("box"), _el$43 = createElement("text");
51481
+ insertNode(_el$42, _el$43);
51482
+ setProp(_el$43, "wrapMode", "word");
51483
+ insert(_el$43, description);
51484
+ effect((_p$) => {
51485
+ var _v$31 = props.labelColumn(), _v$32 = muted();
51486
+ _v$31 !== _p$.e && (_p$.e = setProp(_el$42, "paddingLeft", _v$31, _p$.e));
51487
+ _v$32 !== _p$.t && (_p$.t = setProp(_el$43, "fg", _v$32, _p$.t));
51488
+ return _p$;
51489
+ }, {
51490
+ e: undefined,
51491
+ t: undefined
51492
+ });
51493
+ return _el$42;
51494
+ })()
51495
+ }), null);
51496
+ effect((_p$) => {
51497
+ 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;
51498
+ _v$25 !== _p$.e && (_p$.e = setProp(_el$34, "backgroundColor", _v$25, _p$.e));
51499
+ _v$26 !== _p$.t && (_p$.t = setProp(_el$35, "fg", _v$26, _p$.t));
51500
+ _v$27 !== _p$.a && (_p$.a = setProp(_el$36, "fg", _v$27, _p$.a));
51501
+ _v$28 !== _p$.o && (_p$.o = setProp(_el$37, "fg", _v$28, _p$.o));
51502
+ _v$29 !== _p$.i && (_p$.i = setProp(_el$38, "fg", _v$29, _p$.i));
51503
+ _v$30 !== _p$.n && (_p$.n = setProp(_el$38, "flexGrow", _v$30, _p$.n));
51504
+ return _p$;
51505
+ }, {
51506
+ e: undefined,
51507
+ t: undefined,
51508
+ a: undefined,
51509
+ o: undefined,
51510
+ i: undefined,
51511
+ n: undefined
51512
+ });
51513
+ return _el$33;
51514
+ })();
51515
+ }
51516
+ var ASK_COMPACT_COLUMNS = 64, GUTTER = 2, CURSOR_CELLS = 2, STATE_CELLS = 2, BADGE_GAP = 2;
51517
+ var init_ask_panel = __esm(() => {
51518
+ init_index_bun();
51519
+ init_index_bun();
51520
+ init_index_bun();
51521
+ init_index_bun();
51522
+ init_index_bun();
51523
+ init_index_bun();
51524
+ init_index_bun();
51525
+ init_index_bun();
51526
+ init_index_bun();
51527
+ init_server();
51528
+ init_i18n();
51529
+ init_theme3();
51530
+ init_config();
51531
+ init_semantic();
51532
+ init_ask_options();
51533
+ init_ask_keys();
51534
+ init_dock_host();
51535
+ init_string_width();
51536
+ });
51537
+
49966
51538
  // ../tui-base/src/routes/session/turn-overlays.tsx
49967
51539
  function summarizeArgs(name, args, limit = 160) {
49968
51540
  let body = JSON.stringify(args);
@@ -50015,408 +51587,41 @@ function ReminderBadge() {
50015
51587
  return _el$;
50016
51588
  })();
50017
51589
  }
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
51590
  function TurnOverlayHost(props) {
50401
51591
  const dialog = useDialog();
51592
+ const dock = useDock();
51593
+ const pageOwns = useIsPageOwner();
50402
51594
  const [version, setVersion] = createSignal(0);
50403
51595
  onMount(() => {
50404
- const unsubscribe = props.controller.subscribe(() => setVersion((v) => v + 1));
51596
+ const unsubscribe = props.controller.subscribe(() => setVersion((value) => value + 1));
50405
51597
  onCleanup(unsubscribe);
50406
51598
  });
50407
51599
  props.controller.onIdle(() => {
50408
51600
  setTimeout(() => props.reclaimFocus?.(), 3);
50409
51601
  });
51602
+ let panelFocus;
51603
+ let askHandle;
51604
+ let askId;
50410
51605
  let shown;
51606
+ function closeAsk() {
51607
+ askHandle?.close();
51608
+ askHandle = undefined;
51609
+ askId = undefined;
51610
+ }
50411
51611
  createEffect(() => {
50412
51612
  version();
50413
51613
  const approval = props.controller.pendingApproval;
50414
51614
  const ask = props.controller.pendingAsk;
50415
- const key = approval ? `approval:${approval.id}` : ask ? `ask:${ask.id}` : "";
51615
+ const askShowing = askHandle !== undefined && ask !== undefined && askId === ask.id;
51616
+ const pageOwned = pageOwns();
51617
+ const approvalWins = approval !== undefined && !askShowing;
51618
+ const askAdmitted = ask !== undefined && (askShowing || pageOwned);
51619
+ const key = approvalWins ? `approval:${approval.id}` : askAdmitted ? `ask:${ask.id}` : "";
50416
51620
  if (key === shown)
50417
51621
  return;
50418
51622
  shown = key;
50419
- if (approval) {
51623
+ if (approvalWins) {
51624
+ closeAsk();
50420
51625
  const atOpen = key;
50421
51626
  dialog.replace(() => createComponent2(ApprovalCard, {
50422
51627
  get name() {
@@ -50439,24 +51644,36 @@ function TurnOverlayHost(props) {
50439
51644
  });
50440
51645
  return;
50441
51646
  }
50442
- if (ask) {
50443
- const atOpen = key;
50444
- dialog.replace(() => createComponent2(AskPicker, {
51647
+ if (ask !== undefined && askAdmitted) {
51648
+ if (askHandle !== undefined && askId === ask.id)
51649
+ return;
51650
+ const previous = askHandle;
51651
+ askId = ask.id;
51652
+ askHandle = dock.open((ctx) => createComponent2(AskPanel, {
50445
51653
  get controller() {
50446
51654
  return props.controller;
50447
51655
  },
50448
- onDecline: () => props.controller.decline()
50449
- }), () => {
50450
- if (shown === atOpen)
50451
- props.controller.decline();
50452
- }, {
50453
- tone: "warning"
51656
+ get width() {
51657
+ return ctx.width;
51658
+ },
51659
+ queued: () => Math.max(0, props.controller.pendingAskCount + props.controller.pendingApprovalCount - 1),
51660
+ onFocusTarget: (resolve) => {
51661
+ panelFocus = resolve;
51662
+ }
51663
+ }), {
51664
+ kind: "ask",
51665
+ contentRows: estimateAskRows(ask),
51666
+ focusRef: () => panelFocus?.(),
51667
+ overflowLabel: (hidden) => t("overlay.ask.overflow", {
51668
+ count: hidden
51669
+ })
50454
51670
  });
51671
+ previous?.close();
50455
51672
  return;
50456
51673
  }
50457
- if (untrack(() => dialog.stack.length) > 0)
50458
- dialog.clear();
51674
+ closeAsk();
50459
51675
  });
51676
+ onCleanup(closeAsk);
50460
51677
  return createComponent2(Show, {
50461
51678
  when: false,
50462
51679
  children: null
@@ -50472,21 +51689,19 @@ var init_turn_overlays = __esm(() => {
50472
51689
  init_index_bun();
50473
51690
  init_index_bun();
50474
51691
  init_index_bun();
50475
- init_index_bun();
50476
- init_index_bun();
50477
- init_index_bun();
50478
51692
  init_server();
50479
51693
  init_index_bun();
50480
51694
  init_dialog_confirm();
50481
- init_dialog_select();
50482
51695
  init_dialog();
50483
- init_keymap();
50484
- init_config();
51696
+ init_input_ownership();
50485
51697
  init_theme3();
50486
51698
  init_i18n();
50487
51699
  init_motion();
50488
51700
  init_semantic();
50489
51701
  init_widgets_dock();
51702
+ init_ask_panel();
51703
+ init_ask_options();
51704
+ init_dock_host();
50490
51705
  });
50491
51706
 
50492
51707
  // ../tui-base/src/routes/session/hotkeys.ts
@@ -52549,6 +53764,7 @@ function formatSkillLine(row, selected) {
52549
53764
  function SkillsPanel(props) {
52550
53765
  const theme = useThemeOptional();
52551
53766
  const dialog = useDialog();
53767
+ const pageOwns = useIsPageOwner();
52552
53768
  const [open, setOpen] = useSkillsPanelOpenState();
52553
53769
  const [filterOpen, setFilterOpen] = createSignal(false);
52554
53770
  const [filter, setFilter] = createSignal("");
@@ -52678,7 +53894,7 @@ function SkillsPanel(props) {
52678
53894
  }
52679
53895
  Keymap2.createLayer(() => ({
52680
53896
  mode: "global",
52681
- enabled: open() && dialog.stack.length === 0,
53897
+ enabled: open() && pageOwns(),
52682
53898
  priority: 2,
52683
53899
  commands: [{
52684
53900
  bind: "escape",
@@ -52912,6 +54128,7 @@ var init_skills_panel = __esm(() => {
52912
54128
  init_index_bun();
52913
54129
  init_server();
52914
54130
  init_keymap();
54131
+ init_input_ownership();
52915
54132
  init_i18n();
52916
54133
  init_dialog();
52917
54134
  init_dialog_confirm();
@@ -52958,7 +54175,7 @@ async function resumeSearchHit(options) {
52958
54175
  }
52959
54176
  function SessionsSearch(props) {
52960
54177
  const theme = useThemeOptional();
52961
- const dialog = useDialog();
54178
+ const pageOwns = useIsPageOwner();
52962
54179
  const [open, setOpen] = useSessionsSearchOpenState();
52963
54180
  const [query, setQuery] = createSignal("");
52964
54181
  const [hits, setHits] = createSignal([]);
@@ -53030,7 +54247,7 @@ function SessionsSearch(props) {
53030
54247
  }
53031
54248
  Keymap2.createLayer(() => ({
53032
54249
  mode: "global",
53033
- enabled: open() && dialog.stack.length === 0,
54250
+ enabled: open() && pageOwns(),
53034
54251
  priority: 2,
53035
54252
  commands: [
53036
54253
  {
@@ -53063,7 +54280,7 @@ function SessionsSearch(props) {
53063
54280
  }));
53064
54281
  Keymap2.createLayer(() => ({
53065
54282
  mode: "global",
53066
- enabled: !open() && dialog.stack.length === 0,
54283
+ enabled: !open() && pageOwns(),
53067
54284
  commands: [{
53068
54285
  id: "session.searchSessions",
53069
54286
  title: t("overlay.sessions.keymap.open"),
@@ -53204,9 +54421,9 @@ var init_sessions_search = __esm(() => {
53204
54421
  init_server();
53205
54422
  init_server();
53206
54423
  init_keymap();
53207
- init_dialog();
53208
54424
  init_i18n();
53209
54425
  init_theme3();
54426
+ init_input_ownership();
53210
54427
  [bridgeOpen2, setBridgeOpen2] = createSignal(false);
53211
54428
  [panelOpen3, setPanelOpen3] = createSignal(false);
53212
54429
  sessionsSearchOpen = panelOpen3;
@@ -53309,6 +54526,7 @@ function installPreviewLine(inspection) {
53309
54526
  function PluginsPanel(props) {
53310
54527
  const theme = useThemeOptional();
53311
54528
  const dialog = useDialog();
54529
+ const pageOwns = useIsPageOwner();
53312
54530
  const [open, setOpen] = usePluginsPanelOpenState();
53313
54531
  const [filterOpen, setFilterOpen] = createSignal(false);
53314
54532
  const [filter, setFilter] = createSignal("");
@@ -53555,7 +54773,7 @@ function PluginsPanel(props) {
53555
54773
  }
53556
54774
  Keymap2.createLayer(() => ({
53557
54775
  mode: "global",
53558
- enabled: open() && dialog.stack.length === 0,
54776
+ enabled: open() && pageOwns(),
53559
54777
  priority: 2,
53560
54778
  commands: [{
53561
54779
  bind: "escape",
@@ -53825,6 +55043,7 @@ var init_plugins_panel = __esm(() => {
53825
55043
  init_index_bun();
53826
55044
  init_server();
53827
55045
  init_keymap();
55046
+ init_input_ownership();
53828
55047
  init_i18n();
53829
55048
  init_dialog();
53830
55049
  init_dialog_confirm();
@@ -55961,11 +57180,11 @@ var init_input_row = __esm(() => {
55961
57180
  });
55962
57181
 
55963
57182
  // ../panel-kit/src/kit.tsx
55964
- function createHostKeyAdapter(keymap) {
57183
+ function createHostKeyAdapter(keymap, ownership) {
55965
57184
  const [active, setActive] = createSignal(undefined);
55966
57185
  const disposeLayer = keymap.createLayer(() => ({
55967
57186
  mode: "modal",
55968
- enabled: active() !== undefined,
57187
+ enabled: active() !== undefined && (ownership === undefined || ownership.owns(ownership.topFrame())),
55969
57188
  bindings: PANEL_KEY_IDS.map((id) => ({
55970
57189
  key: id,
55971
57190
  group: "Panel",
@@ -55993,13 +57212,22 @@ function createHostKeyAdapter(keymap) {
55993
57212
  }
55994
57213
  function PanelKitProvider(props) {
55995
57214
  const theme = toAccessor(props.theme);
55996
- const keys = props.keys ?? (props.keymap ? createHostKeyAdapter(props.keymap) : undefined);
57215
+ const [topFrame, setTopFrame] = createSignal(undefined);
57216
+ const ownership = props.ownership ? {
57217
+ push: (kind) => props.ownership.push(kind),
57218
+ pop: (token) => props.ownership.pop(token),
57219
+ owns: (token) => props.ownership.owns(token),
57220
+ topFrame,
57221
+ setTopFrame
57222
+ } : undefined;
57223
+ const keys = props.keys ?? (props.keymap ? createHostKeyAdapter(props.keymap, ownership) : undefined);
55997
57224
  return createComponent2(PanelKitContext.Provider, {
55998
57225
  get value() {
55999
57226
  return {
56000
57227
  theme,
56001
57228
  motion: props.motion,
56002
- keys
57229
+ keys,
57230
+ ownership
56003
57231
  };
56004
57232
  },
56005
57233
  get children() {
@@ -56034,10 +57262,16 @@ function inTree(root, node) {
56034
57262
  function PanelStack(props) {
56035
57263
  const renderer = useRenderer();
56036
57264
  const panelTheme = usePanelTheme();
57265
+ const ownership = usePanelKit()?.ownership;
56037
57266
  const [layers, setLayers] = createSignal([]);
56038
57267
  const handles = new Map;
56039
57268
  let counter = 0;
56040
57269
  let baseFocus = null;
57270
+ onCleanup(() => {
57271
+ for (const entry of layers())
57272
+ ownership?.pop(entry.frame);
57273
+ ownership?.setTopFrame(undefined);
57274
+ });
56041
57275
  const maxDepth = () => props.maxDepth ?? 4;
56042
57276
  const layerScrimAlpha = (index) => {
56043
57277
  const entry = layers()[index];
@@ -56093,6 +57327,8 @@ function PanelStack(props) {
56093
57327
  const next = layers().filter((entry) => entry.id !== id);
56094
57328
  handles.delete(id);
56095
57329
  setLayers(next);
57330
+ ownership?.pop(closing.frame);
57331
+ ownership?.setTopFrame(next.at(-1)?.frame);
56096
57332
  if (next.length === 0)
56097
57333
  restore(baseFocus);
56098
57334
  else
@@ -56103,6 +57339,10 @@ function PanelStack(props) {
56103
57339
  get depth() {
56104
57340
  return Math.max(0, layers().findIndex((item) => item.id === entry.id));
56105
57341
  },
57342
+ get frame() {
57343
+ return entry.frame;
57344
+ },
57345
+ ownsInput: () => ownership !== undefined ? ownership.owns(entry.frame) : layers().at(-1)?.id === entry.id,
56106
57346
  close() {
56107
57347
  if (entry.handle)
56108
57348
  entry.handle.close();
@@ -56131,6 +57371,8 @@ function PanelStack(props) {
56131
57371
  return {
56132
57372
  id,
56133
57373
  depth: 0,
57374
+ frame: undefined,
57375
+ ownsInput: () => false,
56134
57376
  close: () => {},
56135
57377
  closeNow: () => {}
56136
57378
  };
@@ -56139,6 +57381,7 @@ function PanelStack(props) {
56139
57381
  if (layers().length === 0)
56140
57382
  baseFocus = focused;
56141
57383
  focused?.blur();
57384
+ const frame = ownership?.push("panel");
56142
57385
  const entry = {
56143
57386
  id,
56144
57387
  options: {
@@ -56147,9 +57390,11 @@ function PanelStack(props) {
56147
57390
  },
56148
57391
  render,
56149
57392
  focusBefore: focused,
57393
+ frame,
56150
57394
  pendingClose: false
56151
57395
  };
56152
57396
  setLayers((current) => [...current, entry]);
57397
+ ownership?.setTopFrame(frame);
56153
57398
  const handle = makeHandle(entry);
56154
57399
  handles.set(id, handle);
56155
57400
  return handle;
@@ -56170,6 +57415,9 @@ function PanelStack(props) {
56170
57415
  handles.clear();
56171
57416
  setLayers([]);
56172
57417
  });
57418
+ for (const entry of entries)
57419
+ ownership?.pop(entry.frame);
57420
+ ownership?.setTopFrame(undefined);
56173
57421
  restore(baseFocus);
56174
57422
  },
56175
57423
  confirm(options) {
@@ -57929,11 +59177,10 @@ function AgentsPanel(props) {
57929
59177
  return true;
57930
59178
  }
57931
59179
  Keymap2.createLayer(() => {
57932
- const top = panels.top;
57933
59180
  const ownTop = layers().at(-1)?.handle;
57934
59181
  return {
57935
59182
  mode: "global",
57936
- enabled: open() && top !== undefined && top === ownTop,
59183
+ enabled: open() && ownTop?.ownsInput() === true,
57937
59184
  priority: 2,
57938
59185
  commands: [
57939
59186
  {
@@ -58788,6 +60035,7 @@ function HistoryPanel(props) {
58788
60035
  const [sessionCursor, setSessionCursor] = createSignal(0);
58789
60036
  const [showSessions, setShowSessions] = createSignal(false);
58790
60037
  let handle;
60038
+ const [sessionsHandle, setSessionsHandle] = createSignal(undefined);
58791
60039
  let sequence = 0;
58792
60040
  let loadSequence = 0;
58793
60041
  const current = createMemo(() => turns()[cursor()]);
@@ -58901,12 +60149,15 @@ function HistoryPanel(props) {
58901
60149
  setStatus(t("panel.history.status.noSessions"));
58902
60150
  return;
58903
60151
  }
58904
- panels.open(() => renderSessions(), {
60152
+ setSessionsHandle(panels.open(() => renderSessions(), {
58905
60153
  id: `history-sessions-${++sequence}`,
58906
60154
  title: t("panel.history.title.switch"),
58907
60155
  size: "xlarge",
58908
- onClose: () => setShowSessions(false)
58909
- });
60156
+ onClose: () => {
60157
+ setSessionsHandle(undefined);
60158
+ setShowSessions(false);
60159
+ }
60160
+ }));
58910
60161
  } catch (error) {
58911
60162
  setStatus(historyFailureText(t("panel.history.op.sessionList"), error));
58912
60163
  }
@@ -58940,43 +60191,40 @@ function HistoryPanel(props) {
58940
60191
  setStatus(historyFailureText(t("panel.history.op.fork"), error));
58941
60192
  }).finally(() => setBusy(false));
58942
60193
  }
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
60194
  Keymap2.createLayer(() => ({
58978
60195
  mode: "global",
58979
- enabled: open() && showSessions(),
60196
+ enabled: open() && handle?.ownsInput() === true,
60197
+ priority: 2,
60198
+ commands: [{
60199
+ bind: "up,k",
60200
+ title: t("panel.history.keymap.previousTurn"),
60201
+ group: "History",
60202
+ run: () => moveCursor(-1)
60203
+ }, {
60204
+ bind: "down,j",
60205
+ title: t("panel.history.keymap.nextTurn"),
60206
+ group: "History",
60207
+ run: () => moveCursor(1)
60208
+ }, {
60209
+ bind: "return,c",
60210
+ title: showSessions() ? t("panel.history.keymap.pickSession") : t("panel.history.keymap.refill"),
60211
+ group: "History",
60212
+ run: () => showSessions() ? pickSession(sessionCursor()) : refill()
60213
+ }, {
60214
+ bind: "s",
60215
+ title: t("panel.history.keymap.switchSession"),
60216
+ group: "History",
60217
+ run: openSessions
60218
+ }, {
60219
+ bind: "f",
60220
+ title: t("panel.history.keymap.fork"),
60221
+ group: "History",
60222
+ run: fork
60223
+ }]
60224
+ }));
60225
+ Keymap2.createLayer(() => ({
60226
+ mode: "global",
60227
+ enabled: open() && showSessions() && sessionsHandle()?.ownsInput() === true,
58980
60228
  priority: 3,
58981
60229
  commands: [{
58982
60230
  bind: "up,k",
@@ -59454,77 +60702,71 @@ function SubagentsViewer(props) {
59454
60702
  }
59455
60703
  });
59456
60704
  });
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
- });
60705
+ Keymap2.createLayer(() => ({
60706
+ mode: "global",
60707
+ enabled: open() && transcriptHandle === undefined && handle?.ownsInput() === true && dialog.stack.length === 0,
60708
+ priority: 2,
60709
+ commands: [{
60710
+ bind: "up,k",
60711
+ title: t("panel.subagents.keymap.previous"),
60712
+ group: "Subagents",
60713
+ run: () => moveCursor(-1)
60714
+ }, {
60715
+ bind: "down,j",
60716
+ title: t("panel.subagents.keymap.next"),
60717
+ group: "Subagents",
60718
+ run: () => moveCursor(1)
60719
+ }, {
60720
+ bind: "return",
60721
+ title: t("panel.subagents.keymap.openTranscript"),
60722
+ group: "Subagents",
60723
+ run: () => {
60724
+ const row = rows()[cursor()];
60725
+ if (row !== undefined)
60726
+ openTranscript(row.id);
60727
+ return true;
60728
+ }
60729
+ }, {
60730
+ bind: "s",
60731
+ title: t("panel.subagents.keymap.sort"),
60732
+ group: "Subagents",
60733
+ run: () => {
60734
+ setSortByRounds((value) => !value);
60735
+ return true;
60736
+ }
60737
+ }, {
60738
+ bind: "shift+k",
60739
+ title: t("panel.subagents.keymap.stopAll"),
60740
+ group: "Subagents",
60741
+ run: stopAll
60742
+ }]
60743
+ }));
60744
+ Keymap2.createLayer(() => ({
60745
+ mode: "global",
60746
+ enabled: open() && transcriptHandle?.ownsInput() === true && dialog.stack.length === 0,
60747
+ priority: 2,
60748
+ commands: [{
60749
+ bind: "up,k",
60750
+ title: t("panel.subagents.keymap.scrollUp"),
60751
+ group: "Subagents",
60752
+ run: () => scrollBy(-1)
60753
+ }, {
60754
+ bind: "down,j",
60755
+ title: t("panel.subagents.keymap.scrollDown"),
60756
+ group: "Subagents",
60757
+ run: () => scrollBy(1)
60758
+ }, {
60759
+ bind: "return",
60760
+ title: t("panel.subagents.keymap.steer"),
60761
+ group: "Subagents",
60762
+ run: openSteer
60763
+ }, {
60764
+ bind: "x",
60765
+ title: t("panel.subagents.keymap.stopTwice"),
60766
+ group: "Subagents",
60767
+ run: stopChild
60768
+ }]
60769
+ }));
59528
60770
  function clip(text, width) {
59529
60771
  if (width <= 0)
59530
60772
  return "";
@@ -59745,7 +60987,7 @@ var init_subagents_viewer = __esm(() => {
59745
60987
  import { TextAttributes as TextAttributes12 } from "@opentui/core";
59746
60988
  function resolveVersion() {
59747
60989
  try {
59748
- return "0.18.1";
60990
+ return "0.18.3";
59749
60991
  } catch {
59750
60992
  return "dev";
59751
60993
  }
@@ -60530,7 +61772,7 @@ function SettingsModalBody(props) {
60530
61772
  scrollRowInto(action === "pagedown" ? (page + 1) * size : (page - 1) * size);
60531
61773
  return true;
60532
61774
  }
60533
- const ownsTop = () => props.layerHandle !== undefined && panels.top === props.layerHandle;
61775
+ const ownsTop = () => props.layerHandle?.ownsInput() === true;
60534
61776
  Keymap2.createLayer(() => ({
60535
61777
  mode: "global",
60536
61778
  priority: 2,
@@ -61459,9 +62701,17 @@ function createTuiPanelKeymapHost(keymap) {
61459
62701
  }
61460
62702
  };
61461
62703
  }
62704
+ function createTuiPanelOwnership(ownership) {
62705
+ return {
62706
+ push: (kind) => ownership.push(kind),
62707
+ pop: (token) => ownership.pop(token),
62708
+ owns: (token) => ownership.owns(token)
62709
+ };
62710
+ }
61462
62711
  function PanelKitHost(props) {
61463
62712
  const theme = useTheme();
61464
62713
  const keymap = Keymap2.use();
62714
+ const ownership = useInputOwnershipOptional();
61465
62715
  const panelTheme = () => projectPanelTheme(theme);
61466
62716
  return createComponent2(PanelKitProvider, {
61467
62717
  theme: panelTheme,
@@ -61471,6 +62721,9 @@ function PanelKitHost(props) {
61471
62721
  get keymap() {
61472
62722
  return createTuiPanelKeymapHost(keymap);
61473
62723
  },
62724
+ get ownership() {
62725
+ return ownership ? createTuiPanelOwnership(ownership) : undefined;
62726
+ },
61474
62727
  get children() {
61475
62728
  return createComponent2(PanelStack, {
61476
62729
  get children() {
@@ -61481,9 +62734,11 @@ function PanelKitHost(props) {
61481
62734
  });
61482
62735
  }
61483
62736
  var init_panel_kit_host = __esm(() => {
62737
+ init_index_bun();
61484
62738
  init_index_bun();
61485
62739
  init_src3();
61486
62740
  init_motion();
62741
+ init_input_ownership();
61487
62742
  init_keymap();
61488
62743
  init_theme3();
61489
62744
  });
@@ -61778,12 +63033,7 @@ class RemoteSessionSeam {
61778
63033
  const rows = await this.#session.storedTranscript(id, skip);
61779
63034
  return rows.map((row) => {
61780
63035
  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 };
63036
+ return { kind: row.kind, text: "", final: true, entries: row.entries };
61787
63037
  }
61788
63038
  if (row.kind === "tool") {
61789
63039
  return { kind: "tool", text: row.name, final: true, args: row.args, output: row.brief, ok: row.ok };
@@ -62241,6 +63491,13 @@ async function loadShell() {
62241
63491
  return { shared, lifecycle, transport, rhs, adapter, git };
62242
63492
  }
62243
63493
  function V2SessionPage(props) {
63494
+ return createComponent2(DockProvider, {
63495
+ get children() {
63496
+ return createComponent2(V2SessionPageBody, props);
63497
+ }
63498
+ });
63499
+ }
63500
+ function V2SessionPageBody(props) {
62244
63501
  const seam = props.seam;
62245
63502
  const projection = createSeamRows(seam, () => seam.currentSessionId() ?? "", {
62246
63503
  onApprove: (name, args) => overlays.requestApproval(name, args),
@@ -62248,6 +63505,8 @@ function V2SessionPage(props) {
62248
63505
  onToolRun: () => setTools((n) => n + 1)
62249
63506
  });
62250
63507
  const dialog = useDialog();
63508
+ const pageOwns = useIsPageOwner();
63509
+ const dock = useDock();
62251
63510
  const theme = useTheme();
62252
63511
  const themeService = useThemes();
62253
63512
  const themeSeam = createThemeSeam(themeService);
@@ -62283,6 +63542,10 @@ function V2SessionPage(props) {
62283
63542
  Promise.all([face.list(), face.currentId()]).then(([rows, id]) => setPresetLabel(presetLabelFor(rows, id))).catch(() => {});
62284
63543
  };
62285
63544
  let composerRef;
63545
+ dock.bindComposerFocus(() => {
63546
+ if (composerRef && !composerRef.focused())
63547
+ composerRef.focus();
63548
+ });
62286
63549
  let transcriptScroll;
62287
63550
  const renderer = useRenderer();
62288
63551
  const dimensions = useTerminalSize();
@@ -62744,48 +64007,48 @@ function V2SessionPage(props) {
62744
64007
  },
62745
64008
  turnActive: () => busy()
62746
64009
  }),
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
- ];
64010
+ pending: () => composerPending()
64011
+ }),
64012
+ createComponent2(DockSeat, {
64013
+ composer: () => [
64014
+ createComponent2(ComposerContext, {
64015
+ cwd: () => props.workspace,
64016
+ probeBranch: props.probeBranch,
64017
+ revision: () => contextRevision(),
64018
+ steer: () => composerBusy(),
64019
+ attachTitle: (get) => {
64020
+ contextFrameTitle = get;
64021
+ }
64022
+ }),
64023
+ createComponent2(SessionComposer, {
64024
+ seam,
64025
+ send,
64026
+ footerHint: false,
64027
+ frameTitle: () => contextFrameTitle?.() ?? "",
64028
+ onBusyChange: setComposerBusy,
64029
+ ref: (r) => composerRef = r,
64030
+ chooseDelivery: (text) => openDeliveryChoice(dialog, text),
64031
+ onPendingChange: (rows) => setComposerPending(rows),
64032
+ 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),
64033
+ isTurnAborted: () => turnAborted,
64034
+ slashKeyFilter: slash.slashKeyFilter,
64035
+ slashSync: (buffer) => slash.controller.sync(buffer, slash.commands),
64036
+ interceptSubmit: slash.interceptSubmit,
64037
+ slashComplete: (buffer, cursor) => dialog.stack.length > 0 ? undefined : slash.slashComplete(buffer, cursor),
64038
+ slashPalette: () => createComponent2(SlashPalette, { controller: slash.controller, commands: () => slash.commands }),
64039
+ slashHeight: () => slash.controller.rows()
64040
+ })
64041
+ ]
64042
+ }),
64043
+ createComponent2(LastRequestDock, {
64044
+ get rows() {
64045
+ return projection.rows;
64046
+ },
64047
+ get lastRequest() {
64048
+ return lastRequest();
62787
64049
  }
62788
64050
  }),
64051
+ createComponent2(NoticesDock, {}),
62789
64052
  createComponent2(SubagentsPicker, {
62790
64053
  get seam() {
62791
64054
  return seam;
@@ -62793,11 +64056,11 @@ function V2SessionPage(props) {
62793
64056
  }),
62794
64057
  createComponent2(TranscriptScrollKeys, {
62795
64058
  scroll: () => transcriptScroll,
62796
- enabled: () => dialog.stack.length === 0
64059
+ enabled: pageOwns
62797
64060
  }),
62798
64061
  createComponent2(PaneFocusKeys, {
62799
64062
  pane: paneFocus.pane,
62800
- keysEnabled: () => dialog.stack.length === 0,
64063
+ keysEnabled: pageOwns,
62801
64064
  slashOpen: () => slash.controller.open,
62802
64065
  pickerOpen: subagentsPickerOpen,
62803
64066
  busy,
@@ -62815,7 +64078,7 @@ function V2SessionPage(props) {
62815
64078
  confirmStopAll();
62816
64079
  },
62817
64080
  quit: props.quit,
62818
- enabled: () => dialog.stack.length === 0,
64081
+ enabled: pageOwns,
62819
64082
  escapeYields: () => slash.controller.open
62820
64083
  }),
62821
64084
  createComponent2(PowerlineFooter, {
@@ -62964,24 +64227,28 @@ async function bootClientV2(options = {}) {
62964
64227
  get children() {
62965
64228
  return createComponent2(ClipboardHost, {
62966
64229
  get children() {
62967
- return createComponent2(DialogProvider, {
64230
+ return createComponent2(InputOwnershipProvider, {
62968
64231
  get children() {
62969
- return createComponent2(ErrorBoundaryDiagnostics, {
64232
+ return createComponent2(DialogProvider, {
62970
64233
  get children() {
62971
- return createComponent2(PanelKitHost, {
64234
+ return createComponent2(ErrorBoundaryDiagnostics, {
62972
64235
  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
64236
+ return createComponent2(PanelKitHost, {
64237
+ get children() {
64238
+ return createComponent2(V2SessionPage, {
64239
+ seam,
64240
+ themeName,
64241
+ quit: () => process.exit(0),
64242
+ workspace,
64243
+ profileName: profile,
64244
+ probeBranch: (cwd) => git.probeGitBranchOrSha(cwd),
64245
+ initialSessionId,
64246
+ resumeNotice,
64247
+ skills: skillRows,
64248
+ skillsSource: skillsManagerRoots.source,
64249
+ skillsCurated: skillsManagerRoots.curated
64250
+ });
64251
+ }
62985
64252
  });
62986
64253
  }
62987
64254
  });
@@ -63055,7 +64322,9 @@ var init_v2_entry = __esm(() => {
63055
64322
  init_pane_focus();
63056
64323
  init_subagents_picker();
63057
64324
  init_turn_cancel();
64325
+ init_turn_overlay_controller();
63058
64326
  init_turn_overlays();
64327
+ init_dock_host();
63059
64328
  init_slash_palette();
63060
64329
  init_slash_deps();
63061
64330
  init_commands();
@@ -63079,6 +64348,7 @@ var init_v2_entry = __esm(() => {
63079
64348
  init_keymap();
63080
64349
  init_theme3();
63081
64350
  init_panel_kit_host();
64351
+ init_input_ownership();
63082
64352
  init_config();
63083
64353
  init_selection();
63084
64354
  init_theme2();