Skip to content

Commit efdeff7

Browse files
committed
fix(build): resolve TypeScript errors and add missing dependencies
- Add missing zustand dependency to package.json - Fix unused variable errors in ToolWidgets.tsx - Remove invalid 'white' theme comparison in claudeSyntaxTheme.ts - Add proper TypeScript types to stores using StateCreator pattern - Add null checks and type casting in Settings.tsx filter operations - Add onChange handler to Switch component to suppress React warning - Add 'check' script for TypeScript validation These changes ensure the TypeScript build passes without errors.
1 parent c87d36e commit efdeff7

File tree

8 files changed

+53
-35
lines changed

8 files changed

+53
-35
lines changed

bun.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"tailwind-merge": "^2.6.0",
4545
"tailwindcss": "^4.1.8",
4646
"zod": "^3.24.1",
47+
"zustand": "^5.0.6",
4748
},
4849
"devDependencies": {
4950
"@tauri-apps/cli": "^2",
@@ -1021,6 +1022,8 @@
10211022

10221023
"zod": ["[email protected]", "", {}, "sha512-idA2YXwpCdqUSKRCACDE6ItZD9TZzy3OZMtpfLoh6oPR47lipysRrJfjzMqFxQ3uJuUPyUeWe1r9vLH33xO/Qw=="],
10231024

1025+
"zustand": ["[email protected]", "", { "peerDependencies": { "@types/react": ">=18.0.0", "immer": ">=9.0.6", "react": ">=18.0.0", "use-sync-external-store": ">=1.2.0" }, "optionalPeers": ["@types/react", "immer", "react", "use-sync-external-store"] }, "sha512-ihAqNeUVhe0MAD+X8M5UzqyZ9k3FFZLBTtqo6JLPwV53cbRB/mJwBI0PxcIgqhBBHlEs8G45OTDTMq3gNcLq3A=="],
1026+
10241027
"zwitch": ["[email protected]", "", {}, "sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A=="],
10251028

10261029
"@babel/core/semver": ["[email protected]", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA=="],

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"dev": "vite",
99
"build": "tsc && vite build",
1010
"preview": "vite preview",
11-
"tauri": "tauri"
11+
"tauri": "tauri",
12+
"check": "tsc --noEmit && cd src-tauri && cargo check"
1213
},
1314
"dependencies": {
1415
"@hookform/resolvers": "^3.9.1",

src/components/Settings.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,12 @@ export const Settings: React.FC<SettingsProps> = ({
170170
const updatedSettings: ClaudeSettings = {
171171
...settings,
172172
permissions: {
173-
allow: allowRules.map(rule => rule.value).filter(v => v.trim()),
174-
deny: denyRules.map(rule => rule.value).filter(v => v.trim()),
173+
allow: allowRules.map(rule => rule.value).filter(v => v && String(v).trim()),
174+
deny: denyRules.map(rule => rule.value).filter(v => v && String(v).trim()),
175175
},
176176
env: envVars.reduce((acc, { key, value }) => {
177-
if (key.trim() && value.trim()) {
178-
acc[key] = value;
177+
if (key && String(key).trim() && value && String(value).trim()) {
178+
acc[key] = String(value);
179179
}
180180
return acc;
181181
}, {} as Record<string, string>),

src/components/ToolWidgets.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -632,9 +632,6 @@ export const BashWidget: React.FC<{
632632
description?: string;
633633
result?: any;
634634
}> = ({ command, description, result }) => {
635-
const { theme } = useTheme();
636-
const syntaxTheme = getClaudeSyntaxTheme(theme);
637-
638635
// Extract result content if available
639636
let resultContent = '';
640637
let isError = false;

src/components/ui/switch.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const Switch = React.forwardRef<HTMLInputElement, SwitchProps>(
5252
checked={checked}
5353
disabled={disabled}
5454
className="sr-only"
55+
onChange={() => {}}
5556
{...props}
5657
/>
5758
</button>

src/lib/claudeSyntaxTheme.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export const getClaudeSyntaxTheme = (theme: ThemeMode): any => {
124124
overflow: 'auto',
125125
},
126126
':not(pre) > code[class*="language-"]': {
127-
background: theme === 'light' || theme === 'white'
127+
background: theme === 'light'
128128
? 'rgba(139, 92, 246, 0.1)'
129129
: 'rgba(139, 92, 246, 0.1)',
130130
padding: '0.1em 0.3em',

src/stores/agentStore.ts

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { create } from 'zustand';
22
import { subscribeWithSelector } from 'zustand/middleware';
3+
import type { StateCreator } from 'zustand';
34
import { api } from '@/lib/api';
45
import type { AgentRunWithMetrics } from '@/lib/api';
56

@@ -32,8 +33,12 @@ interface AgentState {
3233
pollingInterval: NodeJS.Timeout | null;
3334
}
3435

35-
export const useAgentStore = create<AgentState>()(
36-
subscribeWithSelector((set, get) => ({
36+
const agentStore: StateCreator<
37+
AgentState,
38+
[],
39+
[['zustand/subscribeWithSelector', never]],
40+
AgentState
41+
> = (set, get) => ({
3742
// Initial state
3843
agentRuns: [],
3944
runningAgents: new Set(),
@@ -59,8 +64,8 @@ export const useAgentStore = create<AgentState>()(
5964
try {
6065
const runs = await api.listAgentRuns();
6166
const runningIds = runs
62-
.filter(r => r.status === 'running' || r.status === 'pending')
63-
.map(r => r.id?.toString() || '')
67+
.filter((r) => r.status === 'running' || r.status === 'pending')
68+
.map((r) => r.id?.toString() || '')
6469
.filter(Boolean);
6570

6671
set({
@@ -83,7 +88,7 @@ export const useAgentStore = create<AgentState>()(
8388

8489
try {
8590
const output = await api.getAgentRunWithRealTimeMetrics(runId).then(run => run.output || '');
86-
set(state => ({
91+
set((state) => ({
8792
sessionOutputs: {
8893
...state.sessionOutputs,
8994
[runId]: output
@@ -107,7 +112,7 @@ export const useAgentStore = create<AgentState>()(
107112
const run = await api.getAgentRun(runId);
108113

109114
// Update local state immediately
110-
set(state => ({
115+
set((state) => ({
111116
agentRuns: [run, ...state.agentRuns],
112117
runningAgents: new Set([...state.runningAgents, runId.toString()])
113118
}));
@@ -127,8 +132,8 @@ export const useAgentStore = create<AgentState>()(
127132
await api.killAgentSession(runId);
128133

129134
// Update local state
130-
set(state => ({
131-
agentRuns: state.agentRuns.map(r =>
135+
set((state) => ({
136+
agentRuns: state.agentRuns.map((r) =>
132137
r.id === runId ? { ...r, status: 'cancelled' } : r
133138
),
134139
runningAgents: new Set(
@@ -147,7 +152,7 @@ export const useAgentStore = create<AgentState>()(
147152
deleteAgentRun: async (runId: number) => {
148153
try {
149154
// First ensure the run is cancelled if it's still running
150-
const run = get().agentRuns.find(r => r.id === runId);
155+
const run = get().agentRuns.find((r) => r.id === runId);
151156
if (run && (run.status === 'running' || run.status === 'pending')) {
152157
await api.killAgentSession(runId);
153158
}
@@ -156,8 +161,8 @@ export const useAgentStore = create<AgentState>()(
156161
// The run will remain in the database but won't be shown in the UI
157162

158163
// Update local state
159-
set(state => ({
160-
agentRuns: state.agentRuns.filter(r => r.id !== runId),
164+
set((state) => ({
165+
agentRuns: state.agentRuns.filter((r) => r.id !== runId),
161166
runningAgents: new Set(
162167
[...state.runningAgents].filter(id => id !== runId.toString())
163168
),
@@ -178,8 +183,8 @@ export const useAgentStore = create<AgentState>()(
178183

179184
// Handle real-time agent run updates
180185
handleAgentRunUpdate: (run: AgentRunWithMetrics) => {
181-
set(state => {
182-
const existingIndex = state.agentRuns.findIndex(r => r.id === run.id);
186+
set((state) => {
187+
const existingIndex = state.agentRuns.findIndex((r) => r.id === run.id);
183188
const updatedRuns = [...state.agentRuns];
184189

185190
if (existingIndex >= 0) {
@@ -189,8 +194,8 @@ export const useAgentStore = create<AgentState>()(
189194
}
190195

191196
const runningIds = updatedRuns
192-
.filter(r => r.status === 'running' || r.status === 'pending')
193-
.map(r => r.id?.toString() || '')
197+
.filter((r) => r.status === 'running' || r.status === 'pending')
198+
.map((r) => r.id?.toString() || '')
194199
.filter(Boolean);
195200

196201
return {
@@ -228,5 +233,8 @@ export const useAgentStore = create<AgentState>()(
228233
set({ pollingInterval: null });
229234
}
230235
}
231-
}))
236+
});
237+
238+
export const useAgentStore = create<AgentState>()(
239+
subscribeWithSelector(agentStore)
232240
);

src/stores/sessionStore.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { create } from 'zustand';
22
import { subscribeWithSelector } from 'zustand/middleware';
3+
import type { StateCreator } from 'zustand';
34
import { api } from '@/lib/api';
45
import type { Session, Project } from '@/lib/api';
56

@@ -30,8 +31,12 @@ interface SessionState {
3031
handleOutputUpdate: (sessionId: string, output: string) => void;
3132
}
3233

33-
export const useSessionStore = create<SessionState>()(
34-
subscribeWithSelector((set, get) => ({
34+
const sessionStore: StateCreator<
35+
SessionState,
36+
[],
37+
[['zustand/subscribeWithSelector', never]],
38+
SessionState
39+
> = (set, get) => ({
3540
// Initial state
3641
projects: [],
3742
sessions: {},
@@ -62,7 +67,7 @@ export const useSessionStore = create<SessionState>()(
6267
set({ isLoadingSessions: true, error: null });
6368
try {
6469
const projectSessions = await api.getProjectSessions(projectId);
65-
set(state => ({
70+
set((state) => ({
6671
sessions: {
6772
...state.sessions,
6873
[projectId]: projectSessions
@@ -85,7 +90,7 @@ export const useSessionStore = create<SessionState>()(
8590
if (sessionId) {
8691
// Find session across all projects
8792
for (const projectSessions of Object.values(sessions)) {
88-
const found = projectSessions.find(s => s.id === sessionId);
93+
const found = projectSessions.find((s) => s.id === sessionId);
8994
if (found) {
9095
currentSession = found;
9196
break;
@@ -101,7 +106,7 @@ export const useSessionStore = create<SessionState>()(
101106
set({ isLoadingOutputs: true, error: null });
102107
try {
103108
const output = await api.getClaudeSessionOutput(sessionId);
104-
set(state => ({
109+
set((state) => ({
105110
sessionOutputs: {
106111
...state.sessionOutputs,
107112
[sessionId]: output
@@ -123,10 +128,10 @@ export const useSessionStore = create<SessionState>()(
123128
console.warn('deleteSession not implemented in API');
124129

125130
// Update local state
126-
set(state => ({
131+
set((state) => ({
127132
sessions: {
128133
...state.sessions,
129-
[projectId]: state.sessions[projectId]?.filter(s => s.id !== sessionId) || []
134+
[projectId]: state.sessions[projectId]?.filter((s) => s.id !== sessionId) || []
130135
},
131136
currentSessionId: state.currentSessionId === sessionId ? null : state.currentSessionId,
132137
currentSession: state.currentSession?.id === sessionId ? null : state.currentSession,
@@ -150,7 +155,7 @@ export const useSessionStore = create<SessionState>()(
150155
set(state => {
151156
const projectId = session.project_id;
152157
const projectSessions = state.sessions[projectId] || [];
153-
const existingIndex = projectSessions.findIndex(s => s.id === session.id);
158+
const existingIndex = projectSessions.findIndex((s) => s.id === session.id);
154159

155160
let updatedSessions;
156161
if (existingIndex >= 0) {
@@ -172,12 +177,15 @@ export const useSessionStore = create<SessionState>()(
172177

173178
// Handle output update
174179
handleOutputUpdate: (sessionId: string, output: string) => {
175-
set(state => ({
180+
set((state) => ({
176181
sessionOutputs: {
177182
...state.sessionOutputs,
178183
[sessionId]: output
179184
}
180185
}));
181186
}
182-
}))
187+
});
188+
189+
export const useSessionStore = create<SessionState>()(
190+
subscribeWithSelector(sessionStore)
183191
);

0 commit comments

Comments
 (0)