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): show true shown sequence for backward digit-span review

Adam Eivyf008ab237641
diff --git a/client/src/components/meatspace/post/DrillQuestionReview.jsx b/client/src/components/meatspace/post/DrillQuestionReview.jsx
index 3f047ee88b..8a7361c5fa 100644
--- a/client/src/components/meatspace/post/DrillQuestionReview.jsx
+++ b/client/src/components/meatspace/post/DrillQuestionReview.jsx
@@ -185,9 +185,26 @@ function NBackReview({ questions, missed }) {
}
// =============================================================================
-// DIGIT SPAN — shown digits vs recalled digits, per round.
+// DIGIT SPAN — shown digits vs recalled digits, per round. `q.expected` is the
+// required RECALL order (reversed for backward drills), NOT the shown
+// sequence — so the "Shown" column derives the true shown digits from
+// `drillData.sequences[q.index]` when available, else by un-reversing
+// `expected` for backward drills. A backward drill gets an extra "Expected"
+// column so the review teaches both what was shown and the required answer.
// =============================================================================
-function DigitSpanReview({ questions, missed }) {
+function DigitSpanReview({ questions, missed, drillData }) {
+ // Direction is per-drill (all rounds share it). Fall back to the prompt
+ // text ("3-digit (backward)") for history records without drillData.
+ const isBackward = drillData?.config?.direction === 'backward'
+ || (!drillData?.config?.direction && questions.some((q) => /backward/.test(q.prompt || '')));
+
+ const shownFor = (q) => {
+ const seq = drillData?.sequences?.[q.index]?.digits;
+ if (Array.isArray(seq)) return seq.join('');
+ if (q.expected == null) return null;
+ return isBackward ? [...String(q.expected)].reverse().join('') : String(q.expected);
+ };
+
return (
<div>
<MissedSummary missed={missed} formatPrompt={(q) => q.prompt} />
@@ -196,6 +213,7 @@ function DigitSpanReview({ questions, missed }) {
<tr className="text-gray-500 text-left border-b border-port-border">
<th className="py-1 pr-2 font-medium">Round</th>
<th className="py-1 pr-2 font-medium">Shown</th>
+ {isBackward && <th className="py-1 pr-2 font-medium">Expected</th>}
<th className="py-1 pr-2 font-medium">Recalled</th>
<th className="py-1 pr-2 font-medium text-center">Result</th>
<th className="py-1 pl-2 font-medium text-right">Time</th>
@@ -207,7 +225,10 @@ function DigitSpanReview({ questions, missed }) {
return (
<tr key={i} className={`border-b border-port-border/30 ${rowTint(q.correct, unanswered)}`}>
<td className="py-1 pr-2 text-gray-400">{q.prompt}</td>
- <td className="py-1 pr-2 font-mono text-white tracking-widest">{q.expected ?? '—'}</td>
+ <td className="py-1 pr-2 font-mono text-white tracking-widest">{shownFor(q) ?? '—'}</td>
+ {isBackward && (
+ <td className="py-1 pr-2 font-mono text-port-success tracking-widest">{q.expected ?? '—'}</td>
+ )}
<td className="py-1 pr-2 font-mono tracking-widest">
{unanswered ? <span className="italic text-gray-500 tracking-normal">skipped</span> : q.answered}
</td>
@@ -356,8 +377,9 @@ function TimingReview({ questions, missed, type }) {
* pure-speed drills (schulte-table/reaction-time) each get a type-appropriate
* view because their `questions[]` capture different things per trial.
*
- * `drillData` is the generated drill (only used by Stroop, to look up each
- * color's swatch hex) — optional, and safely ignored by every other type.
+ * `drillData` is the generated drill — used by Stroop (color swatch hex
+ * lookup) and digit-span (true shown-digit sequence + direction). Optional,
+ * and safely ignored by every other type.
*/
export default function DrillQuestionReview({ type, questions, drillData }) {
const list = questions || [];
@@ -369,7 +391,7 @@ export default function DrillQuestionReview({ type, questions, drillData }) {
case 'n-back':
return <NBackReview questions={list} missed={missed} />;
case 'digit-span':
- return <DigitSpanReview questions={list} missed={missed} />;
+ return <DigitSpanReview questions={list} missed={missed} drillData={drillData} />;
case 'stroop':
return <StroopReview questions={list} missed={missed} drillData={drillData} />;
case 'schulte-table':
diff --git a/client/src/components/meatspace/post/DrillQuestionReview.test.jsx b/client/src/components/meatspace/post/DrillQuestionReview.test.jsx
index 3bcc56e129..05fe4f8457 100644
--- a/client/src/components/meatspace/post/DrillQuestionReview.test.jsx
+++ b/client/src/components/meatspace/post/DrillQuestionReview.test.jsx
@@ -121,6 +121,33 @@ describe('DrillQuestionReview — digit-span', () => {
expect(screen.getByText('skipped')).toBeInTheDocument();
expect(screen.getByText('123')).toBeInTheDocument();
});
+
+ it('backward drills show the TRUE shown sequence plus the reversed expected recall (regression: expected is the recall order, not what was shown)', () => {
+ const questions = [
+ { prompt: '3-digit (backward)', index: 0, expected: '321', answered: '123', correct: false, responseMs: 1100, length: 3 },
+ ];
+ const drillData = {
+ config: { direction: 'backward' },
+ sequences: [{ digits: [1, 2, 3], length: 3 }],
+ };
+ render(<DrillQuestionReview type="digit-span" questions={questions} drillData={drillData} />);
+ expect(screen.getByText('Shown')).toBeInTheDocument();
+ expect(screen.getByText('Expected')).toBeInTheDocument();
+ // Shown column carries the digits as displayed (123), Expected the
+ // required reversed recall (321) — previously "Shown" wrongly showed 321.
+ expect(screen.getAllByText('123').length).toBeGreaterThan(0); // shown + (wrong) recalled
+ expect(screen.getByText('321')).toBeInTheDocument();
+ });
+
+ it('backward drills without drillData still derive the shown sequence by un-reversing expected', () => {
+ const questions = [
+ { prompt: '3-digit (backward)', index: 0, expected: '321', answered: null, correct: false, responseMs: 0, length: 3 },
+ ];
+ render(<DrillQuestionReview type="digit-span" questions={questions} />);
+ // Direction inferred from the prompt; shown = expected un-reversed.
+ expect(screen.getByText('123')).toBeInTheDocument(); // shown
+ expect(screen.getByText('321')).toBeInTheDocument(); // expected recall
+ });
});
describe('DrillQuestionReview — stroop', () => {