Update URL fragment to only appear when connected
- Only set URL fragment when mcpClient is connected - Set default fragment based on server capabilities priority (resources > prompts > tools > ping) - Clear fragment when disconnected to prevent stale routing state 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
9f6e731dc4
commit
28d3fc56c1
1 changed files with 17 additions and 3 deletions
|
|
@ -465,10 +465,24 @@ const App = () => {
|
|||
}, [roots]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!window.location.hash) {
|
||||
window.location.hash = "resources";
|
||||
if (mcpClient && !window.location.hash) {
|
||||
const defaultTab = serverCapabilities?.resources
|
||||
? "resources"
|
||||
: serverCapabilities?.prompts
|
||||
? "prompts"
|
||||
: serverCapabilities?.tools
|
||||
? "tools"
|
||||
: "ping";
|
||||
window.location.hash = defaultTab;
|
||||
} else if (!mcpClient && window.location.hash) {
|
||||
// Clear hash when disconnected - completely remove the fragment
|
||||
window.history.replaceState(
|
||||
null,
|
||||
"",
|
||||
window.location.pathname + window.location.search,
|
||||
);
|
||||
}
|
||||
}, []);
|
||||
}, [mcpClient, serverCapabilities]);
|
||||
|
||||
useEffect(() => {
|
||||
const handleHashChange = () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue