Skip to content

Commit 730b177

Browse files
committed
Fix remaining CI failures: rustfmt, TypeScript errors
- cargo fmt across all modified files - Add Vite client types and Window.__SPACEDRIVE__ declaration - Fix @sd/interface/platform import to @sd/interface - Align @types/react versions between tauri and interface packages - Remove unused imports/vars in useDropZone, DragOverlay, ContextMenuWindow - Fix WebviewWindow.location references to use globalThis - Exclude updater.example.ts from typecheck
1 parent acde17c commit 730b177

15 files changed

Lines changed: 63 additions & 67 deletions

File tree

apps/server/src/main.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ use clap::Parser;
1515
use futures::stream::{Stream, StreamExt};
1616
use rust_embed::Embed;
1717
use secstr::SecStr;
18-
use std::{collections::HashMap, convert::Infallible, net::SocketAddr, path::PathBuf, sync::Arc, time::Duration};
18+
use std::{
19+
collections::HashMap, convert::Infallible, net::SocketAddr, path::PathBuf, sync::Arc,
20+
time::Duration,
21+
};
1922
use tokio::{
2023
io::{AsyncBufReadExt, AsyncWriteExt, BufReader},
2124
net::TcpStream,
@@ -135,9 +138,8 @@ async fn events_sse(
135138
}
136139
});
137140

138-
let stream = ReceiverStream::new(rx).map(|line| {
139-
Ok::<SseEvent, Infallible>(SseEvent::default().data(line))
140-
});
141+
let stream = ReceiverStream::new(rx)
142+
.map(|line| Ok::<SseEvent, Infallible>(SseEvent::default().data(line)));
141143

142144
Sse::new(stream).keep_alive(
143145
KeepAlive::new()
@@ -186,8 +188,7 @@ async fn bridge_daemon_events(
186188
// acks and anything else the daemon might emit.
187189
match serde_json::from_str::<serde_json::Value>(trimmed) {
188190
Ok(value) => {
189-
let is_payload = value.get("Event").is_some()
190-
|| value.get("LogMessage").is_some();
191+
let is_payload = value.get("Event").is_some() || value.get("LogMessage").is_some();
191192
if !is_payload {
192193
continue;
193194
}

apps/tauri/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"@sd/assets": "workspace:*",
2525
"@sd/interface": "workspace:*",
2626
"@sd/ts-client": "workspace:*",
27+
"@spacedrive/primitives": "^0.2.3",
2728
"@tauri-apps/api": "^2.1.1",
2829
"@tauri-apps/plugin-dialog": "^2.4.2",
2930
"@tauri-apps/plugin-fs": "^2.0.1",
@@ -40,8 +41,8 @@
4041
"@tailwindcss/typography": "^0.5.10",
4142
"@tailwindcss/vite": "^4.1.0",
4243
"@tauri-apps/cli": "^2.1.0",
43-
"@types/react": "npm:types-react@rc",
44-
"@types/react-dom": "npm:types-react-dom@rc",
44+
"@types/react": "19.2.14",
45+
"@types/react-dom": "19.2.3",
4546
"tailwindcss": "^4.1.0",
4647
"tailwindcss-animate": "^1.0.7",
4748
"tailwindcss-radix": "^2.8.0",

apps/tauri/src/env.d.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/// <reference types="vite/client" />
2+
3+
interface SpacedriveGlobal {
4+
showContextMenu?: (
5+
items: import("@sd/interface").ContextMenuItem[],
6+
position: { x: number; y: number }
7+
) => Promise<void>;
8+
registerKeybind?: (
9+
id: string,
10+
accelerator: string,
11+
handler: () => void | Promise<void>
12+
) => Promise<void>;
13+
unregisterKeybind?: (id: string) => Promise<void>;
14+
}
15+
16+
interface Window {
17+
__SPACEDRIVE__: SpacedriveGlobal;
18+
}

apps/tauri/src/hooks/useDropZone.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import { useEffect, useState, useCallback, useRef } from 'react';
1+
import { useEffect, useState, useRef } from 'react';
22
import { getCurrentWebviewWindow } from '@tauri-apps/api/webviewWindow';
33
import {
44
onDragEntered,
55
onDragLeft,
66
onDragEnded,
77
type DragItem,
8-
type DragResult,
98
} from '../lib/drag';
109

1110
export interface UseDropZoneOptions {

apps/tauri/src/platform.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { open as shellOpen } from "@tauri-apps/plugin-shell";
33
import { convertFileSrc as tauriConvertFileSrc, invoke } from "@tauri-apps/api/core";
44
import { listen } from "@tauri-apps/api/event";
55
import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow";
6-
import type { Platform } from "@sd/interface/platform";
6+
import type { Platform } from "@sd/interface";
77
import { beginDrag, onDragBegan, onDragMoved, onDragEntered, onDragLeft, onDragEnded } from "./lib/drag";
88

99
let _isDragging = false;
@@ -272,7 +272,7 @@ export const platform: Platform = {
272272
},
273273

274274
async onDragEvent(event, callback) {
275-
const handlers: Record<string, typeof onDragBegan> = {
275+
const handlers: Record<string, (handler: (payload: any) => void) => Promise<() => void>> = {
276276
began: onDragBegan,
277277
moved: onDragMoved,
278278
entered: onDragEntered,

apps/tauri/src/routes/ContextMenuWindow.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { invoke } from "@tauri-apps/api/core";
22
import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow";
33
import { ContextMenu } from "@spacedrive/primitives";
4+
import type { Icon } from "@phosphor-icons/react";
45
import { useEffect, useRef, useState } from "react";
56

67
export interface MenuItem {
78
type?: "separator";
8-
icon?: React.ElementType;
9+
icon?: Icon;
910
label?: string;
1011
onClick?: () => void;
1112
keybind?: string;
@@ -22,20 +23,18 @@ export interface ContextMenuData {
2223

2324
export function ContextMenuWindow() {
2425
const [items, setItems] = useState<MenuItem[]>([]);
25-
const [contextId, setContextId] = useState<string | null>(null);
2626
const menuRef = useRef<HTMLDivElement>(null);
27-
const window = getCurrentWebviewWindow();
27+
const webviewWindow = getCurrentWebviewWindow();
2828

2929
useEffect(() => {
3030
console.log('[ContextMenuWindow] Component mounted');
31-
console.log('[ContextMenuWindow] Window location:', window.location.href);
31+
console.log('[ContextMenuWindow] Window location:', globalThis.location.href);
3232

3333
// Extract context ID from URL params
34-
const params = new URLSearchParams(window.location.search);
34+
const params = new URLSearchParams(globalThis.location.search);
3535
const id = params.get("context");
3636
console.log('[ContextMenuWindow] Context ID from params:', id);
3737
console.log('[ContextMenuWindow] All params:', Array.from(params.entries()));
38-
setContextId(id);
3938

4039
if (!id) {
4140
console.error("[ContextMenuWindow] No context ID provided");
@@ -65,7 +64,7 @@ export function ContextMenuWindow() {
6564

6665
// Position the menu at the cursor
6766
invoke("position_context_menu", {
68-
label: window.label,
67+
label: webviewWindow.label,
6968
x: data.x,
7069
y: data.y,
7170
menuWidth: width,
@@ -84,10 +83,10 @@ export function ContextMenuWindow() {
8483

8584
// Close on blur (when clicking outside)
8685
const handleBlur = async () => {
87-
invoke("close_window", { label: window.label }).catch(console.error);
86+
invoke("close_window", { label: webviewWindow.label }).catch(console.error);
8887
};
8988

90-
window.listen("tauri://blur", handleBlur);
89+
webviewWindow.listen("tauri://blur", handleBlur);
9190

9291
return () => {
9392
// Cleanup handled by Tauri
@@ -99,7 +98,7 @@ export function ContextMenuWindow() {
9998
item.onClick();
10099
}
101100
// Close menu after click
102-
invoke("close_window", { label: window.label }).catch(console.error);
101+
invoke("close_window", { label: webviewWindow.label }).catch(console.error);
103102
};
104103

105104
const renderItem = (item: MenuItem, index: number) => {

apps/tauri/src/routes/DragOverlay.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { useEffect, useState } from 'react';
2-
import { getDragSession, onDragMoved, type DragSession } from '../lib/drag';
2+
import { getDragSession, type DragSession } from '../lib/drag';
33

44
export function DragOverlay() {
55
const [session, setSession] = useState<DragSession | null>(null);
6-
const [position, setPosition] = useState({ x: 0, y: 0 });
76

87
useEffect(() => {
98
// Get the session from query params
@@ -13,14 +12,6 @@ export function DragOverlay() {
1312
if (sessionId) {
1413
getDragSession().then((s) => setSession(s));
1514
}
16-
17-
const unlisten = onDragMoved((event) => {
18-
setPosition({ x: event.x, y: event.y });
19-
});
20-
21-
return () => {
22-
unlisten.then((fn) => fn());
23-
};
2415
}, []);
2516

2617
if (!session) {

apps/tauri/src/updater.example.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* You can adapt this code to fit your UI/UX requirements.
66
*/
77

8-
import { check, Update } from '@tauri-apps/plugin-updater';
8+
import { check } from '@tauri-apps/plugin-updater';
99
import { relaunch } from '@tauri-apps/plugin-process';
1010

1111
export interface UpdateCheckResult {

apps/tauri/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@
2828
"@spacebot/api-client/*": ["../../../spacebot/packages/api-client/src/*"]
2929
}
3030
},
31-
"include": ["src", "vite.config.ts"]
31+
"include": ["src", "vite.config.ts"],
32+
"exclude": ["src/updater.example.ts"]
3233
}

apps/tauri/vite.config.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import tailwindcss from '@tailwindcss/vite';
33
import react from '@vitejs/plugin-react-swc';
44
import {defineConfig} from 'vite';
55

6-
const COMMANDS = ['initialize_core', 'core_rpc', 'subscribe_events'];
7-
8-
export default defineConfig(async () => ({
6+
export default defineConfig(() => ({
97
plugins: [react(), tailwindcss()],
108

119
resolve: {
@@ -126,7 +124,7 @@ export default defineConfig(async () => ({
126124
envPrefix: ['VITE_', 'TAURI_ENV_*'],
127125
build: {
128126
target: ['es2021', 'chrome100', 'safari13'],
129-
minify: !process.env.TAURI_ENV_DEBUG ? 'esbuild' : false,
127+
minify: !process.env.TAURI_ENV_DEBUG ? ('esbuild' as const) : false,
130128
sourcemap: !!process.env.TAURI_ENV_DEBUG
131129
}
132130
}));

0 commit comments

Comments
 (0)