refactor: simplify session title fallback to static 'Open Claude'

This commit is contained in:
Raj Rasane
2026-04-02 10:40:27 +05:30
parent 63546dcd9c
commit f340b199c8

View File

@@ -125,28 +125,9 @@ export async function generateSessionTitle(
})
logEvent('tengu_session_title_generated', { success: false })
// Fallback: derive a title locally from the user's first message.
// This ensures 3P providers (Ollama, Gemini, OpenAI) still get
// meaningful terminal titles when the Haiku API call is unavailable.
return localFallbackTitle(trimmed)
// Fallback: When using 3P providers without a compatible schema,
// default to the application name.
return 'Open Claude'
}
}
/**
* Fallback local title generator for when the Haiku API is unavailable
* (e.g. when using third-party providers without an Anthropic API key).
*/
function localFallbackTitle(text: string): string | null {
const words = text.split(/\s+/).slice(0, 7)
if (words.length === 0) return null
// Create a sentence-case string
let fallback = words.join(' ')
if (fallback.length > 50) {
fallback = fallback.substring(0, 49) + '…'
}
if (fallback.length <= 3) return null
return fallback.charAt(0).toUpperCase() + fallback.slice(1)
}