Repository navigation
Studio: advertise the chat-title repair guards on the thread lists instead of fetching /openapi.json - #15685
Conversation
The legacy chat-title repair fetched the whole /openapi.json (~1 MB, and a multi-second cold build on the server) once per session to learn whether ChatThreadPatch has expectedTitle and expectedOpeningMessageId. The thread list and sidebar rows responses the repair already starts from now carry threadPatchGuards, derived from the same model. The frontend uses it when present and falls back to the schema probe for older backends; /openapi.json is unchanged for older frontends.
|
@codex 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: Didn't find any major issues. Keep them coming! 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". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. 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". |
… update the repair seam check)
|
@codex review |
|
Codex Review: Didn't find any major issues. 👍 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 `(Python 3.13, a-f)` fails on main and on every PR based on it (seen on the #15693 and #15761 staging runs) with two stale tests. Both product changes are intentional; the tests had not caught up. **1. `test_account_chat_settings.py::test_list_export_and_delete_stay_in_the_account`** ``` assert {'threads': [...Guards': True} == {'threads': []} Left contains 1 more item: {'threadPatchGuards': True} ``` #15685 advertises the chat-title repair guards on the thread lists (`threadPatchGuards` on the `/chat/threads` reply). This test checks that another account's thread stays invisible, but compared the whole reply to `{"threads": []}`. It now asserts the thread list itself is empty, which is the privacy claim. **2. `test_checkpoint_compaction.py::test_the_reachability_probe_closes_the_connection_it_opens`** ``` assert _open_archive_handles() <= before + 1 E assert 4 <= (0 + 1) ``` #15719 keeps one WAL keeper connection per `rag.db` for the life of the process (`storage/rag_db._ensure_wal_keeper`), holding `rag.db` plus its `-wal` and `-shm` sidecars. The first probe in a fresh process creates it, so the test counted the keeper's descriptors as a leak. It also failed when run alone, not only under xdist. The test now probes once to warm the keeper up, takes its baseline after that, and requires no growth at all over 50 probes. That is stricter than the old `before + 1`, and it is the leak the test exists for: one leaked probe connection per call. ## Testing - Both tests fail on main (`75555ccb54`) and pass with this change; `test_account_chat_settings.py` 93 passed. - Sabotage: replacing the `conn.close()` in `conversation_archive.reachable()` with a no-op makes the probe test fail with `assert 23 <= 5`.
The legacy chat-title repair only writes when the backend enforces the
expectedTitleandexpectedOpeningMessageIdguards onPATCH /api/chat/threads/{id}. To find that out, the frontend fetched the whole/openapi.jsononce per page session and looked for the two fields onChatThreadPatch. That document is 1.15 MB, and building it the first time takes the backend about 3.3 s of CPU. This PR has the thread list responses the sidebar already loads say the same thing in one boolean, and keeps the schema probe for backends that do not send it.What changes
routes/chat_history.py:THREAD_PATCH_GUARDSis computed fromChatThreadPatch.model_fields, the same model the schema probe reads, so the two answers cannot differ. It is sent asthreadPatchGuardsonGET /api/chat/threadsandPOST /api/chat/sidebar/rows. No other field or status code changes.chat-api.ts:listChatThreadsandfetchSidebarRowsnote the flag when the response carries a boolean.repair-legacy-chat-titles.tsuses it when present and otherwise runs the unchanged/openapi.jsonprobe, including its rule that a failed fetch is not cached.true, the same verdict the schema gives, so the repair runs exactly as before, minus the schema fetch./openapi.jsonstill declares both guard fields.Results
main.app.openapi()on this branch: 1,151,343 bytes compact JSON, 3.28 s for the first build on this host. With the flag present, the repair no longer requests it. Nothing else in the frontend fetches/openapi.json.Tests
studio/backend/tests/test_chat_thread_patch_guards_flag.py(4): both list responses carrythreadPatchGuards: true, the flag equals what the schema probe reads, and the flag followsChatThreadPatch. All 4 fail on main and pass here.studio/frontend/tests/openapi-support.test.ts, 5 new cases: flag read and malformed input, an advertised flag never calls the probe, a missing flag runs the probe and returns its answer unchanged, flag and schema agree. On main the file fails to import the new helpers; here 11 of 11 pass.test_chat_history_routes.py,test_chat_history_storage.py,test_chat_sidebar_rows.py,test_chat_thread_settings.py,test_rag_thread_document_cleanup.py,multi_account/test_routing_invariance.py,test_keyless_api_access_adversarial.py): same failing test IDs as main. The 21 failures intest_rag_thread_document_cleanup.pyhappen on main too, because this host has nosqlite-vec.node --testrun: the failing test names are the same as on main exceptopenapi-support.test.ts, which now passes. The other failures are files that neednode_modules, which this checkout does not have, on both sides.Not covered
/openapi.jsonis no longer requested follows from the call sites above, but no network panel was checked.Verification
/chatreload with seeded threads:/openapi.jsonrequests 1 -> 0;GET /api/chat/threadsreturnsthreadPatchGuards: trueon this branch and omits it on the base. Chat endpoint request counts are otherwise identical; the only other moved counts are timer polls (/api/inference/status,/api/hub/*) inside the fixed settle window. No visible UI change.tests/studio/test_legacy_chat_title_repair.pyasserted the old probe text and failed here; it now also asserts the advertised flag decides first (passes here, fails against the base source). Five frontend tests that loadchat-api.tsthroughloadWithStubsneeded a stub for the new../utils/openapi-supportimport (28 failures before, 0 after).node --test: 14260 pass / 0 fail here, 14255 / 0 on the base. Backend chat tests and every repo-root test reading these files: same results as the base.