{"record":{"id":"73d6957fe24cc7a5","repo":"slopus/happy","slug":"no-active-claude-goal","errorCode":null,"errorMessage":"No active Claude goal","messagePattern":"No active Claude goal","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/happy-cli/src/claude/runClaude.ts","lineNumber":584,"sourceCode":"        appendSystemPrompt: currentAppendSystemPrompt,\n        allowedTools: currentAllowedTools,\n        disallowedTools: currentDisallowedTools,\n        effort: currentEffort,\n    });\n\n    session.rpcHandlerManager.registerHandler('goal-action', async (params: unknown) => {\n        const actionParams = params && typeof params === 'object' && !Array.isArray(params)\n            ? params as Record<string, unknown>\n            : null;\n        const command = actionParams ? parseClaudeGoalActionParams(actionParams) : null;\n        if (!command) {\n            throw new Error('Unsupported Claude goal action');\n        }\n        if (pendingClaudeGoalAction) {\n            throw new Error('Claude goal action already in progress');\n        }\n        if (!latestClaudeGoalStatus || latestClaudeGoalStatus.status !== 'active') {\n            throw new Error('No active Claude goal');\n        }\n\n        const capabilities = latestClaudeGoalStatus.capabilities ?? {};\n        if (command.type === 'clear' && !capabilities.clear) {\n            throw new Error('Claude clear goal action is not supported');\n        }\n        if (command.type === 'set' && !capabilities.edit) {\n            throw new Error('Claude edit goal action is not supported');\n        }\n        if (currentRunMode !== 'remote') {\n            throw new Error('Claude goal action is not ready: remote mode is not active');\n        }\n        if (!currentSession || currentSession.thinking) {\n            throw new Error('Claude goal action is not ready while Claude is thinking');\n        }\n        if (messageQueue.size() > 0) {\n            throw new Error('Claude message queue is busy');\n        }","sourceCodeStart":566,"sourceCodeEnd":602,"githubUrl":"https://github.com/slopus/happy/blob/b824cd0a4681d41af631a8e422a813873e4455b0/packages/happy-cli/src/claude/runClaude.ts#L566-L602","documentation":"Goal actions require an active goal state tracked in latestClaudeGoalStatus. If no status has been received yet, or its status is not 'active', the handler rejects set/clear actions with this error because there is no goal machinery in a state that can accept commands.","triggerScenarios":"A 'goal-action' RPC arrives before the CLI has received any goal status from Claude, or after the goal transitioned out of 'active' (e.g. already cleared or finished).","commonSituations":"Sending a clear action when no goal was ever set; acting on a stale UI after the goal completed; session restart wiping goal state while the mobile UI still shows an active goal.","solutions":["Refresh the goal state in the mobile app before acting.","Set a goal first (status must be 'active') before attempting further actions.","Re-sync the session / reopen it so latestClaudeGoalStatus is repopulated.","Update app+CLI so stale UI is invalidated when the goal status changes."],"exampleFix":"// before\nawait rpc('goal-action', { action: 'clear' }); // no active goal\n// after\nif (goalStatus?.status === 'active') await rpc('goal-action', { action: 'clear' });","handlingStrategy":"validation","validationCode":"if (goalStatus?.status !== 'active') {\n  console.warn('No active goal — skipping action');\n  return;\n}","typeGuard":"function hasActiveGoal(s: { status: string } | null | undefined): s is { status: 'active' } & Record<string, unknown> {\n  return s !== null && s !== undefined && s.status === 'active';\n}","tryCatchPattern":"try {\n  await rpc('goal-action', { action: 'clear' });\n} catch (err) {\n  if ((err as Error).message === 'No active Claude goal') {\n    logger.warn('Goal action ignored: no active goal — refresh goal state first');\n  } else throw err;\n}","preventionTips":["Refresh the session's goal status before displaying action buttons.","Only offer set/clear actions when status === 'active'.","Resync goal state after session restarts.","Treat stale mobile UI as a signal to re-fetch session metadata."],"tags":["rpc","state","validation"],"backgroundTag":"invalid-state-transition","analyzedSha":"b824cd0a4681d41af631a8e422a813873e4455b0","analyzedAt":"2026-08-31T23:12:36.205Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}