Problem
The note-delete handler removes the note from local state unconditionally after the fetch settles, without checking `res.ok`, and even a caught network error still falls through to the state update:
```ts
const remove = async (id: number) => {
if (!accessToken) return;
await fetch(`/api/notes/${id}`, { method: "DELETE", ... }).catch((e) => console.error(...));
setNotes((prev) => prev.filter((n) => n.id !== id));
};
```
Impact
If the DELETE request fails server-side (4xx/5xx) or errors over the network, the UI still shows the note as deleted immediately, while it actually still exists in the database. The note will reappear the next time notes are reloaded, which is confusing — the user believed it was permanently removed and may have relied on that (e.g. re-typed sensitive content elsewhere assuming the original was gone).
Location
`components/layout/ContextSidebar.tsx:125-132`
Suggested fix
Only strip the note from local state when the response is `ok`; on failure, keep the note in state and surface an error (toast/inline message), mirroring the pattern already used for the `save` handler in the same file.
Problem
The note-delete handler removes the note from local state unconditionally after the fetch settles, without checking `res.ok`, and even a caught network error still falls through to the state update:
```ts
const remove = async (id: number) => {
if (!accessToken) return;
await fetch(`/api/notes/${id}`, { method: "DELETE", ... }).catch((e) => console.error(...));
setNotes((prev) => prev.filter((n) => n.id !== id));
};
```
Impact
If the DELETE request fails server-side (4xx/5xx) or errors over the network, the UI still shows the note as deleted immediately, while it actually still exists in the database. The note will reappear the next time notes are reloaded, which is confusing — the user believed it was permanently removed and may have relied on that (e.g. re-typed sensitive content elsewhere assuming the original was gone).
Location
`components/layout/ContextSidebar.tsx:125-132`
Suggested fix
Only strip the note from local state when the response is `ok`; on failure, keep the note in state and surface an error (toast/inline message), mirroring the pattern already used for the `save` handler in the same file.