Skip to content

fix(ui): reset overview model controls when switching agents - #39401

Closed
SergioChan wants to merge 1 commit into
openclaw:mainfrom
SergioChan:fix/agent-model-stale-39392
Closed

SergioChan wants to merge 1 commit into
openclaw:mainfrom
SergioChan:fix/agent-model-stale-39392

Conversation

@SergioChan

Copy link
Copy Markdown

Summary

  • Problem: the Control UI could show a stale/wrong model selection value after switching agents (e.g. main → youtubeagent → main) without saving.
  • Why it matters: users can be misled into thinking an agent model changed when backend config/runtime are unchanged.
  • What changed: wrapped the Overview panel rendering with Lit's keyed(selectedAgent.id, ...) so the model/fallback form controls remount per agent switch.
  • What did NOT change (scope boundary): no backend config logic, persistence, or model resolution code paths were modified.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

User-visible / Behavior Changes

  • Agent Overview model controls now reset correctly per selected agent, avoiding stale model display after agent switching.

Security Impact (required)

  • New permissions/capabilities? (No)
  • Secrets/tokens handling changed? (No)
  • New/changed network calls? (No)
  • Command/tool execution surface changed? (No)
  • Data access scope changed? (No)
  • If any Yes, explain risk + mitigation:

Repro + Verification

Environment

  • OS: Linux (WSL2)
  • Runtime/container: Node + Vite/Lit Control UI
  • Model/provider: N/A (UI rendering fix)
  • Integration/channel (if any): N/A
  • Relevant config (redacted): multi-agent config with distinct model assignments

Steps

  1. Open Control UI Agents page, select main and observe model control value.
  2. Switch to another agent with a different model, then switch back to main.
  3. Verify displayed model selection matches main consistently after switching.

Expected

  • Model selection reflects the currently selected agent and does not leak prior agent UI state.

Actual

  • With this patch: model selection remounts per selected agent and remains consistent.

Evidence

Attach at least one:

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Validation run:

  • pnpm -C ui build
  • pnpm -C ui test src/ui/views/agents-utils.test.ts

Human Verification (required)

What you personally verified (not just CI), and how:

  • Verified scenarios: agent switch path described in issue, with per-agent model control reset behavior.
  • Edge cases checked: repeated switching between agents with different model IDs.
  • What you did not verify: full end-to-end manual browser video capture.

Compatibility / Migration

  • Backward compatible? (Yes)
  • Config/env changes? (No)
  • Migration needed? (No)
  • If yes, exact upgrade steps:

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly: revert commit c193a1a1c.
  • Files/config to restore: ui/src/ui/views/agents.ts.
  • Known bad symptoms reviewers should watch for: unnecessary remount side-effects in Overview panel interactions.

Risks and Mitigations

  • Risk: overview panel remount could reset unsaved transient input state on agent switch.
    • Mitigation: this is desired for per-agent isolation and prevents stale cross-agent state leakage.

@greptile-apps

greptile-apps Bot commented Mar 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a UI bug where the model selection controls in the Agent Overview panel would display stale/incorrect values after switching between agents. The fix wraps renderAgentOverview with Lit's keyed(selectedAgent.id, ...) directive, ensuring the entire Overview panel DOM is torn down and reconstructed whenever the active agent changes — preventing cross-agent state bleed on the form controls.

  • The change is minimal and well-targeted: one import added, one call wrapped with keyed.
  • Usage of keyed is idiomatic Lit: the key is selectedAgent.id (the natural per-agent discriminator), and the value is the TemplateResult returned by renderAgentOverview, which is a valid renderable for the directive.
  • The rest of the codebase (other panels, backend config paths) is intentionally untouched per the stated scope boundary.
  • The side-effect of resetting unsaved transient input state on agent switch is acknowledged in the PR as the desired behavior for per-agent isolation.

Confidence Score: 5/5

  • This PR is safe to merge — it is a minimal, correct, idiomatic Lit fix with no backend or API surface changes.
  • The change is a single-directive wrap using a well-documented Lit API. The key (selectedAgent.id) correctly identifies agent-switch events, and the value is a proper TemplateResult. There are no logic branches, no new state, and no network/data-layer impact. The acknowledged side-effect (resetting unsaved form state on agent switch) is the intended behavior.
  • No files require special attention.

Last reviewed commit: c193a1a

@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 23, 2026
@clawsweeper

clawsweeper Bot commented Apr 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex automated review: keeping this open.

Keep #39401 open. Current main still renders the Agents overview directly without the proposed keyed(selectedAgent.id, ...) remount boundary or another selected-agent reset for the overview model controls, and the linked bug #39392 remains a concrete open repro. Related PR #39495 is closed unmerged, so it is not a shipped superseder.

Best possible solution:

Keep #39401 open or nominate a fresh canonical PR for #39392. The best implementation path is to add a per-selected-agent remount/reset boundary around the Agents overview model controls, then add focused regression coverage that switches between agents with different model settings and verifies the displayed primary/fallback controls reflect the selected agent.

What I checked:

Remaining risk / open question:

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

@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Apr 26, 2026
@vincentkoc

Copy link
Copy Markdown
Member

ProjectClownfish could not safely update this branch, so it opened a narrow replacement PR instead.

Replacement PR: #72328
Source PR: #39401
Contributor credit is preserved in the replacement PR body and changelog plan.

@vincentkoc

Copy link
Copy Markdown
Member

ProjectClownfish could not safely update this branch, so it opened a narrow replacement PR instead.

Replacement PR: #72328
Source PR: #39401
Contributor credit is preserved in the replacement PR body and changelog plan.

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

2 participants