← Back to PRs

#21788: ui(agents): add Start New Session action per agent

by rt219 open 2026-02-20 11:08 View on GitHub →
app: web-ui size: S
## 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