Skip to content

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

Go

MUL-7384: fix(onboarding): require confirmed daemon setup targets (#8907)

Nassreddinlrac673fbf1923
diff --git a/packages/core/api/schema.test.ts b/packages/core/api/schema.test.ts
index beee178890..9a0c3d1abf 100644
--- a/packages/core/api/schema.test.ts
+++ b/packages/core/api/schema.test.ts
@@ -901,6 +901,36 @@ describe("ApiClient schema fallback", () => {
});
describe("getConfig", () => {
+ it("preserves an omitted daemon setup target for legacy self-host detection", async () => {
+ stubFetchJson({
+ daemon_server_url: "https://api.example.com",
+ daemon_app_url: "https://app.example.com",
+ });
+ const config = await new ApiClient("https://api.example.test").getConfig();
+ expect(config.daemon_setup_target).toBeUndefined();
+ expect(config.daemon_server_url).toBe("https://api.example.com");
+ expect(config.daemon_app_url).toBe("https://app.example.com");
+ });
+
+ it.each([null, 123, {}, "unexpected", "unknown"])(
+ "does not infer Cloud from an unrecognized daemon setup target: %j",
+ async (target) => {
+ stubFetchJson({
+ daemon_setup_target: target,
+ daemon_server_url: "https://api.example.com",
+ daemon_app_url: "https://app.example.com",
+ });
+ const config = await new ApiClient("https://api.example.test").getConfig();
+ expect(config.daemon_setup_target).toBe("unknown");
+ },
+ );
+
+ it.each(["cloud", "self_host"])("preserves the confirmed daemon setup target %s", async (target) => {
+ stubFetchJson({ cdn_domain: "", daemon_setup_target: target });
+ const config = await new ApiClient("https://api.example.test").getConfig();
+ expect(config.daemon_setup_target).toBe(target);
+ });
+
it("drops malformed daemon setup URLs instead of throwing", async () => {
stubFetchJson({
cdn_domain: "cdn.example.com",
diff --git a/packages/core/api/schemas.ts b/packages/core/api/schemas.ts
index 7a618e5640..4ca8ec31d9 100644
--- a/packages/core/api/schemas.ts
+++ b/packages/core/api/schemas.ts
@@ -881,6 +881,7 @@ export interface AppConfigResponse {
analytics_environment?: string;
daemon_server_url?: string;
daemon_app_url?: string;
+ daemon_setup_target?: "cloud" | "self_host" | "unknown";
workspace_creation_disabled?: boolean;
/** Whether this deployment offers the self-hosted Git provider integration
* (self-host only; off on the managed cloud). Absent/false hides the whole
@@ -1158,6 +1159,7 @@ export const AppConfigSchema = z.object({
analytics_environment: OptionalStringSchema,
daemon_server_url: OptionalStringSchema,
daemon_app_url: OptionalStringSchema,
+ daemon_setup_target: z.enum(["cloud", "self_host", "unknown"]).optional().catch("unknown"),
workspace_creation_disabled: BooleanWithDefaultSchema(false).optional(),
vcs_integration_available: BooleanWithDefaultSchema(false).optional(),
feature_flags: FeatureFlagsSchema,
@@ -1176,6 +1178,7 @@ export const EMPTY_APP_CONFIG: AppConfigResponse = {
google_client_id: "",
daemon_server_url: "",
daemon_app_url: "",
+ daemon_setup_target: "unknown",
workspace_creation_disabled: false,
vcs_integration_available: false,
// Fail closed: an unreadable config must not look like a server that
diff --git a/packages/core/config/index.ts b/packages/core/config/index.ts
index 94aae1dfc9..3a1278a414 100644
--- a/packages/core/config/index.ts
+++ b/packages/core/config/index.ts
@@ -1,5 +1,6 @@
import { createStore } from "zustand/vanilla";
import { useStore } from "zustand";
+import type { DaemonConfigStatus, DaemonSetupTarget } from "../runtimes/commands";
interface ConfigState {
cdnDomain: string;
@@ -12,6 +13,8 @@ interface ConfigState {
googleClientId: string;
daemonServerUrl: string;
daemonAppUrl: string;
+ daemonConfigStatus: DaemonConfigStatus;
+ daemonSetupTarget: DaemonSetupTarget;
// Self-host gate (#3433): when true, every "Create workspace" affordance
// must be hidden. Defaults to false so unknown / older servers behave like
// the managed-cloud case.
@@ -55,7 +58,9 @@ interface ConfigState {
setDaemonConfig: (config: {
daemonServerUrl?: string;
daemonAppUrl?: string;
+ daemonSetupTarget?: DaemonSetupTarget;
}) => void;
+ setDaemonConfigStatus: (status: DaemonConfigStatus) => void;
setFeatureFlags: (flags?: Record<string, boolean>) => void;
setServerVersion: (version?: string) => void;
setLocalWorktreeSupported: (supported?: boolean) => void;
@@ -72,6 +77,8 @@ export const configStore = createStore<ConfigState>((set) => ({
googleClientId: "",
daemonServerUrl: "",
daemonAppUrl: "",
+ daemonConfigStatus: "loading",
+ daemonSetupTarget: "unknown",
workspaceCreationDisabled: false,
vcsIntegrationAvailable: false,
featureFlags: {},
@@ -88,8 +95,17 @@ export const configStore = createStore<ConfigState>((set) => ({
workspaceCreationDisabled = false,
vcsIntegrationAvailable = false,
}) => set({ allowSignup, googleClientId, workspaceCreationDisabled, vcsIntegrationAvailable }),
- setDaemonConfig: ({ daemonServerUrl = "", daemonAppUrl = "" }) =>
- set({ daemonServerUrl, daemonAppUrl }),
+ setDaemonConfig: ({
+ daemonServerUrl = "",
+ daemonAppUrl = "",
+ daemonSetupTarget = "unknown",
+ }) => set({
+ daemonServerUrl,
+ daemonAppUrl,
+ daemonSetupTarget,
+ daemonConfigStatus: "ready",
+ }),
+ setDaemonConfigStatus: (daemonConfigStatus) => set({ daemonConfigStatus }),
setFeatureFlags: (flags = {}) => set({ featureFlags: { ...flags } }),
setServerVersion: (version = "") => set({ serverVersion: version }),
setLocalWorktreeSupported: (supported = false) =>
diff --git a/packages/core/platform/auth-initializer.test.tsx b/packages/core/platform/auth-initializer.test.tsx
index a3e0fb486a..e5075bbc89 100644
--- a/packages/core/platform/auth-initializer.test.tsx
+++ b/packages/core/platform/auth-initializer.test.tsx
@@ -5,8 +5,9 @@ import { act, render, waitFor } from "@testing-library/react";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { setApiInstance } from "../api";
-import { ApiError, type ApiClient } from "../api/client";
+import { ApiClient, ApiError } from "../api/client";
import { configStore } from "../config";
+import { daemonCommands } from "../runtimes/commands";
import {
createAuthStore,
registerAuthStore,
@@ -75,6 +76,12 @@ function makeApi(overrides: Partial<ApiClient> = {}): ApiClient {
} as unknown as ApiClient;
}
+function makeApiWithConfigResponse(config: unknown): ApiClient {
+ vi.stubGlobal("fetch", vi.fn().mockResolvedValue(new Response(JSON.stringify(config))));
+ const configApi = new ApiClient("https://api.example.test");
+ return makeApi({ getConfig: () => configApi.getConfig() });
+}
+
function renderInitializer({
api,
storage = makeStorage({ multica_token: "token-1" }),
@@ -114,14 +121,155 @@ function renderInitializer({
beforeEach(() => {
vi.clearAllMocks();
+ configStore.setState({
+ daemonConfigStatus: "loading",
+ daemonSetupTarget: "unknown",
+ daemonServerUrl: "",
+ daemonAppUrl: "",
+ });
__clearDraftCleanupRegistryForTest();
});
afterEach(() => {
+ vi.unstubAllGlobals();
vi.useRealTimers();
});
describe("AuthInitializer recovery", () => {
+ it("keeps self-host commands available when an older API omits the target", async () => {
+ renderInitializer({ api: makeApiWithConfigResponse({
+ daemon_server_url: " https://api.example.com/// ",
+ daemon_app_url: "https://app.example.com/",
+ }) });
+
+ await waitFor(() => {
+ expect(configStore.getState().daemonConfigStatus).toBe("ready");
+ });
+ const config = configStore.getState();
+ expect(config.daemonSetupTarget).toBe("self_host");
+ const commands = daemonCommands({
+ status: config.daemonConfigStatus,
+ target: config.daemonSetupTarget,
+ serverUrl: config.daemonServerUrl,
+ appUrl: config.daemonAppUrl,
+ });
+ expect(commands).toMatchObject({
+ status: "ready",
+ setupCmd: "multica setup self-host --server-url https://api.example.com --app-url https://app.example.com",
+ });
+ if (commands.status !== "ready") throw new Error("expected self-host commands");
+ expect(commands.tokenCmd).toContain("server_url https://api.example.com");
+ expect(commands.tokenCmd).toContain("app_url https://app.example.com");
+ expect(commands.tokenCmd).not.toContain("multica.ai");
+ });
+
+ it.each([
+ { name: "both URLs absent", response: {} },
+ { name: "app URL absent", response: { daemon_server_url: "https://api.example.com" } },
+ { name: "server URL absent", response: { daemon_app_url: "https://app.example.com" } },
+ {
+ name: "blank server URL",
+ response: { daemon_server_url: " / ", daemon_app_url: "https://app.example.com" },
+ },
+ {
+ name: "blank app URL",
+ response: { daemon_server_url: "https://api.example.com", daemon_app_url: " " },
+ },
+ {
+ name: "malformed server URL",
+ response: { daemon_server_url: {}, daemon_app_url: "https://app.example.com" },
+ },
+ {
+ name: "malformed app URL",
+ response: { daemon_server_url: "https://api.example.com", daemon_app_url: 123 },
+ },
+ ...["unknown", "future_target", null].map((target) => ({
+ name: `explicit target ${JSON.stringify(target)}`,
+ response: {
+ daemon_setup_target: target,
+ daemon_server_url: "https://api.example.com",
+ daemon_app_url: "https://app.example.com",
+ },
+ })),
+ {
+ name: "unreadable config",
+ response: {
+ cdn_domain: 123,
+ daemon_server_url: "https://api.example.com",
+ daemon_app_url: "https://app.example.com",
+ },
+ },
+ ])("keeps commands unavailable for $name", async ({ response }) => {
+ renderInitializer({ api: makeApiWithConfigResponse(response) });
+ await waitFor(() => {
+ expect(configStore.getState().daemonConfigStatus).toBe("ready");
+ });
+ const config = configStore.getState();
+ expect(config.daemonSetupTarget).toBe("unknown");
+ expect(daemonCommands({
+ status: config.daemonConfigStatus,
+ target: config.daemonSetupTarget,
+ serverUrl: config.daemonServerUrl,
+ appUrl: config.daemonAppUrl,
+ })).toEqual({ status: "unknown" });
+ });
+
+ it("honors an explicit Cloud target even when both URLs are present", async () => {
+ renderInitializer({ api: makeApiWithConfigResponse({
+ daemon_setup_target: "cloud",
+ daemon_server_url: "https://api.example.com",
+ daemon_app_url: "https://app.example.com",
+ }) });
+ await waitFor(() => {
+ expect(configStore.getState().daemonConfigStatus).toBe("ready");
+ });
+ expect(configStore.getState().daemonSetupTarget).toBe("cloud");
+ });
+
+ it("keeps setup unavailable until a delayed config response confirms the target", async () => {
+ let resolveConfig!: (config: Awaited<ReturnType<ApiClient["getConfig"]>>) => void;
+ const getConfig = vi.fn(() => new Promise<Awaited<ReturnType<ApiClient["getConfig"]>>>(
+ (resolve) => { resolveConfig = resolve; },
+ ));
+ renderInitializer({ api: makeApi({ getConfig }) });
+ expect(configStore.getState().daemonConfigStatus).toBe("loading");
+ expect(configStore.getState().daemonSetupTarget).toBe("unknown");
+ await act(async () => resolveConfig({
+ cdn_domain: "",
+ allow_signup: true,
+ daemon_setup_target: "self_host",
+ daemon_server_url: "https://api.example.com",
+ daemon_app_url: "https://app.example.com",
+ }));
+ expect(configStore.getState()).toMatchObject({
+ daemonConfigStatus: "ready",
+ daemonSetupTarget: "self_host",
+ daemonServerUrl: "https://api.example.com",
+ daemonAppUrl: "https://app.example.com",
+ });
+ });
+
+ it("exposes config failure and recovers the setup target on the existing retry", async () => {
+ vi.useFakeTimers();
+ const getConfig = vi.fn()
+ .mockRejectedValueOnce(new TypeError("network unavailable"))
+ .mockResolvedValue({ daemon_setup_target: "cloud" });
+ renderInitializer({ api: makeApi({ getConfig }) });
+ await act(async () => {
+ await Promise.resolve();
+ });
+ expect(configStore.getState().daemonConfigStatus).toBe("error");
+ expect(configStore.getState().daemonSetupTarget).toBe("unknown");
+ await act(async () => {
+ await vi.advanceTimersByTimeAsync(1_000);
+ });
+ expect(getConfig).toHaveBeenCalledTimes(2);
+ expect(configStore.getState()).toMatchObject({
+ daemonConfigStatus: "ready",
+ daemonSetupTarget: "cloud",
+ });
+ });
+
it("publishes the API origin used by persisted attachment links", async () => {
const api = makeApi({
getConfig: vi.fn().mockResolvedValue({
diff --git a/packages/core/platform/auth-initializer.tsx b/packages/core/platform/auth-initializer.tsx
index 6a500f19b6..004c3ba8ec 100644
--- a/packages/core/platform/auth-initializer.tsx
+++ b/packages/core/platform/auth-initializer.tsx
@@ -11,6 +11,7 @@ import {
initAnalytics,
} from "../analytics";
import { configStore } from "../config";
+import { normalizeCommandURL } from "../runtimes/commands";
import { workspaceListOptions } from "../workspace/queries";
import { createLogger } from "../logger";
import { clearClientSessionData } from "./session-cleanup";
@@ -56,6 +57,7 @@ export function AuthInitializer({
if (configLoadedRef.current) return Promise.resolve(true);
if (configRequestRef.current) return configRequestRef.current;
+ configStore.getState().setDaemonConfigStatus("loading");
const request = getApi()
.getConfig()
.then((cfg) => {
@@ -76,9 +78,17 @@ export function AuthInitializer({
// Absent/false on the managed cloud and older servers → section hidden.
vcsIntegrationAvailable: cfg.vcs_integration_available === true,
});
+ // Legacy servers only publish both URLs for self-host. Explicit unknown
+ // or malformed targets stay closed, and absent URLs never imply Cloud.
+ const daemonSetupTarget = cfg.daemon_setup_target ?? (
+ normalizeCommandURL(cfg.daemon_server_url) && normalizeCommandURL(cfg.daemon_app_url)
+ ? "self_host"
+ : "unknown"
+ );
configStore.getState().setDaemonConfig({
daemonServerUrl: cfg.daemon_server_url,
daemonAppUrl: cfg.daemon_app_url,
+ daemonSetupTarget,
});
configStore.getState().setFeatureFlags(cfg.feature_flags);
configStore.getState().setServerVersion(cfg.server_version);
@@ -118,7 +128,10 @@ export function AuthInitializer({
configLoadedRef.current = true;
return true;
})
- .catch(() => false)
+ .catch(() => {
+ configStore.getState().setDaemonConfigStatus("error");
+ return false;
+ })
.finally(() => {
configRequestRef.current = null;
});
diff --git a/packages/core/runtimes/commands.test.ts b/packages/core/runtimes/commands.test.ts
new file mode 100644
index 0000000000..b645d429a0
--- /dev/null
+++ b/packages/core/runtimes/commands.test.ts
@@ -0,0 +1,114 @@
+// @vitest-environment node
+import { describe, expect, it } from "vitest";
+import {
+ daemonCommands,
+ normalizeCommandURL,
+ type DaemonSetupConfig,
+} from "./commands";
+
+describe("normalizeCommandURL", () => {
+ it("trims and strips trailing slashes", () => {
+ expect(normalizeCommandURL(" https://api.example.com/// ")).toBe(
+ "https://api.example.com",
+ );
+ expect(normalizeCommandURL("")).toBe("");
+ expect(normalizeCommandURL(undefined)).toBe("");
+ });
+});
+
+describe("daemonCommands", () => {
+ it("only returns Cloud commands for a confirmed Cloud deployment", () => {
+ const result = daemonCommands({ status: "ready", target: "cloud" });
+ expect(result.status).toBe("ready");
+ if (result.status !== "ready") {
+ throw new Error("expected confirmed Cloud commands");
+ }
+ expect(result.setupCmd).toBe("multica setup");
+ expect(result.tokenCmd).toContain("server_url https://api.multica.ai");
+ expect(result.tokenCmd).toContain("app_url https://multica.ai");
+ });
+
+ it("returns self-host commands with the configured URLs", () => {
+ const result = daemonCommands({
+ status: "ready",
+ target: "self_host",
+ serverUrl: " https://api.example.com/// ",
+ appUrl: "https://app.example.com/",
+ });
+ expect(result.status).toBe("ready");
+ if (result.status !== "ready") {
+ throw new Error("expected self-host commands");
+ }
+ expect(result.setupCmd).toBe(
+ "multica setup self-host --server-url https://api.example.com --app-url https://app.example.com",
+ );
+ expect(result.tokenCmd).toContain(
+ "multica config set server_url https://api.example.com",
+ );
+ expect(result.tokenCmd).toContain(
+ "multica config set app_url https://app.example.com",
+ );
+ expect(result.tokenCmd).not.toContain("multica.ai");
+ });
+
+ it.each<{ name: string; config: DaemonSetupConfig; status: string }>([
+ {
+ name: "initial load",
+ config: { status: "loading", target: "unknown" },
+ status: "loading",
+ },
+ {
+ name: "loading despite a previous target",
+ config: { status: "loading", target: "cloud" },
+ status: "loading",
+ },
+ {
+ name: "request failure",
+ config: { status: "error", target: "unknown" },
+ status: "error",
+ },
+ {
+ name: "failure despite a previous target",
+ config: { status: "error", target: "cloud" },
+ status: "error",
+ },
+ {
+ name: "missing target",
+ config: { status: "ready", target: "unknown" },
+ status: "unknown",
+ },
+ {
+ name: "unknown target with URLs",
+ config: {
+ status: "ready", target: "unknown",
+ serverUrl: "https://api.example.com", appUrl: "https://app.example.com",
+ },
+ status: "unknown",
+ },
+ {
+ name: "missing both self-host URLs",
+ config: { status: "ready", target: "self_host" },
+ status: "incomplete",
+ },
+ {
+ name: "missing app URL",
+ config: { status: "ready", target: "self_host", serverUrl: "https://api.example.com" },
+ status: "incomplete",
+ },
+ {
+ name: "missing server URL",
+ config: { status: "ready", target: "self_host", appUrl: "https://app.example.com" },
+ status: "incomplete",
+ },
+ {
+ name: "blank self-host URL",
+ config: {
+ status: "ready", target: "self_host",
+ serverUrl: " / ", appUrl: "https://app.example.com",
+ },
+ status: "incomplete",
+ },
+ ])("offers no setup or token command for $name", ({ config, status }) => {
+ expect(daemonCommands(config)).toEqual({ status });
+ });
+});
diff --git a/packages/core/runtimes/commands.ts b/packages/core/runtimes/commands.ts
new file mode 100644
index 0000000000..f94ecb5b2b
--- /dev/null
+++ b/packages/core/runtimes/commands.ts
@@ -0,0 +1,49 @@
+export const CLOUD_SERVER_URL = "https://api.multica.ai";
+export const CLOUD_APP_URL = "https://multica.ai";
+
+export function normalizeCommandURL(url: string | undefined): string {
+ return url?.trim().replace(/\/+$/, "") ?? "";
+}
+
+export type DaemonSetupTarget = "cloud" | "self_host" | "unknown";
+export type DaemonConfigStatus = "loading" | "ready" | "error";
+
+export interface DaemonSetupConfig {
+ status: DaemonConfigStatus;
+ target: DaemonSetupTarget;
+ serverUrl?: string;
+ appUrl?: string;
+}
+
+export type DaemonCommands =
+ | { status: "ready"; setupCmd: string; tokenCmd: string }
+ | { status: "loading" | "error" | "unknown" | "incomplete" };
+
+export function daemonCommands(config: DaemonSetupConfig): DaemonCommands {
+ if (config.status !== "ready") return { status: config.status };
+
+ if (config.target === "self_host") {
+ const normalizedServerUrl = normalizeCommandURL(config.serverUrl);
+ const normalizedAppUrl = normalizeCommandURL(config.appUrl);
+ if (!normalizedServerUrl || !normalizedAppUrl) return { status: "incomplete" };
+ return {
+ status: "ready",
+ setupCmd: `multica setup self-host --server-url ${normalizedServerUrl} --app-url ${normalizedAppUrl}`,
+ tokenCmd: `multica config set server_url ${normalizedServerUrl}
+multica config set app_url ${normalizedAppUrl}
+multica login --token <YOUR_TOKEN>
+multica daemon start`,
+ };
+ }
+
+ // Empty URLs are also returned by misconfigured self-hosted servers.
+ if (config.target !== "cloud") return { status: "unknown" };
+ return {
+ status: "ready",
+ setupCmd: "multica setup",
+ tokenCmd: `multica config set server_url ${CLOUD_SERVER_URL}
+multica config set app_url ${CLOUD_APP_URL}
+multica login --token <YOUR_TOKEN>
+multica daemon start`,
+ };
+}
diff --git a/packages/core/runtimes/index.ts b/packages/core/runtimes/index.ts
index 69661e26b4..fdcb4bc16f 100644
--- a/packages/core/runtimes/index.ts
+++ b/packages/core/runtimes/index.ts
@@ -11,3 +11,5 @@ export * from "./use-runtime-health";
export * from "./cli-version";
export * from "./custom-pricing-store";
export * from "./cloud-runtime";
+export * from "./commands";
+export * from "./use-daemon-setup-commands";
diff --git a/packages/core/runtimes/use-daemon-setup-commands.ts b/packages/core/runtimes/use-daemon-setup-commands.ts
new file mode 100644
index 0000000000..a840137aa9
--- /dev/null
+++ b/packages/core/runtimes/use-daemon-setup-commands.ts
@@ -0,0 +1,10 @@
+import { useConfigStore } from "../config";
+import { daemonCommands } from "./commands";
+
+export function useDaemonSetupCommands() {
+ const status = useConfigStore((s) => s.daemonConfigStatus);
+ const target = useConfigStore((s) => s.daemonSetupTarget);
+ const serverUrl = useConfigStore((s) => s.daemonServerUrl);
+ const appUrl = useConfigStore((s) => s.daemonAppUrl);
+ return daemonCommands({ status, target, serverUrl, appUrl });
+}
diff --git a/packages/views/common/daemon-setup-notice.tsx b/packages/views/common/daemon-setup-notice.tsx
new file mode 100644
index 0000000000..b8b50f3546
--- /dev/null
+++ b/packages/views/common/daemon-setup-notice.tsx
@@ -0,0 +1,18 @@
+import type { DaemonCommands } from "@multica/core/runtimes";
+import { useT } from "../i18n";
+
+export function DaemonSetupNotice({
+ status,
+}: {
+ status: Exclude<DaemonCommands["status"], "ready">;
+}) {
+ const { t } = useT("common");
+ return (
+ <p
+ role={status === "loading" ? "status" : "alert"}
+ className="text-caption text-muted-foreground"
+ >
+ {t(($) => $.daemon_setup[status])}
+ </p>
+ );
+}
diff --git a/packages/views/locales/en/common.json b/packages/views/locales/en/common.json
index 30551f3362..f32986bd07 100644
--- a/packages/views/locales/en/common.json
+++ b/packages/views/locales/en/common.json
@@ -1,4 +1,10 @@
{
+ "daemon_setup": {
+ "loading": "Loading connection settings...",
+ "error": "Couldn't load connection settings. Check your connection; retrying automatically.",
+ "unknown": "This server hasn't confirmed its connection settings. Ask your administrator to update the server.",
+ "incomplete": "Connection settings are incomplete. Ask your administrator to configure this server's public URLs."
+ },
"avatar_upload": {
"change": "Change avatar",
"remove": "Remove",
diff --git a/packages/views/locales/fr/common.json b/packages/views/locales/fr/common.json
index 68301bb14f..4b5c3796dd 100644
--- a/packages/views/locales/fr/common.json
+++ b/packages/views/locales/fr/common.json
@@ -1,4 +1,10 @@
{
+ "daemon_setup": {
+ "loading": "Chargement des paramètres de connexion...",
+ "error": "Impossible de charger les paramètres de connexion. Vérifiez votre connexion ; une nouvelle tentative sera effectuée automatiquement.",
+ "unknown": "Ce serveur n’a pas confirmé ses paramètres de connexion. Demandez à votre administrateur de mettre à jour le serveur.",
+ "incomplete": "Les paramètres de connexion sont incomplets. Demandez à votre administrateur de configurer les URL publiques de ce serveur."
+ },
"avatar_upload": {
"change": "Changer d'avatar",
"remove": "Supprimer",
diff --git a/packages/views/locales/ja/common.json b/packages/views/locales/ja/common.json
index 6aded4ad73..d934a2f499 100644
--- a/packages/views/locales/ja/common.json
+++ b/packages/views/locales/ja/common.json
@@ -1,4 +1,10 @@
{
+ "daemon_setup": {
+ "loading": "接続設定を読み込み中...",
+ "error": "接続設定を読み込めませんでした。ネットワーク接続を確認してください。自動的に再試行します。",
+ "unknown": "サーバーの接続設定を確認できません。管理者にサーバーの更新を依頼してください。",
+ "incomplete": "接続設定が不完全です。管理者にサーバーの公開 URL の設定を依頼してください。"
+ },
"avatar_upload": {
"change": "アバターを変更",
"remove": "削除",
diff --git a/packages/views/locales/ko/common.json b/packages/views/locales/ko/common.json
index 5d7795233d..9e3de0997b 100644
--- a/packages/views/locales/ko/common.json
+++ b/packages/views/locales/ko/common.json
@@ -1,4 +1,10 @@
{
+ "daemon_setup": {
+ "loading": "연결 설정을 불러오는 중...",
+ "error": "연결 설정을 불러오지 못했습니다. 네트워크 연결을 확인하세요. 자동으로 다시 시도합니다.",
+ "unknown": "서버의 연결 설정을 확인할 수 없습니다. 관리자에게 서버 업데이트를 요청하세요.",
+ "incomplete": "연결 설정이 완전하지 않습니다. 관리자에게 서버의 공개 URL 설정을 요청하세요."
+ },
"avatar_upload": {
"change": "아바타 변경",
"remove": "제거",
diff --git a/packages/views/locales/zh-Hans/common.json b/packages/views/locales/zh-Hans/common.json
index 58530fc977..c310baba35 100644
--- a/packages/views/locales/zh-Hans/common.json
+++ b/packages/views/locales/zh-Hans/common.json
@@ -1,4 +1,10 @@
{
+ "daemon_setup": {
+ "loading": "正在加载连接配置...",
+ "error": "无法加载连接配置。请检查网络,系统会自动重试。",
+ "unknown": "服务端尚未确认连接配置。请联系管理员更新服务端。",
+ "incomplete": "连接配置不完整。请联系管理员配置此服务的公开访问地址。"
+ },
"avatar_upload": {
"change": "更换头像",
"remove": "移除",
diff --git a/packages/views/locales/zh-Hant/common.json b/packages/views/locales/zh-Hant/common.json
index eea7d071e4..7d8d205d45 100644
--- a/packages/views/locales/zh-Hant/common.json
+++ b/packages/views/locales/zh-Hant/common.json
@@ -1,4 +1,10 @@
{
+ "daemon_setup": {
+ "loading": "正在載入連線設定...",
+ "error": "無法載入連線設定。請檢查網路,系統會自動重試。",
+ "unknown": "伺服器尚未確認連線設定。請聯絡管理員更新伺服器。",
+ "incomplete": "連線設定不完整。請聯絡管理員設定此服務的公開存取網址。"
+ },
"avatar_upload": {
"change": "更換頭像",
"remove": "移除",
diff --git a/packages/views/onboarding/steps/cli-install-instructions.test.tsx b/packages/views/onboarding/steps/cli-install-instructions.test.tsx
index 2eb1202cd0..3de6238972 100644
--- a/packages/views/onboarding/steps/cli-install-instructions.test.tsx
+++ b/packages/views/onboarding/steps/cli-install-instructions.test.tsx
@@ -1,7 +1,8 @@
-import { render, screen } from "@testing-library/react";
+import { act, cleanup, render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
-import { describe, expect, it } from "vitest";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { I18nProvider } from "@multica/core/i18n/react";
+import { configStore } from "@multica/core/config";
import enCommon from "../../locales/en/common.json";
import enOnboarding from "../../locales/en/onboarding.json";
import { CliInstallInstructions } from "./cli-install-instructions";
@@ -11,10 +12,74 @@ const TEST_RESOURCES = { en: { common: enCommon, onboarding: enOnboarding } };
const WINDOWS_CMD =
"irm https://raw.githubusercontent.com/multica-ai/multica/main/scripts/install.ps1 | iex";
+const clipboard = vi.hoisted(() => ({ copyText: vi.fn() }));
+vi.mock("@multica/ui/lib/clipboard", () => ({ copyText: clipboard.copyText }));
+
+function renderInstructions() {
+ return render(
+ <I18nProvider locale="en" resources={TEST_RESOURCES}>
+ <CliInstallInstructions />
+ </I18nProvider>,
+ );
+}
+
+function resetConfigStore() {
+ configStore.setState({
+ cdnDomain: "",
+ allowSignup: true,
+ googleClientId: "",
+ daemonServerUrl: "",
+ daemonAppUrl: "",
+ daemonConfigStatus: "loading",
+ daemonSetupTarget: "unknown",
+ workspaceCreationDisabled: false,
+ });
+}
+
describe("CliInstallInstructions", () => {
+ beforeEach(() => {
+ resetConfigStore();
+ clipboard.copyText.mockReset().mockResolvedValue(true);
+ });
+ afterEach(() => {
+ cleanup();
+ resetConfigStore();
+ });
+
+ it("does not offer a setup command before connection settings resolve", () => {
+ renderInstructions();
+ expect(screen.queryByText("multica setup")).not.toBeInTheDocument();
+ expect(screen.getAllByRole("button", { name: "Copy" })).toHaveLength(1);
+ expect(screen.getByRole("status")).toHaveTextContent(
+ "Loading connection settings",
+ );
+ });
+
+ it("withholds setup after a failure, then copies only the late-arriving self-host command", async () => {
+ const user = userEvent.setup();
+ renderInstructions();
+ act(() => configStore.getState().setDaemonConfigStatus("error"));
+ expect(screen.getByRole("alert")).toHaveTextContent(
+ "Couldn't load connection settings",
+ );
+ expect(screen.queryByText("multica setup")).not.toBeInTheDocument();
+ expect(screen.getAllByRole("button", { name: "Copy" })).toHaveLength(1);
+ act(() => configStore.getState().setDaemonConfig({
+ daemonSetupTarget: "self_host",
+ daemonServerUrl: "https://api.example.com",
+ daemonAppUrl: "https://app.example.com",
+ }));
+ expect(screen.queryByRole("alert")).not.toBeInTheDocument();
+ await user.click(screen.getAllByRole("button", { name: "Copy" })[1]!);
+ expect(clipboard.copyText).toHaveBeenCalledExactlyOnceWith(
+ "multica setup self-host --server-url https://api.example.com --app-url https://app.example.com",
+ );
+ });
+
// The switch itself is covered in common/cli-install-command.test.tsx; this
// checks the card wires it into step 1 and leaves step 2 shared.
it("offers the Windows installer in step 1 and keeps setup shared", async () => {
+ configStore.getState().setDaemonConfig({ daemonSetupTarget: "cloud" });
const user = userEvent.setup();
render(
<I18nProvider locale="en" resources={TEST_RESOURCES}>
@@ -27,4 +92,25 @@ describe("CliInstallInstructions", () => {
expect(screen.getByText(WINDOWS_CMD)).toBeInTheDocument();
expect(screen.getByText("multica setup")).toBeInTheDocument();
});
+
+ it("renders self-host setup command when daemon URLs are configured", () => {
+ configStore.getState().setDaemonConfig({
+ daemonSetupTarget: "self_host",
+ daemonServerUrl: "https://api.example.com/",
+ daemonAppUrl: "https://app.example.com/",
+ });
+
+ render(
+ <I18nProvider locale="en" resources={TEST_RESOURCES}>
+ <CliInstallInstructions />
+ </I18nProvider>,
+ );
+
+ expect(
+ screen.getByText(
+ "multica setup self-host --server-url https://api.example.com --app-url https://app.example.com",
+ ),
+ ).toBeInTheDocument();
+ expect(screen.queryByText("multica setup")).not.toBeInTheDocument();
+ });
});
diff --git a/packages/views/onboarding/steps/cli-install-instructions.tsx b/packages/views/onboarding/steps/cli-install-instructions.tsx
index 48f8215a52..43bd84407a 100644
--- a/packages/views/onboarding/steps/cli-install-instructions.tsx
+++ b/packages/views/onboarding/steps/cli-install-instructions.tsx
@@ -7,11 +7,11 @@ import { TooltipHint } from "@multica/ui/components/common/tooltip-hint";
import { CODE_LIGATURE_CLASS } from "@multica/ui/lib/code-style";
import { cn } from "@multica/ui/lib/utils";
import { copyText } from "@multica/ui/lib/clipboard";
+import { useDaemonSetupCommands } from "@multica/core/runtimes";
import { CliInstallCommand } from "../../common/cli-install-command";
+import { DaemonSetupNotice } from "../../common/daemon-setup-notice";
import { useT } from "../../i18n";
-const SETUP_CMD = "multica setup";
-
function CopyButton({ text }: { text: string }) {
const { t } = useT("onboarding");
const [copied, setCopied] = useState(false);
@@ -78,16 +78,10 @@ function Step({
);
}
-/**
- * CLI install instructions — two copy-and-run commands. Step 1 is the public
- * install script, which differs per OS and so renders through
- * `CliInstallCommand`'s platform switch; step 2 is the cloud
- * `multica setup`, hardcoded because the CLI itself knows the endpoints for
- * it. Local development tests a self-host variant by typing the extended
- * command directly in the terminal; no need to thread env vars through React.
- */
export function CliInstallInstructions() {
const { t } = useT("onboarding");
+ const commands = useDaemonSetupCommands();
+
return (
<Card className="w-full">
<CardContent className="space-y-4 pt-4">
@@ -106,7 +100,11 @@ export function CliInstallInstructions() {
</CliInstallCommand>
</Step>
<Step n={2} label={t(($) => $.cli_install.step2_label)}>
- <CommandRow cmd={SETUP_CMD} />
+ {commands.status === "ready" ? (
+ <CommandRow cmd={commands.setupCmd} />
+ ) : (
+ <DaemonSetupNotice status={commands.status} />
+ )}
</Step>
</CardContent>
</Card>
diff --git a/packages/views/onboarding/steps/step-platform-fork.test.tsx b/packages/views/onboarding/steps/step-platform-fork.test.tsx
index 4e82eac20c..667bef7ca1 100644
--- a/packages/views/onboarding/steps/step-platform-fork.test.tsx
+++ b/packages/views/onboarding/steps/step-platform-fork.test.tsx
@@ -1,9 +1,10 @@
-import { describe, expect, it, vi, beforeEach } from "vitest";
-import { render, screen, within } from "@testing-library/react";
+import { describe, expect, it, vi, beforeEach, afterEach } from "vitest";
+import { act, cleanup, fireEvent, render, screen, within } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import type { AgentRuntime } from "@multica/core/types";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { I18nProvider } from "@multica/core/i18n/react";
+import { configStore } from "@multica/core/config";
import enCommon from "../../locales/en/common.json";
import enOnboarding from "../../locales/en/onboarding.json";
@@ -80,10 +81,52 @@ function resetPicker(patch: Partial<typeof mocks.pickerState> = {}) {
describe("StepPlatformFork", () => {
beforeEach(() => {
+ configStore.getState().setDaemonConfig({ daemonSetupTarget: "cloud" });
resetPicker();
vi.restoreAllMocks();
});
+ afterEach(() => {
+ cleanup();
+ vi.useRealTimers();
+ configStore.setState({
+ daemonConfigStatus: "loading",
+ daemonSetupTarget: "unknown",
+ daemonServerUrl: "",
+ daemonAppUrl: "",
+ });
+ });
+
+ it("uses the same self-host command throughout the waiting stages", () => {
+ vi.useFakeTimers();
+ configStore.getState().setDaemonConfig({
+ daemonSetupTarget: "self_host",
+ daemonServerUrl: "https://api.example.com",
+ daemonAppUrl: "https://app.example.com",
+ });
+ renderFork();
+ fireEvent.click(screen.getByRole("button", { name: /show steps/i }));
+ const dialog = screen.getByRole("dialog");
+ const command = "multica setup self-host --server-url https://api.example.com --app-url https://app.example.com";
+ expect(within(dialog).getByText(command)).toBeInTheDocument();
+ act(() => vi.advanceTimersByTime(15_000));
+ expect(within(dialog).getByText(command)).toBeInTheDocument();
+ act(() => vi.advanceTimersByTime(30_000));
+ expect(within(dialog).getByText(command)).toBeInTheDocument();
+ expect(within(dialog).queryByText("multica setup")).not.toBeInTheDocument();
+ });
+
+ it("does not show Cloud waiting guidance while configuration is loading or failed", () => {
+ configStore.getState().setDaemonConfigStatus("loading");
+ renderFork();
+ fireEvent.click(screen.getByRole("button", { name: /show steps/i }));
+ const dialog = screen.getByRole("dialog");
+ expect(within(dialog).queryByText("multica setup")).not.toBeInTheDocument();
+ expect(within(dialog).queryByText(/waiting for your computer/i)).not.toBeInTheDocument();
+ act(() => configStore.getState().setDaemonConfigStatus("error"));
+ expect(within(dialog).queryByText("multica setup")).not.toBeInTheDocument();
+ });
+
it("renders the three fork options at rest", () => {
renderFork();
expect(screen.getByText(/^use this computer$/i)).toBeInTheDocument();
diff --git a/packages/views/onboarding/steps/step-platform-fork.tsx b/packages/views/onboarding/steps/step-platform-fork.tsx
index 0a76fd3ca6..db83c4d9d2 100644
--- a/packages/views/onboarding/steps/step-platform-fork.tsx
+++ b/packages/views/onboarding/steps/step-platform-fork.tsx
@@ -12,7 +12,10 @@ import {
} from "@multica/ui/components/ui/dialog";
import { cn } from "@multica/ui/lib/utils";
import type { AgentRuntime } from "@multica/core/types";
-import { runtimeDisplayLabel } from "@multica/core/runtimes";
+import {
+ runtimeDisplayLabel,
+ useDaemonSetupCommands,
+} from "@multica/core/runtimes";
import {
StepFooter,
StepHeading,
@@ -396,10 +399,11 @@ function formatElapsed(seconds: number) {
*/
function CliWaitingStatus({ dialogOpen }: { dialogOpen: boolean }) {
const { t } = useT("onboarding");
+ const commands = useDaemonSetupCommands();
const [elapsed, setElapsed] = useState(0);
useEffect(() => {
- if (!dialogOpen) {
+ if (!dialogOpen || commands.status !== "ready") {
setElapsed(0);
return;
}
@@ -407,7 +411,9 @@ function CliWaitingStatus({ dialogOpen }: { dialogOpen: boolean }) {
setElapsed((e) => e + 1);
}, 1000);
return () => window.clearInterval(id);
- }, [dialogOpen]);
+ }, [dialogOpen, commands.status]);
+
+ if (commands.status !== "ready") return null;
// Stage thresholds are rough — `multica setup` typical flow is
// ~1s save config → browser-tab auth (user-driven, 5–30s) →
@@ -451,21 +457,21 @@ function CliWaitingStatus({ dialogOpen }: { dialogOpen: boolean }) {
{stage === "normal" && (
<>
{t(($) => $.step_platform.stage_normal_prefix)}
- <span className="font-mono">{"multica setup"}</span>
+ <span className="font-mono break-all">{commands.setupCmd}</span>
{t(($) => $.step_platform.stage_normal_suffix)}
</>
)}
{stage === "midway" && (
<>
{t(($) => $.step_platform.stage_midway_prefix)}
- <span className="font-mono">{"multica setup"}</span>
+ <span className="font-mono break-all">{commands.setupCmd}</span>
{t(($) => $.step_platform.stage_midway_suffix)}
</>
)}
{stage === "slow" && (
<>
{t(($) => $.step_platform.stage_slow_prefix)}
- <span className="font-mono">{"multica setup"}</span>
+ <span className="font-mono break-all">{commands.setupCmd}</span>
{t(($) => $.step_platform.stage_slow_suffix)}
</>
)}
diff --git a/packages/views/runtimes/components/connect-remote-dialog.test.tsx b/packages/views/runtimes/components/connect-remote-dialog.test.tsx
index abebc7f089..be9bc91f4e 100644
--- a/packages/views/runtimes/components/connect-remote-dialog.test.tsx
+++ b/packages/views/runtimes/components/connect-remote-dialog.test.tsx
@@ -4,6 +4,7 @@ import userEvent from "@testing-library/user-event";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { I18nProvider } from "@multica/core/i18n/react";
import { configStore } from "@multica/core/config";
+import type { DaemonConfigStatus, DaemonSetupTarget } from "@multica/core/runtimes";
import enCommon from "../../locales/en/common.json";
import enRuntimes from "../../locales/en/runtimes.json";
import { ConnectRemoteDialog } from "./connect-remote-dialog";
@@ -58,6 +59,8 @@ function resetConfigStore() {
googleClientId: "",
daemonServerUrl: "",
daemonAppUrl: "",
+ daemonConfigStatus: "loading",
+ daemonSetupTarget: "unknown",
workspaceCreationDisabled: false,
});
}
@@ -65,11 +68,11 @@ function resetConfigStore() {
function renderDialog(config?: {
daemonServerUrl?: string;
daemonAppUrl?: string;
-}) {
+ daemonSetupTarget?: DaemonSetupTarget;
+}, status: DaemonConfigStatus = "ready") {
resetConfigStore();
- if (config) {
- configStore.getState().setDaemonConfig(config);
- }
+ configStore.getState().setDaemonConfig(config ?? { daemonSetupTarget: "cloud" });
+ configStore.getState().setDaemonConfigStatus(status);
const qc = new QueryClient({ defaultOptions: { queries: { retry: false } } });
return render(
<QueryClientProvider client={qc}>
@@ -101,6 +104,7 @@ describe("ConnectRemoteDialog", () => {
it("uses self-host daemon URLs from runtime config", () => {
const { baseElement } = renderDialog({
+ daemonSetupTarget: "self_host",
daemonServerUrl: "https://api.example.com/",
daemonAppUrl: "https://app.example.com/",
});
@@ -116,6 +120,43 @@ describe("ConnectRemoteDialog", () => {
);
});
+ it("withholds setup and token commands until config recovers", () => {
+ const { baseElement } = renderDialog({}, "loading");
+ expect(screen.getByRole("status")).toHaveTextContent(
+ "Loading connection settings",
+ );
+ expect(baseElement).not.toHaveTextContent("multica setup");
+ expect(baseElement).not.toHaveTextContent("multica config set");
+ act(() => configStore.getState().setDaemonConfigStatus("error"));
+ expect(screen.getByRole("alert")).toHaveTextContent(
+ "Couldn't load connection settings",
+ );
+ expect(baseElement).not.toHaveTextContent("multica setup");
+ expect(baseElement).not.toHaveTextContent("multica config set");
+ act(() => configStore.getState().setDaemonConfig({
+ daemonSetupTarget: "self_host",
+ daemonServerUrl: "https://api.example.com",
+ daemonAppUrl: "https://app.example.com",
+ }));
+ expect(baseElement).toHaveTextContent(
+ "multica setup self-host --server-url https://api.example.com --app-url https://app.example.com",
+ );
+ expect(baseElement).toHaveTextContent(
+ "multica config set server_url https://api.example.com",
+ );
+ });
+
+ it.each([
+ { daemonSetupTarget: "unknown" as const },
+ { daemonSetupTarget: "self_host" as const, daemonServerUrl: "https://api.example.com" },
+ ])("withholds both command paths for unresolved config %j", (config) => {
+ const { baseElement } = renderDialog(config);
+ expect(screen.getByRole("alert")).toBeInTheDocument();
+ expect(baseElement).not.toHaveTextContent("multica setup");
+ expect(baseElement).not.toHaveTextContent("multica config set");
+ expect(screen.getAllByRole("button", { name: "Copy" })).toHaveLength(1);
+ });
+
// The install command is OS-specific, so the dialog can't hardcode one.
// Before this switch existed the dialog shipped only the curl command and
// Windows users had no path at all, despite scripts/install.ps1. The switch
diff --git a/packages/views/runtimes/components/connect-remote-dialog.tsx b/packages/views/runtimes/components/connect-remote-dialog.tsx
index dadc61d0af..46aa50e395 100644
--- a/packages/views/runtimes/components/connect-remote-dialog.tsx
+++ b/packages/views/runtimes/components/connect-remote-dialog.tsx
@@ -12,9 +12,9 @@ import { Check, ChevronRight, Copy, Terminal } from "lucide-react";
import { useQueryClient } from "@tanstack/react-query";
import { useWorkspaceId } from "@multica/core/hooks";
import { runtimeKeys } from "@multica/core/runtimes/queries";
+import { useDaemonSetupCommands } from "@multica/core/runtimes";
import { useWSEvent } from "@multica/core/realtime";
import { paths, useWorkspaceSlug } from "@multica/core/paths";
-import { useConfigStore } from "@multica/core/config";
import {
Dialog,
DialogContent,
@@ -33,40 +33,12 @@ import {
} from "@multica/ui/lib/motion";
import { cn } from "@multica/ui/lib/utils";
import { CliInstallCommand } from "../../common/cli-install-command";
+import { DaemonSetupNotice } from "../../common/daemon-setup-notice";
import { useNavigation } from "../../navigation";
import { useT } from "../../i18n";
type Step = "instructions" | "success";
-const CLOUD_SERVER_URL = "https://api.multica.ai";
-const CLOUD_APP_URL = "https://multica.ai";
-
-function normalizeCommandURL(url: string | undefined) {
- return url?.trim().replace(/\/+$/, "") ?? "";
-}
-
-function daemonCommands(serverUrl: string | undefined, appUrl: string | undefined) {
- const normalizedServerUrl = normalizeCommandURL(serverUrl);
- const normalizedAppUrl = normalizeCommandURL(appUrl);
- if (normalizedServerUrl && normalizedAppUrl) {
- return {
- setupCmd: `multica setup self-host --server-url ${normalizedServerUrl} --app-url ${normalizedAppUrl}`,
- tokenCmd: `multica config set server_url ${normalizedServerUrl}
-multica config set app_url ${normalizedAppUrl}
-multica login --token <YOUR_TOKEN>
-multica daemon start`,
- };
- }
-
- return {
- setupCmd: "multica setup",
- tokenCmd: `multica config set server_url ${CLOUD_SERVER_URL}
-multica config set app_url ${CLOUD_APP_URL}
-multica login --token <YOUR_TOKEN>
-multica daemon start`,
- };
-}
-
export function ConnectRemoteDialog({ onClose }: { onClose: () => void }) {
const [step, setStep] = useState<Step>("instructions");
const wsId = useWorkspaceId();
@@ -240,9 +212,7 @@ function CommandStep({
function InstructionsStep({ onClose }: { onClose: () => void }) {
const { t } = useT("runtimes");
- const daemonServerUrl = useConfigStore((s) => s.daemonServerUrl);
- const daemonAppUrl = useConfigStore((s) => s.daemonAppUrl);
- const { setupCmd, tokenCmd } = daemonCommands(daemonServerUrl, daemonAppUrl);
+ const commands = useDaemonSetupCommands();
return (
<>
<DialogHeader className="px-6 pt-6 pb-2">
@@ -278,19 +248,28 @@ function InstructionsStep({ onClose }: { onClose: () => void }) {
<div>
<CommandStep n={2} label={t(($) => $.connect.step2_label)}>
- <CommandRow
- cmd={setupCmd}
- copyAria={t(($) => $.connect.copy_aria)}
- />
+ {commands.status === "ready" ? (
+ <CommandRow
+ cmd={commands.setupCmd}
+ copyAria={t(($) => $.connect.copy_aria)}
+ />
+ ) : (
+ <DaemonSetupNotice status={commands.status} />
+ )}
</CommandStep>
- <p className="mt-1.5 text-micro leading-[1.55] text-muted-foreground">
- {t(($) => $.connect.step2_hint)}
- </p>
+ {commands.status === "ready" && (
+ <p className="mt-1.5 text-micro leading-[1.55] text-muted-foreground">
+ {t(($) => $.connect.step2_hint)}
+ </p>
+ )}
</div>
- <LiveListening />
-
- <TroubleshootingDetails tokenCmd={tokenCmd} />
+ {commands.status === "ready" && (
+ <>
+ <LiveListening />
+ <TroubleshootingDetails tokenCmd={commands.tokenCmd} />
+ </>
+ )}
</div>
</div>
diff --git a/server/internal/daemon/daemon_test.go b/server/internal/daemon/daemon_test.go
index 9999d04983..fe84e86c79 100644
--- a/server/internal/daemon/daemon_test.go
+++ b/server/internal/daemon/daemon_test.go
@@ -4182,8 +4182,9 @@ func TestExecuteAndDrain_IdleWatchdog_FiresOnInactivity(t *testing.T) {
// the production watchdog window or relying on child-process scheduling speed.
type waitForAgentMessageBackend struct {
agent.Backend
- match func(agent.Message) bool
- onMatch func()
+ match func(agent.Message) bool
+ onMatch func()
+ resultGate <-chan struct{}
}
func (b waitForAgentMessageBackend) Execute(ctx context.Context, prompt string, opts agent.ExecOptions) (*agent.Session, error) {
@@ -4213,12 +4214,25 @@ func (b waitForAgentMessageBackend) Execute(ctx context.Context, prompt string,
messages <- msg
}
}()
+ result := session.Result
+ if b.resultGate != nil {
+ // Keep Result unavailable until the daemon enters the branch under test.
+ gatedResult := make(chan agent.Result, 1)
+ go func() {
+ defer close(gatedResult)
+ <-b.resultGate
+ if final, ok := <-session.Result; ok {
+ gatedResult <- final
+ }
+ }()
+ result = gatedResult
+ }
return &agent.Session{
ToolActivity: session.ToolActivity,
InterruptBackgroundTools: session.InterruptBackgroundTools,
TerminalObserved: session.TerminalObserved,
Messages: messages,
- Result: session.Result,
+ Result: result,
}, nil
}
}
@@ -4403,11 +4417,19 @@ func TestExecuteAndDrain_PiWithoutTurnErrorKeepsUpstreamCancellation(t *testing.
if err != nil {
t.Fatalf("new pi backend: %v", err)
}
+ probe := &handoffProbe{
+ gate: make(chan struct{}),
+ prefix: "waiting for the backend to hand over its result after cancellation",
+ }
+ defer func() { probe.once.Do(func() { close(probe.gate) }) }()
matched := make(chan struct{})
backend = waitForAgentMessageBackend{
Backend: backend,
match: func(msg agent.Message) bool { return msg.Type == agent.MessageStatus },
onMatch: func() { close(matched) },
+ // Both Done and Result can become ready on cancellation. Pin the drain
+ // arm rather than requiring select to choose it over an aborted Result.
+ resultGate: probe.gate,
}
d := newTestDaemon(t)
ctx, cancel := context.WithCancel(context.Background())
@@ -4425,7 +4447,7 @@ func TestExecuteAndDrain_PiWithoutTurnErrorKeepsUpstreamCancellation(t *testing.
backend,
"prompt-ignored",
agent.ExecOptions{ResumeSessionID: sessionPath},
- slog.Default(),
+ slog.New(probe),
"t-pi-no-provider-error-upstream-cancel",
"",
new(atomic.Int32),
@@ -4445,6 +4467,9 @@ func TestExecuteAndDrain_PiWithoutTurnErrorKeepsUpstreamCancellation(t *testing.
if got.err != nil {
t.Fatalf("executeAndDrain: %v", got.err)
}
+ if !probe.seen.Load() {
+ t.Fatal("upstream cancellation hand-off was not exercised")
+ }
if got.result.Status != "cancelled" || !strings.Contains(got.result.Error, "task cancelled by upstream context") {
t.Fatalf("result = %+v, want existing upstream cancellation", got.result)
}
diff --git a/server/internal/handler/config.go b/server/internal/handler/config.go
index 5a6764e680..02e4fedb9f 100644
--- a/server/internal/handler/config.go
+++ b/server/internal/handler/config.go
@@ -39,6 +39,9 @@ type AppConfig struct {
// with the operator's own domains instead of Multica Cloud defaults.
DaemonServerURL string `json:"daemon_server_url,omitempty"`
DaemonAppURL string `json:"daemon_app_url,omitempty"`
+ // Explicit even when URLs are omitted, so clients never infer Cloud from
+ // missing self-host configuration. Older clients ignore this additive field.
+ DaemonSetupTarget string `json:"daemon_setup_target"`
// VCSIntegrationAvailable mirrors the MULTICA_VCS_INTEGRATION_ENABLED
// deployment switch so the Settings UI can hide the whole self-hosted Git
@@ -127,6 +130,7 @@ func (h *Handler) GetConfig(w http.ResponseWriter, r *http.Request) {
config.AttachmentPublicURL = h.cfg.PublicURL
config.CdnSigned = h.CFSigner != nil
config.DaemonServerURL, config.DaemonAppURL = daemonSetupURLsFromEnv()
+ config.DaemonSetupTarget = "self_host"
config.VCSIntegrationAvailable = h.cfg.VCSIntegrationEnabled
config.FeatureFlags = featureflags.EvaluateFrontendPublicFlags(r.Context(), h.FeatureFlags)
// Only surface the build version on self-hosted deployments. The managed
@@ -134,6 +138,8 @@ func (h *Handler) GetConfig(w http.ResponseWriter, r *http.Request) {
// the Help popover's version row would just be noise there (MUL-4108).
if !isOfficialCloudDeployment() {
config.ServerVersion = h.cfg.ServerVersion
+ } else {
+ config.DaemonSetupTarget = "cloud"
}
// Re-read from env on every request so operators can rotate keys via
diff --git a/server/internal/handler/config_test.go b/server/internal/handler/config_test.go
index 1027ab5c09..e927acff22 100644
--- a/server/internal/handler/config_test.go
+++ b/server/internal/handler/config_test.go
@@ -130,6 +130,32 @@ func TestGetConfigUsesDaemonServerURLOverride(t *testing.T) {
}
}
+func TestGetConfigDeclaresDaemonSetupTarget(t *testing.T) {
+ for _, tt := range []struct {
+ name, appURL, wantTarget, wantServerURL string
+ }{
+ {"official Cloud", "https://multica.ai", "cloud", ""},
+ {"configured self-host", "https://app.example.com", "self_host", "https://api.example.com"},
+ {"incomplete self-host", "", "self_host", ""},
+ } {
+ t.Run(tt.name, func(t *testing.T) {
+ t.Setenv("MULTICA_APP_URL", tt.appURL)
+ t.Setenv("FRONTEND_ORIGIN", "")
+ t.Setenv("MULTICA_PUBLIC_URL", "https://api.example.com")
+ t.Setenv("MULTICA_DAEMON_SERVER_URL", "")
+ var cfg AppConfig
+ req := httptest.NewRequest(http.MethodGet, "/api/config", nil)
+ testutil.Call(t, testHandler.GetConfig, req).Want(http.StatusOK).JSON(&cfg)
+ if cfg.DaemonSetupTarget != tt.wantTarget {
+ t.Fatalf("daemon_setup_target = %q, want %q", cfg.DaemonSetupTarget, tt.wantTarget)
+ }
+ if cfg.DaemonServerURL != tt.wantServerURL {
+ t.Fatalf("daemon_server_url = %q, want %q", cfg.DaemonServerURL, tt.wantServerURL)
+ }
+ })
+ }
+}
+
func TestGetConfigHonorsVCSIntegrationSwitch(t *testing.T) {
origCfg := testHandler.cfg
t.Cleanup(func() { testHandler.cfg = origCfg })