Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.
fix(computer): format Claude model labels from structured fields only
chendongdong0e25af3ebd16
diff --git a/apps/computer/local-daemon/internal/provider/native/catalog_claude.go b/apps/computer/local-daemon/internal/provider/native/catalog_claude.goindex b1187ef4..2fefad29 100644--- a/apps/computer/local-daemon/internal/provider/native/catalog_claude.go+++ b/apps/computer/local-daemon/internal/provider/native/catalog_claude.go@@ -25,7 +25,6 @@ type claudeCatalogModel struct {Value string `json:"value"`ResolvedModel string `json:"resolvedModel"`DisplayName string `json:"displayName"`- Description string `json:"description"`SupportedEffortLevels []string `json:"supportedEffortLevels"`SupportsEffort *bool `json:"supportsEffort"`}@@ -89,7 +88,7 @@ func claudeCatalog(ctx context.Context, inv Invocation) (ModelList, error) {efforts.add(level, "")}}- option := ModelOption{ID: id, Label: claudeModelLabel(entry), Provider: "anthropic", Default: entry.Value == "default", Effort: efforts.support("")}+ option := ModelOption{ID: id, Label: claudeModelLabel(id, entry), Provider: "anthropic", Default: entry.Value == "default", Effort: efforts.support("")}if entry.ResolvedModel != id {option.Resolved = entry.ResolvedModel}@@ -110,19 +109,51 @@ func claudeCatalog(ctx context.Context, inv Invocation) (ModelList, error) {if len(models.models) == 0 {return ModelList{}, errors.New("Claude initialized without a selectable model catalog")}- return models.list(), nil+ list := models.list()+ disambiguateModelLabels(list.Models)+ return list, nil}-// The native picker puts the concrete version in its description, while the-// display name is only a family label. This formatting never selects a model.-func claudeModelLabel(entry claudeCatalogModel) string {+// claudeModelLabel formats a Claude catalog entry using only structured fields+// (displayName, id, and resolvedModel). Free-form description prose varies+// across Anthropic first-party, cloud hosts, and third-party gateways, so it is+// never parsed into the display label. When id is an alias for a different+// concrete model, the resolved model id is appended unless the display name+// already contains it. This formatting never selects a model.+func claudeModelLabel(id string, entry claudeCatalogModel) string {label := strings.TrimSpace(entry.DisplayName)- summary, _, _ := strings.Cut(strings.TrimSpace(entry.Description), " · ")- if summary == "" {- return label+ if label == "" {+ return ""}- if entry.Value == "default" && label != "" {- return label + " · " + summary+ resolved := strings.TrimSpace(entry.ResolvedModel)+ if validCatalogToken(resolved) && claudeIsAlias(id, resolved) && !strings.Contains(strings.ToLower(label), strings.ToLower(resolved)) {+ return label + " · " + resolved+ }+ return label+}++// claudeIsAlias reports whether id selects resolved through an alias rather+// than naming resolved directly (or with a bracket modifier such as "[1m]").+func claudeIsAlias(id, resolved string) bool {+ if id == resolved {+ return false+ }+ if strings.HasPrefix(id, resolved+"[") && strings.HasSuffix(id, "]") {+ return false+ }+ return true+}++// disambiguateModelLabels appends the selectable id to entries that share the+// same display label so distinct models remain distinguishable.+func disambiguateModelLabels(models []ModelOption) {+ counts := make(map[string]int, len(models))+ for _, model := range models {+ counts[model.Label]+++ }+ for i := range models {+ if counts[models[i].Label] > 1 && models[i].Label != models[i].ID {+ models[i].Label += " (" + models[i].ID + ")"+ }}- return summary}diff --git a/apps/computer/local-daemon/internal/provider/native/catalog_test.go b/apps/computer/local-daemon/internal/provider/native/catalog_test.goindex ae1b903e..c531a4f9 100644--- a/apps/computer/local-daemon/internal/provider/native/catalog_test.go+++ b/apps/computer/local-daemon/internal/provider/native/catalog_test.go@@ -18,7 +18,7 @@ func TestClaudeCatalog(t *testing.T) {t.Fatalf("models = %+v", list.Models)}first, second := list.Models[0], list.Models[1]- if first.ID != "organization-alias" || first.Default || first.Label != "Organization" || first.Provider != "anthropic" {+ if first.ID != "organization-alias" || first.Default || first.Label != "Organization · organization-model" || first.Provider != "anthropic" {t.Fatalf("first = %+v", first)}if first.Effort == nil || first.Effort.Default != "" ||@@ -121,7 +121,7 @@ func TestClaudeCatalogPreservesNativeChoicesAndVersions(t *testing.T) {}wantIDs := []string{"default", "opus", "claude-fable-5-1[1m]", "sonnet", "custom-future", "no-description", "resolved-only","claude-opus-5-5", "claude-fable-5-1", "claude-sonnet-5-5", "organization-model"}- wantLabels := []string{"Default (recommended) · Use the default model (currently Opus 5.5)", "Opus 5.5", "Fable 5.1", "Sonnet 5.5", "Organization 42", "Fallback", "Resolved only",+ wantLabels := []string{"Default (recommended) · claude-opus-5-5", "Opus · claude-opus-5-5", "Fable", "Sonnet · claude-sonnet-5-5", "Custom · organization-model", "Fallback", "Resolved only","claude-opus-5-5", "claude-fable-5-1", "claude-sonnet-5-5", "organization-model"}if !reflect.DeepEqual(ids, wantIDs) || !reflect.DeepEqual(labels, wantLabels) {t.Fatalf("models = %+v", list.Models)@@ -148,3 +148,43 @@ func TestClaudeCatalogPreservesNativeChoicesAndVersions(t *testing.T) {t.Fatalf("concrete choice = %+v", pinned)}}++func TestClaudeCatalogFormatsStructuredLabelsAndDisambiguatesDuplicates(t *testing.T) {+ list, err := DiscoverModels(context.Background(), "claude", fixtureInvocation(t, "claude-catalog", map[string]string{+ "FIXTURE_MODELS": `[+ {"value":"auto/deepseek[1m]","resolvedModel":"auto/deepseek[1m]","displayName":"DeepSeek Flash · routing group","description":"via gateway"},+ {"value":"cursor/grok@500k","resolvedModel":"cursor/grok@500k","displayName":"Grok @ 500k · Cursor","description":"[email protected] · via gateway"},+ {"value":"sub2api/claude-opus[1m]","resolvedModel":"sub2api/claude-opus","displayName":"Claude Opus · Sub2API","description":"via gateway"},+ {"value":"custom-alias","resolvedModel":"org-model","displayName":"Org-Model (custom)","description":"Custom model"},+ {"value":"us.anthropic.claude-sonnet-v1:0","resolvedModel":"us.anthropic.claude-sonnet-v1:0","displayName":"Claude Sonnet","description":"Best for complex coding tasks"},+ {"value":"raw-id","resolvedModel":"raw-id","displayName":"","description":"Some tagline"},+ {"value":"provider-a/gpt-5","resolvedModel":"provider-a/gpt-5","displayName":"GPT-5","description":"via provider A"},+ {"value":"provider-b/gpt-5","resolvedModel":"provider-b/gpt-5","displayName":"GPT-5","description":"via provider B"},+ {"value":"alias-x","resolvedModel":"model-x","displayName":"model-x","description":"ignored"}+ ]`,+ }))+ if err != nil {+ t.Fatal(err)+ }+ var got []string+ for _, model := range list.Models {+ got = append(got, model.Label)+ }+ want := []string{+ "DeepSeek Flash · routing group",+ "Grok @ 500k · Cursor",+ "Claude Opus · Sub2API",+ "Org-Model (custom)",+ "Claude Sonnet",+ "raw-id",+ "GPT-5 (provider-a/gpt-5)",+ "GPT-5 (provider-b/gpt-5)",+ "model-x (alias-x)",+ "sub2api/claude-opus",+ "org-model",+ "model-x",+ }+ if !reflect.DeepEqual(got, want) {+ t.Fatalf("labels = %q, want %q", got, want)+ }+}