{"record":{"id":"f59e362a97ba0dd3","repo":"Hmbown/CodeWhale","slug":"no-active-turn","errorCode":null,"errorMessage":"No active turn","messagePattern":"No active turn","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/runtime_mobile.html","lineNumber":642,"sourceCode":"      if (!state.threadId) await newThread();\n      const prompt = $(\"prompt\").value.trim();\n      if (!prompt) return;\n      const res = await api(\"/v1/threads/\" + encodeURIComponent(state.threadId) + \"/turns\", {\n        method: \"POST\",\n        body: JSON.stringify({\n          prompt,\n          allow_shell: $(\"allow-shell\").checked,\n          trust_mode: false,\n          auto_approve: $(\"auto-approve\").checked\n        })\n      });\n      state.activeTurnId = res.turn?.id || state.activeTurnId;\n      $(\"prompt\").value = \"\";\n      await loadThreads();\n    }\n\n    async function steerTurn() {\n      if (!state.threadId || !state.activeTurnId) throw new Error(\"No active turn\");\n      const prompt = $(\"prompt\").value.trim();\n      if (!prompt) return;\n      await api(\n        \"/v1/threads/\" + encodeURIComponent(state.threadId) +\n        \"/turns/\" + encodeURIComponent(state.activeTurnId) + \"/steer\",\n        { method: \"POST\", body: JSON.stringify({ prompt }) }\n      );\n      $(\"prompt\").value = \"\";\n    }\n\n    async function interruptTurn() {\n      if (!state.threadId || !state.activeTurnId) throw new Error(\"No active turn\");\n      await api(\n        \"/v1/threads/\" + encodeURIComponent(state.threadId) +\n        \"/turns/\" + encodeURIComponent(state.activeTurnId) + \"/interrupt\",\n        { method: \"POST\", body: \"{}\" }\n      );\n    }","sourceCodeStart":624,"sourceCodeEnd":660,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/runtime_mobile.html#L624-L660","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Start a turn (submit a prompt) so state.activeTurnId is set, then steer.","Verify the turn-start response includes turn.id and that state.activeTurnId is assigned from it.","Reload/reconnect the session and re-enter the thread if state was lost."],"exampleFix":"// before\nawait steerTurn();\n// after\nif (!state.activeTurnId) { await submitPrompt('continue'); }\nawait steerTurn();","handlingStrategy":"validation","validationCode":"if (!state.threadId || !state.activeTurnId) {\n  showHint('Start a turn before steering');\n  return;\n}","typeGuard":"function canSteer(s) {\n  return typeof s.threadId === 'string' && s.threadId.length > 0 &&\n         typeof s.activeTurnId === 'string' && s.activeTurnId.length > 0;\n}","tryCatchPattern":"try {\n  await steerTurn();\n} catch (e) {\n  if (String(e.message) === 'No active turn') startNewTurn();\n  else throw e;\n}","preventionTips":["Disable steer/interrupt controls until a turn is active.","Set activeTurnId from every turn-start response and assert turn.id exists.","Reset activeTurnId on thread switches to keep state truthful."],"tags":["state","turn","mobile"],"backgroundTag":"invalid-state-transition","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}