(msg tea.KeyMsg)
| 464 | } |
| 465 | |
| 466 | func (m harness) updateApproval(msg tea.KeyMsg) (tea.Model, tea.Cmd) { |
| 467 | // When the approval includes a diff/detail, forward scroll keys to the |
| 468 | // modal viewport so the user can browse long diffs. y/n still resolves. |
| 469 | if m.approvalDetail != "" { |
| 470 | switch msg.Type { |
| 471 | case tea.KeyPgUp, tea.KeyPgDown, tea.KeyHome, tea.KeyEnd, tea.KeyUp, tea.KeyDown: |
| 472 | var cmd tea.Cmd |
| 473 | m.debugView, cmd = m.debugView.Update(msg) |
| 474 | return m, cmd |
| 475 | } |
| 476 | } |
| 477 | |
| 478 | var answer bool |
| 479 | switch msg.String() { |
| 480 | case "y", "Y": |
| 481 | answer = true |
| 482 | case "n", "N", "esc", "ctrl+c", "ctrl+d", "enter": |
| 483 | answer = false |
| 484 | default: |
| 485 | return m, nil |
| 486 | } |
| 487 | // Echo the decision into scrollback so the user can see what they answered. |
| 488 | verdict := "denied" |
| 489 | if answer { |
| 490 | verdict = "approved" |
| 491 | } |
| 492 | m.output.WriteString(Dimmed(fmt.Sprintf(" ↳ %s", verdict)) + "\n") |
| 493 | m.setConversationContent() |
| 494 | m.viewport.GotoBottom() |
| 495 | |
| 496 | if m.approvalReply != nil { |
| 497 | m.approvalReply <- answer |
| 498 | m.approvalReply = nil |
| 499 | } |
| 500 | m.approvalPrompt = "" |
| 501 | m.approvalDetail = "" |
| 502 | m.state = stateRunning |
| 503 | // If the modal was up, layout needs to revert from modal-size to the |
| 504 | // normal panel/viewport split before the next render. |
| 505 | m.layout() |
| 506 | return m, nil |
| 507 | } |
| 508 | |
| 509 | func (m harness) runOnce(text string) tea.Cmd { |
| 510 | return func() tea.Msg { |
no test coverage detected