{"record":{"id":"6db8dee87bcd75a9","repo":"slopus/happy","slug":"claude-goal-action-is-not-ready-remote-mode-is-no","errorCode":null,"errorMessage":"Claude goal action is not ready: remote mode is not active","messagePattern":"Claude goal action is not ready: remote mode is not active","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/happy-cli/src/claude/runClaude.ts","lineNumber":595,"sourceCode":"        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        }\n\n        const slashCommand = command.type === 'clear'\n            ? '/goal clear'\n            : `/goal ${command.objective}`;\n        const mode = currentEnhancedMode();\n\n        return await new Promise<{ ok: true }>((resolve, reject) => {\n            const timeout = setTimeout(() => {\n                pendingClaudeGoalAction = null;\n                reject(new Error('Timed out waiting for Claude goal confirmation'));\n            }, 30000);","sourceCodeStart":577,"sourceCodeEnd":613,"githubUrl":"https://github.com/slopus/happy/blob/b824cd0a4681d41af631a8e422a813873e4455b0/packages/happy-cli/src/claude/runClaude.ts#L577-L613","documentation":"Goal actions are only applied while the CLI runs Claude in remote mode (currentRunMode === 'remote'), where results can be observed and synced. If the action arrives while in another run mode (e.g. local/interactive or transitioning), the handler rejects it as not ready.","triggerScenarios":"A 'goal-action' RPC arrives while currentRunMode is not 'remote' — e.g. during mode handoff, in local/interactive mode, or before the mode state machine has settled into remote.","commonSituations":"Sending a goal action right as the user switches between local and remote mode; mobile app acting on a session still initializing; RPC racing the mode transition after reconnection.","solutions":["Retry the goal action once the session is fully in remote mode.","Wait for session initialization/mode transition to complete before acting.","Avoid toggling local/remote modes while issuing goal actions.","Update the app to disable goal actions until the session reports remote mode."],"exampleFix":"// before\nawait rpc('goal-action', { action: 'set', goal: 'x' }); // during mode switch\n// after\nif (session.runMode === 'remote') await rpc('goal-action', { action: 'set', goal: 'x' });","handlingStrategy":"retry","validationCode":"if (session.runMode !== 'remote') {\n  console.warn('Goal actions require remote mode — retry after the session finishes switching');\n  return;\n}","typeGuard":"function isRemoteMode(m: string | null | undefined): m is 'remote' {\n  return m === 'remote';\n}","tryCatchPattern":"async function goalActionWhenRemote(p: unknown, tries = 5) {\n  for (let i = 0; i < tries; i++) {\n    try { return await rpc('goal-action', p); }\n    catch (err) {\n      if (!(err as Error).message.includes('remote mode is not active') || i === tries - 1) throw err;\n      await sleep(2000);\n    }\n  }\n}","preventionTips":["Delay goal actions until the session reports remote mode.","Avoid mode toggling while remote actions are pending.","Have the app subscribe to run-mode changes and enable/disable actions accordingly.","Retry transient mode-transition rejections with backoff."],"tags":["rpc","mode","state"],"backgroundTag":"invalid-state-transition","analyzedSha":"b824cd0a4681d41af631a8e422a813873e4455b0","analyzedAt":"2026-08-31T23:12:36.205Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}