Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(views): don't misreport unlisted runtime as missing CLI version (#7655)
importcpp440ef8aa16c4
diff --git a/packages/views/modals/quick-create-issue.test.tsx b/packages/views/modals/quick-create-issue.test.tsxindex 4cd4dc7d05..3579d06709 100644--- a/packages/views/modals/quick-create-issue.test.tsx+++ b/packages/views/modals/quick-create-issue.test.tsx@@ -126,6 +126,16 @@ const mockSquadsData = vi.hoisted(() => ({ list: [] as Array<{ id: string; name: string; leader_id: string; archived_at: string | null }> }),);+// Per-test override for the runtimes list. Non-admin members receive a+// filtered list (ListVisibleAgentRuntimes) that omits other members' private+// machines, so a selected agent can point at a runtime_id that is simply not+// present here — the case that used to be misreported as "daemon has no CLI+// version" (#7633). Tests flip this to drop the row and prove the panel no+// longer blocks on it.+const mockRuntimesData = vi.hoisted(+ () => ({ list: [{ id: "runtime-1", metadata: { cli_version: "1.2.3" } }] as Array<{ id: string; metadata: Record<string, unknown> }> }),+);+// The real handle mints an id when it inserts the placeholder and hands it to// the uploader, which adopts it as the draft `clientUploadId`. Mocks must do// the same or the two records drift apart only in tests.@@ -146,7 +156,7 @@ vi.mock("@tanstack/react-query", () => ({data: [{ id: "agent-1", name: "Bohan", archived_at: null, runtime_id: "runtime-1" }],};case "runtimes":- return { data: [{ id: "runtime-1", metadata: { cli_version: "1.2.3" } }] };+ return { data: mockRuntimesData.list };case "projects":return mockProjectsQuery;default:@@ -242,12 +252,13 @@ vi.mock("@multica/core/auth", () => ({(selector ? selector({ user: { id: "user-1" } }) : { user: { id: "user-1" } }),}));-vi.mock("@multica/core/runtimes", () => ({+// Use the REAL version-check helpers (not stubs): the fix hinges on how the+// panel reacts when the selected runtime is absent vs. present-but-old, and a+// constant-"ok" stub would mask exactly that. Only runtimeListOptions is+// overridden so the query key routes to our mocked useQuery above.+vi.mock("@multica/core/runtimes", async (importOriginal) => ({+ ...(await importOriginal<typeof import("@multica/core/runtimes")>()),runtimeListOptions: () => ({ queryKey: ["runtimes"] }),- checkQuickCreateCliVersion: () => ({ state: "ok", min: "1.0.0" }),- checkQuickCreateFieldsCliVersion: () => ({ state: "ok", min: "1.0.0" }),- readRuntimeCliVersion: () => "1.2.3",- MIN_QUICK_CREATE_CLI_VERSION: "1.0.0",}));@@ -522,6 +533,7 @@ describe("AgentCreatePanel", () => {mockProjectsQuery.data = [];mockProjectsQuery.isSuccess = true;mockSquadsData.list = [];+ mockRuntimesData.list = [{ id: "runtime-1", metadata: { cli_version: "1.2.3" } }];mockQuickCreateIssue.mockResolvedValue(undefined);mockCreateCommentSubIssue.mockResolvedValue({ task_id: "task-source-child" });mockApiUploadFile.mockResolvedValue({@@ -1141,9 +1153,66 @@ describe("AgentCreatePanel", () => {});});- // MUL-4931 — this path files a real issue, so a double-fire is a duplicate- // issue, not a cosmetic glitch. `submitting` is state: two chords landing in- // one tick both read the pre-update value, so only a synchronously-flipped+ // #7633 — a non-admin member's runtime list (ListVisibleAgentRuntimes) omits+ // other members' private machines, so a selected agent can point at a+ // runtime_id that is simply absent from the list the panel sees. That absence+ // used to collapse into "daemon reported no CLI version" and wall the member+ // off with a bogus upgrade prompt — even though the runtime is new enough and+ // the same create succeeds the instant the user is promoted to admin (which+ // only widens the list). The panel must NOT pre-block when it cannot see the+ // runtime at all; the server's version gate (which reads the row by id,+ // regardless of role) stays the trust boundary.+ describe("version pre-check with an unlisted runtime (#7633)", () => {+ it("does not block Create when the selected agent's runtime is not in the visible list", async () => {+ const user = userEvent.setup();+ // Member view: the agent's runtime-1 is a private machine they don't own,+ // so it never appears in their list.+ mockRuntimesData.list = [];++ renderPanel({ onClose: vi.fn(), isExpanded: false, setIsExpanded: vi.fn() });++ await user.click(screen.getByRole("button", { name: /Bohan/ }));++ // No misleading "daemon has no CLI version" wall...+ expect(+ screen.queryByText(/doesn't report a CLI version/i),+ ).not.toBeInTheDocument();+ // ...and Create is reachable (gated only by prompt content, as usual).+ await user.type(+ screen.getByPlaceholderText(+ 'Tell the agent what to do, e.g. "let Bohan fix the inbox loading slowness in the Web project"',+ ),+ "Ship it",+ );+ const create = screen.getByRole("button", { name: /^Create$/i });+ expect(create).not.toBeDisabled();++ await user.click(create);+ await waitFor(() => expect(mockQuickCreateIssue).toHaveBeenCalledTimes(1));+ });++ it("still blocks a runtime that is visible but genuinely too old", async () => {+ const user = userEvent.setup();+ // The runtime IS in the list and reports a real, below-minimum version —+ // the case the gate exists for. We must keep failing closed here.+ mockRuntimesData.list = [{ id: "runtime-1", metadata: { cli_version: "0.0.1" } }];++ renderPanel({ onClose: vi.fn(), isExpanded: false, setIsExpanded: vi.fn() });++ await user.click(screen.getByRole("button", { name: /Bohan/ }));++ expect(screen.getByText(/Create with agent needs ≥/i)).toBeInTheDocument();+ await user.type(+ screen.getByPlaceholderText(+ 'Tell the agent what to do, e.g. "let Bohan fix the inbox loading slowness in the Web project"',+ ),+ "Ship it",+ );+ expect(screen.getByRole("button", { name: /^Create$/i })).toBeDisabled();+ });+ });++// ref can gate it. Mirrors the manual-create regression.describe("send shortcut single-flight", () => {it("creates once when the send chord fires twice in the same tick", async () => {diff --git a/packages/views/modals/quick-create-issue.tsx b/packages/views/modals/quick-create-issue.tsxindex bdcb9758c0..c1bd98a994 100644--- a/packages/views/modals/quick-create-issue.tsx+++ b/packages/views/modals/quick-create-issue.tsx@@ -338,6 +338,16 @@ export function AgentCreatePanel({: undefined,[runtimes, selectedAgent?.runtime_id],);+ // We can only pre-check a version we can actually see. A non-admin member's+ // runtime list (ListVisibleAgentRuntimes) omits other members' private+ // machines, so a selected agent bound to such a runtime yields no row here.+ // That absence is "unknown version", NOT "daemon reported no version": the+ // two must not collapse, or the member gets the misleading "upgrade your+ // daemon" wall for a runtime that is in fact new enough (#7633). When we+ // can't pre-check, defer to the server's authoritative gate+ // (checkQuickCreateDaemonVersion, which reads the row by id regardless of+ // role) instead of failing closed in the UI.+ const canPrecheckVersion = selectedAgent?.runtime_id != null && selectedRuntime != null;const runtimeCliVersion = readRuntimeCliVersion(selectedRuntime?.metadata);const baseVersionCheck = useMemo(() => checkQuickCreateCliVersion(runtimeCliVersion),@@ -350,8 +360,9 @@ export function AgentCreatePanel({const usesExplicitFields = priority !== "none" || dueDate !== null;const versionCheck = usesExplicitFields ? fieldVersionCheck : baseVersionCheck;const versionBlocked =- baseVersionCheck.state !== "ok" ||- (usesExplicitFields && fieldVersionCheck.state !== "ok");+ canPrecheckVersion &&+ (baseVersionCheck.state !== "ok" ||+ (usesExplicitFields && fieldVersionCheck.state !== "ok"));const initialPrompt = draft.agent.prompt || (data?.prompt as string) || "";// The editor is uncontrolled — we read the latest markdown via the ref at