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: isolate per-file failures in SongBook multi-file attachment upload (#3901)
[._.]/ Adam Eivy9e09266c6ad7
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex da4714cdde..74fed060aa 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -58,3 +58,4 @@- The TUI runner's response-file tests no longer fail at random on a busy machine. They drive the runner's one-second size-stability window with fake timers, but the polls behind that window read the response file from real disk — and a real read finishes on Node's threadpool, which advancing fake timers does not wait for. Under load a poll's read could land after the test had already moved on, so the run took the timeout or fallback path and the failure looked like a regression in whatever diff happened to be under test. Those five tests now serve the response file from memory, so every read settles as a microtask the timer advance always drains, and the assertions are unchanged.- The unused `toolUseLocalModelFilter` export was removed from the client's provider helpers. It offered to hide non-tool-capable local models from a picker, but nothing ever called it, and the approach it represented was already settled the other way: agent and coding pickers annotate each option (`🔧 tool use` / `⚠ no known tool use`) and warn below the select rather than filtering, because the underlying heuristic is a positive allowlist — a non-match means "not a recognized tool-caller", not a proven negative, so filtering would make a newer tool-capable family unselectable. The rationale now lives on the annotation helper that survived.- Deleting or uploading a SongBook attachment no longer crashes when the attachment presence lookup failed on page load. That failure parks the attachment state on a `'failed'` sentinel string so the synced list still renders with presence unknown, but both mutation handlers treated it as an array: the delete handler called `.find()` on it and threw `TypeError: prev.find is not a function`, leaving the row on screen, and the upload handler spread the string into six single-character rows. Both now check for an array first, falling back to the record's own synced list on upload and leaving presence genuinely unknown on delete rather than stamping a false "not on this machine" pill.+- Uploading several SongBook attachments at once no longer stops at the first failure. The upload loop awaited each file without catching, so one rejected read or a single server error broke out of the loop: the remaining files in the selection were never attempted, and the one generic "Upload failed" toast gave no clue which file failed or that anything had been skipped. Each file's read-and-upload now catches on its own, toasting a message that names the file, and the batch continues so the successful files still land.diff --git a/client/src/pages/SongBookViewer.jsx b/client/src/pages/SongBookViewer.jsxindex 978464a73c..380b3344de 100644--- a/client/src/pages/SongBookViewer.jsx+++ b/client/src/pages/SongBookViewer.jsx@@ -327,8 +327,16 @@ export default function SongBookViewer() {toast.error(`"${file.name}" exceeds the ${formatBytes(JSON_UPLOAD_MAX_FILE_SIZE)} limit`);continue;}- const data = await readFileAsBase64(file);- const res = await uploadSongAttachment(id, { filename: file.name, data }, { silent: true });+ // Per-file failure isolation (#3901): a rejected read/upload must not+ // abort the rest of a multi-file selection. Catch here (rather than+ // letting it bubble to useAsyncAction's single generic toast) so the+ // toast names the file that failed and the loop keeps going.+ const res = await readFileAsBase64(file)+ .then((data) => uploadSongAttachment(id, { filename: file.name, data }, { silent: true }))+ .catch((err) => {+ toast.error(`Failed to upload "${file.name}": ${err?.message || 'Upload failed'}`);+ return null;+ });if (res?.attachment) {attachmentsMutatedRef.current = true;// `prev` may be the 'failed' sentinel — spreading a string would yielddiff --git a/client/src/pages/SongBookViewer.test.jsx b/client/src/pages/SongBookViewer.test.jsxindex 045416f0ba..efdf77bbd3 100644--- a/client/src/pages/SongBookViewer.test.jsx+++ b/client/src/pages/SongBookViewer.test.jsx@@ -15,6 +15,7 @@ const api = vi.hoisted(() => ({vi.mock('../services/api', () => api);vi.mock('../components/ui/Toast', () => ({ default: { error: vi.fn(), success: vi.fn() } }));+import toast from '../components/ui/Toast';import SongBookViewer from './SongBookViewer.jsx';// Invented fixture data only (privacy convention) — nonsense sheet content.@@ -186,6 +187,51 @@ describe('SongBookViewer', () => {});});+ describe('multi-file upload failure isolation (#3901)', () => {+ beforeEach(() => {+ api.uploadSongAttachment.mockReset();+ toast.error.mockClear();+ });++ it('keeps uploading the rest of the batch after one file fails', async () => {+ api.uploadSongAttachment.mockImplementation(async (_id, { filename }) => {+ if (filename === 'b.pdf') throw new Error('Server exploded');+ return { attachment: { filename: `x-${filename}`, label: filename, mime: 'application/pdf', size: 10, sha256: 'h' } };+ });+ renderPage();+ expect(await screen.findByText(/No attachments/)).toBeTruthy();++ const input = document.querySelector('input[type="file"]');+ fireEvent.change(input, {+ target: {+ files: [+ new File(['a'], 'a.pdf', { type: 'application/pdf' }),+ new File(['b'], 'b.pdf', { type: 'application/pdf' }),+ new File(['c'], 'c.pdf', { type: 'application/pdf' }),+ ],+ },+ });++ // Every file is attempted — the failure does not break the loop.+ await waitFor(() => expect(api.uploadSongAttachment).toHaveBeenCalledTimes(3));+ // The two successes land in local state.+ expect(await screen.findByRole('link', { name: 'a.pdf' })).toBeTruthy();+ expect(await screen.findByRole('link', { name: 'c.pdf' })).toBeTruthy();+ expect(screen.queryByRole('link', { name: 'b.pdf' })).toBeNull();+ });++ it('toasts an error naming the failed file', async () => {+ api.uploadSongAttachment.mockRejectedValue(new Error('Server exploded'));+ renderPage();+ expect(await screen.findByText(/No attachments/)).toBeTruthy();++ const input = document.querySelector('input[type="file"]');+ fireEvent.change(input, { target: { files: [new File(['b'], 'b.pdf', { type: 'application/pdf' })] } });++ await waitFor(() => expect(toast.error).toHaveBeenCalledWith('Failed to upload "b.pdf": Server exploded'));+ });+ });+describe('instrument-view toggle (#2656)', () => {// Sheet with a tab staff so the non-guitar collapse note is observable.// Six staff lines: identifiably GUITAR tab, so non-guitar views collapse