fix: add from __future__ import annotations to workspace_manager.py

Fixes NameError: ToolInstance not defined at runtime because
type annotations are evaluated at class definition time.
Deferring annotation evaluation with __future__ annotations
keeps TYPE_CHECKING imports from causing runtime crashes.

Also includes ruff formatting cleanup on workspace-related files.
This commit is contained in:
2026-05-31 23:41:45 +02:00
parent 5bba2bbd92
commit a5d64d1859
15 changed files with 831 additions and 699 deletions
+29 -24
View File
@@ -5,33 +5,38 @@ import { listWorkspaces } from "../api/workspaces";
import type { Workspace } from "../types/workspace";
export interface UseWorkspacesResult {
workspaces: Workspace[];
loading: boolean;
error: string | null;
refresh: () => Promise<void>;
workspaces: Workspace[];
loading: boolean;
error: string | null;
refresh: () => Promise<void>;
}
export function useWorkspaces(projectId: string, repoId: string): UseWorkspacesResult {
const [workspaces, setWorkspaces] = useState<Workspace[]>([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
export function useWorkspaces(
projectId: string,
repoId: string,
): UseWorkspacesResult {
const [workspaces, setWorkspaces] = useState<Workspace[]>([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
const refresh = useCallback(async () => {
setLoading(true);
setError(null);
try {
const data = await listWorkspaces(projectId, repoId);
setWorkspaces(data);
} catch (err) {
setError(err instanceof Error ? err.message : "Failed to load workspaces");
} finally {
setLoading(false);
}
}, [projectId, repoId]);
const refresh = useCallback(async () => {
setLoading(true);
setError(null);
try {
const data = await listWorkspaces(projectId, repoId);
setWorkspaces(data);
} catch (err) {
setError(
err instanceof Error ? err.message : "Failed to load workspaces",
);
} finally {
setLoading(false);
}
}, [projectId, repoId]);
useEffect(() => {
refresh();
}, [refresh]);
useEffect(() => {
refresh();
}, [refresh]);
return { workspaces, loading, error, refresh };
return { workspaces, loading, error, refresh };
}