Skip to content

Commit

Permalink
Merge pull request #110 from JunNishimura/#107
Browse files Browse the repository at this point in the history
update finish behaviour for hey command
  • Loading branch information
JunNishimura authored Sep 2, 2023
2 parents 2ec341e + 74f9ee8 commit e599891
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions ui/cmd/hey/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ type Model struct {
spotifyClient *spotify.Client
openaiClient *openai.Client
questionIndex int
questionDone bool
functionCall any
chatCompMessages []openai.ChatCompletionMessage
functions []openai.FunctionDefinition
Expand Down
7 changes: 7 additions & 0 deletions ui/cmd/hey/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case "ctrl+c", "q":
return m, tea.Quit
case "tab":
if m.questionDone {
m.state = recommendationView
}
m.state = m.state.Switch()
case "enter":
if m.err != nil {
Expand Down Expand Up @@ -83,6 +86,10 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.chatCompMessages = append(m.chatCompMessages, msg.msg)
m.functionCall = "auto"
m.questionIndex++
if m.questionIndex == len(functions.List) {
m.questionDone = true
m.state = recommendationView
}
return m, tea.Batch(m.generate, m.recommend)
case recommendMsg:
m.recommendItems = msg.items
Expand Down
6 changes: 6 additions & 0 deletions ui/cmd/hey/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ func (m *Model) View() string {
return style.ErrorView(style.DefaultErrorMessage, m.Window.Width, m.Window.Height)
}

if m.questionDone {
return lipgloss.Place(m.Window.Width, m.Window.Height, lipgloss.Center, lipgloss.Center,
style.RecommendationFocused(m.getViewWidth(), m.getViewHeight()).Render(m.recommendationView()),
)
}

var s string
if m.state == chatView {
s += lipgloss.Place(m.Window.Width, m.Window.Height, lipgloss.Center, lipgloss.Center,
Expand Down

0 comments on commit e599891

Please sign in to comment.