Skip to content

Commit 4054a9d

Browse files
Format Stockfish loading branch changes for CI
1 parent d8040d9 commit 4054a9d

4 files changed

Lines changed: 28 additions & 9 deletions

File tree

src/contexts/StockfishEngineContext.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ const isTruthy = (value: string | null | undefined): boolean => {
2121
const isStockfishDebugLoadingEnabled = (): boolean => {
2222
if (typeof window !== 'undefined') {
2323
try {
24-
const localValue = window.localStorage.getItem(STOCKFISH_DEBUG_LOADING_KEY)
24+
const localValue = window.localStorage.getItem(
25+
STOCKFISH_DEBUG_LOADING_KEY,
26+
)
2527
if (localValue !== null) return isTruthy(localValue)
2628
} catch {
2729
// ignore localStorage access failures
@@ -164,7 +166,10 @@ export const StockfishEngineContextProvider: React.FC<{
164166
// Toast notifications for Stockfish engine status
165167
useEffect(() => {
166168
return () => {
167-
if (loadingToastTimerRef.current !== null && typeof window !== 'undefined') {
169+
if (
170+
loadingToastTimerRef.current !== null &&
171+
typeof window !== 'undefined'
172+
) {
168173
window.clearTimeout(loadingToastTimerRef.current)
169174
loadingToastTimerRef.current = null
170175
}
@@ -201,7 +206,10 @@ export const StockfishEngineContextProvider: React.FC<{
201206
return
202207
}
203208

204-
if (loadingToastTimerRef.current !== null && typeof window !== 'undefined') {
209+
if (
210+
loadingToastTimerRef.current !== null &&
211+
typeof window !== 'undefined'
212+
) {
205213
window.clearTimeout(loadingToastTimerRef.current)
206214
loadingToastTimerRef.current = null
207215
}

src/lib/engine/maia.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ class Maia {
9797
position += chunk.length
9898
}
9999

100-
await this.storage.storeModel(this.modelUrl, this.modelVersion, buffer.buffer)
100+
await this.storage.storeModel(
101+
this.modelUrl,
102+
this.modelVersion,
103+
buffer.buffer,
104+
)
101105

102106
await this.initializeModel(buffer.buffer)
103107
this.options.setStatus('ready')

src/lib/engine/stockfish.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ class Engine {
7777
.catch((error) => {
7878
console.error('Failed to initialize Stockfish:', error)
7979
this.initError =
80-
error instanceof Error ? error.message : 'Unknown initialization error'
80+
error instanceof Error
81+
? error.message
82+
: 'Unknown initialization error'
8183
this.isReady = false
8284
this.nnueLoaded = false
8385
this.initPhase = 'error'
@@ -408,7 +410,9 @@ const fetchWithTimeout = async (
408410
return await fetch(url, { signal: controller.signal })
409411
} catch (error) {
410412
if (error instanceof DOMException && error.name === 'AbortError') {
411-
throw new Error(`Stockfish NNUE fetch timed out after ${timeoutMs}ms: ${url}`)
413+
throw new Error(
414+
`Stockfish NNUE fetch timed out after ${timeoutMs}ms: ${url}`,
415+
)
412416
}
413417
throw error
414418
} finally {

src/pages/_app.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,12 @@ function MaiaPlatform({ Component, pageProps }: AppProps) {
4545
'/settings',
4646
'/broadcast',
4747
].some((path) => router.pathname.includes(path))
48-
const isPageWithStockfish = ['/analysis', '/openings', '/puzzles', '/broadcast'].some(
49-
(path) => router.pathname.includes(path),
50-
)
48+
const isPageWithStockfish = [
49+
'/analysis',
50+
'/openings',
51+
'/puzzles',
52+
'/broadcast',
53+
].some((path) => router.pathname.includes(path))
5154

5255
useEffect(() => {
5356
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY as string, {

0 commit comments

Comments
 (0)