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 Element Flash: Enter/Return advances to next question after answering
[._.]/ Adam Eivy4fc796080c4d
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 60472f4a70..728a2d73e5 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -122,3 +122,5 @@- **Fix the app-manager Git tab's "Clean N merged" button counting worktree-locked branches, so cleanup deleted zero and toasted "No merged branches to clean up".** `getBranches` marked a local branch `merged: true` from `git branch --merged` alone, but `deleteMergedBranches` (correctly) skips branches checked out in a worktree — `git branch -d` can't delete them. On any install with active CoS-agent/claim worktrees, those merged-but-locked branches inflated the button's count while yielding no deletions. `getBranches` now also returns a `worktree` flag (branch checked out in another worktree), the Git tab's `localMergedCount` counts only `merged && !worktree` so the button reflects what the server will actually delete, and locked branches render a `worktree` badge next to `merged` so the user sees why they linger. Server + client tests cover the count and badge.- **[issue-2654] Lift the CoS actionable-insights fetch into `ChiefOfStaff.fetchData` so the banner refreshes for the whole staleness class.** `ActionableInsightsBanner` owned its own `/cos/actionable-insights` fetch on a 60s `useAutoRefetch` poll, decoupled from the parent's 30s task poll, so its server-derived counts (blocked, approvals, "N health issues") lagged any parent-owned data change until that poll. A prior fix bridged only the TasksTab mutation path via an `insightsRefreshKey` counter; socket-driven task changes, agent spawn/completion, and health checks stayed stale. Insights are now fetched inside `ChiefOfStaff.fetchData`'s `Promise.all` and passed down as an `insights` prop, making the banner presentational (it keeps only dismiss/expand/unblock UI state); its unblock path calls `onRefresh` up instead of owning a `refetch()`. The banner's counts refresh **only** through `fetchData`: the 30s poll, task mutations (TasksTab `onRefresh`), the unblock-up path, and agent spawn/completion (which already call `fetchData`). There is deliberately no on-demand "refresh just the insights" path, because `/cos/actionable-insights` runs a health check that **auto-restarts errored PM2 processes** (`server/services/cosHealthMonitor.js`) and re-emits `cos:health:check` — so refreshing from the `cos:health:check` socket handler would loop, and refreshing from the manual "Run Check" button would fire a second process-restart ~1s after the button's own check. Daemon/manual health changes therefore refresh the banner on the next `fetchData` poll (a 2× improvement over the retired 60s self-poll, and the cadence skew is gone). A failed/transient insights fetch (`null`) preserves the last-good array; a legitimately-empty `[]` clears the banner. Because that same insights call triggers a fresh server health check whose `cos:health:check` socket emit can land before `fetchData`'s own (pre-check) `getCosHealth` read resolves, `fetchData` keeps whichever health check is newer by `lastCheck` (`Date.parse`-normalized), and preserves the last-good health when its own read fails — instead of blanking a fresher socket-delivered result. Retires `insightsRefreshKey`, `refreshTasks`'s signal bump, the banner's `refreshKey` prop, its `didMountRef` skip-mount effect, and its `useAutoRefetch` self-poll. Tests cover the prop-driven render, null/empty gating, the unblock-up path, guards asserting neither the `cos:health:check` socket handler nor the manual button re-fetches insights (no loop, no second restart), and the stale/failed-read health-overwrite guards.++- **Fix Element Flash: pressing Enter/Return after answering now advances to the next question.** In the Element Flash recall test (`ElementsSong.jsx`), the Enter-to-submit handler lived only on the answer `<input>`, which unmounts once the result is shown — so a second Enter did nothing and the user had to click "Next" to continue. `ElementFlashMode` now binds a window `keydown` listener while a result is showing (input unmounted) that advances on Enter/Return, mirroring the "Next" button; the `next()` handler was hoisted above the completion early-return so the effect can reference it without breaking hook order. A new test drives answer → Enter (submit) → Enter (advance) and asserts the question counter increments.diff --git a/client/src/components/meatspace/post/ElementsSong.jsx b/client/src/components/meatspace/post/ElementsSong.jsxindex 3f623e9c2e..5fb43668a7 100644--- a/client/src/components/meatspace/post/ElementsSong.jsx+++ b/client/src/components/meatspace/post/ElementsSong.jsx@@ -1,4 +1,4 @@-import { useState, useEffect, useRef, useMemo } from 'react';+import { useState, useEffect, useRef, useMemo, useCallback } from 'react';import { ChevronLeft, ChevronRight, BookOpen, Zap, Target, Check, X, SkipForward, Loader, Search, Eye, BarChart3, Gauge, Layers, RotateCw } from 'lucide-react';import { submitMemoryPractice, getMemoryMastery, getMemoryItem } from '../../../services/api';import { RapidReaderModal } from '../../RapidReader';@@ -734,6 +734,24 @@ function ElementFlashMode({ item, mastery, onBack, onComplete }) {useEffect(() => { inputRef.current?.focus(); }, [idx]);+ const next = useCallback(() => {+ setIdx(prev => prev + 1);+ setAnswer('');+ setShowResult(null);+ }, []);++ // While a result is showing the answer input is unmounted, so its Enter+ // handler is gone — bind a window listener so a second Enter/Return advances+ // to the next question (mirrors the "Next" button) instead of doing nothing.+ useEffect(() => {+ if (!showResult) return undefined;+ const onKeyDown = (e) => {+ if (e.key === 'Enter') { e.preventDefault(); next(); }+ };+ window.addEventListener('keydown', onKeyDown);+ return () => window.removeEventListener('keydown', onKeyDown);+ }, [showResult, next]);+if (idx >= questions.length) {const correct = results.filter(r => r.correct).length;const pct = Math.round((correct / results.length) * 100);@@ -789,12 +807,6 @@ function ElementFlashMode({ item, mastery, onBack, onComplete }) {setShowResult(isCorrect ? 'correct' : 'wrong');}- function next() {- setIdx(prev => prev + 1);- setAnswer('');- setShowResult(null);- }-return (<div className="space-y-6 max-w-2xl"><div className="flex items-center gap-3">diff --git a/client/src/components/meatspace/post/ElementsSong.test.jsx b/client/src/components/meatspace/post/ElementsSong.test.jsxindex 93d68770ac..b9caacffe0 100644--- a/client/src/components/meatspace/post/ElementsSong.test.jsx+++ b/client/src/components/meatspace/post/ElementsSong.test.jsx@@ -81,3 +81,32 @@ describe('ElementsSong — Flash Cards study mode', () => {expect(payload.results.filter((r) => r.correct)).toHaveLength(1);});});++describe('ElementsSong — Element Flash recall test', () => {+ it('advances to the next question when Enter is pressed after a result is shown', async () => {+ render(<ElementsSong item={item} onBack={() => {}} />);+ await settle();++ fireEvent.click(screen.getByText('Element Flash'));+ await settle();++ // 2 elements → a 2-question quiz.+ expect(screen.getByText('1 / 2')).toBeInTheDocument();++ // Answer + submit with Enter from the input → the result is shown and the+ // input unmounts (replaced by the "Next" button).+ const input = screen.getByRole('textbox');+ fireEvent.change(input, { target: { value: 'x' } });+ fireEvent.keyDown(input, { key: 'Enter' });+ await settle();+ expect(screen.getByText('Next')).toBeInTheDocument();+ expect(screen.queryByRole('textbox')).not.toBeInTheDocument();++ // A second Enter (now caught by the window listener, since the input is+ // gone) must advance to question 2 rather than doing nothing.+ fireEvent.keyDown(window, { key: 'Enter' });+ await settle();+ expect(screen.getByText('2 / 2')).toBeInTheDocument();+ expect(screen.getByRole('textbox')).toBeInTheDocument();+ });+});