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

fix: guard unavailable sing-to-verify microphone (#3239)

[._.]/ Adam Eivy0d53e439464e
diff --git a/client/src/hooks/useSingToVerify.js b/client/src/hooks/useSingToVerify.js
index f99b01f804..a8e6e12d77 100644
--- a/client/src/hooks/useSingToVerify.js
+++ b/client/src/hooks/useSingToVerify.js
@@ -84,7 +84,13 @@ export default function useSingToVerify({ score: scoreText = '', tempo } = {}) {
trackRef.current = [];
startBarRef.current = startBar;
- const stream = await navigator.mediaDevices.getUserMedia({ audio: true }).catch((err) => {
+ const getUserMedia = navigator.mediaDevices?.getUserMedia?.bind(navigator.mediaDevices);
+ if (!getUserMedia) {
+ startPendingRef.current = false;
+ if (mountedRef.current) setError('Microphone access requires a secure browser connection');
+ return;
+ }
+ const stream = await getUserMedia({ audio: true }).catch((err) => {
if (requestGeneration === requestGenerationRef.current) {
startPendingRef.current = false;
if (mountedRef.current) setError(err?.message || 'Microphone access denied');
diff --git a/client/src/hooks/useSingToVerify.test.js b/client/src/hooks/useSingToVerify.test.js
index 827f784a9f..4f336ae037 100644
--- a/client/src/hooks/useSingToVerify.test.js
+++ b/client/src/hooks/useSingToVerify.test.js
@@ -120,6 +120,19 @@ describe('useSingToVerify', () => {
expect(result.current.phase).toBe(VERIFY_COUNT_IN);
});
+ it('reports unavailable microphone APIs without getting stuck', async () => {
+ global.navigator.mediaDevices = undefined;
+ const { result } = renderHook(() => useSingToVerify({
+ tempo: 120,
+ score: 'time: 4/4\n| C4q |',
+ }));
+
+ await act(async () => { await result.current.start(1); });
+ expect(result.current.error).toMatch(/secure browser connection/i);
+ await act(async () => { await result.current.start(1); });
+ expect(result.current.error).toMatch(/secure browser connection/i);
+ });
+
it('cancels an active capture without aligning stale rows', async () => {
const { result } = renderHook(() => useSingToVerify({
tempo: 120,