Hmbown/CodeWhale · error

No active turn

Error message

No active turn

What it means

steerTurn sends a steering prompt to an existing turn. It requires both state.threadId and state.activeTurnId; if either is unset (no thread open, or no turn has started/been recorded), the runtime throws instead of calling the steer endpoint.

Solutions

  1. Start a turn (submit a prompt) so state.activeTurnId is set, then steer.
  2. Verify the turn-start response includes turn.id and that state.activeTurnId is assigned from it.
  3. Reload/reconnect the session and re-enter the thread if state was lost.

Example fix

// before
await steerTurn();
// after
if (!state.activeTurnId) { await submitPrompt('continue'); }
await steerTurn();
Defensive patterns

Strategy: validation

Validate before calling

if (!state.threadId || !state.activeTurnId) {
  showHint('Start a turn before steering');
  return;
}

Type guard

function canSteer(s) {
  return typeof s.threadId === 'string' && s.threadId.length > 0 &&
         typeof s.activeTurnId === 'string' && s.activeTurnId.length > 0;
}

Try / catch

try {
  await steerTurn();
} catch (e) {
  if (String(e.message) === 'No active turn') startNewTurn();
  else throw e;
}

Prevention

When it happens

Trigger: Pressing the steer control before starting a turn in the current thread; page state reset (reload) losing activeTurnId; a turn response that lacked turn.id so activeTurnId was never set.

Common situations: User submits a steering message from a fresh page load without running a turn first; server response shape changed so turn.id was not captured; threads list loaded but no turn started in the active thread.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/f59e362a97ba0dd3. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/runtime_mobile.html:642

      if (!state.threadId) await newThread();
      const prompt = $("prompt").value.trim();
      if (!prompt) return;
      const res = await api("/v1/threads/" + encodeURIComponent(state.threadId) + "/turns", {
        method: "POST",
        body: JSON.stringify({
          prompt,
          allow_shell: $("allow-shell").checked,
          trust_mode: false,
          auto_approve: $("auto-approve").checked
        })
      });
      state.activeTurnId = res.turn?.id || state.activeTurnId;
      $("prompt").value = "";
      await loadThreads();
    }

    async function steerTurn() {
      if (!state.threadId || !state.activeTurnId) throw new Error("No active turn");
      const prompt = $("prompt").value.trim();
      if (!prompt) return;
      await api(
        "/v1/threads/" + encodeURIComponent(state.threadId) +
        "/turns/" + encodeURIComponent(state.activeTurnId) + "/steer",
        { method: "POST", body: JSON.stringify({ prompt }) }
      );
      $("prompt").value = "";
    }

    async function interruptTurn() {
      if (!state.threadId || !state.activeTurnId) throw new Error("No active turn");
      await api(
        "/v1/threads/" + encodeURIComponent(state.threadId) +
        "/turns/" + encodeURIComponent(state.activeTurnId) + "/interrupt",
        { method: "POST", body: "{}" }
      );
    }

View on GitHub (pinned to 73e0f67d83)