Connect outside services, and see each connection's status.
Mail
ExpiredSend email as you.
Sign-in expired Nov 27. Workflows that send email are paused.
Pipeline CRM
Contacts, companies and deals.
Data Warehouse
Not availableQuery and load tables.
Turned off by your admin
import { Command, UiSchema } from "@effect/ui"import { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Effect, Schema } from "effect"import { CatalogConnector, ConnectorCatalog } from "./ui/uicontext/components/kit/Connect.ts"import { sx } from "./ui/uicontext/components/Sx.ts"const styles = stylex.create({ frame: { inlineSize: "100%" } })const Message = UiSchema.TaggedEnum({ Connect: { id: Schema.String }, Disconnect: { id: Schema.String }, Finished: { id: Schema.String, status: Schema.Literals(["connected", "disconnected"]) },})// Stands in for the app's sign-in window and the provider's answer.const Authorize = Command.make("ConnectionsDemo.Authorize", { args: { id: Schema.String, to: Schema.Literals(["connected", "disconnected"]) } }, ({ id, to }) => Effect.sleep("900 millis").pipe(Effect.as(Message.Finished({ id, status: to }))))const seed: ReadonlyArray<CatalogConnector> = [ { id: "chat", name: "Team Chat", category: "Communication", description: "Read channels you choose and post replies.", status: "connected", account: "[email protected]", usedBy: "Used by 4 workflows", can: ["connect", "disconnect"], disconnectWarning: "4 workflows pause until you connect again." }, { id: "mail", name: "Mail", category: "Communication", description: "Send email as you.", status: "expired", account: "[email protected]", detail: "Sign-in expired Nov 27. Workflows that send email are paused.", can: ["connect", "disconnect"] }, { id: "crm", name: "Pipeline CRM", category: "Sales", description: "Contacts, companies and deals.", status: "available", can: ["connect"] }, { id: "warehouse", name: "Data Warehouse", category: "Data", description: "Query and load tables.", status: "unavailable", lockedReason: "Turned off by your admin" },]export const Connections = Html.component({ name: "Connections", model: Schema.Array(CatalogConnector), message: Message,}).make({ init: () => seed, update: { Connect: ($, { id }) => $.set($.model.map((c) => (c.id === id ? { ...c, status: "connecting" as const, detail: "Approve access in the sign-in window." } : c))).run(Authorize.make({ id, to: "connected" })), Disconnect: ($, { id }) => $.set($.model.map((c) => (c.id === id ? { ...c, status: "disconnecting" as const } : c))).run(Authorize.make({ id, to: "disconnected" })), Finished: ($, { id, status }) => $.model.map((c) => { if (c.id !== id) return c; const { account: _account, detail: _detail, ...rest } = c; return status === "connected" ? { ...rest, status, account: "[email protected]", can: ["connect", "disconnect"] as const } : { ...rest, status } }), }, view: (h, connectors) => h.div.attrs(sx(styles.frame)).children( ConnectorCatalog(h, { props: { label: "Connections", agentId: "connections-demo", connectors, searchable: true }, onEmit: { RequestedConnect: ({ id }) => Message.Connect({ id }), RequestedReconnect: ({ id }) => Message.Connect({ id }), RequestedDisconnect: ({ id }) => Message.Disconnect({ id }), RequestedSecondary: () => undefined, RequestedApplies: () => undefined, }, }), ),})Installation
pnpm dlx shadcn@latest add checkfu/uicontext/connectUsage
import { ConnectorCard, type ConnectorStatus } from "./ui/uicontext/components/kit/Connect.ts"const Message = UiSchema.TaggedEnum({ ConnectedMail: {}, DisconnectedMail: {},})export const MailConnection = (h: Html.H<typeof Message.Type>, status: ConnectorStatus, account: string | undefined) => ConnectorCard(h, { props: { id: "mail", name: "Mail", description: "Send email as you.", status, ...(account === undefined ? {} : { account }), can: ["connect", "disconnect"], disconnectWarning: "Workflows that send email pause.", }, onEmit: { RequestedConnect: () => Message.ConnectedMail(), RequestedReconnect: () => Message.ConnectedMail(), RequestedDisconnect: () => Message.DisconnectedMail(), RequestedSecondary: () => undefined, RequestedApplies: () => undefined, }, })API reference
ConnectorCardComponent
Props
| Name | Type | Default | Description |
|---|---|---|---|
idrequired | string | — | The connector's id, unique among its siblings |
agentId | string | connector:<id> | This card's id for agents, unique on the page; connector:<id> by default |
namerequired | string | — | The service's name: "Google Drive" |
description | string | — | What it lets an agent do, in a sentence |
icon | string | — | An image URL for the app's icon; the name's first letter otherwise |
statusrequired | ConnectorStatus | — | Where the connection stands: available, connected, syncing, expired, failed and so on |
statusLabel | string | — | Replaces the status's default words |
detail | string | — | A line under the status: "Last synced 2 minutes ago", "Expired Nov 3", "Waiting for the workspace admin" |
account | string | — | The account it signs in as: "[email protected]" |
owner | string | — | Whose connection it is, when shared: "Shared by Ben", "Your own account" |
usedBy | string | — | What relies on it: "Used by 4 workflows" |
permissions | string[] | — | What it may do, plainly: ["Read issues", "Post messages"] |
can | Can(["connect", "disconnect"]) | — | What this person may do: "connect" connects or reconnects it (and changes where it applies), "disconnect" disconnects it. Left out, they may connect and not disconnect. |
lockedReason | string | — | Why it can't be connected: "Turned off by your admin", "Data is still being removed" |
requiredReason | string | — | Why it can't be disconnected: "Required by your team" |
disconnectWarning | string | — | What stops on disconnect: "Indexed pages are deleted. 4 workflows pause." |
connectLabel | string | Connect | The connect button's words; Connect by default |
secondary | ConnectorStep | — | A second step: "Manage", "Retry sync", "Cancel request" |
appliesTo | { legend, options } | — | Where it may be used, as checkboxes |
layout | "card" | "row" | — | A card in a grid, or a row in a list |
Events
| Event | Payload | Description |
|---|---|---|
RequestedConnect | {} | Start connecting: the app runs the sign-in |
RequestedReconnect | {} | Sign in again to a connection that expired or failed |
RequestedDisconnect | {} | Disconnect, after the person confirmed |
RequestedSecondary | {} | The second step was pressed: "Manage", "Retry sync" |
RequestedApplies | { values: string[] } | Every value that should be checked now |
Agent actions
| Action | Description |
|---|---|
ClickedConnect | Start connecting. The person finishes the sign-in; you never handle credentials. |
ClickedReconnect | Start reconnecting an expired or broken connection. The person finishes the sign-in. |
ConfirmedDisconnectasks first | Disconnect. Name { name, account } as the target. |
ToggledApplies | Check or uncheck one place it applies to (value from page_query). Checking widens access: name the checked values as the target. |
ConnectorCatalogComponent
Props
| Name | Type | Default | Description |
|---|---|---|---|
agentId | string | catalog:<label> | The id agents know this catalog by; catalog:<label> by default |
labelrequired | string | — | "Connectors", "Apps" |
connectorsrequired | CatalogConnector[] | — | The services, each with its category and status |
layout | "card" | "row" | — | Cards in a grid (browsing) or rows in a list (what's connected) |
searchable | boolean | — | Show the search field and category filter; by default only for more than 6 connectors |
searchPlaceholder | string | Name or what it does | The search field's placeholder; Name or what it does by default |
emptyTitle | string | Nothing to connect yet | What an empty catalog says; Nothing to connect yet by default |
emptyHint | string | — | A hint under the empty title at what to do next |
Events
| Event | Payload | Description |
|---|---|---|
RequestedConnect | { id: string } | Start connecting a service: the app runs the sign-in |
RequestedReconnect | { id: string } | Sign in again to a connection that expired or failed |
RequestedDisconnect | { id: string } | Disconnect a service, after the person confirmed |
RequestedSecondary | { id: string } | A service's second step was pressed: "Manage", "Retry sync" |
RequestedApplies | { id: string; values: string[] } | What a service applies to changed: every value that should be checked now |
Agent actions
| Action | Description |
|---|---|
UpdatedQuery | Search connectors by name or description |
ChoseCategory | Show one category (value from page_query), or "" for all |
Accessibility
- Each connector is a labelled group; its status is text, never color alone.
- Disconnecting asks first and says what stops.
- The catalog's search is a
searchlandmark, and its count of results is announced as you filter.