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 (self+codex): pin the keying-highlight fix with tests, tighten showMs bounds

Adam Eivy44475427946c
diff --git a/client/src/components/meatspace/post/MorseTrainer.jsx b/client/src/components/meatspace/post/MorseTrainer.jsx
index 8928b63e80..4123866f61 100644
--- a/client/src/components/meatspace/post/MorseTrainer.jsx
+++ b/client/src/components/meatspace/post/MorseTrainer.jsx
@@ -535,7 +535,7 @@ function ReferenceWidget({ keying, mode }) {
);
}
-function isNodeOnPath(node, currentPath) {
+export function isNodeOnPath(node, currentPath) {
// Root's placeholder char ('·') is truthy but isn't a real decoded
// character — gate on `currentPath.length > 0` too so an idle/empty path
// (reference-only view, or before the first key press) never lights up
diff --git a/client/src/components/meatspace/post/MorseTrainer.test.jsx b/client/src/components/meatspace/post/MorseTrainer.test.jsx
index 5c835ace75..8f6fc817e7 100644
--- a/client/src/components/meatspace/post/MorseTrainer.test.jsx
+++ b/client/src/components/meatspace/post/MorseTrainer.test.jsx
@@ -1,7 +1,7 @@
import { describe, it, expect, vi } from 'vitest';
import { render, screen, fireEvent } from '@testing-library/react';
import { MemoryRouter, Routes, Route, useLocation } from 'react-router-dom';
-import MorseTrainer, { MODES, MORSE_MODE_IDS, MORSE_TABLE } from './MorseTrainer';
+import MorseTrainer, { MODES, MORSE_MODE_IDS, MORSE_TABLE, isNodeOnPath } from './MorseTrainer';
// Surfaces the live URL (path + search) so tests can assert the reference tab
// is encoded in the query string — the "URL is the source of truth" contract.
@@ -96,3 +96,31 @@ describe('MorseTrainer Tree reference view', () => {
expect(rootLeft).toBeLessThan(totalWidth * 0.7);
});
});
+
+describe('isNodeOnPath (live keying highlight gate)', () => {
+ // Root's placeholder char is '·' (truthy) and its code is '' — an idle/empty
+ // currentPath must not make it read as "matched", or the reference tree lights
+ // up the root before the user has keyed anything.
+ const root = { char: '·', code: '' };
+ const e = { char: 'E', code: '.' };
+ const i = { char: 'I', code: '..' };
+ const t = { char: 'T', code: '-' };
+
+ it('does not match or highlight the root when currentPath is empty', () => {
+ expect(isNodeOnPath(root, '')).toEqual({ matched: false, onPath: false });
+ });
+
+ it('matches a node whose code equals the current keyed path', () => {
+ expect(isNodeOnPath(i, '..')).toEqual({ matched: true, onPath: false });
+ });
+
+ it('marks an ancestor of the current path as onPath but not matched', () => {
+ // 'e' ('.') is a prefix of the in-progress path '..' but is not the
+ // fully-keyed node itself.
+ expect(isNodeOnPath(e, '..')).toEqual({ matched: false, onPath: true });
+ });
+
+ it('does not flag a node unrelated to the current path', () => {
+ expect(isNodeOnPath(t, '..')).toEqual({ matched: false, onPath: false });
+ });
+});
diff --git a/server/lib/postValidation.js b/server/lib/postValidation.js
index 32c7e5c25b..2d44771d21 100644
--- a/server/lib/postValidation.js
+++ b/server/lib/postValidation.js
@@ -64,14 +64,17 @@ const drillTypeConfigSchema = z.object({
tolerancePct: z.number().min(1).max(50).optional(),
// --- Cognitive drill knobs (n-back / digit-span / stroop) ---
// Bounds match the generator clamps in meatspacePostCognitive.js so the UI /
- // API can't accept a value the generator will silently narrow.
+ // API can't accept a value the generator will silently narrow. Exception:
+ // `length`'s effective floor is `n + 5` (dynamic, up to 8) inside the
+ // generator — Zod can't express a cross-field minimum here, so this schema
+ // keeps a conservative fixed floor of 6 and lets the generator clamp up.
n: z.number().int().min(1).max(3).optional(),
length: z.number().int().min(6).max(60).optional(),
stimulusMs: z.number().int().min(1000).max(5000).optional(),
direction: z.enum(['forward', 'backward']).optional(),
startLength: z.number().int().min(3).max(9).optional(),
maxLength: z.number().int().min(3).max(12).optional(),
- showMs: z.number().int().min(200).max(5000).optional()
+ showMs: z.number().int().min(400).max(4000).optional()
});
// Task result within a session