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:
Richard Michael 2025-07-23 14:38:38 -07:00
commit 28d3fc56c1

View file

@ -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 = () => {