Skip to content

Commit d867b45

Browse files
committed
chore: formatting and lint fixes
1 parent dd7cb74 commit d867b45

15 files changed

+87
-77
lines changed

.storybook/preview.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { Preview } from '@storybook/react-vite'
21
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
2+
import type { Preview } from '@storybook/react-vite'
33
import '../src/styles.css'
44

55
const queryClient = new QueryClient({

src/components/BackgroundJobItem.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { Meta, StoryObj } from '@storybook/react'
21
import { BackgroundJobItem } from './BackgroundJobItem'
2+
import type { Meta, StoryObj } from '@storybook/react-vite'
33
import type { BackgroundJob } from '@/lib/schemas'
44

55
const meta: Meta<typeof BackgroundJobItem> = {

src/components/BackgroundJobItem.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import { Clock, Play, Trash2, X } from 'lucide-react'
2+
import { useEffect } from 'react'
13
import { Button } from './ui/button'
2-
import { Clock, Play, X, Trash2 } from 'lucide-react'
3-
import { useBackgroundJobStatus } from '@/hooks/useBackgroundJobStatus'
44
import type { BackgroundJob } from '@/lib/schemas'
5-
import { useEffect } from 'react'
5+
import { useBackgroundJobStatus } from '@/hooks/useBackgroundJobStatus'
66

77
export function BackgroundJobItem({
88
job,

src/components/BackgroundJobsSidebar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import { Clock } from 'lucide-react'
12
import { Sidebar } from './ui/sidebar'
3+
import { BackgroundJobItem } from './BackgroundJobItem'
24
import { useHasMounted } from '@/hooks/useHasMounted'
35
import { useBackgroundJobs } from '@/hooks/useBackgroundJobs'
4-
import { Clock } from 'lucide-react'
5-
import { BackgroundJobItem } from './BackgroundJobItem'
66

77
interface BackgroundJobsSidebarProps {
88
isOpen: boolean

src/components/BackgroundToggle.stories.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ export default meta
2727
type Story = StoryObj<typeof BackgroundToggle>
2828

2929
const Template = (args: any) => {
30-
const [useBackground, setUseBackground] = useState(args.useBackground ?? false)
30+
const [useBackground, setUseBackground] = useState(
31+
args.useBackground ?? false,
32+
)
3133
return (
3234
<BackgroundToggle
3335
{...args}
@@ -95,4 +97,4 @@ export const UnsupportedModelWithMaxJobs: Story = {
9597
disabled: false,
9698
maxJobsReached: true,
9799
},
98-
}
100+
}

src/components/Chat.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
22
import { useChat } from 'ai/react'
3-
import { MessageSquarePlus, Clock } from 'lucide-react'
3+
import { Clock, MessageSquarePlus } from 'lucide-react'
44
import { useModel } from '../contexts/ModelContext'
55
import { useUser } from '../contexts/UserContext'
66
import { generateMessageId } from '../mcp/client'
@@ -206,15 +206,12 @@ export function Chat() {
206206
useEffect(() => {
207207
setMessages((prevMessages) =>
208208
prevMessages.map((message) => {
209-
if (message) {
210-
const job = backgroundJobs.find(
211-
(j) => j.id === message.backgroundJobId,
212-
)
213-
if (job && job.response && job.response !== message.content) {
214-
// Update message content with latest job response
215-
return { ...message, content: job.response }
216-
}
209+
const job = backgroundJobs.find((j) => j.id === message.id)
210+
if (job && job.response && job.response !== message.content) {
211+
// Update message content with latest job response
212+
return { ...message, content: job.response }
217213
}
214+
218215
return message
219216
}),
220217
)

src/components/ui/sidebar.tsx

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react'
2-
import { cn } from '@/lib/utils'
3-
import { Button } from './button'
42
import { X } from 'lucide-react'
3+
import { Button } from './button'
4+
import { cn } from '@/lib/utils'
55

66
interface SidebarProps {
77
children: React.ReactNode
@@ -11,29 +11,26 @@ interface SidebarProps {
1111
className?: string
1212
}
1313

14-
export function Sidebar({
15-
children,
16-
isOpen,
17-
onClose,
18-
title,
19-
className
14+
export function Sidebar({
15+
children,
16+
isOpen,
17+
onClose,
18+
title,
19+
className,
2020
}: SidebarProps) {
2121
return (
2222
<>
2323
{/* Overlay */}
2424
{isOpen && (
25-
<div
26-
className="fixed inset-0 bg-black/50 z-40"
27-
onClick={onClose}
28-
/>
25+
<div className="fixed inset-0 bg-black/50 z-40" onClick={onClose} />
2926
)}
30-
27+
3128
{/* Sidebar */}
3229
<div
3330
className={cn(
3431
'fixed right-0 top-0 h-full w-80 bg-background border-l shadow-lg transform transition-transform duration-200 ease-in-out z-50',
3532
isOpen ? 'translate-x-0' : 'translate-x-full',
36-
className
33+
className,
3734
)}
3835
>
3936
<div className="flex items-center justify-between p-4 border-b">
@@ -53,4 +50,4 @@ export function Sidebar({
5350
</div>
5451
</>
5552
)
56-
}
53+
}

src/hooks/useBackgroundJobStatus.test.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { renderHook, waitFor } from '@testing-library/react'
2-
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
2+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
33
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
44
import { useBackgroundJobStatus } from './useBackgroundJobStatus'
55
import { getTimestamp } from '@/lib/utils/date'
@@ -132,7 +132,11 @@ describe('useBackgroundJobStatus', () => {
132132

133133
mockFetch.mockResolvedValue({
134134
ok: true,
135-
json: async () => ({ status: 'failed', error: 'Job failed', completedAt: getTimestamp() }),
135+
json: async () => ({
136+
status: 'failed',
137+
error: 'Job failed',
138+
completedAt: getTimestamp(),
139+
}),
136140
})
137141

138142
const { result } = renderHook(() => useBackgroundJobStatus(job), {

src/hooks/useBackgroundJobStatus.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ export const useBackgroundJobStatus = (
4949
}
5050
return fetchJobStatus(job.id)
5151
},
52-
enabled: !!job?.id && (job.status === 'running' || (job.status === 'failed' && !job.completedAt)),
52+
enabled:
53+
!!job?.id &&
54+
(job.status === 'running' ||
55+
(job.status === 'failed' && !job.completedAt)),
5356
refetchInterval,
5457
refetchIntervalInBackground: true,
5558
retry: (failureCount, error) => {

src/hooks/useBackgroundJobs.test.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { renderHook, act } from '@testing-library/react'
2-
import { describe, it, expect, beforeEach } from 'vitest'
1+
import { act, renderHook } from '@testing-library/react'
2+
import { beforeEach, describe, expect, it } from 'vitest'
33
import { useBackgroundJobs } from './useBackgroundJobs'
44
import type { BackgroundJob } from '../lib/schemas'
55

@@ -302,7 +302,7 @@ describe('useBackgroundJobs', () => {
302302
title: 'Session 2 Job',
303303
})
304304

305-
let firstSessionResult = renderHook(() => useBackgroundJobs())
305+
const firstSessionResult = renderHook(() => useBackgroundJobs())
306306

307307
expect(firstSessionResult.result.current.jobs).toHaveLength(0)
308308
expect(localStorage.getItem(STORAGE_KEY)).toBeNull()
@@ -319,7 +319,7 @@ describe('useBackgroundJobs', () => {
319319
expect(firstSessionResult.result.current.jobs).toHaveLength(2)
320320
firstSessionResult.unmount()
321321

322-
let secondSessionResult = renderHook(() => useBackgroundJobs())
322+
const secondSessionResult = renderHook(() => useBackgroundJobs())
323323
expect(secondSessionResult.result.current.jobs).toHaveLength(2)
324324
expect(
325325
secondSessionResult.result.current.getJobById('browser-session-alpha'),
@@ -350,7 +350,7 @@ describe('useBackgroundJobs', () => {
350350

351351
secondSessionResult.unmount()
352352

353-
let thirdSessionResult = renderHook(() => useBackgroundJobs())
353+
const thirdSessionResult = renderHook(() => useBackgroundJobs())
354354
expect(thirdSessionResult.result.current.jobs).toHaveLength(1)
355355

356356
const persistedJob = thirdSessionResult.result.current.getJobById(

0 commit comments

Comments
 (0)