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: exempt manual "check now" from the update-check gh backoff

[._.]/ Adam Eivy15fe438d18ec
diff --git a/server/routes/update.js b/server/routes/update.js
index d5a9d94ad2..5398ffd34d 100644
--- a/server/routes/update.js
+++ b/server/routes/update.js
@@ -44,9 +44,12 @@ router.get('/status', asyncHandler(async (req, res) => {
res.json({ ...status, activeCosAgents, persistentMindImages });
}));
-// POST /api/update/check — triggers manual check
+// POST /api/update/check — triggers manual check. `manual: true` bypasses the
+// unattended scheduler's gh backoff — a user who explicitly asked for a check
+// must get a real attempt, not a silent rejection from a cooldown the
+// background poller armed on its own.
router.post('/check', asyncHandler(async (req, res) => {
- const result = await updateChecker.checkForUpdate();
+ const result = await updateChecker.checkForUpdate({ manual: true });
res.json(result);
}));
diff --git a/server/routes/update.test.js b/server/routes/update.test.js
index 38eed0cea4..5cf3ffe5e5 100644
--- a/server/routes/update.test.js
+++ b/server/routes/update.test.js
@@ -626,3 +626,19 @@ describe('POST /api/update/sync-fork', () => {
expect(updateChecker.getRemoteInfo).not.toHaveBeenCalled();
});
});
+
+describe('POST /api/update/check', () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ });
+
+ it('marks the check manual so it bypasses the unattended scheduler\'s gh backoff', async () => {
+ // A user who explicitly clicks "check now" must get a real attempt, not a
+ // silent rejection from a cooldown the background 30-min poller armed on
+ // its own after an earlier unattended failure.
+ updateChecker.checkForUpdate.mockResolvedValue(baseStatus());
+ const res = await request(makeApp()).post('/api/update/check').send({});
+ expect(res.status).toBe(200);
+ expect(updateChecker.checkForUpdate).toHaveBeenCalledWith({ manual: true });
+ });
+});
diff --git a/server/services/updateChecker.js b/server/services/updateChecker.js
index 9068724d03..c4732e19df 100644
--- a/server/services/updateChecker.js
+++ b/server/services/updateChecker.js
@@ -196,20 +196,28 @@ export async function syncFork({ branch, remoteInfo } = {}) {
* Always polls the upstream atomantic/PortOS releases so users running
* from a fork still see upstream version availability. Pull/checkout
* behavior is unchanged — update.sh still pulls from origin.
+ *
+ * @param {{ manual?: boolean }} [options] - `manual: true` (the `POST
+ * /api/update/check` "check now" route) always makes a real attempt: a
+ * user who explicitly asked for a check must never be silently swallowed
+ * by the background scheduler's backoff cooldown from an earlier failure
+ * it hit on its own. Only the unattended 30-min scheduler tick opts into
+ * that backoff.
*/
-export async function checkForUpdate() {
+export async function checkForUpdate({ manual = false } = {}) {
return withLock(async () => {
const state = await loadState();
const currentVersion = await getCurrentVersion();
- // `backoffKey` opts this periodic read into execGh's consecutive-failure
- // backoff — the 30-min scheduler retries a failure on its very next tick
- // with no cooldown of its own, which piled up alongside branch-reconcile's
- // identical gap during a real `gh` blip (both logged the same incident).
+ // `backoffKey` opts the unattended periodic read into execGh's
+ // consecutive-failure backoff — the 30-min scheduler retries a failure
+ // on its very next tick with no cooldown of its own, which piled up
+ // alongside branch-reconcile's identical gap during a real `gh` blip
+ // (both logged the same incident).
const raw = await execGh(
['api', `repos/${UPSTREAM_OWNER}/${UPSTREAM_REPO}/releases/latest`],
undefined,
- { backoffKey: 'update-check' }
+ manual ? {} : { backoffKey: 'update-check' }
);
let data;
try { data = JSON.parse(raw); } catch { throw new Error(`Failed to parse GitHub release response: ${raw.slice(0, 200)}`); }
diff --git a/server/services/updateChecker.test.js b/server/services/updateChecker.test.js
index f799858de1..19284ead1d 100644
--- a/server/services/updateChecker.test.js
+++ b/server/services/updateChecker.test.js
@@ -312,6 +312,29 @@ describe('checkForUpdate', () => {
);
});
+ it('bypasses the backoff for a manual "check now" request', async () => {
+ readJSONFile
+ .mockResolvedValueOnce({
+ lastCheck: null,
+ latestRelease: null,
+ ignoredVersions: [],
+ updateInProgress: false,
+ lastUpdateResult: null
+ })
+ .mockResolvedValueOnce({ version: '1.26.0' });
+ execGh.mockResolvedValue(JSON.stringify({ tag_name: 'v1.27.0' }));
+
+ // A user who explicitly asked for a check must always get a real
+ // attempt, not a silent rejection from a cooldown the unattended
+ // scheduler armed on its own after an earlier failure.
+ await checkForUpdate({ manual: true });
+ expect(execGh).toHaveBeenCalledWith(
+ ['api', 'repos/atomantic/PortOS/releases/latest'],
+ undefined,
+ {}
+ );
+ });
+
it('should not detect update when versions match', async () => {
readJSONFile
.mockResolvedValueOnce({