Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(daemon): detect Codex Desktop bundle CLI (#3332)

DENG7bc1aa756386
diff --git a/server/internal/daemon/config.go b/server/internal/daemon/config.go
index ff129d584a..a4722a9992 100644
--- a/server/internal/daemon/config.go
+++ b/server/internal/daemon/config.go
@@ -31,16 +31,16 @@ const (
// daemon-visible activity — see MUL-2300. 30 min keeps the safety net for
// truly stuck runs (dockerd hang) while leaving headroom for long writes.
// Set MULTICA_AGENT_IDLE_WATCHDOG=0 to disable.
- DefaultAgentIdleWatchdog = 30 * time.Minute
- DefaultRuntimeName = "Local Agent"
- DefaultWorkspaceSyncInterval = 30 * time.Second
- DefaultHealthPort = 19514
- DefaultMaxConcurrentTasks = 20
- DefaultGCInterval = 1 * time.Hour
- DefaultGCTTL = 24 * time.Hour // 1 day — AI-coding issues rarely stay open long
- DefaultGCOrphanTTL = 72 * time.Hour // 3 days — orphans with no meta (crashes, pre-GC leftovers)
- DefaultGCArtifactTTL = 12 * time.Hour // 12h — drop regenerable artifacts on completed but still-open issues
- DefaultAutoUpdateCheckInterval = 6 * time.Hour // how often the daemon polls GitHub for a newer CLI release
+ DefaultAgentIdleWatchdog = 30 * time.Minute
+ DefaultRuntimeName = "Local Agent"
+ DefaultWorkspaceSyncInterval = 30 * time.Second
+ DefaultHealthPort = 19514
+ DefaultMaxConcurrentTasks = 20
+ DefaultGCInterval = 1 * time.Hour
+ DefaultGCTTL = 24 * time.Hour // 1 day — AI-coding issues rarely stay open long
+ DefaultGCOrphanTTL = 72 * time.Hour // 3 days — orphans with no meta (crashes, pre-GC leftovers)
+ DefaultGCArtifactTTL = 12 * time.Hour // 12h — drop regenerable artifacts on completed but still-open issues
+ DefaultAutoUpdateCheckInterval = 6 * time.Hour // how often the daemon polls GitHub for a newer CLI release
)
// DefaultGCArtifactPatterns lists basename matches that the GC loop treats as
@@ -164,6 +164,18 @@ func LoadConfig(overrides Overrides) (Config, error) {
Model: strings.TrimSpace(os.Getenv(modelEnv)),
}, true
}
+ if defaultCmd == "codex" && cmd == defaultCmd {
+ // Codex Desktop bundles its CLI inside the macOS app instead of
+ // installing it onto PATH.
+ for _, p := range codexDesktopAppBundlePaths() {
+ if _, err := os.Stat(p); err == nil {
+ return AgentEntry{
+ Path: p,
+ Model: strings.TrimSpace(os.Getenv(modelEnv)),
+ }, true
+ }
+ }
+ }
return AgentEntry{}, false
}
@@ -540,6 +552,16 @@ var defaultAgentCommandNames = []string{
"gemini", "pi", "cursor-agent", "copilot", "kimi", "kiro-cli",
}
+var codexDesktopAppBundlePaths = func() []string {
+ paths := []string{
+ "/Applications/Codex.app/Contents/Resources/codex",
+ }
+ if home, err := os.UserHomeDir(); err == nil {
+ paths = append(paths, filepath.Join(home, "Applications", "Codex.app", "Contents", "Resources", "codex"))
+ }
+ return paths
+}
+
// loginShellResolveTimeout caps how long the daemon will wait for the user's
// login shell to print canonical agent paths. A broken rc file should not
// block startup — if the shell takes longer than this, we proceed without
diff --git a/server/internal/daemon/config_test.go b/server/internal/daemon/config_test.go
index 7f41f33f05..39ac509690 100644
--- a/server/internal/daemon/config_test.go
+++ b/server/internal/daemon/config_test.go
@@ -499,3 +499,98 @@ func TestLoadConfig_SkipsLoginShellWhenLookPathSucceeds(t *testing.T) {
t.Fatalf("unexpected error stat-ing marker file: %v", err)
}
}
+
+func TestLoadConfig_UsesCodexDesktopAppBundleFallback(t *testing.T) {
+ pathDir := t.TempDir()
+ fakeCodex := filepath.Join(pathDir, "Codex.app", "Contents", "Resources", "codex")
+ if err := os.MkdirAll(filepath.Dir(fakeCodex), 0o755); err != nil {
+ t.Fatalf("mkdir fake Codex bundle: %v", err)
+ }
+ if err := os.WriteFile(fakeCodex, []byte("#!/bin/sh\nexit 0\n"), 0o755); err != nil {
+ t.Fatalf("write fake Codex bundle CLI: %v", err)
+ }
+
+ oldBundlePaths := codexDesktopAppBundlePaths
+ codexDesktopAppBundlePaths = func() []string { return []string{fakeCodex} }
+ t.Cleanup(func() { codexDesktopAppBundlePaths = oldBundlePaths })
+
+ t.Setenv("PATH", t.TempDir())
+ t.Setenv("SHELL", filepath.Join(t.TempDir(), "fish"))
+ t.Setenv("MULTICA_DAEMON_ID", "11111111-1111-1111-1111-111111111111")
+ t.Setenv("MULTICA_CODEX_MODEL", "gpt-5")
+ pinNonCodexAgentsToMissingPaths(t)
+
+ cfg, err := LoadConfig(Overrides{
+ ServerURL: "http://localhost:0",
+ WorkspacesRoot: t.TempDir(),
+ })
+ if err != nil {
+ t.Fatalf("LoadConfig: %v", err)
+ }
+ got, ok := cfg.Agents["codex"]
+ if !ok {
+ t.Fatalf("expected codex agent from Desktop app bundle fallback, got %#v", cfg.Agents)
+ }
+ if got.Path != fakeCodex {
+ t.Fatalf("codex path = %q, want %q", got.Path, fakeCodex)
+ }
+ if got.Model != "gpt-5" {
+ t.Fatalf("codex model = %q, want gpt-5", got.Model)
+ }
+}
+
+func TestLoadConfig_CodexDesktopFallbackDoesNotOverrideExplicitPath(t *testing.T) {
+ pathDir := t.TempDir()
+ fakeCodex := filepath.Join(pathDir, "Codex.app", "Contents", "Resources", "codex")
+ if err := os.MkdirAll(filepath.Dir(fakeCodex), 0o755); err != nil {
+ t.Fatalf("mkdir fake Codex bundle: %v", err)
+ }
+ if err := os.WriteFile(fakeCodex, []byte("#!/bin/sh\nexit 0\n"), 0o755); err != nil {
+ t.Fatalf("write fake Codex bundle CLI: %v", err)
+ }
+
+ oldBundlePaths := codexDesktopAppBundlePaths
+ codexDesktopAppBundlePaths = func() []string { return []string{fakeCodex} }
+ t.Cleanup(func() { codexDesktopAppBundlePaths = oldBundlePaths })
+
+ t.Setenv("PATH", t.TempDir())
+ t.Setenv("SHELL", filepath.Join(t.TempDir(), "fish"))
+ t.Setenv("MULTICA_DAEMON_ID", "11111111-1111-1111-1111-111111111111")
+ t.Setenv("MULTICA_CODEX_PATH", filepath.Join(t.TempDir(), "missing-codex"))
+ pinNonCodexAgentsToMissingPaths(t)
+ fakeClaude := filepath.Join(t.TempDir(), "claude")
+ if err := os.WriteFile(fakeClaude, []byte("#!/bin/sh\nexit 0\n"), 0o755); err != nil {
+ t.Fatalf("write fake claude: %v", err)
+ }
+ t.Setenv("MULTICA_CLAUDE_PATH", fakeClaude)
+
+ cfg, err := LoadConfig(Overrides{
+ ServerURL: "http://localhost:0",
+ WorkspacesRoot: t.TempDir(),
+ })
+ if err != nil {
+ t.Fatalf("LoadConfig: %v", err)
+ }
+ if got, ok := cfg.Agents["codex"]; ok {
+ t.Fatalf("explicit missing MULTICA_CODEX_PATH should not fall back to Desktop bundle, got %#v", got)
+ }
+}
+
+func pinNonCodexAgentsToMissingPaths(t *testing.T) {
+ t.Helper()
+ missingDir := t.TempDir()
+ for _, name := range []string{
+ "MULTICA_CLAUDE_PATH",
+ "MULTICA_OPENCODE_PATH",
+ "MULTICA_OPENCLAW_PATH",
+ "MULTICA_HERMES_PATH",
+ "MULTICA_GEMINI_PATH",
+ "MULTICA_PI_PATH",
+ "MULTICA_CURSOR_PATH",
+ "MULTICA_COPILOT_PATH",
+ "MULTICA_KIMI_PATH",
+ "MULTICA_KIRO_PATH",
+ } {
+ t.Setenv(name, filepath.Join(missingDir, strings.ToLower(name)))
+ }
+}