MCPcopy Create free account
hub / github.com/claude-code-best/claude-code / handleDeepLinkUri

Function handleDeepLinkUri

src/utils/deepLink/protocolHandler.ts:37–74  ·  view source on GitHub ↗
(uri: string)

Source from the content-addressed store, hash-verified

35 * @returns exit code (0 = success)
36 */
37export async function handleDeepLinkUri(uri: string): Promise<number> {
38 logForDebugging(`Handling deep link URI: ${uri}`)
39
40 let action
41 try {
42 action = parseDeepLink(uri)
43 } catch (error) {
44 const message = error instanceof Error ? error.message : String(error)
45 console.error(`Deep link error: ${message}`)
46 return 1
47 }
48
49 logForDebugging(`Parsed deep link action: ${jsonStringify(action)}`)
50
51 // Always the running executable — no PATH lookup. The OS launched us via
52 // an absolute path (bundle symlink / .desktop Exec= / registry command)
53 // baked at registration time, and we want the terminal-launched Claude to
54 // be the same binary. process.execPath is that binary.
55 const { cwd, resolvedRepo } = await resolveCwd(action)
56 // Resolve FETCH_HEAD age here, in the trampoline process, so main.tsx
57 // stays await-free — the launched instance receives it as a precomputed
58 // flag instead of statting the filesystem on its own startup path.
59 const lastFetch = resolvedRepo ? await readLastFetchTime(cwd) : undefined
60 const launched = await launchInTerminal(process.execPath, {
61 query: action.query,
62 cwd,
63 repo: resolvedRepo,
64 lastFetchMs: lastFetch?.getTime(),
65 })
66 if (!launched) {
67 console.error(
68 'Failed to open a terminal. Make sure a supported terminal emulator is installed.',
69 )
70 return 1
71 }
72
73 return 0
74}
75
76/**
77 * Handle the case where claude was launched as the app bundle's executable

Callers 3

mainFunction · 0.85
handleUrlSchemeLaunchFunction · 0.85

Calls 7

parseDeepLinkFunction · 0.85
jsonStringifyFunction · 0.85
resolveCwdFunction · 0.85
readLastFetchTimeFunction · 0.85
launchInTerminalFunction · 0.85
errorMethod · 0.65
logForDebuggingFunction · 0.50

Tested by

no test coverage detected