Skip to content

studio: render a chat send without waiting on persistence - #8136

Merged
danielhanchen merged 56 commits into
unslothai:mainfrom
mahiatlinux:fix/studio-composer-send-latency
Aug 10, 2026
Merged

danielhanchen merged 56 commits into
unslothai:mainfrom
mahiatlinux:fix/studio-composer-send-latency

Conversation

@mahiatlinux

Copy link
Copy Markdown
Contributor

What

Sending the first message in a new chat cleared the composer, then left the thread blank for a
second or more before anything appeared. This makes the message render immediately and fixes the
defects found along that path.

Why the send stalled

LocalThreadRuntimeCore.append in assistant-ui awaits the thread-list item's initialize promise
before adding the message to its repository, and BaseComposerRuntimeCore.send has already
emptied the composer by then. createStudioDbAdapter.initialize wrote the thread row before
resolving, so every round trip it made sat between the composer clearing and the first paint.

Fixed

The send blocked the first paint. initialize now returns the thread id straight away and
registers the row write through trackStoredChatThreadRecord. The user message and the assistant
placeholder render in microtasks. The model run still waits for persistence through the existing
history-append gate, so a failed write cannot leave an orphan run.

The user message flashed when the response started. Thread keyed
GeneratedImageOverlayProvider on the app's activeThreadId, which flips from "default" to the
thread id the moment the first message persists. That remounted the whole message tree and
replayed the user bubble's animate-in classes. It keys on assistant-ui's threadListItem.id
now, stable across that transition and still changing on a real thread switch.

The prompt queue's model correction was silently dropped. thread.tsx corrects a fresh
thread's modelId to the model captured for the queued run. With the row write no longer
complete at that point, updateStoredChatThread returned undefined and the patch never applied,
so the thread persisted with the live global model instead. ensureStoredChatThread now awaits
any in-flight row write, which keeps the guarantee at one choke point rather than asking every
initialize caller to remember it.

ensureThreadRecord listed every thread to answer an existence question, twice per call
through listStoredChatThreads. It uses a getStoredChatThread point lookup, so first-send cost
no longer scales with how many chats exist.

The history append made five round trips to write one message. It called
ensureStoredChatThread on a record getStoredChatThread had already resolved, and fetched the
entire thread history to find one message's createdAt. It now reads the thread and the message
together and looks the message up by id.

listStoredChatThreads listed threads twice on every call, the second read covering threads
the legacy Dexie import might have added. legacyChatImportGeneration tracks whether that import
actually created any, so the re-read happens only when it did.

routes/chat_history.py ran blocking sqlite on the event loop. The handlers were async def
calling synchronous studio.db functions, so a thread listing serialised behind model loads and
status probes. They are sync defs now and run in Starlette's threadpool, matching
save_thread_message and replace_thread_messages in the same file.

Verification

Manually tested end to end in the desktop UI: new chat, first send, streaming response, prompt
queue, thread switching, and reload.

ruff check and scripts/run_ruff_format.py clean. 237 backend tests covering chat history
routes, attachments, research runs, parallel slots, and logging middleware. 900 frontend tests.
tsc -b clean. biome check reports the same diagnostics as the base commit on all three changed
frontend files.

test_route_handlers_are_sync guards the threadpool conversion, and the tests that drove those
handlers through asyncio.run call them directly now.

GPU checks were not run: nothing here touches a model path.

Sending the first message in a new chat cleared the composer, then left the thread blank for
a second or more before anything appeared.

assistant-ui's LocalThreadRuntimeCore.append awaits the thread-list item's initialize promise
before adding the message to its repository, and the composer has already emptied by then. The
Studio adapter's initialize wrote the thread row first, so the whole stall sat between the
composer clearing and the first paint.

createStudioDbAdapter.initialize now returns the thread id straight away and registers the row
write through trackStoredChatThreadRecord. The user message and the assistant placeholder render
in microtasks. The model run still waits for persistence through the existing history-append
gate, so a failed write cannot leave an orphan run.

ensureStoredChatThread awaits any in-flight row write, which keeps the guarantee at one choke
point instead of asking every initialize caller to remember it. Without that, the prompt queue's
model correction in thread.tsx silently dropped its patch: updateStoredChatThread returned
undefined for a row that had not landed yet, and the thread persisted with the live global model
rather than the model captured for the queued run.

Three round trips also left the send path:

- ensureThreadRecord answers "does this thread exist" with getStoredChatThread instead of listing
  every thread, so it no longer scales with how many chats exist
- the history append reads the thread and the message together, and looks the message up by id
  rather than fetching the whole thread history
- listStoredChatThreads re-reads after the legacy import only when that import actually created
  threads, tracked by legacyChatImportGeneration

Handlers in routes/chat_history.py are sync defs so Starlette runs studio.db's blocking sqlite in
its threadpool. As async defs they ran it on the event loop, where a thread listing serialised
behind model loads and status probes. test_route_handlers_are_sync guards the conversion, and the
tests that drove those handlers through asyncio.run now call them directly.

Thread keyed GeneratedImageOverlayProvider on the app's activeThreadId, which flips from "default"
to the thread id the moment the first message persists. That remounted the whole message tree and
replayed the user bubble's animate-in classes just as the response started. It now keys on
assistant-ui's threadListItem.id, which is stable across that transition and still changes on a
real thread switch.

Verified with ruff, 237 backend tests, 900 frontend tests, tsc, and biome. GPU checks were not
run: none of this touches a model path.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

Deleting a thread now waits for a row write that initialize() started, so an in-flight upsert
cannot land after the DELETE and resurrect an empty thread that nothing later cleans up.

Overlapping initializations chain in trackStoredChatThreadRecord instead of replacing the tracked
promise. Waiting on only the newest upsert let a slower one finish afterwards and overwrite a
modelId a queued run had already corrected.

backfillLegacyThreadFields bumps the listing generation when it restores a container binding.
Only the row-creation branch bumped it, so listStoredChatThreads skipped its re-read and returned
the pre-backfill record, and the OpenAI container cleanup in openai-code-exec-section could miss a
thread still bound to a deleted container.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

…on on commit

awaitStoredChatThreadRecord read the tracked entry once, so a creator registered while it was
already waiting was missed and a delete could still beat that upsert. It drains until the entry
stops changing, reporting the last outcome so a thread nobody wrote is still the failure case.

backfillLegacyThreadFields bumps the generation after the patch commits rather than before. A
listing that captured the bumped value while the request was in flight read the old row, then
skipped its re-read because the generation never moved again.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

ThreadDocumentsBar treated a resolved initialize() as proof the thread was persisted. Since
initialize() now returns before the row write, a failed thread POST no longer reached the catch:
the bar reported success, indexed documents against a thread id that was never created, and left
the user without the error toast. Awaiting the tracked creation restores the previous behaviour
for this consumer while the message path keeps rendering immediately.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

A transient failure in the row write left the chat permanently broken. initialize() had already
resolved, so assistant-ui cached the remote id and never asked the adapter for the row again, and
ensureStoredChatThread can only read or import an existing row. Every later message write then
returned 404 until the user abandoned the chat.

trackStoredChatThreadRecord takes a creator rather than a promise and keeps it when the write
rejects. ensureStoredChatThread re-runs it once the reads confirm the row is genuinely absent,
which restores the retry that rejecting from initialize() used to provide.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

Waiting on the tracked write was not enough. After a failed row write the tracked promise is
already gone and assistant-ui returns its cached initialize() result, so a retried attachment
resolved immediately and indexed documents under a thread id with no chat row.

The bar now goes through ensureStoredChatThread, which reads the row and re-runs a failed creator
before reporting success, so the failure reaches the existing catch and its toast. Temporary chats
are exempt: they never persist a row, so isThreadIncognito skips the check.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

Only per-id deletion waited for a tracked row write, so clear-all could race one. The DELETE
finished first and the POST recreated the thread, and because the inventory clearStoredChats
builds comes from a listing taken before that POST landed, the thread was never tombstoned either
and survived the clear outright.

The drain runs before that listing so a freshly written row is both visible and removed, and it
discards failed creators so a later retry cannot recreate what the user just cleared.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: bf64e5b05e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

ensureStoredChatThread awaits awaitStoredChatThreadRecord before its reads, and that
rethrows a rejected row write. The retryFailedThreadRecord branch further down never
runs for a caller that was already waiting when the write failed, so a recoverable
write surfaced to it as a rejection instead.

updateStoredChatThread is the visible one: a rename or an archive over a row write
that had just failed rejected rather than retrying the creator and applying. The next
call did recover, because the failed creator stays registered, but only after the
first one had already thrown.

Waiting on the tracked write is still correct, adopting its failure is not: the reads
below already decide whether the row exists, and retryFailedThreadRecord re-runs the
creator when it does not.
Deleting a thread and clearing history both wait for a tracked row write so an
in-flight upsert cannot land afterwards and resurrect what was just removed. Neither
wait had a bound, and authFetch sets no timeout or AbortSignal, so a request the
backend never answers blocked both for as long as the browser took to give up.

Before the drain existed there was nothing to wait on, so this is reachable only on
this branch: a wedged POST /api/chat/threads left the user unable to delete that chat
or to clear history at all.

Both paths now give up after 5s and proceed. That is safe: deleteStoredChatThreads
tombstones the ids, so a row landing late is masked from every read and removed by
the next delete.
@shimmyshimmer

Copy link
Copy Markdown
Member

Went through this one carefully and pushed two fixes to the branch. Both are on the
tracked-row-write path, and both only became reachable once initialize() stopped
awaiting the write, so neither is a pre-existing issue.

1. ensureStoredChatThread rejected instead of retrying

ensureStoredChatThread awaits awaitStoredChatThreadRecord before its reads, and
that rethrows a rejected row write. The retryFailedThreadRecord branch further down
is then unreachable for any caller that was already waiting when the write failed, so
a recoverable write reached it as a rejection.

Ordering decides which behaviour you get, which is why it is easy to miss:

  • write fails, settles, gets forgotten, then ensureStoredChatThread runs: the
    pending entry is gone, the await is a no-op, the retry runs. Fine.
  • ensureStoredChatThread is already inside the await when the write rejects: it
    adopts the failure and returns before ever reaching the retry.

updateStoredChatThread is the visible one. A rename or an archive over a row write
that had just failed rejected rather than retrying the creator and applying. It does
self-heal on the following call, since the failed creator stays registered, but only
after the first one has already thrown.

Waiting on the tracked write is right, adopting its failure is not. The reads below
already decide whether the row exists.

2. The wait on a row write had no bound

deleteStoredChatThreads and clearStoredChats both wait for the tracked write so a
late upsert cannot resurrect what was just removed. Neither wait was bounded, and
authFetch sets no timeout and no AbortSignal, so a request the backend never
answers blocks both for as long as the browser takes to give up.

A wedged POST /api/chat/threads left the user unable to delete that chat, and unable
to clear history at all. Before the drain existed there was nothing to wait on, so
this only exists on this branch.

Both now give up after 5s and proceed. Safe, because deleteStoredChatThreads
tombstones the ids, so a row that lands late is masked from every read and removed by
the next delete.

How I checked

I stood up a rig that imports the real chat-history-storage.ts from main and from
this branch side by side, against a fake backend where I can hold a request open,
release it, or fail it on demand. That is what it takes to hit these: both are
ordering bugs that need the write to fail or hang at a specific instant.

48 scenarios, run against the branch before and after the fixes:

  • both defects reproduce on the branch and are gone after, and main is clean for
    the second one, which is what makes it a regression rather than a pre-existing bug
  • the races this PR already closes stay closed: delete vs in-flight write, clear-all
    vs in-flight write, overlapping initialize() keeping the queued-run modelId,
    the retry after a failed write, temporary chats never persisting
  • no unhandled rejections under an abandoned-chat storm or 200 concurrent
    initializations, and the pending map drains in every path

Also ran it in real browsers, since this is all promise plumbing and engines differ
there. Chrome, Firefox, Safari and Brave, 12/12 each, bundled at the app's actual
vite target and again at es2020 for margin.

Backend side, I confirmed the async def to def conversion does what it says using
the real router: max event loop stall over a burst of thread listings drops from
26.9ms to 6.5ms with 300 chats. Instrumenting studio_db shows main peaking at 1
concurrent DB call on 1 thread versus 40 across 40 threads here, so the serialisation
really is gone. Hammered the new concurrency with overlapping upserts, patches,
deletes and forks looking for database is locked, lost updates or orphaned
messages, and found none, which tracks since every write is a single atomic statement
with CAS where it matters.

Two things worth knowing, neither blocking

Concurrent listings get slower. 12 simultaneous GET /threads went from 21ms on
main to 281ms here. Not lock contention and not the pool: CPython's sqlite3 drops
and re-acquires the GIL once per row, so concurrent readers of a large result set
convoy on the handoff. It scales with row count (1 row is ~1x, 1000 rows is ~35x) and
the cliff starts around 6 concurrent readers. Studio's real pattern tops out near 5,
and on the actual tab-open and first-send sequences main and this branch measured
indistinguishable (4.9ms vs 4.8ms). Worth knowing before anything starts fanning out
chat-history reads, and the lever is fewer rows per response, which this PR already
moves toward.

getStoredChatThread is not gated on the tracked write. I chased whether
generateTitle could read a row that has not landed. It cannot: assistant-ui fires it
from a runEnd handler, and the run is already gated on the write. Leaving it as is,
just noting it so the next person does not have to re-derive it.

Ask

Can we get the tracking logic under test in the repo's own suite before this merges?
trackStoredChatThreadRecord, awaitStoredChatThreadRecord, the drain and the retry
are the subtle part of this change and currently have no coverage there, which is what
let both of these through. It needs a bit of setup, since the runner is bare
node --experimental-strip-types --test and the module uses extensionless imports
plus Dexie, so a small loader hook and stubs are needed. Happy to push that too if you
would rather I just did it.

Otherwise this looks good to me. Nice find on the initialize() stall, the diagnosis
through LocalThreadRuntimeCore.append is exactly right.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

retryFailedThreadRecord consumed the stored creator before starting its retry, so a second caller
arriving in that window found no creator, reported the row absent and returned without waiting.
updateStoredChatThread then dropped its patch and saveStoredChatMessage raced its PUT against the
retrying POST. It now falls through to the pending write when the creator is already claimed.

That retry also swallowed its own failure. Returning undefined reads as no row to update, which is
how the prompt queue permanently clears shouldCorrectPersistedModel and leaves the thread carrying
the live checkpoint instead of the one captured for the queued run. The failure propagates now.

A write that outruns the bounded wait still commits, and a local tombstone only hides the row
here while the backend keeps serving it. deleteLateThreadRecords issues a second delete once such
a write settles, for both the per-id path and clear-all.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

…l stable

A write in flight when history was cleared still ran its rejection handler afterwards, which
recorded its creator again after the map had been emptied. The uncommitted thread was in neither
inventory so it got no tombstone either, and the next ensureStoredChatThread consumed that creator
and recreated a thread the user had cleared. Creators now carry the clear epoch they were
registered under and only record themselves while it still matches.

deleteLateThreadRecords also snapshotted the tracked promise once, so a creator chained on after
that snapshot was missed and the follow-up DELETE could run before the newer write committed. It
waits through awaitStoredChatThreadRecord instead, which drains until the entry stops changing.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

…t point imports

Overlapping initializations with mixed outcomes each recorded a retry creator, including the ones
whose sibling had already persisted the row. Nothing cleared them on success, so if that row was
later removed without this tab taking a tombstone, the next autosave consumed a stale creator and
recreated a deleted chat. A resolved tracked write now drops them.

importLegacyThread also creates a backend row without moving legacyChatImportGeneration, so a
listing that read before a point-lookup import could skip its re-read and, once the import hint
was set, drop the legacy copy too, returning a list missing the recovered thread.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

…ion across a clear

The point-import generation bump lands only when the POST promise resolves, not when its commit
becomes visible to other requests, so a listing holding a stale first read could compare an
unmoved generation and skip its re-read. With the import hint set it then drops the legacy copy
too, returning a list missing the recovered thread. Listings now await imports already in flight.

ThreadDocumentsBar also kept waiting through a clear that had given up on its thread POST. The
follow-up delete then raced the upload, and upload_thread_document does not check that the chat
row exists, so documents stayed indexed after a reported successful clear. The bar captures the
clear boundary and abandons materialization when it moves.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

…eanup

The late-cleanup list was snapshotted before the drain, so a chat initialized while the drain was
running, whose write also outlived the deadline, was in neither that list nor the backend
inventory the clear builds. It took no tombstone and no follow-up delete, and reappeared after a
successful clear. The list is now the union of the pre-drain ids and whatever is still pending
when the drain gives up.
@mahiatlinux

Copy link
Copy Markdown
Contributor Author

@codex review

@unslothai unslothai deleted a comment from mahiatlinux Aug 10, 2026
@unslothai unslothai deleted a comment from mahiatlinux Aug 10, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 10, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 10, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 10, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 10, 2026
@unslothai unslothai deleted a comment from mahiatlinux Aug 10, 2026
@unslothai unslothai deleted a comment from mahiatlinux Aug 10, 2026
@unslothai unslothai deleted a comment from mahiatlinux Aug 10, 2026
@unslothai unslothai deleted a comment from mahiatlinux Aug 10, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 10, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 10, 2026
@unslothai unslothai deleted a comment from oobabooga Aug 10, 2026
@unslothai unslothai deleted a comment from oobabooga Aug 10, 2026
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ba0f6e0600

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment on lines +70 to +76
} catch (error) {
// A backend tombstone is an answer, not an indeterminate transport failure: indexing
// against it would leave documents under a thread that can never come back.
if (error instanceof ChatThreadDeletedError) {
throw error;
}
return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject definitive thread-creation failures before upload

When the background thread creation fails with a definitive non-410 HTTP response—such as 404 Project not found after its project is concurrently deleted—ensureStoredChatThread rejects with a generic error and this catch treats it as an indeterminate transport failure. The upload then proceeds even though upload_thread_document does not validate the chat thread, leaving a RAG document indexed under a thread ID that has no chat row. Only genuinely ambiguous transport failures should be allowed through; known HTTP failures should block the upload.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving this one. The 410 case was worth separating because the retry produces a typed error that says the thread is definitively gone. A generic non-410 failure does not carry that, so telling definitive from indeterminate here means classifying HTTP status through saveChatThread into a second error type, and the window it buys is a project deleted between a first send and the document upload attached to it, with orphaned rag_sources rows as the cost rather than lost user content. That is not worth another error class in this path, and the current shape is the one the bar deliberately settled on in ba5b088: a failure that is not proof the row is missing lets the upload through. Happy to revisit if there is a path where the orphaned rows matter beyond the row count, or if a definitive-failure signal shows up in the API layer for another reason.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@danielhanchen

Copy link
Copy Markdown
Member

Ran the review loop over four rounds today and pushed six commits. Everything Codex raised is
triaged and answered; the PR now stops on one thing that is yours to decide, at the bottom.

Rounds

Round one had 19 un-reacted items, all but two of them describing the design d24aa9b replaced:
the per-thread delete queues, the settle-batch timeout, the fallback DELETE, the drain, the
pending-cleanup confirmation. Those are 👍 with a pointer to what retired them, since the rewrite
closed the class rather than the instance. The rest across the four rounds:

item verdict
Bound delete reconciliation reads fixed in 07e0ff6
Treat cancelled ingestion jobs as terminal during startup fixed in 505da99
Keep admission closed after a timed-out clear fixed in ba0f6e0
Reject deleted-thread errors before document upload fixed in ba0f6e0
Signal only claimed planning runs during deletion fixed in ba0f6e0
Avoid re-signalling runs when replaying a clear fixed in 4459dff
Preserve workspaces when project deletion keeps files fixed in 4640434
Check document deletion before handling empty ingests fixed in 4640434
Hold the deletion guard through replacement retirement fixed in 99a9e76
Allow clear-all to fence more than 10,000 threads fixed in 99a9e76
Fence failed initializers before clearing their registry 👎, the premise does not hold
Reject definitive thread-creation failures before upload 👎, below the bar

Four of these are worth calling out because they are not independent findings.

The propagation regression. 7b74fda made a failed row write rethrow, with the comment
"Rethrows on purpose. A caller handed undefined reads it as no row to update and drops its patch".
d24aa9b swapped the waiter that carried the outcome for awaitStoredChatThreadWrites, which is
Promise.allSettled and never throws, and the guarantee did not come back with the comment. The
consequence is the one you documented: thread.tsx clears shouldCorrectPersistedModel right
after the awaited updateStoredChatThread, so a permanently failed write silently dropped the
queued run's model correction. Restored in 84bd870, with
test_a_failed_thread_row_write_surfaces_to_the_patch_caller pinning it.

Two follow-ups came from that restore. The document bar's catch had been swallowing the
retry's rejection, which only became reachable once the retry could reject at all, and
generateTitle moved to ensureStoredChatThread in this PR, so it needed a catch of its own
rather than letting a cosmetic title reject a runEnd handler. Both landed alongside it.

The clear retry then produced its own. Retrying the same operationId on a timeout is what
closes the P1, but it also made the replay path routine, and the replay was re-signalling research
runs whose workers had already exited. Fixed in 4459dff.

Verification

Two Playwright browsers' worth of assertion is not enough for promise plumbing, so the ordering
work runs against the real chat-history-storage.ts with a fake backend where a request can be
parked, released or failed at a chosen instant, one fresh module instance per scenario. 34
scenarios, in node and in Chromium 151, Firefox 153 and WebKit 26.5, which between them cover
Chrome and Edge, the WebView2 the Windows build embeds, and the WKWebView and WebKitGTK the macOS
and Linux builds embed. 34/34 in all four. Every fix above has a scenario that fails on the commit
before it.

Alongside that: 23 checks on the schema and old installs, driving one studio.db from a main
worktree and this branch in separate processes (upgrade, downgrade, the intermediate
deleted_thread_ids_json shape, 16 threads racing first-launch schema init); 28 on the HTTP
contract and concurrency against the real router, including the old no-body DELETE /api/chat, the
operationId replay, and a clear-all loop racing 150 concurrent writes; and 13 on platform
behaviour, using ntpath for the Windows path rules this host cannot run.

Staging CI on an owned repo, so the org queue keeps its slots: Backend, Frontend, Startup profile,
Mac Studio UI + API + Update, Mac Studio GGUF and Windows GGUF all green. Cross-platform:
ubuntu-latest, windows-latest and the studio-live Playwright workflow green; macos-14 red only
because that runner's Python cannot load sqlite extensions, so every RAG test errors on
enable_load_extension. Ubuntu ran the identical file list and reported 229 passed, and the same
tests pass here with sqlite-vec installed. One earlier Mac UI failure and one Backend CI failure
were both flakes: a 5s Playwright expect on a composer pill, and a wall-clock
assert elapsed < 1.0 that measured 1.03s in test_research_runs_hardening.py, which this PR does
not touch. Both green on re-run.

What stops this from converging

The branch no longer merges. pre-commit.ci is red on "merge conflict", not on a hook, and
mergeStateStatus is DIRTY. #8256 landed on four of the same files, and one of the conflicts is a
real design question rather than a mechanical overlap: upstream's delete_threads is an
async def that await run_in_threadpool(...)s the new sandbox-folder cleanup and
collect_orphaned_project_workspaces, while this PR converts those handlers to sync defs and
guards that with test_route_handlers_are_sync. Resolving it means deciding how the new cleanup
runs under the sync-handler contract, and I would rather you made that call than have me pick one
and bury it in a merge commit on your branch. The other three conflicts
(studio_db.py, chat-api.ts, chat-history-storage.ts) looked mechanical next to it.

Once that merge is in, the loop is otherwise clean: no un-reacted items, fixcheck OK, and every 👍
has a fix commit behind it.

Still open, unchanged

Tombstones are never pruned server-side. deleted_at and cleared_at are written and never read,
and clear-all does not drop the table, while the browser half in chat-thread-tombstones.ts
already GCs at 90 days with a 5000 cap. Worth a retention pass on the server side eventually.

Partial-clear reporting still calls legacy-only threads failed when the backend clear fails but
Dexie succeeded. Your call, left alone.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 99a9e76474

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 99a9e76474

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants