Yeachan-Heo/oh-my-codex · error · Error

sendToWorker: text must be non-empty

Error message

sendToWorker: text must be non-empty

What it means

Guard inside assertWorkerTriggerText: the trigger text, after trimming, must contain at least one non-whitespace character. Sending only whitespace would press keys that produce no actionable input, leaving the worker pane in an ambiguous state, so it is rejected before any tmux call is made.

Source

Thrown at src/team/tmux-session.ts:3741

  runTmux(['send-keys', '-t', secondTarget, 'Enter']);
  return true;
}

export const normalizeTmuxCapture = sharedNormalizeTmuxCapture;

function normalizeWorkerTriggerForDraftMatch(value: string | null | undefined): string {
  // Codex/tmux can wrap long path-like trigger text after a hyphen, e.g.
  // `worker-\n  1/inbox.md`. Treat those visual wraps as the original token so
  // delivery verification does not mistake an unsent draft for consumed input.
  return normalizeTmuxCapture(value ?? '').replace(/-\s+/g, '-');
}

function assertWorkerTriggerText(text: string): void {
  if (text.length >= 200) {
    throw new Error('sendToWorker: text must be < 200 characters');
  }
  if (text.trim().length === 0) {
    throw new Error('sendToWorker: text must be non-empty');
  }
  if (text.includes(INJECTION_MARKER)) {
    throw new Error('sendToWorker: injection marker is not allowed');
  }
}

export function sendToWorkerStdin(
  stdin: Pick<NodeJS.WritableStream, 'write' | 'writable'> | null | undefined,
  text: string,
): void {
  assertWorkerTriggerText(text);
  if (!stdin || !stdin.writable) {
    throw new Error('sendToWorkerStdin: stdin is not writable');
  }
  stdin.write(`${text}\n`);
}

// Send SHORT text (<200 chars) to worker via tmux send-keys

View on GitHub (pinned to 3ad79a8a6f)

Solutions

  1. Default the trigger text: `const trigger = rawTrigger?.trim() || 'proceed'`
  2. Validate user-supplied trigger config at startup, not at send time
  3. Log the offending value before the call when debugging

Example fix

// before
sendToWorkerStdin(worker.stdin, process.env.WORKER_TRIGGER ?? '');

// after
const trigger = (process.env.WORKER_TRIGGER ?? '').trim();
if (!trigger) throw new Error('WORKER_TRIGGER must be set to non-empty text');
sendToWorkerStdin(worker.stdin, trigger);
Defensive patterns

Strategy: validation

Validate before calling

if (!trigger || trigger.trim().length === 0) throw new Error('trigger text required');

Type guard

function isNonEmptyTrigger(text: string): boolean { return typeof text === 'string' && text.trim().length > 0; }

Prevention

When it happens

Trigger: Calling sendToWorker / sendToWorkerStdin with '', ' ', '\n\t', or any string that is whitespace-only — often from an unvalidated config value, an empty template interpolation, or a variable that was never set.

Common situations: Environment/config variable for the trigger is unset so it interpolates to ''; template produces empty string; loop iteration yields undefined coerced to ' '.

Related errors


AI-assisted analysis of Yeachan-Heo/oh-my-codex@3ad79a8a6f (2026-08-27). Data as JSON: /api/errors/19a6bbe416e81444. Report an issue: GitHub.