Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: use try/finally so a synchronous throw also clears schedulingBusy (#3517)
[._.]/ Adam Eivya95d3e3d5f27
diff --git a/client/src/hooks/useGoalDetail.js b/client/src/hooks/useGoalDetail.jsindex b3f4c30c14..50fd0078de 100644--- a/client/src/hooks/useGoalDetail.js+++ b/client/src/hooks/useGoalDetail.js@@ -146,17 +146,25 @@ export function useGoalDetail({ goal, allGoals, onClose, onRefresh }) {};// The three time-block actions share one busy flag, so they share one runner- // (issue #3517). Swallowing the rejection is what clears `schedulingBusy` on a- // failed request — without it the buttons latch on "Scheduling..." forever and- // the only recovery is a full page reload. No custom toast here on purpose:- // `request()` already toasts the failure, so this stays a single-layer error UI.- // The refresh runs either way, because a failed schedule/reschedule can still- // have written some blocks before erroring and the panel should show reality.+ // (issue #3517). Swallowing the failure is what clears `schedulingBusy` — without+ // it the buttons latch on "Scheduling..." forever and the only recovery is a full+ // page reload. No custom toast here on purpose: `request()` already toasts the+ // failure, so this stays a single-layer error UI. The refresh runs either way,+ // because a failed schedule/reschedule can still have written some blocks before+ // erroring and the panel should show reality.+ // `finally` rather than the `.catch(() => null)` used elsewhere in this hook:+ // a bare `.catch` only covers a rejected promise, so an action that threw+ // before returning one would skip the reset and re-open this very bug.const runSchedulingAction = async (action) => {setSchedulingBusy(true);- await action(goal.id).catch(() => null);- setSchedulingBusy(false);- onRefresh();+ try {+ await action(goal.id);+ } catch {+ // Deliberately swallowed — see the single-layer note above.+ } finally {+ setSchedulingBusy(false);+ onRefresh();+ }};const handleSchedule = () => runSchedulingAction(api.scheduleGoalTimeBlocks);diff --git a/client/src/hooks/useGoalDetail.test.jsx b/client/src/hooks/useGoalDetail.test.jsxindex 6d66ff774e..74230cf8c6 100644--- a/client/src/hooks/useGoalDetail.test.jsx+++ b/client/src/hooks/useGoalDetail.test.jsx@@ -90,6 +90,19 @@ describe('useGoalDetail scheduling actions', () => {expect(result.current.schedulingBusy).toBe(false);});+ // A bare `.catch()` on the call would miss this: it never gets attached when the+ // action throws before handing back a promise, so the reset would be skipped and+ // the buttons would latch exactly as they did before the fix.+ it.each(SCHEDULING_ACTIONS)('%s clears schedulingBusy when the action throws synchronously', async (handler, apiFn) => {+ apiFn().mockImplementation(() => { throw new Error('threw before returning a promise'); });+ const { result, onRefresh } = renderGoalDetail();++ await act(async () => { await result.current[handler](); });++ expect(result.current.schedulingBusy).toBe(false);+ expect(onRefresh).toHaveBeenCalledTimes(1);+ });+it('does not surface a rejection to the caller as an unhandled promise', async () => {scheduleGoalTimeBlocks.mockRejectedValue(new Error('server exploded'));const { result } = renderGoalDetail();