@threadbase-sh/streamer 1.70.2 → 1.70.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -2724,6 +2724,15 @@ var OPTION_RE2 = /^\s*(?:❯)?\s*(\d+)\.\s+(.+?)\s*$/;
2724
2724
  var QUESTION_RE = /\?\s*$/;
2725
2725
  var BOX_ONLY_RE2 = /^[\s│─┌┐└┘├┤┬┴┼╭╮╰╯╱╲=_-]+$/;
2726
2726
  var PERMISSION_LABEL_RE = /^(Yes|No)\b/i;
2727
+ var KNOWN_STATE_MARKER_RE = /^(?:\[(?:[ xX*]|✓|✔)\]|[☐☑☒])\s*/;
2728
+ var UNKNOWN_STATE_MARKER_RE = /^(?:\[[^\]]{0,3}\]|\([^)]{0,3}\))\s*/;
2729
+ function stripStateMarker(label) {
2730
+ if (KNOWN_STATE_MARKER_RE.test(label)) {
2731
+ return { label: label.replace(KNOWN_STATE_MARKER_RE, ""), marked: true };
2732
+ }
2733
+ if (UNKNOWN_STATE_MARKER_RE.test(label)) return { label, marked: true };
2734
+ return { label, marked: false };
2735
+ }
2727
2736
  function stripBoxGutter(line) {
2728
2737
  return line.replace(/^\s*[│|]\s?/, "").replace(/\s*[│|]\s*$/, "");
2729
2738
  }
@@ -2738,6 +2747,7 @@ function detectQuestionFromScreen(lines) {
2738
2747
  if (footerIdx === -1) return null;
2739
2748
  const options = [];
2740
2749
  let firstOptionIdx = -1;
2750
+ let sawStateMarker = false;
2741
2751
  for (let i = footerIdx - 1; i >= 0; i--) {
2742
2752
  const line = lines[i];
2743
2753
  const inner = stripBoxGutter(line);
@@ -2751,8 +2761,10 @@ function detectQuestionFromScreen(lines) {
2751
2761
  if (options.length > 0 && QUESTION_RE.test(trimmed) && !OPTION_RE2.test(inner)) break;
2752
2762
  const m = OPTION_RE2.exec(inner);
2753
2763
  if (m) {
2754
- const label = m[2].trim();
2755
- if (PERMISSION_LABEL_RE.test(label)) return null;
2764
+ const rendered = m[2].trim();
2765
+ if (PERMISSION_LABEL_RE.test(rendered)) return null;
2766
+ const { label, marked } = stripStateMarker(rendered);
2767
+ if (marked) sawStateMarker = true;
2756
2768
  options.unshift({ label, description: "" });
2757
2769
  firstOptionIdx = i;
2758
2770
  }
@@ -2771,7 +2783,7 @@ function detectQuestionFromScreen(lines) {
2771
2783
  }
2772
2784
  if (!question) return null;
2773
2785
  return {
2774
- questions: [{ question, header: "", multiSelect: false, options }]
2786
+ questions: [{ question, header: "", multiSelect: sawStateMarker, options }]
2775
2787
  };
2776
2788
  }
2777
2789
  function isQuestionMenuOnScreen(lines) {
@@ -18550,23 +18562,16 @@ var StreamerServer = class {
18550
18562
  * it.
18551
18563
  */
18552
18564
  async resolveConversationTarget(sessionId) {
18553
- let jsonlPath = this.conversationHandlers.findJsonlPath(sessionId);
18554
- let conv = await this.conversationHandlers.findConversationByUuid(sessionId);
18555
- let historyId = sessionId;
18556
- let registryProvider;
18557
- if (!jsonlPath && !conv) {
18558
- const row = this.managedSessionsRepo?.get(sessionId) ?? null;
18559
- const boundId = row ? resumeIdForRow(row) : null;
18560
- if (boundId != null && boundId !== sessionId) {
18561
- historyId = boundId;
18562
- registryProvider = row?.provider;
18563
- jsonlPath = this.conversationHandlers.findJsonlPath(boundId);
18564
- conv = await this.conversationHandlers.findConversationByUuid(boundId);
18565
- }
18566
- }
18565
+ const row = this.managedSessionsRepo?.get(sessionId) ?? null;
18566
+ const liveSession = this.sessionStore.getManaged(sessionId);
18567
+ const resumeId = (row ? resumeIdForRow(row) : null) ?? (liveSession?.provider === CODEX_CLI_PROVIDER ? liveSession.boundConversationId ?? null : null);
18568
+ const historyId = resumeId ?? sessionId;
18569
+ const managedProvider = row?.provider ?? liveSession?.provider;
18570
+ const jsonlPath = this.conversationHandlers.findJsonlPath(historyId);
18571
+ const conv = await this.conversationHandlers.findConversationByUuid(historyId);
18567
18572
  const cachedConvMeta = this.cache?.getMetaById(historyId);
18568
18573
  const cachedPath = cachedConvMeta?.filePath ? toNativeFilePath(cachedConvMeta.filePath) : null;
18569
- const cachedCodexPath = (registryProvider === CODEX_CLI_PROVIDER || cachedConvMeta?.provider === CODEX_CLI_PROVIDER) && cachedPath != null && (0, import_fs28.existsSync)(cachedPath) ? cachedPath : null;
18574
+ const cachedCodexPath = (managedProvider === CODEX_CLI_PROVIDER || cachedConvMeta?.provider === CODEX_CLI_PROVIDER) && cachedPath != null && (0, import_fs28.existsSync)(cachedPath) ? cachedPath : null;
18570
18575
  const jsonlCwd = jsonlPath ? await this.conversationHandlers.readCwdFromJsonl(jsonlPath) : null;
18571
18576
  const projectPath = jsonlCwd ?? conv?.projectPath ?? (cachedCodexPath ? cachedConvMeta?.projectPath : null);
18572
18577
  if (!projectPath) {
@@ -18576,7 +18581,7 @@ var StreamerServer = class {
18576
18581
  return { ok: false, reason: "no_project_path" };
18577
18582
  }
18578
18583
  const provider = coerceProviderForRunner(
18579
- conv?.provider ?? cachedConvMeta?.provider ?? registryProvider
18584
+ conv?.provider ?? cachedConvMeta?.provider ?? managedProvider
18580
18585
  );
18581
18586
  return {
18582
18587
  ok: true,