fix(api): monitor, replay

This commit is contained in:
ttk
2024-09-06 19:45:01 +08:00
parent 5a63cc375a
commit a30bd94541
6 changed files with 75 additions and 96 deletions

View File

@@ -672,7 +672,8 @@ func (m Model) View() string {
v += styleText(m.echoTransform(string(value[pos+1:]))) // text after cursor
v += m.completionView(0) // suggested completion
} else {
if m.canAcceptSuggestion() {
if m.canAcceptSuggestion() && len(m.matchedSuggestions) <= 1 {
suggestion := m.matchedSuggestions[m.currentSuggestionIndex]
if len(value) < len(suggestion) {
m.Cursor.TextStyle = m.CompletionStyle

View File

@@ -175,7 +175,11 @@ func (m *view) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
case errMsg:
if msg != nil {
return m, tea.Printf(" [ERROR] %s\n\n", errStyle.Render(msg.Error()))
str := msg.Error()
if ae, ok := msg.(*controller.ApiError); ok {
str = controller.Err2Msg[ae.Code].One
}
return m, tea.Printf(" [ERROR] %s\n\n", errStyle.Render(str))
}
}
m.textinput, tiCmd = m.textinput.Update(msg)
@@ -327,7 +331,7 @@ func (conn *connector) SetStderr(w io.Writer) {
}
func (conn *connector) Run() error {
gsess, err := controller.DoConnect(conn.Ctx)
gsess, err := controller.DoConnect(conn.Ctx, nil)
if err != nil {
return err
}