Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/renderer/src/pages/DriverManagerPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export function DriverManagerPage({ embedded }: { embedded?: boolean }) {

// ─── Scan for both stale packages and updates ─────────────
const handleScan = useCallback(async () => {
const scanStart = Date.now()
const store = useDriverStore.getState()
store.setScanning(true)
store.setUpdateScanning(true)
Expand All @@ -90,9 +91,13 @@ export function DriverManagerPage({ embedded }: { embedded?: boolean }) {

const s = useDriverStore.getState()

let staleCount = 0
let staleSize = 0
if (staleResult.status === 'fulfilled') {
s.setPackages(staleResult.value.packages)
s.setTotalStaleSize(staleResult.value.totalStaleSize)
staleCount = staleResult.value.packages.length
staleSize = staleResult.value.totalStaleSize
// Auto-select all stale packages
useDriverStore.getState().selectAllStale()
} else {
Expand All @@ -101,8 +106,10 @@ export function DriverManagerPage({ embedded }: { embedded?: boolean }) {
s.setError(t('driverManager.scanFailedError'))
}

let updateCount = 0
if (updateResult.status === 'fulfilled') {
s.setUpdates(updateResult.value.updates)
updateCount = updateResult.value.updates.length
} else {
console.error('Driver update scan failed:', updateResult.reason)
toast.error(t('driverManager.updateScanFailedToast'), { description: t('driverManager.updateScanFailedDescription') })
Expand All @@ -115,6 +122,27 @@ export function DriverManagerPage({ embedded }: { embedded?: boolean }) {
final.setScanProgress(null)
final.setUpdateProgress(null)
final.setHasScanned(true)

// Record scan in history so dashboard reflects completion
if (staleResult.status === 'fulfilled' || updateResult.status === 'fulfilled') {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid logging a successful scan when one scan branch failed

This condition records a drivers history entry even when only one of the two scans succeeds, but the entry is written as a clean success (errorCount: 0), so the dashboard/history can report the driver tool as completed despite a visible scan failure toast. In a partial-failure run (e.g., stale scan fails, update scan succeeds), this produces inaccurate completion and reliability signals; the history write should require full success or include the failure in the recorded result.

Useful? React with 👍 / 👎.

const totalFound = staleCount + updateCount
await historyStore.addEntry({
id: Date.now().toString(),
type: 'drivers',
timestamp: new Date().toISOString(),
duration: Date.now() - scanStart,
totalItemsFound: totalFound,
totalItemsCleaned: 0,
totalItemsSkipped: 0,
totalSpaceSaved: 0,
categories: [
...(staleCount > 0 ? [{ name: 'Stale Drivers', itemsFound: staleCount, itemsCleaned: 0, spaceSaved: staleSize }] : []),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep scan-only history from inflating recovered-space analytics

Using staleSize as spaceSaved for a scan-only entry reports unrecovered bytes as recovered bytes. HistoryPage aggregates category.spaceSaved into category charts, so these entries can incorrectly rank “Stale Drivers” as recovered space even when no cleanup happened (totalSpaceSaved is 0). For scan entries, category spaceSaved should remain 0 to keep history metrics consistent.

Useful? React with 👍 / 👎.

...(updateCount > 0 ? [{ name: 'Driver Updates', itemsFound: updateCount, itemsCleaned: 0, spaceSaved: 0 }] : [])
],
errorCount: 0
})
recomputeStats()
}
}, [])

// ─── Combined Update & Clean ──────────────────────────────
Expand Down
Loading