Private
Public Access
1
0

tui: Add --system-prompt handling

And some state handling changes
This commit is contained in:
2024-05-07 08:07:48 +00:00
parent 2b38db7db7
commit aeeb7bb7f7
3 changed files with 33 additions and 20 deletions

View File

@@ -35,8 +35,10 @@ type views struct {
}
type (
// send to change the current app state
msgChangeState state
// send to change the current state
msgStateChange state
// sent to a state when it is entered
msgStateEnter struct{}
// sent when an error occurs
msgError error
)
@@ -81,7 +83,7 @@ func (m model) Init() tea.Cmd {
m.conversations.Init(),
m.chat.Init(),
func() tea.Msg {
return msgChangeState(m.state)
return msgStateChange(m.state)
},
)
}
@@ -124,18 +126,20 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
if handled {
return m, cmd
}
case msgChangeState:
switch msg {
case msgStateChange:
m.state = state(msg)
switch m.state {
case stateChat:
m.chat.handleResize(m.width, m.height)
case stateConversations:
m.conversations.handleResize(m.width, m.height)
}
m.state = state(msg)
return m, func() tea.Msg { return msgStateEnter(struct{}{}) }
case msgConversationSelected:
// passed up through conversation list model
m.opts.convShortname = msg.ShortName.String
cmds = append(cmds, func() tea.Msg {
return msgChangeState(stateChat)
return msgStateChange(stateChat)
})
case tea.WindowSizeMsg:
m.width, m.height = msg.Width, msg.Height