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: stop reporting a failed app archive as success (#3436)

[._.]/ Adam Eivyef0f43bc66ce
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 9a330a5d70..3c43983a09 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -8,6 +8,7 @@
## Fixed
+- **[issue-3436] Archiving an app no longer reports success when the request failed.** `handleArchive` / `handleUnarchive` on `/apps` swallowed the failure with `.catch(() => null)` and then fired their success toast unconditionally — so a failed archive showed the red "Request failed" toast from `request()` immediately followed by a green "<app> archived", and the last one read won. The user was told an app was excluded from CoS scheduling when it was not. Both handlers now gate the toast on a response, matching `handleBuild` in the same file, and update the row's archived state locally on success instead of waiting for the `apps:changed` round-trip. The app-detail Overview tab carried the identical bug and is fixed with it.
- **[issue-3435] A running app Update no longer vanishes when you collapse the row or leave `/apps`, and can't be dispatched twice.** The Update / Standardize flow (git pull → npm install → setup → PM2 restart, minutes long) rendered its step log *inside* the expanded row, and the hook tracking it held `isOperating` / `steps` in page state whose unmount tore down the socket listeners — so collapsing the row or navigating away left a long-running operation with no indicator anywhere, and the second dispatch that invited ran a concurrent `npm install` against the same checkout. The server now owns the in-flight set: a module-level map keyed by app id rejects a second `app:update` / `app:standardize` for an app already operating (a re-entrancy guard, not a lock), buffers the steps emitted so far, and broadcasts progress with `io.emit` instead of replying only to the socket that dispatched. Clients rehydrate from `app:operations:active` — pushed on connect and on demand via `app:operations:list` — so a page that mounts mid-operation restores the whole log. `/apps` renders that state in a sticky page-level banner naming the app (`Updating <app>…`) above the list instead of inside the row, and a row blocked only by another app's operation now reads `Update (busy)` rather than being silently greyed out. Operations are tracked per app id, so two apps operating from different tabs each get their own banner instead of one shadowing the other, and the app-detail Overview tab passes its own `appId` so it still reports only its own operation. The guard also matches on `repoPath`, since two app records can point at the same checkout; a refused dispatch is flagged `duplicate` so the client toasts it without marking the healthy run failed; and a completion carrying `success: false` now reads as a failure instead of "Operation complete".
- **A successful `branch-cleanup` run is no longer recorded as a failure.** The task deletes merged branches in the app's live checkout — its prompt `cd`s to the repo path and runs `git branch -d` / `git push --delete` — but it was the only git/gh coordinator type shipping with no `taskMetadata` at all, so `applyAppWorktreeDefault` filled `useWorktree`/`openPR` from the app's `defaultOpenPR: true`. Every run got a CoS-managed worktree it never touched (one that holds the very refs it was trying to delete) and a PR expectation it could never satisfy, and finalization scored the completed run `pr-missing`. The four non-committing coordinator types — `branch-cleanup`, `branch-reconcile`, `issue-reconcile`, `jira-status-report` — now share one documented `taskMetadata` posture: `useWorktree`/`openPR` explicitly `false` (not merely absent, which is what let the app defaults in) *and* locked via `MANAGED_AGENT_OPTIONS` so a per-app override can't re-attach them, plus `worktreeChangesExpected: false`, because a clean tree is the success shape for a branch deletion or a posted report and the TUI idle-complete gate must not read it as "the model produced no work". `jira-status-report` was hit by the same bug for a subtler reason: its `readOnly: true` skips worktree *creation* but the finalize-time PR-claim check reads `metadata.openPR` directly, so a posted report still scored `pr-missing`. A guard test now iterates `NON_COMMITTING_COORDINATOR_TASK_TYPES` — the set that already grants these types their commit-criterion exemption — so a future coordinator type can't be added to one list and not the other. Existing installs pick all of this up on the next schedule load: the taskMetadata deep-merge backfills the new keys and `enforceManagedAgentOptions` rewrites any stored `true`.
- **[issue-3396] CyberCity's ambient music no longer drifts under main-thread load.** The chord changes (every 2400ms) and the 16th-note arp plucks (every 150ms) rode two independent `setInterval`s that each read `ctx.currentTime` at fire time — so under load both drifted against the audio clock *and* against each other, the failure mode the sibling synth players adopted the shared lookahead scheduler to avoid. Both now come off one 16th-note step counter (16 steps per chord, so the arp is phase-locked to the chord changes by construction) and every event is written to the audio clock at an absolute grid time, `gridOrigin + step × 0.15s`, which cannot accumulate drift. The timing constants come from `SYNTH_TIMING` in `lib/lookaheadTransport.js` so the feel stays shared; the transport body itself is deliberately not reused, because it reads its clock from the shared `lib/audioContext.js` singleton while `cityAudioEngine` is a documented holdout that owns (and closes) its own `AudioContext` — scheduling this graph against a clock it doesn't run on would be worse than the drift. A backgrounded tab now re-anchors to the grid on return instead of dumping every missed step into one burst. Generative behavior (chord walk, mood sets, energy-driven arp gain) and the stop-ramp contract are unchanged.
diff --git a/client/src/components/apps/tabs/OverviewTab.jsx b/client/src/components/apps/tabs/OverviewTab.jsx
index 0da5025b50..d401199877 100644
--- a/client/src/components/apps/tabs/OverviewTab.jsx
+++ b/client/src/components/apps/tabs/OverviewTab.jsx
@@ -97,21 +97,23 @@ export default function OverviewTab({ app, onRefresh }) {
}
};
- const handleArchive = async () => {
+ // Same contract as the /apps list (#3436): `request()` already toasted the
+ // failure, so a success toast on top of it would tell the user the app was
+ // excluded from CoS scheduling when nothing changed.
+ const setArchived = async (archived) => {
setArchiving(true);
- await api.archiveApp(app.id).catch(() => null);
+ const result = await (archived ? api.archiveApp(app.id) : api.unarchiveApp(app.id)).catch(() => null);
setArchiving(false);
- toast.success(`${app.name} archived - excluded from COS tasks`);
+ if (!result) return;
+ toast.success(archived
+ ? `${app.name} archived — excluded from CoS tasks`
+ : `${app.name} unarchived — included in CoS tasks`);
onRefresh();
};
- const handleUnarchive = async () => {
- setArchiving(true);
- await api.unarchiveApp(app.id).catch(() => null);
- setArchiving(false);
- toast.success(`${app.name} unarchived - included in COS tasks`);
- onRefresh();
- };
+ const handleArchive = () => setArchived(true);
+
+ const handleUnarchive = () => setArchived(false);
return (
<div className="space-y-6">
diff --git a/client/src/pages/Apps.jsx b/client/src/pages/Apps.jsx
index b52f546f22..b1199a6407 100644
--- a/client/src/pages/Apps.jsx
+++ b/client/src/pages/Apps.jsx
@@ -136,19 +136,24 @@ export default function Apps() {
}
};
- const handleArchive = async (app) => {
+ // Archive/unarchive gate their success toast on a response, the way
+ // handleBuild does: `request()` already toasted the failure, and a green
+ // "archived" on top of it told the user an app was excluded from CoS
+ // scheduling when it was not (#3436).
+ const setArchived = async (app, archived) => {
setArchiving(prev => ({ ...prev, [app.id]: true }));
- await api.archiveApp(app.id).catch(() => null);
+ const result = await (archived ? api.archiveApp(app.id) : api.unarchiveApp(app.id)).catch(() => null);
setArchiving(prev => ({ ...prev, [app.id]: false }));
- toast.success(`${app.name} archived - excluded from COS tasks`);
+ if (!result) return;
+ setApps(prev => prev.map(a => (a.id === app.id ? { ...a, archived } : a)));
+ toast.success(archived
+ ? `${app.name} archived — excluded from CoS tasks`
+ : `${app.name} unarchived — included in CoS tasks`);
};
- const handleUnarchive = async (app) => {
- setArchiving(prev => ({ ...prev, [app.id]: true }));
- await api.unarchiveApp(app.id).catch(() => null);
- setArchiving(prev => ({ ...prev, [app.id]: false }));
- toast.success(`${app.name} unarchived - included in COS tasks`);
- };
+ const handleArchive = (app) => setArchived(app, true);
+
+ const handleUnarchive = (app) => setArchived(app, false);
// The server names the app it is operating on (so a rehydrated operation is
// labelled even before the list loads); fall back to the loaded list.
diff --git a/client/src/pages/Apps.test.jsx b/client/src/pages/Apps.test.jsx
index 1e663879a1..dba46808a7 100644
--- a/client/src/pages/Apps.test.jsx
+++ b/client/src/pages/Apps.test.jsx
@@ -35,11 +35,16 @@ vi.mock('../services/api', () => ({
handleSelfRestart: vi.fn(),
}));
+vi.mock('../components/ui/Toast', () => ({
+ default: { success: vi.fn(), error: vi.fn(), loading: vi.fn(), dismiss: vi.fn(), custom: vi.fn() }
+}));
+
vi.mock('../services/socket', () => ({
default: { on: vi.fn(), off: vi.fn(), emit: vi.fn() },
}));
import * as api from '../services/api';
+import toast from '../components/ui/Toast';
import socket from '../services/socket';
import Apps from './Apps';
@@ -343,3 +348,55 @@ describe('Apps concurrent operations and duplicate dispatch (#3435)', () => {
expect(banners()[0].textContent).toContain('Update failed for Example App');
});
});
+
+describe('Apps archive result reporting (#3436)', () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ api.getApps.mockResolvedValue(APPS);
+ });
+
+ it('does not claim an app was archived when the request failed', async () => {
+ api.archiveApp.mockRejectedValue(new Error('Server unreachable'));
+ const user = userEvent.setup();
+ await renderApps();
+
+ await openRowMenu(user);
+ await user.click(screen.getByRole('menuitem', { name: 'Archive' }));
+ await waitFor(() => expect(api.archiveApp).toHaveBeenCalledWith('app-alpha'));
+
+ // request() already toasted the failure — a green "archived" on top of it
+ // told the user CoS would skip the app when nothing changed.
+ expect(toast.success).not.toHaveBeenCalled();
+
+ // …and the menu item is back from "Working…" so the action can be retried.
+ await openRowMenu(user);
+ expect(screen.getByRole('menuitem', { name: 'Archive' })).toBeTruthy();
+ });
+
+ it('does not claim an app was unarchived when the request failed', async () => {
+ api.getApps.mockResolvedValue([ARCHIVED_APP]);
+ api.unarchiveApp.mockRejectedValue(new Error('Server unreachable'));
+ const user = userEvent.setup();
+ render(<MemoryRouter initialEntries={['/apps?view=archived']}><Apps /></MemoryRouter>);
+ await screen.findByRole('link', { name: 'Example App' });
+
+ await openRowMenu(user);
+ await user.click(screen.getByRole('menuitem', { name: 'Unarchive' }));
+ await waitFor(() => expect(api.unarchiveApp).toHaveBeenCalledWith('app-alpha'));
+
+ expect(toast.success).not.toHaveBeenCalled();
+ });
+
+ it('confirms and reflects a successful archive without waiting for a refetch', async () => {
+ api.archiveApp.mockResolvedValue({ ...APPS[0], archived: true });
+ const user = userEvent.setup();
+ await renderApps();
+
+ await openRowMenu(user);
+ await user.click(screen.getByRole('menuitem', { name: 'Archive' }));
+
+ await waitFor(() => expect(toast.success).toHaveBeenCalledWith(expect.stringContaining('archived')));
+ // Local state moved the row into the archived list — no refetch needed.
+ expect(await screen.findByRole('button', { name: /Archived \(1\)/ })).toBeTruthy();
+ });
+});