Skip to content

Commit dfc71e3

Browse files
committed
fix: resolve typescript errors in frontend and enable type checks everywhere
1 parent 2808590 commit dfc71e3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1562
-352
lines changed

justfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,7 @@ check-frontend:
9191
try:
9292
subprocess.run(['bun', 'run', '--cwd', 'src-frontend', 'prettier', '--check', '.'], check=True)
9393
subprocess.run(['bun', 'run', '--cwd', 'src-frontend', 'lint'], check=True)
94-
95-
# TODO: Uncomment this once the type errors are fixed.
96-
# subprocess.run(['bun', 'run', '--cwd', 'src-frontend', 'tsc', '--noEmit'], check=True)
94+
subprocess.run(['bun', 'run', '--cwd', 'src-frontend', 'tsc', '--noEmit'], check=True)
9795

9896
print(f"\n{{ _green }}Frontend code quality check completed successfully.{{ _nc }}\n")
9997
except subprocess.CalledProcessError as e:
@@ -157,6 +155,10 @@ tidy-frontend:
157155
try:
158156
subprocess.run(['bun', 'run', '--cwd', 'src-frontend', 'prettier', '--write', '.'], check=True)
159157
subprocess.run(['bun', 'run', '--cwd', 'src-frontend', 'lint', '--fix'], check=True)
158+
159+
# This doesn't fix the type errors, but it's good to ensure it returns 0 (success).
160+
subprocess.run(['bun', 'run', '--cwd', 'src-frontend', 'tsc', '--noEmit'], check=True)
161+
160162
print(f"\n{{ _green }}Frontend code tidied up successfully.{{ _nc }}\n")
161163
except subprocess.CalledProcessError as e:
162164
sys.exit(e.returncode)

src-frontend/app/(desktop-only)/updates/page.tsx

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ export default function UpdatePage() {
5757
let unlisten: (() => void) | undefined;
5858

5959
const updateWindowStateListener = async () => {
60-
if (typeof window !== "undefined") {
60+
if (
61+
typeof window !== "undefined" &&
62+
typeof window.__TAURI__ !== "undefined"
63+
) {
6164
// Get initial state
6265
const initialState =
6366
await window.__TAURI__.core.invoke<UpdateWindowState>(
@@ -70,7 +73,7 @@ export default function UpdatePage() {
7073
window.__TAURI__.webviewWindow.getCurrentWebviewWindow();
7174
unlisten = await appWebview.listen<UpdateWindowState>(
7275
"update-window-state",
73-
(event) => {
76+
(event: { payload: UpdateWindowState }) => {
7477
setState(event.payload);
7578
},
7679
);
@@ -94,22 +97,35 @@ export default function UpdatePage() {
9497
}
9598
}, [state.progress, state.updateWindowType]);
9699

97-
const onUpdate = () => {
100+
const onUpdate = (): void => {
98101
setState((prev) => ({ ...prev, updateWindowType: Type.downloading }));
99-
window.__TAURI__.core.invoke("update_window_response", {
100-
installUpdate: true,
101-
});
102+
if (
103+
typeof window !== "undefined" &&
104+
typeof window.__TAURI__ !== "undefined"
105+
) {
106+
window.__TAURI__.core.invoke("update_window_response", {
107+
installUpdate: true,
108+
});
109+
}
102110
};
103111

104-
const onLater = () => {
105-
window.__TAURI__.core.invoke("update_window_response", {
106-
installUpdate: false,
107-
});
112+
const onLater = (): void => {
113+
if (
114+
typeof window !== "undefined" &&
115+
typeof window.__TAURI__ !== "undefined"
116+
) {
117+
window.__TAURI__.core.invoke("update_window_response", {
118+
installUpdate: false,
119+
});
120+
}
108121
closeHandler();
109122
};
110123

111-
const closeHandler = () => {
112-
if (window.__TAURI__) {
124+
const closeHandler = (): void => {
125+
if (
126+
typeof window !== "undefined" &&
127+
typeof window.__TAURI__ !== "undefined"
128+
) {
113129
window.__TAURI__.window.getCurrentWindow().close();
114130
}
115131
};
@@ -323,16 +339,19 @@ export default function UpdatePage() {
323339
<Markdown
324340
remarkPlugins={[remarkGfm]}
325341
components={{
326-
a: ({ href, children }) => (
342+
a: (props: {
343+
href?: string;
344+
children?: React.ReactNode;
345+
}) => (
327346
<a
328347
href="#"
329-
onClick={(e) => {
348+
onClick={(e: React.MouseEvent<HTMLAnchorElement>) => {
330349
e.preventDefault();
331-
if (href) openPath(href);
350+
if (props.href) openPath(props.href);
332351
}}
333352
className="text-blue-600 hover:text-blue-800 dark:text-blue-400 dark:hover:text-blue-300"
334353
>
335-
{children}
354+
{props.children}
336355
</a>
337356
),
338357
}}

src-frontend/app/workspace/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function FilesPageContent() {
1616
const { setBreadcrumb, clearBreadcrumb } = useBreadcrumbStore();
1717

1818
useEffect(() => {
19-
initializeFileSystemStore(initialPath);
19+
initializeFileSystemStore(initialPath ? initialPath.split("/") : []);
2020
}, [initialPath]);
2121

2222
useEffect(() => {

src-frontend/bun.lockb

4.04 KB
Binary file not shown.

src-frontend/components/app-sidebar.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,17 @@ export function AppSidebar() {
221221
const item = JSON.parse(data);
222222
const { addFavorite } = useSidebarStore.getState();
223223
if (item.type === "folder") {
224+
// Convert string path to array format expected by FavoriteItem
225+
// FileSystemItem.path is a string like "/apps" or "/folder/subfolder"
226+
const pathArray = item.path
227+
? item.path.split("/").filter(Boolean)
228+
: [];
229+
224230
addFavorite({
225231
id: item.id,
226232
name: item.name,
227233
type: "folder",
228-
path: [...item.path, item.name],
234+
path: pathArray,
229235
});
230236
} else if (item.type === "app") {
231237
addFavorite({

src-frontend/components/apps/app-detail.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ export function AppDetail({ appId, onBack }: AppDetailProps) {
269269
}
270270
};
271271

272-
const updateActiveTab = (tab: string) => {
272+
const updateActiveTab = (tab: string): void => {
273273
setActiveTab(tab);
274274
fetchApp();
275275
};

src-frontend/components/apps/app-files.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { getWorkspaceItems } from "@/lib/api/workspace";
44
import { Layers, FileText, ChevronLeft, Database } from "lucide-react";
55
import { useEffect, useState, useCallback } from "react";
66
import { FilePreview } from "../workspace/file-preview";
7+
import type { FileSystemItem } from "@/lib/types";
78

89
export function AppFiles({ appPath }: { appPath: string }) {
910
const router = useRouter();

src-frontend/components/apps/app-interface.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { ExternalLink, Play, RefreshCcw, Terminal } from "lucide-react";
22
import { Button } from "@/components/ui/button";
33
import { useEffect } from "react";
4+
import { App } from "@/lib/api/apps";
45

56
interface AppInterfaceProps {
67
app: App;

src-frontend/components/apps/app-list.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ import { AppBreadcrumb } from "./apps-breadcrumb";
6464
const installFormSchema = z.object({
6565
repoURL: z.string().url("Must be a valid Git repository URL"),
6666
branch: z.string(),
67-
force: z.boolean().default(false),
67+
force: z.boolean(),
6868
});
69-
// Install form type
69+
// Install form type - inferred from schema
7070
type InstallFormValues = z.infer<typeof installFormSchema>;
7171

7272
interface AppListProps {
@@ -97,7 +97,7 @@ export function AppList({ onSelectApp }: AppListProps) {
9797
});
9898

9999
useEffect(() => {
100-
setBreadcrumb(<AppBreadcrumb />);
100+
setBreadcrumb(<AppBreadcrumb app={null} />);
101101
return () => clearBreadcrumb();
102102
}, [setBreadcrumb, clearBreadcrumb]);
103103

src-frontend/components/apps/app-logs.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import { useEffect, useState, useRef, useCallback } from "react";
33
import { ArrowDown } from "lucide-react";
44
import { Button } from "@/components/ui/button";
55
import { ScrollArea } from "@/components/ui/scroll-area";
6-
import { getLogs, type LogsResponse } from "@/lib/api/logs";
6+
import { getLogs, type ParsedLogResponse } from "@/lib/api/logs";
77
import { Badge } from "@/components/ui/badge";
88
import { useVirtualizer } from "@tanstack/react-virtual";
99

1010
const MAX_LOGS = 5000; // Limit logs for app view
1111

1212
export function AppLogs({ appId }: { appId: string }) {
13-
const [logs, setLogs] = useState<LogsResponse["logs"]>([]);
13+
const [logs, setLogs] = useState<ParsedLogResponse["logs"]>([]);
1414
const [nextToken, setNextToken] = useState<number>(1);
1515
const [isAutoScroll, setIsAutoScroll] = useState(false);
1616
const scrollAreaRef = useRef<HTMLDivElement>(null);

0 commit comments

Comments
 (0)