Repository navigation
Persist chat pins across clients of the same Unsloth server - #15293
Conversation
|
The three new paths were added only to the
|
…into push filter [skip ci]
…measured growth [skip ci]
[skip ci]
|
@codex review |
|
@codex security review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
5 similar comments
|
@codex review |
|
@codex review |
|
@codex review |
|
@codex review |
|
@codex review |
…across sign-out, and the session mark of pre-mark logins
…nslothai#15440) With Studio open in two tabs or windows, sidebar sections, favorites and pinned projects made in one were lost as soon as the other one changed anything of the same kind. Creating a section in one tab and a different section in the other left only the second section after a reload, and the chats filed into the first were back in Recents. The same happened to chats or projects starred in the Library and to pinned projects. These only live in the browser, so there was nothing to get them back from. The sidebar layout, Library favorites and pinned projects now pick up what another window saved as soon as it is written, the same way the browser panel's bookmarks and history already do. The next change in any window builds on it instead of overwriting it, and the other window's sidebar updates live. Pinned chats are left out on purpose, since unslothai#15293 moves them to server settings. A single window behaves exactly as before, and existing saved sections, favorites and pins keep loading as they did. ## Before / After Tab A creates section Work, tab B (opened earlier) creates section Play, then tab A reloads.  Tab A stars Alpha chat in the Library, tab B stars Beta chat, then tab A reloads.  ## Before / After on two clean installs Base 73560d3 vs this PR's head 7d27066, one Chromium context with two tabs: tab B is opened first, tab A creates section Work, tab B creates section Play, then tab A reloads. Before, only Play is saved (`["Play"]`) and Work is gone; after, both are saved (`["Play", "Work"]`) and both are drawn.  Co-authored-by: Daniel Han <[email protected]>
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…line unpin cancels on upgrade replay [skip ci]
… an unpin cancel a queued pin of the same chat [skip ci]
…fore sending each intent
… bulk pin [skip ci]
… invalid [skip ci]
…op them on sign-out
…dged without applying [skip ci]
…etadata rejections, hydrate on transport failures [skip ci]
…fore Clear all [skip ci]
…r unpin can cancel it [skip ci]
…in cannot block the queue [skip ci]
… boundaries without it
… fence it [skip ci]
[skip ci]
…an unpin already fenced
…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]>
Chat pins currently live only in browser localStorage, so another browser or computer connected to the same Unsloth server does not see them.
Persist chat and comparison pin IDs in account-scoped server settings. Migrate existing browser pins, reconcile concurrent edits with compare-and-set, and retain pending pin intents across reloads and temporary failures. Keep compatibility with older backends and avoid resurrecting explicit unpins. A pin awaiting legacy chat import remains pending; deleted chats and comparisons are acknowledged so they cannot block later saves.
Existing mixed sidebar drag/drop and manual ordering behavior is preserved. This synchronizes chat pins between clients of the same backend; separate installations and project/page pins are outside this change.
Validation:
Browser checks use production store/lifecycle code with real routes and temporary SQLite, without model inference. Native packaged desktop and macOS/Safari were not exercised.
Before / after
A chat is pinned in browser A, then a second fresh browser opens the same Studio server. Before this PR the chat stays under Recents in browser B and
/api/chat/pinsreturns 404. After it, browser B shows the chat in the Pinned section and/api/chat/pinsreturns{"pinnedIds":["uidiff-pin-a-00efadb5"]}. Head33461eb85vs merge base9c397197e.