oh-my-codex 0.22.4 → 0.22.6
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/Cargo.lock +6 -6
- package/Cargo.toml +1 -1
- package/crates/omx-api/src/lib.rs +7 -2
- package/crates/omx-api/tests/cli.rs +58 -0
- package/dist/cli/__tests__/cleanup.test.js +58 -73
- package/dist/cli/__tests__/cleanup.test.js.map +1 -1
- package/dist/cli/__tests__/launch-fallback.test.js +41 -0
- package/dist/cli/__tests__/launch-fallback.test.js.map +1 -1
- package/dist/cli/__tests__/question.test.js +193 -2
- package/dist/cli/__tests__/question.test.js.map +1 -1
- package/dist/cli/cleanup.d.ts +0 -16
- package/dist/cli/cleanup.d.ts.map +1 -1
- package/dist/cli/cleanup.js +2 -71
- package/dist/cli/cleanup.js.map +1 -1
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +8 -4
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/question.d.ts.map +1 -1
- package/dist/cli/question.js +38 -20
- package/dist/cli/question.js.map +1 -1
- package/dist/mcp/__tests__/memory-server-concurrency.test.d.ts +2 -0
- package/dist/mcp/__tests__/memory-server-concurrency.test.d.ts.map +1 -0
- package/dist/mcp/__tests__/memory-server-concurrency.test.js +128 -0
- package/dist/mcp/__tests__/memory-server-concurrency.test.js.map +1 -0
- package/dist/mcp/memory-server.d.ts.map +1 -1
- package/dist/mcp/memory-server.js +40 -49
- package/dist/mcp/memory-server.js.map +1 -1
- package/dist/notifications/__tests__/reply-routing-realtmux.test.d.ts +2 -0
- package/dist/notifications/__tests__/reply-routing-realtmux.test.d.ts.map +1 -0
- package/dist/notifications/__tests__/reply-routing-realtmux.test.js +133 -0
- package/dist/notifications/__tests__/reply-routing-realtmux.test.js.map +1 -0
- package/dist/notifications/index.d.ts.map +1 -1
- package/dist/notifications/index.js +5 -1
- package/dist/notifications/index.js.map +1 -1
- package/dist/notifications/reply-listener.d.ts +2 -1
- package/dist/notifications/reply-listener.d.ts.map +1 -1
- package/dist/notifications/reply-listener.js +13 -5
- package/dist/notifications/reply-listener.js.map +1 -1
- package/dist/notifications/session-registry.d.ts +2 -0
- package/dist/notifications/session-registry.d.ts.map +1 -1
- package/dist/notifications/session-registry.js.map +1 -1
- package/dist/notifications/tmux-detector.d.ts +12 -0
- package/dist/notifications/tmux-detector.d.ts.map +1 -1
- package/dist/notifications/tmux-detector.js +46 -2
- package/dist/notifications/tmux-detector.js.map +1 -1
- package/dist/question/__tests__/renderer.test.js +84 -50
- package/dist/question/__tests__/renderer.test.js.map +1 -1
- package/dist/question/__tests__/state.test.js +192 -2
- package/dist/question/__tests__/state.test.js.map +1 -1
- package/dist/question/__tests__/ui.test.js +82 -1
- package/dist/question/__tests__/ui.test.js.map +1 -1
- package/dist/question/renderer.d.ts +2 -2
- package/dist/question/renderer.d.ts.map +1 -1
- package/dist/question/renderer.js +14 -22
- package/dist/question/renderer.js.map +1 -1
- package/dist/question/state.d.ts +4 -0
- package/dist/question/state.d.ts.map +1 -1
- package/dist/question/state.js +76 -23
- package/dist/question/state.js.map +1 -1
- package/dist/question/ui.d.ts.map +1 -1
- package/dist/question/ui.js +8 -2
- package/dist/question/ui.js.map +1 -1
- package/dist/scripts/__tests__/worker-stop-task-read.test.d.ts +2 -0
- package/dist/scripts/__tests__/worker-stop-task-read.test.d.ts.map +1 -0
- package/dist/scripts/__tests__/worker-stop-task-read.test.js +76 -0
- package/dist/scripts/__tests__/worker-stop-task-read.test.js.map +1 -0
- package/dist/scripts/codex-native-hook.d.ts.map +1 -1
- package/dist/scripts/codex-native-hook.js +28 -14
- package/dist/scripts/codex-native-hook.js.map +1 -1
- package/dist/scripts/notify-hook/team-dispatch.d.ts.map +1 -1
- package/dist/scripts/notify-hook/team-dispatch.js +137 -128
- package/dist/scripts/notify-hook/team-dispatch.js.map +1 -1
- package/dist/subagents/tracker.d.ts.map +1 -1
- package/dist/subagents/tracker.js +12 -2
- package/dist/subagents/tracker.js.map +1 -1
- package/dist/team/__tests__/lock-recovery.test.d.ts +2 -0
- package/dist/team/__tests__/lock-recovery.test.d.ts.map +1 -0
- package/dist/team/__tests__/lock-recovery.test.js +304 -0
- package/dist/team/__tests__/lock-recovery.test.js.map +1 -0
- package/dist/team/__tests__/state.test.js +8 -6
- package/dist/team/__tests__/state.test.js.map +1 -1
- package/dist/team/state/dispatch-lock.d.ts.map +1 -1
- package/dist/team/state/dispatch-lock.js +3 -11
- package/dist/team/state/dispatch-lock.js.map +1 -1
- package/dist/team/state/locks.d.ts +1 -0
- package/dist/team/state/locks.d.ts.map +1 -1
- package/dist/team/state/locks.js +29 -13
- package/dist/team/state/locks.js.map +1 -1
- package/dist/vscode/__tests__/index.test.js +21 -0
- package/dist/vscode/__tests__/index.test.js.map +1 -1
- package/dist/vscode/index.d.ts.map +1 -1
- package/dist/vscode/index.js +8 -4
- package/dist/vscode/index.js.map +1 -1
- package/package.json +1 -1
- package/plugins/oh-my-codex/.codex-plugin/plugin.json +1 -1
- package/src/scripts/__tests__/worker-stop-task-read.test.ts +77 -0
- package/src/scripts/codex-native-hook.ts +25 -11
- package/src/scripts/notify-hook/team-dispatch.ts +133 -125
|
@@ -8,6 +8,32 @@ import { execFileSync, spawnSync } from 'child_process';
|
|
|
8
8
|
import { sleepSync } from '../utils/sleep.js';
|
|
9
9
|
import { resolveCommandPathForPlatform, resolveTmuxBinaryForPlatform } from '../utils/platform-command.js';
|
|
10
10
|
import { buildCapturePaneArgv as sharedBuildCapturePaneArgv } from '../scripts/tmux-hook-engine.js';
|
|
11
|
+
import { readExactPaneProofSync } from '../team/exact-pane.js';
|
|
12
|
+
import { shellEscapeSingle } from '../hud/tmux.js';
|
|
13
|
+
export function readReplyPaneIdentity(paneId, sessionId) {
|
|
14
|
+
const proof = readExactPaneProofSync(paneId);
|
|
15
|
+
if (proof.status !== 'live')
|
|
16
|
+
return null;
|
|
17
|
+
try {
|
|
18
|
+
const snapshot = execFileSync(resolveTmuxBinaryForPlatform() || 'tmux', [
|
|
19
|
+
'display-message', '-p', '-t', paneId,
|
|
20
|
+
'#{pane_id}\t#{pane_pid}\t#{session_id}\t#{session_created}\t#{session_name}\t#{@omx_instance_id}\t#{@omx_team_pane_owner_id}\t#{@omx_pane_instance_id}\tEND',
|
|
21
|
+
], { encoding: 'utf-8', timeout: 3000, stdio: ['ignore', 'pipe', 'pipe'] }).trim();
|
|
22
|
+
const fields = snapshot.split('\t');
|
|
23
|
+
if (fields.length !== 9 || fields[8] !== 'END' || fields[0] !== paneId
|
|
24
|
+
|| Number(fields[1]) !== proof.pid || !/^\$\d+$/.test(fields[2]) || !/^\d+$/.test(fields[3])
|
|
25
|
+
|| !fields[4] || !/^[A-Za-z0-9_.:/-]*$/.test(fields[5]) || !/^[A-Za-z0-9_.:/-]*$/.test(fields[6])
|
|
26
|
+
|| !/^[A-Za-z0-9_.:/-]*$/.test(fields[7]))
|
|
27
|
+
return null;
|
|
28
|
+
// Match managed-tmux's pane-first ownership rule; a live pane alone cannot authorize an old session's reply.
|
|
29
|
+
if (!sessionId || (fields[7] || fields[5]) !== sessionId)
|
|
30
|
+
return null;
|
|
31
|
+
return { panePid: proof.pid, sessionId: fields[2], sessionCreated: fields[3], sessionName: fields[4], sessionOwner: fields[5], paneOwner: fields[6], paneInstanceId: fields[7] };
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
11
37
|
export function isTmuxAvailable() {
|
|
12
38
|
return resolveCommandPathForPlatform('tmux') !== null;
|
|
13
39
|
}
|
|
@@ -107,14 +133,32 @@ export function sendToPane(paneId, text, pressEnter = true, deps = {}) {
|
|
|
107
133
|
const sleepImpl = deps.sleepImpl ?? sleepSync;
|
|
108
134
|
const argvs = buildSendPaneArgvs(paneId, text, pressEnter);
|
|
109
135
|
const tmuxCommand = resolveTmuxBinaryForPlatform() || 'tmux';
|
|
136
|
+
const expected = deps.expectedIdentity;
|
|
137
|
+
if (expected && (!/^%\d+$/.test(paneId) || !Number.isSafeInteger(expected.panePid) || expected.panePid <= 0
|
|
138
|
+
|| !/^\$\d+$/.test(expected.sessionId) || !/^\d+$/.test(expected.sessionCreated)
|
|
139
|
+
|| !/^[A-Za-z0-9_.:/-]*$/.test(expected.sessionOwner) || !/^[A-Za-z0-9_.:/-]*$/.test(expected.paneOwner)
|
|
140
|
+
|| !/^[A-Za-z0-9_.:/-]*$/.test(expected.paneInstanceId)))
|
|
141
|
+
return false;
|
|
142
|
+
const predicate = expected ? [
|
|
143
|
+
`#{==:#{pane_id},${paneId}}`, '#{==:#{pane_dead},0}',
|
|
144
|
+
`#{==:#{pane_pid},${expected.panePid}}`, `#{==:#{session_id},${expected.sessionId}}`,
|
|
145
|
+
`#{==:#{session_created},${expected.sessionCreated}}`,
|
|
146
|
+
...(expected.paneInstanceId ? [] : [`#{==:#{@omx_instance_id},${expected.sessionOwner}}`]),
|
|
147
|
+
`#{==:#{@omx_team_pane_owner_id},${expected.paneOwner}}`,
|
|
148
|
+
`#{==:#{@omx_pane_instance_id},${expected.paneInstanceId}}`,
|
|
149
|
+
].reduce((left, right) => `#{&&:${left},${right}}`) : '';
|
|
110
150
|
for (const [index, argv] of argvs.entries()) {
|
|
111
|
-
const
|
|
151
|
+
const guardedArgv = expected ? [
|
|
152
|
+
'if-shell', '-F', '-t', paneId, predicate,
|
|
153
|
+
`${argv.map(shellEscapeSingle).join(' ')} ; display-message -p __omx_reply_sent__`, '',
|
|
154
|
+
] : argv;
|
|
155
|
+
const result = spawnSyncImpl(tmuxCommand, guardedArgv, {
|
|
112
156
|
timeout: 3000,
|
|
113
157
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
114
158
|
encoding: 'utf-8',
|
|
115
159
|
windowsHide: process.platform === 'win32',
|
|
116
160
|
});
|
|
117
|
-
if (result.error || result.status !== 0)
|
|
161
|
+
if (result.error || result.status !== 0 || (expected && String(result.stdout).trim() !== '__omx_reply_sent__'))
|
|
118
162
|
return false;
|
|
119
163
|
const hasNextArgv = index < argvs.length - 1;
|
|
120
164
|
if (!hasNextArgv)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tmux-detector.js","sourceRoot":"","sources":["../../src/notifications/tmux-detector.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,6BAA6B,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAC3G,OAAO,EAAE,oBAAoB,IAAI,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"tmux-detector.js","sourceRoot":"","sources":["../../src/notifications/tmux-detector.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,6BAA6B,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAC3G,OAAO,EAAE,oBAAoB,IAAI,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AACpG,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAYnD,MAAM,UAAU,qBAAqB,CAAC,MAAc,EAAE,SAAiB;IACrE,MAAM,KAAK,GAAG,sBAAsB,CAAC,MAAM,CAAC,CAAC;IAC7C,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IACzC,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,YAAY,CAAC,4BAA4B,EAAE,IAAI,MAAM,EAAE;YACtE,iBAAiB,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM;YACrC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AAC,IAAI,CAAC;QACT,MAAM,MAAM,GAAG,aAAa,CAAC,WAAW,EAAE,WAAW,EAAE;YACrD,OAAO,EAAE,IAAI;YACb,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;YAC/B,QAAQ,EAAE,OAAO;YACjB,WAAW,EAAE,OAAO,CAAC,QAAQ,KAAK,OAAO;SAC1C,CAAC,CAAC;QACH,IAAI,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,KAAK,oBAAoB,CAAC;YAAE,OAAO,KAAK,CAAC;QAE7H,MAAM,WAAW,GAAG,KAAK,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;QAC7C,IAAI,CAAC,WAAW;YAAE,SAAS;QAE3B,SAAS,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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',
|