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

tell the user which forge CLI is broken instead of "try again shortly" forever

[._.]/ Adam Eivy548243a87c1d
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 766822621a..ba5e2941cd 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -59,6 +59,7 @@
## Chief of Staff
+- **"Try again shortly" no longer hides a forge CLI that will never work again on its own.** Running a perpetual task like claim-issue when its `gh` probe fails always toasted "couldn't complete the check just now (a transient forge/network issue) — try again shortly", which is only true for a momentary blip. A `gh` that isn't installed, isn't authenticated, or is blocked outbound by a local firewall fails identically on every future tick, so the advice sent you in a loop with nothing naming the actual fault — the firewall case is the worst of the three, since a denied `connect()` surfaces as "bad file descriptor" and reads like a local bug rather than a network block. The work detector already knew which CLI it ran and how the call failed, but a transient skip deliberately doesn't park, so that verdict had nowhere to go and was dropped at a debug log. It now travels the same route the park reason already does, and when the failing CLI is `gh` the toast reports its health with the remedy ("allow the gh binary to reach api.github.com", "run `gh auth login`", "install the GitHub CLI"). Attribution comes from the CLI that actually failed rather than the task-type name — `claim-work` picks its forge internally, and branch-reconcile and quota-burn go transient over git and provider faults with no forge involved, so a name-based guess would have told a GitLab or Ollama user to install the GitHub CLI. A blip where `gh` itself is fine still gets the original wording.
- **Run-history row actions and screenshot-remove buttons are now visible when you tab to them.** The view-logs, resume and delete buttons on a run-history row — and the remove-screenshot buttons on the task form and the resume-agent dialog — were revealed only on mouse hover. On a tablet, which has no hover state, they were undiscoverable; for anyone navigating by keyboard they could be focused but never seen, so you could tab onto a delete button with nothing on screen telling you so. They now appear on keyboard focus as well as hover.
## Messages
diff --git a/client/src/hooks/useOnDemandTaskToast.js b/client/src/hooks/useOnDemandTaskToast.js
index 61f49eab58..e3daab95f2 100644
--- a/client/src/hooks/useOnDemandTaskToast.js
+++ b/client/src/hooks/useOnDemandTaskToast.js
@@ -37,11 +37,17 @@ export function useOnDemandTaskToast() {
const scope = data?.appName ? ` for ${data.appName}` : '';
// A perpetual task that did NOT park ⇒ the detector couldn't complete (a
- // transient gh/glab probe failure). Never claim "nothing to do" — the
- // check didn't finish.
+ // gh/glab probe failure). Never claim "nothing to do" — the check didn't
+ // finish. When the server classified the forge CLI as broken in a way that
+ // will NOT clear on its own (not installed / not authenticated / blocked
+ // outbound), say THAT and give the remedy — "try again shortly" is a dead
+ // end when every future tick fails identically.
if (data?.outcome === 'transient') {
- toast(`${task}${scope}: couldn't complete the check just now (a transient forge/network issue) — try again shortly.`, {
- duration: 7000,
+ const forge = data?.forge;
+ toast(forge?.remedy
+ ? `${task}${scope}: the ${forge.cli} check couldn't run — ${forge.remedy}`
+ : `${task}${scope}: couldn't complete the check just now (a transient forge/network issue) — try again shortly.`, {
+ duration: forge?.remedy ? 12000 : 7000,
icon: '⚠️'
});
return;
diff --git a/client/src/hooks/useOnDemandTaskToast.test.jsx b/client/src/hooks/useOnDemandTaskToast.test.jsx
index 32c5017412..f48dac7558 100644
--- a/client/src/hooks/useOnDemandTaskToast.test.jsx
+++ b/client/src/hooks/useOnDemandTaskToast.test.jsx
@@ -47,6 +47,37 @@ describe('useOnDemandTaskToast — idle outcome', () => {
});
});
+describe('useOnDemandTaskToast — transient outcome', () => {
+ beforeEach(() => { handlers.clear(); toastSpy.mockClear(); });
+ afterEach(cleanup);
+
+ it('keeps the generic "try again shortly" copy when the forge health is unknown', () => {
+ renderHook(() => useOnDemandTaskToast());
+ fire({ taskType: 'claim-issue', appName: 'App One', outcome: 'transient' });
+ const [msg, opts] = toastSpy.mock.calls[0];
+ expect(msg).toMatch(/transient forge\/network issue/);
+ expect(opts.icon).toBe('⚠️');
+ });
+
+ it('names the real fault + remedy when the forge CLI is broken in a way that will not self-clear', () => {
+ renderHook(() => useOnDemandTaskToast());
+ fire({
+ taskType: 'claim-issue', appName: 'App One', outcome: 'transient',
+ forge: {
+ cli: 'gh',
+ remedy: 'gh cannot open an outbound connection. If an outbound firewall (e.g. Little Snitch) is installed, allow the gh binary to reach api.github.com — a denied connect surfaces as "bad file descriptor".'
+ }
+ });
+ const [msg, opts] = toastSpy.mock.calls[0];
+ // Names the CLI that actually failed, so a glab fault never reads as a gh one.
+ expect(msg).toMatch(/the gh check couldn't run/);
+ expect(msg).toMatch(/allow the gh binary to reach api\.github\.com/);
+ // "try again shortly" is a dead end for a permanent fault — it must be gone.
+ expect(msg).not.toMatch(/try again shortly/);
+ expect(opts.duration).toBeGreaterThan(7000);
+ });
+});
+
describe('useOnDemandTaskToast — parked outcome', () => {
beforeEach(() => { handlers.clear(); toastSpy.mockClear(); });
afterEach(cleanup);
diff --git a/server/services/cosTaskGenerator.js b/server/services/cosTaskGenerator.js
index c0949b5d37..68613c399f 100644
--- a/server/services/cosTaskGenerator.js
+++ b/server/services/cosTaskGenerator.js
@@ -1782,14 +1782,53 @@ async function generateManagedAppImprovementTask(app, state, { ignoreTaskId = nu
* @param {Object} state - Current CoS state
* @returns {Object} Generated task
*/
+// Last transient (non-parking) detector verdict, keyed the same way a park is
+// (`taskType` + appId), so emitOnDemandEmpty can read it right beside
+// getPerpetualParkInfo. A transient skip deliberately does NOT park — there is no
+// park record to hang the reason on — so this is that path's reason channel.
+//
+// Deliberately in-memory and short-lived: the only consumer is the emit that
+// follows the gate a few frames later in the SAME drain, so a persisted schedule
+// field would have nothing left to read it after a restart. The TTL keeps a
+// verdict from a *previous* drain out of an unrelated later toast, and the read
+// consumes it so it can never be reported twice.
+const TRANSIENT_VERDICT_TTL_MS = 60_000;
+const transientVerdicts = new Map();
+const transientVerdictKey = (taskType, appId) => `${taskType}:${appId || 'global'}`;
+
+/**
+ * Record why a perpetual work gate skipped WITHOUT parking. `cli` is the forge
+ * CLI whose probe failed (`gh` / `glab`), or null when no forge was involved.
+ * Passing a null verdict clears any stale entry (the actionable / park paths).
+ */
+export function recordPerpetualTransient(taskType, appId, verdict) {
+ const key = transientVerdictKey(taskType, appId);
+ if (!verdict) {
+ transientVerdicts.delete(key);
+ return;
+ }
+ transientVerdicts.set(key, { ...verdict, at: Date.now() });
+}
+
+/** Read-and-consume the recorded verdict; null when absent or past its TTL. */
+function takePerpetualTransient(taskType, appId) {
+ const key = transientVerdictKey(taskType, appId);
+ const verdict = transientVerdicts.get(key);
+ transientVerdicts.delete(key);
+ if (!verdict || (Date.now() - verdict.at) > TRANSIENT_VERDICT_TTL_MS) return null;
+ return verdict;
+}
+
/**
* Surface WHY a user-initiated on-demand "Run" produced no task, so the trigger
* isn't a silent no-op the user only discovers in the pm2 logs. Emits
* `schedule:on-demand-empty` (which the client toasts) with an `outcome`:
* - 'parked' → a perpetual detector re-checked and found no actionable work;
* carries the reason + open/in-flight/filtered breakdown.
- * - 'transient' → a perpetual task that did NOT park — a transient gh/glab
- * probe failure — so the check didn't actually complete.
+ * - 'transient' → a perpetual task that did NOT park — a gh/glab probe
+ * failure — so the check didn't actually complete. Carries a
+ * `forge` block naming the real fault when the CLI is broken
+ * in a way that will NOT clear on its own.
* - 'idle' → a non-perpetual task produced no task: a genuine "nothing to
* do", NOT a failure (e.g. pr-watcher with no new PRs).
*
@@ -1818,6 +1857,24 @@ export async function emitOnDemandEmpty({ taskScheduleMod, request, targetApp, t
reason = app?.layeredIntelligence?.lastRunReason || null;
}
+ // 'transient' says "the forge probe failed, try again shortly" — only true when
+ // the forge is momentarily flaky. A gh that is missing, unauthenticated, or
+ // blocked by an outbound firewall fails EVERY tick forever, so that advice sends
+ // the user in circles. Ask the CLI the detector actually ran (recorded by the
+ // work gate moments ago — the task-type NAME can't answer this: `claim-work`
+ // resolves its forge internally, and branch-reconcile/quota-burn go transient
+ // over git/provider faults with no forge involved) whether it is broken in a
+ // way that won't self-clear, and pass the remedy through. No verdict, an
+ // unprobeable CLI, or a healthy one all leave `forge` null and keep the
+ // generic copy — the failure really was a blip, or at least not one we can name.
+ let forge = null;
+ const verdict = outcome === 'transient' ? takePerpetualTransient(request.taskType, appId) : null;
+ if (verdict?.cli === 'gh') {
+ const { checkGhHealth } = await import('./github.js');
+ const health = await checkGhHealth().catch(() => null);
+ if (health && !health.ok && health.remedy) forge = { cli: 'gh', remedy: health.remedy };
+ }
+
cosEvents.emit('schedule:on-demand-empty', {
requestId: request.id,
taskType: request.taskType,
@@ -1825,6 +1882,7 @@ export async function emitOnDemandEmpty({ taskScheduleMod, request, targetApp, t
appName: targetApp?.name || null,
outcome,
reason,
+ forge,
parkReason: parkInfo?.parkReason || null,
parkedUntil: parkInfo?.parkedUntil || null,
actionableCount: parkInfo?.parkActionableCount ?? null,
@@ -1946,13 +2004,19 @@ async function applyPerpetualWorkGate(app, taskType, promptTaskType, metadata, i
});
if (detection.actionable) {
await taskSchedule.clearPerpetualPark(taskType, app.id);
+ recordPerpetualTransient(taskType, app.id, null);
metadata.perpetual = true;
return { skip: false };
}
if (detection.transient) {
emitLog('debug', `Perpetual ${taskType} skip for ${app.name} (transient: ${detection.reason})`, { appId: app.id });
+ // The skip is silent by design (the next tick retries), but an explicit user
+ // "Run" ends here too — record which CLI failed so emitOnDemandEmpty can tell
+ // the difference between a blip and a forge that is broken for good.
+ recordPerpetualTransient(taskType, app.id, { cli: detection.cli || null, reason: detection.reason });
return { skip: true };
}
+ recordPerpetualTransient(taskType, app.id, null);
// Carry the detector's open/in-flight/filtered breakdown into the park so an
// explicit "Run" can explain WHY a non-empty queue yielded no work.
const counts = detection.total != null
diff --git a/server/services/cosTaskGenerator.test.js b/server/services/cosTaskGenerator.test.js
index 7bb244bdf0..4854976d10 100644
--- a/server/services/cosTaskGenerator.test.js
+++ b/server/services/cosTaskGenerator.test.js
@@ -11,7 +11,7 @@
* (under-report). These tests pin both behaviors.
*/
-import { describe, it, expect, vi } from 'vitest';
+import { describe, it, expect, vi, beforeEach } from 'vitest';
import { readFileSync } from 'fs';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
@@ -27,8 +27,15 @@ vi.mock('./codeReview.js', async (importActual) => ({
...(await importActual()),
getCodeReviewDefaults: vi.fn(async () => ({ reviewers: ['copilot'], usernames: ['alice'], optionalReviewers: [] })),
}));
+// emitOnDemandEmpty's gh-health read spawns `gh api rate_limit` for real. Stub it
+// so the transient-verdict tests assert OUR branching, not the machine's gh.
+const ghHealth = vi.fn(async () => ({ status: 'ok', ok: true, detail: null, remedy: null }));
+vi.mock('./github.js', async (importActual) => ({
+ ...(await importActual()),
+ checkGhHealth: (...a) => ghHealth(...a),
+}));
-import { selectDryRunAutoApproved, exceedsMaxSpawns, resolveIssueAuthorFilterBlock, resolveSwarmBlock, isCooldownExemptTask, emitOnDemandEmpty, buildJiraTicketTask, buildImprovementDedupSets, normalizeWorkItemRef, buildTargetWorkItemBlock, resolveTaskInputHook } from './cosTaskGenerator.js';
+import { selectDryRunAutoApproved, exceedsMaxSpawns, resolveIssueAuthorFilterBlock, resolveSwarmBlock, isCooldownExemptTask, emitOnDemandEmpty, recordPerpetualTransient, buildJiraTicketTask, buildImprovementDedupSets, normalizeWorkItemRef, buildTargetWorkItemBlock, resolveTaskInputHook } from './cosTaskGenerator.js';
import { cosEvents } from './cosEvents.js';
import { MAX_TOTAL_SPAWNS } from '../lib/validation.js';
@@ -627,6 +634,90 @@ describe('emitOnDemandEmpty', () => {
expect(events[0]).toMatchObject({ taskType: 'pr-watcher', outcome: 'idle', reason: null });
});
+ // Default: gh is healthy, so no test inherits a previous one's stubbed fault.
+ beforeEach(() => {
+ ghHealth.mockReset();
+ ghHealth.mockResolvedValue({ status: 'ok', ok: true, detail: null, remedy: null });
+ });
+
+ const emitTransient = async (taskType) => {
+ const events = [];
+ const handler = (d) => events.push(d);
+ cosEvents.on('schedule:on-demand-empty', handler);
+ try {
+ await emitOnDemandEmpty({
+ taskScheduleMod: stubMod,
+ request: { id: 'req-2', taskType },
+ targetApp: { id: 'app-1', name: 'App One' },
+ taskConfig: { type: 'perpetual' }
+ });
+ } finally {
+ cosEvents.off('schedule:on-demand-empty', handler);
+ }
+ return events[0];
+ };
+
+ it('emits no forge block when the gate recorded no transient verdict', async () => {
+ // Nothing recorded ⇒ we cannot name the fault, so the client keeps the
+ // generic "try again shortly" copy rather than guessing at a CLI.
+ expect(await emitTransient('claim-issue')).toMatchObject({ outcome: 'transient', forge: null });
+ });
+
+ it('skips the gh probe for a non-gh transient verdict, so a glab/git fault never toasts a gh remedy', async () => {
+ // branch-reconcile and quota-burn go transient over git / provider faults with
+ // no forge at all (cli: null); claim-issue-gitlab fails on glab. None of them
+ // should be attributed to gh — the pre-fix suffix check got all three wrong.
+ for (const [taskType, cli] of [['claim-issue-gitlab', 'glab'], ['branch-reconcile', null], ['quota-burn', null]]) {
+ recordPerpetualTransient(taskType, 'app-1', { cli, reason: 'probe-failed' });
+ expect(await emitTransient(taskType)).toMatchObject({ outcome: 'transient', forge: null });
+ }
+ });
+
+ it('names gh + its remedy when a gh verdict meets a gh that is broken for good', async () => {
+ ghHealth.mockResolvedValueOnce({
+ status: 'unreachable', ok: false, detail: 'bad file descriptor', remedy: 'Allow the gh binary outbound.'
+ });
+ recordPerpetualTransient('claim-issue', 'app-1', { cli: 'gh', reason: 'gh-list-failed' });
+ expect(await emitTransient('claim-issue')).toMatchObject({
+ outcome: 'transient',
+ forge: { cli: 'gh', remedy: 'Allow the gh binary outbound.' }
+ });
+ });
+
+ it('stays generic when gh itself is healthy — that failure really was a blip', async () => {
+ recordPerpetualTransient('claim-issue', 'app-1', { cli: 'gh', reason: 'gh-list-failed' });
+ expect(await emitTransient('claim-issue')).toMatchObject({ forge: null });
+ });
+
+ it('consumes the verdict on read, so a stale one cannot be reported twice', async () => {
+ ghHealth.mockResolvedValue({ status: 'not-installed', ok: false, detail: null, remedy: 'Install gh.' });
+ recordPerpetualTransient('claim-issue', 'app-1', { cli: 'gh', reason: 'gh-list-failed' });
+ expect(await emitTransient('claim-issue')).toMatchObject({ forge: { cli: 'gh' } });
+ // Second emit finds nothing recorded — the verdict belonged to the first run.
+ expect(await emitTransient('claim-issue')).toMatchObject({ forge: null });
+ });
+
+ it('keys the verdict by task type + app, so one type never consumes another\'s', async () => {
+ ghHealth.mockResolvedValue({ status: 'not-installed', ok: false, detail: null, remedy: 'Install gh.' });
+ recordPerpetualTransient('claim-issue', 'app-1', { cli: 'gh', reason: 'gh-list-failed' });
+ // A different task type on the same app must not read claim-issue's verdict…
+ expect(await emitTransient('pr-watcher')).toMatchObject({ forge: null });
+ // …and it is still intact for the type that recorded it.
+ expect(await emitTransient('claim-issue')).toMatchObject({ forge: { cli: 'gh' } });
+ });
+
+ it('drops a verdict older than its TTL rather than explaining an unrelated run', async () => {
+ ghHealth.mockResolvedValue({ status: 'not-installed', ok: false, detail: null, remedy: 'Install gh.' });
+ recordPerpetualTransient('claim-issue', 'app-1', { cli: 'gh', reason: 'gh-list-failed' });
+ vi.useFakeTimers({ shouldAdvanceTime: true });
+ vi.setSystemTime(Date.now() + 61_000);
+ try {
+ expect(await emitTransient('claim-issue')).toMatchObject({ forge: null });
+ } finally {
+ vi.useRealTimers();
+ }
+ });
+
it('reads the LI last-run reason only for the layered-intelligence task type', () => {
// Source-pinned (the behavioral read dynamic-imports the live app store):
// the reason surfacing is gated on the LI task type + the 'idle' outcome and
diff --git a/server/services/perpetualWork.js b/server/services/perpetualWork.js
index 0c39b5da66..e41b99b555 100644
--- a/server/services/perpetualWork.js
+++ b/server/services/perpetualWork.js
@@ -337,12 +337,18 @@ async function detectForgeIssues(forgeKey, app, { issueAuthorFilter = 'self' } =
// default plus any out-of-vocab value) = the @me security boundary. Transient
// resolver failures skip this dispatch and retry next tick rather than parking
// a full cadence.
+ // Shared shape for a transient (non-parking) probe failure. Carries the CLI
+ // that failed so the caller can attribute the fault to `gh` vs `glab` instead
+ // of guessing from the task-type name — a `claim-work` request only resolves to
+ // its forge-specific type internally, so the name is not a reliable signal.
+ const transient = (reason) => ({ actionable: false, count: 0, cli: cfg.cli, reason, transient: true });
+
let authorApplied = false;
if (issueAuthorFilter === 'any') {
// no --author filter
} else if (issueAuthorFilter === 'owner') {
const { owner, isOrg, error } = await cfg.resolveOwner(repoPath);
- if (error) return { actionable: false, count: 0, reason: error, transient: true };
+ if (error) return transient(error);
if (isOrg) {
// The owner filter resolved to a non-authoring owner (a GitHub ORG or a
// GitLab GROUP), which can never be an issue author — `--author <owner>` is
@@ -357,20 +363,20 @@ async function detectForgeIssues(forgeKey, app, { issueAuthorFilter = 'self' } =
authorApplied = true;
} else {
const { author, error } = await cfg.resolveSelf(repoPath);
- if (error) return { actionable: false, count: 0, reason: error, transient: true };
+ if (error) return transient(error);
args.push('--author', author);
authorApplied = true;
}
const res = await runCli(cfg.cli, args, repoPath);
- if (res.code !== 0) return { actionable: false, count: 0, reason: cfg.listFail, transient: true };
+ if (res.code !== 0) return transient(cfg.listFail);
let raw;
try {
raw = JSON.parse(res.stdout || '[]');
} catch {
- return { actionable: false, count: 0, reason: cfg.parseFail, transient: true };
+ return transient(cfg.parseFail);
}
- if (!Array.isArray(raw)) return { actionable: false, count: 0, reason: cfg.parseFail, transient: true };
+ if (!Array.isArray(raw)) return transient(cfg.parseFail);
if (raw.length === 0) {
// An empty *filtered* list is ambiguous: the repo may truly have no open
// issues, OR it has open issues that just don't match the author filter —