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.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(plugins): publish connections immediately
rubenluetke10-beep217a028e77f0
diff --git a/jarvis/ui/web/frontend/src/views/PluginsView.test.tsx b/jarvis/ui/web/frontend/src/views/PluginsView.test.tsxindex 567066b31a..ac8ffd3c8d 100644--- a/jarvis/ui/web/frontend/src/views/PluginsView.test.tsx+++ b/jarvis/ui/web/frontend/src/views/PluginsView.test.tsx@@ -349,6 +349,87 @@ describe("PluginsView opens the PKCE pre-connect dialog", () => {});});+describe("PluginsView publishes OAuth success immediately", () => {+ it("shows Gmail as connected while the catalog revalidation is still pending", async () => {+ let catalogReads = 0;+ const fetchMock = vi.fn(async (input: RequestInfo | URL) => {+ const url = String(input);+ if (url === "/api/marketplace/plugins") {+ catalogReads += 1;+ if (catalogReads > 1) {+ return new Promise<Response>(() => {});+ }+ 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,+ oauth_client_configured: true,+ },+ ],+ }),+ } as Response;+ }+ if (url.endsWith("/connect/start")) {+ return {+ ok: true,+ status: 200,+ json: async () => ({+ flow_id: "gmail-flow",+ plugin_id: "gmail",+ kind: "browser_redirect",+ open_url: "https://accounts.example.test/authorize",+ expires_at_ms: null,+ }),+ } as Response;+ }+ if (url === "/api/settings/open-external") {+ return {+ ok: true,+ status: 200,+ json: async () => ({ opened: true }),+ } as Response;+ }+ if (url.endsWith("/connect/poll/gmail-flow")) {+ return {+ ok: true,+ status: 200,+ json: async () => ({ state: "connected", plugin_id: "gmail" }),+ } as Response;+ }+ throw new Error(`unexpected fetch ${url}`);+ });+ (globalThis as unknown as { fetch: typeof fetch }).fetch =+ fetchMock as unknown as typeof fetch;++ renderPluginsView();+ await waitFor(() =>+ expect(screen.getByRole("button", { name: "Connect plugin" })).toBeDefined(),+ );+ fireEvent.click(screen.getByRole("button", { name: "Connect plugin" }));+ fireEvent.click(await screen.findByRole("button", { name: /^continue$/i }));++ await screen.findByText("Gmail connected");+ expect(+ screen.getByRole("button", { name: "Disconnect plugin" }),+ ).toBeDefined();+ expect(catalogReads).toBeGreaterThan(1);+ });+});+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.tsxindex adb48b5cf4..075ab4f287 100644--- a/jarvis/ui/web/frontend/src/views/PluginsView.tsx+++ b/jarvis/ui/web/frontend/src/views/PluginsView.tsx@@ -1,5 +1,10 @@import { useEffect, useMemo, useRef, useState } from "react";-import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";+import {+ type QueryClient,+ useMutation,+ useQuery,+ useQueryClient,+} from "@tanstack/react-query";import { useEventStore } from "@/store/events";import {Blocks,@@ -123,6 +128,45 @@ interface CatalogResponse {connected: number;}+/** Publish the status that a connect/disconnect endpoint has already committed.+ *+ * OAuth completion used to only invalidate the catalog query. That leaves the+ * old card visible while an embedded WebView waits for the follow-up request,+ * so a successful Gmail login can still look disconnected long enough for the+ * user to start a second login. Update the canonical query cache immediately,+ * then let a background refetch reconcile the remaining runtime metadata.+ */+function cachePluginStatus(+ queryClient: QueryClient,+ pluginId: string,+ status: PluginStatus,+): void {+ queryClient.setQueryData<CatalogResponse>(+ ["marketplace-plugins"],+ (catalog) => {+ if (!catalog) return catalog;+ let found = false;+ const plugins = catalog.plugins.map((plugin) => {+ if (plugin.id !== pluginId) return plugin;+ found = true;+ return {+ ...plugin,+ status,+ reauth_reason: null,+ reauth_at: null,+ ...(status === "not_connected" ? { live_callable: false } : {}),+ };+ });+ if (!found) return catalog;+ return {+ ...catalog,+ plugins,+ connected: plugins.filter((plugin) => plugin.status === "connected").length,+ };+ },+ );+}+interface PatPasteAuthDetail {mode: "pat_paste";token_creation_url: string;@@ -357,6 +401,11 @@ export function PluginsView() {refetchInterval: 30_000,});+ const publishPluginStatus = (pluginId: string, status: PluginStatus) => {+ cachePluginStatus(qc, pluginId, status);+ void qc.refetchQueries({ queryKey: ["marketplace-plugins"] });+ };+const connectMutation = useMutation({mutationFn: async ({pluginId,@@ -387,8 +436,8 @@ export function PluginsView() {}return res.json();},- onSuccess: () => {- qc.invalidateQueries({ queryKey: ["marketplace-plugins"] });+ onSuccess: (_result, variables) => {+ publishPluginStatus(variables.pluginId, "connected");setConnectingPlugin(null);},});@@ -399,8 +448,8 @@ export function PluginsView() {if (!res.ok) throw new Error(`HTTP ${res.status}`);return res.json();},- onSuccess: () => {- qc.invalidateQueries({ queryKey: ["marketplace-plugins"] });+ onSuccess: (_result, pluginId) => {+ publishPluginStatus(pluginId, "not_connected");setDisconnectingPlugin(null);},});@@ -764,7 +813,6 @@ export function PluginsView() {}}onSuccess={() => {setOauthSession(null);- qc.invalidateQueries({ queryKey: ["marketplace-plugins"] });}}/>)}@@ -784,7 +832,6 @@ export function PluginsView() {}}onSuccess={() => {setDeviceSession(null);- qc.invalidateQueries({ queryKey: ["marketplace-plugins"] });}}/>)}@@ -1669,6 +1716,29 @@ function CopyableUrl({ url, hint }: { url: string; hint?: string }) {);}+function usePublishConnectedPlugin(+ pluginId: string,+ state: "pending" | "connected" | "error" | undefined,+ onSuccess: () => void,+): void {+ const qc = useQueryClient();+ const onSuccessRef = useRef(onSuccess);++ useEffect(() => {+ onSuccessRef.current = onSuccess;+ }, [onSuccess]);++ useEffect(() => {+ if (state !== "connected") return;+ cachePluginStatus(qc, pluginId, "connected");+ void qc.refetchQueries({ queryKey: ["marketplace-plugins"] });+ // Keep the success tick visible briefly, while the card behind the dialog+ // has already changed to Connected.+ const timer = window.setTimeout(() => onSuccessRef.current(), 800);+ return () => window.clearTimeout(timer);+ }, [pluginId, qc, state]);+}+function OAuthRedirectDialog({flowId,pluginId,@@ -1708,14 +1778,7 @@ function OAuthRedirectDialog({refetchIntervalInBackground: true,});- // Auto-close on success after a short pause so the user sees the- // "Connected" tick.- useEffect(() => {- if (poll.data?.state === "connected") {- const t = window.setTimeout(onSuccess, 800);- return () => window.clearTimeout(t);- }- }, [poll.data?.state, onSuccess]);+ usePublishConnectedPlugin(pluginId, poll.data?.state, onSuccess);const state = poll.data?.state ?? "pending";const errorMessage =@@ -1880,12 +1943,7 @@ function DeviceCodeDialog({refetchIntervalInBackground: true,});- useEffect(() => {- if (poll.data?.state === "connected") {- const t = window.setTimeout(onSuccess, 800);- return () => window.clearTimeout(t);- }- }, [poll.data?.state, onSuccess]);+ usePublishConnectedPlugin(pluginId, poll.data?.state, onSuccess);const copyCode = async () => {if (await robustCopy(userCode)) {