{"record":{"id":"05f50c6ab7bbce07","repo":"davila7/claude-code-templates","slug":"could-not-auto-open-browser","errorCode":null,"errorMessage":"⚠️  Could not auto-open browser:","messagePattern":"⚠️  Could not auto-open browser:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"cli-tool/src/chats-mobile.js","lineNumber":1182,"sourceCode":"        }, 45000);\n      });\n    } catch (error) {\n      console.error(chalk.red('❌ Error setting up Cloudflare Tunnel:'), error.message);\n      return null;\n    }\n  }\n\n  /**\n   * Open browser to the mobile chats interface\n   */\n  async openBrowser() {\n    try {\n      // Use tunnel URL if available, otherwise local URL\n      const url = this.tunnelUrl || this.localUrl || `http://localhost:${this.port}`;\n      console.log(chalk.cyan(`🌐 Opening browser to ${url}`));\n      await open(url);\n    } catch (error) {\n      console.warn(chalk.yellow('⚠️  Could not auto-open browser:', error.message));\n    }\n  }\n\n  /**\n   * Stop the server\n   */\n  async stop() {\n    // Prevent multiple stop calls\n    if (this.isStopped) {\n      return;\n    }\n    this.isStopped = true;\n\n    if (this.cloudflaredProcess) {\n      try {\n        this.cloudflaredProcess.kill('SIGTERM');\n        this.log('info', chalk.gray('☁️  Cloudflare Tunnel stopped'));\n      } catch (error) {","sourceCodeStart":1164,"sourceCodeEnd":1200,"githubUrl":"https://github.com/davila7/claude-code-templates/blob/a0851ed10c7c60463dac8cfaaca124cf32d5804d/cli-tool/src/chats-mobile.js#L1164-L1200","documentation":"This warning is emitted by ChatsMobile.openBrowser() when the `open` npm package fails to launch the user's default browser at the mobile chat server URL (tunnel or localhost). It is a non-fatal warning: the server keeps running and the user can open the URL manually. Common causes are no display available (SSH/headless), no default browser configured, missing xdg-open, or an invalid/undefined URL.","triggerScenarios":"Running the chats-mobile server in an environment where `open(url)` rejects: headless Linux box with no $DISPLAY, minimal containers without xdg-open/browser, SSH sessions without X forwarding, or a malformed URL (undefined tunnelUrl/localUrl falling back to a bogus value).","commonSituations":"Running the CLI over SSH, in Docker/WSL without a browser, on a server CI box, or on Linux where xdg-settings has no default Browser configured.","solutions":["If on SSH, use the printed URL and open it in your local browser manually (the tunnel URL is printed just above the warning).","Set a default browser: `xdg-settings set default-web-browser firefox.desktop` (Linux) or ensure BROWSER env var points to a browser binary.","On headless machines, run with a port-forward instead: `ssh -L 4040:localhost:4040` and open http://localhost:4040 locally.","If you must auto-open, install xdg-utils (`apt install xdg-utils`) or export BROWSER=/usr/bin/chromium."],"exampleFix":"// before\nconst url = this.tunnelUrl || this.localUrl || `http://localhost:${this.port}`;\nawait open(url);\n// after (guard headless environments)\nconst url = this.tunnelUrl || this.localUrl || `http://localhost:${this.port}`;\nif (!process.env.BROWSER && !process.env.DISPLAY && process.platform === 'linux') {\n  console.log(chalk.cyan(`🌐 Open manually: ${url}`));\n  return;\n}\nawait open(url);","handlingStrategy":"fallback","validationCode":"const isHeadless = process.platform === 'linux' && !process.env.DISPLAY && !process.env.BROWSER;\nif (!isHeadless) await open(url); else console.log(`Open manually: ${url}`);","typeGuard":null,"tryCatchPattern":"try { await open(url); } catch (e) { console.warn('Could not auto-open browser:', e.message); console.log(`Open manually: ${url}`); }","preventionTips":["Always surface the URL in logs so users can open it manually.","Detect headless/SSH environments (no DISPLAY/BROWSER) before calling open()."],"tags":["browser-launch","headless","cli-ux"],"backgroundTag":"failed-to-open-browser","analyzedSha":"a0851ed10c7c60463dac8cfaaca124cf32d5804d","analyzedAt":"2026-08-28T14:11:56.058Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}