Skip to content

Profiles: Make settings reset remove the saved value - #944

Closed
tobocop2 wants to merge 3 commits into
feat/settings-resolverfrom
feat/reset-unsets
Closed

tobocop2 wants to merge 3 commits into
feat/settings-resolverfrom
feat/reset-unsets

Conversation

@tobocop2

@tobocop2 tobocop2 commented Sep 27, 2026 •

Copy link
Copy Markdown
Owner

Problem

Resetting a setting wrote its default back into config.toml. The reset value then counted as a user value: it hid any later change to the default or a profile, and the setting would show as "set by you". Resetting a checkbox in the TUI also wrote the old value straight back.

Solution

A reset now deletes the key from config.toml, and the setting takes whatever it falls back to: the environment variable, else the profile's value, else the built-in. The TUI reset keys, reset-all, the list restore button and the MCP lilbee_settings_reset tool all use it. After a reset, leaving the field writes nothing.

POST /api/config/reset takes {"keys": [...]} and answers like a PATCH, with a 200 and the same shape. Unknown keys, documents_dir, model roles, and a key whose fallback value fails validation are refused with a 400. The MCP settings tools report default as the value a reset falls back to.

Notes

GET /api/config/defaults is unchanged and still returns the built-in values. The Obsidian plugin moves to the reset route in its own change.

This stacks on #941.

@tobocop2
tobocop2 added this pull request to stack #942 September 27, 2026 07:40
@tobocop2
tobocop2 force-pushed the feat/reset-unsets branch 2 times, most recently from 484dc96 to a3f8ee7 Compare September 27, 2026 08:29
@tobocop2 tobocop2 changed the title Make settings reset remove the saved value Profiles: Make settings reset remove the saved value Sep 27, 2026
@tobocop2
tobocop2 marked this pull request as ready for review September 27, 2026 22:30
Reset deleted the key only for nullable settings whose default is None
and otherwise wrote the built-in value back to config.toml. A written
value counts as the user's, so it hid any profile value and outlived
the reset.

Reset now removes each key from config.toml and sets cfg from the
resolver, so the env variable, the profile or the built-in value takes
over. It validates the values the keys will resolve to before it
writes, so a reset cannot leave chunk_overlap at or above chunk_size.
A reset of a key that is not in the file writes nothing.

POST /api/config/reset takes {"keys": [...]} and answers in the
shape PATCH /api/config uses. It refuses the
keys PATCH refuses: a provider switch and the model role slots.
GET /api/config/defaults still answers the built-in values.

The TUI reset button, ctrl+r, reset-all and the list editor's restore
button all call the same reset and then show the resolved value. A
refreshed checkbox no longer emits its change event, which wrote the
reset value straight back as a user value.
A reset with the same key twice deleted it twice and raised KeyError,
so the HTTP route answered 500 and the MCP tool raised. The config
writer now removes each key once.

A reset whose fallback is a profile value the field rejects removed
the user value and left cfg on it. The reset now checks each fallback
against its field first and refuses with an error that names the key,
the source and the value; nothing is written.

The MCP settings default is now what a reset falls back to without an
env variable: the profile value, else the built-in. POST
/api/config/reset answers 200 like PATCH, and the documents_dir
refusal no longer tells HTTP and TUI users to call an MCP tool.

New tests cover reset then blur for Select, multiline and list
editors, validation against a profile value, and the list restore
title and error.
@tobocop2
tobocop2 marked this pull request as draft September 27, 2026 23:51
A reset settles through the same step as an update, and that step
reports a setting left in conflict, such as OCR off with a vision
model set. The reset route answered an empty warnings list, the MCP
reset result had no warnings key, and the TUI reset showed no toast.

Each surface now carries the reset's warnings the way it carries an
update's: the route and the MCP tool return them in warnings, and the
TUI toasts each one.
@tobocop2

tobocop2 commented Oct 3, 2026

Copy link
Copy Markdown
Owner Author

This change is now part of #1003, which collects every Profiles pull request on one branch. Review and merge happen there. The branch stays in place.

@tobocop2 tobocop2 closed this Oct 3, 2026
@tobocop2
tobocop2 deleted the feat/reset-unsets branch November 1, 2026 06:08
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