| 1 | package cli |
| 2 | |
| 3 | import ( |
| 4 | "path/filepath" |
| 5 | "testing" |
| 6 | |
| 7 | tea "charm.land/bubbletea/v2" |
| 8 | |
| 9 | "reasonix/internal/control" |
| 10 | "reasonix/internal/event" |
| 11 | ) |
| 12 | |
| 13 | func TestManualNewlineDuringRunningTurnDoesNotSteerOrClearDraft(t *testing.T) { |
| 14 | dir := t.TempDir() |
| 15 | ctrl := newOwnedTestController(t, control.Options{SessionPath: filepath.Join(dir, "session.jsonl"), SessionDir: dir}) |
| 16 | m := newChatTUI(ctrl, "", make(chan event.Event, 1), 40) |
| 17 | m.state = tuiRunning |
| 18 | m.input.SetValue("first line") |
| 19 | |
| 20 | m0, _ := m.Update(tea.KeyPressMsg{Code: 'j', Mod: tea.ModCtrl}) |
| 21 | m = m0.(chatTUI) |
| 22 | |
| 23 | if got := m.input.Value(); got != "first line\n" { |
| 24 | t.Fatalf("input after running Ctrl+J = %q, want newline-preserved draft", got) |
| 25 | } |
| 26 | if items := ctrl.InboxSnapshot().Items; len(items) != 0 { |
| 27 | t.Fatalf("running Ctrl+J unexpectedly enqueued guidance: %+v", items) |
| 28 | } |
| 29 | } |
| 30 |