Skip to content
Merged
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
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,7 @@ jobs:
app/tests/sidebar-current-row.test.tsx
app/tests/sidebar-window-buttons.test.tsx
app/tests/sidebar-zoom-drag.test.tsx
app/tests/sign-in-app-disconnect-layout.test.tsx
app/tests/sign-in-reconnect-layout.test.tsx
app/tests/sign-in-returns-there.test.tsx
app/tests/sign-in-with-apple-layout.test.tsx
Expand Down
70 changes: 57 additions & 13 deletions app/src/components/manage/plugin-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import {
ItemActions,
ItemContent,
ItemDescription,
ItemFooter,
ItemTitle,
} from "@/components/ui/item";
import { Separator } from "@/components/ui/separator";
Expand All @@ -71,6 +72,7 @@ import {
import { vendorNameOf } from "@/lib/apps/vendor-name";
import { currentUserQueryOptions } from "@/lib/auth/queries";
import { isOrganizationAdmin } from "@/lib/auth/roles";
import { disconnectedHere } from "@/lib/connections/disconnected-here";
import { ALWAYS_ON_APP } from "@/lib/connections/rows";
import { storeMcpToken } from "@/lib/credentials/mutations";
import { deploymentCapabilitiesQueryOptions } from "@/lib/deployment/queries";
Expand All @@ -84,6 +86,7 @@ import { atStart, useManagePaths } from "@/lib/manage-paths";
import { signsInForDirectory } from "@/lib/plugins/directory-state";
import {
connectAccountMutationOptions,
disconnectBrokeredMutationOptions,
grantPlugin,
invalidatePlugins,
} from "@/lib/plugins/mutations";
Expand Down Expand Up @@ -497,6 +500,20 @@ export function PluginPage({
window.location.href = authorizationUrl;
},
});
/*
* DISCONNECT, for an app OpenBot signs the person in to itself: the same write a directory app's
* row makes (disconnectApp). The app is asked to end the access where it can be, then OpenBot
* forgets the sign-in, and the row reads as not connected with Connect offered again. A refusal is
* said in the banner, and the row stays Connected.
*
* The row offered nothing here, and the app's switch was the only control on the page: Fireflies
* on OpenBot Desktop read "Connected" with no way to take the account back short of turning the
* app off for every Bot.
*/
const disconnectSelf = useMutation({
...disconnectBrokeredMutationOptions(queryClient),
...report,
});
const entry = catalogue.data?.find((item) => item.key === key);
const server = plugins.data?.find((item) => item.id === key);
/*
Expand Down Expand Up @@ -559,8 +576,8 @@ export function PluginPage({
* Everything the brokered row below reads and does, shared with the personal connected-accounts
* screen that draws the same row. See `brokered-account-row.tsx`.
*
* `connectSelf` above stays: it is the `user-oauth` row's Connect, which is a different row with
* no Disconnect beside it and nothing brokered to confirm.
* `connectSelf` and `disconnectSelf` above stay: they are the `user-oauth` row's Connect and
* Disconnect, which is a different row with nothing brokered to confirm.
*/
const brokeredAccount = useBrokeredAccount({
connectsWith: server?.connectsWith ?? null,
Expand Down Expand Up @@ -1276,9 +1293,9 @@ export function PluginPage({
* and still this person's account and nobody else's.
*
* The two are drawn by different things, which is the honest arrangement rather than
* one row branching on `auth` in five places. A brokered account is ended from here as
* well as begun, and says so; an OAuth one is withdrawn at the vendor and this page
* offers no button pretending otherwise.
* one row branching on `auth` in five places. Both are ended from here as well as begun,
* with the same Disconnect under the row: connect, disconnect and reconnect work the
* same way whichever way an app is connected.
*/}
{auth === "brokered" ? (
<>
Expand Down Expand Up @@ -1356,16 +1373,22 @@ export function PluginPage({
<Item size="sm">
<ItemContent>
<ItemTitle>Your account</ItemTitle>
<ItemDescription>
{/* Never clamped, as a directory app's row isn't: after a disconnect the app
couldn't carry out, it names the one step left, and that is the part a
clamp would cut. */}
<ItemDescription className="line-clamp-none">
{withdrawn
? `Your ${title} connection needs reconnecting.`
: personal
? youConnected
? `Connected. Your Bots use your ${vendorNameOf(title)} as you.`
: `Connect your ${vendorNameOf(title)} account so your Bots can use it.`
: youConnected
? `Connected. A Bot with these tools uses your ${vendorNameOf(title)} as you. Everybody else connects their own.`
: `Connect your own account to try this app. ${reassurance}`}
: !youConnected &&
disconnectSelf.data?.revocationRequested === false
? disconnectedHere(title, entry?.vendor ?? title)
: personal
? youConnected
? `Connected. Your Bots use your ${vendorNameOf(title)} as you.`
: `Connect your ${vendorNameOf(title)} account so your Bots can use it.`
: youConnected
? `Connected. A Bot with these tools uses your ${vendorNameOf(title)} as you. Everybody else connects their own.`
: `Connect your own account to try this app. ${reassurance}`}
</ItemDescription>
</ItemContent>
<ItemActions>
Expand Down Expand Up @@ -1415,6 +1438,27 @@ export function PluginPage({
</>
)}
</ItemActions>
{/*
* DISCONNECT, ON A LINE OF ITS OWN UNDER THE SENTENCE, exactly where a directory
* app's row puts it (`BrokeredAccountRow`). Offered over a withdrawn grant too:
* Reconnect is one way out of that state, and ending the account is the other.
*/}
{youConnected ? (
<ItemFooter className="flex-wrap justify-start">
<Button
disabled={disconnectSelf.isPending}
onClick={() => {
setError(null);
disconnectSelf.mutate(key);
}}
size="sm"
type="button"
variant="outline"
>
Disconnect
</Button>
</ItemFooter>
) : null}
</Item>
)}
</>
Expand Down
11 changes: 11 additions & 0 deletions app/src/lib/connections/disconnected-here.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* What a disconnect says when OpenBot ended its own copy of the sign-in but the app couldn't be
* asked to end it there: the app offers no way to, or didn't answer. Said plainly, so nobody
* believes they ended access the app still lists.
*
* Said by every page that disconnects an app OpenBot signs the person in to itself: the app's own
* page under Apps in either edition, and a person's page for it in the team edition.
*/
export function disconnectedHere(title: string, where: string): string {
return `Disconnected. No Bot can use your ${title} account now. To remove OpenBot from it too, use your ${where} account's third-party access settings.`;
}
11 changes: 3 additions & 8 deletions app/src/routes/_authed/_app/connections.$key.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import { currentUserQueryOptions } from "@/lib/auth/queries";
import { isOrganizationAdmin } from "@/lib/auth/roles";
import { useDropBrokerReturn } from "@/lib/connections/broker-return";
import { useConnectApp } from "@/lib/connections/connect-app";
import { disconnectedHere } from "@/lib/connections/disconnected-here";
import { ALWAYS_ON_APP } from "@/lib/connections/rows";
import { deploymentCapabilitiesQueryOptions } from "@/lib/deployment/queries";
import { useAppsOpen } from "@/lib/enterprise/apps-open";
Expand Down Expand Up @@ -109,14 +110,8 @@ export function addedByMe(
return addedBy.trim().toLowerCase() === email.trim().toLowerCase();
}

/**
* What a disconnect says when OpenBot ended its own copy of the sign-in but the app couldn't be
* asked to end it there: the app offers no way to, or didn't answer. Said plainly, so nobody
* believes they ended access the app still lists.
*/
export function disconnectedHere(title: string, where: string): string {
return `Disconnected. No Bot can use your ${title} account now. To remove OpenBot from it too, use your ${where} account's third-party access settings.`;
}
// The sentence after a disconnect the app couldn't be asked to carry out, shared with the app's page.
export { disconnectedHere };

/** The longest action name this page will repeat back. Real ones are far shorter. */
const MAX_LANDED_ACTION = 200;
Expand Down
216 changes: 216 additions & 0 deletions app/tests/sign-in-app-disconnect-layout.fixture.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
import { QueryClientProvider } from "@tanstack/react-query";
import {
createBrowserHistory,
createRootRoute,
createRoute,
createRouter,
Outlet,
RouterProvider,
} from "@tanstack/react-router";
import { createRoot } from "react-dom/client";
import { TooltipProvider } from "@/components/ui/tooltip";
import { setCurrentOrganization } from "@/lib/organizations/current";
import { queryClient } from "@/query-client";
import { Route as ConnectionsAppRoute } from "@/routes/_authed/_app/connections.$key";
import { ME_PATH, meResponse } from "./accounts-api";
import {
APPS_SETTING_PATH,
appsSettingResponse,
DEPLOYMENT_PATH,
} from "./admin-settings-api";
import { answerAppsApi, type TodayServer } from "./apps-api";
import {
APP_ACCESS_REQUESTS_PATH,
appAccessRequestsResponse,
} from "./bot-grants-api";
import { answerBotsList } from "./bots-api";
import {
accountsPage,
connectionPage,
connectionResponse,
connectionsCall,
disconnectionResponse,
startResponse,
type TodayConnection,
} from "./connections-api";

/**
* Fireflies.ai and Google Sheets on OpenBot Desktop, each app's page under Apps, as a page of its
* own for sign-in-app-disconnect-layout.test.tsx to bundle and load in a browser. The app's own route
* for an app's page sits at `/connections/$key`, which in the personal edition is the whole app, with
* this page playing the server.
*
* Fireflies is added as its own MCP server, which signs each person in; Google Sheets is from the
* directory. Both are connected. `?answer=not-asked` answers a disconnect as the server does where
* the app couldn't be asked to end the access, and `?theme=dark` draws it dark. Every write the page
* sends is kept in order on `window.__events`.
*/
type Page = Window & { __events: string[] };
const page = window as unknown as Page;
page.__events = [];
setCurrentOrganization("default");

const params = new URLSearchParams(location.search);
if (params.get("theme") === "dark")
document.documentElement.classList.add("dark");
const notAsked = params.get("answer") === "not-asked";

const fireflies: TodayServer = {
id: "fireflies",
title: "Fireflies.ai",
vendor: "api.fireflies.ai",
url: "https://api.fireflies.ai/mcp",
provenance: "custom",
signIn: true,
dynamicClient: true,
accountMode: null,
ownerGrants: "any",
everyBot: true,
tools: [
{
name: "fireflies_get_transcripts",
description: "List your meeting transcripts.",
effect: "read",
grantedTo: ["assistant"],
},
],
};
const sheets: TodayServer = {
id: "composio-googlesheets",
title: "Google Sheets",
url: "composio://googlesheets",
provenance: "composio",
authScheme: "OAUTH2",
accountMode: "personal",
ownerGrants: "any",
everyBot: true,
tools: [
{
name: "GOOGLESHEETS_BATCH_GET",
description: "Read values from a spreadsheet.",
effect: "read",
grantedTo: ["assistant"],
},
],
};

let rows: TodayConnection[] = [
{ serverId: "fireflies", scope: "" },
{
serverId: "composio-googlesheets",
verified: true,
verifiedAt: "2026-11-20T09:00:00.000Z",
probe: null,
checkable: false,
canAddAccount: true,
},
];

const original = window.fetch.bind(window);
window.fetch = (async (input: RequestInfo | URL, init?: RequestInit) => {
const url = new URL(String(input), location.origin);
const path = url.pathname;
const method = (init?.method ?? "GET").toUpperCase();
if (!path.startsWith("/api/")) return original(input, init);
if (method !== "GET") page.__events.push(`${method} ${path}`);
if (path === DEPLOYMENT_PATH)
return Response.json({
generativeUi: true,
selfHostBanner: false,
localEvaluation: true,
edition: "personal",
});
if (path === ME_PATH)
return meResponse({ user: { id: "usr_me", role: "admin", name: "Me" } });
if (path === APPS_SETTING_PATH) return appsSettingResponse(false);
if (path === APP_ACCESS_REQUESTS_PATH) return appAccessRequestsResponse([]);
const call = connectionsCall(path, init);
if (call?.operation === "list") return connectionPage(rows);
if (call?.operation === "get") {
const row = rows.find((held) => held.serverId === call.appId);
if (row) return connectionResponse(row);
}
if (call?.operation === "accounts")
return accountsPage([
{
id: "acct-1",
identity: "me@example.com",
label: "me@example.com",
isDefault: true,
connectedAt: "2026-11-20T09:00:00.000Z",
},
]);
if (call?.operation === "disconnect") {
rows = rows.filter((row) => row.serverId !== call.appId);
return disconnectionResponse(!notAsked);
}
if (call?.operation === "connect")
return startResponse({
authorizationUrl: `https://sign-in.example/${call.appId}`,
});
if (call?.operation === "confirm") return Response.json({ connected: true });
const apps = answerAppsApi(input, init, {
servers: [fireflies, sheets],
catalogue: [],
botsMayCallBack: true,
redirectUri: "https://openbot.example/callback",
composioConfigured: true,
provider: "composio",
});
if (apps) return apps;
const bots = answerBotsList(input, init, { visible: [] });
if (bots) return bots;
return Response.json({ error: "Not found." }, { status: 404 });
}) as typeof fetch;

queryClient.setDefaultOptions({ queries: { retry: false } });

const root = createRootRoute({ component: Outlet });
const authed = createRoute({
id: "/_authed",
getParentRoute: () => root,
component: Outlet,
});
const app = createRoute({
id: "/_app",
getParentRoute: () => authed,
component: Outlet,
});
const connections = createRoute({
path: "/connections",
getParentRoute: () => app,
component: () => (
<div className="min-h-svh bg-background text-foreground">
<Outlet />
</div>
),
});
const connectionsIndex = createRoute({
path: "/",
getParentRoute: () => connections,
component: () => <p>Apps</p>,
});
const appPage = (
ConnectionsAppRoute as unknown as { update: (options: unknown) => unknown }
).update({ id: "/$key", path: "/$key", getParentRoute: () => connections });
const router = createRouter({
routeTree: root.addChildren([
authed.addChildren([
app.addChildren([
connections.addChildren([connectionsIndex, appPage as never]),
]),
]),
]),
history: createBrowserHistory(),
});

const mount = document.getElementById("root");
if (mount) {
createRoot(mount).render(
<QueryClientProvider client={queryClient}>
<TooltipProvider>
<RouterProvider router={router as never} />
</TooltipProvider>
</QueryClientProvider>,
);
}
Loading
Loading