v0.50.1 a637010

developer_context_test.go RawHistoryFolder

1package provider
2
3import "testing"
4
5func TestSystemWithDeveloperContextSeparatesStableAndDynamicText(t *testing.T) {
6	stable, dynamic, messages := systemWithDeveloperContext(Request{
7		System:        "stable instructions",
8		SystemContext: "legacy host context",
9		Messages: []Message{
10			{Role: RoleDeveloper, Content: []Content{TextBlock{Text: "dynamic host context"}}},
11			{Role: RoleUser, Content: []Content{TextBlock{Text: "user task"}}},
12		},
13	})
14	if stable != "stable instructions" {
15		t.Fatalf("stable = %q", stable)
16	}
17	if dynamic != "legacy host context\n\ndynamic host context" {
18		t.Fatalf("dynamic = %q", dynamic)
19	}
20	if len(messages) != 1 || messages[0].Role != RoleUser {
21		t.Fatalf("messages = %#v, want only the user task", messages)
22	}
23}
24
25func TestAnthropicDeveloperContextFollowsStableCacheBoundary(t *testing.T) {
26	req, err := (&anthropicClient{}).buildRequest(Request{
27		Model:  "claude-sonnet-4-5",
28		System: "stable instructions",
29		Messages: []Message{
30			{Role: RoleDeveloper, Content: []Content{TextBlock{Text: "dynamic host context"}}},
31			{Role: RoleUser, Content: []Content{TextBlock{Text: "user task"}}},
32		},
33	})
34	if err != nil {
35		t.Fatal(err)
36	}
37	if len(req.System) != 2 || req.System[0].Text != "stable instructions" || req.System[0].CacheControl == nil || req.System[1].Text != "dynamic host context" || req.System[1].CacheControl != nil {
38		t.Fatalf("system blocks = %#v", req.System)
39	}
40}
41
42func TestOpenAICompatUsesSystemRoleForDeepSeekDeveloperContext(t *testing.T) {
43	tests := []struct {
44		name   string
45		client *openaiClient
46		model  string
47		want   string
48	}{
49		{name: "direct DeepSeek", client: NewDeepSeek("key", "").(*openaiClient), model: "deepseek-v4-flash", want: "system"},
50		{name: "OpenCode Go DeepSeek", client: NewOpenAICompat(ProviderOpenCodeGo, "key", "https://example.test/v1", "").(*openaiClient), model: "deepseek/deepseek-v4.1-flash", want: "system"},
51		{name: "OpenCode Go other model", client: NewOpenAICompat(ProviderOpenCodeGo, "key", "https://example.test/v1", "").(*openaiClient), model: "other/model", want: "developer"},
52	}
53	for _, test := range tests {
54		t.Run(test.name, func(t *testing.T) {
55			req, err := test.client.buildRequest(Request{
56				Model: test.model,
57				Messages: []Message{
58					{Role: RoleDeveloper, Content: []Content{TextBlock{Text: "dynamic host context"}}},
59					{Role: RoleUser, Content: []Content{TextBlock{Text: "user task"}}},
60				},
61			})
62			if err != nil {
63				t.Fatal(err)
64			}
65			if len(req.Messages) != 2 || req.Messages[0].Role != test.want || req.Messages[0].Content != "dynamic host context" {
66				t.Fatalf("messages = %#v, want developer context as %q", req.Messages, test.want)
67			}
68		})
69	}
70}
71
72func TestBedrockDeveloperContextFollowsStableCacheBoundary(t *testing.T) {
73	req, err := (&bedrockClient{region: "us-east-1"}).buildRequest(Request{
74		Model:  "anthropic.claude-sonnet-4-5-20250929-v1:0",
75		System: "stable instructions",
76		Messages: []Message{
77			{Role: RoleDeveloper, Content: []Content{TextBlock{Text: "dynamic host context"}}},
78			{Role: RoleUser, Content: []Content{TextBlock{Text: "user task"}}},
79		},
80	})
81	if err != nil {
82		t.Fatal(err)
83	}
84	if len(req.System) != 3 || req.System[0]["text"] != "stable instructions" || req.System[1]["cachePoint"] == nil || req.System[2]["text"] != "dynamic host context" {
85		t.Fatalf("system blocks = %#v", req.System)
86	}
87}

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