Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 49 additions & 11 deletions mcpjam-inspector/client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import { SupportTab } from "./components/SupportTab";
import { RegistryTab } from "./components/RegistryTab";
import OAuthDebugCallback from "./components/oauth/OAuthDebugCallback";
import { MCPSidebar } from "./components/mcp-sidebar";
import type { SidebarSignOut } from "./components/sidebar/sidebar-user";
import { SidebarInset, SidebarProvider } from "./components/ui/sidebar";
import {
Alert,
Expand Down Expand Up @@ -250,7 +251,7 @@ function sanitizeOAuthDebuggerText(value: string | null | undefined): string {
const separator = typeof args[2] === "string" ? args[2] : undefined;
return key && separator ? `${key}${separator}[redacted]` : "[redacted]";
}),
value,
value
);
}

Expand Down Expand Up @@ -816,6 +817,27 @@ export default function App() {
const server = runtimeServer ?? projectServer;
return server ? { runtimeServer, projectServer, server } : null;
}, []);
const handleSignOut = useCallback<SidebarSignOut>(
async (options) => {
const serverNamesToDisconnect = Object.entries(appState.servers)
.filter(([, server]) => server.connectionStatus !== "disconnected")
.map(([serverName]) => serverName);

await Promise.allSettled(
serverNamesToDisconnect.map((serverName) =>
handleDisconnect(serverName)
)
);

if (options?.navigate === false) {
await signOut(options);
return;
}

signOut(options);
},
[appState.servers, handleDisconnect, signOut]
);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
useEffect(() => {
return subscribeToOAuthDebuggerRequests(({ serverName }) => {
const matchedServerName = Object.entries(
Expand Down Expand Up @@ -1288,6 +1310,21 @@ export default function App() {
setSelectedMultipleServersToAllServers,
]
);
const previousActiveProjectIdRef = useRef(activeProjectId);

useEffect(() => {
const previousActiveProjectId = previousActiveProjectIdRef.current;
previousActiveProjectIdRef.current = activeProjectId;

if (
previousActiveProjectId === activeProjectId ||
previousActiveProjectId === "none"
) {
return;
}

applyNavigation("servers", { updateHash: true });
}, [activeProjectId, applyNavigation]);

useLayoutEffect(() => {
if (HOSTED_MODE) {
Expand Down Expand Up @@ -1666,8 +1703,8 @@ export default function App() {
section === "billing"
? `organizations/${organizationId}/billing`
: section === "models"
? `organizations/${organizationId}/models`
: `organizations/${organizationId}`,
? `organizations/${organizationId}/models`
: `organizations/${organizationId}`,
{ updateHash: true }
);
return;
Expand Down Expand Up @@ -2002,6 +2039,7 @@ export default function App() {
activeOrganizationName={activeOrganizationName}
onSwitchOrganization={handleSidebarSwitchOrganization}
onSwitchActiveOrganization={handleSwitchActiveOrganization}
onSignOut={handleSignOut}
onProjectShared={handleProjectShared}
billingUiEnabled={billingUiEnabled}
billingGateDenied={sidebarGateDenied}
Expand Down Expand Up @@ -2237,7 +2275,7 @@ export default function App() {
?.writeText(details)
.then(() => toast.success("Copied OAuth debugger error"))
.catch(() =>
toast.error("Could not copy OAuth debugger error"),
toast.error("Could not copy OAuth debugger error")
);
};

Expand Down Expand Up @@ -2272,7 +2310,7 @@ export default function App() {
message: sanitizedError.message,
stack: sanitizedError.stack,
componentStack: sanitizeOAuthDebuggerText(
errorInfo.componentStack,
errorInfo.componentStack
),
});
}}
Expand Down Expand Up @@ -2355,11 +2393,11 @@ export default function App() {
/>
)}
{activeTab === "settings" && (
<SettingsTab
activeOrganizationId={activeOrganizationId}
onNavigate={handleNavigate}
/>
)}
<SettingsTab
activeOrganizationId={activeOrganizationId}
onNavigate={handleNavigate}
/>
)}
{activeTab === "support" && <SupportTab />}
{activeTab === "profile" && <ProfileTab />}
{activeTab === "organizations" && (
Expand Down Expand Up @@ -2474,7 +2512,7 @@ export default function App() {
signIn();
}}
onSignOut={() => {
void signOut();
void handleSignOut();
}}
>
{isSharedChatRoute ? (
Expand Down
Loading
Loading