Skip to content

fix(ui): reset agent overview model form on agent switch - #39495

Closed
aworki wants to merge 1 commit into
openclaw:mainfrom
aworki:fix/control-ui-agent-model-switch
Closed

aworki wants to merge 1 commit into
openclaw:mainfrom
aworki:fix/control-ui-agent-model-switch

Conversation

@aworki

@aworki aworki commented Mar 8, 2026

Copy link
Copy Markdown

Summary

  • key the Agents overview panel by selectedAgent.id
  • force a remount of the model/fallback form controls when switching agents

Why

Control UI could show stale model selection after switching main -> another agent -> main due to reused form element state across agent switches. Backend/runtime config remained correct, but the visible model dropdown could drift.

Behavior after fix

When switching agents, the overview form is recreated for the selected agent id, so model/fallback controls always reflect that agent's own resolved config state.

Test evidence

  • pnpm vitest run --config vitest.unit.config.ts ui/src/ui/controllers/agents.test.ts ui/src/ui/views/agents-utils.test.ts
    • Passed: 2 files, 14 tests

Fixes #39392

@greptile-apps

greptile-apps Bot commented Mar 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a UI stale-state bug in the Agents overview panel where the model/fallback form controls could display the wrong values after switching agents (e.g. main → another agent → main). The fix is minimal and correct: wrapping renderAgentOverview with Lit's keyed(selectedAgent.id, ...) directive forces the DOM to be torn down and rebuilt whenever the selected agent changes, resetting any native <select> and <input> element state that was accumulating across agent switches.

Key observations:

  • The use of keyed is idiomatic and appropriate for this exact scenario in Lit — it's the recommended pattern for forcing remount on key change.
  • The backend/runtime state was never affected; this was purely a DOM-side drift in native form element .value.
  • Other panels (files, tools, skills, channels, cron) are unaffected since they are already destroyed/recreated whenever you navigate away from them via the nothing fallback — the overview panel, however, needed keying because it can be the active panel during an agent switch.

Confidence Score: 5/5

  • This PR is safe to merge — it is a minimal, targeted fix using a well-established Lit primitive with no logic changes and no risk of regressions.
  • The change is a single-line-of-intent addition (import + keyed wrapper) that uses a standard Lit directive exactly as designed. It does not touch state management, event handlers, or data flow. The fix directly addresses the root cause of stale form state after agent switches by forcing DOM remount. The PR description clearly explains the problem, the solution is idiomatic Lit, and tests were run and passed.
  • No files require special attention

Last reviewed commit: ff6bb05

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Apr 24, 2026
@clawsweeper

clawsweeper Bot commented Apr 26, 2026 •

Copy link
Copy Markdown
Contributor

Closing this as duplicate or superseded after Codex automated review.

#39495 is a duplicate patch attempt for the same remaining Agents Overview model-control bug already tracked by the earlier open PR #39401 and linked bug #39392. Current main does not implement the fix, so the right cleanup is to close this PR only as duplicate and keep the canonical bug/fix path open.

Best possible solution:

Close #39495 as a duplicate patch attempt and keep #39401 plus linked issue #39392 as the canonical path. The eventual fix should adapt one keyed/remount or equivalent explicit reset for the Agents Overview model/fallback controls and add a regression test for switching agents while staying on the Overview panel.

What I checked:

So I’m closing this here and keeping the remaining discussion on the canonical linked item.

Codex Review notes: model gpt-5.5, reasoning high; reviewed against b67d9bf7f06f.

@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Apr 26, 2026
@clawsweeper clawsweeper Bot closed this Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Agent switch causes stale/wrong model selection UI in Control UI

1 participant