oh-my-codex 0.22.5 → 0.22.7

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 (57) hide show
  1. package/Cargo.lock +6 -6
  2. package/Cargo.toml +1 -1
  3. package/dist/cli/__tests__/cleanup.test.js +58 -73
  4. package/dist/cli/__tests__/cleanup.test.js.map +1 -1
  5. package/dist/cli/__tests__/question.test.js +193 -2
  6. package/dist/cli/__tests__/question.test.js.map +1 -1
  7. package/dist/cli/cleanup.d.ts +0 -16
  8. package/dist/cli/cleanup.d.ts.map +1 -1
  9. package/dist/cli/cleanup.js +2 -71
  10. package/dist/cli/cleanup.js.map +1 -1
  11. package/dist/cli/index.d.ts +1 -1
  12. package/dist/cli/index.d.ts.map +1 -1
  13. package/dist/cli/index.js +1 -1
  14. package/dist/cli/question.d.ts.map +1 -1
  15. package/dist/cli/question.js +38 -20
  16. package/dist/cli/question.js.map +1 -1
  17. package/dist/question/__tests__/renderer.test.js +84 -50
  18. package/dist/question/__tests__/renderer.test.js.map +1 -1
  19. package/dist/question/__tests__/state.test.js +192 -2
  20. package/dist/question/__tests__/state.test.js.map +1 -1
  21. package/dist/question/__tests__/ui.test.js +82 -1
  22. package/dist/question/__tests__/ui.test.js.map +1 -1
  23. package/dist/question/renderer.d.ts +2 -2
  24. package/dist/question/renderer.d.ts.map +1 -1
  25. package/dist/question/renderer.js +14 -22
  26. package/dist/question/renderer.js.map +1 -1
  27. package/dist/question/state.d.ts +4 -0
  28. package/dist/question/state.d.ts.map +1 -1
  29. package/dist/question/state.js +76 -23
  30. package/dist/question/state.js.map +1 -1
  31. package/dist/question/ui.d.ts.map +1 -1
  32. package/dist/question/ui.js +8 -2
  33. package/dist/question/ui.js.map +1 -1
  34. package/dist/scripts/notify-hook/team-dispatch.d.ts.map +1 -1
  35. package/dist/scripts/notify-hook/team-dispatch.js +137 -128
  36. package/dist/scripts/notify-hook/team-dispatch.js.map +1 -1
  37. package/dist/team/__tests__/lock-recovery.test.d.ts +2 -0
  38. package/dist/team/__tests__/lock-recovery.test.d.ts.map +1 -0
  39. package/dist/team/__tests__/lock-recovery.test.js +304 -0
  40. package/dist/team/__tests__/lock-recovery.test.js.map +1 -0
  41. package/dist/team/__tests__/state.test.js +8 -6
  42. package/dist/team/__tests__/state.test.js.map +1 -1
  43. package/dist/team/state/dispatch-lock.d.ts.map +1 -1
  44. package/dist/team/state/dispatch-lock.js +3 -11
  45. package/dist/team/state/dispatch-lock.js.map +1 -1
  46. package/dist/team/state/locks.d.ts +1 -0
  47. package/dist/team/state/locks.d.ts.map +1 -1
  48. package/dist/team/state/locks.js +29 -13
  49. package/dist/team/state/locks.js.map +1 -1
  50. package/package.json +1 -1
  51. package/plugins/oh-my-codex/.codex-plugin/plugin.json +1 -1
  52. package/plugins/oh-my-codex/templates/AGENTS.md +2 -3
  53. package/prompts/build-fixer.md +4 -4
  54. package/prompts/team-executor.md +3 -3
  55. package/skills/ultrawork/references/agent-tiers.md +1 -1
  56. package/src/scripts/notify-hook/team-dispatch.ts +133 -125
  57. package/templates/AGENTS.md +2 -3
@@ -1,4 +1,5 @@
1
1
  import assert from 'node:assert/strict';
2
+ import { execFileSync } from 'node:child_process';
2
3
  import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
3
4
  import { tmpdir } from 'node:os';
4
5
  import { join } from 'node:path';
@@ -273,12 +274,12 @@ describe('question window topology selection', () => {
273
274
  });
274
275
  });
275
276
  describe('launchQuestionRenderer', () => {
276
- it('fails before building UI argv or invoking tmux when no visible renderer is available', () => {
277
+ it('fails before building UI argv or invoking tmux when no visible renderer is available', async () => {
277
278
  const calls = [];
278
279
  const originalArgv1 = process.argv[1];
279
280
  process.argv[1] = '';
280
281
  try {
281
- assert.throws(() => launchQuestionRenderer({
282
+ await assert.rejects(() => launchQuestionRenderer({
282
283
  cwd: '/repo',
283
284
  recordPath: '/repo/.omx/state/sessions/s1/questions/question-1.json',
284
285
  env: {},
@@ -303,9 +304,9 @@ describe('launchQuestionRenderer', () => {
303
304
  }
304
305
  assert.deepEqual(calls, []);
305
306
  });
306
- it('opens an interactive foreground split when already inside an attached tmux session', () => {
307
+ it('opens an interactive foreground split when already inside an attached tmux session', async () => {
307
308
  const calls = [];
308
- const result = launchQuestionRenderer({
309
+ const result = await launchQuestionRenderer({
309
310
  cwd: '/repo',
310
311
  recordPath: '/repo/.omx/state/sessions/s1/questions/question-1.json',
311
312
  sessionId: 's1',
@@ -352,7 +353,7 @@ describe('launchQuestionRenderer', () => {
352
353
  assert.ok(splitCall.includes('OMX_QUESTION_RETURN_TRANSPORT=tmux-send-keys'));
353
354
  assert.ok(calls.some((call) => call.join(' ') === 'list-panes -t %42 -F #{pane_dead}\t#{pane_id}'));
354
355
  });
355
- it('opens a new tmux window when the current pane is too short for the question frame', () => {
356
+ it('opens a new tmux window when the current pane is too short for the question frame', async () => {
356
357
  const cwd = mkdtempSync(join(tmpdir(), 'omx-question-renderer-new-window-'));
357
358
  try {
358
359
  const stateDir = join(cwd, '.omx', 'state', 'sessions', 's1', 'questions');
@@ -390,7 +391,7 @@ describe('launchQuestionRenderer', () => {
390
391
  source: 'deep-interview',
391
392
  }, null, 2));
392
393
  const calls = [];
393
- const result = launchQuestionRenderer({
394
+ const result = await launchQuestionRenderer({
394
395
  cwd,
395
396
  recordPath,
396
397
  sessionId: 's1',
@@ -429,7 +430,7 @@ describe('launchQuestionRenderer', () => {
429
430
  rmSync(cwd, { recursive: true });
430
431
  }
431
432
  });
432
- it('opens a new tmux window when wrapped content would exceed the split budget in a narrow pane', () => {
433
+ it('opens a new tmux window when wrapped content would exceed the split budget in a narrow pane', async () => {
433
434
  const cwd = mkdtempSync(join(tmpdir(), 'omx-question-renderer-wrapped-window-'));
434
435
  try {
435
436
  const stateDir = join(cwd, '.omx', 'state', 'sessions', 's1', 'questions');
@@ -465,7 +466,7 @@ describe('launchQuestionRenderer', () => {
465
466
  }],
466
467
  }, null, 2));
467
468
  const calls = [];
468
- const result = launchQuestionRenderer({
469
+ const result = await launchQuestionRenderer({
469
470
  cwd,
470
471
  recordPath,
471
472
  sessionId: 's1',
@@ -505,7 +506,7 @@ describe('launchQuestionRenderer', () => {
505
506
  rmSync(cwd, { recursive: true });
506
507
  }
507
508
  });
508
- it('falls back to the default tmux width when the width probe fails', () => {
509
+ it('falls back to the default tmux width when the width probe fails', async () => {
509
510
  const cwd = mkdtempSync(join(tmpdir(), 'omx-question-renderer-width-fallback-'));
510
511
  try {
511
512
  const stateDir = join(cwd, '.omx', 'state', 'sessions', 's1', 'questions');
@@ -541,7 +542,7 @@ describe('launchQuestionRenderer', () => {
541
542
  }],
542
543
  }, null, 2));
543
544
  const calls = [];
544
- const result = launchQuestionRenderer({
545
+ const result = await launchQuestionRenderer({
545
546
  cwd,
546
547
  recordPath,
547
548
  sessionId: 's1',
@@ -585,9 +586,9 @@ describe('launchQuestionRenderer', () => {
585
586
  rmSync(cwd, { recursive: true });
586
587
  }
587
588
  });
588
- it('targets the explicit leader pane even when the caller is already inside tmux', () => {
589
+ it('targets the explicit leader pane even when the caller is already inside tmux', async () => {
589
590
  const calls = [];
590
- const result = launchQuestionRenderer({
591
+ const result = await launchQuestionRenderer({
591
592
  cwd: '/repo',
592
593
  recordPath: '/repo/.omx/state/sessions/s1/questions/question-leader.json',
593
594
  sessionId: 's1',
@@ -618,9 +619,9 @@ describe('launchQuestionRenderer', () => {
618
619
  assert.ok(splitCall);
619
620
  assert.deepEqual(splitCall.slice(0, 6), ['split-window', '-v', '-l', '24', '-t', '%44']);
620
621
  });
621
- it('fails closed before splitting when inside a detached tmux session', () => {
622
+ it('fails closed before splitting when inside a detached tmux session', async () => {
622
623
  const calls = [];
623
- assert.throws(() => launchQuestionRenderer({
624
+ await assert.rejects(() => launchQuestionRenderer({
624
625
  cwd: '/repo',
625
626
  recordPath: '/repo/.omx/state/sessions/s1/questions/question-detached.json',
626
627
  sessionId: 's1',
@@ -645,9 +646,9 @@ describe('launchQuestionRenderer', () => {
645
646
  });
646
647
  assert.deepEqual(calls, [['display-message', '-p', '-t', '%11', '#{session_attached}']]);
647
648
  });
648
- it('reports tmux permission failures without claiming the session is detached', () => {
649
+ it('reports tmux permission failures without claiming the session is detached', async () => {
649
650
  const probeError = Object.assign(new Error('connect /private/tmp/tmux-501/default: Operation not permitted'), { code: 'EPERM' });
650
- assert.throws(() => launchQuestionRenderer({
651
+ await assert.rejects(() => launchQuestionRenderer({
651
652
  cwd: '/repo',
652
653
  recordPath: '/repo/.omx/state/sessions/s1/questions/question-permission-denied.json',
653
654
  sessionId: 's1',
@@ -666,9 +667,9 @@ describe('launchQuestionRenderer', () => {
666
667
  return true;
667
668
  });
668
669
  });
669
- it('preserves unexpected tmux attachment probe failures', () => {
670
+ it('preserves unexpected tmux attachment probe failures', async () => {
670
671
  const probeError = new Error('tmux server returned malformed output');
671
- assert.throws(() => launchQuestionRenderer({
672
+ await assert.rejects(() => launchQuestionRenderer({
672
673
  cwd: '/repo',
673
674
  recordPath: '/repo/.omx/state/sessions/s1/questions/question-probe-failed.json',
674
675
  sessionId: 's1',
@@ -687,9 +688,9 @@ describe('launchQuestionRenderer', () => {
687
688
  return true;
688
689
  });
689
690
  });
690
- it('targets an explicit host pane when launching from a container without TMUX', () => {
691
+ it('targets an explicit host pane when launching from a container without TMUX', async () => {
691
692
  const calls = [];
692
- const result = launchQuestionRenderer({
693
+ const result = await launchQuestionRenderer({
693
694
  cwd: '/repo',
694
695
  recordPath: '/repo/.omx/state/sessions/s1/questions/question-bridge.json',
695
696
  sessionId: 's1',
@@ -723,10 +724,10 @@ describe('launchQuestionRenderer', () => {
723
724
  assert.ok(splitCall.includes('%77'));
724
725
  assert.ok(calls.some((call) => call.join(' ') === 'list-panes -t %78 -F #{pane_dead}\t#{pane_id}'));
725
726
  });
726
- it('opens a visible Windows psmux shell pane and injects the question UI command literally', () => {
727
+ it('opens a visible Windows psmux shell pane and injects the question UI command literally', async () => {
727
728
  const tmuxCalls = [];
728
729
  const spawnCalls = [];
729
- const result = launchQuestionRenderer({
730
+ const result = await launchQuestionRenderer({
730
731
  cwd: '/repo',
731
732
  recordPath: '/repo/.omx/state/sessions/s1/questions/question-bridge.json',
732
733
  sessionId: 's1',
@@ -774,10 +775,10 @@ describe('launchQuestionRenderer', () => {
774
775
  ['send-keys', '-t', '%55', 'C-m'],
775
776
  ]);
776
777
  });
777
- it('keeps the detached Windows console path for explicit non-psmux return bridges', () => {
778
+ it('keeps the detached Windows console path for explicit non-psmux return bridges', async () => {
778
779
  const tmuxCalls = [];
779
780
  const spawnCalls = [];
780
- const result = launchQuestionRenderer({
781
+ const result = await launchQuestionRenderer({
781
782
  cwd: 'C:/repo',
782
783
  recordPath: 'C:/repo/.omx/state/sessions/s1/questions/question-bridge.json',
783
784
  sessionId: 's1',
@@ -815,7 +816,7 @@ describe('launchQuestionRenderer', () => {
815
816
  assert.equal(env.OMX_QUESTION_RETURN_TARGET, '%44');
816
817
  assert.equal(env.OMX_QUESTION_RETURN_TRANSPORT, 'tmux-send-keys');
817
818
  });
818
- it('targets a persisted workflow pane when launching from a container without TMUX', () => {
819
+ it('targets a persisted workflow pane when launching from a container without TMUX', async () => {
819
820
  const cwd = mkdtempSync(join(tmpdir(), 'omx-question-renderer-persisted-'));
820
821
  try {
821
822
  const stateDir = join(cwd, '.omx', 'state', 'sessions', 'sess-stateful');
@@ -827,7 +828,7 @@ describe('launchQuestionRenderer', () => {
827
828
  tmux_pane_id: '%91',
828
829
  }, null, 2));
829
830
  const calls = [];
830
- const result = launchQuestionRenderer({
831
+ const result = await launchQuestionRenderer({
831
832
  cwd,
832
833
  recordPath: join(stateDir, 'questions', 'question-bridge.json'),
833
834
  sessionId: 'sess-stateful',
@@ -861,9 +862,9 @@ describe('launchQuestionRenderer', () => {
861
862
  rmSync(cwd, { recursive: true, force: true });
862
863
  }
863
864
  });
864
- it('fails before prompting state when a reported split pane is already gone', () => {
865
+ it('fails before prompting state when a reported split pane is already gone', async () => {
865
866
  const calls = [];
866
- assert.throws(() => launchQuestionRenderer({
867
+ await assert.rejects(() => launchQuestionRenderer({
867
868
  cwd: '/repo',
868
869
  recordPath: '/repo/.omx/state/sessions/s1/questions/question-1.json',
869
870
  sessionId: 's1',
@@ -896,9 +897,9 @@ describe('launchQuestionRenderer', () => {
896
897
  ]);
897
898
  assert.ok(calls.some((call) => call.join(' ') === 'list-panes -t %42 -F #{pane_dead}\t#{pane_id}'));
898
899
  });
899
- it('uses inline-tty on Windows without invoking tmux when no attached tmux pane is available', () => {
900
+ it('uses inline-tty on Windows without invoking tmux when no attached tmux pane is available', async () => {
900
901
  const calls = [];
901
- const result = launchQuestionRenderer({
902
+ const result = await launchQuestionRenderer({
902
903
  cwd: '/repo',
903
904
  recordPath: '/repo/.omx/state/sessions/s1/questions/question-inline.json',
904
905
  sessionId: 's1',
@@ -918,7 +919,7 @@ describe('launchQuestionRenderer', () => {
918
919
  assert.equal(result.target, 'inline-tty');
919
920
  assert.deepEqual(calls, []);
920
921
  });
921
- it('falls back to the persisted session mode pane when Bash/tool env lost TMUX_PANE', () => {
922
+ it('falls back to the persisted session mode pane when Bash/tool env lost TMUX_PANE', async () => {
922
923
  const cwd = mkdtempSync(join(tmpdir(), 'omx-question-renderer-state-'));
923
924
  try {
924
925
  const stateDir = join(cwd, '.omx', 'state', 'sessions', 'sess-stateful');
@@ -930,7 +931,7 @@ describe('launchQuestionRenderer', () => {
930
931
  tmux_pane_id: '%91',
931
932
  }, null, 2));
932
933
  const calls = [];
933
- const result = launchQuestionRenderer({
934
+ const result = await launchQuestionRenderer({
934
935
  cwd,
935
936
  recordPath: join(cwd, '.omx', 'state', 'sessions', 'sess-stateful', 'questions', 'question-3.json'),
936
937
  sessionId: 'sess-stateful',
@@ -962,7 +963,7 @@ describe('launchQuestionRenderer', () => {
962
963
  rmSync(cwd, { recursive: true, force: true });
963
964
  }
964
965
  });
965
- it('prefers session-scoped persisted panes over root workflow fallback panes', () => {
966
+ it('prefers session-scoped persisted panes over root workflow fallback panes', async () => {
966
967
  const cwd = mkdtempSync(join(tmpdir(), 'omx-question-renderer-precedence-'));
967
968
  try {
968
969
  const rootStateDir = join(cwd, '.omx', 'state');
@@ -980,7 +981,7 @@ describe('launchQuestionRenderer', () => {
980
981
  current_phase: 'planning',
981
982
  tmux_pane_id: '%91',
982
983
  }, null, 2));
983
- const result = launchQuestionRenderer({
984
+ const result = await launchQuestionRenderer({
984
985
  cwd,
985
986
  recordPath: join(sessionStateDir, 'questions', 'question-4.json'),
986
987
  sessionId: 'sess-stateful',
@@ -1008,9 +1009,9 @@ describe('launchQuestionRenderer', () => {
1008
1009
  rmSync(cwd, { recursive: true, force: true });
1009
1010
  }
1010
1011
  });
1011
- it('passes direct tmux argv so non-POSIX default shells do not parse a shell string', () => {
1012
+ it('passes direct tmux argv so non-POSIX default shells do not parse a shell string', async () => {
1012
1013
  const calls = [];
1013
- launchQuestionRenderer({
1014
+ await launchQuestionRenderer({
1014
1015
  cwd: '/repo',
1015
1016
  recordPath: '/repo/question with spaces.json',
1016
1017
  sessionId: 'sess-123',
@@ -1045,14 +1046,14 @@ describe('launchQuestionRenderer', () => {
1045
1046
  '/repo/question with spaces.json',
1046
1047
  ]);
1047
1048
  });
1048
- it('resolves the leader return target before opening the question pane', () => {
1049
+ it('resolves the leader return target before opening the question pane', async () => {
1049
1050
  const calls = [];
1050
1051
  const originalTmuxPane = process.env.TMUX_PANE;
1051
1052
  const originalTmux = process.env.TMUX;
1052
1053
  process.env.TMUX_PANE = '%200';
1053
1054
  process.env.TMUX = '/tmp/tmux-leader';
1054
1055
  try {
1055
- const result = launchQuestionRenderer({
1056
+ const result = await launchQuestionRenderer({
1056
1057
  cwd: '/repo',
1057
1058
  recordPath: '/repo/question-4.json',
1058
1059
  sessionId: 'sess-123',
@@ -1089,9 +1090,9 @@ describe('launchQuestionRenderer', () => {
1089
1090
  delete process.env.TMUX;
1090
1091
  }
1091
1092
  });
1092
- it('uses detached sessions outside tmux', () => {
1093
+ it('uses detached sessions outside tmux', async () => {
1093
1094
  const calls = [];
1094
- const result = launchQuestionRenderer({
1095
+ const result = await launchQuestionRenderer({
1095
1096
  cwd: '/repo',
1096
1097
  recordPath: '/repo/.omx/state/sessions/s1/questions/question-2.json',
1097
1098
  nowIso: '2026-04-19T00:00:00.000Z',
@@ -1120,9 +1121,9 @@ describe('launchQuestionRenderer', () => {
1120
1121
  ]);
1121
1122
  assert.deepEqual(calls[1], ['has-session', '-t', 'omx-question-question-2']);
1122
1123
  });
1123
- it('fails when a detached tmux session disappears immediately after launch', () => {
1124
+ it('fails when a detached tmux session disappears immediately after launch', async () => {
1124
1125
  const calls = [];
1125
- assert.throws(() => launchQuestionRenderer({
1126
+ await assert.rejects(() => launchQuestionRenderer({
1126
1127
  cwd: '/repo',
1127
1128
  recordPath: '/repo/.omx/state/sessions/s1/questions/question-2.json',
1128
1129
  nowIso: '2026-04-19T00:00:00.000Z',
@@ -1141,12 +1142,12 @@ describe('launchQuestionRenderer', () => {
1141
1142
  assert.equal(calls[0]?.[0], 'new-session');
1142
1143
  assert.deepEqual(calls[1], ['has-session', '-t', 'omx-question-question-2']);
1143
1144
  });
1144
- it('prefers the current launcher path over a stale ambient OMX_ENTRY_PATH when spawning the UI', () => {
1145
+ it('prefers the current launcher path over a stale ambient OMX_ENTRY_PATH when spawning the UI', async () => {
1145
1146
  const calls = [];
1146
1147
  const originalArgv1 = process.argv[1];
1147
1148
  process.argv[1] = '/repo/dist/cli/omx.js';
1148
1149
  try {
1149
- const result = launchQuestionRenderer({
1150
+ const result = await launchQuestionRenderer({
1150
1151
  cwd: '/repo',
1151
1152
  recordPath: '/repo/.omx/state/sessions/s1/questions/question-3.json',
1152
1153
  sessionId: 's1',
@@ -1337,7 +1338,7 @@ describe('question renderer in-flight dedupe', () => {
1337
1338
  rmSync(cwd, { recursive: true, force: true });
1338
1339
  }
1339
1340
  });
1340
- it('marks prior live prompting panes superseded and kills them before a new tmux split', () => {
1341
+ it('marks prior live prompting panes superseded and kills them before a new tmux split', async () => {
1341
1342
  const cwd = mkdtempSync(join(tmpdir(), 'omx-question-dedupe-launch-'));
1342
1343
  try {
1343
1344
  const dir = join(cwd, '.omx', 'state', 'sessions', 'sess-dedupe', 'questions');
@@ -1358,7 +1359,7 @@ describe('question renderer in-flight dedupe', () => {
1358
1359
  renderer: undefined,
1359
1360
  });
1360
1361
  const calls = [];
1361
- const result = launchQuestionRenderer({
1362
+ const result = await launchQuestionRenderer({
1362
1363
  cwd,
1363
1364
  recordPath: nextPath,
1364
1365
  sessionId: 'sess-dedupe',
@@ -1400,7 +1401,7 @@ describe('question renderer in-flight dedupe', () => {
1400
1401
  rmSync(cwd, { recursive: true, force: true });
1401
1402
  }
1402
1403
  });
1403
- it('does not supersede answered records when launching a replacement renderer', () => {
1404
+ it('does not supersede answered records when launching a replacement renderer', async () => {
1404
1405
  const cwd = mkdtempSync(join(tmpdir(), 'omx-question-dedupe-answered-'));
1405
1406
  try {
1406
1407
  const dir = join(cwd, '.omx', 'state', 'sessions', 'sess-dedupe', 'questions');
@@ -1415,7 +1416,7 @@ describe('question renderer in-flight dedupe', () => {
1415
1416
  launched_at: '2026-05-27T00:00:00.000Z',
1416
1417
  },
1417
1418
  });
1418
- const superseded = supersedeLiveQuestionsForSession(cwd, 'sess-dedupe', (args) => {
1419
+ const superseded = await supersedeLiveQuestionsForSession(cwd, 'sess-dedupe', (args) => {
1419
1420
  if (args[0] === 'list-panes')
1420
1421
  return '0\t%41\n';
1421
1422
  throw new Error(`unexpected tmux call: ${args.join(' ')}`);
@@ -1428,6 +1429,39 @@ describe('question renderer in-flight dedupe', () => {
1428
1429
  rmSync(cwd, { recursive: true, force: true });
1429
1430
  }
1430
1431
  });
1432
+ it('preserves an answer committed after reading the live renderer snapshot', async () => {
1433
+ const cwd = mkdtempSync(join(tmpdir(), 'omx-question-dedupe-answer-race-'));
1434
+ try {
1435
+ const dir = join(cwd, '.omx', 'state', 'sessions', 'sess-dedupe', 'questions');
1436
+ mkdirSync(dir, { recursive: true });
1437
+ const recordPath = join(dir, 'question-prior.json');
1438
+ writeQuestionRecord(recordPath, { question_id: 'question-prior' });
1439
+ const stateModule = new URL('../state.js', import.meta.url).href;
1440
+ let answered = false;
1441
+ let accepted = '';
1442
+ const superseded = await supersedeLiveQuestionsForSession(cwd, 'sess-dedupe', (args) => {
1443
+ if (args[0] === 'list-panes' && !answered) {
1444
+ answered = true;
1445
+ execFileSync(process.execPath, ['--input-type=module', '-e', `
1446
+ import { submitQuestionAnswerById } from ${JSON.stringify(stateModule)};
1447
+ await submitQuestionAnswerById(${JSON.stringify(cwd)}, 'question-prior', {
1448
+ answer: { kind: 'option', value: 'a', selected_labels: ['A'], selected_values: ['a'] },
1449
+ }, { sessionId: 'sess-dedupe', closeQuestionRenderer: () => true });
1450
+ `]);
1451
+ accepted = readFileSync(recordPath, 'utf8');
1452
+ }
1453
+ assert.notEqual(args[0], 'kill-pane', 'The superseding caller must not close an answered renderer');
1454
+ return '0\t%41\n';
1455
+ });
1456
+ assert.equal(answered, true);
1457
+ assert.equal(JSON.parse(accepted).status, 'answered');
1458
+ assert.deepEqual(superseded, []);
1459
+ assert.equal(readFileSync(recordPath, 'utf8'), accepted);
1460
+ }
1461
+ finally {
1462
+ rmSync(cwd, { recursive: true, force: true });
1463
+ }
1464
+ });
1431
1465
  });
1432
1466
  describe('buildQuestionUiTmuxArgs', () => {
1433
1467
  const recordPath = '/repo/.omx/state/sessions/s1/questions/question-1.json';
@@ -1507,9 +1541,9 @@ describe('buildQuestionUiTmuxArgs', () => {
1507
1541
  });
1508
1542
  });
1509
1543
  describe('launchQuestionRenderer under cmux', () => {
1510
- it('drops bare -e and exports env so the cmux split pane runs the real command', () => {
1544
+ it('drops bare -e and exports env so the cmux split pane runs the real command', async () => {
1511
1545
  const calls = [];
1512
- const result = launchQuestionRenderer({
1546
+ const result = await launchQuestionRenderer({
1513
1547
  cwd: '/repo',
1514
1548
  recordPath: '/repo/.omx/state/sessions/s1/questions/question-cmux.json',
1515
1549
  sessionId: 's1',