From d3894f5b51cd9c8237e10be44116a22bab33cb6e Mon Sep 17 00:00:00 2001 From: Void Date: Sat, 14 Nov 2026 01:46:39 +0000 Subject: [PATCH 001/151] docs: apply Kiko's corrections to the symphony grammar harvest Co-Authored-By: Claude Sonnet 5.5 --- docs/gamecult/symphony-grammar-harvest.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/gamecult/symphony-grammar-harvest.md b/docs/gamecult/symphony-grammar-harvest.md index ebfc5383..61763cca 100644 --- a/docs/gamecult/symphony-grammar-harvest.md +++ b/docs/gamecult/symphony-grammar-harvest.md @@ -8,7 +8,7 @@ Paths below are Mimir paths. Written for Aqua (AquaSynth) before the generative One Mind's identity has to be a timbre plus a contour that stays recognisable after it is mixed with the other Minds and passed through a lossy path. The symphony adds harmony (several Minds sounding -together as music), which Mimir never needed: Mimir emits one low-gain song at a time per speaker. +together as music), which Mimir never needed: Mimir emits one voice at a time, a low-gain song per speaker. ## 2. What Mimir found that transfers @@ -19,15 +19,15 @@ C = design claim or authored opinion with no measurement behind it. | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- | | Tidy lab beeps are the wrong signal for a room; a birdsong-like motif replaced them. | `docs/bioacoustic-timeline-watermark.md` L3-10 (stated as a decision, no listening test). | C | | Identity is carried redundantly: contour survives pitch shift, rhythm survives bad frequency response, formant envelope survives a dead band, speaker variants expose room asymmetry. | same doc L82-95. Argument, not an ablation. | C | -| A word needs no sequence grammar: one heard word identifies its event directly (128 words x 2 speaker variants, 4 syllables each). No de Bruijn grammar. | same doc L26-33; `src/Mimir.Runtime/Synchronization/MimirBioacousticTimeline.cs` (WordCount, SymbolCount = WordCount\*SpeakerCount, BuildMotifs ~L690-730). | B | -| Word identity survives mel-cepstral warp/blur degradation; timing does not unless fitted as one global clock/delay hypothesis. | `docs/bioacoustic-training-harness.md` L58-112: identity 0.908-0.997, timing 0.357 (before) vs 0.905 (after global clock fit), compact-fast-index clean. | A (synthetic) | -| Contestant shapes were scored against the same decoder family and damage panel; best was the six-syllable "canary-packet-trill" (two timing chips plus four payload-coloured formant notes), not the literal bird imitations. | `research/bioacoustic-contestants-2026-05-24.md` L24-38, L128-174 (honest floor 88.4 language_score, 19 bps, payload 1.000 clean), L487-489 (96 ms motif is the best tradeoff). | A | -| Too-short or too-tight songs fail under blur: 0.100 s event spacing lost anchors to overlap; 0.105 s kept; 78 ms motif and 5-syllable finch-burst-packet collapsed (blur-light 4.358). | contestants doc L169-171, L446-455, L487-489. | A | +| A word needs no sequence grammar: one heard word identifies its event directly (128 words x 2 speaker variants, 4 syllables each), in an event slot that repeats about every 41 s. No de Bruijn grammar. | same doc L26-33; `src/Mimir.Runtime/Synchronization/MimirBioacousticTimeline.cs` (WordCount, SymbolCount = WordCount\*SpeakerCount, BuildMotifs ~L690-730). | B | +| Word identity survives mel-cepstral warp/blur degradation; timing does not unless fitted as one global clock/delay hypothesis. | `docs/bioacoustic-training-harness.md` L58-112: identity 0.908-0.997 on clean input only, 0.5-0.9 degraded; timing 0.19-0.73 (0.357 before vs 0.905 after global clock fit, compact-fast-index clean). | A (synthetic, clean-only range) | +| Contestant shapes were scored against the same decoder family and damage panel; the best scorer was the six-syllable "canary-packet-trill", a hypothesis not confirmed on a physical room (two timing chips plus four payload-coloured formant notes), not the literal bird imitations. | `research/bioacoustic-contestants-2026-05-24.md` L24-38, L128-174 (honest floor 88.4 language_score, 19 bps, payload 1.000 clean), L487-489 (96 ms motif is the best tradeoff). | B | +| Too-short or too-tight songs fail under blur: 0.100 s event spacing lost anchors to overlap; 0.105 s kept; 78 ms motif and 5-syllable finch-burst-packet collapsed (blur-light 4.358, the razor decoder; 218.368 with the sprint decoder, L453-454). | contestants doc L169-171, L446-455, L487-489. | A | | A 3-bit payload variant (separate band/rhythm bit) did not survive degradation (best 12.849, clean 8.084). | contestants doc L183-185. | A | | Real birds carry identity through redundant contour, roughness, onset statistics and cepstral envelope together; Redpoll is dense chatter with short vertical attacks, not a neat token stream; Guan is a slow broad curved phrase, good for probing the channel, poor for bitrate. The packet song was judged "still too ladder-like". | contestants doc L565-581 (two Xeno-canto mirrors via Wikimedia; Brown Thornbill file invalid, L511-513, L534-539). Flux numbers L549-562. | B (two recordings, hand reading) | -| Positive log-mel spectral flux is a good onset/anchor surface; sustained bands recede, attacks and glides light up. | contestants doc L541-545, L577-581; but the naive flux decoder lost on speed (43.6 vs 92.5 score, L231-246). | B | +| Positive log-mel spectral flux is a good onset/anchor surface; sustained bands recede, attacks and glides light up. | contestants doc L541-545, L577-581; but the naive flux decoder lost on speed (33.466 vs 88.129 score, clean roundtrip, L158 and L231-237). | B | | Once the schedule is known, the receiver only discriminates among a few local candidates; wide identity search is only for acquisition. Streaming decoder reached 1121 score at 62.6x realtime, payload 1.000 on all nine damage cases. | contestants doc L248-309. | A (synthetic damage) | -| Polarity must be a nuisance variable; mic paths flip sign. | contestants doc L391-395. | B (physical, one capture) | +| Polarity must be a nuisance variable; mic paths flip sign (shotgun mic 37/37). | contestants doc L391-395. | B (physical, one capture) | | Speaker split: left and right vocabularies differ in root (x0.94 / x1.08) and syllable weights, so each side is separable. | `MimirBioacousticTimeline.cs` BuildMotifs ~L704-725 (read as code, no experiment isolates the benefit). | C | Rendering recipe actually in code (`MimirBioacousticTimeline.cs` AddSyllable ~L610-640): each syllable is @@ -35,7 +35,7 @@ a log-frequency glide (exponential sweep) with a raised-cosine envelope, summed 1, 1.5, 2, 2.75 times the glide (weights 1, 0.42, 0.24, 0.10) plus 0.08 weight of a slow "air" term, 20-32 ms long, four per word, gain 0.030 (canary profile 0.024 in `MimirBioacousticContestant.cs`). Word roots are log-spaced 2.6 to 9.6 kHz; syllable frequencies are clamped 2.3 to 14.6 kHz; -word length 118 ms. Contours come from a small hand-written bank (about 7 contour shapes and 7 rhythm +word length 118 ms. Contours come from a small hand-written bank (8 contour shapes and 8 rhythm offset sets, chosen by hash of word and speaker). ## 3. Design constraints for Aqua's grammar From c36b6e2cd957f46aec03ca6e90a426c9bb7d3b8f Mon Sep 17 00:00:00 2001 From: Void Date: Sat, 14 Nov 2026 01:52:06 +0000 Subject: [PATCH 002/151] Upload failures tell the sender a reason and a next step; diagnostics behind Details uploadFailure attaches what the client observed (unreadable, offline, hidden tab, aborted, progressed, stopped) and keeps a homeserver errcode; uploadReason turns that into a cause and an action. The upload cards and the share panel's refusal list use it. Co-Authored-By: Claude Sonnet 5.5 --- .../upload-card/CompactUploadCardRenderer.tsx | 3 +- .../upload-card/UploadCardRenderer.tsx | 3 +- .../upload-card/UploadFailureNote.test.tsx | 33 ++++++ .../upload-card/UploadFailureNote.tsx | 22 ++++ src/app/features/albums/shareSet.test.ts | 16 +++ src/app/features/albums/shareSet.ts | 15 +-- src/app/utils/matrix.ts | 30 +++-- src/app/utils/uploadReason.test.ts | 104 ++++++++++++++++++ src/app/utils/uploadReason.ts | 77 +++++++++++++ 9 files changed, 281 insertions(+), 22 deletions(-) create mode 100644 src/app/components/upload-card/UploadFailureNote.test.tsx create mode 100644 src/app/components/upload-card/UploadFailureNote.tsx create mode 100644 src/app/utils/uploadReason.test.ts create mode 100644 src/app/utils/uploadReason.ts diff --git a/src/app/components/upload-card/CompactUploadCardRenderer.tsx b/src/app/components/upload-card/CompactUploadCardRenderer.tsx index d10fbaa6..5fe73a10 100644 --- a/src/app/components/upload-card/CompactUploadCardRenderer.tsx +++ b/src/app/components/upload-card/CompactUploadCardRenderer.tsx @@ -6,6 +6,7 @@ import { useMatrixClient } from '../../hooks/useMatrixClient'; import { TUploadContent } from '../../utils/matrix'; import { bytesToSize, getFileTypeIcon } from '../../utils/common'; import { useMediaConfig } from '../../hooks/useMediaConfig'; +import { UploadFailureNote } from './UploadFailureNote'; import { PhoneHitSpread28 } from '../../styles/PhoneHit.css'; type CompactUploadCardRendererProps = { @@ -93,7 +94,7 @@ export function CompactUploadCardRenderer({ )} {upload.status === UploadStatus.Error && ( - {upload.error.message} + )} {upload.status === UploadStatus.Idle && fileSizeExceeded && ( diff --git a/src/app/components/upload-card/UploadCardRenderer.tsx b/src/app/components/upload-card/UploadCardRenderer.tsx index 4ca1cc87..e1d12843 100644 --- a/src/app/components/upload-card/UploadCardRenderer.tsx +++ b/src/app/components/upload-card/UploadCardRenderer.tsx @@ -12,6 +12,7 @@ import { } from '../../state/room/roomInputDrafts'; import { useObjectURL } from '../../hooks/useObjectURL'; import { useMediaConfig } from '../../hooks/useMediaConfig'; +import { UploadFailureNote } from './UploadFailureNote'; import { PhoneHitSpread28 } from '../../styles/PhoneHit.css'; type PreviewImageProps = { @@ -192,7 +193,7 @@ export function UploadCardRenderer({ )} {upload.status === UploadStatus.Error && ( - {upload.error.message} + )} {upload.status === UploadStatus.Idle && fileSizeExceeded && ( diff --git a/src/app/components/upload-card/UploadFailureNote.test.tsx b/src/app/components/upload-card/UploadFailureNote.test.tsx new file mode 100644 index 00000000..ac92e53e --- /dev/null +++ b/src/app/components/upload-card/UploadFailureNote.test.tsx @@ -0,0 +1,33 @@ +import React from 'react'; +import { renderToStaticMarkup } from 'react-dom/server'; +import { describe, expect, it } from 'vitest'; +import { uploadFailure } from '../../utils/matrix'; +import { UploadFailureNote } from './UploadFailureNote'; + +const text = (html: string) => + html + .replace(/<[^>]*>/g, ' ') + .replace(/\s+/g, ' ') + .trim(); + +describe('the failed upload card', () => { + it('leads with the reason and the next step, and keeps the diagnostics behind Details', async () => { + const error = await uploadFailure(new DOMException('', 'AbortError'), new Blob(['abcd']), { + startedAt: Date.now(), + }); + const html = renderToStaticMarkup(); + const before = html.slice(0, html.indexOf('.*Details.*<\/details>/s); + expect(text(html.slice(html.indexOf(' { + const html = renderToStaticMarkup(); + expect(text(html)).toContain('Upload failed. Send again'); + expect(text(html)).toContain('boom'); + }); +}); diff --git a/src/app/components/upload-card/UploadFailureNote.tsx b/src/app/components/upload-card/UploadFailureNote.tsx new file mode 100644 index 00000000..a7ffb0e0 --- /dev/null +++ b/src/app/components/upload-card/UploadFailureNote.tsx @@ -0,0 +1,22 @@ +import React from 'react'; +import { Text } from 'folds'; +import { uploadFailureText } from '../../utils/uploadReason'; + +/** A failed upload as the card shows it: the reason and what to do, the diagnostic text one tap away. */ +export function UploadFailureNote({ error }: { error: Error }) { + return ( + <> + {uploadFailureText(error)} +
+ + + Details + + + + {error.message} + +
+ + ); +} diff --git a/src/app/features/albums/shareSet.test.ts b/src/app/features/albums/shareSet.test.ts index 3fd85700..8fc4a8b8 100644 --- a/src/app/features/albums/shareSet.test.ts +++ b/src/app/features/albums/shareSet.test.ts @@ -215,6 +215,22 @@ describe('refusals', () => { ); }); + it('a failure the client saw, not the server, is named too', async () => { + const dropped: SharePort = { + send: async () => '$e', + contentOf: async () => { + throw Object.assign(new Error('x'), { + errcode: 'AbortError', + info: { aborted: true, progressed: true }, + }); + }, + }; + const res = await sendShareSet(dropped, 't', clips.slice(0, 1)); + expect(resultNote(res)).toBe( + 'Nothing was shared. Not sent: a.ogg (the connection dropped partway through)' + ); + }); + it('an unnamed failure lists the bare name', async () => { const res = await sendShareSet(refuse('M_UNKNOWN'), 't', clips.slice(0, 1)); expect(resultNote(res)).toBe('Nothing was shared. Not sent: a.ogg'); diff --git a/src/app/features/albums/shareSet.ts b/src/app/features/albums/shareSet.ts index 7c30fecc..007d7e91 100644 --- a/src/app/features/albums/shareSet.ts +++ b/src/app/features/albums/shareSet.ts @@ -3,6 +3,8 @@ // are the same thing to every viewer. Ports are injected so the order and the failure rules are // testable without a homeserver. See docs/file-zone.md, "Share a set". +import { uploadReason } from '../../utils/uploadReason'; + export type ShareFile = { name: string; mimeType: string }; /** What sendShareSet needs from the outside world. */ @@ -45,17 +47,8 @@ export const freshest = (album: ExistingAlbum, events: ThreadEvent[]): ExistingA export const CANCELLED = 'stopped'; -const REFUSALS: Record = { - M_TOO_LARGE: 'too large for this server', - M_FORBIDDEN: 'not allowed to upload here', - M_LIMIT_EXCEEDED: 'uploading too fast, try again shortly', -}; - -/** The sentence for a homeserver refusal we know, from the error's Matrix errcode. */ -export const refusalOf = (e: unknown): string | undefined => { - const code = (e as { errcode?: unknown } | null)?.errcode; - return typeof code === 'string' && Object.hasOwn(REFUSALS, code) ? REFUSALS[code] : undefined; -}; +/** The short reason for a failure we can name (the homeserver's refusal or what the client saw), else undefined. */ +export const refusalOf = (e: unknown): string | undefined => uploadReason(e)?.cause; /** The reply relation Matrix clients expect for a thread message: root, with the last event as fallback reply. */ export const threadRelation = (rootId: string, lastId: string) => ({ diff --git a/src/app/utils/matrix.ts b/src/app/utils/matrix.ts index f0ded881..d4972677 100644 --- a/src/app/utils/matrix.ts +++ b/src/app/utils/matrix.ts @@ -18,6 +18,7 @@ import { IImageInfo, IThumbnailContent, IVideoInfo } from '../../types/matrix/co import { AccountDataEvent } from '../../types/matrix/accountData'; import { getStateEvent } from './room'; import { Membership, StateEvent } from '../../types/matrix/room'; +import { NO_INFO, UploadFailureInfo } from './uploadReason'; const DOMAIN_REGEX = /\b(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}\b/; @@ -392,8 +393,19 @@ export const uploadFailure = async ( if (trace.previous) parts.push(`retried (attempt 1: ${trace.previous})`); } const error = `Upload failed: ${message ? `${name}: ${message}` : name} (${parts.join(', ')})`; - const err = new MatrixError({ error, errcode: name }); + // A homeserver refusal keeps its own errcode (M_TOO_LARGE ...), which is what names it to the sender. + const errcode = typeof e?.errcode === 'string' && e.errcode.startsWith('M_') ? e.errcode : name; + const err = new MatrixError({ error, errcode }); (err as any).cause = e; + const info: UploadFailureInfo = { + unreadable: readable !== 'file readable', + offline: typeof navigator !== 'undefined' && navigator.onLine === false, + hidden: typeof document !== 'undefined' && document?.visibilityState === 'hidden', + aborted: name === 'AbortError', + progressed: trace?.firstProgressAt !== undefined, + stopped: trace?.signalAborted === true, + }; + (err as any).info = info; return err; }; @@ -435,14 +447,14 @@ export const uploadContent = async ( body = await copyInMemory(file); } catch (readErr: any) { const errcode = readErr?.name || 'Error'; - onError( - new MatrixError({ - error: `Upload failed: file unreadable before upload (${errcode}) (${file.size} bytes, ${ - file.type || 'unknown type' - })`, - errcode, - }) - ); + const unreadable = new MatrixError({ + error: `Upload failed: file unreadable before upload (${errcode}) (${file.size} bytes, ${ + file.type || 'unknown type' + })`, + errcode, + }); + (unreadable as any).info = { ...NO_INFO, unreadable: true }; + onError(unreadable); return; } const probe = startAbortProbe(); diff --git a/src/app/utils/uploadReason.test.ts b/src/app/utils/uploadReason.test.ts new file mode 100644 index 00000000..9debb085 --- /dev/null +++ b/src/app/utils/uploadReason.test.ts @@ -0,0 +1,104 @@ +import { afterEach, describe, expect, it, vi } from 'vitest'; +import { uploadContent, uploadFailure } from './matrix'; +import { uploadFailureText, uploadReason } from './uploadReason'; + +// What a person reads, from failures built the way the app builds them: through uploadFailure and +// uploadContent, not by hand-made info objects. +const abort = () => new DOMException('', 'AbortError'); +const blob = new Blob(['abcd'], { type: 'image/jpeg' }); +const textOf = async (e: unknown, trace = { startedAt: Date.now() } as any, file: Blob = blob) => + uploadFailureText(await uploadFailure(e, file, trace)); + +afterEach(() => { + vi.unstubAllGlobals(); +}); + +describe('what the sender is told when an upload fails', () => { + it('a drop before any byte left says the file never started, and to send again', async () => { + expect(await textOf(abort())).toBe( + 'Upload failed: the connection dropped before the file started. Send again.' + ); + }); + + it('a drop after progress says partway through and points at Wi-Fi', async () => { + const text = await textOf(abort(), { startedAt: 1, firstProgressAt: 5, loaded: 2, total: 4 }); + expect(text).toContain('dropped partway through'); + expect(text).toContain('Wi-Fi'); + }); + + it('a drop with the tab in the background says to keep the tab open', async () => { + vi.stubGlobal('document', { visibilityState: 'hidden' }); + expect(await textOf(abort())).toContain('Keep this tab open'); + }); + + it('offline outranks the drop it caused', async () => { + vi.stubGlobal('navigator', { onLine: false }); + expect(await textOf(abort())).toBe('Upload failed: you are offline. Reconnect and send again.'); + }); + + it('a file the browser can no longer read says to pick it again', async () => { + const gone = new Blob(['x']); + (gone as any).arrayBuffer = () => Promise.reject(new DOMException('gone', 'NotReadableError')); + expect(await textOf(abort(), undefined, gone)).toContain('can no longer read the file'); + }); + + it('a stopped upload says stopped, not that the connection failed', async () => { + const text = await textOf(abort(), { startedAt: 1, signalAborted: true }); + expect(text).toBe('Upload failed: stopped. Send it again when you are ready.'); + }); + + it('a homeserver refusal says what the server said in words, with what to do', () => { + expect(uploadFailureText({ errcode: 'M_TOO_LARGE' })).toBe( + 'Upload failed: too large for this server. Pick a smaller file.' + ); + expect(uploadFailureText({ errcode: 'M_FORBIDDEN' })).toContain('Ask a steward'); + expect(uploadFailureText({ errcode: 'M_LIMIT_EXCEEDED' })).toContain('Wait a moment'); + }); + + it('a failure we cannot name stays generic and sends the sender to the details', async () => { + const text = await textOf(new Error('Timeout')); + expect(text).toBe( + 'Upload failed. Send again; if it keeps failing, show the details below to a steward.' + ); + expect(uploadReason({ errcode: 'constructor' })).toBeUndefined(); + expect(uploadReason(null)).toBeUndefined(); + }); + + it('the long diagnostic text is still on the error for the details', async () => { + const err = await uploadFailure(abort(), blob, { startedAt: Date.now() }); + expect(err.message).toContain('4 bytes'); + expect(err.message).toContain('no progress'); + }); +}); + +describe('through uploadContent, as the composer and the share panel call it', () => { + it('an unreadable picked file is named before any request', async () => { + const bad = new Blob(['x']); + (bad as any).arrayBuffer = () => Promise.reject(new DOMException('gone', 'NotReadableError')); + const mx = { uploadContent: vi.fn() } as any; + const onError = vi.fn(); + await uploadContent(mx, bad, { onSuccess: vi.fn(), onError }); + expect(mx.uploadContent).not.toHaveBeenCalled(); + expect(uploadFailureText(onError.mock.calls[0][0])).toContain('can no longer read the file'); + }); + + it('a request that dies is told as a drop', async () => { + const mx = { uploadContent: () => Promise.reject(abort()) } as any; + const onError = vi.fn(); + await uploadContent(mx, blob, { onSuccess: vi.fn(), onError }); + expect(uploadFailureText(onError.mock.calls[0][0])).toContain('the connection dropped'); + }); + + it('a server that refuses keeps its errcode and is told in words', async () => { + const mx = { + uploadContent: () => + Promise.reject(Object.assign(new Error('x'), { errcode: 'M_TOO_LARGE' })), + } as any; + const onError = vi.fn(); + await uploadContent(mx, blob, { onSuccess: vi.fn(), onError }); + expect(onError.mock.calls[0][0].errcode).toBe('M_TOO_LARGE'); + expect(uploadFailureText(onError.mock.calls[0][0])).toBe( + 'Upload failed: too large for this server. Pick a smaller file.' + ); + }); +}); diff --git a/src/app/utils/uploadReason.ts b/src/app/utils/uploadReason.ts new file mode 100644 index 00000000..b101d6a4 --- /dev/null +++ b/src/app/utils/uploadReason.ts @@ -0,0 +1,77 @@ +// What a person is told when an upload fails: a cause they can name and the thing to do next. +// uploadFailure (matrix.ts) attaches the facts the client observed as `info`; the homeserver's +// refusals arrive as Matrix errcodes. The long diagnostic text stays on the error's message. + +/** What the client observed at the moment an upload died. */ +export type UploadFailureInfo = { + /** The browser could not read the picked file back. */ + unreadable: boolean; + /** navigator.onLine was false. */ + offline: boolean; + /** The tab was in the background. */ + hidden: boolean; + /** The request was aborted (the SDK reports a dropped XHR as an AbortError). */ + aborted: boolean; + /** At least one progress event arrived before it died. */ + progressed: boolean; + /** The sender pressed Stop. */ + stopped: boolean; +}; + +export const NO_INFO: UploadFailureInfo = { + unreadable: false, + offline: false, + hidden: false, + aborted: false, + progressed: false, + stopped: false, +}; + +export type UploadReason = { cause: string; action: string }; + +const REFUSALS: Record = { + M_TOO_LARGE: { cause: 'too large for this server', action: 'Pick a smaller file.' }, + M_FORBIDDEN: { + cause: 'not allowed to upload here', + action: 'Ask a steward if you should be able to.', + }, + M_LIMIT_EXCEEDED: { + cause: 'uploading too fast, try again shortly', + action: 'Wait a moment and send again.', + }, +}; + +/** The reason for a failure we can name, or undefined when we cannot: then the text stays generic. */ +export const uploadReason = (e: unknown): UploadReason | undefined => { + const code = (e as { errcode?: unknown } | null)?.errcode; + if (typeof code === 'string' && Object.hasOwn(REFUSALS, code)) return REFUSALS[code]; + const info = (e as { info?: Partial } | null)?.info; + if (!info) return undefined; + if (info.stopped) return { cause: 'stopped', action: 'Send it again when you are ready.' }; + if (info.unreadable) + return { + cause: 'this device can no longer read the file', + action: 'Pick it again; if it came from another app, save a copy first.', + }; + if (info.offline) return { cause: 'you are offline', action: 'Reconnect and send again.' }; + if (!info.aborted) return undefined; + if (info.hidden) + return { + cause: 'the connection dropped while this tab was in the background', + action: 'Keep this tab open while it uploads, and send again.', + }; + return info.progressed + ? { + cause: 'the connection dropped partway through', + action: 'Send again; a large file is safer on Wi-Fi.', + } + : { cause: 'the connection dropped before the file started', action: 'Send again.' }; +}; + +/** The line the upload card shows: the reason when there is one, else a generic line. */ +export const uploadFailureText = (e: unknown): string => { + const reason = uploadReason(e); + return reason + ? `Upload failed: ${reason.cause}. ${reason.action}` + : 'Upload failed. Send again; if it keeps failing, show the details below to a steward.'; +}; From ec2637a2bb1dc274aa1573d989e187d4eb42b3b6 Mon Sep 17 00:00:00 2001 From: Void Date: Sat, 14 Nov 2026 01:53:47 +0000 Subject: [PATCH 003/151] Upload reasons: offline and background-tab only explain a dropped request; Details lays out in the card Co-Authored-By: Claude Sonnet 5.5 --- .../components/upload-card/UploadFailureNote.test.tsx | 2 +- src/app/components/upload-card/UploadFailureNote.tsx | 4 ++-- src/app/utils/uploadReason.test.ts | 9 ++++++++- src/app/utils/uploadReason.ts | 5 +++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/app/components/upload-card/UploadFailureNote.test.tsx b/src/app/components/upload-card/UploadFailureNote.test.tsx index ac92e53e..c2f917ec 100644 --- a/src/app/components/upload-card/UploadFailureNote.test.tsx +++ b/src/app/components/upload-card/UploadFailureNote.test.tsx @@ -21,7 +21,7 @@ describe('the failed upload card', () => { 'Upload failed: the connection dropped before the file started. Send again.' ); expect(before).not.toContain('bytes'); - expect(html).toMatch(/
.*Details.*<\/details>/s); + expect(html).toMatch(/]*>.*Details.*<\/details>/s); expect(text(html.slice(html.indexOf(' {uploadFailureText(error)} -
- +
+ Details diff --git a/src/app/utils/uploadReason.test.ts b/src/app/utils/uploadReason.test.ts index 9debb085..d9e83d4d 100644 --- a/src/app/utils/uploadReason.test.ts +++ b/src/app/utils/uploadReason.test.ts @@ -28,7 +28,9 @@ describe('what the sender is told when an upload fails', () => { it('a drop with the tab in the background says to keep the tab open', async () => { vi.stubGlobal('document', { visibilityState: 'hidden' }); - expect(await textOf(abort())).toContain('Keep this tab open'); + const text = await textOf(abort()); + expect(text).toContain('(this tab was in the background)'); + expect(text).toContain('Keep this tab open'); }); it('offline outranks the drop it caused', async () => { @@ -36,6 +38,11 @@ describe('what the sender is told when an upload fails', () => { expect(await textOf(abort())).toBe('Upload failed: you are offline. Reconnect and send again.'); }); + it('offline is not blamed for a failure that was not a dropped request', async () => { + vi.stubGlobal('navigator', { onLine: false }); + expect(await textOf(new Error('Bad Gateway'))).toContain('Upload failed. Send again;'); + }); + it('a file the browser can no longer read says to pick it again', async () => { const gone = new Blob(['x']); (gone as any).arrayBuffer = () => Promise.reject(new DOMException('gone', 'NotReadableError')); diff --git a/src/app/utils/uploadReason.ts b/src/app/utils/uploadReason.ts index b101d6a4..badbaf95 100644 --- a/src/app/utils/uploadReason.ts +++ b/src/app/utils/uploadReason.ts @@ -53,11 +53,12 @@ export const uploadReason = (e: unknown): UploadReason | undefined => { cause: 'this device can no longer read the file', action: 'Pick it again; if it came from another app, save a copy first.', }; - if (info.offline) return { cause: 'you are offline', action: 'Reconnect and send again.' }; + // Offline and hidden-tab are only read as the cause of a dropped request, not of any failure. if (!info.aborted) return undefined; + if (info.offline) return { cause: 'you are offline', action: 'Reconnect and send again.' }; if (info.hidden) return { - cause: 'the connection dropped while this tab was in the background', + cause: 'the connection dropped (this tab was in the background)', action: 'Keep this tab open while it uploads, and send again.', }; return info.progressed From 6b40809f9d7b871a50976427880fd749e00bdd3b Mon Sep 17 00:00:00 2001 From: Void Date: Sat, 14 Nov 2026 01:54:29 +0000 Subject: [PATCH 004/151] docs: harvest polarity row loses the shotgun claim; physical room run row; sources for the 41 s and degraded-score claims Co-Authored-By: Claude Sonnet 5.5 --- docs/gamecult/symphony-grammar-harvest.md | 29 ++++++++++++----------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/docs/gamecult/symphony-grammar-harvest.md b/docs/gamecult/symphony-grammar-harvest.md index 61763cca..30b80a8a 100644 --- a/docs/gamecult/symphony-grammar-harvest.md +++ b/docs/gamecult/symphony-grammar-harvest.md @@ -15,20 +15,21 @@ together as music), which Mimir never needed: Mimir emits one voice at a time, a Confidence: A = measured number in a receipt, B = measured but synthetic or single run, C = design claim or authored opinion with no measurement behind it. -| Claim | Evidence | Conf. | -| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- | -| Tidy lab beeps are the wrong signal for a room; a birdsong-like motif replaced them. | `docs/bioacoustic-timeline-watermark.md` L3-10 (stated as a decision, no listening test). | C | -| Identity is carried redundantly: contour survives pitch shift, rhythm survives bad frequency response, formant envelope survives a dead band, speaker variants expose room asymmetry. | same doc L82-95. Argument, not an ablation. | C | -| A word needs no sequence grammar: one heard word identifies its event directly (128 words x 2 speaker variants, 4 syllables each), in an event slot that repeats about every 41 s. No de Bruijn grammar. | same doc L26-33; `src/Mimir.Runtime/Synchronization/MimirBioacousticTimeline.cs` (WordCount, SymbolCount = WordCount\*SpeakerCount, BuildMotifs ~L690-730). | B | -| Word identity survives mel-cepstral warp/blur degradation; timing does not unless fitted as one global clock/delay hypothesis. | `docs/bioacoustic-training-harness.md` L58-112: identity 0.908-0.997 on clean input only, 0.5-0.9 degraded; timing 0.19-0.73 (0.357 before vs 0.905 after global clock fit, compact-fast-index clean). | A (synthetic, clean-only range) | -| Contestant shapes were scored against the same decoder family and damage panel; the best scorer was the six-syllable "canary-packet-trill", a hypothesis not confirmed on a physical room (two timing chips plus four payload-coloured formant notes), not the literal bird imitations. | `research/bioacoustic-contestants-2026-05-24.md` L24-38, L128-174 (honest floor 88.4 language_score, 19 bps, payload 1.000 clean), L487-489 (96 ms motif is the best tradeoff). | B | -| Too-short or too-tight songs fail under blur: 0.100 s event spacing lost anchors to overlap; 0.105 s kept; 78 ms motif and 5-syllable finch-burst-packet collapsed (blur-light 4.358, the razor decoder; 218.368 with the sprint decoder, L453-454). | contestants doc L169-171, L446-455, L487-489. | A | -| A 3-bit payload variant (separate band/rhythm bit) did not survive degradation (best 12.849, clean 8.084). | contestants doc L183-185. | A | -| Real birds carry identity through redundant contour, roughness, onset statistics and cepstral envelope together; Redpoll is dense chatter with short vertical attacks, not a neat token stream; Guan is a slow broad curved phrase, good for probing the channel, poor for bitrate. The packet song was judged "still too ladder-like". | contestants doc L565-581 (two Xeno-canto mirrors via Wikimedia; Brown Thornbill file invalid, L511-513, L534-539). Flux numbers L549-562. | B (two recordings, hand reading) | -| Positive log-mel spectral flux is a good onset/anchor surface; sustained bands recede, attacks and glides light up. | contestants doc L541-545, L577-581; but the naive flux decoder lost on speed (33.466 vs 88.129 score, clean roundtrip, L158 and L231-237). | B | -| Once the schedule is known, the receiver only discriminates among a few local candidates; wide identity search is only for acquisition. Streaming decoder reached 1121 score at 62.6x realtime, payload 1.000 on all nine damage cases. | contestants doc L248-309. | A (synthetic damage) | -| Polarity must be a nuisance variable; mic paths flip sign (shotgun mic 37/37). | contestants doc L391-395. | B (physical, one capture) | -| Speaker split: left and right vocabularies differ in root (x0.94 / x1.08) and syllable weights, so each side is separable. | `MimirBioacousticTimeline.cs` BuildMotifs ~L704-725 (read as code, no experiment isolates the benefit). | C | +| Claim | Evidence | Conf. | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- | +| Tidy lab beeps are the wrong signal for a room; a birdsong-like motif replaced them. | `docs/bioacoustic-timeline-watermark.md` L3-10 (stated as a decision, no listening test). | C | +| Identity is carried redundantly: contour survives pitch shift, rhythm survives bad frequency response, formant envelope survives a dead band, speaker variants expose room asymmetry. | same doc L82-95. Argument, not an ablation. | C | +| A word needs no sequence grammar: one heard word identifies its event directly (128 words x 2 speaker variants, 4 syllables each), in an event slot that repeats about every 41 s (derived, not reported: 128 words x 2 speakers = 256 events at 0.16 s spacing = 40.96 s, from `MimirBioacousticTimeline.cs` L34-39 and `SymbolForEvent` L735-739; no receipt or doc states it). No de Bruijn grammar. | same doc L26-33; `src/Mimir.Runtime/Synchronization/MimirBioacousticTimeline.cs` (WordCount, SymbolCount = WordCount\*SpeakerCount, BuildMotifs ~L690-730). | B | +| Word identity survives mel-cepstral warp/blur degradation; timing does not unless fitted as one global clock/delay hypothesis. | `docs/bioacoustic-training-harness.md` L58-112: identity 0.908-0.997 on clean input only; degraded identity 0.532-0.908 and timing 0.187-0.728 for compact-fast-index across the four degraded cases in `artifacts/bioacoustic-training/bioacoustic-20260524-150729/compact-fast-index/*/summary.json` (`IdentityScore`, `TimingScore`); clean timing 0.357 before vs 0.905 after the global clock fit. | A (synthetic, clean-only range) | +| Contestant shapes were scored against the same decoder family and damage panel; the best scorer was the six-syllable "canary-packet-trill", a hypothesis not confirmed on a physical room (two timing chips plus four payload-coloured formant notes), not the literal bird imitations. | `research/bioacoustic-contestants-2026-05-24.md` L24-38, L128-174 (honest floor 88.4 language_score, 19 bps, payload 1.000 clean), L487-489 (96 ms motif is the best tradeoff). | B | +| Too-short or too-tight songs fail under blur: 0.100 s event spacing lost anchors to overlap; 0.105 s kept; 78 ms motif and 5-syllable finch-burst-packet collapsed (blur-light 4.358, the razor decoder; 218.368 with the sprint decoder, L453-454). | contestants doc L169-171, L446-455, L487-489. | A | +| A 3-bit payload variant (separate band/rhythm bit) did not survive degradation (best 12.849, clean 8.084). | contestants doc L183-185. | A | +| Real birds carry identity through redundant contour, roughness, onset statistics and cepstral envelope together; Redpoll is dense chatter with short vertical attacks, not a neat token stream; Guan is a slow broad curved phrase, good for probing the channel, poor for bitrate. The packet song was judged "still too ladder-like". | contestants doc L565-581 (two Xeno-canto mirrors via Wikimedia; Brown Thornbill file invalid, L511-513, L534-539). Flux numbers L549-562. | B (two recordings, hand reading) | +| Positive log-mel spectral flux is a good onset/anchor surface; sustained bands recede, attacks and glides light up. | contestants doc L541-545, L577-581; but the naive flux decoder lost on speed (33.466 vs 88.129 score, clean roundtrip, L158 and L231-237). | B | +| Once the schedule is known, the receiver only discriminates among a few local candidates; wide identity search is only for acquisition. Streaming decoder reached 1121 score at 62.6x realtime, payload 1.000 on all nine damage cases. | contestants doc L248-309. | A (synthetic damage) | +| Polarity must be a nuisance variable; mic paths flip sign. | contestants doc L391-395. | B (physical, one capture) | +| Physical room run: with per-channel acquisition offsets the co-streamer shotgun mic (ch1) locked 37/37 events, payload 1.000, timing 0.828; the cardioid/near mic (ch0) reached 26/37, payload 0.595, and stayed unreliable. | contestants doc L371-388. | B (physical, one capture) | +| Speaker split: left and right vocabularies differ in root (x0.94 / x1.08) and syllable weights, so each side is separable. | `MimirBioacousticTimeline.cs` BuildMotifs ~L704-725 (read as code, no experiment isolates the benefit). | C | Rendering recipe actually in code (`MimirBioacousticTimeline.cs` AddSyllable ~L610-640): each syllable is a log-frequency glide (exponential sweep) with a raised-cosine envelope, summed partials at From 33e31a6102f9efe664b4d8cea2db5a9612d8fbae Mon Sep 17 00:00:00 2001 From: Void Date: Sat, 14 Nov 2026 02:14:21 +0000 Subject: [PATCH 005/151] Files desk: name loose files the album list cannot show; pin the old publisher wire shape Co-Authored-By: Claude Sonnet 5.5 --- src/app/features/albums/AlbumView.tsx | 33 ++++++- src/app/features/albums/buildAlbums.ts | 34 ++++++- src/app/features/albums/publisherWire.test.ts | 99 +++++++++++++++++++ 3 files changed, 164 insertions(+), 2 deletions(-) create mode 100644 src/app/features/albums/publisherWire.test.ts diff --git a/src/app/features/albums/AlbumView.tsx b/src/app/features/albums/AlbumView.tsx index d6ee37c9..f90138d6 100644 --- a/src/app/features/albums/AlbumView.tsx +++ b/src/app/features/albums/AlbumView.tsx @@ -14,7 +14,7 @@ import { markAsRead } from '../../utils/notifications'; import { getBlobSafeMimeType } from '../../utils/mimeTypes'; import { timeDayMonYear } from '../../utils/time'; import { getMemberDisplayName } from '../../utils/room'; -import { Album, AlbumFile, lastEvent } from './buildAlbums'; +import { Album, AlbumFile, TimelineEvent, lastEvent, looseFiles, looseNote } from './buildAlbums'; import { folderOf, listFolder, pathLabel } from './albumFolders'; import { FileReadBy } from './FileReadBy'; import { ShareSet, useShareEnabled } from './ShareSet'; @@ -106,6 +106,31 @@ function useMarkZoneRead(room: Room) { }, [mx, room, hideActivity]); } +/** The file events in the room's live timeline that no album thread holds, kept current as it syncs. */ +function useLooseFiles(room: Room): AlbumFile[] { + const [, bump] = useState(0); + useEffect(() => { + const on = () => bump((n) => n + 1); + room.on(RoomEvent.Timeline, on); + return () => { + room.off(RoomEvent.Timeline, on); + }; + }, [room]); + const events: TimelineEvent[] = room + .getLiveTimeline() + .getEvents() + .map((e) => ({ + event_id: e.getId(), + type: e.getType(), + sender: e.getSender(), + origin_server_ts: e.getTs(), + content: e.getContent(), + unsigned: e.getUnsigned() as Record, + threadRoot: e.threadRootId, + })); + return looseFiles(events); +} + type AlbumViewProps = { room: Room; onTimeline: () => void }; export function AlbumView({ room, onTimeline }: AlbumViewProps) { useMarkZoneRead(room); @@ -117,6 +142,7 @@ export function AlbumView({ room, onTimeline }: AlbumViewProps) { const authorOf = (a: Album) => getMemberDisplayName(room, a.author) ?? a.author; const encrypted = room.hasEncryptionStateEvent(); const canShare = useShareEnabled(room); + const loose = useLooseFiles(room); let body: React.ReactNode; if (loading) body = Loading albums…; @@ -206,6 +232,11 @@ export function AlbumView({ room, onTimeline }: AlbumViewProps) {
{body} + {!open && !encrypted && !loading && !error && loose.length > 0 && ( + + {looseNote(loose)} + + )} {/* Stays mounted while an album is open, so a running send keeps its progress. */} {canShare && (