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
address review (codex): omit unsaveable simple reaction-time choices, guard Schulte double-tap
Adam Eivy58fa3cd5bfcc
diff --git a/client/src/components/meatspace/post/PostCognitiveDrillRunner.jsx b/client/src/components/meatspace/post/PostCognitiveDrillRunner.jsxindex c1b6530857..4bc29bf4a5 100644--- a/client/src/components/meatspace/post/PostCognitiveDrillRunner.jsx+++ b/client/src/components/meatspace/post/PostCognitiveDrillRunner.jsx@@ -537,6 +537,11 @@ function SchulteTableRunner({ drill, drillIndex, drillCount, onComplete, isTrainconst stepStartRef = useRef(Date.now());const startedAtRef = useRef(Date.now());const flashTimeoutRef = useRef(null);+ // Mirrors `target` synchronously so a double-tap/double-click that fires two+ // handleClick calls before React commits the setTarget update can't both read+ // the same stale `target` and both advance — the second call sees the bumped+ // ref and is treated as a miss instead of a duplicate correct answer.+ const targetRef = useRef(target);useEffect(() => () => clearTimeout(flashTimeoutRef.current), []);@@ -556,23 +561,27 @@ function SchulteTableRunner({ drill, drillIndex, drillCount, onComplete, isTrainfinishRef.current = finish;const handleClick = useCallback((value) => {- if (value !== target) {+ const current = targetRef.current;+ if (value !== current) {setFlash(value);clearTimeout(flashTimeoutRef.current);flashTimeoutRef.current = setTimeout(() => setFlash(null), 200);return;}+ // Advance the ref immediately (synchronously) so a second handleClick call+ // racing in before this render commits sees the bumped value, not `current`.+ targetRef.current = current + 1;questionsRef.current.push({- prompt: `${target}`,- index: target - 1,- answered: target,+ prompt: `${current}`,+ index: current - 1,+ answered: current,correct: true,responseMs: Date.now() - stepStartRef.current,});stepStartRef.current = Date.now();- if (target >= total) finishRef.current();- else setTarget(t => t + 1);- }, [target, total]);+ if (current >= total) finishRef.current();+ else setTarget(current + 1);+ }, [total]);const found = Math.min(target - 1, total);const progressPct = total > 0 ? (found / total) * 100 : 0;diff --git a/server/services/meatspacePostCognitive.js b/server/services/meatspacePostCognitive.jsindex 32df4574a4..40c4bb0c7d 100644--- a/server/services/meatspacePostCognitive.js+++ b/server/services/meatspacePostCognitive.js@@ -274,7 +274,10 @@ export function generateReactionTime(config = {}) {const count = clampInt(config.count, 5, 40, 15);const minDelayMs = clampInt(config.minDelayMs, 300, 5000, 1000);const maxDelayMs = Math.max(minDelayMs, clampInt(config.maxDelayMs, 300, 8000, 3000));- const choices = mode === 'choice' ? clampInt(config.choices, 2, 4, 3) : 1;+ // `choices` is only meaningful (and only schema-valid, min 2) in choice mode —+ // simple mode omits it entirely rather than persisting an out-of-range value+ // like 1, which session submission's `choices: min(2)` schema would reject.+ const choices = mode === 'choice' ? clampInt(config.choices, 2, 4, 3) : undefined;const trials = [];for (let i = 0; i < count; i++) {@@ -283,7 +286,9 @@ export function generateReactionTime(config = {}) {if (mode === 'choice') trial.target = Math.floor(Math.random() * choices);trials.push(trial);}- return { type: 'reaction-time', config: { mode, count, minDelayMs, maxDelayMs, choices }, trials };+ const trialConfig = { mode, count, minDelayMs, maxDelayMs };+ if (choices !== undefined) trialConfig.choices = choices;+ return { type: 'reaction-time', config: trialConfig, trials };}export function generateCognitiveDrill(type, config = {}) {