diff --git a/app/src/assets/brands/github.svg b/app/src/assets/brands/github.svg new file mode 100644 index 0000000000..e3be0e551c --- /dev/null +++ b/app/src/assets/brands/github.svg @@ -0,0 +1,12 @@ + + + GitHub + + + + + + + + + diff --git a/app/src/components/approvals/ask-first-copy.ts b/app/src/components/approvals/ask-first-copy.ts index 3f85ee29df..8df84710e6 100644 --- a/app/src/components/approvals/ask-first-copy.ts +++ b/app/src/components/approvals/ask-first-copy.ts @@ -32,3 +32,19 @@ export const ASK_FIRST_TITLE = "Extra vigilant"; export const ASK_FIRST_DESCRIPTION = "Require your approval for every change to your apps, websites, and files, including routine edits and updates."; + +/* + * The same setting on Settings → Approvals, asked as the question it answers: which changes a Bot + * asks before. Onboarding offers it as one switch, Extra vigilant, and the words above stay its own. + * Here it is a select beside the other "when does a Bot ask" rows, and "Extra vigilant: Risky + * changes" read as a contradiction. + */ +export const ASK_BEFORE_TITLE = "Ask before"; + +export const ASK_BEFORE_DESCRIPTION = + "Bots always ask before risky changes. Choose Every change to approve routine edits and updates to your apps, websites, and files too."; + +export const ASK_BEFORE_LABELS = { + risky: "Risky changes", + every: "Every change", +} as const; diff --git a/app/src/components/approvals/rules.tsx b/app/src/components/approvals/rules.tsx index f4415d5e3d..c3902f7797 100644 --- a/app/src/components/approvals/rules.tsx +++ b/app/src/components/approvals/rules.tsx @@ -207,10 +207,15 @@ export function RuleRow({ {locked ? Locked : null} + {/* Locked, the same select, shown and not changeable: one control on every row. */} {locked ? ( - - {labels[rule.behaviour]} - + undefined} + value={rule.behaviour} + /> ) : ( <> - {ASK_FIRST_TITLE} + {ASK_BEFORE_TITLE} - {ASK_FIRST_DESCRIPTION} + {ASK_BEFORE_DESCRIPTION} - preferences.mutate({ enabled })} + label={ASK_BEFORE_TITLE} + labels={ASK_BEFORE_LABELS} + onChange={(value) => + preferences.mutate({ enabled: value === "every" }) + } + value={inbox.data?.enabled ? "every" : "risky"} /> diff --git a/app/src/components/connections/apps-toolbar.tsx b/app/src/components/connections/apps-toolbar.tsx index 0a5f0accb9..a415fbee44 100644 --- a/app/src/components/connections/apps-toolbar.tsx +++ b/app/src/components/connections/apps-toolbar.tsx @@ -1,7 +1,13 @@ import { Link } from "@tanstack/react-router"; import type { ReactNode } from "react"; -import { IconPlus, IconSearch } from "@/components/icons"; +import { IconChevronDown, IconPlus, IconSearch } from "@/components/icons"; import { Button } from "@/components/ui/button"; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuTrigger, +} from "@/components/ui/dropdown-menu"; import { InputGroup, InputGroupAddon, @@ -32,11 +38,7 @@ export function AppsNavigation({ Your apps }> + + Add custom app + + ); + } + return ( + + }> + + Add + + + + }> + Browse apps + + }> + Custom app (MCP) + + + + ); +} + export function AppsToolbar({ search, onSearch, mayAdd, + browse = null, placeholder = "Search apps", children, }: { search: string; onSearch: (value: string) => void; mayAdd: boolean; + /** The directory "Add" offers to browse, where it isn't the page already open. */ + browse?: PluginsProvider | null; placeholder?: string; children?: ReactNode; }) { @@ -75,12 +121,7 @@ export function AppsToolbar({ onChange={(event) => onSearch(event.target.value)} /> - {mayAdd && ( - - )} + {mayAdd && } {children} diff --git a/app/src/components/connections/identity-connection-page.tsx b/app/src/components/connections/identity-connection-page.tsx index 6e0d7ef04d..8d0612edad 100644 --- a/app/src/components/connections/identity-connection-page.tsx +++ b/app/src/components/connections/identity-connection-page.tsx @@ -12,7 +12,12 @@ import { type LinkableProvider, LinkedAccountSection, linkableProviderTitle, + providerIcon, } from "@/components/settings/linked-accounts"; +import { + identityVendorLogo, + PluginLogo, +} from "@/components/plugins/plugin-logo"; import { linkedNotice, visibleLinkedNotice, @@ -73,6 +78,7 @@ export function IdentityConnectionPage({ } title={title} > {notice ? ( @@ -98,6 +104,23 @@ export function IdentityConnectionPage({ ); } +/** + * The vendor's mark beside the page's title, as on its tile in Apps: GitHub's bundled mark, and + * Slack's own icon. + */ +function IdentityMark({ provider }: { provider: LinkableProvider }) { + const Icon = providerIcon(provider); + return ( + + } + logo={identityVendorLogo(provider)} + name={linkableProviderTitle(provider)} + /> + + ); +} + /** * A brokered GitHub app, where one is enabled. It is a separate connection — tools that read and * change repositories as you — and the Connections list leaves its row out so GitHub is listed once, diff --git a/app/src/components/layout/page-parts.tsx b/app/src/components/layout/page-parts.tsx index 1e7969c99b..5d8a50caf4 100644 --- a/app/src/components/layout/page-parts.tsx +++ b/app/src/components/layout/page-parts.tsx @@ -82,21 +82,34 @@ export function PageColumn({ export function PageHeader({ action, description, + media, title, }: { action?: React.ReactNode; description?: React.ReactNode; + /** A mark before the title, such as an app's logo tile. */ + media?: React.ReactNode; title: string; }) { + const heading = ( +

+ {title} +

+ ); return (
-

- {title} -

+ {media ? ( +
+ {media} + {heading} +
+ ) : ( + heading + )} {action}
{description ? ( diff --git a/app/src/components/layout/page-shell.tsx b/app/src/components/layout/page-shell.tsx index e51a0be7a0..ef575a297f 100644 --- a/app/src/components/layout/page-shell.tsx +++ b/app/src/components/layout/page-shell.tsx @@ -27,12 +27,15 @@ export function PageShell({ children, className, description, + media, title, width = "prose", backButton, }: { /** Sits on the title's baseline. For the page's one primary verb, if it has one. */ action?: React.ReactNode; + /** A mark beside the title, for a page about one app: its logo tile. */ + media?: React.ReactNode; children: React.ReactNode; className?: string; description?: React.ReactNode; @@ -64,7 +67,12 @@ export function PageShell({ const bar = showToggle || !!backButton; const header = ( - + ); const barRow = bar ? ( diff --git a/app/src/components/plugins/plugin-logo.tsx b/app/src/components/plugins/plugin-logo.tsx index e3c30296f4..8c86a3f882 100644 --- a/app/src/components/plugins/plugin-logo.tsx +++ b/app/src/components/plugins/plugin-logo.tsx @@ -1,5 +1,7 @@ import { appKey } from "@openbot/shared/audit-filters"; +import type * as React from "react"; import { useState } from "react"; +import githubLogo from "@/assets/brands/github.svg"; import notionLogo from "@/assets/brands/notion.svg"; import { IconBrandGoogleDrive, IconPlug } from "@/components/icons"; import { cn } from "@/lib/utils"; @@ -22,6 +24,17 @@ export function appVendorLogo(id: string): string | undefined { return appKey(id) === "notion" ? notionLogo : undefined; } +/** + * GitHub's mark for its account tile and page, bundled like Notion's, so it is the same in every + * organization and loads nothing from outside. Slack has none bundled yet: its tile keeps its own + * icon, which a logo address loaded from the directory left blank in WebKit. + */ +export function identityVendorLogo( + provider: "github" | "slack", +): string | undefined { + return provider === "github" ? githubLogo : undefined; +} + /** * An app's logo, or its initial where it has none. * @@ -32,12 +45,16 @@ export function appVendorLogo(id: string): string | undefined { export function PluginLogo({ logo, name, + fallback, }: { logo?: string | null; name?: string; + /** Drawn instead of the initial when there is no logo or it fails: a vendor's own icon. */ + fallback?: React.ReactNode; }) { const [failedUrl, setFailedUrl] = useState(null); if (!logo || failedUrl === logo) { + if (fallback) return fallback; return name ? : ; } @@ -47,7 +64,9 @@ export function PluginLogo({ src={logo} className={cn("size-6 object-contain", LOGO_TILE)} referrerPolicy="no-referrer" - loading="lazy" + // Eager: in WebKit a lazy logo sometimes never starts loading and fires no error, so the + // tile stayed blank and the fallback never ran. A 24px mark gains nothing from waiting. + loading="eager" onError={() => setFailedUrl(logo)} /> ); diff --git a/app/src/components/settings/github-sources.tsx b/app/src/components/settings/github-sources.tsx index 59574f374f..475f41f9a3 100644 --- a/app/src/components/settings/github-sources.tsx +++ b/app/src/components/settings/github-sources.tsx @@ -1,4 +1,9 @@ -import { IconBrandGithub, IconPlus } from "@/components/icons"; +import { + IconBrandGithub, + IconCheck, + IconChevronDown, + IconPlus, +} from "@/components/icons"; import { useMutation, useQuery } from "@tanstack/react-query"; import { Fragment, useId, useState } from "react"; import { @@ -6,7 +11,13 @@ import { PageRows, PageSection, } from "@/components/layout/page-shell"; +import { copyText } from "@/components/settings/linked-accounts"; import { Button } from "@/components/ui/button"; +import { + Collapsible, + CollapsibleContent, + CollapsibleTrigger, +} from "@/components/ui/collapsible"; import { Dialog, DialogBody, @@ -22,7 +33,7 @@ import { Item, ItemActions, ItemContent, - ItemDescription, + ItemFooter, ItemMedia, ItemTitle, } from "@/components/ui/item"; @@ -55,9 +66,10 @@ export function GithubSources() { Add a repository } - description="Add a repository here, then add a webhook in GitHub with the address below and the same secret. Its events, like issues.opened, can then start work on a goal." + description="Events from these repositories, like issues.opened, can start work on a goal." title="Repositories" > + {error ? (

{failureSaid(error)} @@ -82,28 +94,12 @@ export function GithubSources() { {bindings.data.map((binding, index) => ( {index > 0 ? : null} - - - - - - {binding.repository} - - {window.location.origin} - {binding.webhookPath} - - - - - - + remove.mutate(binding.id)} + removing={remove.isPending} + repository={binding.repository} + /> ))} @@ -113,6 +109,106 @@ export function GithubSources() { ); } +/** + * The steps to connect a repository's events, folded away: they are read once, when a repository + * is added, and then they only pushed the rows down. + */ +function HowToSetUp() { + return ( + + } + > + How to set up + + + +

    +
  1. Add a repository here, with a webhook secret.
  2. +
  3. Copy its webhook address.
  4. +
  5. + In GitHub, add a webhook to the repository with that address and the + same secret. +
  6. +
+ + + ); +} + +/** + * One repository: Copy webhook address and Remove. The address used to be drawn in full on the row, + * a long raw address nobody reads, so one press copies it. + * + * Where the copy fails (OpenBot served over plain http has no clipboard), the row says so and shows + * the address on a line of its own, the row's full width, selected with one click. "Copied" is + * said to a screen reader too, since the button's own words change only on screen. + */ +function RepositoryRow({ + address, + repository, + removing, + onRemove, +}: { + address: string; + repository: string; + removing: boolean; + onRemove: () => void; +}) { + const [copied, setCopied] = useState(null); + return ( + + + + + + {repository} + + + + + {copied ? "Copied" : ""} + + {/* Remove, not Disconnect: Disconnect is the account's, above. */} + + + {copied === false ? ( + +

+ Couldn't copy. Select the address and copy it yourself. +

+ + {address} + +
+ ) : null} +
+ ); +} + /** * A repository and the webhook secret GitHub will sign its events with. */ diff --git a/app/src/components/settings/linked-accounts.tsx b/app/src/components/settings/linked-accounts.tsx index e398a3d0a0..b457d61256 100644 --- a/app/src/components/settings/linked-accounts.tsx +++ b/app/src/components/settings/linked-accounts.tsx @@ -1,4 +1,9 @@ -import { IconBrandGithub, IconBrandSlack, IconLink } from "@/components/icons"; +import { + IconBrandGithub, + IconBrandSlack, + IconCheck, + IconLink, +} from "@/components/icons"; import { useMutation, useQuery } from "@tanstack/react-query"; import { useEffect, useState } from "react"; import { @@ -381,8 +386,25 @@ function LinkedAccountRow({ account }: { account: LinkedAccount }) { - {account.title} - {linkedAccountDescription(account)} + {/* Connected says so in words, with the check the Apps tile shows beside it. */} + {account.status === "needs_reconnect" ? ( + <> + {account.title} + + {linkedAccountDescription(account)} + + + ) : ( + <> + + + {account.handle ? ( + @{account.handle} + ) : null} + + )}