refactor: simplify session title fallback to static 'Open Claude'
This commit is contained in:
@@ -125,28 +125,9 @@ export async function generateSessionTitle(
|
|||||||
})
|
})
|
||||||
logEvent('tengu_session_title_generated', { success: false })
|
logEvent('tengu_session_title_generated', { success: false })
|
||||||
|
|
||||||
// Fallback: derive a title locally from the user's first message.
|
// Fallback: When using 3P providers without a compatible schema,
|
||||||
// This ensures 3P providers (Ollama, Gemini, OpenAI) still get
|
// default to the application name.
|
||||||
// meaningful terminal titles when the Haiku API call is unavailable.
|
return 'Open Claude'
|
||||||
return localFallbackTitle(trimmed)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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)
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user