MCPcopy
hub / github.com/codeaashu/claude-code / call

Function call

src/commands/rename/rename.ts:21–87  ·  view source on GitHub ↗
(
  onDone: LocalJSXCommandOnDone,
  context: ToolUseContext & LocalJSXCommandContext,
  args: string,
)

Source from the content-addressed store, hash-verified

19import { generateSessionName } from './generateSessionName.js'
20
21export async function call(
22 onDone: LocalJSXCommandOnDone,
23 context: ToolUseContext & LocalJSXCommandContext,
24 args: string,
25): Promise<null> {
26 // Prevent teammates from renaming - their names are set by team leader
27 if (isTeammate()) {
28 onDone(
29 'Cannot rename: This session is a swarm teammate. Teammate names are set by the team leader.',
30 { display: 'system' },
31 )
32 return null
33 }
34
35 let newName: string
36 if (!args || args.trim() === '') {
37 const generated = await generateSessionName(
38 getMessagesAfterCompactBoundary(context.messages),
39 context.abortController.signal,
40 )
41 if (!generated) {
42 onDone(
43 'Could not generate a name: no conversation context yet. Usage: /rename <name>',
44 { display: 'system' },
45 )
46 return null
47 }
48 newName = generated
49 } else {
50 newName = args.trim()
51 }
52
53 const sessionId = getSessionId() as UUID
54 const fullPath = getTranscriptPath()
55
56 // Always save the custom title (session name)
57 await saveCustomTitle(sessionId, newName, fullPath)
58
59 // Sync title to bridge session on claude.ai/code (best-effort, non-blocking).
60 // v2 env-less bridge stores cse_* in replBridgeSessionId —
61 // updateBridgeSessionTitle retags internally for the compat endpoint.
62 const appState = context.getAppState()
63 const bridgeSessionId = appState.replBridgeSessionId
64 if (bridgeSessionId) {
65 const tokenOverride = getBridgeTokenOverride()
66 void import('../../bridge/createSession.js').then(
67 ({ updateBridgeSessionTitle }) =>
68 updateBridgeSessionTitle(bridgeSessionId, newName, {
69 baseUrl: getBridgeBaseUrlOverride(),
70 getAccessToken: tokenOverride ? () => tokenOverride : undefined,
71 }).catch(() => {}),
72 )
73 }
74
75 // Also persist as the session's agent name for prompt-bar display
76 await saveAgentName(sessionId, newName, fullPath)
77 context.setAppState(prev => ({
78 ...prev,

Callers

nothing calls this directly

Calls 11

isTeammateFunction · 0.85
generateSessionNameFunction · 0.85
getSessionIdFunction · 0.85
getTranscriptPathFunction · 0.85
saveCustomTitleFunction · 0.85
getBridgeTokenOverrideFunction · 0.85
updateBridgeSessionTitleFunction · 0.85
getBridgeBaseUrlOverrideFunction · 0.85
saveAgentNameFunction · 0.85
onDoneFunction · 0.50

Tested by

no test coverage detected