-
Notifications
You must be signed in to change notification settings - Fork 0
fix(ui): record history entry after driver scan so dashboard highlights completion #116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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) | ||
|
|
@@ -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 { | ||
|
|
@@ -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') }) | ||
|
|
@@ -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') { | ||
| 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 }] : []), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Using Useful? React with 👍 / 👎. |
||
| ...(updateCount > 0 ? [{ name: 'Driver Updates', itemsFound: updateCount, itemsCleaned: 0, spaceSaved: 0 }] : []) | ||
| ], | ||
| errorCount: 0 | ||
| }) | ||
| recomputeStats() | ||
| } | ||
| }, []) | ||
|
|
||
| // ─── Combined Update & Clean ────────────────────────────── | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition records a
drivershistory 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 👍 / 👎.