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: report mic processing on every pitch-analysis surface, and clear it per capture (#5303)
[._.]/ Adam Eivy96312bc61275
diff --git a/client/src/components/songs/PitchTuner.jsx b/client/src/components/songs/PitchTuner.jsxindex 9de71de7b5..9b64bc0eb5 100644--- a/client/src/components/songs/PitchTuner.jsx+++ b/client/src/components/songs/PitchTuner.jsx@@ -77,10 +77,13 @@ export default function PitchTuner({ stream = null, a4 = 440 }) {}, []);// Attach the tuner to a stream. Returns nothing; teardownTracker() detaches.- const attach = useCallback((src) => {+ // `processing` is the read-back `openAnalysisMic` already did for a mic we+ // opened ourselves; the attached-stream path has no such report and reads the+ // track directly.+ const attach = useCallback((src, processing) => {teardownTracker();if (!src) return;- setMicProcessing(readAppliedProcessing(src));+ setMicProcessing(processing ?? readAppliedProcessing(src));const graph = createStreamAnalyser(src);analyserRef.current = graph;trackerRef.current = createPitchTracker(graph.analyser, {@@ -148,11 +151,11 @@ export default function PitchTuner({ stream = null, a4 = 440 }) {return null;});if (!opened) return;- const { stream: src } = opened;+ const { stream: src, processing } = opened;if (!mountedRef.current) { src.getTracks().forEach((t) => t.stop()); return; }ownStreamRef.current = src;setStandaloneOn(true);- attach(src);+ attach(src, processing);}, [attach, standaloneOn]);const active = Boolean(stream) || standaloneOn;diff --git a/client/src/components/songs/SingToScore.jsx b/client/src/components/songs/SingToScore.jsxindex dd11305bc0..40dd2368c0 100644--- a/client/src/components/songs/SingToScore.jsx+++ b/client/src/components/songs/SingToScore.jsx@@ -15,12 +15,15 @@import { useMemo } from 'react';import { Mic, Square, Plus, Replace, X } from 'lucide-react';+import MicProcessingHint from './MicProcessingHint.jsx';import ScoreSheet from './ScoreSheet.jsx';import useSingToScore, { SING_IDLE, SING_COUNT_IN, SING_RECORDING } from '../../hooks/useSingToScore.js';import { parseScore } from '../../lib/scoreNotation.js';export default function SingToScore({ value = '', tempo = null, musicKey = 'C', hasSelection = false, onInsert }) {- const { phase, beat, result, error, start, stop, reset } = useSingToScore({ tempo, score: value, musicKey });+ const {+ phase, beat, result, error, micProcessing, start, stop, reset,+ } = useSingToScore({ tempo, score: value, musicKey });// The result is just the measure body; render it under the score's own header// (clef/key/time/tempo) so the preview staff matches what the inserted notes@@ -87,6 +90,7 @@ export default function SingToScore({ value = '', tempo = null, musicKey = 'C',</p>{error && <p className="mt-2 text-xs text-port-error">{error}</p>}+ <MicProcessingHint processing={micProcessing} />{/* Transcribed result — live preview + insert controls. */}{result != null && !recording && (diff --git a/client/src/components/songs/SongTraining.jsx b/client/src/components/songs/SongTraining.jsxindex b3037505c8..9f7b9964ba 100644--- a/client/src/components/songs/SongTraining.jsx+++ b/client/src/components/songs/SongTraining.jsx@@ -35,6 +35,7 @@ import {} from '../../lib/songProgress.js';import useSongTraining from '../../hooks/useSongTraining.js';import useMounted from '../../hooks/useMounted.js';+import MicProcessingHint from './MicProcessingHint.jsx';import ScoreSheet from './ScoreSheet.jsx';// Accuracy % → readout tone. Mirrors the color-match summary coloring.@@ -73,6 +74,9 @@ export default function SongTraining({// deliberate practice action, so it owns its own getUserMedia (separate from// the take recorder), and nothing it captures is persisted as audio.const [stream, setStream] = useState(null);+ // What the browser actually applied to the training mic — grading reads the+ // same processed signal the tuner would, so it warns the same way.+ const [micProcessing, setMicProcessing] = useState(null);const streamRef = useRef(null);const mountedRef = useMounted();@@ -94,6 +98,7 @@ export default function SongTraining({streamRef.current = null;}setStream(null);+ setMicProcessing(null);}, []);// Stop a session: end the training loop, then close the mic.@@ -109,10 +114,11 @@ export default function SongTraining({return null;});if (!opened) return;- const { stream: src } = opened;+ const { stream: src, processing } = opened;if (!mountedRef.current) { src.getTracks().forEach((t) => t.stop()); return; }streamRef.current = src;setStream(src);+ setMicProcessing(processing);}, [running, stream, mountedRef]);// Once the mic stream lands (after Start), arm the training run for the scope.@@ -209,6 +215,8 @@ export default function SongTraining({</div></div>+ <MicProcessingHint processing={micProcessing} />+{/* Scope picker — whole song or a single section to drill. */}<div><label htmlFor="training-scope" className="block text-xs text-gray-400 mb-1">Practice</label>diff --git a/client/src/components/songs/SongTraining.test.jsx b/client/src/components/songs/SongTraining.test.jsxindex 8a476c30c3..a347db3111 100644--- a/client/src/components/songs/SongTraining.test.jsx+++ b/client/src/components/songs/SongTraining.test.jsx@@ -99,4 +99,17 @@ describe('SongTraining', () => {expect(trackStop).toHaveBeenCalled();expect(screen.getByRole('button', { name: /start/i })).toBeTruthy();});++ it('warns when the browser kept processing on for the training mic', async () => {+ const getUserMedia = vi.fn().mockResolvedValue({+ getTracks: () => [{ stop: vi.fn(), getSettings: () => ({ noiseSuppression: true }) }],+ });+ Object.defineProperty(global.navigator, "mediaDevices", {+ value: { getUserMedia }, configurable: true,+ });+ render(<SongTraining score={SCORE} />);+ fireEvent.click(screen.getByRole("button", { name: /start/i }));+ await act(async () => {});+ expect(screen.getByText(/Browser audio processing is on \(noise suppression\)/)).toBeTruthy();+ });});diff --git a/client/src/hooks/useSingToScore.js b/client/src/hooks/useSingToScore.jsindex b72606ebad..a67d97ce08 100644--- a/client/src/hooks/useSingToScore.js+++ b/client/src/hooks/useSingToScore.js@@ -44,7 +44,8 @@ const nowMs = () => (typeof performance !== 'undefined' ? performance.now() : Da* @param {string} [opts.musicKey] — key name for enharmonic spelling (e.g. "Eb").* @returns {{* phase: string, beat: number|null, result: string|null,- * error: string|null, start: () => Promise<void>, stop: () => void,+ * error: string|null, micProcessing: object|null,+ * start: () => Promise<void>, stop: () => void,* reset: () => void,* }}*/@@ -53,6 +54,9 @@ export default function useSingToScore({ tempo, score = '', musicKey = 'C' } = {const [beat, setBeat] = useState(null);const [result, setResult] = useState(null);const [error, setError] = useState(null);+ // What the browser actually applied to the capture stream — a stage left on+ // despite ANALYSIS_AUDIO_CONSTRAINTS is why a transcription can come back off.+ const [micProcessing, setMicProcessing] = useState(null);const mountedRef = useMounted();const streamRef = useRef(null); // mic stream we own + must stop@@ -127,6 +131,8 @@ export default function useSingToScore({ tempo, score = '', musicKey = 'C' } = {if (requestGeneration === null) return;setError(null);setResult(null);+ // Drop the previous capture's report up front — see useSingToVerify.+ setMicProcessing(null);trackRef.current = [];// Resolved (and null-checked) BEFORE the claim: on an insecure origin@@ -153,7 +159,7 @@ export default function useSingToScore({ tempo, score = '', musicKey = 'C' } = {return null;});if (!opened) return;- const src = opened.stream;+ const { stream: src, processing } = opened;if (!mountedRef.current || !isCurrent(requestGeneration)) {src.getTracks().forEach((track) => track.stop());if (isCurrent(requestGeneration)) releaseSession();@@ -161,6 +167,7 @@ export default function useSingToScore({ tempo, score = '', musicKey = 'C' } = {}settleStart(requestGeneration);streamRef.current = src;+ setMicProcessing(processing);const graph = createStreamAnalyser(src);analyserRef.current = graph;@@ -216,6 +223,7 @@ export default function useSingToScore({ tempo, score = '', musicKey = 'C' } = {const reset = useCallback(() => {setResult(null);setError(null);+ setMicProcessing(null);}, []);// Belt-and-suspenders: cancel everything on unmount so a navigation-away@@ -226,5 +234,5 @@ export default function useSingToScore({ tempo, score = '', musicKey = 'C' } = {cancelRef.current = cancel;useEffect(() => () => cancelRef.current(), []);- return { phase, beat, result, error, start, stop, reset };+ return { phase, beat, result, error, micProcessing, start, stop, reset };}diff --git a/client/src/hooks/useSingToVerify.js b/client/src/hooks/useSingToVerify.jsindex 2e6e792b68..997bfd95ff 100644--- a/client/src/hooks/useSingToVerify.js+++ b/client/src/hooks/useSingToVerify.js@@ -94,6 +94,9 @@ export default function useSingToVerify({ score: scoreText = '', tempo } = {}) {if (requestGeneration === null) return;setError(null);setRows([]);+ // Drop the previous capture's report up front: a denied or aborted request+ // below must not leave the old warning standing next to a new attempt.+ setMicProcessing(null);trackRef.current = [];startBarRef.current = startBar;@@ -177,6 +180,7 @@ export default function useSingToVerify({ score: scoreText = '', tempo } = {}) {const reset = useCallback(() => {setRows([]);setError(null);+ setMicProcessing(null);}, []);const toggleAccept = useCallback((index) => {diff --git a/client/src/hooks/useSingToVerify.test.js b/client/src/hooks/useSingToVerify.test.jsindex eb66f296d1..81f1f83158 100644--- a/client/src/hooks/useSingToVerify.test.js+++ b/client/src/hooks/useSingToVerify.test.js@@ -129,6 +129,24 @@ describe('useSingToVerify', () => {autoGainControl: null,});});+ it('drops the processing report when the comparison is reset', async () => {+ // The warning describes ONE capture. Left standing after a reset (or a+ // score edit, which resets), it would blame the next attempt for drift+ // that belonged to the last one.+ navigator.mediaDevices.getUserMedia = vi.fn(async () => ({+ getTracks: () => [{ stop: trackStop, getSettings: () => ({ autoGainControl: true }) }],+ }));+ const { result } = renderHook(() => useSingToVerify({+ tempo: 120,+ score: 'time: 4/4\n| C4q |',+ }));++ await act(async () => { await result.current.start(1); });+ expect(result.current.micProcessing.autoGainControl).toBe(true);++ act(() => result.current.reset());+ expect(result.current.micProcessing).toBeNull();+ });it('tears down mic stream, analyser, tracker, and metronome on unmount', async () => {const { result, unmount } = renderHook(() => useSingToVerify({tempo: 120,