MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / updateBridgeSessionTitle

Function updateBridgeSessionTitle

source code/bridge/createSession.ts:329–386  ·  view source on GitHub ↗
(
  sessionId: string,
  title: string,
  opts?: { baseUrl?: string; getAccessToken?: () => string | undefined },
)

Source from the content-addressed store, hash-verified

327 * Errors are swallowed — title sync is best-effort.
328 */
329export async function updateBridgeSessionTitle(
330 sessionId: string,
331 title: string,
332 opts?: { baseUrl?: string; getAccessToken?: () => string | undefined },
333): Promise<void> {
334 const { getClaudeAIOAuthTokens } = await import('../utils/auth.js')
335 const { getOrganizationUUID } = await import('../services/oauth/client.js')
336 const { getOauthConfig } = await import('../constants/oauth.js')
337 const { getOAuthHeaders } = await import('../utils/teleport/api.js')
338 const { default: axios } = await import('axios')
339
340 const accessToken =
341 opts?.getAccessToken?.() ?? getClaudeAIOAuthTokens()?.accessToken
342 if (!accessToken) {
343 logForDebugging('[bridge] No access token for session title update')
344 return
345 }
346
347 const orgUUID = await getOrganizationUUID()
348 if (!orgUUID) {
349 logForDebugging('[bridge] No org UUID for session title update')
350 return
351 }
352
353 const headers = {
354 ...getOAuthHeaders(accessToken),
355 'anthropic-beta': 'ccr-byoc-2025-07-29',
356 'x-organization-uuid': orgUUID,
357 }
358
359 // Compat gateway only accepts session_* (compat/convert.go:27). v2 callers
360 // pass raw cse_*; retag here so all callers can pass whatever they hold.
361 // Idempotent for v1's session_* and bridgeMain's pre-converted compatSessionId.
362 const compatId = toCompatSessionId(sessionId)
363 const url = `${opts?.baseUrl ?? getOauthConfig().BASE_API_URL}/v1/sessions/${compatId}`
364 logForDebugging(`[bridge] Updating session title: ${compatId} → ${title}`)
365
366 try {
367 const response = await axios.patch(
368 url,
369 { title },
370 { headers, timeout: 10_000, validateStatus: s => s < 500 },
371 )
372
373 if (response.status === 200) {
374 logForDebugging(`[bridge] Session title updated successfully`)
375 } else {
376 const detail = extractErrorDetail(response.data)
377 logForDebugging(
378 `[bridge] Session title update failed with status ${response.status}${detail ? `: ${detail}` : ''}`,
379 )
380 }
381 } catch (err: unknown) {
382 logForDebugging(
383 `[bridge] Session title update request failed: ${errorMessage(err)}`,
384 )
385 }
386}

Callers 3

patchFunction · 0.85
runBridgeLoopFunction · 0.85
callFunction · 0.85

Calls 7

logForDebuggingFunction · 0.85
getOrganizationUUIDFunction · 0.85
getOAuthHeadersFunction · 0.85
toCompatSessionIdFunction · 0.85
getOauthConfigFunction · 0.85
extractErrorDetailFunction · 0.85
errorMessageFunction · 0.50

Tested by

no test coverage detected