chore(runtimes): remove obsolete update hook

Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
Eve
2026-07-15 12:29:23 +08:00
parent 2396fc8d94
commit e2f03d7be1
4 changed files with 0 additions and 91 deletions

View File

@@ -55,7 +55,6 @@
"./runtimes": "./runtimes/index.ts",
"./runtimes/queries": "./runtimes/queries.ts",
"./runtimes/mutations": "./runtimes/mutations.ts",
"./runtimes/hooks": "./runtimes/hooks.ts",
"./runtimes/custom-pricing-store": "./runtimes/custom-pricing-store.ts",
"./dashboard": "./dashboard/index.ts",
"./dashboard/queries": "./dashboard/queries.ts",

View File

@@ -1,66 +0,0 @@
import { useMemo } from "react";
import { useQuery } from "@tanstack/react-query";
import { useAuthStore } from "../auth";
import type { AgentRuntime } from "../types";
import { runtimeListOptions, latestCliVersionOptions } from "./queries";
function stripV(v: string): string {
return v.replace(/^v/, "");
}
function isNewer(latest: string, current: string): boolean {
const l = stripV(latest).split(".").map(Number);
const c = stripV(current).split(".").map(Number);
for (let i = 0; i < Math.max(l.length, c.length); i++) {
const lv = l[i] ?? 0;
const cv = c[i] ?? 0;
if (lv > cv) return true;
if (lv < cv) return false;
}
return false;
}
function runtimeNeedsUpdate(
rt: AgentRuntime,
latestVersion: string,
userId: string,
): boolean {
if (rt.runtime_mode !== "local") return false;
// Only show to the user who owns this runtime.
if (rt.owner_id !== userId) return false;
// Desktop-managed runtimes are updated by the Desktop app's own auto-updater;
// the platform should not surface CLI update prompts for them.
if (rt.metadata && rt.metadata.launched_by === "desktop") {
return false;
}
const cliVersion =
rt.metadata && typeof rt.metadata.cli_version === "string"
? rt.metadata.cli_version
: null;
if (!cliVersion) return false;
return isNewer(latestVersion, cliVersion);
}
/**
* Returns a Set of runtime IDs that belong to the current user and have updates available.
* Accepts wsId as parameter so callers outside WorkspaceIdProvider can use it safely.
*/
export function useUpdatableRuntimeIds(wsId: string | undefined): Set<string> {
const userId = useAuthStore((s) => s.user?.id);
const { data: runtimes } = useQuery({
...runtimeListOptions(wsId ?? ""),
enabled: !!wsId,
});
const { data: latestVersion } = useQuery(latestCliVersionOptions());
return useMemo(() => {
if (!runtimes || !latestVersion || !userId) return new Set<string>();
const ids = new Set<string>();
for (const rt of runtimes) {
if (runtimeNeedsUpdate(rt, latestVersion, userId)) {
ids.add(rt.id);
}
}
return ids;
}, [runtimes, latestVersion, userId]);
}

View File

@@ -1,7 +1,6 @@
export * from "./queries";
export * from "./profiles";
export * from "./mutations";
export * from "./hooks";
export * from "./models";
export * from "./local-skills";
export * from "./types";

View File

@@ -12,7 +12,6 @@ export const runtimeKeys = {
// by-hour now follows the viewer's tz, like the other reports.
usageByHour: (rid: string, days: number, tz: string) =>
["runtimes", "usage", "by-hour", rid, days, tz] as const,
latestVersion: () => ["runtimes", "latestVersion"] as const,
};
// `tz` is the viewer's IANA name — all reports follow the viewer's tz.
@@ -54,25 +53,3 @@ export function runtimeListOptions(wsId: string, owner?: "me") {
queryFn: () => api.listRuntimes({ workspace_id: wsId, owner }),
});
}
const GITHUB_RELEASES_URL =
"https://api.github.com/repos/multica-ai/multica/releases/latest";
export function latestCliVersionOptions() {
return queryOptions({
queryKey: runtimeKeys.latestVersion(),
queryFn: async (): Promise<string | null> => {
try {
const resp = await fetch(GITHUB_RELEASES_URL, {
headers: { Accept: "application/vnd.github+json" },
});
if (!resp.ok) return null;
const data = await resp.json();
return (data.tag_name as string) ?? null;
} catch {
return null;
}
},
staleTime: 10 * 60 * 1000, // 10 minutes
});
}