Commit Graph
2 Commits
Author SHA1 Message Date
Jason 07a9c459a9 fix(openclaw): keep the User-Agent switch in sync with JSON header edits
The Send User-Agent switch was only derived from settingsConfig.headers
on mount and on preset reset. Editing headers directly in the
Configuration JSON editor left it stale in both directions: adding a UA
in JSON kept the switch off (and clicking it then replaced the custom
value with the default UA), removing it kept the switch on.

Add syncOpenclawUserAgentFromConfig to useOpenclawFormState and call it
from the OpenClaw JSON editor's onChange. It only reads valid JSON
objects, sets the switch to the case-insensitive presence of a
User-Agent header, never rewrites the JSON, and keeps the last state
while the draft is invalid.

Refs #8256
2026-10-16 19:29:24 +08:00
Hulk 00db3eef04 fix(openclaw): preserve custom headers when toggling User-Agent (#7847)
The "Send User-Agent" toggle in the OpenClaw form replaced the whole
headers object when turned on and deleted it when turned off, so every
other custom header was lost on save.

Update only the User-Agent entry: drop existing variants
case-insensitively, add a canonical User-Agent when enabled, and remove
the headers object only when it ends up empty. Detecting the toggle
state is case-insensitive as well.

Fixes #7846
2026-10-10 12:05:10 +08:00