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

address review (claude): scope Run Now state merge + report orphaned project on late failure

Adam Eivy6a2185116412
diff --git a/client/src/pages/CreativeCommissions.jsx b/client/src/pages/CreativeCommissions.jsx
index 3f51cda69f..11163f1630 100644
--- a/client/src/pages/CreativeCommissions.jsx
+++ b/client/src/pages/CreativeCommissions.jsx
@@ -275,8 +275,13 @@ export default function CreativeCommissions() {
setRunningIds((prev) => new Set(prev).add(commission.id));
try {
const result = await runCommissionNow(commission.id, { silent: true });
+ // Merge only the run-history fields the response is authoritative for —
+ // replacing the whole record would clobber a concurrent optimistic local
+ // mutation (e.g. a Pause click while the run was in flight) with the
+ // server re-read that predates it.
if (result?.commission?.id) {
- setCommissions((prev) => prev.map((c) => (c.id === result.commission.id ? result.commission : c)));
+ const fresh = result.commission;
+ setCommissions((prev) => prev.map((c) => (c.id === fresh.id ? { ...c, runs: fresh.runs, feedback: fresh.feedback } : c)));
}
if (result?.status === 'started') toast.success('Run started — output will appear in run history');
else if (result?.status === 'skipped') toast.error(`Run skipped: ${result.reason}`);
diff --git a/server/services/creativeCommissions/scheduler.js b/server/services/creativeCommissions/scheduler.js
index ab32e9d7df..f0e36c55fd 100644
--- a/server/services/creativeCommissions/scheduler.js
+++ b/server/services/creativeCommissions/scheduler.js
@@ -180,6 +180,11 @@ export async function runCommissionNow(commissionId) {
*/
async function fireCommission(commission, trigger) {
const commissionId = commission.id;
+ // Hoisted so a throw AFTER createProject succeeded (e.g. the advance kick)
+ // still reports the minted project on the failed run/outcome — otherwise a
+ // manual caller sees a bare failure, can't find the orphaned CD project, and
+ // a retry mints a duplicate.
+ let startedProjectId = null;
const skip = async (reason) => {
const run = await recordCommissionRun(commissionId, { status: 'skipped', reason, trigger }).catch(() => null);
return { status: 'skipped', reason, run };
@@ -279,6 +284,7 @@ async function fireCommission(commission, trigger) {
modelOverrides,
});
+ startedProjectId = project.id;
const run = await recordCommissionRun(commissionId, {
status: 'started',
trigger,
@@ -300,7 +306,7 @@ async function fireCommission(commission, trigger) {
} catch (err) {
console.error(`❌ Creative commission ${commissionId} ${trigger} fire failed: ${err?.message || err}`);
const error = err?.message || String(err);
- const run = await recordCommissionRun(commissionId, { status: 'failed', error, trigger }).catch(() => null);
- return { status: 'failed', error, run };
+ const run = await recordCommissionRun(commissionId, { status: 'failed', error, trigger, projectId: startedProjectId }).catch(() => null);
+ return { status: 'failed', error, projectId: startedProjectId, run };
}
}
diff --git a/server/services/creativeCommissions/scheduler.test.js b/server/services/creativeCommissions/scheduler.test.js
index 7a69c0829f..99619aa84f 100644
--- a/server/services/creativeCommissions/scheduler.test.js
+++ b/server/services/creativeCommissions/scheduler.test.js
@@ -333,10 +333,20 @@ describe('runCommissionNow (manual "Run Now")', () => {
createProjectMock.mockRejectedValueOnce(new Error('collection create failed'));
getCommissionMock.mockResolvedValue(videoCommission());
const outcome = await runCommissionNow('commission-1');
- expect(outcome).toMatchObject({ status: 'failed', error: 'collection create failed' });
+ expect(outcome).toMatchObject({ status: 'failed', error: 'collection create failed', projectId: null });
expect(recordRunMock).toHaveBeenCalledWith('commission-1', expect.objectContaining({ status: 'failed', error: 'collection create failed', trigger: 'manual' }));
});
+ it('reports the minted project id when the fire throws AFTER createProject succeeded', async () => {
+ // Without the id, the caller sees a bare failure, can't find the orphaned
+ // CD project, and a retry mints a duplicate.
+ advanceMock.mockRejectedValueOnce(new Error('advance kick failed'));
+ getCommissionMock.mockResolvedValue(videoCommission());
+ const outcome = await runCommissionNow('commission-1');
+ expect(outcome).toMatchObject({ status: 'failed', error: 'advance kick failed', projectId: 'cd-xyz' });
+ expect(recordRunMock).toHaveBeenCalledWith('commission-1', expect.objectContaining({ status: 'failed', projectId: 'cd-xyz', trigger: 'manual' }));
+ });
+
it('propagates NOT_FOUND for an unknown commission (route maps it to 404)', async () => {
getCommissionMock.mockRejectedValue(Object.assign(new Error('gone'), { code: 'NOT_FOUND' }));
await expect(runCommissionNow('missing')).rejects.toMatchObject({ code: 'NOT_FOUND' });