| 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "reasonix/internal/event" |
| 7 | "reasonix/internal/provider" |
| 8 | ) |
| 9 | |
| 10 | func TestReadPauseHistoryAndTopic(t *testing.T) { |
| 11 | p := &provider.ReadPause{ID: "run", Reads: []provider.PausedRead{{Path: "file", Reason: "no_progress"}}} |
| 12 | rows, ok := historyLocalOnlyRows(provider.Message{LocalOnly: true, ReadPause: p}) |
| 13 | if !ok || len(rows) != 1 || rows[0].Code != event.TurnOutcomeIncompleteRead || rows[0].ReadPause.ID != "run" { |
| 14 | t.Fatal("pause not restored as one notice") |
| 15 | } |
| 16 | if status, ok := topicStatusFromTurnDone(event.TurnOutcomeIncompleteRead); !ok || status != topicStatusPaused { |
| 17 | t.Fatal("read pause classified as success") |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | func TestReadPauseSurvivesColdHistorySlice(t *testing.T) { |
| 22 | app := historySliceTestApp(t) |
| 23 | tab := newColdHistoryTab(t, app) |
| 24 | dir := tabSessionDir(tab) |
| 25 | _, tab.SessionPath = saveHistorySliceSession(t, dir, "read-pause.jsonl", []provider.Message{ |
| 26 | {Role: provider.RoleUser, Content: "read all"}, |
| 27 | {Role: provider.RoleAssistant, Content: "candidate"}, |
| 28 | {Role: provider.RoleTool, LocalOnly: true, ToolCallID: provider.LocalOnlyToolID, Name: provider.LocalOnlyToolName, ReadPause: &provider.ReadPause{ID: "run", Reads: []provider.PausedRead{{Path: "fixture.txt", Reason: "no_progress"}}}}, |
| 29 | }) |
| 30 | page := app.HistorySliceForTab(tab.ID, HistorySliceRequest{Turns: 12}) |
| 31 | if page.Error != "" { |
| 32 | t.Fatal(page.Error) |
| 33 | } |
| 34 | count := 0 |
| 35 | for _, entry := range page.Entries { |
| 36 | if entry.Message.ReadPause != nil { |
| 37 | count++ |
| 38 | } |
| 39 | } |
| 40 | if count != 1 { |
| 41 | t.Fatalf("pause count=%d entries=%+v", count, page.Entries) |
| 42 | } |
| 43 | } |
| 44 |