Skip to content

fix(ui): sort MCP tools by name and lead the template page back to the chat - #3644

Draft
cjlg-soloio wants to merge 2 commits into
kagent-dev:mainfrom
cjlg-soloio:cjlg-soloio/issueFollowups
Draft

cjlg-soloio wants to merge 2 commits into
kagent-dev:mainfrom
cjlg-soloio:cjlg-soloio/issueFollowups

Conversation

@cjlg-soloio

Copy link
Copy Markdown
Contributor

🤖 written by Claude (start)

Changelog

MCP server tools are listed alphabetically, and an AgentTemplate opened from a chat now has a button back to that conversation.

/kind fix

Changes

Sorts each MCP server's tools by name, styles the chat panel's Template link with a hover state and tooltip, and gives the AgentTemplate page a "Back to conversation" button when opened from that link, via a small useBackLink hook in ui/src/router/backLink.ts that reads router state and only follows in-app paths.

Testing

  1. In ui/, run KAGENT_UI_ENABLE_MOCK=true yarn dev, open /mcp and expand kagent-tool-server: tools read k8s_describe_resource, k8s_get_events, k8s_get_pods, and stay in that order when you search k8s_get.
  2. Open an agent's chat at a wide window, hover the right panel's Template link (underline and tooltip), click it, and use "Back to conversation" to return to the same chat.
  3. Open the same template from Agents → Templates: the button says "Back to templates".

🤖 written by Claude (end)

🤖 Generated with Claude Code

…e chat

- The tools an MCP server reports are listed alphabetically (numeric-aware)
  on the MCP servers page and the app detail page, instead of in discovery
  order.
- The chat context panel's Template link reads as a link: it underlines on
  hover or focus and has a tooltip saying it opens the AgentTemplate.
- Opened from that link, the AgentTemplate page's back button says "Back to
  conversation" and returns to the same chat. A direct visit still says
  "Back to templates". The origin travels in router state through a small
  `useBackLink` hook, which only follows in-app paths.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Carlos Logroño Guerrero <carlos.logrono@solo.io>
@github-actions github-actions Bot added the bug Something isn't working label Nov 11, 2026

@cjlg-soloio cjlg-soloio left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This automated review is a first pass. A manual review will follow once the blockers are addressed.


Two issues block merge. The template page tells people it leads back to a conversation when they came from the agent's own page. And switching tabs on the template page loses the way back.

⚠️ What I checked
  • MCP tool sort: numeric-aware localeCompare, applied inside ToolServerTools, so the MCP servers page and the app detail page both get it ✅
  • backLink.ts: accepts only state whose from starts with / and not //, with a non-empty label, and falls back otherwise ✅
  • Wrapping a react-router Link in an antd Tooltip: RR7's Link forwards its ref and the hover/focus handlers, and no wrapper element is added ✅
  • Back-link label for every place the context panel renders: the chat and the agent page (AgentPage.tsx:611)
  • Router state surviving in-page navigation on the template page: tabs, delete
  • Keyboard access to the new tooltip
  • Forbidden terms in the diff, title and body ✅

🤖 written by Claude

…y origin

- The context panel's link labels the way back "Back to agent" when no
  conversation is open, and its tooltip also opens on keyboard focus.
- Switching tabs on the AgentTemplate page carries the router state, so the
  back button keeps pointing at where the reader came from. Returning replaces
  the history entry.
- Tools whose names differ only in case get a fixed order.
- An e2e test covers chat → template → tab switch → back to the same chat.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Carlos Logroño Guerrero <carlos.logrono@solo.io>
@cjlg-soloio

cjlg-soloio commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor Author

Before (main) and after (this branch), recorded on a fresh kind cluster built from this branch, with a real k8s-helper agent, its AgentTemplate and a real conversation.

  • MCP tools order: the expanded server lists its tools A–Z in the UI. This controller already reports kagent-tool-server's tools in name order, so on this data main looks the same; the sort makes the order independent of what the controller sends.
  • Template link: the chat panel's link underlines on hover or focus, and a tooltip says it opens the AgentTemplate.
  • Way back: opened from the chat, the template page says "Back to conversation", keeps it across tabs and returns to the same chat; main sends you to the template list.
  • Direct visit: still "Back to templates".
verify-3644.mp4

Screenshots

Before: Template link on hover before-template-link-hover
After: underline and tooltip after-template-link-hover
Before: template opened from the chat before-template-back-from-chat
After: Back to conversation after-template-back-from-chat
Before: back lands on the template list before-template-back-lands
After: back in the same conversation after-template-back-lands
Before: direct visit before-template-back-direct
After: direct visit unchanged after-template-back-direct
Before: MCP tools, filtered to k8s_get before-mcp-tools-order
After: MCP tools, filtered to k8s_get after-mcp-tools-order

🤖 written by Claude

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant