Skip to content

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

fix: gate goal check-in drawer open + refresh on the server actually returning a check-in (#3518)

[._.]/ Adam Eivy5c3412ffed1c
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 074595e8ac..e9e85ae6b6 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -106,6 +106,7 @@
- **[issue-3517] A failed "Schedule Time Blocks" left the goal's scheduling buttons stuck on "Scheduling..." until you reloaded the page.** Scheduling, rescheduling, and removing a goal's time blocks each raised a shared busy flag before their request and lowered it afterwards, but nothing caught a rejection — so a server error or a dropped connection aborted the handler before the flag came back down, and all three buttons stayed disabled with no way to retry short of reloading. The three now share one runner that always clears the flag, and the panel refreshes afterwards whether or not the request succeeded, because a scheduling run can write some blocks before it fails and leaving that half-written state off screen is the more confusing outcome. The failure itself still surfaces exactly once, from the shared request helper, rather than picking up a second toast of its own.
- **[issue-3525] Tapping "edit bucket" on a phone in Bookmarks often deleted the bucket instead.** The edit and delete icons in a bucket's header were 13px glyphs with 4px of padding — roughly 17px of tappable area each, sitting right next to each other — so on a narrow screen a thumb aimed at edit landed on delete and opened its confirmation instead. Both now use the standard 44px minimum tap target with the icon centered inside it, which is what the rest of PortOS uses for icon-only buttons, and the header's own vertical padding drops to compensate so the taller buttons don't inflate the card. The bucket's "add a URL" submit button had the same problem and gets the same treatment.
- **[issue-3529] Syncing two machines wiped your Digital Twin's evaluation history down to a single run.** Every persona test, values-alignment run, adversarial-boundary run and multi-turn run is recorded with a `runId`, but the peer merge was unioning those four histories on an `id` field none of them has. Every entry therefore resolved to the same empty key: the local runs overwrote each other until one was left, and every run arriving from the other machine was then discarded as a duplicate of it. Both machines lost their history on the first sync, permanently. The merge now keys on `runId`, so runs recorded on either machine survive and a run both machines already have is not duplicated. The union helper underneath no longer collapses records at all when the field it was pointed at is missing — records with no usable key are matched on their content instead, so the next time a key field is named wrong the result is a harmless duplicate rather than silent destruction, and re-syncing the same records adds nothing. Merged histories are also re-sorted newest-first, because the recorders keep only the fifty most recent runs and take them off the front: a peer's runs appended to the end would have read as the oldest, and the next local run would have trimmed away the newest entries instead of the oldest.
+- **[issue-3518] A failed goal check-in silently expanded the check-ins list onto nothing.** "Run Check-In" raised its busy flag, fired the request, and then unconditionally opened the check-ins accordion and refreshed the panel — whether or not the server had actually produced a check-in. So a failed run ended with the list flipping open on the same entries it already had, which reads as "the check-in ran and produced nothing" rather than "the request failed." The panel now only opens when the server returns the new check-in, and the pointless refresh is gone with it; the failure surfaces exactly once, from the shared request helper, rather than picking up a second toast of its own. Clearing the busy flag also moved into a `finally`, so a call that throws before returning a promise can no longer latch the button on "Checking in..." until a page reload.
## Three.js Models
diff --git a/client/src/hooks/useGoalDetail.js b/client/src/hooks/useGoalDetail.js
index 50fd0078de..7f6fc5beb1 100644
--- a/client/src/hooks/useGoalDetail.js
+++ b/client/src/hooks/useGoalDetail.js
@@ -137,10 +137,26 @@ export function useGoalDetail({ goal, allGoals, onClose, onRefresh }) {
onRefresh();
};
+ // The response is the signal (issue #3518): a failed check-in used to expand the
+ // accordion onto an unchanged list and fire a pointless refresh, so the only
+ // feedback the user got was an empty panel. Now the panel opens only when the
+ // server actually returned the new check-in. No custom toast on purpose —
+ // `request()` already toasts the failure, so this stays a single-layer error UI.
+ // `try/finally` rather than the `.catch(() => null)` used elsewhere in this hook
+ // for the same reason as runSchedulingAction below: a bare `.catch` only covers a
+ // rejected promise, so a call that threw before returning one would skip the reset
+ // and latch the button on "Checking in..." until a full page reload.
const handleCheckIn = async () => {
setCheckingIn(true);
- await api.checkInGoal(goal.id).catch(() => null);
- setCheckingIn(false);
+ let checkIn = null;
+ try {
+ checkIn = await api.checkInGoal(goal.id);
+ } catch {
+ // Deliberately swallowed — see the single-layer note above.
+ } finally {
+ setCheckingIn(false);
+ }
+ if (checkIn == null) return;
setCheckInsOpen(true);
onRefresh();
};
diff --git a/client/src/hooks/useGoalDetail.test.jsx b/client/src/hooks/useGoalDetail.test.jsx
index 74230cf8c6..3b38b19409 100644
--- a/client/src/hooks/useGoalDetail.test.jsx
+++ b/client/src/hooks/useGoalDetail.test.jsx
@@ -6,13 +6,15 @@ const getCalendarAccounts = vi.fn(() => Promise.resolve([]));
const scheduleGoalTimeBlocks = vi.fn(() => Promise.resolve({}));
const removeGoalSchedule = vi.fn(() => Promise.resolve({}));
const rescheduleGoalTimeBlocks = vi.fn(() => Promise.resolve({}));
+const checkInGoal = vi.fn(() => Promise.resolve({ id: 'check-in-1' }));
vi.mock('../services/api', () => ({
getActivities: (...args) => getActivities(...args),
getCalendarAccounts: (...args) => getCalendarAccounts(...args),
scheduleGoalTimeBlocks: (...args) => scheduleGoalTimeBlocks(...args),
removeGoalSchedule: (...args) => removeGoalSchedule(...args),
- rescheduleGoalTimeBlocks: (...args) => rescheduleGoalTimeBlocks(...args)
+ rescheduleGoalTimeBlocks: (...args) => rescheduleGoalTimeBlocks(...args),
+ checkInGoal: (...args) => checkInGoal(...args)
}));
const { useGoalDetail } = await import('./useGoalDetail');
@@ -112,3 +114,97 @@ describe('useGoalDetail scheduling actions', () => {
});
});
});
+
+// Issue #3518: handleCheckIn opened the accordion and refreshed unconditionally, so
+// a failed check-in expanded an unchanged list with no sign anything went wrong.
+describe('useGoalDetail handleCheckIn', () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ getActivities.mockResolvedValue([]);
+ getCalendarAccounts.mockResolvedValue([]);
+ checkInGoal.mockResolvedValue({ id: 'check-in-1' });
+ });
+
+ it('opens the check-ins list and refreshes when the server returns a check-in', async () => {
+ const { result, onRefresh } = renderGoalDetail();
+
+ await act(async () => { await result.current.handleCheckIn(); });
+
+ expect(checkInGoal).toHaveBeenCalledWith(GOAL.id);
+ expect(result.current.checkInsOpen).toBe(true);
+ expect(result.current.checkingIn).toBe(false);
+ expect(onRefresh).toHaveBeenCalledTimes(1);
+ });
+
+ it('flips checkingIn true while the request is in flight', async () => {
+ let release;
+ checkInGoal.mockReturnValue(new Promise((resolve) => { release = resolve; }));
+ const { result } = renderGoalDetail();
+
+ let pending;
+ act(() => { pending = result.current.handleCheckIn(); });
+ expect(result.current.checkingIn).toBe(true);
+
+ await act(async () => { release({ id: 'check-in-1' }); await pending; });
+ expect(result.current.checkingIn).toBe(false);
+ });
+
+ it('leaves the check-ins list closed and skips the refresh when the request rejects', async () => {
+ checkInGoal.mockRejectedValue(new Error('server exploded'));
+ const { result, onRefresh } = renderGoalDetail();
+
+ await act(async () => { await result.current.handleCheckIn(); });
+
+ expect(result.current.checkInsOpen).toBe(false);
+ expect(onRefresh).not.toHaveBeenCalled();
+ // The button must re-arm — the failure is recoverable by clicking again.
+ expect(result.current.checkingIn).toBe(false);
+ });
+
+ // A 204/empty body is "nothing was created", not a check-in worth revealing.
+ it('leaves the check-ins list closed when the server returns no check-in', async () => {
+ checkInGoal.mockResolvedValue(null);
+ const { result, onRefresh } = renderGoalDetail();
+
+ await act(async () => { await result.current.handleCheckIn(); });
+
+ expect(result.current.checkInsOpen).toBe(false);
+ expect(onRefresh).not.toHaveBeenCalled();
+ expect(result.current.checkingIn).toBe(false);
+ });
+
+ // A bare `.catch()` never gets attached when the call throws before handing back
+ // a promise, so the reset would be skipped and the button would latch forever.
+ it('clears checkingIn when the api call throws synchronously', async () => {
+ checkInGoal.mockImplementation(() => { throw new Error('threw before returning a promise'); });
+ const { result, onRefresh } = renderGoalDetail();
+
+ await act(async () => { await result.current.handleCheckIn(); });
+
+ expect(result.current.checkingIn).toBe(false);
+ expect(result.current.checkInsOpen).toBe(false);
+ expect(onRefresh).not.toHaveBeenCalled();
+ });
+
+ it('does not surface a rejection to the caller as an unhandled promise', async () => {
+ checkInGoal.mockRejectedValue(new Error('server exploded'));
+ const { result } = renderGoalDetail();
+
+ await act(async () => {
+ await expect(result.current.handleCheckIn()).resolves.toBeUndefined();
+ });
+ });
+
+ it('can be retried after a failure', async () => {
+ checkInGoal.mockRejectedValueOnce(new Error('server exploded'));
+ const { result, onRefresh } = renderGoalDetail();
+
+ await act(async () => { await result.current.handleCheckIn(); });
+ expect(result.current.checkInsOpen).toBe(false);
+
+ await act(async () => { await result.current.handleCheckIn(); });
+ expect(checkInGoal).toHaveBeenCalledTimes(2);
+ expect(result.current.checkInsOpen).toBe(true);
+ expect(onRefresh).toHaveBeenCalledTimes(1);
+ });
+});