Orkas is an open-source (MIT), local-first AI team for your desktop: a Commander turns your goal into to-dos and coordinates 16 built-in specialist agents plus Claude Code, Codex, OpenCode, OpenClaw and Hermes, with projects, scheduled automations and connectors. Free app for macOS & Windows; built-in models or your own keys.
JavaScript agent-collaborationagent-harnessagent-orchestrationagent-teamagent-workflowai-assistantai-automationai-employeeai-productivityai-teamai-workflowautonomous-agentsclaude-code-guiclaude-coworkdesktop-agentlocal-firstmulti-agentmulti-agent-systemself-evolving-agentstask-automation
fix(connectors): show pending feedback for initial OAuth launch
wyt8bbc2396d171
diff --git a/src/renderer/modules/connectors.js b/src/renderer/modules/connectors.jsindex aa9ad57f..d1b2c625 100644--- a/src/renderer/modules/connectors.js+++ b/src/renderer/modules/connectors.js@@ -2028,6 +2028,8 @@ function _openAddCustomDialog() {});if (res && res.ok && res.instance) {if (res.started && typeof res.attempt_id === 'string') {+ const launch = _startOAuthLaunchFeedback(res.instance.id);+ launch.attemptId = res.attempt_id;_pendingConnectAttempts.set(res.attempt_id, { uiCatalogId: res.instance.id });}added = true;diff --git a/test/renderer/connectors-degraded-card.test.ts b/test/renderer/connectors-degraded-card.test.tsindex fe4b925b..c6e15d4a 100644--- a/test/renderer/connectors-degraded-card.test.ts+++ b/test/renderer/connectors-degraded-card.test.ts@@ -2348,3 +2348,73 @@ describe('explicit connector failure codes', () => {if (error.code === 'storage_unavailable') expect(context.__alerts[0]).toBe(context.t('connectors.errors.storage_unavailable'));});});++describe('first custom OAuth connection owns launch feedback', () => {+ it.each([false, true])('keeps the accepted add busy, handles a synchronous close callback=%s, and rejects superseded results', async callbackOnClose => {+ const entry = { id: 'custom-owned', display_name: 'Owned test connector', _custom: true };+ const instance = { id: entry.id, origin: 'custom', custom_auth_mode: 'oauth', status: { kind: 'connecting' } };+ let retries = 0;+ const invoke = vi.fn(async channel => {+ if (channel === 'connectors.add_custom') return { ok: true, instance, started: true, attempt_id: 'add-first' };+ if (channel === 'connectors.authorize_custom') return { ok: true, started: true, attempt_id: `retry-${++retries}` };+ return { ok: true };+ });+ const ctx = loadConnectorsRenderer(invoke);+ ctx.loadConnectors = vi.fn(async () => {});+ const handlers = new Map<string, () => Promise<void>>();+ const control = (key: string, value = '') => ({+ value, style: {}, disabled: false, textContent: '', focus: vi.fn(),+ addEventListener: (event: string, handler: () => Promise<void>) => handlers.set(`${key}:${event}`, handler),+ });+ const fields = new Map([+ ['kind', control('kind', 'streamable-http')], ['auth_mode', control('auth_mode', 'oauth')],+ ['name', control('name', entry.display_name)], ['url', control('url', 'https://connector.example/mcp')],+ ['headers', control('headers')],+ ]);+ const submit = control('submit');+ const overlay: any = { innerHTML: '', querySelector: (selector: string) => {+ const field = selector.match(/^\[data-f="([^"]+)"\]$/)?.[1];+ if (field) return fields.get(field);+ if (selector === '[data-act="ok"]') return submit;+ return control(selector);+ }, remove: vi.fn(() => {+ if (callbackOnClose) ctx.__emitPush('connectors:oauth-callback', { attempt_id: 'add-first', catalog_id: entry.id });+ }) };+ const createElement = ctx.document.createElement;+ ctx.document.createElement = () => overlay;+ ctx._openAddCustomDialog();+ expect(overlay.innerHTML).toContain('data-act="ok"');+ await handlers.get('submit:click')!();+ ctx.document.createElement = createElement;+ expect(overlay.remove).toHaveBeenCalledOnce();+ expect(invoke).toHaveBeenCalledExactlyOnceWith('connectors.add_custom', {+ display_name: entry.display_name, auth_mode: 'oauth',+ transport: { kind: 'streamable-http', url: 'https://connector.example/mcp', headers: {} },+ });+ const card = () => ctx._renderCatalogCard(entry, instance).innerHTML;+ expect(card()).toContain('is-loading');+ expect(card()).toContain('disabled');+ await ctx._authorizeCustom(entry, instance);+ expect(retries).toBe(0);+ ctx.__advanceTimers(2000);+ if (callbackOnClose) {+ await ctx._authorizeCustom(entry, instance);+ expect(retries).toBe(0);+ ctx.__emitPush('connectors:oauth-result', { attempt_id: 'add-first', catalog_id: entry.id, result: 'success' });+ } else {+ // No callback yet: an explicit retry after the throttle owns a new launch.+ await ctx._authorizeCustom(entry, instance);+ expect(retries).toBe(1);+ ctx.__emitPush('connectors:oauth-result', { attempt_id: 'add-first', catalog_id: entry.id, result: 'cancelled', code: 'superseded' });+ expect(card()).toContain('is-loading');+ ctx.__emitPush('connectors:oauth-callback', { attempt_id: 'retry-1', catalog_id: entry.id });+ ctx.__advanceTimers(2000);+ await ctx._authorizeCustom(entry, instance);+ expect(retries).toBe(1);+ ctx.__emitPush('connectors:oauth-result', { attempt_id: 'retry-1', catalog_id: entry.id, result: 'success' });+ }+ expect(card()).not.toContain('is-loading');+ expect(ctx.__alerts).toEqual([]);+ expect(invoke.mock.calls.some(([channel]) => channel === 'connectors.cancel_oauth')).toBe(false);+ });+});