Repository navigation
Studio: stop the pinned-chat sync toast after updates for good - #18139
Conversation
Background pin refreshes and retryable writes stay queued in the journal, so a failed read, a 401 whose token refresh could not finish, a proxy page, or an edit waiting behind a trimmed bulk pin no longer shows the error toast. A pin change the server rejects for good still does. The legacy pin migrate, re-sent on every refresh, now answers from a read and takes the studio.db writer lock only when it adds pins, so it no longer queues behind startup writers for up to 30 s.
Codex Review Summary: ✅ CompletedThis 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 |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ 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". |
…ine as benign (red since #18135) (#18145) `tests/studio/test_backend_ci_parallel_isolation.py::test_every_tight_elapsed_bound_is_isolated` fails on main since #18135 (workflow-trigger lint and the CPU `studio` shard, seen on the staging run of #18139): ``` E assert not {'test_openai_images_load_swap.py': ['test_openai_images_load_swap.py:199 one duration against another']} ``` ## Cause #18135 added `test_a_batch_waiting_through_a_reload_carries_the_pin`, which waits for two image requests to join one batch: ```python deadline = asyncio.get_running_loop().time() + 5 while sum(len(b.members) for b in batching._OPEN.values()) < 2: assert asyncio.get_running_loop().time() < deadline, "the batch never formed" await asyncio.sleep(0.01) ``` That is a poll deadline: descheduling only delays the poll and cannot make the condition false. The lint flags every clock comparison in backend tests run under `-n 4` until it is recorded, and this one was not. ## Fix Add `("test_openai_images_load_swap.py", "test_a_batch_waiting_through_a_reload_carries_the_pin")` to `BENIGN_TIMING` with a one-line reason. The lint keys on the outermost enclosing function, so the test name covers the nested `run()`. ## Verification - main: `test_every_tight_elapsed_bound_is_isolated` fails with the message above. - this branch: `tests/studio/test_backend_ci_parallel_isolation.py` 43 passed.
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ 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". |
Summary
Follow-up to #18087 for #18063. People still see "Could not sync pinned chats. Try again when connected." after updating, even though nothing was lost and the pins sync on the next refresh.
#16188 and #18087 each silenced a list of error shapes (update window, timeouts, transport failures, 5xx). Failures outside those lists still toast. The ones that happen right after an update or restart:
authFetchhands back the original 401. That is a terminal 4xx toisExpectedPinSyncInterruption, so every 30 s poll toasted.isRetryablePinErroralready treats the same 401 as retryable and keeps the edit queued.a, b, pinc, then unpinabefore the first save finishes. The first entry is replaced with a new id in its slot, and the edits behind it throwPinnedChatsBlockedErrorwith no cause. Nothing failed, every edit saves, and it toasted twice.The other half is why the reads are slow in the first place. Legacy localStorage pin ids are re-sent to
POST /api/chat/pins/migrateon every refresh (30 s poll plus focus, visibility and online), and the server always tookBEGIN IMMEDIATEwith a 30 s busy timeout, even when every id was already pinned. Right after an update the legacy chat import and the attachment inventory work hold the studio.db writer lock, so each refresh queued a writer transaction that outlived the 10 s client abort and kept a threadpool worker waiting.Changes
pinned-chats-sync.ts:onErrornow gets aneditLostflag. It is true only when the sync discarded a pin change: a non-retryable rejection thatrecoverdrops, or asetPinnedthat could not be queued. Background reads and retryable writes reporteditLost = false, because the journal retries them.pinned-chats-update-failure.ts:shouldReportPinSyncFailure(error, editLost)keeps the existing update-window and interruption checks and adds theeditLostcondition.sync-pinned-chats.tstoasts only when it returns true. The tests use the same function, so they exercise the real decision.studio_db.migrate_chat_pins: the merge is computed from a read first. When it adds nothing and the stored value is clean, it returns without taking the writer lock. Otherwise it takesBEGIN IMMEDIATEand recomputes, as before. The response is identical in both cases.What does not change: the toast text, when pins are retried, the journal format, and the API. A pin change the server rejects for good still shows the toast.
Verification
node --experimental-strip-types --test tests/pinned-chats-*.test.ts tests/desktop-update-refresh-toast.test.ts tests/settings-retry.test.ts: 122 passed.pinned-chats-update-failure.test.tsrun the real pins API and sync runtime withfetchstubbed:["b", "c"]saved;python -m pytest studio/backend/tests/test_pinned_chat_settings.py: 60 passed. The new test holds the studio.db writer lock from another connection. A repeated migrate answers right away. A migrate that adds a pin still waits for the lock. On main the repeated migrate fails withdatabase is locked.npm run typecheck, eslint on the changed files, and ruff are clean.Fixes #18063
Live check (real Studio installs, base vs this PR)
Two Studio installs on the same Linux host, merge base
d9aa650and this branch, driven by Chromium:/api/auth/refreshanswers 502 (backend restarting behind a tunnel or proxy).GET /api/chat/pinsreturns a real 401The AFTER frame was taken at the end of the 45 s window. The result comes from polling the page text, not from this one frame. "Failed to refresh models" is a separate toast with the same 401 cause and is not changed here.
Cross-platform staging ran the scoped tests (60 backend, 27 frontend, new tests included) green on
ubuntu-latest,ubuntu-24.04-arm,macos-15andwindows-latest.windows-11-armdid not reach the tests:pyarrow(viadatasets) has no win-arm64 wheel and the runner failed to build it.