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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix([style-probe-image-uses-draft-not-saved]): address codex review — require clean draft at probe completion
[._.]/ Adam Eivy93d1df58fc86
diff --git a/client/src/components/universe/StyleProbeImage.jsx b/client/src/components/universe/StyleProbeImage.jsxindex 3f6f6954a3..71fc3f1eae 100644--- a/client/src/components/universe/StyleProbeImage.jsx+++ b/client/src/components/universe/StyleProbeImage.jsx@@ -43,6 +43,19 @@ export function hasStyleForProbe(universe) {// different influences.export const probeStyleKey = (universe) => JSON.stringify(buildStyleProbePrompt(universe));+// Decide whether a completed probe may be persisted onto the saved record. The+// render-time gate ensures a probe only STARTS while the style is clean, but the+// job is async — so the completion handler must re-confirm two things hold:+// 1. the draft still equals the saved record (`!styleDirty`) — otherwise the+// image would pin to a record whose influences differ from the draft (e.g.+// the user saved a different style, or reverted the draft without saving);+// 2. the live style still matches what the probe was queued against — so a+// save-to-a-different-style mid-render can't pin a stale image either.+// Conservative by design: it would rather drop a still-valid image (asking for a+// harmless re-run) than ever pin one built from different influences.+export const shouldPersistProbe = ({ styleDirty, capturedKey, currentKey }) =>+ !styleDirty && capturedKey !== null && currentKey === capturedKey;+export default function StyleProbeImage({ universe, onUniverseChange, canRender = true, styleDirty = false, onPreview = null, onRenderComplete = null }) {const [imageCfg, setImageCfg] = useState(PIPELINE_IMAGE_DEFAULTS);const [jobId, setJobId] = useState(null);@@ -87,11 +100,11 @@ export default function StyleProbeImage({ universe, onUniverseChange, canRenderif (!filename || !universe?.id) return;if (processedRef.current.has(filename)) return; // multi-fire guardprocessedRef.current.add(filename);- // The probe job is async; if the live style drifted from what it was queued- // against (the user edited + saved influences while it rendered), the image- // no longer represents the saved record — drop it rather than pin a- // mismatched ref the gate at render time meant to prevent.- if (probeStyleKeyRef.current !== null && probeStyleKey(universe) !== probeStyleKeyRef.current) {+ // The probe job is async; only persist when the draft still equals the saved+ // record AND the live style matches what the probe was queued against — else+ // the image would pin to a record built from different influences (the very+ // mismatch the render-time gate exists to prevent).+ if (!shouldPersistProbe({ styleDirty, capturedKey: probeStyleKeyRef.current, currentKey: probeStyleKey(universe) })) {toast.error('Style changed while the base style rendered — re-run the probe');return;}diff --git a/client/src/components/universe/StyleProbeImage.test.jsx b/client/src/components/universe/StyleProbeImage.test.jsxindex b023d3c5e0..dd7d57f212 100644--- a/client/src/components/universe/StyleProbeImage.test.jsx+++ b/client/src/components/universe/StyleProbeImage.test.jsx@@ -11,7 +11,7 @@ vi.mock('../../services/api', () => ({updateUniverse: vi.fn(() => Promise.resolve(null)),}));-import StyleProbeImage, { buildStyleProbePrompt, hasStyleForProbe, probeStyleKey } from './StyleProbeImage';+import StyleProbeImage, { buildStyleProbePrompt, hasStyleForProbe, probeStyleKey, shouldPersistProbe } from './StyleProbeImage';describe('StyleProbeImage — buildStyleProbePrompt', () => {it('uses embrace tokens as positive and avoid tokens as negative', () => {@@ -74,6 +74,34 @@ describe('StyleProbeImage — probeStyleKey (mid-render drift guard)', () => {});});+describe('StyleProbeImage — shouldPersistProbe (async completion guard)', () => {+ const A = 'keyA';+ const B = 'keyB';++ it('persists when the draft is clean and the live style still matches the queued probe', () => {+ expect(shouldPersistProbe({ styleDirty: false, capturedKey: A, currentKey: A })).toBe(true);+ });++ it('drops when influences were saved to a different style mid-render', () => {+ // queued A, then edited + saved B → live key is now B (clean), captured A.+ expect(shouldPersistProbe({ styleDirty: false, capturedKey: A, currentKey: B })).toBe(false);+ });++ it('drops the codex revert case: queued A, saved B, draft reverted to A but unsaved', () => {+ // draft key matches captured A, but draft != saved (B) so styleDirty is true.+ // Without the styleDirty guard the A image would wrongly pin to the saved B record.+ expect(shouldPersistProbe({ styleDirty: true, capturedKey: A, currentKey: A })).toBe(false);+ });++ it('drops on unsaved style edits during render (conservative — safe re-run)', () => {+ expect(shouldPersistProbe({ styleDirty: true, capturedKey: A, currentKey: B })).toBe(false);+ });++ it('drops when no probe was queued (captured key absent)', () => {+ expect(shouldPersistProbe({ styleDirty: false, capturedKey: null, currentKey: A })).toBe(false);+ });+});+describe('StyleProbeImage — styleDirty gating', () => {const universe = { id: 'u1', influences: { embrace: ['noir'], avoid: [] }, styleImageRefs: [] };