Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

feat(plugins-ui): in-app own-OAuth-client dialog + keep-connected hint

Ruben Lütkea7f56aebab20
diff --git a/jarvis/ui/web/frontend/src/views/PluginsView.test.tsx b/jarvis/ui/web/frontend/src/views/PluginsView.test.tsx
index 9c90d34d84..1c91a1458a 100644
--- a/jarvis/ui/web/frontend/src/views/PluginsView.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/PluginsView.test.tsx
@@ -273,6 +273,60 @@ describe("PkceConnectDialog own-client + production hint", () => {
});
});
+describe("PluginsView opens the PKCE pre-connect dialog", () => {
+ it("shows the own-client dialog instead of starting OAuth immediately", async () => {
+ const fetchMock = vi.fn(async (input: RequestInfo | URL) => {
+ const url = String(input);
+ if (url === "/api/marketplace/plugins") {
+ return {
+ ok: true,
+ status: 200,
+ json: async () => ({
+ version: 1,
+ schema_version: "t",
+ total: 1,
+ connected: 0,
+ plugins: [
+ {
+ id: "gmail",
+ display_name: "Gmail",
+ description: "Mail",
+ category: "Communication",
+ logo_slug: "gmail",
+ auth: { mode: "oauth_pkce_loopback" },
+ status: "not_connected",
+ live_callable: false,
+ },
+ ],
+ }),
+ } as Response;
+ }
+ // A /connect/start hit here would mean OAuth fired immediately (the old
+ // behaviour) — make that an explicit failure.
+ throw new Error(`unexpected fetch ${url}`);
+ });
+ (globalThis as unknown as { fetch: typeof fetch }).fetch =
+ fetchMock as unknown as typeof fetch;
+
+ renderPluginsView();
+ // Wait for the real row's Connect button (the "Gmail" text alone also appears
+ // in the static "Coming soon" strip before data loads, so it isn't a safe
+ // signal that the row has rendered).
+ await waitFor(() =>
+ expect(
+ screen.getByRole("button", { name: "Connect plugin" }),
+ ).toBeDefined(),
+ );
+
+ fireEvent.click(screen.getByRole("button", { name: "Connect plugin" }));
+
+ await waitFor(() =>
+ expect(screen.getByRole("dialog")).toBeDefined(),
+ );
+ expect(screen.getByText(/Connect Gmail/i)).toBeDefined();
+ });
+});
+
describe("PluginsView keeps revoked plugins visible", () => {
it("shows a needs_reauth plugin under Installed with a Reconnect-needed badge", async () => {
const fetchMock = vi.fn(async (input: RequestInfo | URL) => {
diff --git a/jarvis/ui/web/frontend/src/views/PluginsView.tsx b/jarvis/ui/web/frontend/src/views/PluginsView.tsx
index 008d286f0a..c28b0d18b0 100644
--- a/jarvis/ui/web/frontend/src/views/PluginsView.tsx
+++ b/jarvis/ui/web/frontend/src/views/PluginsView.tsx
@@ -181,6 +181,8 @@ export function PluginsView() {
const [query, setQuery] = useState("");
const [filter, setFilter] = useState<FilterId>("all");
const [connectingPlugin, setConnectingPlugin] = useState<Plugin | null>(null);
+ // PKCE plugin awaiting the pre-connect dialog (own-client + keep-connected hint).
+ const [pkceSetupPlugin, setPkceSetupPlugin] = useState<Plugin | null>(null);
// Plugin awaiting a "really disconnect?" confirmation. Removing a plugin is
// destructive (tokens dropped, brain tools re-expanded), so it must ask first.
const [disconnectingPlugin, setDisconnectingPlugin] = useState<Plugin | null>(null);
@@ -271,65 +273,79 @@ export function PluginsView() {
expiresAtMs: number | null;
} | null>(null);
+ // Kick off the real OAuth handshake: /connect/start, open the URL, then the
+ // dialog long-polls /connect/poll. Shared by the DCR/device path (called
+ // directly) and the PKCE path (called by the pre-connect dialog's Continue).
+ const startOAuthFlow = async (p: Plugin) => {
+ try {
+ const r = await oauthStart.mutateAsync(p.id);
+ if (r.kind === "device_flow") {
+ // GitHub-style: show the user_code in a dedicated dialog,
+ // pre-open the verification URL with code embedded if present.
+ const verifyUrl = (r as unknown as { verification_uri?: string })
+ .verification_uri;
+ const verifyUrlComplete = (r as unknown as {
+ verification_uri_complete?: string;
+ }).verification_uri_complete;
+ const userCode = (r as unknown as { user_code?: string }).user_code;
+ if (!verifyUrl || !userCode) {
+ alert("Backend returned an incomplete device-flow session.");
+ return;
+ }
+ // Auto-open the pre-filled verify URL if available; user lands
+ // on the consent page with the code already typed in.
+ if (verifyUrlComplete) {
+ void openExternalUrl(verifyUrlComplete);
+ }
+ setDeviceSession({
+ flowId: r.flow_id,
+ pluginId: r.plugin_id,
+ pluginName: p.name,
+ userCode,
+ verificationUri: verifyUrl,
+ verificationUriComplete: verifyUrlComplete ?? null,
+ expiresAtMs: r.expires_at_ms,
+ });
+ return;
+ }
+ if (!r.open_url) {
+ alert("Backend returned no open_url — connect aborted.");
+ return;
+ }
+ void openExternalUrl(r.open_url);
+ setOauthSession({
+ flowId: r.flow_id,
+ pluginId: r.plugin_id,
+ pluginName: p.name,
+ openUrl: r.open_url,
+ });
+ } catch (e) {
+ alert(
+ `Could not start ${p.name} connect flow: ${
+ e instanceof Error ? e.message : String(e)
+ }`,
+ );
+ }
+ };
+
const handleConnect = async (p: Plugin) => {
if (p.authMode === "pat_paste") {
setConnectingPlugin(p);
return;
}
+ if (p.authMode === "oauth_pkce_loopback") {
+ // PKCE plugins ship a placeholder client — show the pre-connect dialog so
+ // the user can supply their OWN production OAuth client (the durable fix
+ // for the 7-day expiry) and sees the keep-connected hint, before the
+ // browser sign-in actually starts.
+ setPkceSetupPlugin(p);
+ return;
+ }
if (
p.authMode === "hosted_mcp_oauth_dcr" ||
- p.authMode === "oauth_pkce_loopback" ||
p.authMode === "oauth_device_flow"
) {
- try {
- const r = await oauthStart.mutateAsync(p.id);
- if (r.kind === "device_flow") {
- // GitHub-style: show the user_code in a dedicated dialog,
- // pre-open the verification URL with code embedded if present.
- const verifyUrl = (r as unknown as { verification_uri?: string })
- .verification_uri;
- const verifyUrlComplete = (r as unknown as {
- verification_uri_complete?: string;
- }).verification_uri_complete;
- const userCode = (r as unknown as { user_code?: string }).user_code;
- if (!verifyUrl || !userCode) {
- alert("Backend returned an incomplete device-flow session.");
- return;
- }
- // Auto-open the pre-filled verify URL if available; user lands
- // on the consent page with the code already typed in.
- if (verifyUrlComplete) {
- void openExternalUrl(verifyUrlComplete);
- }
- setDeviceSession({
- flowId: r.flow_id,
- pluginId: r.plugin_id,
- pluginName: p.name,
- userCode,
- verificationUri: verifyUrl,
- verificationUriComplete: verifyUrlComplete ?? null,
- expiresAtMs: r.expires_at_ms,
- });
- return;
- }
- if (!r.open_url) {
- alert("Backend returned no open_url — connect aborted.");
- return;
- }
- void openExternalUrl(r.open_url);
- setOauthSession({
- flowId: r.flow_id,
- pluginId: r.plugin_id,
- pluginName: p.name,
- openUrl: r.open_url,
- });
- } catch (e) {
- alert(
- `Could not start ${p.name} connect flow: ${
- e instanceof Error ? e.message : String(e)
- }`,
- );
- }
+ await startOAuthFlow(p);
return;
}
// hosted_mcp_allowlist (Vercel v2) — needs cloud proxy, deferred.
@@ -476,6 +492,14 @@ export function PluginsView() {
/>
)}
+ {pkceSetupPlugin && (
+ <PkceConnectDialog
+ plugin={pkceSetupPlugin}
+ onClose={() => setPkceSetupPlugin(null)}
+ onProceed={() => startOAuthFlow(pkceSetupPlugin)}
+ />
+ )}
+
{disconnectingPlugin && (
<DisconnectConfirmDialog
plugin={disconnectingPlugin}