v0.2.99 4d92b3d

usermodels_test.go RawHistoryFolder

1package provider
2
3import (
4	"os"
5	"path/filepath"
6	"strings"
7	"testing"
8)
9
10func TestSetUserModelsPreservesCatalogWithoutLiveOverlay(t *testing.T) {
11	SetLiveModels(nil)
12	t.Cleanup(func() { SetLiveModels(nil) })
13
14	SetUserModels([]Model{{
15		Provider:    "custom-test",
16		ID:          "custom-model",
17		DisplayName: "Custom Model",
18		Source:      "user",
19	}})
20
21	if _, err := FindModel("anthropic", "claude-sonnet-4-5"); err != nil {
22		t.Fatalf("built-in model hidden after SetUserModels: %v", err)
23	}
24	if _, err := FindModel("custom-test", "custom-model"); err != nil {
25		t.Fatalf("custom model missing after SetUserModels: %v", err)
26	}
27}
28
29func TestLoadUserModelsRegistersModelLevelBaseURLCustomProvider(t *testing.T) {
30	dir := t.TempDir()
31	path := filepath.Join(dir, "models.json")
32	if err := os.WriteFile(path, []byte(`{
33		"providers": {
34			"model-base-only": {
35				"models": [
36					{"id": "m1", "baseUrl": "https://llm.example.com/v1"}
37				]
38			}
39		}
40	}`), 0o644); err != nil {
41		t.Fatal(err)
42	}
43
44	models, warnings := LoadUserModelsWithWarnings(path)
45	if len(warnings) != 0 {
46		t.Fatalf("warnings = %v, want none", warnings)
47	}
48	if len(models) != 1 {
49		t.Fatalf("models = %d, want 1", len(models))
50	}
51	cfg, ok := CustomProviders()["model-base-only"]
52	if !ok {
53		t.Fatal("custom provider was not registered")
54	}
55	if cfg.API != "openai" {
56		t.Fatalf("api = %q, want openai", cfg.API)
57	}
58}
59
60func TestLoadUserModelsWarnsOnUnknownAPI(t *testing.T) {
61	dir := t.TempDir()
62	path := filepath.Join(dir, "models.json")
63	if err := os.WriteFile(path, []byte(`{
64		"providers": {
65			"bad-api": {
66				"baseUrl": "https://llm.example.com/v1",
67				"api": "anthropic-message",
68				"models": [{"id": "m1"}]
69			}
70		}
71	}`), 0o644); err != nil {
72		t.Fatal(err)
73	}
74
75	_, warnings := LoadUserModelsWithWarnings(path)
76	if len(warnings) != 1 || !strings.Contains(warnings[0], "unknown api") {
77		t.Fatalf("warnings = %v, want unknown api warning", warnings)
78	}
79	if cfg := CustomProviders()["bad-api"]; cfg.API != "openai" {
80		t.Fatalf("api = %q, want openai", cfg.API)
81	}
82}

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