#21788: ui(agents): add Start New Session action per agent
app: web-ui
size: S
Cluster:
UI Enhancements and Fixes
## Summary
- add a Start New Session action on the Agents page header for the selected agent
- wire the action to switch to that agent main session key and reuse existing slash-new chat flow
- keep behavior in existing frontend control UI flow (no new backend RPC)
## Files
- ui/src/ui/views/agents.ts
- ui/src/ui/app-render.ts
## Testing
- verified in local OpenClaw control UI runtime: clicking the new button switches to chat and starts a fresh session
- UI build validated in runtime container using npm run build from the ui directory
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR adds a "Start New Session" button to the Agents page header that switches to the selected agent's main session and initiates a fresh chat session. The implementation reuses the existing `/new` chat command flow, avoiding new backend RPC calls.
**Key changes:**
- Added `onStartNewSession` callback to agents view props and wired it through the component hierarchy
- Implemented session switching logic that clears chat state, builds the agent's main session key, and triggers `/new` command
- Added UI button to the agent header metadata section
**Review notes:**
- The state clearing logic duplicates patterns found elsewhere in the codebase (lines 398-414 in app-render.ts are nearly identical to lines 825-841)
- All critical state fields are properly reset before switching sessions
- The implementation correctly delegates to `/new` command which handles session refresh automatically
<h3>Confidence Score: 4/5</h3>
- This PR is safe to merge with minor code quality improvements recommended
- The implementation follows existing patterns correctly and all critical state is properly cleared. However, there's duplicated session-switching logic that could be refactored to use the existing `resetChatStateForSessionSwitch` helper function (app-render.helpers.ts:35). The PR was tested in local runtime and the UI build was validated, reducing integration risk.
- No files require special attention - the changes are straightforward UI enhancements
<sub>Last reviewed commit: b160052</sub>
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#22977: fix(ui): resolve agent names from config in session dropdown
by NikhilGaddam · 2026-02-21
78.0%
#14309: fix(ui): resolve chat event session key mismatch
by justonlyforyou · 2026-02-11
77.6%
#11708: feat(ui): add Delete Session button to /chat page
by andrii-solokh · 2026-02-08
76.6%
#18694: fix(ui): reset session key to main after /new in webchat
by Phineas1500 · 2026-02-17
76.5%
#22798: feat(webchat): ChatGPT-style multi-chat threads with generated titles
by opnsec · 2026-02-21
75.9%
#8774: Fix/frontend session key normalization
by zhaodageng · 2026-02-04
75.2%
#21679: fix: Mission Control dashboard issues for agent status, stale sessi...
by thejawdoc · 2026-02-20
75.1%
#8210: ui: show subagent labels in chat session dropdown
by pborgen · 2026-02-03
75.0%
#13548: feat(control-ui): Add quote reply and send message to session features
by Annaxiebot · 2026-02-10
74.9%
#20072: feat(sessions_spawn): add sessionKey param to reuse sub-agent sessions
by Be1Human · 2026-02-18
74.1%