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 (codex r4): delete-vs-feedback race, newest-first digest, blur vote swallow

[._.]/ Adam Eivy828c3847ef80
diff --git a/client/src/pages/CreativeCommissions.jsx b/client/src/pages/CreativeCommissions.jsx
index a74781ced6..0de3655f8d 100644
--- a/client/src/pages/CreativeCommissions.jsx
+++ b/client/src/pages/CreativeCommissions.jsx
@@ -629,7 +629,12 @@ function RunFeedback({ runId, current, onRate }) {
// discarded on close/save (the drawer Save doesn't carry feedback). A note
// can't be saved before a rating exists — a rating is required — so this is a
// no-op until the run has been thumbed at least once.
- const persistNoteEdit = async () => {
+ const persistNoteEdit = async (e) => {
+ // Don't autosave when focus is moving to a rating button — the thumb's own
+ // click will save the (edited) note under the NEW vote. Autosaving here would
+ // fire submit(oldRating) + setBusy(true), disabling the thumb before its
+ // click lands, so the newly clicked vote would be silently dropped.
+ if (e?.relatedTarget?.hasAttribute?.('data-commission-rate')) return;
if (busy || !rating) return;
if (note.trim() === (current?.note || '')) return; // unchanged
await submit(rating);
@@ -641,6 +646,7 @@ function RunFeedback({ runId, current, onRate }) {
type="button"
disabled={busy}
onClick={() => submit('up')}
+ data-commission-rate
aria-label="Like this result"
aria-pressed={isUp}
title="Like — steer future runs toward this"
@@ -652,6 +658,7 @@ function RunFeedback({ runId, current, onRate }) {
type="button"
disabled={busy}
onClick={() => submit('down')}
+ data-commission-rate
aria-label="Dislike this result"
aria-pressed={isDown}
title="Dislike — steer future runs away from this"
diff --git a/server/services/creativeCommissions/directive.js b/server/services/creativeCommissions/directive.js
index 1ff38393d2..8e69ad9c9e 100644
--- a/server/services/creativeCommissions/directive.js
+++ b/server/services/creativeCommissions/directive.js
@@ -86,11 +86,15 @@ export function renderFeedbackDigest(feedback, windowSize = 5) {
// first) can't eat the whole digest and truncate away the newer dislikes + the
// steering instruction. Each group gets an equal share of the digest budget
// (minus the fixed steering sentence); the final clamp is then a no-op safety net.
+ // Render each group NEWEST-first before clamping: `likes`/`dislikes` are
+ // collected oldest→newest, and `clamp` keeps the prefix, so clamping the
+ // chronological join would drop the user's LATEST reaction in a long group.
+ // Reversing puts the newest notes first, so the truncation sheds the oldest.
const STEER = 'Steer toward the likes and away from the dislikes.';
const groupBudget = Math.max(0, Math.floor((MAX_DIGEST_LEN - STEER.length - 40) / 2));
const parts = [];
- if (likes.length) parts.push(`Recent likes: ${clamp(likes.join('; '), groupBudget)}.`);
- if (dislikes.length) parts.push(`Recent dislikes: ${clamp(dislikes.join('; '), groupBudget)}.`);
+ if (likes.length) parts.push(`Recent likes: ${clamp([...likes].reverse().join('; '), groupBudget)}.`);
+ if (dislikes.length) parts.push(`Recent dislikes: ${clamp([...dislikes].reverse().join('; '), groupBudget)}.`);
parts.push(STEER);
return clamp(parts.join(' '), MAX_DIGEST_LEN);
}
diff --git a/server/services/creativeCommissions/store.js b/server/services/creativeCommissions/store.js
index db22a43299..1ac9e2b985 100644
--- a/server/services/creativeCommissions/store.js
+++ b/server/services/creativeCommissions/store.js
@@ -329,9 +329,20 @@ export async function updateCommission(id, patch) {
}
export async function deleteCommission(id) {
- const current = await commissionStore().readRaw(id);
- if (!current) throw makeErr(`Commission not found: ${id}`, ERR_NOT_FOUND);
- await commissionStore().deleteRaw(id);
+ const store = commissionStore();
+ // Serialize the read+delete on the SAME per-id write queue as
+ // update/recordRun/submitFeedback. Otherwise an in-flight feedback write (its
+ // own queued read→writeRaw) could interleave with a delete that runs outside
+ // the queue: feedback reads the row, delete hard-deletes it, feedback's
+ // writeRaw then upserts the stale record and resurrects the commission. With
+ // delete on the tail, a feedback write queued after it finds no row and 404s.
+ const existed = await store.queueRecordWrite(id, async () => {
+ const current = await store.readRaw(id);
+ if (!current) return false;
+ await store.deleteRaw(id);
+ return true;
+ });
+ if (!existed) throw makeErr(`Commission not found: ${id}`, ERR_NOT_FOUND);
commissionEvents.emit('commission:changed', { id, action: 'delete' });
return { id, deleted: true };
}