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

tmux target validation failed: ${resolved.reason}

Error message

tmux target validation failed: ${resolved.reason}

What it means

Thrown by the omx tmux-hook validate subcommand when the configured tmux target (session/window/pane) cannot be resolved against the running tmux server. It wraps the lower-level reason from resolveValidateTarget, e.g. tmux not installed, no such session, or malformed target spec. The check is skipped only when the init result used a placeholder target.

Source

Thrown at src/cli/tmux-hook.ts:433

    console.log(`Tracked Panes: ${panes}`);
    if (legacySessions > 0) {
      console.log(`Tracked Sessions (legacy): ${legacySessions}`);
    }
  }

  console.log(`Log (today): ${existsSync(logPath) ? logPath : 'none yet'}`);
}

async function validateTmuxHookConfig(): Promise<void> {
  const cwd = process.cwd();
  const { config, initResult } = await loadConfigForCommand('validate', cwd);
  if (initResult?.usedPlaceholderTarget) {
    return;
  }
  const resolved = resolveValidateTarget(config);

  if (!resolved.ok) {
    throw new Error(`tmux target validation failed: ${resolved.reason}`);
  }

  console.log('tmux-hook config is valid.');
  console.log(`Resolved target pane: ${resolved.target}`);
  console.log(`Mode gating: ${config.allowed_modes.join(', ')}`);
  if (!config.enabled) {
    console.log('Note: config is currently disabled (`enabled: false`).');
  }
}

async function testTmuxHook(args: string[]): Promise<void> {
  const cwd = process.cwd();
  const { initResult } = await loadConfigForCommand('test', cwd);
  if (initResult?.usedPlaceholderTarget) {
    console.log('Proceeding with placeholder target; notify-hook may log `invalid_config` skips.');
  }
  const pkgRoot = getPackageRoot();
  const notifyHook = join(pkgRoot, 'dist', 'scripts', 'notify-hook.js');

View on GitHub (pinned to 3ad79a8a6f)

Solutions

  1. Run `tmux list-sessions -F '#{session_name}:#{window_index}.#{pane_index}'` and paste an exact existing target into the config/flag
  2. Start or attach the tmux session you configured, then re-run validate
  3. Fix target syntax: `session:window.pane` (pane optional depending on config)
  4. If tmux is not installed, install it or run init with a placeholder target so validation is skipped

Example fix

# before
omx tmux-hook validate --target mysession:1.0
# tmux target validation failed: no such session

# after
tmux list-sessions -F '#{session_name}:#{window_index}.#{pane_index}'
omx tmux-hook validate --target actual-session:0.0
Defensive patterns

Strategy: validation

Validate before calling

import { execSync } from 'node:child_process';
function tmuxTargetExists(target: string): boolean {
  try { execSync(`tmux display-message -p -t '${target}' '#{session_name}'`, { stdio: 'pipe', shell: '/bin/sh' }); return true; }
  catch { return false; }
}
// before omx tmux-hook validate:
if (!tmuxTargetExists(cfgTarget)) console.error(`target ${cfgTarget} not resolvable; start tmux first`);

Prevention

When it happens

Trigger: Running `omx tmux-hook validate` (or the command dispatcher hitting validateTmuxHookConfig) with a --target like `session:window.pane` that does not exist, tmux not running, or tmux binary not on PATH; also when init did not use a placeholder target but config.target is stale (session renamed/closed).

Common situations: Renaming or killing the tmux session after `omx tmux-hook init`; running on a machine without tmux installed; copy-pasting a target spec with wrong syntax (missing colon or pane suffix); stale .omx config pointing at a dead pane.

Related errors


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