fix: Replace hardcoded sleep(2000) OMO detection with readiness polling
Description
When launching a job in an OMO mode (plan, ralph, ulw), Mission Control waits a hardcoded 2 seconds before sending slash commands to the tmux pane. On slow machines, the agent may not be ready; on fast machines, it wastes time.
Steps to Reproduce
- Configure
omo.defaultMode: "ulw". - Launch a job:
mc_launch(name: "test", prompt: "..."). - On a loaded machine, the slash command may arrive before the agent is ready, causing it to be lost.
Expected Behavior
MC should poll for pane readiness (e.g., check for the OpenCode prompt pattern) before sending commands, with a configurable timeout.
Actual Behavior
// src/tools/launch.ts:268
await sleep(2000);
switch (mode) {
case 'plan':
await sendKeys(tmuxTarget, '/start-work');
Proposed Fix
Replace the fixed sleep with a polling loop that checks the tmux pane content for a readiness indicator (e.g., the ctrl+p commands prompt that indicates OpenCode is ready for input):
async function waitForPaneReady(target: string, timeoutMs = 10000): Promise<boolean> {
const start = Date.now();
while (Date.now() - start < timeoutMs) {
const content = await capturePane(target, 5);
if (content.includes('ctrl+p') || content.includes('commands')) {
return true;
}
await sleep(500);
}
return false;
}
Files Involved
src/tools/launch.ts:268— the hardcoded sleepsrc/lib/tmux.ts—capturePane()for content checking
Additional Context
From audit report Section 7: "Fixed sleep(2000) for OMO mode detection — still present at launch.ts:268."
Closing as obsolete with Mission Control 2.0 (#94): OMO detection, including the hardcoded sleep(2000), is removed.