v0.33.0 653c635

replay_test.go RawHistoryFolder

1package provider
2
3import (
4	"encoding/json"
5	"testing"
6)
7
8func TestReplayContentPreservesHistoryAndRestoresOrigin(t *testing.T) {
9	original := Message{Role: RoleAssistant, Meta: map[string]string{"provider": "google", "model": "model-a"}, Content: []Content{
10		ReasoningBlock{Encrypted: "opaque"}, TextBlock{Text: "answer", ThoughtSignature: "text-signature"}, ImageBlock{ThoughtSignature: "image-signature"}, ToolCallBlock{ID: "call_1", Name: "lookup", ThoughtSignature: "tool-signature"},
11	}}
12	before, _ := json.Marshal(original)
13	foreign := replayContent(original, "google", "model-b")
14	if len(foreign) != 3 || foreign[0].(TextBlock).ThoughtSignature != "" || foreign[1].(ImageBlock).ThoughtSignature != "" || foreign[2].(ToolCallBlock).ThoughtSignature != "" {
15		t.Fatalf("foreign content = %#v", foreign)
16	}
17	restored := replayContent(original, "google", "model-a")
18	if len(restored) != 4 || restored[0].(ReasoningBlock).Encrypted != "opaque" || restored[1].(TextBlock).ThoughtSignature != "text-signature" {
19		t.Fatal("switch back lost private state")
20	}
21	after, _ := json.Marshal(original)
22	if string(before) != string(after) {
23		t.Fatal("history mutated")
24	}
25}
26
27func TestResponsesContinuationAllowsHostOrigin(t *testing.T) {
28	prior := Request{Model: "model-a", Messages: []Message{{Role: RoleUser, Content: []Content{TextBlock{Text: "hello"}}}}}
29	output := Message{Role: RoleAssistant, Content: []Content{TextBlock{Text: "answer"}}}
30	session := responsesWebSocketSession{lastRequest: prior, lastOutput: output, lastResponseID: "resp_1", lastBaseline: "baseline"}
31	next := prior
32	next.Messages = append(append([]Message(nil), prior.Messages...), WithMessageOrigin(output, "openai-codex", "model-a"), Message{Role: RoleUser, Content: []Content{TextBlock{Text: "next"}}})
33	incremental, id := session.incrementalRequest(next, "cache", func(Request, string) (string, error) { return "baseline", nil })
34	if id != "resp_1" || len(incremental.Messages) != 1 {
35		t.Fatalf("continuation = %q, %d messages", id, len(incremental.Messages))
36	}
37}
38
39func TestResponsesReplayAcrossModels(t *testing.T) {
40	c := newOpenAICodexClient("token", "account", "")
41	for _, tt := range []struct {
42		name, origin, model, id string
43		want                    bool
44	}{
45		{"same model", "openai-codex", "gpt-5.2", "rs_native", true},
46		{"other provider", "opencode", "gpt-5.2", "rs_first:rs_second", false},
47		{"foreign valid ID", "opencode", "gpt-5.2", "rs_native", false},
48		{"other model", "openai-codex", "gpt-5", "rs_native", false},
49		{"unknown compound ID", "", "", "rs_first:rs_second", false},
50	} {
51		t.Run(tt.name, func(t *testing.T) {
52			messages := []Message{{Role: RoleAssistant, Meta: map[string]string{"provider": tt.origin, "model": tt.model}, Content: []Content{
53				ReasoningBlock{ID: tt.id, Encrypted: "opaque"}, TextBlock{Text: "answer"},
54				ToolCallBlock{ID: "call_1", Name: "lookup", Arguments: json.RawMessage(`{}`)},
55			}}, {Role: RoleTool, Content: []Content{ToolResultBlock{CallID: "call_1", Content: []Content{TextBlock{Text: "result"}}}}}}
56			before, _ := json.Marshal(messages)
57			wire, err := c.buildRequest(Request{Model: "gpt-5.2", Messages: messages})
58			if err != nil {
59				t.Fatal(err)
60			}
61			reasoning, text, call, result := 0, 0, 0, 0
62			for _, item := range wire.Input {
63				switch item.(type) {
64				case codexReasoningItem:
65					reasoning++
66				case codexOutputMessage:
67					text++
68				case codexFunctionCall:
69					call++
70				case codexFunctionCallOutput:
71					result++
72				}
73			}
74			if (reasoning == 1) != tt.want || text != 1 || call != 1 || result != 1 {
75				t.Fatalf("reasoning/text/call/result = %d/%d/%d/%d", reasoning, text, call, result)
76			}
77			after, _ := json.Marshal(messages)
78			if string(before) != string(after) {
79				t.Fatal("history mutated")
80			}
81		})
82	}
83}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 476

↑↓ moveenter openesc close