fix(hal): return DispenseResult from IPC dispense handler

The hal:dispense IPC handler in main.ts did not return the result of
dispenseCash(), causing the state machine guard to crash on undefined
output. This left the UI stuck on "Dispensing cash..." after successful
dispense.

- hal-service.ts: return DispenseResult instead of void/throwing
- main.ts: add missing return in IPC handler
- machine.ts: defensive guard (?. instead of .) as safety net

Bug found with the aid of Seoyoung at Trece Cielos.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Patrick Mulligan 2026-03-06 15:46:52 -05:00
commit d8841f7fe9
3 changed files with 39 additions and 8 deletions

View file

@ -175,11 +175,12 @@ ipcMain.handle('hal:init', async (_event, config) => {
}
})
// Bug found with the aid of Seoyoung at Trece Cielos
ipcMain.handle(
'hal:dispense',
async (_event, amounts: { denomination: number; count: number }[]) => {
if (!halInstance) throw new Error('HAL not initialized')
await halInstance.dispenseCash(amounts)
return await halInstance.dispenseCash(amounts)
}
)