mirror of
https://github.com/ollama/ollama.git
synced 2026-10-21 02:51:35 +00:00
tui: surface approvals over modals
This commit is contained in:
parent
66cdf46e7d
commit
cb8af634b3
2 changed files with 41 additions and 0 deletions
|
|
@ -430,6 +430,8 @@ func (m chatModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||
return m, waitForChatMsg(m.events)
|
||||
|
||||
case chatApprovalPromptMsg:
|
||||
m.resumePicker = nil
|
||||
m.historyPopup = nil
|
||||
m.openApprovalPrompt(msg)
|
||||
return m, nil
|
||||
|
||||
|
|
|
|||
|
|
@ -539,6 +539,45 @@ func TestChatApprovalPromptRendersAndApprovesOnce(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestChatApprovalPromptClosesHistoryPopup(t *testing.T) {
|
||||
reply := make(chan coreagent.ApprovalResult, 1)
|
||||
m := chatModel{
|
||||
width: 100,
|
||||
height: 24,
|
||||
historyPopup: &chatHistoryPopup{content: "**Message History**\n\n**user**\n content: old"},
|
||||
}
|
||||
|
||||
updated, cmd := m.Update(chatApprovalPromptMsg{
|
||||
request: coreagent.ApprovalRequest{
|
||||
ToolCallID: "call-1",
|
||||
ToolName: "bash",
|
||||
Args: map[string]any{"command": "git status"},
|
||||
Summary: "Bash wants to run a command",
|
||||
},
|
||||
reply: reply,
|
||||
})
|
||||
if cmd != nil {
|
||||
t.Fatal("opening approval prompt should not return a command")
|
||||
}
|
||||
m = updated.(chatModel)
|
||||
if m.historyPopup != nil {
|
||||
t.Fatal("approval prompt should close history popup")
|
||||
}
|
||||
if m.approvalPrompt == nil {
|
||||
t.Fatal("approval prompt should open")
|
||||
}
|
||||
|
||||
view := stripANSI(m.View())
|
||||
if strings.Contains(view, "Message history") {
|
||||
t.Fatalf("history popup should not render over approval prompt:\n%s", view)
|
||||
}
|
||||
for _, want := range []string{"Bash wants to run a command", "Approve once", "Approve session", "Deny"} {
|
||||
if !strings.Contains(view, want) {
|
||||
t.Fatalf("approval view missing %q:\n%s", want, view)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestChatApprovalPromptDenyShortcut(t *testing.T) {
|
||||
reply := make(chan coreagent.ApprovalResult, 1)
|
||||
m := chatModel{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue