File tree Expand file tree Collapse file tree
packages/opencode/src/cli/cmd/tui/feature-plugins/home Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import { For } from "solid-js"
1+ import { createMemo , For } from "solid-js"
22import { DEFAULT_THEMES , useTheme } from "@tui/context/theme"
33
44const themeCount = Object . keys ( DEFAULT_THEMES ) . length
@@ -30,17 +30,20 @@ function parse(tip: string): TipPart[] {
3030 return parts
3131}
3232
33- export function Tips ( ) {
33+ const NO_MODELS_TIP = "Run {highlight}/connect{/highlight} to add an AI provider and start coding"
34+
35+ export function Tips ( props : { connected ?: boolean } ) {
3436 const theme = useTheme ( ) . theme
35- const parts = parse ( TIPS [ Math . floor ( Math . random ( ) * TIPS . length ) ] )
37+ const randomTip = TIPS [ Math . floor ( Math . random ( ) * TIPS . length ) ]
38+ const parts = createMemo ( ( ) => parse ( props . connected === false ? NO_MODELS_TIP : randomTip ) )
3639
3740 return (
3841 < box flexDirection = "row" maxWidth = "100%" >
3942 < text flexShrink = { 0 } style = { { fg : theme . warning } } >
4043 ● Tip{ " " }
4144 </ text >
4245 < text flexShrink = { 1 } >
43- < For each = { parts } >
46+ < For each = { parts ( ) } >
4447 { ( part ) => < span style = { { fg : part . highlight ? theme . text : theme . textMuted } } > { part . text } </ span > }
4548 </ For >
4649 </ text >
Original file line number Diff line number Diff line change @@ -4,11 +4,11 @@ import { Tips } from "./tips-view"
44
55const id = "internal:home-tips"
66
7- function View ( props : { show : boolean } ) {
7+ function View ( props : { show : boolean ; connected : boolean } ) {
88 return (
99 < box height = { 4 } minHeight = { 0 } width = "100%" maxWidth = { 75 } alignItems = "center" paddingTop = { 3 } flexShrink = { 1 } >
1010 < Show when = { props . show } >
11- < Tips />
11+ < Tips connected = { props . connected } />
1212 </ Show >
1313 </ box >
1414 )
@@ -35,8 +35,13 @@ const tui: TuiPlugin = async (api) => {
3535 home_bottom ( ) {
3636 const hidden = createMemo ( ( ) => api . kv . get ( "tips_hidden" , false ) )
3737 const first = createMemo ( ( ) => api . state . session . count ( ) === 0 )
38- const show = createMemo ( ( ) => ! first ( ) && ! hidden ( ) )
39- return < View show = { show ( ) } />
38+ const connected = createMemo ( ( ) =>
39+ api . state . provider . some (
40+ ( item ) => item . id !== "opencode" || Object . values ( item . models ) . some ( ( model ) => model . cost ?. input !== 0 ) ,
41+ ) ,
42+ )
43+ const show = createMemo ( ( ) => ( ! first ( ) || ! connected ( ) ) && ! hidden ( ) )
44+ return < View show = { show ( ) } connected = { connected ( ) } />
4045 } ,
4146 } ,
4247 } )
You can’t perform that action at this time.
0 commit comments