Repository navigation
Model picker: remember the Run Settings advanced toggle across models - #7747
Conversation
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.
|
@codex review |
There was a problem hiding this comment.
💡 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".
| const [showAdvanced, setShowAdvanced] = useState( | ||
| () => readAdvancedSettingsOpen() || hasNonDefaultAdvanced(config), | ||
| ); |
There was a problem hiding this comment.
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.
|
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 The toggle now goes through a small subscribe and notify pair next to the other model config storage, and the panel reads it with 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. |
There was a problem hiding this comment.
💡 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; |
There was a problem hiding this comment.
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 👍 / 👎.
| localStorage.setItem(ADVANCED_SETTINGS_OPEN_KEY, open ? "true" : "false"); | ||
| } catch { | ||
| // ignore |
There was a problem hiding this comment.
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.
|
Both P2s are correct. Fixed in 7d67d07, and one change covers both. On the auto-open one: On the refused write: Rather than propagate a close to every instance's local flag, the preference is now unset, on, or off, and memory backed:
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 |
There was a problem hiding this comment.
💡 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"; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
|
Both correct again. Fixed in f9a724d. On the reset: 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. Reading on every snapshot is a All four findings across the last two rounds are mutation checked, each against the specific tests that cover it:
11 tests in the file, 297 in the suite, typecheck and build clean, and |
|
@codex review |
There was a problem hiding this comment.
💡 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".
| if (event.key === null || event.key === ADVANCED_SETTINGS_OPEN_KEY) { | ||
| onChange(); |
There was a problem hiding this comment.
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 👍 / 👎.
f9a724d to
bdd0647
Compare
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.
|
Correct, fixed in 1bc7305. Once 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:
13 tests in the file, 299 in the suite, typecheck and build clean, |
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Before
Advanced settingsin 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:
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 preferencesclears the key, which its explicit key list would otherwise have skipped.Notes
The helpers live in
per-model-config.tsnext 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 switchreconciling 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_KEYSfails only the reset testnpm run typecheckcleannpm test: 299 passing, 0 failingnpm run buildcleanbiome checkon all three touched source files matchesmainexactly, and the new test file carries the samenoNodejsModuleswarningssidebar-width.test.tsdoes for the same reason