Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cmd/air/list_tui.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,9 @@ func (m listModel) clampedOffset() int {
return max(offset, 0)
}

func (m listModel) View() string {
func (m listModel) View() string { return m.render() }

func (m listModel) render() string {
if m.mode == modeDetail {
faint := m.styles.r.NewStyle().Foreground(colN7)
lines := []string{m.detailTitle}
Expand Down
4 changes: 2 additions & 2 deletions cmd/apps/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ func promptForPluginsAndDeps(ctx context.Context, m *manifest.Manifest, preSelec
// asks per resource that can be accessed on behalf of the user.
// Resources that cannot are listed as info and resolve to sp.
// Returns a map of resource key to auth mode, or nil if nothing needs to be asked.
func promptForAuthModes(ctx context.Context, resources []manifest.Resource, theme *huh.Theme) (map[string]string, error) {
func promptForAuthModes(ctx context.Context, resources []manifest.Resource, theme prompt.Theme) (map[string]string, error) {
var capable []manifest.Resource
for _, r := range resources {
if r.Scope != "" && !r.AppOnly {
Expand Down Expand Up @@ -751,7 +751,7 @@ func authModeLabel(mode string) string {
// promptForResource prompts the user for a resource value.
// Returns a map of value keys to values. For single-field resources the key is "resource_key.field".
// For multi-field resources, keys use "resource_key.field_name".
func promptForResource(ctx context.Context, r manifest.Resource, theme *huh.Theme, required bool) (map[string]string, error) {
func promptForResource(ctx context.Context, r manifest.Resource, theme prompt.Theme, required bool) (map[string]string, error) {
if fn, ok := prompt.GetPromptFunc(r.Type); ok {
if !required {
var configure bool
Expand Down
13 changes: 8 additions & 5 deletions libs/apps/prompt/prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,17 @@ var (
colorDimmedDark cmdio.Color = lipgloss.Color("#52525B")
)

// Theme is the huh theme handed to appkit prompt forms and fields.
type Theme = *huh.Theme

// AppkitTheme returns a custom theme for appkit prompts.
func AppkitTheme() *huh.Theme {
return appkitTheme(cmdio.HasDarkBackground())
func AppkitTheme() Theme {
return appkitStyles(cmdio.HasDarkBackground())
}

// appkitTheme builds the theme for a known background, matching the shape of
// huh v2's ThemeFunc.
func appkitTheme(isDark bool) *huh.Theme {
// appkitStyles builds the appkit styles on top of huh's base theme for a known
// background, matching the shape of huh v2's ThemeFunc.
func appkitStyles(isDark bool) *huh.Theme {
lightDark := cmdio.LightDark(isDark)
t := huh.ThemeBase()

Expand Down
4 changes: 2 additions & 2 deletions libs/apps/prompt/prompt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,6 @@ func TestListSystemAIModelServicesWithoutAccess(t *testing.T) {
}

func TestAppkitThemeDimmedButtonFollowsBackground(t *testing.T) {
assert.Equal(t, colorDimmedDark, appkitTheme(true).Focused.BlurredButton.GetForeground())
assert.Equal(t, colorDimmedLight, appkitTheme(false).Focused.BlurredButton.GetForeground())
assert.Equal(t, colorDimmedDark, appkitStyles(true).Focused.BlurredButton.GetForeground())
assert.Equal(t, colorDimmedLight, appkitStyles(false).Focused.BlurredButton.GetForeground())
}
4 changes: 3 additions & 1 deletion libs/cmdio/pager.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,9 @@ func (m *pagerModel[T]) startDrain() tea.Cmd {
return m.fetch(m.pageSize, m.limit, m.total)
}

func (m *pagerModel[T]) View() string {
func (m *pagerModel[T]) View() string { return m.render() }

func (m *pagerModel[T]) render() string {
switch {
case m.iterDone || m.err != nil:
return ""
Expand Down
4 changes: 3 additions & 1 deletion libs/cmdio/prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ func (m *promptModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, nil
}

func (m *promptModel) View() string {
func (m *promptModel) View() string { return m.render() }

func (m *promptModel) render() string {
// HideEntered: empty final frame so the masked value isn't left in
// scrollback after the user presses Enter.
if m.submitted && m.hideEntered {
Expand Down
4 changes: 3 additions & 1 deletion libs/cmdio/select.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,9 @@ func (m *selectModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, nil
}

func (m *selectModel) View() string {
func (m *selectModel) View() string { return m.render() }

func (m *selectModel) render() string {
var b strings.Builder

// After submission render only the Selected template; the post-quit
Expand Down
4 changes: 3 additions & 1 deletion libs/cmdio/spinner.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ func (m spinnerModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
}

func (m spinnerModel) View() string {
func (m spinnerModel) View() string { return m.render() }

func (m spinnerModel) render() string {
if m.quitting {
return ""
}
Expand Down
4 changes: 3 additions & 1 deletion libs/tableview/tableview.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,9 @@ func (m model) updateSearch(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
}
}

func (m model) View() string {
func (m model) View() string { return m.render() }

func (m model) render() string {
if !m.ready {
return "Loading..."
}
Expand Down
Loading