Skip to content

Self-hosted workflows for coding-agent delivery. Orchestrate CodeBuddy, Codex and Claude Code with scripts and human approval gates. Includes Local workflows for coding assistants.

refactor(httpapi): use builtin max instead of maxInt64/maxFloat/maxInt in space_lanes (#266)

fx-kurumi3768251472e6
diff --git a/internal/httpapi/space_lanes.go b/internal/httpapi/space_lanes.go
index 25730271..95389b30 100644
--- a/internal/httpapi/space_lanes.go
+++ b/internal/httpapi/space_lanes.go
@@ -228,7 +228,7 @@ func (h *spacesHandlers) lane(c *gin.Context) {
fillLane(&detail.spaceLane, run, h.agentNamer())
if view, ok := h.repo.RunView(runID); ok {
// RunState carries raw usage only; RunView aggregates it.
- detail.Tokens, detail.CostUSD, detail.ToolCalls = maxInt64(detail.Tokens, view.Usage.TotalTokens), maxFloat(detail.CostUSD, view.Usage.CostUSD), maxInt(detail.ToolCalls, view.ToolCalls)
+ detail.Tokens, detail.CostUSD, detail.ToolCalls = max(detail.Tokens, view.Usage.TotalTokens), max(detail.CostUSD, view.Usage.CostUSD), max(detail.ToolCalls, view.ToolCalls)
}
detail.Workspace = h.laneWorkspace(run)
events := run.Events
@@ -244,27 +244,6 @@ func (h *spacesHandlers) lane(c *gin.Context) {
c.JSON(http.StatusOK, detail)
}
-func maxInt64(a, b int64) int64 {
- if b > a {
- return b
- }
- return a
-}
-
-func maxFloat(a, b float64) float64 {
- if b > a {
- return b
- }
- return a
-}
-
-func maxInt(a, b int) int {
- if b > a {
- return b
- }
- return a
-}
-
// startSOPs dispatches SOPs from the space. Inputs pin the artifact versions
// the lanes start from and are appended to the issue description so every
// agent reads the same spec.
diff --git a/internal/httpapi/spaces_cases_test.go b/internal/httpapi/spaces_cases_test.go
index 642afe63..805c5f34 100644
--- a/internal/httpapi/spaces_cases_test.go
+++ b/internal/httpapi/spaces_cases_test.go
@@ -235,9 +235,6 @@ func TestSpaceLaneProjectionAndUtilityBranches(t *testing.T) {
if ws = h.laneWorkspace(run); ws.State != "cleaned" {
t.Fatalf("cleaned workspace: %+v", ws)
}
- if maxInt64(1, 2) != 2 || maxInt64(2, 1) != 2 || maxFloat(1, 2) != 2 || maxFloat(2, 1) != 2 || maxInt(1, 2) != 2 || maxInt(2, 1) != 2 {
- t.Fatal("max helpers")
- }
if got := withInputs(strings.Repeat("x", 7990), []string{"line"}); len([]rune(got)) > 8000 || !strings.HasSuffix(got, "…") {
t.Fatalf("withInputs clipping len=%d suffix=%q", len([]rune(got)), got[len(got)-3:])
}