Skip to content

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

Go

fix(runtimes): accept wsId as parameter instead of requiring WorkspaceIdProvider

Naiyuan Qing33768a2d3ac5
diff --git a/packages/core/runtimes/hooks.ts b/packages/core/runtimes/hooks.ts
index efcfb0387a..55daa23bf1 100644
--- a/packages/core/runtimes/hooks.ts
+++ b/packages/core/runtimes/hooks.ts
@@ -1,7 +1,6 @@
import { useMemo } from "react";
import { useQuery } from "@tanstack/react-query";
import { useAuthStore } from "../auth";
-import { useWorkspaceId } from "../hooks";
import type { AgentRuntime } from "../types";
import { runtimeListOptions, latestCliVersionOptions } from "./queries";
@@ -39,11 +38,14 @@ function runtimeNeedsUpdate(
/**
* Returns true if the current user has any local runtime with an outdated CLI version.
+ * Accepts wsId as parameter so callers outside WorkspaceIdProvider can use it safely.
*/
-export function useMyRuntimesNeedUpdate(): boolean {
- const wsId = useWorkspaceId();
+export function useMyRuntimesNeedUpdate(wsId: string | undefined): boolean {
const userId = useAuthStore((s) => s.user?.id);
- const { data: runtimes } = useQuery(runtimeListOptions(wsId));
+ const { data: runtimes } = useQuery({
+ ...runtimeListOptions(wsId ?? ""),
+ enabled: !!wsId,
+ });
const { data: latestVersion } = useQuery(latestCliVersionOptions());
if (!runtimes || !latestVersion || !userId) return false;
@@ -53,11 +55,14 @@ export function useMyRuntimesNeedUpdate(): boolean {
/**
* 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(): Set<string> {
- const wsId = useWorkspaceId();
+export function useUpdatableRuntimeIds(wsId: string | undefined): Set<string> {
const userId = useAuthStore((s) => s.user?.id);
- const { data: runtimes } = useQuery(runtimeListOptions(wsId));
+ const { data: runtimes } = useQuery({
+ ...runtimeListOptions(wsId ?? ""),
+ enabled: !!wsId,
+ });
const { data: latestVersion } = useQuery(latestCliVersionOptions());
return useMemo(() => {
diff --git a/packages/views/runtimes/components/runtimes-page.tsx b/packages/views/runtimes/components/runtimes-page.tsx
index cff6e6db91..b9e9073c4d 100644
--- a/packages/views/runtimes/components/runtimes-page.tsx
+++ b/packages/views/runtimes/components/runtimes-page.tsx
@@ -41,7 +41,7 @@ export default function RuntimesPage() {
}, [qc, wsId]);
useWSEvent("daemon:register", handleDaemonEvent);
- const updatableIds = useUpdatableRuntimeIds();
+ const updatableIds = useUpdatableRuntimeIds(wsId);
// Auto-select first runtime if nothing selected
const effectiveSelectedId = selectedId && runtimes.some((r) => r.id === selectedId)