handle undefined tips (#27635)

This commit is contained in:
Sebastian
2026-05-15 23:04:00 +02:00
committed by GitHub
parent f060874b29
commit aa07e21945
@@ -69,6 +69,7 @@ function parse(tip: string): TipPart[] {
} }
const NO_MODELS_TIP = "Run {highlight}/connect{/highlight} to add an AI provider and start coding" const NO_MODELS_TIP = "Run {highlight}/connect{/highlight} to add an AI provider and start coding"
const NO_MODELS_PARTS = parse(NO_MODELS_TIP)
function shortcutText(value: string) { function shortcutText(value: string) {
return `{highlight}${value}{/highlight}` return `{highlight}${value}{/highlight}`
@@ -138,8 +139,13 @@ export function Tips(props: { api: TuiPluginApi; connected?: boolean }) {
return value ? [value] : [] return value ? [value] : []
}) })
return tips[Math.floor(tipOffset * tips.length)] ?? NO_MODELS_TIP return tips[Math.floor(tipOffset * tips.length)] ?? NO_MODELS_TIP
}) }, NO_MODELS_TIP)
const parts = createMemo(() => parse(tip())) // Solid can expose a memo's initial value while a pure computation is pending.
const parts = createMemo(() => {
const value = tip()
if (typeof value === "string") return parse(value)
return NO_MODELS_PARTS
}, NO_MODELS_PARTS)
return ( return (
<box flexDirection="row" maxWidth="100%"> <box flexDirection="row" maxWidth="100%">