Skip to content

Support independent multi-chat prompt queues - #6985

Closed
Imagineer99 wants to merge 184 commits into
unslothai:mainfrom
Imagineer99:feat/multi-chat-queue-support
Closed

Imagineer99 wants to merge 184 commits into
unslothai:mainfrom
Imagineer99:feat/multi-chat-queue-support

Conversation

@Imagineer99

@Imagineer99 Imagineer99 commented Jul 8, 2026 •

Copy link
Copy Markdown
Member

Summary

  • replace the singleton prompt queue with per-chat queue runs keyed to exact thread runtimes
  • add a round-robin coordinator with global queue concurrency so background chats advance fairly
  • keep queue state and sidebar indicators scoped per queue run/thread to avoid cross-chat leakage
  • allow navigation/new chat without cancelling background queue runs

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the prompt queue system to support multiple concurrent queue runs per chat thread rather than a single global queue, introducing a new Zustand store and updating the sidebar to show activity indicators for active queues or unread threads. The review feedback is highly constructive, suggesting defensive improvements such as adding a maximum retry limit to prevent infinite loops on dispatch errors, filtering active thread records to guard against false values, and defensively checking for the existence of threadIds on sidebar items to avoid potential runtime crashes.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

I am having trouble creating individual review comments. Click here to see my feedback.

studio/frontend/src/components/assistant-ui/thread.tsx (295-307)

high

If item.target.append throws an error repeatedly (e.g., when the thread runtime is permanently unavailable or deleted), the queue will retry indefinitely every 500ms. Implement a maximum retry limit to prevent infinite background CPU/timer loops.

function appendQueuedPrompt(run: PromptQueueRun, item: PromptQueueItem) {
  item.dispatched = true;
  promptQueueActiveRunIds.add(run.id);
  syncPromptQueueUI();
  try {
    item.target.append(item.prompt);
  } catch (error) {
    item.dispatched = false;
    promptQueueActiveRunIds.delete(run.id);
    syncPromptQueueUI();
    const maxRetries = 5;
    item.retries = (item.retries ?? 0) + 1;
    if (item.retries > maxRetries) {
      console.error("Prompt queue dispatch failed permanently:", error);
      deletePromptQueueRun(run);
    } else {
      scheduleQueuedPromptDispatch(run, item, 500);
    }
  }
}

studio/frontend/src/components/assistant-ui/thread.tsx (364-369)

medium

Defensively count only active/running threads by filtering the values of runningByThreadId. This guards against any potential false values remaining in the record keys.

function getPromptQueueActiveGenerationCount() {
  return Math.max(
    Object.values(useChatRuntimeStore.getState().runningByThreadId).filter(Boolean).length,
    promptQueueActiveRunIds.size + promptQueueDispatchingRunIds.size,
  );
}

studio/frontend/src/components/app-sidebar.tsx (266-268)

medium

Defensively check if item.threadIds is defined before accessing its length property to prevent potential runtime crashes with legacy or mocked sidebar items.

function getSidebarItemThreadIds(item: SidebarItem) {
  return item.threadIds && item.threadIds.length > 0 ? item.threadIds : [item.id];
}

@Imagineer99
Imagineer99 marked this pull request as ready for review July 9, 2026 11:47

@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: 9fb1f12046

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@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: d8e0dddd70

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

requestPromptQueueStop();
stopChatRun(mainThreadId);
}
const switchResult = aui.threads().switchToThread(threadId) as unknown;

ghost Jul 10, 2026

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 Scope compare waits to the compare panes

When switching chats no longer cancels the previous run, an unrelated background thread can remain in runningByThreadId while the user opens or runs a general compare. RegisterCompareHandle.waitForRunEnd in studio/frontend/src/features/chat/shared-composer.tsx waits for Object.keys(state.runningByThreadId).length to become zero, so Model 2 will not start until every background chat finishes, not just the compare pane that was started. Scope that wait to the handle's own thread id or otherwise ignore unrelated background runs.

Useful? React with 👍 / 👎.

requestPromptQueueStop();
stopChatRun(mainThreadId);
}
const switchResult = aui.threads().switchToThread(threadId) as unknown;

ghost Jul 10, 2026

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 Gate sends while another chat is running

With this switch now leaving the previous generation alive, the newly visible composer can still submit immediately because Composer.handleSubmit only checks the current thread's threadIsRunning. If a user switches away from a generating chat and presses Send in another chat, this bypasses the prompt queue's global concurrency of 1 and starts a second model request while the hidden run is still in runningByThreadId; route that send through the queue or disable it until global capacity is available.

Useful? React with 👍 / 👎.

Comment on lines 307 to 309
item.dispatched = true;
promptQueueActiveRunIds.add(run.id);
syncPromptQueueUI();

ghost Jul 10, 2026

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 Release queue capacity when dispatched runs fail early

After adding the run id to promptQueueActiveRunIds, capacity is only released by a later runningByThreadId transition or a synchronous append throw. If the queued run fails inside the adapter before it calls setThreadRunning(true) (for example no model can be auto-loaded, or model loading aborts), thread.append does not throw synchronously and no running-state transition arrives, so this run id stays active and PROMPT_QUEUE_GLOBAL_CONCURRENCY = 1 stalls every other prompt queue. Clear the active id on run errors or subscribe to the thread/run end signal for this dispatch.

Useful? React with 👍 / 👎.

ghost 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: 86ccc28f95

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

const activeItem = getActivePromptQueueItem(run);
const activeTarget = activeItem?.target;
const shouldCancelActiveRun = Boolean(activeItem?.dispatched);
deletePromptQueueRun(run);

ghost Jul 10, 2026

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 Pump remaining queues after stopping an active run

When this stops a queue whose active item was already dispatched, deletePromptQueueRun frees the run from promptQueueActiveRunIds, but nothing requests another pump unless cancel() later produces a runningByThreadId decrease. If the user stops/archives/deletes during the window after appendQueuedPrompt marks the run active but before the adapter has called setThreadRunning(true), that decrease may never happen, leaving other ready per-chat queues idle even though global capacity is now free. Schedule a pump after deleting a dispatched run when other queues remain.

Useful? React with 👍 / 👎.

ghost 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: 2a8acaa12c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines 1926 to 1931
append: (prompt) => {
const thread = getThreadRuntime();
if (!thread) {
throw new Error("Prompt queue thread runtime is unavailable");
}
thread.append(appendTextToThread(prompt));

ghost Jul 10, 2026

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 Preserve temporary status for delayed queued prompts

When a user queues a prompt from a fresh Temporary chat but it dispatches later (for example because global queue capacity is occupied or the queued run waits for the delayed pump) and then leaves or starts a new chat before this append runs, the global incognito flag has already been reset. This append then initializes the thread under the non-temporary state in ensureThreadRecord, so the temporary chat can be saved to history instead of disappearing; capture the incognito state when creating the queue target or mark the thread before deferring dispatch.

Useful? React with 👍 / 👎.

Comment on lines +1875 to +1876
store.setThreadRunning(threadKey, true);
store.setThreadRunning(threadKey, false);

ghost Jul 10, 2026

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 Don't advance queues on pre-stream failures

For a queued dispatch that fails before the stream starts (missing API key, no loadable model, image edit gate, etc.), this synthetic on→off transition is indistinguishable from a successful run ending to handlePromptQueueRunState, which advances the queue and can submit every remaining prompt after the first failure. The fresh evidence is this new synthetic running pulse; release the reserved capacity on these errors without signaling a completed generation to the prompt queue.

Useful? React with 👍 / 👎.

Comment on lines +2016 to +2017
const promptQueueAtCapacity = !promptQueueHasCapacity();
if (threadIsRunning || promptQueueActive || promptQueueAtCapacity) {

ghost Jul 10, 2026

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 Apply the capacity gate to compare sends too

This global-capacity check only covers the regular chat composer; the compare SharedComposer still calls its handles directly, so if a user switches away from a generating chat and opens a compare, sending there can start additional model requests while the background run is still present in runningByThreadId. Mirror this gate in the compare composer or route those sends through the same queue/capacity path before starting compare handles.

Useful? React with 👍 / 👎.

stopChatRun(mainThreadIdRef.current);
// Switch to a fresh local thread without persisting it yet; persistence
// still happens on first message append.
void aui.threads().switchToNewThread();

ghost Jul 10, 2026

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 Keep background appends from reselecting old chats

Because New Chat no longer cancels the previous run before switching, a hidden old run or delayed queued prompt can append after this point; createStudioDbAdapter.append in this file still unconditionally calls setActiveThreadId(remoteId) for every base-chat append. In that case the background thread writes its id back into global state after the fresh chat set it to null, so the new-chat UI can start using the old thread id for composer draft/docs/queue bookkeeping; guard that active-thread update to the currently visible main thread.

Useful? React with 👍 / 👎.

Lee Jackson and others added 14 commits July 14, 2026 11:33
…unslothai#7117)

* Studio: make Stop interrupt a llama.cpp generation stalled mid-stream

* Studio: tighten stream-cancel comments

---------

Co-authored-by: danielhanchen <[email protected]>
…yle (unslothai#7077)

* Unsloth: appearance palettes, customization options, and control restyle

Adds Standard, Classic, and Minimal color palettes to Appearance settings,
each adapting to light and dark mode. Classic is a neutral enterprise look
that reserves its blue accent for toggles, badges, and focus rings; Minimal
is strictly black, grey, and white.

Adds customization options scoped to the active mode: accent, background,
and foreground colors with an in-app color picker, UI and code fonts with a
searchable dropdown covering bundled, device, and imported fonts, font file
import, UI and code font sizes, contrast, pointer cursors, reduce motion,
font smoothing, and translucent sidebar. Settings persist through the
personalization API with backend validation and sync across devices.

Restyles core controls for a cleaner, flatter look in both modes: bordered
white input fields, fully rounded pills for single-row controls, no drop
shadows, simple straight-line chevrons replacing all rounded arrow icons,
and consistent hover tones in dropdown menus. Popovers now portal into the
open dialog so their lists scroll correctly inside modal dialogs.

Moves Language into General settings and Chat defaults into the Chat tab
above the Canvas section.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Unsloth: appearance follow-ups, font options, and settings search

Neutralizes focus and selection rings across all palettes so highlighted
elements, including typing boxes and the selected palette card, never take
the accent color. The custom accent no longer recolors rings.

Restyles the color controls as filled pills showing the hex value inside,
with text and border contrast picked from the color's luminance. Menus in
popovers now match the app's dropdown menus: rounded-lg corners, tighter
padding, accent hover rows, and a bordered search field. Popovers inside
modal dialogs are modal so their lists scroll with the wheel. Outline
buttons share the same dark fills as dropdown triggers.

Adds heading and chat font options next to the UI and code fonts, each
using the searchable font dropdown and persisting through the
personalization API. Removes the translucent sidebar option end to end.

Adds settings search: a search field at the top of the settings sidebar
that filters setting names across every tab, grouped by tab with icons,
and jumps to the tab on click.

* Unsloth: use the shared accent token for dark hover fills

The settings dialog nav, its close button, the model selector, and the
project switcher hovered with hardcoded blue tinted greys (#3a3d43,
#2d2e32) in dark mode while every menu and sidebar uses --accent. All
hover and active pill fills now use the accent token so dark hovers are
the same everywhere and adapt to the active palette.

* Unsloth: settings search polish and jump to matched setting

Widens the settings dialog to 880px and the sidebar column to 248px so
the search field has more room. The search pill aligns with the left
start of the Settings title, gets more spacing above and below, and its
icon and placeholder sit slightly further left.

Search results now jump to the exact setting: rows and sections expose
their label as a data attribute, and picking a result opens the tab,
scrolls the matched row into view, and flashes it briefly.

* Unsloth: settings search bar spans the full nav pill width

The search field now starts and ends at the same edges as the nav hover
pills instead of being inset to the title text.

* Unsloth: address review findings on motion, sync, and font limits

Reduce motion Off now opts back out of the OS reduced-motion preference
for CSS animations via a force-motion class that the media rules skip,
and forcing reduce motion On keeps the loader exceptions (spinners,
loading dots, progress bars) animating.

When the color scheme follows the system, the resolved mode is now part
of the theme store snapshot, so an OS scheme flip re-renders consumers
and reapplies per-mode custom colors instead of leaving stale inline
variables from the previous mode.

Imported fonts get an aggregate size cap (4.4M characters) on both the
frontend sanitizer and the backend model so the persisted store always
fits browser localStorage quotas, with a clear error toast when an
import would exceed it. Backend validation also tightens imported font
names (rejects CSS delimiter characters) and requires strict base64
font data URLs, matching the frontend patterns.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Unsloth: profile toggle to hide the sloth in the chat greeting

Adds a Show greeting sloth switch to Settings > Profile. The chat welcome
hides the mascot when it is off. The preference persists locally and
through the personalization API, with backend validation and tests, and
the row is reachable from settings search in all four locales.

* Unsloth: control restyle, dropdown scrolling, and palette consistency

Settings sidebar puts search on top with the tab list under a small
Settings label. Combobox popups scroll with the wheel inside dialogs by
falling back to manual list scrolling while a dialog scroll lock is
active, and the local model selector popover became modal for the same
reason. Number inputs swap native spinners for a shared grey stepper
that clamps to min, max, and step. Run settings fields in light mode use
the same white fill and border as the settings dialog. Selection and
focus rings derive from each palette's border color instead of near
black, hover borders soften the same way, the Classic sidebar stays
white like Standard, decorative greens follow the palette accent, and
meaning-carrying marks like the hub verified badge keep the brand green
in every palette.

* Unsloth: palette card selection keyed off the palette attribute

Switching palettes restyles the whole page the moment data-palette lands
on the html element, but the React re-render that moves the selection
classes arrives later, so the ring and check briefly stayed on the
previous card with the new palette's colors. The active ring and check
now key off html[data-palette] in CSS, so they swap in the same style
pass that swaps the tokens. Also adds breathing room around the settings
search bar and under the Settings label, shortens the greeting sloth
description, and renames the avatar section to Or pick a sloth profile
picture in all locales.

* Unsloth: restore neutral rings, drop the palette check, sidebar spacing

Puts the ring tokens back to their fixed per palette values and removes
the hover border darkening, undoing the derived border experiment. The
selected palette card no longer shows a check since the ring already
marks it. The settings sidebar search bar, nav pills, and search results
get a little side padding, and the Settings label lines up with the pill
text.

* Unsloth: indicator restyle, sidebar menu customization, edge fade toggle

- Derive focus and selection rings from the border color so indicators
  stay 1px and adapt to every theme and palette
- Suppress mouse focus rings except on pressed controls to remove the
  selection flash on the avatar and palette pickers
- Defer settings panel rendering so the active nav pill updates instantly
- Customizable sidebar user menu with drag to reorder and shortcuts to
  the settings tabs
- Grey hover for the standard light palette instead of green
- Borderless controls in dark mode with fill based focus states
- Profile picture: no picture option, pencil edit icon, atomic selection
- Font dropdowns: narrower triggers and the resolved default shown as
  Inter Variable (Default)
- System prompt border darkens on focus
- New appearance setting to swap edge fades for thin divider lines
- Move the theme bootstrap to an external script to satisfy CSP

* Unsloth: harden theme boot and Firefox scroll container focus

- Guard the theme and palette storage reads separately so a blocked
  localStorage (private browsing) still resolves a mode from the OS
  preference instead of skipping the boot entirely
- Firefox makes scrollable containers keyboard focusable and drew its
  3px UA outline on them; swap it for the app's soft 1px indicator

* Unsloth: make the UI and code font settings reach the font utilities

The theme block declared the sans and mono stacks as literals, so
Tailwind inlined them into every font-sans and font-mono utility at
build time and the runtime overrides from Settings > Appearance never
applied. Reference the :root tokens instead, matching how the color
tokens already work.

* Unsloth: in-dropdown font upload, accent meters and avatar, naming cleanup

- Move font importing into each font dropdown: Upload and Select folder
  sit side by side under the list, imported fonts get an inline remove,
  and the standalone Import font row is gone
- Uploads reuse fonts the user already has (bundled, imported, or
  installed, matched by file name with style suffixes stripped) instead
  of embedding a duplicate copy; only new fonts are embedded
- Folder scan lists font files from a picked folder in every dropdown
  for the session; picking one imports it through the same path
- Fallback avatar uses the control accent with a readable foreground
  instead of the neutral primary that rendered black outside standard
- Monitor bars, progress defaults, sliders, and usage meters use the
  control accent; warning and danger tiers stay amber and red
- User facing strings that called the app just Studio now say Unsloth
  in all four locales, keeping Unsloth Studio and LM Studio intact

* Unsloth: left align the font upload actions and divide them

Upload and Select folder now read from the left like the list items,
with a short vertical rule between the two.

* Unsloth: keep sliders neutral and the chat greeting on Hellix

- Sliders are controls, not meters, so their fill goes back to the
  neutral primary instead of the palette accent
- The base h1 rule reads --font-heading with !important and the chat
  thread root resets that variable to the sans stack, which pulled the
  greeting off Hellix; restore the stack on the greeting element

* Unsloth: move the None avatar cell last and keep footer actions on one line

- None sits after the sloth pictures instead of leading the grid
- Upload shrinks to its label so Select folder no longer wraps

* Unsloth: size the folder action to its label

Both footer actions now hug their content so the hover pill does not
stretch across the leftover row width.

* Unsloth: separators only between unrelated settings clusters

Rows inside a titled section are related, so the per row divide-y is
gone from SettingsSection. A SettingsGroupDivider marks the two real
boundaries in the theme section (colors to fonts, fonts to contrast)
and the Clear all chats row gets its destructive border back now that
divide-y no longer draws one for it.

* Unsloth: balance the two font upload actions

Both actions share the footer row evenly again; nowrap keeps Select
folder on one line at the narrower width.

* Unsloth: drop the theme section dividers and split the chat menu groups

The colors, fonts, and contrast rows read fine without rules, and the
chat menu gains its one real boundary between the pin toggles and the
disclaimer rows.

* Unsloth: normalize oversized sidebar menus and reject newline font data URLs

Two backend validation fixes in PersonalizationCustomization:

- sidebarMenu refused any list longer than the number of distinct ids
  because Field(max_length) is enforced before the dedupe validator runs.
  A stale or duplicated payload that would normalize to one entry per id
  was rejected outright, defeating the normalizer that exists for exactly
  that case. Cap the incoming list at a generous multiple so it reaches
  the validator; a pathologically long list is still refused.

- The imported font dataUrl validator used re.match on a pattern ending
  in $, which also matches just before a trailing newline, so
  "data:font/woff2;base64,AAAA\n" passed even though the frontend JS
  pattern rejects it. Use re.fullmatch for parity.

Adds covering tests for both.

* Unsloth: preview fonts in their own typeface and slim the color pills

- Every font dropdown entry, the default item, and the closed trigger
  render in the font they name, falling back to the UI stack for
  families the browser cannot resolve
- Color swatch pills drop from 36px to 28px so they sit closer to the
  row label height

* Unsloth: drop the font row and theme section descriptions

The labels carry the meaning on their own; the mode switching note in
particular read long and confusing.

* Unsloth: let the chat greeting follow the heading font setting

The greeting stays on Hellix by default but adopts a chosen heading
font through a --custom-heading-font variable the applier sets only
while an override exists, so the thread root's sans reset for chat
prose no longer hides the user's pick from the greeting.

* Unsloth: divide the theme section clusters and align the color pill height

Separators return between colors and fonts and between fonts and
contrast, and the color pills share the 32px height of the font
dropdown triggers.

* Unsloth: color pills at half the dropdown width

Fixed w-24 against the w-48 font triggers, with tighter padding so the
hex value still fits.

* Studio: update dep-removal test after next-themes was replaced

The frontend no longer declares next-themes or imports it in src (it was
replaced by the custom theme store and boot script), so the checker now
reports its removal as a safe no-op. The C1 and C8 fixtures in
test_frontend_dep_removal.py still asserted next-themes was a used
dependency, which fails the studio frontend CI dependency-removal safety
check. Update C1 to expect a no-op PASS and drop next-themes from the C8
expected failures so the suite matches the checker's correct output.

* Studio: remove unused ageLabel and exportCollectionJsonl helpers

* Studio: fix blocked-storage theme desync, search jump race, font validation

- theme-store.ts: keep an in-memory currentTheme/currentPalette so a selected
  value survives when localStorage is blocked (private browsing). The snapshots
  previously re-read empty storage and reverted React state to the default while
  the DOM already changed. The matchMedia handler no longer re-reads storage, so
  it cannot clobber the in-memory choice; cross-tab storage events still adopt.
- settings-dialog.tsx: the search jump waited a single fixed 60ms for the
  deferred tab panel to render, then silently missed under render lag. Retry
  across animation frames until the target row exists, then scroll and flash.
- settings.py: apply the font-name character check to the four selected-font
  fields (uiFont/headingFont/chatFont/codeFont), and forbid backslash, comma,
  slash and control characters so a name cannot escape the quoted CSS
  font-family or smuggle extra fallbacks. Adds covering tests.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix appearance customization edge cases for PR unslothai#7077

- Reset all local preferences now also clears palette and appearance customization
- Number input wrapper keeps full width so fields fill their flex/grid cell, and the stepper stays pinned to the field edge
- Number stepper snaps to the min anchored step grid like the native spinner instead of leaving a step-invalid value
- Code font now applies to chat code fences and inline code via a dedicated token
- Reduce motion (on/off) is honored by onboarding/tour confetti and the theme toggle view transition
- Re-importing a font under the same name with new bytes now swaps the FontFace
- Keep local customization when a synced record predates the customization field, and re-push it

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Align client font name sanitization with server validation for PR unslothai#7077

sanitizeFont now strips the same characters the backend _FONT_NAME_FORBIDDEN
rejects (backslash, slash, comma, backtick) plus control chars, so a locally
chosen font name can no longer pass the client but fail the personalization PUT
and silently stall appearance sync.

* Address follow-up review items for PR unslothai#7077

- Number input wrapper carries React Flow interaction classes (nodrag/nopan/nowheel) so clicking the stepper arrows increments instead of dragging the node
- Preserve local palette and greeting-sloth toggle when the synced record predates those fields, and re-push them, mirroring the customization handling (new paletteSaved and greetingSlothSaved response flags)
- Add settings-search scroll targets (data-settings-label) for the Profile title, description, display name, nickname, and avatar shape rows

* Preserve absent personalization fields on PUT for PR unslothai#7077

A stale client that omits palette or customization previously had those
defaults materialized by model_dump() and persisted, which flipped
paletteSaved/customizationSaved to true and defeated the legacy detection.
The PUT now dumps only the request's set fields and merges them onto the
stored record, so omitted fields keep whatever was already stored.

* Persist theme and palette via a fixed allow-list for PR unslothai#7077

The theme/palette values reach setTheme/setPalette from the authenticated
personalization sync, which made the CodeQL clear-text-storage query treat
writing them to localStorage as storing sensitive data. Store a re-derived
literal from a constant map instead, so a plain UI preference is not tracked
as sensitive; behavior is unchanged.

* Harden imported-font handling for PR unslothai#7077

- syncImportedFonts: a rejected FontFace.load() only clears the registry entry
  if it still points at that face, so a same-name re-import while the old load
  was pending is no longer untracked/leaked.
- Cap imported-font names to the backend length (100) so an over-long name can
  no longer pass the client but fail the personalization PUT and stall sync.
- Add a backend test that a stale PUT preserves an existing stored palette and
  customization (not just that absent fields stay absent).

* Return the merged personalization record from PUT

The PUT /personalization handler returned the request payload, which
Pydantic had already filled with defaults for any field the client
omitted. A partial or stale write (for example a client sending only
theme) therefore got back a response that contradicted both storage and
the next GET: preserved fields like palette and the custom font showed
their defaults instead of the stored values.

Return model_validate(merged) so the response mirrors what was stored.
The stored record is still the full merged dict, so legacy fields the
model does not know about are preserved as before.

* Fix small UI and keyboard-focus defects in appearance settings

- Settings search now scrolls to the result within its destination tab
  instead of a same-named row in the previously rendered deferred tab
  (for example "Storage" and "Models folder" appear in both General and
  Resources).
- The reduce-motion segmented control honors its own Off/On/System choice
  by reading useReducedMotionConfig instead of the OS-only useReducedMotion.
- The color picker saturation/value area is operable by keyboard, so the
  role="slider" surface responds to the arrow keys it advertises.
- Profile avatars and palette cards show a visible keyboard focus ring
  again.
- Guard the persisted appearance-customization write so a blocked or full
  localStorage does not throw out of a store action, matching the theme
  store.
- Import the appearance store symbols from the settings feature barrel.

* Tighten appearance fix comments

---------

Co-authored-by: shimmyshimmer <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Daniel Han <[email protected]>
…nslothai#7112)

* Studio: pin llama.cpp update apply to the release the banner offered

* Document the pinned walk-back trade-off and cover win32

* Trim the pin comments

* Studio: verify a pinned llama.cpp update landed on the pinned release

The pin passes --published-release-tag so the installer resolves exactly the offered release. Also verify the result: if the post-install marker stays on the pinned repo but reports a different tag, the installer ignored the pin, so fail with a retryable error instead of a false success. A Vulkan/Intel host legitimately reroutes fork to upstream and drops the pin, so the check is scoped to the pinned repo.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: danielhanchen <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
unslothai#7113)

* Studio: fix the permanent GGUF "update available" on no-symlink caches

Without the symlink privilege (the default on Windows with Developer Mode
OFF), hf_hub_download MOVES the downloaded blob into snapshots/ instead of
symlinking it out of blobs/, so blobs/ is left empty and scan_cache_dir
reports blob_path = the snapshot file itself. Path(blob_path).name is then
the GGUF FILENAME, not the file's etag.

_repo_gguf_blob_map recorded that filename as the file's local blob hash, so
_variant_update_available_from_requirement's `remote_sha256 in local_set`
test could never match and every cached GGUF reported "update available"
forever. Re-downloading could not clear it: the same file is rewritten, still
with no blob.

Only treat Path(blob_path).name as a hash when the file really lives in the
cache's blobs/ dir; otherwise record a size identity so the file still appears
in the map (dropping it would make the update check read it as absent and
report the same phantom update). The comparison falls back to the remote
ExpectedFile.size only when the cached file carries no blob hash, so the
blob-hash path is unchanged wherever HF does produce blobs.

A remote requant that keeps the byte size identical is not detected in that
layout; re-hashing multi-GB GGUFs on the inventory hot path is the only
stricter option.

Fixes unslothai#7060

* Studio: match GGUF update checks by manifest sha256, closing the equal-size requant blind spot (unslothai#7060)

On a no-symlink cache (Windows without Developer Mode) blobs/ is empty, so the update check falls back to comparing byte size. A Studio download records each file's sha256 in its manifest, so feed that into the local identity set: the check can then match by hash and detect an equal-size requant. The size fallback now applies only when no real hash is present, so a manifest hash that differs is still reported as a genuine update. Adds regression tests.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Revert the manifest-sha256 identity merge; keep the size-identity fallback (unslothai#7060)

The download manifest is written before the transfer with the expected remote hashes, so it records download intent, not verified on-disk content, and completion is checked by size only. Merging those hashes into the local identity set could clear the update badge for an interrupted equal-size update that left the old bytes on disk. The accompanying all-size-identity gate also suppressed the size fallback whenever an older revision contributed a real blob hash, which re-showed a false update on mixed hash and size caches. Restoring the plain size-identity fallback keeps the fix without those regressions.

* Studio: don't delete no-symlink GGUFs during stale-variant reclaim (unslothai#7060)

On a no-symlink cache (Windows without Developer Mode) the downloaded file is moved into snapshots/ and scan_cache_dir reports its blob_path as that snapshot file, whose name is the filename, not an etag. reclaim_replaced_gguf_variant treated that name as a blob hash, which never matches the current hashes to keep, so it unlinked the freshly downloaded file. Only extract a deletable hash when the blob path is a real cache blob under the repo blobs directory, and keep any file we cannot identify; stale no-symlink revisions leak rather than risk removing the current file. Adds a regression test.

* Studio: anchor GGUF blob-hash detection to the repo cache blobs dir (unslothai#7060)

The inventory update check and the stale-variant reclaim both decide whether a scanned file is a real cache blob (name is the etag) or a moved no-symlink snapshot file (name is the filename). Both now share one _is_real_cache_blob helper that anchors to the repo cache blobs directory instead of matching any parent folder named blobs, so a repo that ships GGUFs under its own blobs subdir is no longer misread as the cache blob store. Threads repo_path through _repo_gguf_blob_map. Adds a regression test.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Studio: tighten comments in the GGUF update-check helpers (unslothai#7060)

Post-review comment pass: shorten the internal blob-identity and size-fallback docstrings. Comments only, no behavior change.

---------

Co-authored-by: Lee Jackson <[email protected]>
Co-authored-by: Daniel Han <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* persist vision/audio model flags to fix S3 tab flash on reload

* persist modelType and reset capability flags on model switch
…nslothai#7126)

RawTextDataLoader.smart_chunk_text takes chunk_size and stride as its own
arguments, so a direct call with stride >= chunk_size bypasses the
constructor validation. In that case `start_idx += chunk_size - stride` is
non-positive, so start_idx never advances past the first window and the
chunking loop never terminates (hangs).

Re-add the chunk_size/stride guard at the top of smart_chunk_text so direct
callers fail fast with a clear ValueError. The constructor keeps its own
guard for the internal callers (defense in depth). Add a regression test
that calls smart_chunk_text directly with stride == chunk_size and
stride > chunk_size and asserts it raises instead of hanging.

Signed-off-by: Anas Khan <[email protected]>
…thai#7089)

* fix: name unsloth_vllm_standby parameter in vLLM standby error

FastBaseModel.from_pretrained's vLLM-standby guard raised
"UNSLOTH_VLLM_STANDBY is True, but UNSLOTH_VLLM_STANDBY is not set to 1",
naming the environment variable in both clauses. The value that is True is
the unsloth_vllm_standby parameter, not the env var, so the message was
self-contradictory. Name the parameter in the first clause, matching the
sibling guard in FastLlamaModel.from_pretrained.

Signed-off-by: Anas Khan <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Remove vLLM standby error message test

---------

Signed-off-by: Anas Khan <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: danielhanchen <[email protected]>
)

* Studio: expose Windows drive roots in the folder browser

The model-selection folder browser bounds navigation to the roots returned
by _build_browse_allowlist(), which exposed Linux removable-media mounts via
linux_run_media_mount_roots() but had no Windows analog. As a result a user
on C: could not browse to D:/E: to pick a model directory.

Add windows_drive_roots(), a Windows-only companion to
linux_run_media_mount_roots() that lists readable logical drive roots, and
wire it into both browse-allowlist builders and their suggestion chips so
other drives are both navigable and offered as quick-picks. The helper is a
no-op on Linux/macOS, so existing platforms are unaffected.

Closes unslothai#6368

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Studio: cover the Windows drive-root browse wiring with an integration test

Add an allowlist integration test mirroring the Linux side's
test_legacy_browse_allowlist_includes_linux_run_media_mounts: it extracts
_build_browse_allowlist from routes/models.py, stubs external_media so
windows_drive_roots() yields a fake drive root, and asserts that root becomes
browsable through the built allowlist. Proves the wiring, not just the helper.

* Studio: skip inactive drives via GetLogicalDrives before probing

Resolve active logical drives from GetLogicalDrives() before probing each
letter with os.path.isdir. Probing a drive letter mapped to a disconnected
network share can otherwise block the async backend for tens of seconds per
letter. The call degrades gracefully (falls back to probing all letters) when
ctypes/windll is unavailable, so behavior is unchanged on Linux/macOS. Tests
override the bitmask source to stay deterministic on real Windows hosts.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Studio: allow browsing descendants of a drive-root allowlist entry

routes/models.py _is_path_inside_allowlist() checked descendants with
startswith(root_real + os.sep). A drive root ("D:\") already ends in a
separator, so the prefix became "D:\\" and a child like "D:\models" was
rejected with 403 after the browser opened the drive root. Only append a
separator when the root does not already end in one. folder_browser.py already
uses commonpath and was unaffected. Adds a regression test covering the
separator-terminated-root descendant case.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Studio: enforce the system-directory denylist during folder browsing

Exposing whole Windows drive roots (and any legacy-registered filesystem root)
widened the browse allowlist above system directories, but the browse
resolvers only re-applied the credential/config denylist, not the
_denied_path_prefixes() system-dir denylist that scan-folder registration
enforces. That let browse-folders enumerate C:\Windows, C:\Program Files,
/etc and /proc.

- Add is_denied_system_path() to both storage modules and enforce it in both
  browse resolvers (legacy routes/models.py and hub folder_browser.py), on each
  resolved child and on the final target, keeping the /run/media carve-out.
- Rework the legacy _is_path_inside_allowlist to use splitdrive + commonpath so
  a Windows drive root authorizes its descendants while a bare POSIX / does not,
  and to compare case-insensitively like the hub browser.
- Reject the filesystem root in the legacy add_scan_folder, matching the hub.
- Hide denied system dirs from browse listings and suggestion chips.
- Add tests/test_browse_denylist.py and update the external-media path tests.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Studio: make browse-denylist tests OS-portable

The browse-time denylist tests used real /etc and tmp_path locations; on macOS
tmp lives under the (legitimately denied) /private/var and /etc resolves to
/private/etc, so three tests failed there. Pin the platform / use a tmp-based
denied prefix so they assert the same behavior on Linux, macOS and Windows.

* Studio: apply the bare POSIX-root guard to the hub folder browser too

The _is_path_inside_allowlist guard that stops a legacy-registered '/' scan
folder from authorizing every absolute path lived only in the legacy browser.
The hub browser used commonpath without it, so a stale '/' row let it descend
into /var, /root, /home -- which the system-directory denylist (/proc /sys /dev
/etc /boot /run) does not cover, while the legacy browser blocked them. Mirror
the legacy guard so both browsers treat '/' identically.

Also resolve each directory entry before the denylist check in both listing
loops, so a symlink or junction pointing into a denied dir is hidden instead of
rendered as a row that 403s on descent. Adds legacy-vs-hub parity tests.

* Studio: bound Windows drive probing so a disconnected mapping can't stall the browser

GetLogicalDrives includes mapped network drives, so a disconnected but still
mapped drive (e.g. Z: -> \\nas\share) stays set in the bitmask and reaches
os.path.isdir, which can block for tens of seconds while Windows tries to
reconnect. Because windows_drive_roots() runs synchronously while building both
folder-browser responses, one stale mapping stalled every browse request.

Probe each surviving drive in a daemon thread bounded by a short timeout and
skip it if it does not answer in time, so a hung mapping is dropped instead of
blocking the caller. Connected drives (local or network) still respond well
within the timeout, so drive discovery is unchanged. Corrects the
GetLogicalDrives docstring, which claimed the bitmask alone prevented the stall.

* Studio: probe drive/media roots once per browse request, not twice

Both folder browsers called windows_drive_roots() (and
linux_run_media_mount_roots()) twice per browse request: once to seed the
allowlist in _build_browse_allowlist() and again to build the suggestion chips.
With the bounded drive probe, a disconnected mapped network drive then paid the
timeout twice per folder click. Probe both once in the request handler and pass
the results into _build_browse_allowlist(), reusing them for the chips, in both
the legacy and hub browsers. Adds a test asserting the roots are reused, not
re-probed.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Studio: run the legacy browse endpoint in the threadpool, fix its stale test

Two follow-ups from review of the drive-probe changes:

- browse_folders was 'async def' but does only blocking filesystem I/O (the
  timeout-bounded drive probe, iterdir, realpath). On the event loop a
  disconnected mapped drive waiting out its probe timeout stalled every other
  request. Declare it sync 'def' so FastAPI runs it in the threadpool, matching
  the hub browse endpoint. No await was used in the body.

- test_browse_folders_hides_sensitive_dirs monkeypatched _build_browse_allowlist
  with a zero-arg lambda; the once-per-request refactor now calls it with
  (media_roots, drive_roots), so the lambda raised TypeError. Accept and ignore
  the args.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Studio: probe Windows drive roots concurrently so multiple dead mappings don't stack timeouts

windows_drive_roots() probed each candidate serially, so N disconnected-but-mapped network drives each paid the full per-drive timeout in turn (e.g. four stale mappings added ~8s to every folder-browser request). Collect the candidate roots first, then probe them all at once under a single overall deadline, so the added delay stays at ~one timeout regardless of how many drives are disconnected. _readable_dir_within stays as a thin single-path wrapper for its existing callers/tests.

* Studio: tighten comments in the folder-browser drive-root changes

Condense the comments and docstrings added by the Windows drive-root and
system-directory denylist work to be shorter and clearer while keeping the
security and correctness rationale intact. Comment and docstring text only;
no code changes.

* Studio: iterate the input, not the results dict, when collecting readable drive probes

_readable_dirs_within returned {path for path, ok in results.items()...}, but a probe thread that exceeded the join deadline is still alive and can insert its key into results during that iteration, raising 'dictionary changed size during iteration' -- reachable exactly in the disconnected-mapped-drive case the probe exists for. Iterate the fixed input list and read results.get(path) (an atomic read) instead.

* Studio: keep the browse-route containment tests denylist-inert so they pass on macOS

test_browse_folders_route.py exercises allowlist containment and the file-vs-directory guard, not the system-directory denylist. On macOS pytest tmp_path resolves under /private/var, a denied prefix, so _resolve_browse_target 403s the fixture dirs before the containment logic runs (4 failures). Add an autouse fixture that makes is_denied_system_path inert in this file; the denylist keeps its own coverage in test_browse_denylist.py.

* Studio: keep the hub browse tests denylist-inert so they pass on macOS

* Studio: register a UNC share root; only reject local filesystem roots

* Studio: reject device drive roots and browse a registered UNC share root

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Studio: treat device-namespace volume GUID roots as local filesystem roots

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: danielhanchen <[email protected]>
…unslothai#7137)

* Studio CI: make tool-calling SSE probes resilient to transport stalls

* Studio CI: bound tool-probe SSE stalls to the job timeout and stop accepting partial tool events

* Studio CI: surface HTTP errors from the seed loop and bound the Mac best-effort probes

* Studio CI: keep completed tool results on a stall and cap seed reads by the remaining budget
@Imagineer99

ghost commented Jul 23, 2026

Copy link
Copy Markdown
Member Author

@codex review

ghost 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: 2d8224b49a

ℹ️ 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 +2159 to +2161
if (!tryReservePreStreamRun()) {
event.preventDefault();
toast.error("Wait for the current response to finish");

ghost Jul 23, 2026

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 Gate retry/edit run starters on queue capacity

This reservation only runs for the main composer submit path. When a prompt queue is active in a background chat, the visible chat's Retry/Refresh controls (ActionBarPrimitive.Reload) and the edit composer still start runs directly via assistant-ui (aui.composer().send()/reload) without checking anyPromptQueueRunning, promptQueueHasCapacity(), or reserving pre-stream capacity. In that scenario a user can start a second generation while the queue scheduler believes global concurrency is 1, so two local generations can run concurrently and the queue's capacity accounting is bypassed.

Useful? React with 👍 / 👎.

@@ -905,6 +1026,21 @@ export function SharedComposer({
}
if (content.length === 0) return;

if (compareSendAtGlobalCapacity()) {

ghost Jul 23, 2026

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 Reserve compare capacity before async model loads

This is only a point-in-time capacity check; generalized compare then spends time in ensureModelLoaded() before either pane calls startRun() and flips runningByThreadId. If the user navigates away and sends or queues another chat during that load window, the normal composer sees no running thread or pre-stream reservation and admits a second request, so the single backend model can be loaded/generated concurrently with the compare run despite the global concurrency limit.

Useful? React with 👍 / 👎.

Comment on lines +1916 to +1920
const chatStateAtQueueStart = useChatRuntimeStore.getState();
const incognitoAtQueueStart = chatStateAtQueueStart.incognito;
const usesThreadDocumentsAtQueueStart =
chatStateAtQueueStart.ragEnabled &&
chatStateAtQueueStart.ragSource.type === "thread";

ghost Jul 23, 2026

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 Snapshot queued chat generation settings

This queue target only snapshots incognito and thread-document mode, but the adapter still re-reads the global useChatRuntimeStore params/tools/model when each queued prompt actually dispatches. Because this change allows a chat's queue to keep running after the user navigates away, starting a queue in Chat A and then changing model or tool toggles in Chat B before the remaining prompts run will make Chat A's queued prompts execute with Chat B's live configuration, corrupting queued experiments.

Useful? React with 👍 / 👎.

@Imagineer99

ghost commented Jul 23, 2026

Copy link
Copy Markdown
Member Author

@codex review

ghost 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: 5f46180412

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines 2080 to 2084
if (!tryReservePreStreamRun()) {
toast.error("Wait for the current response to finish");
return;
}
aui.composer().send();

ghost Jul 23, 2026

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 Check global capacity before firing parked sends

When document indexing clears, this parked-send path only calls tryReservePreStreamRun(), which guards another pre-stream reservation but does not check runningByThreadId or an active prompt queue. If this chat has a pending indexing send while a different chat is generating in the background, the auto-send starts as soon as indexing finishes and bypasses the same global concurrency gate used by handleSubmit; use the full capacity check/reservation path here before calling send().

Useful? React with 👍 / 👎.

Comment on lines +6 to +7
const QUEUED_SETTING_KEYS = [
"supportsTools",

ghost Jul 23, 2026

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 Snapshot reasoning controls for queued runs

The fresh evidence is this new QUEUED_SETTING_KEYS snapshot: it freezes params/tools/RAG settings for background queued prompts, but still omits user-controlled reasoning fields such as reasoningEnabled, reasoningEffort, and preserveThinking, which chat-adapter.ts later reads from runtime when building the request. If a user queues prompts with one Think/preserve-thinking configuration, switches chats, and changes those pills before the remaining queued prompts dispatch, the queued experiment runs with the visible chat's reasoning settings instead of the settings it was queued with.

Useful? React with 👍 / 👎.

Comment on lines +2148 to +2149
runtime = queuedRunSettings
? { ...useChatRuntimeStore.getState(), ...queuedRunSettings }

ghost Jul 23, 2026

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 Preserve autoloaded checkpoint for queued snapshots

When a prompt is queued while no model is loaded, its snapshot has an empty params.checkpoint; this branch then auto-loads a model into the live store, but immediately reapplies the stale queued snapshot over that freshly loaded state. The queued request can then continue with params.checkpoint === "" (and stale capability flags) after a successful autoload, so queued follow-ups from the first no-model chat fail or send an invalid model instead of using the model that was just loaded.

Useful? React with 👍 / 👎.

// Assistant UI can replace its optimistic local id with a persisted remote
// id between append() and adapter startup. Global concurrency is one, so a
// sole pending snapshot is unambiguously the queued run being started.
if (index < 0 && pendingSettings.length === 1) index = 0;

ghost Jul 23, 2026

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 Drop queued setting snapshots when runs are stopped

This fallback is only safe while the sole pending snapshot still belongs to a queued dispatch that is about to start. If the user stops/deletes/archives that queued run after registerQueuedChatRunSettings() but before the adapter consumes it, the snapshot is never discarded; the next unrelated run with a nonmatching thread id will hit this pendingSettings.length === 1 path and inherit the old queued prompt's model/tools/params.

Useful? React with 👍 / 👎.

@@ -1801,6 +2183,10 @@ const Composer: FC<{
});
closeOverlay();
}
if (!tryReservePreStreamRun()) {

ghost Jul 23, 2026

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 Release reservations when attachment prep fails

When a send includes a requires-action attachment, this reserves global pre-stream capacity before assistant-ui converts the attachment; if PDF/DOCX parsing, file reads, or audio/image conversion reject before createOpenAIStreamAdapter.run() starts, none of the adapter release paths run and getPreStreamRunReservationCount() stays nonzero, blocking every later send/queue until reload. Release the reservation from the composer send-failure path or reserve only after attachment preparation succeeds.

Useful? React with 👍 / 👎.

Comment on lines +2249 to +2255
if (usePromptQueueUI.getState().isRunning) {
toast.info("A prompt queue is still running", {
description:
"Stop the queue before changing models so its remaining prompts keep the model they started with.",
});
return;
}

ghost Jul 23, 2026

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 Block model loads while background chats run

This new guard only stops model changes for prompt queues, but switching chats no longer cancels ordinary background generations. If Chat A is still streaming and the user opens Chat B and selects/drops a different local model through this path, loadModel/setCheckpoint can replace the backend model while the hidden run is using it; include runningByThreadId and pre-stream reservations in this gate, or cancel the background run before loading another model.

Useful? React with 👍 / 👎.

@Imagineer99

ghost commented Jul 23, 2026

Copy link
Copy Markdown
Member Author

@codex review

ghost 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: a85bc006b7

ℹ️ 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 +2163 to +2164
...queuedRunSettings.params,
checkpoint: liveRuntime.params.checkpoint,

ghost Jul 23, 2026

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 Preserve auto-load settings for queued fresh starts

When a prompt queue is started before any model is loaded, the adapter auto-loads a model and then rebuilds runtime here, but this spread keeps the pre-load queued params (and the ...queuedRunSettings above also keeps pre-load fields like ggufContextLength). The result is that the queued request runs against the newly loaded checkpoint while still using stale pre-load limits/settings, unlike a normal first send after auto-load; saved-prompt run lists from a fresh session can therefore send with the wrong context/output limits. Preserve the live auto-load-derived model settings when queuedRunSettings.params.checkpoint was empty, not just the checkpoint string.

Useful? React with 👍 / 👎.

Comment on lines +1156 to +1158
if (
visibleThreadId === localThreadId &&
store.activeThreadId !== remoteId

ghost Jul 23, 2026

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 Accept the remote id when syncing a newly saved chat

This guard only updates activeThreadId when the visible thread is still the optimistic local id captured before initialize(). In the fresh-chat paths where ActiveThreadSync is disabled (newThreadNonce/project new chat), if assistant-ui has already promoted mainThreadId to the persisted remoteId by the time this awaited write resumes, the condition fails and the newly created chat never becomes the active thread. Treat visibleThreadId === remoteId as still visible so foreground new chats continue to switch from the draft/local id to the persisted id.

Useful? React with 👍 / 👎.

@@ -1801,6 +2220,15 @@ const Composer: FC<{
});
closeOverlay();
}
if (!tryReservePreStreamRun()) {

ghost Jul 23, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Gate Send button clicks through the same capacity path

This reservation is only reached by the form submit path, but ComposerPrimitive.Send is an action button that sends from its own click handler rather than submitting the form. As a result, mouse/touch clicks on Send only run interceptSend, bypassing the new anyPromptQueueRunning/capacity checks and pre-stream reservation here; when another chat has a queued or running generation, clicking Send can still start a second response while pressing Enter is correctly gated. Move the capacity/reservation logic into the Send click path as well.

Useful? React with 👍 / 👎.

@@ -2394,6 +2625,7 @@ export function createOpenAIStreamAdapter(
if (abortSignal.aborted) return;
runtime.setGeneratingStatus("waiting");
}, warmupDelayMs);
releasePreStreamRunReservation();

ghost Jul 23, 2026

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 Release reservations before persisted setup can fail

This is the first normal streaming release point for the pre-stream reservation, but the persisted-run wrapper awaits the first history append before createOpenAIStreamAdapter.run() is entered. If that storage/autosave step rejects after a send has reserved capacity, this release is never reached, leaving preStreamRunReservations stuck above zero and blocking subsequent sends/model changes until reload. Add a release/failed notification around the wrapper's pre-adapter wait, or reserve only after that wait succeeds.

Useful? React with 👍 / 👎.

@Imagineer99

ghost commented Jul 23, 2026

Copy link
Copy Markdown
Member Author

@codex review

ghost 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: 62ac46eeed

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +1000 to +1002
if (!failedRun || !promptQueueActiveRunIds.has(failedRun.id)) {
return;
}

ghost Jul 23, 2026

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 Pump queues after pre-stream reservation failures

When a queued prompt is waiting only because another send holds the pre-stream reservation, and that send fails before setThreadRunning(true) (for example model validation/API-key/image gates), notifyPreStreamRunFailed releases the reservation and dispatches this event. Because the queued run is not the failed active run, this branch returns without scheduling requestPromptQueuePumpIfReady(), so the ready queue can sit idle until some unrelated running-state or queue edit happens. Pump ready queues after the reservation-release event even when there is no matching active failed run.

Useful? React with 👍 / 👎.

Comment on lines +10 to +11
requestPromptQueueStop();
return clearStoredChats();

ghost Jul 23, 2026

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 Stop running chats before clearing all chats

When Settings > Data > Clear all is used after the user has navigated away from a streaming chat, this new wrapper only stops prompt queues; it never cancels ordinary runs still present in runningByThreadId. Since this change allows those runs to keep streaming in the background, clearStoredChats() can clear/tombstone history while the hidden generation continues consuming the model and racing later history writes. Cancel the currently running thread ids before clearing, as the archive-all path already does.

Useful? React with 👍 / 👎.

Comment on lines +214 to +216
for (const id of threadIds) {
cancelIfRunning(id);
}

ghost Jul 23, 2026

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 Cancel pre-stream sends before archiving chats

When a user sends a prompt and immediately archives or deletes that chat while the adapter is still in its pre-stream phase, runningByThreadId has not been set yet, so this loop does nothing; requestPromptQueueStop only affects queued prompts, not the ordinary send that already reserved capacity. The run can then reach setThreadRunning(true) after the thread was hidden or tombstoned and continue generating/saving against it. Track and cancel pre-stream starts for these thread ids before archiving/deleting, not only runs already marked running.

Useful? React with 👍 / 👎.

@Imagineer99

ghost commented Jul 23, 2026

Copy link
Copy Markdown
Member Author

@codex review

ghost 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: 3916bc0c72

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +1474 to +1476
const nextCancel = { ...state.cancelByThreadId };
delete nextCancel[threadId];
return { runningByThreadId: nextRunning, cancelByThreadId: nextCancel };

ghost Jul 23, 2026

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 Preserve cancel handles for subsequent runs

After a run ends in a still-mounted chat, this deletes the thread's registered cancel callback, but CancelRegistrar now only registers on mainThreadId changes and will not re-register for the next run in the same chat. If the user starts another generation and then archives/deletes/clears that chat from the sidebar, cancelIfRunning sees runningByThreadId[threadId] but cancelByThreadId[threadId] is undefined, so the stream is not stopped before the thread is hidden/deleted. Let the registrar cleanup own unregistration, or re-register on each run start.

Useful? React with 👍 / 👎.

Comment on lines +1460 to +1461
if (compareReservationPending) {
releasePreStreamRunReservation();

ghost Jul 23, 2026

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 Notify queues when compare releases capacity

The fresh evidence is this direct compare-load release path, which bypasses notifyPreStreamRunFailed. When a generalized compare holds the pre-stream reservation during ensureModelLoaded, a user can queue a normal chat prompt; if the compare load/validation then fails after that queue's initial pump already found capacity full, this finally frees the slot without any runningByThreadId transition or queue-failure event, so the ready prompt queue stays idle until unrelated activity. Dispatch the same failure/pump notification after releasing this failed reservation.

Useful? React with 👍 / 👎.

Comment on lines +2067 to +2068
if (getPreStreamRunReservationCount() > 0) {
releasePreStreamRunReservation();

ghost Jul 23, 2026

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 Pump queues after attachment-prep failures

When a normal send with an attachment reserves the pre-stream slot while another chat's prompt queue is waiting, an attachment conversion/read failure is handled here before the adapter starts. This releases the reservation, but it does not emit the queue-failure/pump event that notifyPreStreamRunFailed sends, and there is no runningByThreadId transition for queues to observe, so the ready queued prompt can remain idle until some unrelated state change triggers another pump. Notify the prompt queue after this release as well.

Useful? React with 👍 / 👎.

@Imagineer99

ghost commented Jul 23, 2026

Copy link
Copy Markdown
Member Author

@codex review

ghost 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: c1eec22432

ℹ️ 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 +2065 to +2069
void Promise.resolve(aui.composer().send()).catch((error) => {
// Attachment conversion happens before the adapter starts. If it
// rejects there, the adapter cannot release the pre-stream slot.
if (getPreStreamRunReservationCount() > 0) {
notifyPreStreamRunFailed(referenceThreadId);

ghost Jul 23, 2026

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 Release the reserved slot when attachment preparation fails

When a queued-capacity send includes a requires-action attachment and the attachment adapter rejects during preparation (for example, a FileReader error while converting an image/text file), this .catch never runs because aui.composer().send() is fire-and-forget: the assistant-ui runtime calls core.send(options) without returning its promise, and attachment conversion happens before handleSend starts the model adapter. In that failure path the pre-stream reservation made just before calling sendReservedComposer() is never released, so generation capacity stays stuck and future sends/model changes are blocked until reload.

Useful? React with 👍 / 👎.

@Imagineer99

ghost commented Jul 23, 2026

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@Imagineer99

ghost commented Jul 23, 2026

Copy link
Copy Markdown
Member Author

@codex review

ghost 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: 311c5dcbfa

ℹ️ 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 +2006 to +2012
const settingsId = registerQueuedChatRunSettings(
getQueueThreadIds(),
runSettingsAtQueueStart,
);
pendingSettingsIds.add(settingsId);
try {
thread.append(appendTextToThread(prompt));

ghost Jul 23, 2026

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 Discard queued settings when pre-stream startup fails

If the queued append gets far enough to register this settings snapshot but the async history/initialize gate rejects before createOpenAIStreamAdapter.run is entered, the snapshot is never consumed (the consume happens inside the adapter) and this catch only covers synchronous thread.append throws. That leaves a stale entry in pendingSettings, so a later send can match the sole-pending fallback and run with the failed queued prompt’s old model/settings; the pre-stream failure path needs to discard the registered settings as well.

Useful? React with 👍 / 👎.

stopPropagation?: () => void;
},
): boolean {
if (promptQueueHasCapacity() && tryReservePreStreamRun()) return true;

ghost Jul 23, 2026

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 Block retries while prompt queues are waiting

When a prompt queue is active but waiting on document indexing or a retry timer, there may be no runningByThreadId, pre-stream reservation, or active dispatch, so this capacity check returns true. The new Retry/Refresh/Edit preflights can then start an interactive generation ahead of the active saved-prompt queue, unlike normal sends which explicitly check anyPromptQueueRunning; include the queue-running state in this helper so regenerations cannot reorder queued experiment prompts.

Useful? React with 👍 / 👎.

@Imagineer99

ghost commented Jul 23, 2026

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@Imagineer99

ghost commented Jul 23, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

ghost commented Jul 23, 2026

Copy link
Copy Markdown

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

Reviewed commit: 70d8ea9aca

ℹ️ 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.