MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / safeOpen

Function safeOpen

cli/src/utils/open-url.ts:18–37  ·  view source on GitHub ↗
(url: string)

Source from the content-addressed store, hash-verified

16 * @returns `true` if the browser was (likely) opened, `false` if skipped.
17 */
18export async function safeOpen(url: string): Promise<boolean> {
19 if (os.platform() === 'linux') {
20 const env = getCliEnv()
21 const hasDisplay = Boolean(env.DISPLAY || env.WAYLAND_DISPLAY)
22 if (!hasDisplay) {
23 logger.warn(
24 'No display server detected (DISPLAY / WAYLAND_DISPLAY unset). Skipping browser open.',
25 )
26 return false
27 }
28 }
29
30 try {
31 await open(url)
32 return true
33 } catch (err) {
34 logger.error(err, 'Failed to open browser')
35 return false
36 }
37}

Callers 9

ChatFunction · 0.90
UsageBannerFunction · 0.90
ChoiceAdBannerFunction · 0.90
handleBuyCreditsFunction · 0.90
handleUpgradeFunction · 0.90
RenderUIButtonFunction · 0.90
connectChatGptOAuthFunction · 0.90
useFetchLoginUrlFunction · 0.90

Calls 1

getCliEnvFunction · 0.90

Tested by

no test coverage detected