Skip to content

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

Go

fix(runtimes): guard delete for self-healing local runtimes (#3076)

YYClawed8f43867c31
diff --git a/packages/views/locales/en/runtimes.json b/packages/views/locales/en/runtimes.json
index 29dfb47bff..287181259b 100644
--- a/packages/views/locales/en/runtimes.json
+++ b/packages/views/locales/en/runtimes.json
@@ -84,9 +84,8 @@
"detail": {
"all_runtimes": "All runtimes",
"read_only": "Read-only",
- "delete_aria": "Delete runtime",
- "delete_tooltip": "Delete runtime",
"delete_button": "Delete runtime",
+ "delete_disabled_tooltip": "This runtime is managed by a running local daemon and will re-register itself within seconds. Stop the daemon process to remove it permanently.",
"last_seen": "last seen {{when}}",
"fact_owner": "Owner",
"fact_device": "Device",
diff --git a/packages/views/locales/zh-Hans/runtimes.json b/packages/views/locales/zh-Hans/runtimes.json
index d9266bc5ac..7cbbd7e159 100644
--- a/packages/views/locales/zh-Hans/runtimes.json
+++ b/packages/views/locales/zh-Hans/runtimes.json
@@ -80,9 +80,8 @@
"detail": {
"all_runtimes": "全部运行时",
"read_only": "只读",
- "delete_aria": "删除运行时",
- "delete_tooltip": "删除运行时",
"delete_button": "删除运行时",
+ "delete_disabled_tooltip": "该运行时由正在运行的本地 daemon 托管,删除后会在数秒内自动重新注册。需停止 daemon 进程才能彻底移除。",
"last_seen": "最后活跃 {{when}}",
"fact_owner": "所有者",
"fact_device": "设备",
diff --git a/packages/views/runtimes/components/runtime-detail-visibility.test.tsx b/packages/views/runtimes/components/runtime-detail-visibility.test.tsx
index 5248c83598..b8d1297316 100644
--- a/packages/views/runtimes/components/runtime-detail-visibility.test.tsx
+++ b/packages/views/runtimes/components/runtime-detail-visibility.test.tsx
@@ -94,7 +94,10 @@ vi.mock("../../agents/presence", () => ({
workloadConfig: { idle: { icon: () => null, textClass: "" } },
}));
vi.mock("../../common/actor-avatar", () => ({ ActorAvatar: () => null }));
-vi.mock("../../navigation", () => ({ AppLink: () => null }));
+vi.mock("../../navigation", () => ({
+ AppLink: () => null,
+ useNavigation: () => ({ push: vi.fn(), replace: vi.fn() }),
+}));
import { RuntimeDetail } from "./runtime-detail";
diff --git a/packages/views/runtimes/components/runtime-detail.tsx b/packages/views/runtimes/components/runtime-detail.tsx
index d3576ee47f..82efb3f272 100644
--- a/packages/views/runtimes/components/runtime-detail.tsx
+++ b/packages/views/runtimes/components/runtime-detail.tsx
@@ -39,7 +39,7 @@ import {
TooltipTrigger,
} from "@multica/ui/components/ui/tooltip";
import { ActorAvatar } from "../../common/actor-avatar";
-import { AppLink } from "../../navigation";
+import { AppLink, useNavigation } from "../../navigation";
import { availabilityConfig, workloadConfig } from "../../agents/presence";
import { formatLastSeen } from "../utils";
import { HealthBadge } from "./shared";
@@ -100,6 +100,7 @@ export function RuntimeDetail({ runtime }: { runtime: AgentRuntime }) {
const user = useAuthStore((s) => s.user);
const wsId = useWorkspaceId();
const paths = useWorkspacePaths();
+ const navigation = useNavigation();
const { data: members = [] } = useQuery(memberListOptions(wsId));
const { data: agents = [] } = useQuery(agentListOptions(wsId));
const { byAgent: presenceMap } = useWorkspacePresenceMap(wsId);
@@ -129,8 +130,9 @@ export function RuntimeDetail({ runtime }: { runtime: AgentRuntime }) {
const handleDelete = () => {
deleteMutation.mutate(runtime.id, {
onSuccess: () => {
- toast.success(t(($) => $.detail.toast_deleted));
setDeleteOpen(false);
+ navigation.replace(paths.runtimes());
+ toast.success(t(($) => $.detail.toast_deleted));
},
onError: (e) => {
toast.error(e instanceof Error ? e.message : t(($) => $.detail.toast_delete_failed));
@@ -166,24 +168,6 @@ export function RuntimeDetail({ runtime }: { runtime: AgentRuntime }) {
{t(($) => $.detail.read_only)}
</span>
)}
- {canDelete && (
- <Tooltip>
- <TooltipTrigger
- render={
- <Button
- variant="ghost"
- size="icon-sm"
- onClick={() => setDeleteOpen(true)}
- className="text-muted-foreground hover:text-destructive"
- aria-label={t(($) => $.detail.delete_aria)}
- >
- <Trash2 className="h-3.5 w-3.5" />
- </Button>
- }
- />
- <TooltipContent>{t(($) => $.detail.delete_tooltip)}</TooltipContent>
- </Tooltip>
- )}
</div>
</div>
@@ -500,6 +484,10 @@ function DiagnosticsCard({
}) {
const { t } = useT("runtimes");
const isLocal = runtime.runtime_mode === "local";
+ // A live local daemon re-registers itself within seconds of a server-side
+ // delete (daemon self-heal, #2404), so deleting an online local runtime
+ // from the UI has no lasting effect — disable it and explain why.
+ const selfHealing = isLocal && runtime.status === "online";
// canDelete here doubles as the "can edit runtime" predicate — it already
// means "workspace owner/admin OR runtime owner", which is the same gate
// the server enforces for the visibility PATCH.
@@ -534,15 +522,41 @@ function DiagnosticsCard({
)}
{canDelete && (
<div className="border-t pt-3">
- <Button
- variant="ghost"
- size="sm"
- className="h-8 w-full justify-start gap-2 text-destructive hover:bg-destructive/10 hover:text-destructive"
- onClick={onDelete}
- >
- <Trash2 className="h-3.5 w-3.5" />
- {t(($) => $.detail.delete_button)}
- </Button>
+ {selfHealing ? (
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ // Wrapping span keeps the trigger hoverable — a disabled
+ // <button> swallows pointer events, so the tooltip would
+ // never open if it were the trigger itself.
+ <span className="block w-full">
+ <Button
+ variant="ghost"
+ size="sm"
+ disabled
+ className="h-8 w-full justify-start gap-2 text-destructive"
+ >
+ <Trash2 className="h-3.5 w-3.5" />
+ {t(($) => $.detail.delete_button)}
+ </Button>
+ </span>
+ }
+ />
+ <TooltipContent>
+ {t(($) => $.detail.delete_disabled_tooltip)}
+ </TooltipContent>
+ </Tooltip>
+ ) : (
+ <Button
+ variant="ghost"
+ size="sm"
+ className="h-8 w-full justify-start gap-2 text-destructive hover:bg-destructive/10 hover:text-destructive"
+ onClick={onDelete}
+ >
+ <Trash2 className="h-3.5 w-3.5" />
+ {t(($) => $.detail.delete_button)}
+ </Button>
+ )}
</div>
)}
</div>