chenbhao commited on
Commit
41f32b4
·
1 Parent(s): d8a167e

chore: rename session title

Browse files
Files changed (1) hide show
  1. src/screens/REPL.tsx +18 -18
src/screens/REPL.tsx CHANGED
@@ -1573,14 +1573,14 @@ export function REPL({
1573
  const sessionTitle = terminalTitleFromRename
1574
  ? getCurrentSessionTitle(getSessionId())
1575
  : undefined
1576
- const [haikuTitle, setHaikuTitle] = useState<string>()
1577
- // Gates the one-shot Haiku call that generates the tab title. Seeded true
1578
- // on resume (initialMessages present) so we don't re-title a resumed
1579
- // session from mid-conversation context.
1580
- const haikuTitleAttemptedRef = useRef((initialMessages?.length ?? 0) > 0)
1581
  const agentTitle = mainThreadAgentDefinition?.agentType
1582
  const terminalTitle =
1583
- sessionTitle ?? agentTitle ?? haikuTitle ?? 'Claude Code'
1584
  const isWaitingForApproval =
1585
  toolUseConfirmQueue.length > 0 ||
1586
  promptQueue.length > 0 ||
@@ -2496,9 +2496,9 @@ export function REPL({
2496
  restoreSessionMetadata(log)
2497
  // Resumed sessions shouldn't re-title from mid-conversation context
2498
  // (same reasoning as the useRef seed), and the previous session's
2499
- // Haiku title shouldn't carry over.
2500
- haikuTitleAttemptedRef.current = true
2501
- setHaikuTitle(undefined)
2502
 
2503
  // Exit any worktree a prior /resume entered, then cd into the one
2504
  // this session was in. Without the exit, resuming from worktree B
@@ -3594,7 +3594,7 @@ export function REPL({
3594
  !titleDisabled &&
3595
  !sessionTitle &&
3596
  !agentTitle &&
3597
- !haikuTitleAttemptedRef.current
3598
  ) {
3599
  const firstUserMessage = newMessages.find(
3600
  m => m.type === 'user' && !m.isMeta,
@@ -3614,14 +3614,14 @@ export function REPL({
3614
  !text.startsWith(`<${COMMAND_NAME_TAG}>`) &&
3615
  !text.startsWith(`<${BASH_INPUT_TAG}>`)
3616
  ) {
3617
- haikuTitleAttemptedRef.current = true
3618
  void generateSessionTitle(text, new AbortController().signal).then(
3619
  title => {
3620
- if (title) setHaikuTitle(title)
3621
- else haikuTitleAttemptedRef.current = false
3622
  },
3623
  () => {
3624
- haikuTitleAttemptedRef.current = false
3625
  },
3626
  )
3627
  }
@@ -4122,8 +4122,8 @@ export function REPL({
4122
  setAppState,
4123
  setConversationId,
4124
  })
4125
- haikuTitleAttemptedRef.current = false
4126
- setHaikuTitle(undefined)
4127
  bashTools.current.clear()
4128
  bashToolsProcessedIdx.current = 0
4129
 
@@ -6555,8 +6555,8 @@ export function REPL({
6555
  setAppState,
6556
  setConversationId,
6557
  })
6558
- haikuTitleAttemptedRef.current = false
6559
- setHaikuTitle(undefined)
6560
  bashTools.current.clear()
6561
  bashToolsProcessedIdx.current = 0
6562
  }
 
1573
  const sessionTitle = terminalTitleFromRename
1574
  ? getCurrentSessionTitle(getSessionId())
1575
  : undefined
1576
+ const [autoGeneratedTitle, setAutoGeneratedTitle] = useState<string>()
1577
+ // Gates the one-shot title generation call. Seeded true on resume
1578
+ // (initialMessages present) so we don't re-title a resumed session
1579
+ // from mid-conversation context.
1580
+ const titleGenerationAttemptedRef = useRef((initialMessages?.length ?? 0) > 0)
1581
  const agentTitle = mainThreadAgentDefinition?.agentType
1582
  const terminalTitle =
1583
+ sessionTitle ?? agentTitle ?? autoGeneratedTitle ?? 'Versper Claw'
1584
  const isWaitingForApproval =
1585
  toolUseConfirmQueue.length > 0 ||
1586
  promptQueue.length > 0 ||
 
2496
  restoreSessionMetadata(log)
2497
  // Resumed sessions shouldn't re-title from mid-conversation context
2498
  // (same reasoning as the useRef seed), and the previous session's
2499
+ // auto-generated title shouldn't carry over.
2500
+ titleGenerationAttemptedRef.current = true
2501
+ setAutoGeneratedTitle(undefined)
2502
 
2503
  // Exit any worktree a prior /resume entered, then cd into the one
2504
  // this session was in. Without the exit, resuming from worktree B
 
3594
  !titleDisabled &&
3595
  !sessionTitle &&
3596
  !agentTitle &&
3597
+ !titleGenerationAttemptedRef.current
3598
  ) {
3599
  const firstUserMessage = newMessages.find(
3600
  m => m.type === 'user' && !m.isMeta,
 
3614
  !text.startsWith(`<${COMMAND_NAME_TAG}>`) &&
3615
  !text.startsWith(`<${BASH_INPUT_TAG}>`)
3616
  ) {
3617
+ titleGenerationAttemptedRef.current = true
3618
  void generateSessionTitle(text, new AbortController().signal).then(
3619
  title => {
3620
+ if (title) setAutoGeneratedTitle(title)
3621
+ else titleGenerationAttemptedRef.current = false
3622
  },
3623
  () => {
3624
+ titleGenerationAttemptedRef.current = false
3625
  },
3626
  )
3627
  }
 
4122
  setAppState,
4123
  setConversationId,
4124
  })
4125
+ titleGenerationAttemptedRef.current = false
4126
+ setAutoGeneratedTitle(undefined)
4127
  bashTools.current.clear()
4128
  bashToolsProcessedIdx.current = 0
4129
 
 
6555
  setAppState,
6556
  setConversationId,
6557
  })
6558
+ titleGenerationAttemptedRef.current = false
6559
+ setAutoGeneratedTitle(undefined)
6560
  bashTools.current.clear()
6561
  bashToolsProcessedIdx.current = 0
6562
  }