Skip to content

Model picker: remember the Run Settings advanced toggle across models - #7747

Merged
shimmyshimmer merged 5 commits into
mainfrom
studio-remember-advanced-settings
Aug 2, 2026
Merged

shimmyshimmer merged 5 commits into
mainfrom
studio-remember-advanced-settings

Conversation

@shimmyshimmer

@shimmyshimmer shimmyshimmer commented Aug 2, 2026 •

Copy link
Copy Markdown
Member

Before

Advanced settings in the model picker's Run Settings panel reset every time. The state lived only in component state, seeded from whether the model happened to carry non-default advanced values, so switching model or quant, or reopening the panel, closed the section again. Anyone who works in KV Cache Dtype or GPU Memory had to switch it back on for every model.

After

The toggle is a standing preference with three states rather than two:

  • unset, the default, leaves the decision to the panel, so a model carrying non-default advanced values still opens the section for itself and those values stay visible
  • on or off is an explicit choice and wins outright, for every model and quant, until it is changed

Run Settings is mounted on three surfaces (the picker, the chat sidebar, the hub settings view), and the sidebar copy stays mounted while collapsed, so the preference is read through a subscription rather than snapshotted at mount. Every mounted panel follows a toggle made on any of them, and writes from another tab are picked up as well. This follows the pattern in use-sidebar-pin.ts.

The value is read from storage rather than cached, so a change made in another tab while every panel was unmounted is still seen on the next mount. Storage events are not replayed, so a cache would have gone stale there.

A browser that refuses the write (storage disabled, sandboxed, or full) still gets a working switch, backed by memory for that session. That fallback records what storage held at the time, so if storage later moves, a newer choice made elsewhere takes over rather than being ignored.

Settings > General > Reset all local preferences clears the key, which its explicit key list would otherwise have skipped.

Notes

The helpers live in per-model-config.ts next to the rest of the model config storage rather than in the chat runtime store, which keeps them importable from tests.

The auto-open check is frozen at mount rather than recomputed, otherwise editing a field back to its default would close the section while it was being used.

The section is GGUF only, as before. Nothing about how a model loads changes, only which rows the panel draws.

Testing

tests/advanced-settings-preference.test.ts, 13 tests: untouched profile reads as unset, open remembered, close remembered as closed rather than untouched, unparseable value counts as untouched, a refused write still moves the switch, a refused write holds while storage stays put, a newer choice elsewhere takes over from a refused write, all mounted panels notified on both open and close, unsubscribe stops delivery, cross-tab event including a null key from a clear and an unrelated key, a cross-tab write seen with no panel mounted to hear it, the key present in the Settings reset list, and listener detach on unmount.

Every fix is mutation checked against the tests that cover it:

  • restoring the cache fails the two cross-tab tests plus three others

  • dropping the refused-write fallback fails only a refused write still moves the switch

  • reconciling that fallback on the storage event instead of on read fails the cross-tab takeover test, since events are not replayed to a panel that was unmounted

  • always dropping the fallback fails the two tests that keep the switch usable while storage refuses writes

  • collapsing the tri-state back to a boolean fails the three tests that need unset distinct from closed

  • removing the key from PREFS_KEYS fails only the reset test

  • npm run typecheck clean

  • npm test: 299 passing, 0 failing

  • npm run build clean

  • biome check on all three touched source files matches main exactly, and the new test file carries the same noNodejsModules warnings sidebar-width.test.ts does for the same reason

Opening advanced settings only lasted until the next model or quant, so it
had to be switched on again every time. Persist it as a standing preference,
like the speculative type and GPU Memory mode.

A model carrying non-default advanced values still opens the section on its
own, so settings already in effect stay visible.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@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: 3e57e95bbb

ℹ️ 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 766 to 768
const [showAdvanced, setShowAdvanced] = useState(
() => readAdvancedSettingsOpen() || hasNonDefaultAdvanced(config),
);

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 Synchronize the toggle across mounted settings pages

When multiple ModelConfigPage instances are mounted, this initializer only snapshots the preference once. On desktop, ChatSettingsPanel keeps its sidebar instance mounted even while collapsed, so changing the toggle in the model picker updates only that picker and localStorage; reopening the existing sidebar still shows its stale state until it happens to remount. Use a shared reactive store or notify/subcribe mounted instances when saving the preference so the standing setting actually applies across surfaces.

Useful? React with 👍 / 👎.

The picker, the chat sidebar and the hub each mount their own Run Settings,
and the sidebar copy stays mounted while collapsed. Reading the preference
once at mount left those copies on a stale snapshot after a toggle elsewhere.

Subscribe to it instead, so every mounted panel follows the preference, and
pick up writes from other tabs while there.

A model carrying non-default advanced values still opens the section on its
own, and using the switch retires that so it stays clickable.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

Good catch, the P2 is correct and I have pushed a fix in 305d6de.

Confirmed the premise before changing anything. On desktop the chat settings panel renders as w-0 overflow-hidden when closed and still renders {settingsContent} unconditionally, so the sidebar SidebarModelConfig really does stay mounted while collapsed. The picker mounts a second ModelConfigPage alongside it, and the hub settings view a third. Reading the preference once in a useState initializer left every copy other than the one that was clicked on a stale snapshot until its instance key changed.

The toggle now goes through a small subscribe and notify pair next to the other model config storage, and the panel reads it with useSyncExternalStore, so all mounted panels move together. Writes from another tab are picked up too, following the same pattern use-sidebar-pin.ts uses.

One detail worth noting: a model carrying non-default advanced values still opens the section on its own, so settings already in effect are never hidden. That is now local state that using the switch retires, otherwise the switch would look stuck on for those models.

Tests cover the notify path, unsubscribe, the cross-tab event including a null key from a clear and an unrelated key, and listener detach on unmount. I checked the notify test fails when the notify loop is removed, so it is actually holding the behaviour down.

@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: 305d6de7d8

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

const [autoOpenAdvanced, setAutoOpenAdvanced] = useState(() =>
hasNonDefaultAdvanced(config),
);
const showAdvanced = advancedPreference || autoOpenAdvanced;

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 Clear auto-open state across every mounted panel

When the active model has any non-default advanced value, both the picker and the desktop sidebar initialize autoOpenAdvanced to true. Closing the switch in one instance clears only that instance's flag; subscribers in the other instance receive the shared false preference, but this expression remains true because its local auto-open flag is unchanged. The fresh evidence after the earlier report is that the new synchronization still ORs the shared preference with an unsynchronized per-instance value, so reopening the mounted sidebar can still show the toggle as enabled. Propagate the explicit close so every mounted instance clears its auto-open state.

Useful? React with 👍 / 👎.

Comment on lines +233 to +235
localStorage.setItem(ADVANCED_SETTINGS_OPEN_KEY, open ? "true" : "false");
} catch {
// ignore

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 an in-memory toggle when persistence fails

When localStorage.setItem throws—for example because storage is disabled, sandboxed, or full—the exception is suppressed but no in-memory value is updated. The listener notification then makes useSyncExternalStore read the old value (normally false), so clicking the switch cannot open advanced settings at all, whereas the previous component-local state remained usable without storage. Keep a memory-backed snapshot so persistence failure affects only remembering the preference, not access to the controls.

Useful? React with 👍 / 👎.

Two holes in the previous commit. Closing the switch on one surface left
another mounted panel open, because its own auto-open flag was untouched.
And a refused localStorage write left the switch inert, since the value was
read back from storage that had not changed.

The preference is now unset, on or off, and memory backed. Unset lets a model
carrying non-default advanced values open the section for itself; once the
switch is used, that choice wins on every panel. A browser that refuses the
write still gets a working switch, it just forgets the choice next launch.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

Both P2s are correct. Fixed in 7d67d07, and one change covers both.

On the auto-open one: showAdvanced = preference || autoOpenAdvanced did leave the other panel open, because autoOpenAdvanced is per instance and a close elsewhere only pushed a shared false that the OR swallowed.

On the refused write: readAdvancedSettingsOpen went straight back to localStorage, so when setItem threw the read returned the unchanged value and the switch could not move at all. Worse than the component state it replaced.

Rather than propagate a close to every instance's local flag, the preference is now unset, on, or off, and memory backed:

  • unset, the default, leaves the decision to the panel, so a model carrying non-default advanced values still opens the section for itself
  • once the switch is used, that choice wins outright on every mounted panel, so there is no per-instance flag left to fall out of sync
  • memory is the source of truth, so a browser that refuses the write still gets a working switch, it just forgets the choice next launch

The auto-open value is frozen at mount rather than recomputed, otherwise editing a field back to its default would close the section while it was being used.

Both fixes are mutation checked. Reading straight from storage again fails only a refused write still moves the switch, and collapsing the tri-state back to a plain boolean fails the three tests that depend on unset being distinct from closed. Full run is 295 passing.

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

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

// Whether Run Settings shows its advanced section is a standing preference,
// not a per-model one: opening it once keeps it open for every model and
// quant. Closed until asked for.
export const ADVANCED_SETTINGS_OPEN_KEY = "unsloth_model_advanced_settings";

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 Include the advanced toggle in preference resets

After a user changes this toggle and selects Settings > General > Reset all local preferences, resetAllPrefs only removes the keys listed in PREFS_KEYS, and this new key is absent from that list (studio/frontend/src/features/settings/tabs/general-tab.tsx). The subsequent reload therefore reads the old advanced-settings choice again, so the advertised reset does not reset all UI preferences.

Useful? React with 👍 / 👎.

export function subscribeAdvancedSettingsOpen(
onChange: () => void,
): () => void {
advancedOpenListeners.add(onChange);

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 Refresh the stored value when panels subscribe

If every Run Settings surface is unmounted when another tab changes this preference, no storage listener exists to update advancedOpen; storage events are not replayed later. On the next mount, subscribing only registers the listener, while readAdvancedSettingsOpen returns the previously cached value, so the cross-tab change remains invisible until another toggle or storage event occurs.

Useful? React with 👍 / 👎.

Two more holes. Caching the value meant a write from another tab while every
panel was unmounted had no listener to catch it, and storage events are not
replayed, so the next mount read a stale value. And Settings > General resets
an explicit key list this one was missing from, so the reset skipped it.

Read straight from storage instead of caching. The memory fallback now covers
only a refused write, which is the case storage cannot answer for, and the
next write that sticks hands control back to storage.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

Both correct again. Fixed in f9a724d.

On the reset: PREFS_KEYS in general-tab.tsx is an explicit allowlist and resetAllPrefs removes only what is in it, so the key really was skipped. Added it next to the other model config keys, and added a test that reads that list from source and fails if the key is missing, the same guard sidebar-width.test.ts already uses for the panel width keys.

On the stale cache: correct, and the cache turned out not to be worth keeping at all. It existed to survive a refused write, but that also made it the only thing standing between a panel and a value written by another tab while nothing was mounted. readAdvancedSettingsOpen now reads storage directly, so there is no window where memory and storage disagree. The memory fallback is down to the one case storage cannot answer for, a write that was refused, and the next write that sticks clears it and hands control back to storage.

Reading on every snapshot is a getItem call a few times per render of one panel, which is not worth a cache given what the cache cost in correctness.

All four findings across the last two rounds are mutation checked, each against the specific tests that cover it:

  • restoring the cache fails the two cross-tab tests plus three others
  • dropping the refused-write fallback fails only a refused write still moves the switch
  • collapsing the tri-state back to a boolean fails the three tests that need unset distinct from closed
  • removing the key from PREFS_KEYS fails only the reset test

11 tests in the file, 297 in the suite, typecheck and build clean, and biome check on all three touched source files matches main exactly.

@shimmyshimmer

Copy link
Copy Markdown
Member Author

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

ℹ️ 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 +280 to +281
if (event.key === null || event.key === ADVANCED_SETTINGS_OPEN_KEY) {
onChange();

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 Let storage events supersede the memory fallback

When a local setItem fails transiently—for example because the origin quota is full—unpersisted remains non-null. If another tab then frees space and writes or clears this preference, this handler calls onChange, but readAdvancedSettingsOpen() still returns the stale in-memory value instead of storage, so the mounted panel ignores the cross-tab choice until it performs another successful local save. Clear or reconcile unpersisted when a relevant storage event arrives.

Useful? React with 👍 / 👎.

@shimmyshimmer
shimmyshimmer force-pushed the studio-remember-advanced-settings branch from f9a724d to bdd0647 Compare August 2, 2026 14:25
A write this tab could not persist kept outranking storage forever, so if
another tab freed the quota and wrote, its choice was ignored until the next
successful local save.

Record what storage held when the write was refused. If storage has moved
since, someone made a newer choice and it takes over. Checked on read rather
than on the storage event, since an event that lands while nothing is mounted
is never replayed.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

Correct, fixed in 1bc7305. Once unpersisted was set it outranked storage unconditionally, so a write from another tab was ignored until the next successful local save.

I did not take the suggested shape though, because clearing it in the storage handler only covers the case where a panel is mounted to receive the event. That is the same gap as the earlier caching report: storage events are not replayed, so an event that lands while every panel is unmounted is lost and the fallback survives it.

Instead the fallback records what storage held when the write was refused. If a later read finds storage no longer holding that, someone made a newer choice and it takes over. That works whether or not anything was mounted when the other tab wrote, and it needs no change to the event handler.

Mutation checked three ways:

  • removing the reconciliation entirely fails a newer choice elsewhere takes over from a refused write, which is the reported bug
  • doing it in the storage handler instead, exactly as suggested, fails that same test, since the test writes with nothing mounted
  • always dropping the fallback fails the two tests that keep the switch usable when storage is refusing writes

13 tests in the file, 299 in the suite, typecheck and build clean, biome check on all three touched source files matches main.

@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 1bc73055d1

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

@shimmyshimmer
shimmyshimmer merged commit 13fdd06 into main Aug 2, 2026
39 of 40 checks passed
@shimmyshimmer
shimmyshimmer deleted the studio-remember-advanced-settings branch August 2, 2026 14:49
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.

1 participant