opencode-mission-control icon indicating copy to clipboard operation
opencode-mission-control copied to clipboard

fix: Replace hardcoded sleep(2000) OMO detection with readiness polling

Open nigel-dev opened this issue 9 months ago • 1 comments

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

  1. Configure omo.defaultMode: "ulw".
  2. Launch a job: mc_launch(name: "test", prompt: "...").
  3. 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 sleep
  • src/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."

nigel-dev avatar Feb 12 '26 03:02 nigel-dev

Closing as obsolete with Mission Control 2.0 (#94): OMO detection, including the hardcoded sleep(2000), is removed.

nigel-dev avatar Nov 20 '26 19:11 nigel-dev