Skip to content

Commit 8ef8fd1

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 <noreply@anthropic.com>
1 parent 1ea8e9a commit 8ef8fd1

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
@@ -377,10 +377,24 @@ const App = () => {
377377
}, [roots]);
378378

379379
useEffect(() => {
380-
if (!window.location.hash) {
381-
window.location.hash = "resources";
380+
if (mcpClient && !window.location.hash) {
381+
const defaultTab = serverCapabilities?.resources
382+
? "resources"
383+
: serverCapabilities?.prompts
384+
? "prompts"
385+
: serverCapabilities?.tools
386+
? "tools"
387+
: "ping";
388+
window.location.hash = defaultTab;
389+
} else if (!mcpClient && window.location.hash) {
390+
// Clear hash when disconnected - completely remove the fragment
391+
window.history.replaceState(
392+
null,
393+
"",
394+
window.location.pathname + window.location.search,
395+
);
382396
}
383-
}, []);
397+
}, [mcpClient, serverCapabilities]);
384398

385399
const handleApproveSampling = (id: number, result: CreateMessageResult) => {
386400
setPendingSampleRequests((prev) => {

0 commit comments

Comments
 (0)