{"record":{"id":"d070acd26dbe8119","repo":"jackwener/OpenCLI","slug":"failed-to-send-chatgpt-message","errorCode":null,"errorMessage":"Failed to send ChatGPT message: ","messagePattern":"Failed to send ChatGPT message: ","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/chatgpt-app/send.js","lineNumber":34,"sourceCode":"    columns: ['Status'],\n    func: async (kwargs) => {\n        if (process.platform !== 'darwin') {\n            throw new ConfigError('ChatGPT Desktop integration requires macOS (osascript is not available on this platform)');\n        }\n        const text = kwargs.text;\n        const model = kwargs.model;\n        try {\n            // Switch model before sending if requested\n            if (model) {\n                activateChatGPT();\n                selectModel(model);\n            }\n            activateChatGPT();\n            sendPrompt(text);\n            return [{ Status: 'Success' }];\n        }\n        catch (err) {\n            throw new CommandExecutionError(\"Failed to send ChatGPT message: \" + getErrorMessage(err));\n        }\n    },\n});\n","sourceCodeStart":16,"sourceCodeEnd":38,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/chatgpt-app/send.js#L16-L38","documentation":"Wrapper error for `chatgpt-app send`: any exception during model selection, app activation, or sendPrompt() is rethrown as CommandExecutionError 'Failed to send ChatGPT message: ' + underlying message. It is the single failure surface for the whole send pipeline on macOS.","triggerScenarios":"`chatgpt-app send` where selectModel/activateChatGPT/sendPrompt throws: invalid --model choice, osascript exec failure, Automation permission denied, app not running, or keystroke paste failing.","commonSituations":"Typo in --model value; ChatGPT app quit; accessibility keystroke simulation blocked; sending while the screen is locked.","solutions":["Check the text after the prefix for the root cause","Verify --model is one of MODEL_CHOICES (auto, instant, thinking, 5.2-instant, 5.2-thinking) or omit it","Ensure ChatGPT Desktop is running and unlocked, permissions are granted, then retry"],"exampleFix":"// before\nexecSync('opencli chatgpt-app send \"hi\" --model gpt4');\n// after\nexecSync('opencli chatgpt-app send \"hi\" --model instant'); // valid choice from MODEL_CHOICES","handlingStrategy":"try-catch","validationCode":"const MODEL_CHOICES = ['auto','instant','thinking','5.2-instant','5.2-thinking'];\nif (model && !MODEL_CHOICES.includes(model)) throw new Error(`bad --model: ${model}`);\nif (process.platform !== 'darwin') throw new Error('macOS required');","typeGuard":null,"tryCatchPattern":"try {\n  execSync(`opencli chatgpt-app send \"${text}\" --model ${model}`);\n} catch (e) {\n  const msg = String(e.message);\n  if (msg.includes('Failed to send')) console.error('send failed:', msg.split('Failed to send ChatGPT message: ')[1]);\n  throw e;\n}","preventionTips":["Keep the ChatGPT app running and foregrounded before sends","Avoid sending from locked screens or headless contexts","Log the underlying error text after the wrapper prefix"],"tags":["applescript","desktop-app","error-wrapper"],"backgroundTag":"command-execution-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}