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): surface callback address while browser login is pending
rubenluetke10-beep39e70b064ac6
diff --git a/jarvis/marketplace/auth/base.py b/jarvis/marketplace/auth/base.pyindex 458217d388..04a4fc0196 100644--- a/jarvis/marketplace/auth/base.py+++ b/jarvis/marketplace/auth/base.py@@ -40,6 +40,11 @@ class AuthSession:kind: SessionKind# Browser-redirect kinds: open this URL in the user's default browser.open_url: str | None = None+ # Browser-redirect kinds: the exact loopback/hosted address the provider+ # must call back with ?code=&state=. Surfaced so the UI can show what it+ # is waiting for (and what a self-registered provider app must allow)+ # instead of spinning silently when the provider never calls back.+ redirect_uri: str | None = None# Device-flow only: code the user types on `verification_uri`.user_code: str | None = Noneverification_uri: str | None = Nonediff --git a/jarvis/marketplace/auth/oauth_dcr.py b/jarvis/marketplace/auth/oauth_dcr.pyindex e1dc82d658..cb4824feb5 100644--- a/jarvis/marketplace/auth/oauth_dcr.py+++ b/jarvis/marketplace/auth/oauth_dcr.py@@ -374,6 +374,7 @@ class HostedMcpDcrHandler:plugin_id=self.plugin_id,kind="browser_redirect",open_url=authorize_url,+ redirect_uri=redirect_uri,expires_at_ms=int((datetime.now(UTC) + timedelta(minutes=15)).timestamp() * 1000),)diff --git a/jarvis/marketplace/auth/oauth_pkce_loopback.py b/jarvis/marketplace/auth/oauth_pkce_loopback.pyindex 33778fdbaa..ef84bf8a44 100644--- a/jarvis/marketplace/auth/oauth_pkce_loopback.py+++ b/jarvis/marketplace/auth/oauth_pkce_loopback.py@@ -170,6 +170,7 @@ class PkceLoopbackHandler:plugin_id=self.plugin_id,kind="browser_redirect",open_url=url,+ redirect_uri=redirect_uri,expires_at_ms=int((datetime.now(UTC) + timedelta(minutes=5)).timestamp() * 1000),)diff --git a/jarvis/ui/web/frontend/src/views/PluginsView.test.tsx b/jarvis/ui/web/frontend/src/views/PluginsView.test.tsxindex 2491029137..ba7f65a2b0 100644--- a/jarvis/ui/web/frontend/src/views/PluginsView.test.tsx+++ b/jarvis/ui/web/frontend/src/views/PluginsView.test.tsx@@ -524,6 +524,84 @@ describe("PluginsView publishes OAuth success immediately", () => {).toBeDefined();expect(catalogReads).toBeGreaterThan(1);});++ it("names the callback address while waiting so a silent provider is diagnosable", 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: "slack",+ display_name: "Slack",+ description: "Chat",+ category: "Communication",+ logo_slug: "slack",+ 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: "slack-flow",+ plugin_id: "slack",+ kind: "browser_redirect",+ open_url: "https://slack.com/oauth/v2/authorize",+ redirect_uri: "http://127.0.0.1:3118/oauth/callback",+ 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/slack-flow")) {+ return {+ ok: true,+ status: 200,+ json: async () => ({ state: "pending", flow_id: "slack-flow" }),+ } 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" }));++ // The pending dialog names the exact address the provider must call+ // back — previously it spun silently when the provider never did.+ await screen.findByText(/to call back at/i);+ expect(+ screen.getByText("http://127.0.0.1:3118/oauth/callback"),+ ).toBeDefined();+ expect(+ screen.getByRole("button", { name: /open slack again/i }),+ ).toBeDefined();+ });});function installImmediateConnectionFetch(diff --git a/jarvis/ui/web/frontend/src/views/PluginsView.tsx b/jarvis/ui/web/frontend/src/views/PluginsView.tsxindex c4f4b38faa..1b9304bb05 100644--- a/jarvis/ui/web/frontend/src/views/PluginsView.tsx+++ b/jarvis/ui/web/frontend/src/views/PluginsView.tsx@@ -638,6 +638,7 @@ export function PluginsView({ inDialog = false }: { inDialog?: boolean } = {}) {plugin_id: string;kind: "browser_redirect" | "device_flow" | "local";open_url: string | null;+ redirect_uri: string | null;expires_at_ms: number | null;}>;},@@ -648,6 +649,7 @@ export function PluginsView({ inDialog = false }: { inDialog?: boolean } = {}) {pluginId: string;pluginName: string;openUrl: string;+ redirectUri: string | null;} | null>(null);const [deviceSession, setDeviceSession] = useState<{@@ -716,6 +718,7 @@ export function PluginsView({ inDialog = false }: { inDialog?: boolean } = {}) {pluginId: r.plugin_id,pluginName: p.name,openUrl: r.open_url,+ redirectUri: r.redirect_uri ?? null,});return true;} catch (e) {@@ -998,6 +1001,7 @@ export function PluginsView({ inDialog = false }: { inDialog?: boolean } = {}) {pluginId={oauthSession.pluginId}pluginName={oauthSession.pluginName}openUrl={oauthSession.openUrl}+ redirectUri={oauthSession.redirectUri}onClose={() => {cancelOAuthSession(oauthSession);setOauthSession(null);@@ -2104,6 +2108,7 @@ function OAuthRedirectDialog({pluginId,pluginName,openUrl,+ redirectUri,onClose,onSuccess,}: {@@ -2111,6 +2116,7 @@ function OAuthRedirectDialog({pluginId: string;pluginName: string;openUrl: string;+ redirectUri: string | null;onClose: () => void;onSuccess: () => void;}) {@@ -2192,6 +2198,21 @@ function OAuthRedirectDialog({stays "Not connected" until you finish there.</p></div>+ {redirectUri && (+ <div className="w-full rounded-md border border-border bg-background px-3 py-2 text-left">+ <p className="text-micro text-muted-foreground">+ Waiting for {pluginName} to call back at+ </p>+ <code className="mt-0.5 block select-all break-all font-mono text-micro text-foreground">+ {redirectUri}+ </code>+ <p className="mt-1 text-micro text-muted-foreground">+ If the provider shows an error instead of asking for+ approval, allow exactly this address in your provider+ app's redirect settings, then open the sign-in again.+ </p>+ </div>+ )}<buttontype="button"onClick={() => void openExternalUrl(openUrl)}diff --git a/jarvis/ui/web/marketplace_routes.py b/jarvis/ui/web/marketplace_routes.pyindex 70160fd547..6806f05260 100644--- a/jarvis/ui/web/marketplace_routes.py+++ b/jarvis/ui/web/marketplace_routes.py@@ -734,6 +734,12 @@ async def connect_start(async with slot.completion_lock:try:result = await handler.await_completion(session)+ except asyncio.CancelledError:+ # The dialog was cancelled (DELETE /connect/{flow_id} drops+ # the slot and stops the listener): nothing left to report.+ # Without this the task dies with an unretrieved exception+ # while the poll endpoint keeps answering "pending".+ returnexcept Exception as exc: # noqa: BLE001log.warning("plugin %s connect/await failed (%s)", plugin_id, type(exc).__name__)if registry.get(session.flow_id) is slot:@@ -789,6 +795,11 @@ async def connect_start("plugin_id": session.plugin_id,"kind": session.kind,"open_url": session.open_url,+ # The exact address the provider must call back with ?code=&state=.+ # The UI shows it while waiting so a provider page that never calls+ # back (unregistered redirect URI, missing approval) is diagnosable+ # instead of an endless spinner.+ "redirect_uri": session.redirect_uri,"user_code": session.user_code,"verification_uri": session.verification_uri,"verification_uri_complete": session.verification_uri_complete,diff --git a/tests/unit/marketplace/test_connect_start_redirect_uri.py b/tests/unit/marketplace/test_connect_start_redirect_uri.pynew file mode 100644index 0000000000..d83fba26a0--- /dev/null+++ b/tests/unit/marketplace/test_connect_start_redirect_uri.py@@ -0,0 +1,130 @@+"""connect_start surfaces the exact callback address the provider must call.++Regression context: a Slack browser login opened the provider page, the user+signed in, and then nothing ever happened — the pending dialog spun silently+because nobody could see WHERE the provider had to call back+(http://127.0.0.1:3118/oauth/callback, which a self-registered provider app+must explicitly allow). The start response now carries `redirect_uri` so the+UI can show it while waiting.+"""++from __future__ import annotations++import asyncio+from urllib.parse import parse_qs, urlparse++import pytest+from fastapi import BackgroundTasks++from jarvis.marketplace.auth.base import AuthSession, FlowResult+from jarvis.marketplace.auth.oauth_pkce_loopback import (+ PkceLoopbackConfig,+ PkceLoopbackHandler,+)+from jarvis.marketplace.token_store import Tokens+from jarvis.ui.web import marketplace_routes as mr+++async def _start_slack_like_session() -> tuple[PkceLoopbackHandler, AuthSession]:+ handler = PkceLoopbackHandler(+ PkceLoopbackConfig(+ plugin_id="slack",+ authorization_url="https://slack.com/oauth/v2/authorize",+ token_url="https://slack.com/api/oauth.v2.access", # noqa: S106+ client_id="test-client-id",+ callback_port=0, # ephemeral: never clash with a live 3118 listener+ scopes=["chat:write", "users:read"],+ scope_param_name="user_scope",+ callback_path="/oauth/callback",+ )+ )+ return handler, await handler.start(object())+++async def test_pkce_start_reports_the_callback_it_listens_on() -> None:+ """The session names the loopback address the provider must redirect to,+ and the authorize URL points the provider exactly there."""+ handler, session = await _start_slack_like_session()+ try:+ assert session.kind == "browser_redirect"+ assert session.redirect_uri is not None+ assert session.redirect_uri.startswith("http://127.0.0.1:")+ assert session.redirect_uri.endswith("/oauth/callback")++ assert session.open_url is not None+ params = parse_qs(urlparse(session.open_url).query)+ assert params["redirect_uri"] == [session.redirect_uri]+ assert params["user_scope"] == ["chat:write,users:read"]+ finally:+ await handler.cancel(session)+++class _Catalog:+ def __init__(self, specs):+ self.plugins = specs++ def by_id(self, plugin_id: str):+ return next((s for s in self.plugins if s.id == plugin_id), None)+++def _pkce_spec(client_id: str):+ for spec in mr.load_catalog().plugins:+ if spec.auth is not None and getattr(spec.auth, "mode", "") == "oauth_pkce_loopback":+ return spec.model_copy(+ update={"auth": spec.auth.model_copy(update={"client_id": client_id})}+ )+ pytest.skip("no oauth_pkce_loopback plugin in catalog")+++class _StubPkceHandler:+ """Stub that, unlike the older token-save stub, also reports redirect_uri."""++ def __init__(self, config) -> None:+ self.config = config++ async def start(self, plugin_spec) -> AuthSession:+ return AuthSession(+ flow_id=f"test-flow-{plugin_spec.id}",+ plugin_id=plugin_spec.id,+ kind="browser_redirect",+ open_url="https://provider.example/authorize",+ redirect_uri="http://127.0.0.1:3118/oauth/callback",+ )++ async def await_completion(self, session: AuthSession) -> FlowResult:+ return FlowResult(tokens=Tokens(access="tok-123"), error=None)+++async def test_connect_start_response_carries_redirect_uri(monkeypatch) -> None:+ """The wire response forwards the handler's redirect_uri (additive field)."""+ real_create_task = asyncio.create_task+ captured: list[asyncio.Task] = []++ def _capturing(coro, **kwargs):+ task = real_create_task(coro, **kwargs)+ captured.append(task)+ return task++ async def _verified(spec, tokens):+ return None++ monkeypatch.setattr(mr.asyncio, "create_task", _capturing)+ monkeypatch.setattr(mr, "verify_connection", _verified)+ monkeypatch.setattr(mr.TokenStore, "save", lambda self, plugin_id, tokens: None)+ monkeypatch.setattr(mr, "_refresh_plugin_in_live_registry", lambda plugin_id: None)+ spec = _pkce_spec("real-client-id.apps.example")+ monkeypatch.setattr(mr, "load_catalog", lambda: _Catalog([spec]))+ monkeypatch.setattr(+ "jarvis.marketplace.connect_helpers.resolve_pkce_client",+ lambda pid, cid, csec: ("real-client-id.apps.example", None),+ )+ monkeypatch.setattr(mr, "PkceLoopbackHandler", _StubPkceHandler)++ session = await mr.connect_start(spec.id, BackgroundTasks())+ for task in captured:+ await task++ assert session["redirect_uri"] == "http://127.0.0.1:3118/oauth/callback"+ assert session["open_url"] == "https://provider.example/authorize"