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 — guard the async completion against mid-render style drift
[._.]/ Adam Eivyccb117c01938
diff --git a/client/src/components/universe/StyleProbeImage.jsx b/client/src/components/universe/StyleProbeImage.jsxindex 7af16f2c4c..3f6f6954a3 100644--- a/client/src/components/universe/StyleProbeImage.jsx+++ b/client/src/components/universe/StyleProbeImage.jsx@@ -35,12 +35,23 @@ export function hasStyleForProbe(universe) {return Boolean(prompt.trim());}+// Stable key for the influences a probe was actually built from. The render job+// is async — between queuing it and its completion the user can edit *and save*+// influences, which re-points the saved record. Capturing this key when the+// probe is queued lets the completion handler skip persisting if the live style+// has since drifted, so a stale image can't be pinned to a record built from+// different influences.+export const probeStyleKey = (universe) => JSON.stringify(buildStyleProbePrompt(universe));+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);// MediaJobThumb's onFilename effect can fire more than once — process each// completed filename's persist exactly once.const processedRef = useRef(new Set());+ // The style key the in-flight probe was queued against, captured at render+ // time so the async completion can detect mid-render style drift.+ const probeStyleKeyRef = useRef(null);useEffect(() => {getSettings({ silent: true })@@ -67,6 +78,7 @@ export default function StyleProbeImage({ universe, onUniverseChange, canRender{ silent: true },).catch((err) => { toast.error(err?.message || 'Style render failed'); return null; });if (!queued?.jobId) return;+ probeStyleKeyRef.current = JSON.stringify(probe);setJobId(queued.jobId);};@@ -75,6 +87,14 @@ 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) {+ toast.error('Style changed while the base style rendered — re-run the probe');+ return;+ }const existing = Array.isArray(universe.styleImageRefs) ? universe.styleImageRefs : [];if (existing.includes(filename)) return;const next = [...existing, filename];diff --git a/client/src/components/universe/StyleProbeImage.test.jsx b/client/src/components/universe/StyleProbeImage.test.jsxindex 8a1c051100..b023d3c5e0 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 } from './StyleProbeImage';+import StyleProbeImage, { buildStyleProbePrompt, hasStyleForProbe, probeStyleKey } from './StyleProbeImage';describe('StyleProbeImage — buildStyleProbePrompt', () => {it('uses embrace tokens as positive and avoid tokens as negative', () => {@@ -58,6 +58,22 @@ describe('StyleProbeImage — hasStyleForProbe', () => {});});+describe('StyleProbeImage — probeStyleKey (mid-render drift guard)', () => {+ it('changes when the influences that feed the probe change', () => {+ const a = { influences: { embrace: ['noir'], avoid: [] } };+ const b = { influences: { embrace: ['noir', 'cinematic'], avoid: [] } };+ // The completion handler compares this key against the render-time capture+ // to skip persisting a probe whose style drifted while it rendered.+ expect(probeStyleKey(a)).not.toBe(probeStyleKey(b));+ });++ it('is stable across edits that do not reach the image model (styleNotes)', () => {+ const a = { styleNotes: 'one', influences: { embrace: ['noir'], avoid: [] } };+ const b = { styleNotes: 'two', influences: { embrace: ['noir'], avoid: [] } };+ expect(probeStyleKey(a)).toBe(probeStyleKey(b));+ });+});+describe('StyleProbeImage — styleDirty gating', () => {const universe = { id: 'u1', influences: { embrace: ['noir'], avoid: [] }, styleImageRefs: [] };