Skip to content

fix(recordings): Stop deleting the last recording from returning a 404 - #555

Merged
brandonhs merged 2 commits into
mainfrom
554-fix-recording-delete-error
Oct 1, 2026
Merged

brandonhs merged 2 commits into
mainfrom
554-fix-recording-delete-error

Conversation

@brandonhs

@brandonhs brandonhs commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Summary

On the device, deleting the last recording(s) showed a "Failed to delete recording" toast even though the files were deleted. Two bugs caused this:

  1. The delete routes checked if not response, so when no recordings were left ([]) they returned a 404 after the files were already deleted.
  2. The 404 handler in run_release.py, which serves index.html for frontend routes, also caught API 404s and returned index.html with a 200 status. openapi-fetch then tried to parse the HTML as JSON, threw, and performDelete showed the error toast.

Changes

  • run_release.py: the 404 handler now uses FastAPI's default JSON response for paths under /api/. Other paths still get index.html. This also fixes the same problem for any other API 404 on the release build.
  • POST /api/recordings/bulk-delete always returns the remaining recordings, including an empty list.
  • DELETE /api/recordings/{recording_path} returns a 404 only when the file does not exist (response is None).
  • bulk_delete_recordings now removes deleted files from the cached self.recordings, like delete_recording already did.
  • Cached durations are now cleared by full path, which is the key they are stored by. Before, they were never removed.
  • delete_recording now takes recordings_lock. Both delete methods use a shared _remove_recording_file helper.
  • performDelete now shows an error toast when the request returns an error status. Before, an error status showed no toast.

Fixes #554

Testing

I ran an app with the recordings router, a StaticFiles mount, and the same 404 handler as run_release.py:

Request main This PR
Bulk delete the last recording 200, index.html 200, []
Delete a missing recording 200, index.html 404, JSON detail
GET /recordings (frontend route) 200, index.html 200, index.html

ruff, ty, tsc and eslint pass. I have not tested this on a device.

Type of change

  • Bug fix
  • Feature / Refactor
  • Breaking change
  • Misc.

Quick Checklist

  • I have reviewed my own code.
  • I have tested these changes locally.
  • I have tested these changes on the following platforms (optional):
    • SVC
    • microSVC (optional)
    • SVC Pro

🤖 Generated with Claude Code

brandonhs and others added 2 commits October 1, 2026 15:02
The bulk and single delete routes treated an empty recordings list as a
failure, so deleting the last remaining recordings returned a 404 and the
frontend kept showing the deleted files.

- Return the remaining list from the delete routes, even when it is empty
- Remove deleted recordings from the cached list in bulk delete
- Clear cached durations by full path, which is the key they are stored by
- Show an error toast in the frontend when the delete request fails

Fixes #554

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 404 handler that serves index.html for frontend routes also caught 404s
raised by API routes. It returned index.html with a 200 status, so the frontend
tried to parse the HTML as JSON and showed an error toast. On the device, this
made deleting the last recording show "Failed to delete recording" even though
the files were deleted.

Paths under /api/ now use FastAPI's default handler and return the JSON error.

Refs #554

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
return;
}

recordingsState.recordings = result.data;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot this still used valtio...

@brandonhs
brandonhs merged commit 87e76b3 into main Oct 1, 2026
2 checks passed
@brandonhs
brandonhs deleted the 554-fix-recording-delete-error branch October 1, 2026 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG REPORT]: Deleting recordings causes an error in the frontend

1 participant