fix(ui): preserve selected agent after config save on agents page#39301
fix(ui): preserve selected agent after config save on agents page#39301MumuTW wants to merge 1 commit intoopenclaw:mainfrom
Conversation
Greptile SummaryThis PR fixes a UI regression on the Key changes:
Confidence Score: 5/5
Last reviewed commit: cb44463 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cb44463f28
ℹ️ 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".
| selectedBefore && | ||
| state.agentsList?.agents.some((a) => a.id === selectedBefore) | ||
| ) { | ||
| state.agentsSelectedId = selectedBefore; |
There was a problem hiding this comment.
Avoid restoring a stale agent selection after async save
selectedBefore is captured, then saveConfig and loadAgents are awaited before this value is written back. If state.agentsSelectedId changes during that async window (for example, the user selects a different agent while save is in flight), this assignment forces the old ID back and overrides the newer selection. This creates a reproducible UI jump that looks like user input was ignored; restore should be conditional on the selection still matching the pre-save value.
Useful? React with 👍 / 👎.
cb44463 to
079c913
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 079c913cf1
ℹ️ 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 ( | ||
| selectedBefore && | ||
| state.agentsList?.agents.some((a) => a.id === selectedBefore) | ||
| ) { | ||
| state.agentsSelectedId = selectedBefore; |
There was a problem hiding this comment.
Guard selection restore against in-flight user changes
This restore step can overwrite a newer user selection made while save/reload is in progress: selectedBefore is captured before await saveConfig(state) and await loadAgents(state), then written back unconditionally if still present. Fresh evidence: agent row clicks remain active during saves (ui/src/ui/views/agents.ts:137-141), so a user can switch agents mid-save and then get forced back to the old one here, causing a visible selection jump and stale panel data.
Useful? React with 👍 / 👎.
079c913 to
15b393b
Compare
15b393b to
0448f39
Compare
Landed from contributor PR #39301 by @MumuTW. Co-authored-by: MumuTW <[email protected]>
|
Rebased onto the latest What changed on top of the original PR:
Landed commit: c0a7c30 Thanks @MumuTW. |
Landed from contributor PR openclaw#39301 by @MumuTW. Co-authored-by: MumuTW <[email protected]>
Landed from contributor PR openclaw#39301 by @MumuTW. Co-authored-by: MumuTW <[email protected]>
Landed from contributor PR openclaw#39301 by @MumuTW. Co-authored-by: MumuTW <[email protected]>
Landed from contributor PR openclaw#39301 by @MumuTW. Co-authored-by: MumuTW <[email protected]>
Landed from contributor PR openclaw#39301 by @MumuTW. Co-authored-by: MumuTW <[email protected]>
Landed from contributor PR openclaw#39301 by @MumuTW. Co-authored-by: MumuTW <[email protected]>
Landed from contributor PR openclaw#39301 by @MumuTW. Co-authored-by: MumuTW <[email protected]>
Landed from contributor PR openclaw#39301 by @MumuTW. Co-authored-by: MumuTW <[email protected]>
Landed from contributor PR openclaw#39301 by @MumuTW. Co-authored-by: MumuTW <[email protected]> (cherry picked from commit c0a7c30)
) * Secrets: refresh baseline for tts line drift (cherry picked from commit 0018f47) * fix: auto-create inherited agent override entries Landed from contributor PR openclaw#39326 by @dunamismax. Co-authored-by: dunamismax <[email protected]> (cherry picked from commit 49261b0) * fix: preserve agents-page selection after config save Landed from contributor PR openclaw#39301 by @MumuTW. Co-authored-by: MumuTW <[email protected]> (cherry picked from commit c0a7c30) * Agents UI: compose save state from config state (cherry picked from commit 96f4f50) * Agents UI: complete config state test fixture (cherry picked from commit 0125bd9) * Secrets: refresh baseline for model provider docs (cherry picked from commit 14916fb) * docs: dedupe changelog contributor attribution (cherry picked from commit 75a44de) * build: reduce build log noise (cherry picked from commit dd8fd98) * build: prepare 2026.3.7-beta.1 release (cherry picked from commit 3596a46) * fix(ui): align control-ui device auth token signing (cherry picked from commit e0f80cf) * build: prepare 2026.3.7 release (cherry picked from commit 42a1394) --------- Co-authored-by: Vincent Koc <[email protected]> Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: dunamismax <[email protected]> Co-authored-by: MumuTW <[email protected]>
Summary
Fixes #39254.
When editing a non-default agent on the
/agentspage and saving config changes, the UI resets back to the default agent instead of staying on the edited agent.Root cause: The
onConfigSavehandler for the agents page calledsaveConfig(state)without reloading the agents list or preserving the selected agent ID. When the config save triggers a gateway reconnect cycle, the agent selection could be lost.Fix: The agents page
onConfigSavehandler now:This mirrors the pattern used by
handleChannelConfigSavewhich also reloads related data after config saves.Test plan
loadAgentsverifying:pnpm testpassespnpm checkpasses