Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

refactor(connectors): move share/actionable predicates into lib to end the layer inversion (R1-H3)

Diego Zacarias67607b2b838d
diff --git a/desktop-app/ui/src/hooks/domain/useConnectorsController.ts b/desktop-app/ui/src/hooks/domain/useConnectorsController.ts
index 553a12aba..2b79d244d 100644
--- a/desktop-app/ui/src/hooks/domain/useConnectorsController.ts
+++ b/desktop-app/ui/src/hooks/domain/useConnectorsController.ts
@@ -1,10 +1,15 @@
import { useCallback, useMemo, useState } from 'react'
import { useQuery, useQueryClient } from '@tanstack/react-query'
import type { RpcAgentConnectors, RpcConnector } from '../../../../src/types'
-import { connectorRowKey } from '../../lib/connectorRows'
+import { connectorRowKey, isActionableConnector, isSharedConnector } from '../../lib/connectorRows'
import { formatMcpServerDisplayName } from '../../lib/format'
import { desktopQueryKeys } from './queryKeys'
+// Re-exported from their new home in `lib/` so existing importers (the pages)
+// keep their `from '.../useConnectorsController'` path. The layering rule is that
+// `lib/` never imports from `hooks/` — these pure predicates belong in `lib/`.
+export { isActionableConnector, isSharedConnector }
+
const EMPTY_AGENTS: RpcAgentConnectors[] = []
function toErrorMessage(error: unknown): string {
@@ -27,24 +32,6 @@ function toActionErrorMessage(
return `Couldn't ${verb} "${name}". ${toErrorMessage(error)}`
}
-/**
- * A connector is "shared by the team" when its grant is keyed by Context, not by
- * user (spec §1.3). Authorizing/disconnecting it affects EVERYONE in the
- * Context, so both the confirm-dialog copy and the panel warning key off this.
- */
-export function isSharedConnector(
- connector: Pick<RpcConnector, 'authKind' | 'grantScope'>
-): boolean {
- return connector.grantScope === 'context' || connector.authKind === 'oauth-context'
-}
-
-/** A connector row is actionable from THIS rail only when it is OAuth-governed:
- * `authorized` → disconnect, `requires_setup` → authorize. `no_oauth` (static /
- * none) is managed by Secret, out of scope — no button. */
-export function isActionableConnector(connector: Pick<RpcConnector, 'status'>): boolean {
- return connector.status === 'authorized' || connector.status === 'requires_setup'
-}
-
export type ConnectorActionInput = {
agentName: string
contextRef: string | null
diff --git a/desktop-app/ui/src/lib/connectorPresentation.ts b/desktop-app/ui/src/lib/connectorPresentation.ts
index 14dbf55cc..6856a722c 100644
--- a/desktop-app/ui/src/lib/connectorPresentation.ts
+++ b/desktop-app/ui/src/lib/connectorPresentation.ts
@@ -1,5 +1,5 @@
import type { RpcConnector } from '../../../src/types'
-import { isSharedConnector } from '../hooks/domain/useConnectorsController'
+import { isSharedConnector } from './connectorRows'
/**
* Shared presentation helpers for a connector's tri-state grant, used by BOTH
diff --git a/desktop-app/ui/src/lib/connectorRows.ts b/desktop-app/ui/src/lib/connectorRows.ts
index 6519a211c..8a7f1ebd8 100644
--- a/desktop-app/ui/src/lib/connectorRows.ts
+++ b/desktop-app/ui/src/lib/connectorRows.ts
@@ -1,6 +1,27 @@
import type { RpcAgentConnectors, RpcConnector } from '../../../src/types'
import { formatMcpServerDisplayName } from './format'
+/**
+ * A connector is "shared by the team" when its grant is keyed by Context, not by
+ * user (spec §1.3). Authorizing/disconnecting it affects EVERYONE in the
+ * Context, so both the confirm-dialog copy and the panel warning key off this.
+ *
+ * Lives in `lib/` (pure, no react) so `lib/connectorPresentation` can consume it
+ * without `lib/` importing from `hooks/domain/` — the layering runs one way.
+ */
+export function isSharedConnector(
+ connector: Pick<RpcConnector, 'authKind' | 'grantScope'>
+): boolean {
+ return connector.grantScope === 'context' || connector.authKind === 'oauth-context'
+}
+
+/** A connector row is actionable from the connectors rail only when it is
+ * OAuth-governed: `authorized` → disconnect, `requires_setup` → authorize.
+ * `no_oauth` (static / none) is managed by Secret, out of scope — no button. */
+export function isActionableConnector(connector: Pick<RpcConnector, 'status'>): boolean {
+ return connector.status === 'authorized' || connector.status === 'requires_setup'
+}
+
/**
* A single deduplicated row of the Connectors table.
*