Minor Spoolbuddy frontend improvements

This commit is contained in:
maziggy
2026-02-27 13:33:47 +01:00
parent 15437534ed
commit 8c9c0a7994
8 changed files with 8704 additions and 8995 deletions
+6 -2
View File
@@ -50,8 +50,12 @@ def event_loop():
"""Create an instance of the default event loop for each test session."""
loop = asyncio.get_event_loop_policy().new_event_loop()
yield loop
# Drain pending callbacks so aiosqlite threads can finish before loop closes
loop.run_until_complete(asyncio.sleep(0.1))
# Dispose the module-level engine so aiosqlite worker threads finish
# before the event loop closes, preventing "Event loop is closed" errors.
from backend.app.core.database import engine
loop.run_until_complete(engine.dispose())
loop.run_until_complete(asyncio.sleep(0.05))
loop.close()
Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

@@ -53,7 +53,7 @@ export function SpoolBuddyTopBar({ selectedPrinterId, onPrinterChange, deviceOnl
<div className="h-11 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary flex items-center px-3 gap-4 shrink-0">
{/* Logo */}
<div className="flex items-center shrink-0">
<img src="/img/spoolbuddy_logo_dark.png" alt="SpoolBuddy" className="h-7" />
<img src="/img/spoolbuddy_logo_dark_small.png" alt="SpoolBuddy" width={113} height={28} className="h-7 w-auto" />
</div>
{/* Printer selector - centered */}
@@ -1,4 +1,4 @@
import { useState, useEffect, useMemo, useRef } from 'react';
import { useState, useEffect, useMemo, useCallback, useRef } from 'react';
import { useOutletContext } from 'react-router-dom';
import { useQuery, useQueryClient } from '@tanstack/react-query';
import { useTranslation } from 'react-i18next';
@@ -96,14 +96,14 @@ export function SpoolBuddyAmsPage() {
? status.ams_extruder_map
: cachedAmsExtruderMap.current;
const getNozzleSide = (amsId: number): 'L' | 'R' | null => {
const getNozzleSide = useCallback((amsId: number): 'L' | 'R' | null => {
if (!isDualNozzle) return null;
const mappedExtruderId = amsExtruderMap[String(amsId)];
const normalizedId = amsId >= 128 ? amsId - 128 : amsId;
const extruderId = mappedExtruderId !== undefined ? mappedExtruderId : normalizedId;
// extruder 0 = right, 1 = left
return extruderId === 1 ? 'L' : 'R';
};
}, [isDualNozzle, amsExtruderMap]);
const [configureSlotModal, setConfigureSlotModal] = useState<{
amsId: number;
@@ -118,7 +118,7 @@ export function SpoolBuddyAmsPage() {
savedPresetId?: string;
} | null>(null);
const getActiveSlotForAms = (amsId: number): number | null => {
const getActiveSlotForAms = useCallback((amsId: number): number | null => {
if (trayNow === 255 || trayNow === 254) return null;
if (amsId <= 3) {
const activeAmsId = Math.floor(trayNow / 4);
@@ -129,9 +129,9 @@ export function SpoolBuddyAmsPage() {
if (trayNow === 16 + htIndex) return 0;
}
return null;
};
}, [trayNow]);
const handleAmsSlotClick = (amsId: number, trayId: number, tray: AMSTray | null) => {
const handleAmsSlotClick = useCallback((amsId: number, trayId: number, tray: AMSTray | null) => {
const globalTrayId = amsId >= 128 ? (amsId - 128) * 4 + trayId + 64 : amsId * 4 + trayId;
const slotPreset = slotPresets?.[globalTrayId];
const mappedExtruderId = amsExtruderMap[String(amsId)];
@@ -149,9 +149,9 @@ export function SpoolBuddyAmsPage() {
caliIdx: tray?.cali_idx,
savedPresetId: slotPreset?.preset_id,
});
};
}, [slotPresets, amsExtruderMap, isDualNozzle]);
const handleExtSlotClick = (extTray: AMSTray) => {
const handleExtSlotClick = useCallback((extTray: AMSTray) => {
const extTrayId = extTray.id ?? 254;
const slotTrayId = extTrayId - 254;
const extSlotPreset = slotPresets?.[255 * 4 + slotTrayId];
@@ -167,7 +167,7 @@ export function SpoolBuddyAmsPage() {
caliIdx: extTray.cali_idx,
savedPresetId: extSlotPreset?.preset_id,
});
};
}, [slotPresets, isDualNozzle]);
// Set alert for low filament in status bar
useEffect(() => {
@@ -236,7 +236,7 @@ export function SpoolBuddyAmsPage() {
}
return items;
}, [htAms, vtTrays, isDualNozzle, trayNow, status?.active_extruder, slotPresets, amsExtruderMap, t]);
}, [htAms, vtTrays, isDualNozzle, trayNow, status?.active_extruder, t, getActiveSlotForAms, getNozzleSide, handleAmsSlotClick, handleExtSlotClick]);
return (
<div className="h-full flex flex-col p-3">
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

+1 -1
View File
@@ -23,7 +23,7 @@
<!-- Splash screens for iOS -->
<link rel="apple-touch-startup-image" href="/img/android-chrome-512x512.png" />
<script type="module" crossorigin src="/assets/index-C7NPsWbv.js"></script>
<script type="module" crossorigin src="/assets/index-C6P1sMLA.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-DAOWLKX-.css">
</head>
<body>