mixdog 0.9.149 → 0.9.151

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.
Files changed (113) hide show
  1. package/README.md +28 -12
  2. package/package.json +1 -1
  3. package/src/headless-exec.mjs +40 -4
  4. package/src/headless-exec.test.mjs +116 -1
  5. package/src/rules/lead/01-general.md +3 -2
  6. package/src/rules/shared/00-general.md +1 -0
  7. package/src/rules/shared/10-tool-workflow.md +11 -12
  8. package/src/rules/shared/30-exploration.md +4 -3
  9. package/src/rules/shared/60-verification.md +4 -3
  10. package/src/runtime/agent/orchestrator/providers/openai-codex-identity.test.mjs +0 -2
  11. package/src/runtime/agent/orchestrator/providers/openai-codex-metadata.mjs +1 -4
  12. package/src/runtime/agent/orchestrator/providers/openai-codex-model.mjs +0 -18
  13. package/src/runtime/agent/orchestrator/providers/openai-oauth-http-sse.mjs +0 -3
  14. package/src/runtime/agent/orchestrator/providers/openai-oauth-ws.mjs +0 -1
  15. package/src/runtime/agent/orchestrator/providers/openai-responses-payload.mjs +4 -72
  16. package/src/runtime/agent/orchestrator/session/approval-mode.mjs +0 -8
  17. package/src/runtime/agent/orchestrator/session/compact/handoff.mjs +2 -4
  18. package/src/runtime/agent/orchestrator/session/compact/runner.mjs +18 -33
  19. package/src/runtime/agent/orchestrator/session/loop/recall-fasttrack.mjs +21 -42
  20. package/src/runtime/agent/orchestrator/session/manager/compaction-runner.mjs +20 -125
  21. package/src/runtime/agent/orchestrator/session/manager/session-lifecycle.mjs +50 -8
  22. package/src/runtime/agent/orchestrator/session/manager/session-lifecycle.test.mjs +31 -1
  23. package/src/runtime/agent/orchestrator/session/store/serialize.mjs +27 -4
  24. package/src/runtime/agent/orchestrator/session/store/serialize.test.mjs +60 -0
  25. package/src/runtime/agent/orchestrator/session/task-wait-control.mjs +78 -0
  26. package/src/runtime/agent/orchestrator/session/task-wait-control.test.mjs +78 -0
  27. package/src/runtime/agent/orchestrator/tools/builtin/absence-absorption.test.mjs +43 -0
  28. package/src/runtime/agent/orchestrator/tools/builtin/absolute-glob-expand.test.mjs +63 -0
  29. package/src/runtime/agent/orchestrator/tools/builtin/arg-guard.mjs +8 -0
  30. package/src/runtime/agent/orchestrator/tools/builtin/atomic-write.mjs +29 -10
  31. package/src/runtime/agent/orchestrator/tools/builtin/builtin-tools.mjs +7 -7
  32. package/src/runtime/agent/orchestrator/tools/builtin/enoent-outside-project.test.mjs +56 -0
  33. package/src/runtime/agent/orchestrator/tools/builtin/external-tool-adapters.mjs +6 -2
  34. package/src/runtime/agent/orchestrator/tools/builtin/git-command-tool.mjs +50 -23
  35. package/src/runtime/agent/orchestrator/tools/builtin/git-command-tool.test.mjs +50 -1
  36. package/src/runtime/agent/orchestrator/tools/builtin/grep-output-budget.test.mjs +31 -0
  37. package/src/runtime/agent/orchestrator/tools/builtin/grep-single-file-rescue.test.mjs +106 -0
  38. package/src/runtime/agent/orchestrator/tools/builtin/lib/absolute-glob-expand.mjs +129 -0
  39. package/src/runtime/agent/orchestrator/tools/builtin/lib/grep-context-expander.mjs +2 -1
  40. package/src/runtime/agent/orchestrator/tools/builtin/lib/grep-single-file-rescue.mjs +218 -0
  41. package/src/runtime/agent/orchestrator/tools/builtin/lib/list-helpers.mjs +9 -2
  42. package/src/runtime/agent/orchestrator/tools/builtin/list-tool-integrity.test.mjs +6 -0
  43. package/src/runtime/agent/orchestrator/tools/builtin/list-tool.mjs +50 -2
  44. package/src/runtime/agent/orchestrator/tools/builtin/native-search-client.mjs +7 -1
  45. package/src/runtime/agent/orchestrator/tools/builtin/noise-dir-visibility.test.mjs +69 -0
  46. package/src/runtime/agent/orchestrator/tools/builtin/path-diagnostics.mjs +33 -6
  47. package/src/runtime/agent/orchestrator/tools/builtin/read-glob-survey.test.mjs +71 -0
  48. package/src/runtime/agent/orchestrator/tools/builtin/read-image-resize.mjs +6 -1
  49. package/src/runtime/agent/orchestrator/tools/builtin/read-single-tool.mjs +7 -0
  50. package/src/runtime/agent/orchestrator/tools/builtin/read-tool.mjs +54 -8
  51. package/src/runtime/agent/orchestrator/tools/builtin/runtime-capabilities.mjs +90 -51
  52. package/src/runtime/agent/orchestrator/tools/builtin/runtime-capabilities.test.mjs +56 -0
  53. package/src/runtime/agent/orchestrator/tools/builtin/search-builders.mjs +25 -0
  54. package/src/runtime/agent/orchestrator/tools/builtin/search-builders.test.mjs +16 -0
  55. package/src/runtime/agent/orchestrator/tools/builtin/search-glob-tool.mjs +30 -1
  56. package/src/runtime/agent/orchestrator/tools/builtin/search-grep-tool.mjs +60 -5
  57. package/src/runtime/agent/orchestrator/tools/builtin/search-path-diagnostics.mjs +54 -1
  58. package/src/runtime/agent/orchestrator/tools/builtin/task-tool.mjs +49 -24
  59. package/src/runtime/agent/orchestrator/tools/builtin/tool-output-limit.mjs +1 -0
  60. package/src/runtime/agent/orchestrator/tools/builtin/write-symlink.test.mjs +153 -0
  61. package/src/runtime/agent/orchestrator/tools/builtin.mjs +11 -1
  62. package/src/runtime/agent/orchestrator/tools/code-graph/aggregate-anchor-relocation.test.mjs +55 -0
  63. package/src/runtime/agent/orchestrator/tools/code-graph/dispatch.mjs +54 -3
  64. package/src/runtime/agent/orchestrator/tools/env-scrub.mjs +16 -0
  65. package/src/runtime/agent/orchestrator/tools/env-scrub.test.mjs +33 -1
  66. package/src/runtime/agent/orchestrator/tools/graph-manifest.json +11 -11
  67. package/src/runtime/agent/orchestrator/tools/lib/native-spawn-client.mjs +9 -1
  68. package/src/runtime/agent/orchestrator/tools/patch/dispatch.mjs +44 -10
  69. package/src/runtime/agent/orchestrator/tools/patch/orchestrator.mjs +57 -5
  70. package/src/runtime/agent/orchestrator/tools/patch/patch-symlink.test.mjs +141 -0
  71. package/src/runtime/agent/orchestrator/tools/patch/v4a-convert.mjs +7 -3
  72. package/src/runtime/agent/orchestrator/tools/patch/v4a-pure-move.test.mjs +57 -0
  73. package/src/runtime/agent/orchestrator/tools/patch/v4a-section-coalesce.test.mjs +81 -0
  74. package/src/runtime/agent/orchestrator/tools/shell-command.mjs +42 -23
  75. package/src/runtime/media/renditions.mjs +7 -1
  76. package/src/runtime/memory/index.mjs +2 -4
  77. package/src/runtime/memory/lib/pg/process.mjs +29 -2
  78. package/src/runtime/memory/lib/pg/process.test.mjs +36 -0
  79. package/src/runtime/memory/lib/pg/supervisor.mjs +5 -1
  80. package/src/runtime/memory/lib/query-handlers.mjs +13 -19
  81. package/src/runtime/memory/lib/recall-format.mjs +13 -31
  82. package/src/runtime/memory/tool-defs.mjs +2 -2
  83. package/src/runtime/shared/memory-snapshot.mjs +57 -4
  84. package/src/runtime/shared/pristine-execution-contract.json +3 -0
  85. package/src/runtime/shared/pristine-execution.mjs +6 -3
  86. package/src/runtime/shared/tool-surface.mjs +6 -0
  87. package/src/runtime/shared/tool-surface.test.mjs +8 -0
  88. package/src/session-runtime/lifecycle-api.mjs +1 -0
  89. package/src/session-runtime/session-turn-api.mjs +5 -0
  90. package/src/standalone/agent-dispatch-broker.mjs +25 -80
  91. package/src/standalone/channel-worker-heartbeat.test.mjs +30 -0
  92. package/src/standalone/channel-worker.mjs +31 -1
  93. package/src/standalone/daemon.mjs +9 -9
  94. package/src/standalone/memory-runtime-proxy.mjs +5 -2
  95. package/src/standalone/session-client.mjs +23 -3
  96. package/src/standalone/session-runtime-host-health.test.mjs +36 -0
  97. package/src/standalone/session-runtime-host.mjs +26 -76
  98. package/src/standalone/session-runtime-worker.mjs +97 -0
  99. package/src/tui/App.jsx +3 -2
  100. package/src/tui/app/use-global-key-input.mjs +9 -0
  101. package/src/tui/app/use-mouse-input.mjs +77 -14
  102. package/src/tui/components/Spinner.jsx +1 -1
  103. package/src/tui/dist/index.mjs +83 -23
  104. package/src/tui/lib/voice-setup.mjs +3 -2
  105. package/src/tui/session/completion-card-restore.test.mjs +18 -0
  106. package/src/tui/session/session-api-ext.mjs +2 -1
  107. package/src/tui/session/session-api.mjs +8 -1
  108. package/src/tui/session/task-wait-submit.test.mjs +80 -0
  109. package/src/tui/session/turn.mjs +58 -6
  110. package/src/tui/spinner-verbs.mjs +1 -0
  111. package/src/workflows/default/WORKFLOW.md +12 -19
  112. package/src/workflows/headless/WORKFLOW.md +11 -0
  113. package/src/workflows/solo/WORKFLOW.md +6 -11
package/src/tui/App.jsx CHANGED
@@ -762,12 +762,12 @@ export function App({ store, initialStatusLine = '', forceOnboarding = false, on
762
762
  }, [stopSmoothScroll]);
763
763
 
764
764
  // SGR mouse handling: extracted to app/use-mouse-input.mjs (useMouseInput).
765
- useMouseInput({
765
+ const { settleStuckDrag } = useMouseInput({
766
766
  inkInput,
767
767
  isRawModeSupported,
768
768
  store,
769
769
  stdout,
770
- rows: resizeState.rows,
770
+ frameColumns,
771
771
  statuslineBandRows: STATUSLINE_BAND_ROWS,
772
772
  dragRef,
773
773
  lastClickRef,
@@ -914,6 +914,7 @@ export function App({ store, initialStatusLine = '', forceOnboarding = false, on
914
914
  scrollTranscriptRows,
915
915
  resetTranscriptScroll,
916
916
  applySelectionRect,
917
+ settleStuckDrag,
917
918
  });
918
919
 
919
920
  // Usage-quota dashboard + /context breakdown panels:
@@ -28,9 +28,18 @@ export function useGlobalKeyInput({
28
28
  scrollTranscriptRows,
29
29
  resetTranscriptScroll,
30
30
  applySelectionRect,
31
+ settleStuckDrag,
31
32
  }) {
32
33
  // (body moved verbatim)
33
34
  useInput((input, key) => {
35
+ // A drag whose button release never reached the app (button let go OUTSIDE
36
+ // the terminal window, or the release swallowed while mouse tracking was
37
+ // off) leaves dragRef.current.active stuck true: Ctrl+C copy is gated on
38
+ // !active, and every later scroll rebuilds the rect from anchor→last so the
39
+ // highlight drifts on its own. A keystroke proves the gesture is over —
40
+ // settle it through the same path a real release takes, before any branch
41
+ // below reads the selection.
42
+ settleStuckDrag?.();
34
43
  if (toolApproval) {
35
44
  const value = String(input || '').trim().toLowerCase();
36
45
  if (key.escape || value === 'd' || value === 'n') {
@@ -140,7 +140,7 @@ export function useMouseInput({
140
140
  isRawModeSupported,
141
141
  store,
142
142
  stdout,
143
- rows,
143
+ frameColumns,
144
144
  statuslineBandRows,
145
145
  dragRef,
146
146
  lastClickRef,
@@ -172,6 +172,29 @@ export function useMouseInput({
172
172
  // Wheel acceleration state (see WHEEL_STEP_ROWS). Hook-scoped so it survives
173
173
  // the input effect's re-subscribes.
174
174
  const wheelAccelRef = useRef({ dir: 0, t: 0, step: WHEEL_STEP_ROWS });
175
+ // Set by the input effect to its own finalizeActiveDrag (+ the WT gesture
176
+ // finish). Held in a ref so settleStuckDrag below can reuse the EXACT
177
+ // button-release path without hoisting the whole handler out of the effect.
178
+ const finalizeDragRef = useRef(null);
179
+
180
+ // Recovery for a drag whose release never arrived: the button was let go
181
+ // OUTSIDE the terminal window, or the release was swallowed while mouse
182
+ // tracking was off. drag.active then stays true indefinitely — Ctrl+C copy is
183
+ // gated on !active, and every later scroll rebuilds the rect from
184
+ // anchor→last, so the highlight keeps moving with no pointer behind it. App
185
+ // calls this from the global key handler: any keystroke ends the gesture.
186
+ const settleStuckDrag = useCallback(() => {
187
+ const drag = dragRef.current;
188
+ if (!drag?.active) return false;
189
+ const finalize = finalizeDragRef.current;
190
+ if (!finalize) {
191
+ drag.active = false;
192
+ return true;
193
+ }
194
+ const last = drag.last || {};
195
+ finalize(Number(last.x) || 0, Number(last.y) || 0);
196
+ return true;
197
+ }, [dragRef]);
175
198
 
176
199
  const passthroughCtrlWheelZoom = useCallback(() => {
177
200
  // Re-enable with retries. Console stream failures are normally reported to
@@ -247,6 +270,26 @@ export function useMouseInput({
247
270
  const { top, bottom } = statusBand();
248
271
  return Math.max(top, Math.min(bottom, row));
249
272
  };
273
+ const maxSelectionColumn = () => {
274
+ const cols = Math.max(1, Number(frameColumns) || Number(stdout?.columns) || 80);
275
+ return cols - 1;
276
+ };
277
+ // Snap a drag point into the region that owns the selection. Rows clamp to
278
+ // the band as before, but the COLUMN now follows normal text-selection
279
+ // semantics: a pointer ABOVE the band selects to the start of its first
280
+ // row, BELOW it to the end of its last row — instead of freezing at
281
+ // whatever column the pointer happened to hold, which painted a partial row
282
+ // on the wrong side of the anchor. Horizontal overshoot is clamped into the
283
+ // grid too: while the pointer sits outside the window a terminal can report
284
+ // column 0 (x = -1 after the 1-based fixup) or a column past the width, and
285
+ // that point orders BEFORE/AFTER the anchor and visibly flips the selection.
286
+ const selectionPointInRegion = (x, y, region) => {
287
+ const { top, bottom } = region === 'status' ? statusBand() : transcriptViewport();
288
+ const maxX = maxSelectionColumn();
289
+ if (y < top) return { x: 0, y: top };
290
+ if (y > bottom) return { x: maxX, y: bottom };
291
+ return { x: Math.max(0, Math.min(maxX, x)), y };
292
+ };
250
293
  const promptRect = () => promptBoxRectRef.current;
251
294
  const isInPromptBox = (x, y) => {
252
295
  const r = promptRect();
@@ -346,16 +389,21 @@ export function useMouseInput({
346
389
  return;
347
390
  }
348
391
  const span = drag.anchorSpan;
349
- const finalY = region === 'status' ? clampToStatusBand(fy) : clampToTranscriptViewport(fy);
392
+ // Release can land outside the region (or outside the window entirely) —
393
+ // snap it the same way drag motion does, so the finalized rect matches
394
+ // the highlight the user was looking at.
395
+ const finalPoint = selectionPointInRegion(fx, fy, region);
396
+ const finalX = finalPoint.x;
397
+ const finalY = finalPoint.y;
350
398
  drag.active = false;
351
399
  if (span) {
352
- const rect = buildSpanRect(span, fx, finalY, region, drag.anchorScroll);
400
+ const rect = buildSpanRect(span, finalX, finalY, region, drag.anchorScroll);
353
401
  applySelectionRect(rect);
354
402
  } else {
355
403
  const anchor = region === 'status'
356
404
  ? drag.anchor
357
405
  : selectionPointAtCurrentScroll(drag.anchor, drag.anchorScroll);
358
- const rect = linearSelection(anchor, { x: fx, y: finalY });
406
+ const rect = linearSelection(anchor, { x: finalX, y: finalY });
359
407
  const empty = rect.x1 === rect.x2 && rect.y1 === rect.y2;
360
408
  if (empty) applySelectionRect(null);
361
409
  else applySelectionRect(rect);
@@ -718,37 +766,43 @@ export function useMouseInput({
718
766
  return;
719
767
  }
720
768
  // Drag motion (transcript or status): extend the selection to the
721
- // current cell, clamped to the owning region's band.
722
- const selectionY = region === 'status' ? clampToStatusBand(y) : clampToTranscriptViewport(y);
769
+ // current cell, snapped into the owning region's band — rows clamp,
770
+ // and a pointer outside the band takes that row's start/end column.
771
+ const motionPoint = selectionPointInRegion(x, y, region);
772
+ const selectionX = motionPoint.x;
773
+ const selectionY = motionPoint.y;
723
774
  const prevDragY = dragRef.current.last ? Number(dragRef.current.last.y) : y;
724
- dragRef.current.last = { x, y: selectionY };
775
+ dragRef.current.last = { x: selectionX, y: selectionY };
725
776
  const span = dragRef.current.anchorSpan;
726
777
  if (span) {
727
778
  // Word/line multi-click drag: extend by whole words/lines from the
728
779
  // anchor span to the word/line under the cursor (see buildSpanRect).
729
- const rect = buildSpanRect(span, x, selectionY, region, dragRef.current.anchorScroll);
780
+ const rect = buildSpanRect(span, selectionX, selectionY, region, dragRef.current.anchorScroll);
730
781
  applySelectionRectThrottled(rect);
731
782
  } else {
732
783
  const anchor = region === 'status'
733
784
  ? dragRef.current.anchor
734
785
  : selectionPointAtCurrentScroll(dragRef.current.anchor, dragRef.current.anchorScroll);
735
- const rect = linearSelection(anchor, { x, y: selectionY });
786
+ const rect = linearSelection(anchor, { x: selectionX, y: selectionY });
736
787
  applySelectionRectThrottled(rect);
737
788
  }
738
789
  // Auto-scroll-while-dragging is transcript-only (the status band does
739
790
  // not scroll).
740
791
  if (region === 'transcript') {
741
- const frameRows = Math.max(1, Number(rows) || 24);
742
792
  const { top, bottom } = transcriptViewport();
743
793
  // Edge auto-scroll only when the pointer pushes TOWARD the edge:
744
794
  // either this motion moved vertically toward it, or the pointer
745
795
  // sits beyond the transcript viewport rows entirely. A horizontal
746
796
  // drag along the top/bottom rows must NOT scroll — it used to
747
- // scroll away the very rows being selected.
748
- if (y <= 1 && (y < prevDragY || y < top)) {
797
+ // scroll away the very rows being selected. The edge is the
798
+ // VIEWPORT's own first/last row: the previous screen-absolute
799
+ // guesses (row <= 1 / rows - 5) drifted away from the real
800
+ // transcript bounds whenever the prompt box grew, leaving rows that
801
+ // clamped the selection without ever scrolling.
802
+ if (y <= top && (y < prevDragY || y < top)) {
749
803
  queueScrollCoalesced(3);
750
804
  startEdgeAutoscroll(1);
751
- } else if (y >= frameRows - 5 && (y > prevDragY || y > bottom)) {
805
+ } else if (y >= bottom && (y > prevDragY || y > bottom)) {
752
806
  queueScrollCoalesced(-3);
753
807
  startEdgeAutoscroll(-1);
754
808
  } else {
@@ -774,10 +828,19 @@ export function useMouseInput({
774
828
  }
775
829
  }
776
830
  };
831
+ // Expose this effect's release path so a keystroke can settle a drag whose
832
+ // release never arrived (see settleStuckDrag).
833
+ finalizeDragRef.current = (fx, fy) => {
834
+ finalizeActiveDrag(fx, fy);
835
+ finishWindowsMouseGesture();
836
+ };
777
837
  inkInput.on('mouse', onMouse);
778
838
  return () => {
779
839
  inkInput.off('mouse', onMouse);
840
+ finalizeDragRef.current = null;
780
841
  stopEdgeAutoscroll();
781
842
  };
782
- }, [inkInput, isRawModeSupported, store, passthroughCtrlWheelZoom, rows, scrollTranscriptRows, queueScrollCoalesced, applySelectionRect, applySelectionRectThrottled, selectionPointAtCurrentScroll, buildSpanRect]);
843
+ }, [inkInput, isRawModeSupported, store, passthroughCtrlWheelZoom, frameColumns, scrollTranscriptRows, queueScrollCoalesced, applySelectionRect, applySelectionRectThrottled, selectionPointAtCurrentScroll, buildSpanRect]);
844
+
845
+ return { settleStuckDrag };
783
846
  }
@@ -223,7 +223,7 @@ export function Spinner({ verb = 'Working', startedAt, outputTokens = 0, tokens
223
223
  // desktop shows the same word at the same second.
224
224
  const displayVerb = SPINNER_MODE_OVERRIDE_VERBS[mode]
225
225
  || (mode === 'reconnecting' ? (String(verb || '').trim() || 'Reconnecting') : spinnerVerbFor(startedAt, now));
226
- const messageText = mode === 'reconnecting' ? displayVerb : `${displayVerb}…`;
226
+ const messageText = displayVerb;
227
227
  const messageLen = messageText.length;
228
228
 
229
229
  // Glimmer speed per mode.
@@ -995,7 +995,12 @@ async function loadSharp() {
995
995
  _sharpPromise = (async () => {
996
996
  try {
997
997
  const mod = await import("sharp");
998
- return mod?.default || mod || null;
998
+ const sharp = mod?.default || mod || null;
999
+ try {
1000
+ sharp?.cache(false);
1001
+ } catch {
1002
+ }
1003
+ return sharp;
999
1004
  } catch {
1000
1005
  return null;
1001
1006
  }
@@ -4712,7 +4717,8 @@ var MAX_HELD_BOUNDARIES = 3;
4712
4717
  var SPINNER_MODE_OVERRIDE_VERBS = {
4713
4718
  compacting: "Compacting conversation",
4714
4719
  "auto-clear": "Auto-clearing conversation",
4715
- resuming: "Resuming conversation"
4720
+ resuming: "Resuming conversation",
4721
+ "task-wait": "\uC791\uC5C5 \uB300\uAE30 \uC911"
4716
4722
  };
4717
4723
  function spinnerVerbFor(startedAt = 0, now = 0, pool = SPINNER_VERBS) {
4718
4724
  const list = Array.isArray(pool) && pool.length ? pool : SPINNER_VERBS;
@@ -4952,7 +4958,7 @@ function Spinner({ verb = "Working", startedAt, outputTokens = 0, tokens = 0, th
4952
4958
  stalledIntensity
4953
4959
  )) : theme.spinnerGlyph;
4954
4960
  const displayVerb = SPINNER_MODE_OVERRIDE_VERBS[mode] || (mode === "reconnecting" ? String(verb || "").trim() || "Reconnecting" : spinnerVerbFor(startedAt, now));
4955
- const messageText = mode === "reconnecting" ? displayVerb : `${displayVerb}\u2026`;
4961
+ const messageText = displayVerb;
4956
4962
  const messageLen = messageText.length;
4957
4963
  const glimmerSpeed = GLIMMER_SPEED_MS[mode] ?? 200;
4958
4964
  const shimmerSpan = Math.max(1, messageLen + GLIMMER_TRAIL);
@@ -13515,7 +13521,7 @@ function useMouseInput({
13515
13521
  isRawModeSupported,
13516
13522
  store,
13517
13523
  stdout: stdout2,
13518
- rows,
13524
+ frameColumns,
13519
13525
  statuslineBandRows,
13520
13526
  dragRef,
13521
13527
  lastClickRef,
@@ -13543,6 +13549,19 @@ function useMouseInput({
13543
13549
  }
13544
13550
  const edgeAutoscrollRef = useRef7({ dir: 0, timer: null, noMove: 0 });
13545
13551
  const wheelAccelRef = useRef7({ dir: 0, t: 0, step: WHEEL_STEP_ROWS });
13552
+ const finalizeDragRef = useRef7(null);
13553
+ const settleStuckDrag = useCallback2(() => {
13554
+ const drag = dragRef.current;
13555
+ if (!drag?.active) return false;
13556
+ const finalize = finalizeDragRef.current;
13557
+ if (!finalize) {
13558
+ drag.active = false;
13559
+ return true;
13560
+ }
13561
+ const last = drag.last || {};
13562
+ finalize(Number(last.x) || 0, Number(last.y) || 0);
13563
+ return true;
13564
+ }, [dragRef]);
13546
13565
  const passthroughCtrlWheelZoom = useCallback2(() => {
13547
13566
  zoomRestoreSchedulerRef.current.passthrough();
13548
13567
  }, []);
@@ -13577,9 +13596,9 @@ function useMouseInput({
13577
13596
  return Math.max(top, Math.min(bottom, row));
13578
13597
  };
13579
13598
  const statusBand = () => {
13580
- const rows2 = Math.max(1, Number(frameRowsRef.current) || 24);
13581
- const top = Math.max(0, rows2 - statuslineBandRows);
13582
- return { top, bottom: Math.max(top, rows2 - 1) };
13599
+ const rows = Math.max(1, Number(frameRowsRef.current) || 24);
13600
+ const top = Math.max(0, rows - statuslineBandRows);
13601
+ return { top, bottom: Math.max(top, rows - 1) };
13583
13602
  };
13584
13603
  const isInStatusBand = (row) => {
13585
13604
  const { top, bottom } = statusBand();
@@ -13589,6 +13608,17 @@ function useMouseInput({
13589
13608
  const { top, bottom } = statusBand();
13590
13609
  return Math.max(top, Math.min(bottom, row));
13591
13610
  };
13611
+ const maxSelectionColumn = () => {
13612
+ const cols = Math.max(1, Number(frameColumns) || Number(stdout2?.columns) || 80);
13613
+ return cols - 1;
13614
+ };
13615
+ const selectionPointInRegion = (x, y, region) => {
13616
+ const { top, bottom } = region === "status" ? statusBand() : transcriptViewport();
13617
+ const maxX = maxSelectionColumn();
13618
+ if (y < top) return { x: 0, y: top };
13619
+ if (y > bottom) return { x: maxX, y: bottom };
13620
+ return { x: Math.max(0, Math.min(maxX, x)), y };
13621
+ };
13592
13622
  const promptRect = () => promptBoxRectRef.current;
13593
13623
  const isInPromptBox = (x, y) => {
13594
13624
  const r = promptRect();
@@ -13663,14 +13693,16 @@ function useMouseInput({
13663
13693
  return;
13664
13694
  }
13665
13695
  const span = drag.anchorSpan;
13666
- const finalY = region === "status" ? clampToStatusBand(fy) : clampToTranscriptViewport(fy);
13696
+ const finalPoint = selectionPointInRegion(fx, fy, region);
13697
+ const finalX = finalPoint.x;
13698
+ const finalY = finalPoint.y;
13667
13699
  drag.active = false;
13668
13700
  if (span) {
13669
- const rect = buildSpanRect(span, fx, finalY, region, drag.anchorScroll);
13701
+ const rect = buildSpanRect(span, finalX, finalY, region, drag.anchorScroll);
13670
13702
  applySelectionRect(rect);
13671
13703
  } else {
13672
13704
  const anchor = region === "status" ? drag.anchor : selectionPointAtCurrentScroll(drag.anchor, drag.anchorScroll);
13673
- const rect = linearSelection(anchor, { x: fx, y: finalY });
13705
+ const rect = linearSelection(anchor, { x: finalX, y: finalY });
13674
13706
  const empty = rect.x1 === rect.x2 && rect.y1 === rect.y2;
13675
13707
  if (empty) applySelectionRect(null);
13676
13708
  else applySelectionRect(rect);
@@ -13903,25 +13935,26 @@ function useMouseInput({
13903
13935
  if (offset != null) promptMouseSelectionRef.current?.extendTo?.(offset);
13904
13936
  return;
13905
13937
  }
13906
- const selectionY = region === "status" ? clampToStatusBand(y) : clampToTranscriptViewport(y);
13938
+ const motionPoint = selectionPointInRegion(x, y, region);
13939
+ const selectionX = motionPoint.x;
13940
+ const selectionY = motionPoint.y;
13907
13941
  const prevDragY = dragRef.current.last ? Number(dragRef.current.last.y) : y;
13908
- dragRef.current.last = { x, y: selectionY };
13942
+ dragRef.current.last = { x: selectionX, y: selectionY };
13909
13943
  const span = dragRef.current.anchorSpan;
13910
13944
  if (span) {
13911
- const rect = buildSpanRect(span, x, selectionY, region, dragRef.current.anchorScroll);
13945
+ const rect = buildSpanRect(span, selectionX, selectionY, region, dragRef.current.anchorScroll);
13912
13946
  applySelectionRectThrottled(rect);
13913
13947
  } else {
13914
13948
  const anchor = region === "status" ? dragRef.current.anchor : selectionPointAtCurrentScroll(dragRef.current.anchor, dragRef.current.anchorScroll);
13915
- const rect = linearSelection(anchor, { x, y: selectionY });
13949
+ const rect = linearSelection(anchor, { x: selectionX, y: selectionY });
13916
13950
  applySelectionRectThrottled(rect);
13917
13951
  }
13918
13952
  if (region === "transcript") {
13919
- const frameRows = Math.max(1, Number(rows) || 24);
13920
13953
  const { top, bottom } = transcriptViewport();
13921
- if (y <= 1 && (y < prevDragY || y < top)) {
13954
+ if (y <= top && (y < prevDragY || y < top)) {
13922
13955
  queueScrollCoalesced(3);
13923
13956
  startEdgeAutoscroll(1);
13924
- } else if (y >= frameRows - 5 && (y > prevDragY || y > bottom)) {
13957
+ } else if (y >= bottom && (y > prevDragY || y > bottom)) {
13925
13958
  queueScrollCoalesced(-3);
13926
13959
  startEdgeAutoscroll(-1);
13927
13960
  } else {
@@ -13934,12 +13967,18 @@ function useMouseInput({
13934
13967
  }
13935
13968
  }
13936
13969
  };
13970
+ finalizeDragRef.current = (fx, fy) => {
13971
+ finalizeActiveDrag(fx, fy);
13972
+ finishWindowsMouseGesture();
13973
+ };
13937
13974
  inkInput.on("mouse", onMouse);
13938
13975
  return () => {
13939
13976
  inkInput.off("mouse", onMouse);
13977
+ finalizeDragRef.current = null;
13940
13978
  stopEdgeAutoscroll();
13941
13979
  };
13942
- }, [inkInput, isRawModeSupported, store, passthroughCtrlWheelZoom, rows, scrollTranscriptRows, queueScrollCoalesced, applySelectionRect, applySelectionRectThrottled, selectionPointAtCurrentScroll, buildSpanRect]);
13980
+ }, [inkInput, isRawModeSupported, store, passthroughCtrlWheelZoom, frameColumns, scrollTranscriptRows, queueScrollCoalesced, applySelectionRect, applySelectionRectThrottled, selectionPointAtCurrentScroll, buildSpanRect]);
13981
+ return { settleStuckDrag };
13943
13982
  }
13944
13983
 
13945
13984
  // src/tui/app/use-transcript-scroll.mjs
@@ -16061,9 +16100,11 @@ function useGlobalKeyInput({
16061
16100
  toggleExpand,
16062
16101
  scrollTranscriptRows,
16063
16102
  resetTranscriptScroll,
16064
- applySelectionRect
16103
+ applySelectionRect,
16104
+ settleStuckDrag
16065
16105
  }) {
16066
16106
  useInput5((input, key) => {
16107
+ settleStuckDrag?.();
16067
16108
  if (toolApproval) {
16068
16109
  const value = String(input || "").trim().toLowerCase();
16069
16110
  if (key.escape || value === "d" || value === "n") {
@@ -20573,6 +20614,23 @@ function isVoiceEnabled() {
20573
20614
  return false;
20574
20615
  }
20575
20616
  }
20617
+ async function getVoiceStatus({ dataDir: dataDir2 = resolvePluginData() } = {}) {
20618
+ const fetcher = await loadVoiceRuntimeFetcher();
20619
+ const runtime = fetcher.resolveVoiceRuntime(dataDir2, {
20620
+ modelId: fetcher.selectVoiceModelId(readSection("voice"))
20621
+ });
20622
+ return {
20623
+ enabled: isVoiceEnabled(),
20624
+ busy: isVoiceInstallBusy(),
20625
+ installed: runtime.installed === true,
20626
+ modelId: runtime.modelId,
20627
+ components: {
20628
+ whisper: Boolean(runtime.binary && runtime.serverCmd),
20629
+ model: Boolean(runtime.model),
20630
+ ffmpeg: Boolean(runtime.ffmpeg)
20631
+ }
20632
+ };
20633
+ }
20576
20634
  var PROGRESS_BAR_CELLS = 6;
20577
20635
  function renderProgressBarText(phase, downloaded, total) {
20578
20636
  const label = phaseLabel(phase);
@@ -20629,7 +20687,8 @@ async function ensureVoiceRuntimeReady({ dataDir: dataDir2 = resolvePluginData()
20629
20687
  }
20630
20688
  async function toggleVoice({ pushNotice, setProgressHint } = {}) {
20631
20689
  const dataDir2 = resolvePluginData();
20632
- if (isVoiceEnabled()) {
20690
+ const status = await getVoiceStatus({ dataDir: dataDir2 });
20691
+ if (status.enabled && status.installed) {
20633
20692
  try {
20634
20693
  await updateSectionAsync("voice", (current) => ({ ...current, enabled: false }));
20635
20694
  } catch (err) {
@@ -23424,12 +23483,12 @@ function App({ store, initialStatusLine = "", forceOnboarding = false, onboardin
23424
23483
  useEffect14(() => () => {
23425
23484
  stopSmoothScroll();
23426
23485
  }, [stopSmoothScroll]);
23427
- useMouseInput({
23486
+ const { settleStuckDrag } = useMouseInput({
23428
23487
  inkInput,
23429
23488
  isRawModeSupported,
23430
23489
  store,
23431
23490
  stdout: stdout2,
23432
- rows: resizeState.rows,
23491
+ frameColumns,
23433
23492
  statuslineBandRows: STATUSLINE_BAND_ROWS,
23434
23493
  dragRef,
23435
23494
  lastClickRef,
@@ -23555,7 +23614,8 @@ function App({ store, initialStatusLine = "", forceOnboarding = false, onboardin
23555
23614
  toggleExpand,
23556
23615
  scrollTranscriptRows,
23557
23616
  resetTranscriptScroll,
23558
- applySelectionRect
23617
+ applySelectionRect,
23618
+ settleStuckDrag
23559
23619
  });
23560
23620
  const { openUsagePanel, openContextPicker } = createUsageContextPanels({
23561
23621
  store,
@@ -113,7 +113,7 @@ function makeThrottledProgressNotice({ pushNotice, setProgressHint } = {}, inter
113
113
  * runtime descriptor (resolveVoiceRuntime shape) once `installed` is true;
114
114
  * throws on any ensure* failure (manifest fetch, sha256 mismatch, etc.).
115
115
  */
116
- async function ensureVoiceRuntimeReady({ dataDir = resolvePluginData(), pushNotice, setProgressHint } = {}) {
116
+ export async function ensureVoiceRuntimeReady({ dataDir = resolvePluginData(), pushNotice, setProgressHint } = {}) {
117
117
  const fetcher = await loadVoiceRuntimeFetcher();
118
118
  // Every device installs the same standard multilingual Q8 model.
119
119
  const modelId = fetcher.selectVoiceModelId(readSection('voice'));
@@ -152,7 +152,8 @@ async function ensureVoiceRuntimeReady({ dataDir = resolvePluginData(), pushNoti
152
152
  */
153
153
  export async function toggleVoice({ pushNotice, setProgressHint } = {}) {
154
154
  const dataDir = resolvePluginData();
155
- if (isVoiceEnabled()) {
155
+ const status = await getVoiceStatus({ dataDir });
156
+ if (status.enabled && status.installed) {
156
157
  // The async RMW preserves the shared config lock/ACL protocol without
157
158
  // blocking the TUI event loop. It can still throw — a locked/corrupt config,
158
159
  // permissions error, etc. Guard it the same way the ON path is guarded and
@@ -91,3 +91,21 @@ test('restored shell results preserve command-failure and no-match taxonomy', ()
91
91
  assert.equal(probe?.isError, false);
92
92
  assert.equal(probe?.exitErrorCount, 0);
93
93
  });
94
+
95
+ test('task wait calls stay hidden when a session transcript is restored', () => {
96
+ const messages = [
97
+ {
98
+ role: 'assistant',
99
+ toolCalls: [
100
+ { id: 'call_wait', name: 'task', arguments: { action: 'wait', task_id: 'task_shell_1' } },
101
+ { id: 'call_read', name: 'task', arguments: { action: 'read', task_id: 'task_shell_1' } },
102
+ ],
103
+ },
104
+ { role: 'tool', toolCallId: 'call_wait', content: 'status: running' },
105
+ { role: 'tool', toolCallId: 'call_read', content: 'status: completed' },
106
+ ];
107
+
108
+ const items = restoreTranscriptItems(messages, { sessionId: 'sess_task_wait_restore' });
109
+ assert.equal(items.some((item) => item?.kind === 'tool' && item?.args?.action === 'wait'), false);
110
+ assert.equal(items.some((item) => item?.kind === 'tool' && item?.args?.action === 'read'), true);
111
+ });
@@ -8,7 +8,7 @@ import { parseModelVisibleCompletionWrapper, parseSyntheticAgentMessage } from '
8
8
  import { flushTuiSteeringPersist } from './tui-steering-persist.mjs';
9
9
  import { getVoiceStatus, toggleVoice } from '../lib/voice-setup.mjs';
10
10
  import { createSessionOAuthFlowRegistry } from './oauth-flows.mjs';
11
- import { aggregateToolCategoryEntries, aggregateDoneCategories, classifyToolCategory, formatAggregateDetail, summarizeToolResult, toolLoadingTargets } from '../../runtime/shared/tool-surface.mjs';
11
+ import { aggregateToolCategoryEntries, aggregateDoneCategories, classifyToolCategory, formatAggregateDetail, isTaskWaitToolCall, summarizeToolResult, toolLoadingTargets } from '../../runtime/shared/tool-surface.mjs';
12
12
  import { aggregateBucketForCategory, aggregateRawResult, aggregateToolMembers, failureDetailText, toolCallOutcome } from './tool-result-status.mjs';
13
13
  import {
14
14
  isInternalTranscriptDisplayText,
@@ -75,6 +75,7 @@ function restoredToolCallItems(message, nextId, pendingByCallId) {
75
75
  if (typeof args === 'string') {
76
76
  try { args = JSON.parse(args); } catch { /* keep the raw string args */ }
77
77
  }
78
+ if (isTaskWaitToolCall(name, args)) continue;
78
79
  const item = {
79
80
  kind: 'tool',
80
81
  id: nextId(),
@@ -80,7 +80,14 @@ export function createSessionApiA(bag) {
80
80
  const submissionId = String(intake?.queueOptions?.id || '').trim();
81
81
  if (submissionId) acceptingSubmissions.delete(submissionId);
82
82
  if (intake?.cancelled === true) return false;
83
- return enqueue(intake.text, intake.queueOptions);
83
+ const accepted = enqueue(intake.text, intake.queueOptions);
84
+ // User input wakes a passive `task wait` without cancelling either the
85
+ // turn or the background task. The returned running snapshot creates the
86
+ // normal post-tool boundary, where this queued prompt is injected.
87
+ if (accepted !== false) {
88
+ try { runtime.interruptTaskWait?.('user-message'); } catch {}
89
+ }
90
+ return accepted;
84
91
  };
85
92
  const submit = (text, options = {}) => {
86
93
  const intake = submission(text, options);
@@ -0,0 +1,80 @@
1
+ import assert from 'node:assert/strict';
2
+ import test from 'node:test';
3
+
4
+ import { SPINNER_MODE_OVERRIDE_VERBS } from '../spinner-verbs.mjs';
5
+ import { createSessionApiA } from './session-api.mjs';
6
+
7
+ function createHarness({ enqueueResult = true } = {}) {
8
+ let state = {
9
+ busy: true,
10
+ commandBusy: false,
11
+ };
12
+ let interruptCount = 0;
13
+ const queued = [];
14
+ const api = createSessionApiA({
15
+ runtime: {
16
+ interruptTaskWait(reason) {
17
+ assert.equal(reason, 'user-message');
18
+ interruptCount += 1;
19
+ },
20
+ },
21
+ nextId: () => `submission_${queued.length + 1}`,
22
+ flags: { autoClearRunning: false },
23
+ pending: [],
24
+ listeners: new Set(),
25
+ getState: () => state,
26
+ getPublishedState: () => state,
27
+ set: (patch) => { state = { ...state, ...patch }; },
28
+ flushEmitImmediate() {},
29
+ pushItem() {},
30
+ patchItem() {},
31
+ replaceItems: (items) => items,
32
+ restoreOlderTranscript() {},
33
+ restoreNewerTranscript() {},
34
+ settleStreamingTail() {},
35
+ clearStreamingTail() {},
36
+ pushNotice() {},
37
+ autoClearState: {},
38
+ agentStatusState: () => ({}),
39
+ routeState: () => ({}),
40
+ syncContextStats() {},
41
+ denyAllToolApprovals() {},
42
+ updateAgentJobCard() {},
43
+ requeueEntriesFront() {},
44
+ enqueue(text, options) {
45
+ queued.push({ text, options });
46
+ return enqueueResult;
47
+ },
48
+ autoClearBeforeSubmit: async () => {},
49
+ restoreQueued() {},
50
+ prioritizeQueued() {},
51
+ resetStatsAndSyncContext() {},
52
+ drain() {},
53
+ flushDeferredExecutionPendingResumeKick() {},
54
+ discardExecutionPendingResume() {},
55
+ });
56
+ return {
57
+ api,
58
+ queued,
59
+ interruptCount: () => interruptCount,
60
+ };
61
+ }
62
+
63
+ test('accepted user input wakes an active task wait', () => {
64
+ const harness = createHarness();
65
+
66
+ assert.equal(harness.api.submit('새 지시'), true);
67
+ assert.equal(harness.queued.length, 1);
68
+ assert.equal(harness.interruptCount(), 1);
69
+ });
70
+
71
+ test('rejected user input does not wake a task wait', () => {
72
+ const harness = createHarness({ enqueueResult: false });
73
+
74
+ assert.equal(harness.api.submit('중복 지시'), false);
75
+ assert.equal(harness.interruptCount(), 0);
76
+ });
77
+
78
+ test('task wait spinner has the dedicated waiting label', () => {
79
+ assert.equal(SPINNER_MODE_OVERRIDE_VERBS['task-wait'], '작업 대기 중');
80
+ });