Skip to content

Studio: stop New chat from requesting a thread row that does not exist yet - #12539

Merged
danielhanchen merged 3 commits into
unslothai:mainfrom
oobabooga:studio-skip-new-chat-thread-read
Oct 3, 2026
Merged

danielhanchen merged 3 commits into
unslothai:mainfrom
oobabooga:studio-skip-new-chat-thread-read

Conversation

@oobabooga

Copy link
Copy Markdown
Member

Opening or refreshing New chat sends requests for a chat thread that does not yet exist in storage. The requests come from looking up the chat's project and counting tokens for context usage, and produce unnecessary 404s in the browser console.

The storage layer now returns an absent thread or an empty message list without making these requests while the chat is still new:

  • It identifies the new chat using assistant-ui's newThreadId. The __LOCALID_ prefix is insufficient because saved chats keep that prefix.
  • Backend reads resume when chat initialization clears newThreadId.
  • Reads also go to the backend once a thread write has started. This handles code-execution settings that can create the thread before the first message is sent.

Validation

Live A/B on Linux in headless Chromium, comparing main and this branch with unsloth/gemma-3-270m-it-GGUF Q8_0:

Action 404s on main 404s with this PR
New chat load or refresh, no model 2 each 0
New chat refresh, model loaded 8 each 0
First send 3 1
Opening a saved chat 0 0

On both builds, normal chats and chats within projects preserved their user and assistant messages after reopening, sending a follow-up, and reloading. Project assignments remained correct. Compare view opened successfully, and neither build raised JavaScript exceptions.

  • All 24 focused tests passed, covering skipped reads, the transition out of new-chat state, writes before first send, and registration and cleanup for multiple runtimes.
  • Full frontend suite: 9711 of 9732 tests passed. Of the 21 failures, 20 also occurred on main. The remaining test, codex-learned-capabilities-survive-sync.test.ts, is intermittent and does not import chat storage.
  • Typecheck passed. ESLint reported no new issues in changed files.

Remaining limitations

  • Saving each new user message still produces a separate message-lookup 404.
  • Empty-chat token counting still runs and returns two 503s with a model loaded on both builds.
  • Two-model generation in compare view, Windows, macOS, and the desktop app were not tested.

…thread-read

# Conflicts:
#	studio/frontend/src/features/chat/utils/chat-history-storage.ts
@oobabooga

Copy link
Copy Markdown
Member Author

Reached Codex review convergence at oobabooga#327.

@danielhanchen

Copy link
Copy Markdown
Member

The Frontend build + bundle sanity failure (over the startup budget: transfer 1800.x KB > 1796.9 KB) is main's, not this PR's: #11491 pushed main's eager startup bundle past the budget. #12560 re-measures it; a re-run or push after it lands should clear the check.

@danielhanchen

Copy link
Copy Markdown
Member

Review record for #12539, carried over from the mirror it was reviewed on: danielhanchen/unsloth-staging-review#335.

Findings are quoted as posted and attributed to the account that posted them. The reactions shown are the triage recorded on the mirror; none were re-applied here. Commits are named as the mirror's, with this PR's equivalent where one was found.

Round 1: reviewed mirror c22dc0155 (no equivalent commit found on this PR)

chatgpt-codex-connector[bot] (on the mirror)

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: c22dc01558

No triage reaction was recorded on the mirror

Verdict

The round converged at mirror c22dc0155 (no equivalent commit found on this PR).

This is the review as it stood at that commit. Anything pushed to this PR afterwards was not part of it.

@danielhanchen
danielhanchen merged commit 8c344a6 into unslothai:main Oct 3, 2026
JoshuaL3000 pushed a commit to JoshuaL3000/unsloth that referenced this pull request Oct 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants