Skip to content

Commit ad14d61

Browse files
committed
fix(agent): Make claudeModelsByID available on non-unix platforms
The Windows CI lint-backend step failed with `undefined: claudeModelsByID` because the helper was defined in claude_test.go, which carries a `//go:build unix` constraint, while the platform-agnostic claude_livesettings_test.go calls it. On Windows the unix file is excluded, so the symbol was missing and the test build failed. Move claudeModelsByID into the unconstrained claude_mockhelpers_test.go so it compiles on every platform while staying available to the unix tests.
1 parent 8106ab7 commit ad14d61

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

backend/internal/worker/agent/claude_mockhelpers_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"context"
55
"os"
66
"os/exec"
7+
8+
leapmuxv1 "github.com/leapmux/leapmux/generated/proto/leapmux/v1"
79
)
810

911
// spawnMockClaudeAgent spawns os.Args[0] with -test.run=testRun as a mock
@@ -16,3 +18,15 @@ func spawnMockClaudeAgent(ctx context.Context, testRun string, extraEnv []string
1618
cmd.Env = append(os.Environ(), extraEnv...)
1719
return wireClaudeMockAgent(ctx, cancel, cmd, opts, sink)
1820
}
21+
22+
// claudeModelsByID indexes converted available models by their ID for
23+
// order-independent assertions. It lives here, outside the unix-only
24+
// claude_test.go, so tests that run on every platform (e.g. the live-settings
25+
// control-response tests) can use it without dragging in unix build tags.
26+
func claudeModelsByID(models []*leapmuxv1.AvailableModel) map[string]*leapmuxv1.AvailableModel {
27+
byID := make(map[string]*leapmuxv1.AvailableModel, len(models))
28+
for _, m := range models {
29+
byID[m.Id] = m
30+
}
31+
return byID
32+
}

backend/internal/worker/agent/claude_test.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1983,14 +1983,6 @@ func claudeEffortIDsFromList(efforts []*leapmuxv1.AvailableEffort) []string {
19831983
return ids
19841984
}
19851985

1986-
func claudeModelsByID(models []*leapmuxv1.AvailableModel) map[string]*leapmuxv1.AvailableModel {
1987-
byID := make(map[string]*leapmuxv1.AvailableModel, len(models))
1988-
for _, m := range models {
1989-
byID[m.Id] = m
1990-
}
1991-
return byID
1992-
}
1993-
19941986
func TestConvertClaudeModels(t *testing.T) {
19951987
models := []claudeCodeModelInfo{
19961988
{Value: "default", DisplayName: "Default (recommended)", Description: "the account default", SupportsEffort: true, SupportedEffortLevels: claudeXHighLevels},

0 commit comments

Comments
 (0)