Repository navigation
Studio: stop the false "Failed to refresh models" error during a desktop update - #11224
Merged
Merged
Conversation
…tles Skip & Restart and the shell-failure recovery call start_server, which returns once the backend is spawned rather than healthy. Clearing the flag on that render left the immediate chat resync (and any focus read or documents poll) unsilenced, so a boot slower than the 10.5s Tauri retry ladder raised "Failed to refresh models" right after the update screen closed. The update layer now delegates to followDesktopUpdateScreen, which keeps the flag up until the resync settles and ignores that settle if an update restarts first.
Collaborator
|
Thanks, this fixes a real problem. I pushed one follow-up commit (b5d0cbd):
|
Collaborator
|
Codex review of b5d0cbd (run on a staging mirror, since the connector isn't active here): Didn't find any major issues. Lyxot#59 (comment) |
…rness The harness slices syncInferenceStatusToStore verbatim and supplies each module-boundary name itself, so the new desktop update imports were ReferenceErrors caught as refresh failures.
Collaborator
Collaborator
|
Codex review of the current head 726ec53: Didn't find any major issues. Lyxot#59 (comment) — CI 48/48 green on the staging mirror. |
Member
|
Confirmed this hits the catch in studio/frontend/src/features/chat/hooks/use-chat-model-runtime.ts, which still toasts "Failed to refresh models" when the updater has stopped the backend on purpose, and the guard only swallows transport failures so real server errors still surface. Will get this reviewed. |
shaojun
pushed a commit
to shaojun/unsloth
that referenced
this pull request
Sep 29, 2026
…top update (unslothai#11224) * Studio: silence model refresh toast while desktop update stops the backend * Studio: only silence transport failures during desktop update, add test * Studio: latch the update flag at issue and silence the documents poll too * fix(studio): hold the update silence until the post-update resync settles Skip & Restart and the shell-failure recovery call start_server, which returns once the backend is spawned rather than healthy. Clearing the flag on that render left the immediate chat resync (and any focus read or documents poll) unsilenced, so a boot slower than the 10.5s Tauri retry ladder raised "Failed to refresh models" right after the update screen closed. The update layer now delegates to followDesktopUpdateScreen, which keeps the flag up until the resync settles and ignores that settle if an update restarts first. * test(studio): stub the desktop update predicates in the chat mount harness The harness slices syncInferenceStatusToStore verbatim and supplies each module-boundary name itself, so the new desktop update imports were ReferenceErrors caught as refresh failures. --------- Co-authored-by: Lyxot <[email protected]>
iam-knoit
pushed a commit
to SynhalaAI/unsloth
that referenced
this pull request
Nov 1, 2026
…esktop update (unslothai#16188) ## Problem During a desktop update, the "Updating backend..." screen can show a red "Could not sync pinned chats. Try again when connected." toast. The update stops the backend on purpose, so the pin sync cannot succeed until it finishes, and the error is false. ## Root cause `TauriUpdateLayer` draws the update screen over the app without unmounting it. The pin sync hook, `usePinnedChatsSync`, keeps polling the backend every 30 s and on window focus. Every failed request reaches the sync runtime's `onError` in `sync-pinned-chats.ts`, which always shows the toast. unslothai#11224 fixed the same symptom for the model status and RAG document refreshes. It added `isBackendDownForDesktopUpdate()`, a flag that is set while the update screen is up, and `isSilencedDesktopUpdateFailure()`, which hides "could not reach the backend" errors while that flag is set. The pin sync from unslothai#15293 was added later and never used them. That helper alone also misses pin failures that the stopped backend causes: - The pins API aborts every request after 10 s. A request in flight when the update starts can end in that `AbortError`. - If the backend stops after the response headers arrive, the body read fails with an untagged `TypeError` or the 10 s abort. For writes and legacy reads, `parseJsonOrThrow` turned both into `null`, which became a "Cannot read properties of null" `TypeError`. - Pin edits are saved one at a time in order. If the first fails, the next fails with "An earlier pin change is still waiting to save.", a plain `Error`. - The helper checks the flag when the error is reported, not when the request failed. A failed write makes a recovery read before reporting, and the edits queued behind it report after that. If the update screen drops in between, those failures toast. ## Fix - `use-pinned-chats-sync.ts`: skip the poll while `isBackendDownForDesktopUpdate()` is true. - `api/chat-pins-api.ts`: record, when each pin request fails, whether the backend was down for the update at issue or at failure; tag a body that breaks off on a 200 as a transport failure. - `api/chat-settings-api.ts`: `parseJsonOrThrow` tags a broken-off body and re-throws an `AbortError` / `TimeoutError` on a 200 instead of returning `null`. Invalid JSON still returns `null`. Only the pin calls pass an abort signal, so other settings callers see no new behavior. - `utils/pinned-chats-sync.ts`: throw the queued-edit error as `PinnedChatsBlockedError`, with the failure it waits on as its `cause`. - `utils/pinned-chats-update-failure.ts` (new, lazily loaded): `isPinFailureUnderDesktopUpdate()` decides whether a failure came from the update. - `sync-pinned-chats.ts`: `onError` skips the toast when that check is true. ## Behavior boundaries - Outside a desktop update, pin sync errors still show the toast. - During an update, an HTTP error the backend returned, a malformed response, or a validation error still shows the toast. - Pin edits made before or during the update stay queued in local storage and are saved after it. ## Verification Live A/B: a page running as the desktop webview (Tauri internals mocked) mounted the real sync hook, `UpdateScreen` and toaster, against a real Studio backend that was killed the way the update stops it. | Scenario | main | this PR | | --- | --- | --- | | Update screen up, backend killed, 30 s poll fires (the reported case) | toast | no toast, no request sent | | Pin read in flight when the update kills the backend, ends in the 10 s abort | toast at 10.6 s | no toast | | Two pin edits queued when the update kills the backend | toast | no toast; both saved after the update | | No update, backend dies (control) | toast | toast | Without the `AbortError` / `TimeoutError` check, the second scenario still shows the toast at 10.7 s. New behavioral tests in `pinned-chats-update-failure.test.ts` run the real pins API and sync runtime with `fetch` stubbed. Each failure case above stays silent under the update and queued edits are saved afterwards. The same failures still show the toast outside an update, and a malformed 200 shows it even during one. The cut-off body, timeout-after-headers and late report tests fail without this change. The focused pin, settings and desktop-update tests (201), typecheck, eslint, build and the bundle size check pass. Not tested: a real desktop update on Windows or macOS. ## UI evidence (merge base vs this PR) Both sides are real Studio installs built from each tree, opened as the desktop webview (Tauri IPC mocked: preflight attaches to that Studio, an update is offered and `start_backend_update` never finishes). After the update screen is up, every `/api` request is refused and the pin sync is woken by a focus event. Update screen up, backend unreachable. Before: the false "Could not sync pinned chats" toast. After: no toast and no pin request sent (0 vs 5 pin requests).  Control, no update and backend unreachable: both sides still show the pin sync toast.  --------- Co-authored-by: Daniel Han <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While the desktop app is updating, it shows a "Failed to refresh models. Unsloth isn't running, please relaunch it." error even though the update is going fine.
This happens because the update stops the backend on purpose, but the chat page is still open behind the update screen. Every time you switch back to the app window, the chat page tries to reload the model list, can't reach the backend, and shows the error.
With this change the chat page stays quiet about that one failure while the update screen is showing. Real errors still show up, and everything works as before once the update is done.
Tested before and after the change in Chromium, Firefox and WebKit. Also added a test for it.