Skip to content

Commit 3e9129d

Browse files
committed
fix: typescheck
1 parent a6e2adc commit 3e9129d

File tree

10 files changed

+217
-55
lines changed

10 files changed

+217
-55
lines changed

pnpm-lock.yaml

Lines changed: 146 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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/features/task-detail/components/FileTreePanel.tsx

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import { useTaskData } from "@features/task-detail/hooks/useTaskData";
12
import { FileIcon, FolderIcon, FolderOpenIcon } from "@phosphor-icons/react";
23
import { Box, Flex, Text } from "@radix-ui/themes";
34
import type { Task } from "@shared/types";
45
import { useQuery } from "@tanstack/react-query";
56
import { useState } from "react";
6-
import { useTaskData } from "@features/task-detail/hooks/useTaskData";
77

88
interface FileTreePanelProps {
99
taskId: string;
@@ -17,8 +17,17 @@ interface TreeNode {
1717
path: string;
1818
}
1919

20-
function buildTreeFromPaths(files: Array<{ path: string; name: string }>): TreeNode[] {
21-
const root: Record<string, TreeNode> = {};
20+
interface TreeNodeBuilder {
21+
name: string;
22+
type: "file" | "folder";
23+
children?: Record<string, TreeNodeBuilder>;
24+
path: string;
25+
}
26+
27+
function buildTreeFromPaths(
28+
files: Array<{ path: string; name: string }>,
29+
): TreeNode[] {
30+
const root: Record<string, TreeNodeBuilder> = {};
2231

2332
for (const file of files) {
2433
const parts = file.path.split("/").filter(Boolean);
@@ -39,13 +48,13 @@ function buildTreeFromPaths(files: Array<{ path: string; name: string }>): TreeN
3948
}
4049

4150
if (!isLastPart && currentLevel[part].children) {
42-
currentLevel = currentLevel[part].children as Record<string, TreeNode>;
51+
currentLevel = currentLevel[part].children;
4352
}
4453
}
4554
}
4655

4756
// Convert children objects to arrays and sort
48-
const convertToArray = (node: TreeNode): TreeNode => {
57+
const convertToArray = (node: TreeNodeBuilder): TreeNode => {
4958
if (node.children && typeof node.children === "object") {
5059
const childrenArray = Object.values(node.children)
5160
.map(convertToArray)
@@ -56,9 +65,19 @@ function buildTreeFromPaths(files: Array<{ path: string; name: string }>): TreeN
5665
}
5766
return a.name.localeCompare(b.name);
5867
});
59-
return { ...node, children: childrenArray };
68+
return {
69+
name: node.name,
70+
type: node.type,
71+
path: node.path,
72+
children: childrenArray,
73+
};
6074
}
61-
return node;
75+
return {
76+
name: node.name,
77+
type: node.type,
78+
path: node.path,
79+
children: undefined,
80+
};
6281
};
6382

6483
return Object.values(root)
@@ -96,7 +115,7 @@ function TreeItem({ node, depth }: TreeItemProps) {
96115
paddingLeft: `${depth * 16 + 8}px`,
97116
cursor: node.type === "folder" ? "pointer" : "default",
98117
}}
99-
className="hover:bg-gray-2 rounded"
118+
className="rounded hover:bg-gray-2"
100119
onClick={handleToggle}
101120
>
102121
{node.type === "folder" ? (
@@ -115,7 +134,11 @@ function TreeItem({ node, depth }: TreeItemProps) {
115134
{node.type === "folder" && isExpanded && node.children && (
116135
<Box>
117136
{node.children.map((child, index) => (
118-
<TreeItem key={`${child.name}-${index}`} node={child} depth={depth + 1} />
137+
<TreeItem
138+
key={`${child.name}-${index}`}
139+
node={child}
140+
depth={depth + 1}
141+
/>
119142
))}
120143
</Box>
121144
)}

src/renderer/features/task-detail/components/TaskDetail.tsx

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,27 @@ import {
44
PanelLeaf,
55
PanelTab,
66
} from "@features/panels";
7+
import { FileTreePanel } from "@features/task-detail/components/FileTreePanel";
78
import { TaskArtifactEditorPanel } from "@features/task-detail/components/TaskArtifactEditorPanel";
89
import { TaskArtifactsPanel } from "@features/task-detail/components/TaskArtifactsPanel";
910
import { TaskDetailPanel } from "@features/task-detail/components/TaskDetailPanel";
1011
import { TaskLogsPanel } from "@features/task-detail/components/TaskLogsPanel";
1112
import { TaskShellPanel } from "@features/task-detail/components/TaskShellPanel";
1213
import { TodoListPanel } from "@features/task-detail/components/TodoListPanel";
13-
import { FileTreePanel } from "@features/task-detail/components/FileTreePanel";
1414
import { useTaskData } from "@features/task-detail/hooks/useTaskData";
1515
import { useTaskExecution } from "@features/task-detail/hooks/useTaskExecution";
1616
import { useTaskPanelLayoutStore } from "@features/task-detail/stores/taskPanelLayoutStore";
1717
import { useBlurOnEscape } from "@hooks/useBlurOnEscape";
1818
import { useStatusBar } from "@hooks/useStatusBar";
19-
import { CheckSquareIcon, FolderIcon, InfoIcon, ListIcon, NotePencilIcon, StackIcon, TerminalIcon } from "@phosphor-icons/react";
19+
import {
20+
CheckSquareIcon,
21+
FolderIcon,
22+
InfoIcon,
23+
ListIcon,
24+
NotePencilIcon,
25+
StackIcon,
26+
TerminalIcon,
27+
} from "@phosphor-icons/react";
2028
import { Flex } from "@radix-ui/themes";
2129
import type { Task } from "@shared/types";
2230
import { useCallback } from "react";
@@ -151,18 +159,26 @@ export function TaskDetail({ task: initialTask }: TaskDetailProps) {
151159
id="todo-list"
152160
label="Todo list"
153161
icon={
154-
<CheckSquareIcon size={12} weight="bold" color="var(--gray-11)" />
162+
<CheckSquareIcon
163+
size={12}
164+
weight="bold"
165+
color="var(--gray-11)"
166+
/>
155167
}
156168
>
157-
<TodoListPanel taskId={taskId} task={task} />
169+
<TodoListPanel taskId={taskId} />
158170
</PanelTab>
159171
</PanelLeaf>
160172
<PanelLeaf droppable={false}>
161173
<PanelTab
162174
id="file-tree"
163175
label="Files"
164176
icon={
165-
<FolderIcon size={12} weight="bold" color="var(--gray-11)" />
177+
<FolderIcon
178+
size={12}
179+
weight="bold"
180+
color="var(--gray-11)"
181+
/>
166182
}
167183
>
168184
<FileTreePanel taskId={taskId} task={task} />

0 commit comments

Comments
 (0)