Skip to content

Commit 28d3fc5

Browse files
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 <[email protected]>
1 parent 9f6e731 commit 28d3fc5

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

client/src/App.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,10 +465,24 @@ const App = () => {
465465
}, [roots]);
466466

467467
useEffect(() => {
468-
if (!window.location.hash) {
469-
window.location.hash = "resources";
468+
if (mcpClient && !window.location.hash) {
469+
const defaultTab = serverCapabilities?.resources
470+
? "resources"
471+
: serverCapabilities?.prompts
472+
? "prompts"
473+
: serverCapabilities?.tools
474+
? "tools"
475+
: "ping";
476+
window.location.hash = defaultTab;
477+
} else if (!mcpClient && window.location.hash) {
478+
// Clear hash when disconnected - completely remove the fragment
479+
window.history.replaceState(
480+
null,
481+
"",
482+
window.location.pathname + window.location.search,
483+
);
470484
}
471-
}, []);
485+
}, [mcpClient, serverCapabilities]);
472486

473487
useEffect(() => {
474488
const handleHashChange = () => {

0 commit comments

Comments
 (0)