Skip to content

Commit 15e78a4

Browse files
committed
feat: use rq instead of use ef
1 parent 59e6430 commit 15e78a4

File tree

2 files changed

+16
-32
lines changed

2 files changed

+16
-32
lines changed

pnpm-workspace.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,4 @@ packages:
33

44
onlyBuiltDependencies:
55
- electron
6-
- esbuild
7-
8-
overrides:
9-
'@posthog/agent': link:../agent
6+
- esbuild

src/renderer/components/TaskArtifacts.tsx

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { FileTextIcon } from "@radix-ui/react-icons";
22
import { Box, Card, Flex, Text, Tooltip } from "@radix-ui/themes";
33
import type { TaskArtifact } from "@shared/types";
4+
import { useQuery } from "@tanstack/react-query";
45
import { formatDistanceToNow } from "date-fns";
5-
import { useEffect, useState } from "react";
66

77
interface TaskArtifactsProps {
88
taskId: string;
@@ -17,34 +17,21 @@ export function TaskArtifacts({
1717
selectedArtifact,
1818
onArtifactSelect,
1919
}: TaskArtifactsProps) {
20-
const [artifacts, setArtifacts] = useState<TaskArtifact[]>([]);
21-
22-
useEffect(() => {
23-
if (!repoPath || !taskId) return;
24-
25-
const loadArtifacts = async () => {
26-
try {
27-
const files = await window.electronAPI?.listTaskArtifacts(
28-
repoPath,
29-
taskId,
30-
);
31-
if (files) {
32-
setArtifacts(files as TaskArtifact[]);
33-
}
34-
} catch (error) {
35-
console.error("Failed to load task artifacts:", error);
20+
const { data: artifacts = [] } = useQuery({
21+
queryKey: ["task-artifacts", repoPath, taskId],
22+
enabled: !!repoPath && !!taskId,
23+
refetchInterval: 5000,
24+
queryFn: async () => {
25+
if (!window.electronAPI) {
26+
throw new Error("Electron API unavailable");
3627
}
37-
};
38-
39-
loadArtifacts();
40-
41-
// Auto-refresh artifacts every 5 seconds
42-
const interval = setInterval(() => {
43-
loadArtifacts();
44-
}, 5000);
45-
46-
return () => clearInterval(interval);
47-
}, [repoPath, taskId]);
28+
const files = await window.electronAPI.listTaskArtifacts(
29+
repoPath as string,
30+
taskId,
31+
);
32+
return (files as TaskArtifact[]) ?? [];
33+
},
34+
});
4835

4936
if (!repoPath || artifacts.length === 0) {
5037
return null;

0 commit comments

Comments
 (0)