Skip to content
This repository was archived by the owner on Oct 19, 2026. It is now read-only.

Commit ae8f131

Browse files
committed
fix eslint
1 parent 0cd7182 commit ae8f131

8 files changed

Lines changed: 353 additions & 366 deletions

File tree

‎moon/apps/web/components/OrionClient/DeleteOrionImageDialog.tsx‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type { OrionVmImage } from '@/hooks/OrionClient/useGetOrionImages'
99
function shortDigest(digest?: string | null) {
1010
if (!digest) return '—'
1111
const hex = digest.replace(/^sha256:/, '').replace(/^sha512:/, '')
12+
1213
return hex.length > 12 ? `${hex.slice(0, 12)}…` : hex
1314
}
1415

@@ -55,13 +56,7 @@ export function DeleteOrionImageDialog({ image, open, onOpenChange }: DeleteOrio
5556
<Button variant='flat' disabled={isPending} onClick={() => onOpenChange(false)}>
5657
Cancel
5758
</Button>
58-
<Button
59-
autoFocus
60-
variant='destructive'
61-
disabled={!image}
62-
loading={isPending}
63-
onClick={onDelete}
64-
>
59+
<Button autoFocus variant='destructive' disabled={!image} loading={isPending} onClick={onDelete}>
6560
Delete
6661
</Button>
6762
</Dialog.TrailingActions>

‎moon/apps/web/components/OrionClient/OrionImagesTable.tsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@ import type { OrionVmImage } from '@/hooks/OrionClient/useGetOrionImages'
1010
function shortDigest(digest?: string | null) {
1111
if (!digest) return '—'
1212
const hex = digest.replace(/^sha256:/, '').replace(/^sha512:/, '')
13+
1314
return hex.length > 12 ? `${hex.slice(0, 12)}…` : hex
1415
}
1516

1617
function formatBytes(n?: number | null) {
1718
if (n == null || n <= 0) return '—'
1819
const gb = n / (1024 * 1024 * 1024)
20+
1921
if (gb >= 1) return `${gb.toFixed(1)} GiB`
2022
const mb = n / (1024 * 1024)
23+
2124
return `${mb.toFixed(0)} MiB`
2225
}
2326

@@ -58,7 +61,7 @@ export function OrionImagesTable({ images, isLoading, error }: Props) {
5861
<>
5962
<div className='overflow-x-auto rounded-md border border-gray-200 dark:border-gray-700'>
6063
<table className='min-w-full text-left text-sm'>
61-
<thead className='bg-gray-50 text-xs uppercase text-gray-500 dark:bg-gray-900 dark:text-gray-400'>
64+
<thead className='bg-gray-50 text-xs text-gray-500 uppercase dark:bg-gray-900 dark:text-gray-400'>
6265
<tr>
6366
<th className='px-3 py-2 font-medium'>Built</th>
6467
<th className='px-3 py-2 font-medium'>Rust</th>
@@ -73,7 +76,7 @@ export function OrionImagesTable({ images, isLoading, error }: Props) {
7376
<tbody>
7477
{images.map((img) => (
7578
<tr key={img.id} className='border-t border-gray-100 dark:border-gray-800'>
76-
<td className='whitespace-nowrap px-3 py-2'>{img.built_at || '—'}</td>
79+
<td className='px-3 py-2 whitespace-nowrap'>{img.built_at || '—'}</td>
7780
<td className='px-3 py-2'>{img.rust || '—'}</td>
7881
<td className='px-3 py-2'>{img.python || '—'}</td>
7982
<td className='px-3 py-2'>{img.buck2 || '—'}</td>

‎moon/apps/web/components/OrionClient/UploadOrionImageDialog.tsx‎

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,7 @@ type ImageInfoSidecar = {
2121
kernel?: string
2222
}
2323

24-
type UploadPhase =
25-
| 'idle'
26-
| 'hashing'
27-
| 'presigning'
28-
| 'uploading_image'
29-
| 'uploading_info'
30-
| 'registering'
24+
type UploadPhase = 'idle' | 'hashing' | 'presigning' | 'uploading_image' | 'uploading_info' | 'registering'
3125

3226
interface UploadOrionImageDialogProps {
3327
open: boolean
@@ -36,11 +30,13 @@ interface UploadOrionImageDialogProps {
3630

3731
function defaultImageName(fileName: string) {
3832
const base = fileName.replace(/\.qcow2$/i, '').trim()
33+
3934
return base || 'debian-13-buck2'
4035
}
4136

4237
function phaseLabel(phase: UploadPhase, progress: number): string {
4338
const pct = Math.round(progress * 100)
39+
4440
switch (phase) {
4541
case 'hashing':
4642
return `Hashing image… ${pct}%`
@@ -91,6 +87,7 @@ export function UploadOrionImageDialog({ open, onOpenChange }: UploadOrionImageD
9187
const resolvedName = imageName.trim() || defaultImageName(qcow2File.name)
9288

9389
let infoMeta: ImageInfoSidecar = {}
90+
9491
if (infoFile) {
9592
try {
9693
infoMeta = JSON.parse(await infoFile.text()) as ImageInfoSidecar
@@ -109,22 +106,16 @@ export function UploadOrionImageDialog({ open, onOpenChange }: UploadOrionImageD
109106

110107
setPhase('uploading_image')
111108
setProgress(0)
112-
await putWithProgress(
113-
resolveMonoUploadUrl(urls.qcow2_put_url, MONO_API_URL),
114-
qcow2File,
115-
setProgress,
116-
{ withCredentials: true }
117-
)
109+
await putWithProgress(resolveMonoUploadUrl(urls.qcow2_put_url, MONO_API_URL), qcow2File, setProgress, {
110+
withCredentials: true
111+
})
118112

119113
if (infoFile && urls.info_put_url) {
120114
setPhase('uploading_info')
121115
setProgress(0)
122-
await putWithProgress(
123-
resolveMonoUploadUrl(urls.info_put_url, MONO_API_URL),
124-
infoFile,
125-
setProgress,
126-
{ withCredentials: true }
127-
)
116+
await putWithProgress(resolveMonoUploadUrl(urls.info_put_url, MONO_API_URL), infoFile, setProgress, {
117+
withCredentials: true
118+
})
128119
}
129120

130121
setPhase('registering')
@@ -147,6 +138,7 @@ export function UploadOrionImageDialog({ open, onOpenChange }: UploadOrionImageD
147138
onOpenChange(false)
148139
} catch (error) {
149140
const message = error instanceof Error ? error.message : 'Upload failed'
141+
150142
toast.error(message)
151143
setPhase('idle')
152144
setProgress(0)
@@ -166,8 +158,8 @@ export function UploadOrionImageDialog({ open, onOpenChange }: UploadOrionImageD
166158
<Dialog.Header>
167159
<Dialog.Title>Upload image</Dialog.Title>
168160
<Dialog.Description>
169-
Upload a qcow2 to object storage and register it in the Orion catalog. Optionally include
170-
image-info.json for toolchain metadata.
161+
Upload a qcow2 to object storage and register it in the Orion catalog. Optionally include image-info.json for
162+
toolchain metadata.
171163
</Dialog.Description>
172164
</Dialog.Header>
173165

@@ -182,6 +174,7 @@ export function UploadOrionImageDialog({ open, onOpenChange }: UploadOrionImageD
182174
disabled={busy}
183175
onChange={(e) => {
184176
const file = e.target.files?.[0] ?? null
177+
185178
setQcow2File(file)
186179
if (file && !imageName.trim()) {
187180
setImageName(defaultImageName(file.name))

‎moon/apps/web/hooks/OrionClient/orionImageUpload.ts‎

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import { createSHA256 } from 'hash-wasm'
22

33
/** Stream SHA-256 of a File/Blob without loading it entirely into memory. */
4-
export async function sha256HexOfFile(
5-
file: Blob,
6-
onProgress?: (ratio: number) => void
7-
): Promise<string> {
4+
export async function sha256HexOfFile(file: Blob, onProgress?: (ratio: number) => void): Promise<string> {
85
const hasher = await createSHA256()
6+
97
hasher.init()
108
const total = file.size || 1
119
let done = 0
@@ -15,6 +13,7 @@ export async function sha256HexOfFile(
1513

1614
for (;;) {
1715
const { done: eof, value } = await reader.read()
16+
1817
if (eof) break
1918
if (value) {
2019
hasher.update(value)
@@ -41,6 +40,7 @@ export function putWithProgress(
4140

4241
return new Promise((resolve, reject) => {
4342
const xhr = new XMLHttpRequest()
43+
4444
xhr.open('PUT', url)
4545
xhr.withCredentials = withCredentials
4646
if (contentType) {
@@ -59,22 +59,16 @@ export function putWithProgress(
5959
return
6060
}
6161
const detail = (xhr.responseText || '').trim().slice(0, 240)
62-
reject(
63-
new Error(
64-
`Upload failed (HTTP ${xhr.status})${detail ? `: ${detail}` : ''}`
65-
)
66-
)
62+
63+
reject(new Error(`Upload failed (HTTP ${xhr.status})${detail ? `: ${detail}` : ''}`))
6764
}
6865

6966
xhr.onerror = () => {
7067
reject(new Error('Upload network error'))
7168
}
7269

7370
// Avoid browser auto Content-Type from Blob.type when none was requested.
74-
const body =
75-
contentType || !blob.type
76-
? blob
77-
: blob.slice(0, blob.size, '')
71+
const body = contentType || !blob.type ? blob : blob.slice(0, blob.size, '')
7872

7973
xhr.send(body)
8074
})
@@ -87,5 +81,6 @@ export function resolveMonoUploadUrl(putUrlOrPath: string, monoApiBase: string):
8781
}
8882
const base = monoApiBase.replace(/\/$/, '')
8983
const path = putUrlOrPath.startsWith('/') ? putUrlOrPath : `/${putUrlOrPath}`
84+
9085
return `${base}${path}`
9186
}

‎moon/apps/web/hooks/OrionClient/usePresignOrionImage.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export function usePresignOrionImage() {
3434
})
3535
const text = await res.text()
3636
let json: Envelope | null = null
37+
3738
try {
3839
json = text ? (JSON.parse(text) as Envelope) : null
3940
} catch {

‎moon/apps/web/hooks/OrionClient/useRunnerLogsSSE.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,13 @@ function mergeLogChunk(prev: string, chunk: string): string {
6666

6767
for (const raw of incoming) {
6868
const line = raw
69+
6970
if (line === '' && incoming.length === 1) {
7071
continue
7172
}
7273
if (isProvisionProgressLine(line)) {
7374
const lastIdx = lines.length - 1
75+
7476
if (lastIdx >= 0 && isProvisionProgressLine(lines[lastIdx])) {
7577
lines[lastIdx] = line
7678
} else {
@@ -82,6 +84,7 @@ function mergeLogChunk(prev: string, chunk: string): string {
8284
}
8385

8486
let next = lines.join('\n')
87+
8588
if (chunk.endsWith('\n') && !next.endsWith('\n')) {
8689
next += '\n'
8790
}
@@ -139,6 +142,7 @@ export function useRunnerLogsSSE(streamKey: string | null) {
139142
// Real guest/system logs arrived — clear the transient-wait gate so a later
140143
// reprovision can announce waiting again if needed. Progress lines keep the gate.
141144
const trimmed = chunk.trim()
145+
142146
if (
143147
!TRANSIENT_NO_VM_RE.test(trimmed) &&
144148
!isProvisionProgressLine(trimmed) &&

‎moon/apps/web/pages/[org]/oc/images.tsx‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import Head from 'next/head'
66
import { Button, UIText } from '@gitmono/ui'
77

88
import { AppLayout } from '@/components/Layout/AppLayout'
9-
import { OrionClientPageWrapper } from '@/components/OrionClient/PageWrapper'
109
import { OrionImagesTable } from '@/components/OrionClient/OrionImagesTable'
10+
import { OrionClientPageWrapper } from '@/components/OrionClient/PageWrapper'
1111
import { UploadOrionImageDialog } from '@/components/OrionClient/UploadOrionImageDialog'
1212
import AuthAppProviders from '@/components/Providers/AuthAppProviders'
1313
import { useAdminCheck } from '@/hooks/admin/useAdminCheck'
@@ -17,11 +17,7 @@ import { PageWithLayout } from '@/utils/types'
1717
const OrionImagesPage: PageWithLayout<any> = () => {
1818
const { data: adminCheck } = useAdminCheck()
1919
const isAdmin = adminCheck?.data?.is_admin || false
20-
const {
21-
data: orionImages = [],
22-
isLoading: isLoadingImages,
23-
error: orionImagesError
24-
} = useGetOrionImages(isAdmin)
20+
const { data: orionImages = [], isLoading: isLoadingImages, error: orionImagesError } = useGetOrionImages(isAdmin)
2521
const [uploadOpen, setUploadOpen] = useState(false)
2622

2723
return (

0 commit comments

Comments
 (0)