From 64918dda3598c0c745c1244ff974280cab08048d Mon Sep 17 00:00:00 2001 From: Nam Rodriguez Date: Sun, 8 Nov 2026 14:21:40 -0500 Subject: [PATCH 1/2] Other apps is one choice: Coderhelm's apps or fully private Settings, System, Hybrid shows one choice with a line per option and the tools it covers, listed from the gateway's catalog (Figma included). Tool pages say which app the install uses and link to the choice; GitHub keeps its own. The install guide offers the same choice. Both send apps_mode and, for an install on an earlier release, the same choice per tool. --- dashboard/e2e/hybrid.spec.ts | 150 +++++++++++------- dashboard/e2e/knowledge-app-choice.spec.ts | 21 +-- .../src/components/hybrid-app-choice.tsx | 37 +++-- dashboard/src/components/hybrid-section.tsx | 122 +++++++------- dashboard/src/lib/api.ts | 13 +- dashboard/src/lib/hybrid.ts | 32 +++- dashboard/src/lib/openapi-fields.ts | 2 +- docs/components/install/wizard.tsx | 44 ++--- docs/e2e/install.spec.ts | 57 +++++-- docs/lib/install/core.ts | 72 ++++----- 10 files changed, 329 insertions(+), 221 deletions(-) diff --git a/dashboard/e2e/hybrid.spec.ts b/dashboard/e2e/hybrid.spec.ts index 597e1703..1b2d03ab 100644 --- a/dashboard/e2e/hybrid.spec.ts +++ b/dashboard/e2e/hybrid.spec.ts @@ -17,7 +17,14 @@ interface State { name: { name: string; hostname: string; code: string } | null; mode: "own" | "hosted"; links: { installation_id: number; account: string; repositories: string[]; ceiling?: string[] | null }[]; - hosted: Set; + /** Other apps, for the whole install. */ + appsMode: "coderhelm" | "private"; + /** Tools the install has its own app for (used whichever choice). */ + ownApps?: Set; + /** A gateway from before the one choice: no `apps_mode`, and it reads only the per-tool `apps`. */ + olderGateway?: boolean; + /** Catalog entries a later release adds, appended as the gateway would list them. */ + added?: { id: string; name: string }[]; sharing: { enabled: boolean; payloads: boolean }; /** Whether Coderhelm's own Google Drive app is set up (the hosted side's `offered`). */ driveOffered?: boolean; @@ -32,6 +39,8 @@ interface Call { } function status(s: State) { + const uses = (id: string, offered = true) => s.appsMode === "coderhelm" && offered && !s.ownApps?.has(id); + const tool = (id: string, name: string, offered = true) => ({ id, name, mode: "hosted", through_coderhelm: "The sign-in only.", stays_with_you: "Every page Coderhelm reads.", uses_coderhelm: uses(id, offered), offered, own_app: !!s.ownApps?.has(id) }); const checks = [ { id: "hybrid_registered", status: s.registered ? "pass" : "todo", code: s.registered ? "ok" : "not_registered", title: "Registered with Coderhelm", fix: s.registered ? null : "Press Register with Coderhelm." }, ...(s.registered ? [{ id: "hybrid_relay", status: s.verified ? "pass" : "fail", code: s.verified ? "ok" : "signature_mismatch", title: "Events from Coderhelm are signed for this install", fix: s.verified ? null : "Register again so this install and Coderhelm share the same signing key." }] : []), @@ -49,15 +58,18 @@ function status(s: State) { github: { mode: s.mode, links: s.links, app_slug: "coderhelm" }, integrations: [ { id: "github", name: "GitHub", mode: "hosted", through_coderhelm: "Webhook events, on their way to this install.", stays_with_you: "Your code: the install reads it straight from GitHub.", uses_coderhelm: s.mode === "hosted" }, - { id: "jira", name: "Jira (Forge app)", mode: "hosted", through_coderhelm: "Ticket events and the sign-in.", stays_with_you: "Ticket contents Coderhelm reads later.", uses_coderhelm: s.hosted.has("jira") }, - { id: "notion", name: "Notion", mode: "hosted", through_coderhelm: "The sign-in only.", stays_with_you: "Every page Coderhelm reads.", uses_coderhelm: s.hosted.has("notion") }, - { id: "confluence", name: "Confluence (Atlassian)", mode: "hosted", through_coderhelm: "The sign-in only.", stays_with_you: "Every page Coderhelm reads.", uses_coderhelm: s.hosted.has("confluence") }, - { id: "google_drive", name: "Google Drive", mode: "hosted", through_coderhelm: "The sign-in only.", stays_with_you: "Every file Coderhelm reads.", uses_coderhelm: s.hosted.has("google_drive"), offered: s.driveOffered !== false }, + tool("jira", "Jira (Forge app)"), + tool("notion", "Notion"), + tool("confluence", "Confluence (Atlassian)"), + tool("google_drive", "Google Drive", s.driveOffered !== false), + tool("figma", "Figma"), + ...(s.added ?? []).map((t) => tool(t.id, t.name)), { id: "slack_notifications", name: "Slack and Teams notifications", mode: "direct", through_coderhelm: "", stays_with_you: "", uses_coderhelm: false }, - { id: "mcp_apps", name: "Figma, Linear, Sentry, Sanity and other sign-in apps", mode: "direct", through_coderhelm: "", stays_with_you: "", uses_coderhelm: false }, + { id: "mcp_apps", name: "Linear, Sentry, Sanity and other sign-in apps", mode: "direct", through_coderhelm: "", stays_with_you: "", uses_coderhelm: false }, { id: "slack_commands", name: "Slack and Teams commands", mode: "unavailable", through_coderhelm: "", stays_with_you: "", reason: "CoderHelm has no shared Slack or Teams app: each team connects its own app's signing secret in Plugins settings, so there is nothing to relay. That keeps working the same way on a hybrid install.", uses_coderhelm: false }, { id: "github_sign_in", name: "Sign in with GitHub", mode: "included", through_coderhelm: "Without a GitHub OAuth client of your own, GitHub's sign-in page is CoderHelm's GitHub App: CoderHelm passes GitHub's one-time code to your install, exchanges it when your install asks (with a secret only your install holds), and revokes the token at GitHub seconds later. It stores neither and doesn't ask GitHub who signed in.", stays_with_you: "Who signs in: your install asks GitHub itself whose account it is, then applies its own rules (team members and invites, two-factor). CoderHelm can't start a session on your install or choose who signs in.", reason: "", uses_coderhelm: false }, ], + ...(s.olderGateway ? {} : { apps_mode: s.appsMode }), sharing: s.sharing, checks, }; @@ -70,7 +82,7 @@ const NAMES: Record | null = SELF, init: Partial = {}) { - const s: State = { registered: false, verified: false, name: null, mode: "own", links: [], hosted: new Set(["notion"]), sharing: { enabled: false, payloads: false }, ...init }; + const s: State = { registered: false, verified: false, name: null, mode: "own", links: [], appsMode: "coderhelm", sharing: { enabled: false, payloads: false }, ...init }; const calls: Call[] = []; const json = (route: Route, body: unknown, code = 200) => route.fulfill({ status: code, contentType: "application/json", body: JSON.stringify(body) }); await page.route((url) => url.pathname === "/runtime-config.js", (route) => @@ -148,12 +160,10 @@ async function setup(page: Page, cfg: Record | null = SELF, ini } if (p === "/api/system/hybrid/settings" && method === "PUT") { if (body?.github_mode) s.mode = body.github_mode as State["mode"]; - if (Array.isArray(body?.integrations)) s.hosted = new Set(body!.integrations as string[]); - // Other apps, per tool: only the tools named change. - for (const [id, v] of Object.entries((body?.apps as Record | undefined) ?? {})) { - if (v === "coderhelm") s.hosted.add(id); - else s.hosted.delete(id); - } + // Other apps: one choice. An older gateway reads only the per-tool `apps`. + const apps = Object.values((body?.apps as Record | undefined) ?? {}); + if (!s.olderGateway && body?.apps_mode) s.appsMode = body.apps_mode as State["appsMode"]; + else if (apps.length) s.appsMode = apps.includes("coderhelm") ? "coderhelm" : "private"; if (body?.sharing) s.sharing = body.sharing as State["sharing"]; return json(route, status(s)); } @@ -331,57 +341,80 @@ for (const [outcome, words, tone] of [ }); } -test("other apps: a new install shows Coderhelm's app selected for every tool", async ({ page }) => { - // What the install answers when nobody chose: Coderhelm's app for each tool. - const { puts } = await setup(page, SELF, { registered: true, verified: true, hosted: new Set(["jira", "notion", "confluence", "google_drive"]) }); +const ALL_TOOLS = { jira: "coderhelm", notion: "coderhelm", confluence: "coderhelm", google_drive: "coderhelm", figma: "coderhelm" }; +const ALL_OWN = { jira: "own", notion: "own", confluence: "own", google_drive: "own", figma: "own" }; + +test("other apps: one choice, Coderhelm's apps by default, for every tool the catalog lists", async ({ page }) => { + const { puts } = await setup(page, SELF, { registered: true, verified: true }); await page.goto("/settings/system/"); - for (const id of ["jira", "notion", "confluence", "google_drive"]) { - const row = page.getByTestId(`hybrid-integration-${id}`); - await expect(row.getByRole("button", { name: "Use Coderhelm's app (easiest)" })).toHaveAttribute("aria-pressed", "true"); - await expect(row.getByRole("button", { name: "Use my own app (fully private)" })).toHaveAttribute("aria-pressed", "false"); - await expect(row).toContainText("Through Coderhelm"); + const row = page.getByTestId("hybrid-integrations"); + await expect(row).toHaveAttribute("data-apps-mode", "coderhelm"); + await expect(row.getByRole("button", { name: "Use Coderhelm's apps (easiest)" })).toHaveAttribute("aria-pressed", "true"); + await expect(row.getByRole("button", { name: "Fully private" })).toHaveAttribute("aria-pressed", "false"); + // One choice: no per-tool switches and no per-tool paragraphs. + await expect(row.getByRole("button")).toHaveCount(2); + await expect(row).not.toContainText("Through Coderhelm"); + await expect(row).not.toContainText("Stays with you"); + await expect(row.getByTestId("hybrid-apps-line")).toContainText("and for any Coderhelm adds later"); + // The tools come from the gateway's catalog, Figma among them. + const tools = row.getByTestId("hybrid-apps-tools"); + for (const id of ["jira", "notion", "confluence", "google_drive", "figma"]) { + await expect(tools.getByTestId(`hybrid-integration-${id}`)).toHaveAttribute("data-uses-coderhelm", "true"); } - // Showing the defaults saves nothing. + await expect(tools.getByTestId("hybrid-integration-figma")).toContainText("Figma"); + await expect(row.getByTestId("hybrid-apps-direct")).not.toContainText("Figma"); + await expect(row.getByTestId("hybrid-apps-direct")).toContainText("Slack and Teams notifications"); + await expect(row.getByTestId("hybrid-apps-unavailable")).toContainText("Slack and Teams commands"); + await expect(row.getByTestId("hybrid-apps-included")).toContainText("Sign in with GitHub"); + // GitHub has its own row above, so it isn't listed again. + await expect(page.getByTestId("hybrid-integration-github")).toHaveCount(0); + // Showing the default saves nothing. expect(puts()).toEqual([]); }); -test("other apps: each choice sends only that tool; direct and unavailable say so", async ({ page }) => { +test("other apps: a new hosted entry is on with nothing to choose", async ({ page }) => { + // A release adds an app to the catalog: the page lists it under the same choice. + const { puts } = await setup(page, SELF, { registered: true, verified: true, added: [{ id: "new_tool", name: "New tool" }] }); + await page.goto("/settings/system/"); + const tool = page.getByTestId("hybrid-apps-tools").getByTestId("hybrid-integration-new_tool"); + await expect(tool).toContainText("New tool"); + await expect(tool).toHaveAttribute("data-uses-coderhelm", "true"); + await expect(page.getByTestId("hybrid-integrations").getByRole("button")).toHaveCount(2); + expect(puts()).toEqual([]); +}); + +test("other apps: fully private sends one choice (and the per-tool copy for an older gateway)", async ({ page }) => { const { puts } = await setup(page, SELF, { registered: true, verified: true }); await page.goto("/settings/system/"); - const jira = page.getByTestId("hybrid-integration-jira"); - await expect(jira).toContainText("Ticket events and the sign-in."); - await jira.getByRole("button", { name: "Use Coderhelm's app (easiest)" }).click(); - await expect.poll(() => puts().at(-1)).toEqual({ apps: { jira: "coderhelm" } }); - await expect(jira.getByRole("button", { name: "Use Coderhelm's app (easiest)" })).toHaveAttribute("aria-pressed", "true"); - await page.getByTestId("hybrid-integration-notion").getByRole("button", { name: "Use my own app (fully private)" }).click(); - await expect.poll(() => puts().at(-1)).toEqual({ apps: { notion: "own" } }); - await expect(page.getByTestId("hybrid-integration-notion").getByRole("button", { name: "Use my own app (fully private)" })).toHaveAttribute("aria-pressed", "true"); - await expect(page.getByTestId("hybrid-integration-confluence")).toHaveAttribute("data-mode", "hosted"); - await expect(page.getByTestId("hybrid-integration-slack_notifications")).toContainText("Works from your install, no app needed"); - await expect(page.getByTestId("hybrid-integration-mcp_apps")).toContainText("Works from your install, no app needed"); - await expect(page.getByTestId("hybrid-integration-slack_commands")).toContainText("Not available"); - // Sign in with GitHub works through Coderhelm's app: on, nothing to choose, - // and the card says the install decides who signs in. - const signIn = page.getByTestId("hybrid-integration-github_sign_in"); - await expect(signIn).toHaveAttribute("data-mode", "included"); - await expect(signIn).toContainText("On through Coderhelm's app"); - await expect(signIn).toContainText("your install asks GitHub itself whose account it is"); - await expect(signIn).not.toContainText("Google"); - await expect(signIn).not.toContainText("Not available"); - await expect(signIn.getByRole("button")).toHaveCount(0); - // GitHub has its own row above, so it isn't listed again. - await expect(page.getByTestId("hybrid-integration-github")).toHaveCount(0); + const row = page.getByTestId("hybrid-integrations"); + await row.getByRole("button", { name: "Fully private" }).click(); + await expect.poll(() => puts().at(-1)).toEqual({ apps_mode: "private", apps: ALL_OWN }); + await expect(row).toHaveAttribute("data-apps-mode", "private"); + await expect(row.getByTestId("hybrid-apps-line")).toContainText("Nothing goes through Coderhelm"); + await expect(row.getByTestId("hybrid-integration-notion")).toHaveAttribute("data-uses-coderhelm", "false"); + await row.getByRole("button", { name: "Use Coderhelm's apps (easiest)" }).click(); + await expect.poll(() => puts().at(-1)).toEqual({ apps_mode: "coderhelm", apps: ALL_TOOLS }); + await expect(row).toHaveAttribute("data-apps-mode", "coderhelm"); +}); + +test("other apps: an older gateway (no apps_mode) still shows and takes the choice", async ({ page }) => { + const { puts } = await setup(page, SELF, { registered: true, verified: true, olderGateway: true, appsMode: "private" }); + await page.goto("/settings/system/"); + const row = page.getByTestId("hybrid-integrations"); + await expect(row).toHaveAttribute("data-apps-mode", "private"); + await row.getByRole("button", { name: "Use Coderhelm's apps (easiest)" }).click(); + await expect.poll(() => puts().at(-1)).toEqual({ apps_mode: "coderhelm", apps: ALL_TOOLS }); + await expect(row).toHaveAttribute("data-apps-mode", "coderhelm"); }); -test("other apps: Google Drive can't use Coderhelm's app while Coderhelm's Drive app isn't set up", async ({ page }) => { - await setup(page, SELF, { registered: true, verified: true, driveOffered: false }); +test("other apps: a tool with its own app keeps it, and one Coderhelm can't offer yet says so", async ({ page }) => { + await setup(page, SELF, { registered: true, verified: true, driveOffered: false, ownApps: new Set(["notion"]) }); await page.goto("/settings/system/"); - const drive = page.getByTestId("hybrid-integration-google_drive"); - await expect(drive).toContainText("Coderhelm's app isn't set up yet"); - await expect(drive).toContainText("Use your own Google Drive app for now."); - await expect(drive.getByRole("button", { name: "Use Coderhelm's app (easiest)" })).toHaveCount(0); - // The others still offer the choice. - await expect(page.getByTestId("hybrid-integration-notion").getByRole("button", { name: "Use Coderhelm's app (easiest)" })).toBeVisible(); + const tools = page.getByTestId("hybrid-apps-tools"); + await expect(tools.getByTestId("hybrid-integration-notion")).toContainText("Notion, your own app"); + await expect(tools.getByTestId("hybrid-integration-notion")).toHaveAttribute("data-uses-coderhelm", "false"); + await expect(tools.getByTestId("hybrid-integration-google_drive")).toContainText("Google Drive, not ready yet"); + await expect(tools.getByTestId("hybrid-integration-confluence")).toHaveAttribute("data-uses-coderhelm", "true"); }); test("sharing with support: off by default, exactly what is sent, payloads only when asked", async ({ page }) => { @@ -438,7 +471,7 @@ test("domain: a Coderhelm address is the third choice and leads to the name pick await expect(page.getByTestId("domain-input")).toBeVisible(); }); -test("integration pages: the app choice saves the same settings, and links to System before registering", async ({ page }) => { +test("integration pages: GitHub keeps its own choice; other tools say which app and link to the one choice", async ({ page }) => { const { puts } = await setup(page, SELF, { registered: true, verified: true }); await page.goto("/settings/integrations/github/"); const choice = page.getByTestId("hybrid-app-choice"); @@ -449,8 +482,11 @@ test("integration pages: the app choice saves the same settings, and links to Sy await page.goto("/settings/integrations/jira/"); const jira = page.getByTestId("hybrid-app-choice"); - await jira.getByRole("button", { name: "Use Coderhelm's app (easiest)" }).click(); - await expect.poll(() => puts().at(-1)).toEqual({ apps: { jira: "coderhelm" } }); + await expect(jira).toHaveAttribute("data-state", "coderhelm"); + await expect(jira).toContainText("Jira signs in through Coderhelm's app, like every tool on this install."); + await expect(jira.getByRole("button")).toHaveCount(0); + await expect(jira.getByRole("link", { name: "Change it for every tool in Settings, Version and updates, Hybrid" })).toHaveAttribute("href", /\/settings\/system\/?#hybrid$/); + expect(puts()).toHaveLength(1); }); test("integration pages before registering point to Settings, System, Hybrid", async ({ page }) => { diff --git a/dashboard/e2e/knowledge-app-choice.spec.ts b/dashboard/e2e/knowledge-app-choice.spec.ts index fb79b747..1f0bead1 100644 --- a/dashboard/e2e/knowledge-app-choice.spec.ts +++ b/dashboard/e2e/knowledge-app-choice.spec.ts @@ -7,7 +7,8 @@ import path from "node:path"; // - "Use Coderhelm's app" shows one "Sign in with " button and the // choice's one line: no token steps and no form fields; // - a key stays behind "Use a key instead"; -// - "Use my own app" without the install's own app shows the token steps; +// - fully private, without the install's own app, shows the token steps; +// - there is no per-tool switch: the one Other apps choice lives in Settings; // - when Coderhelm's app isn't ready yet, it says so, still with no form. // Every call is answered here; nothing reaches a real backend. @@ -26,6 +27,7 @@ interface State { function hybridStatus(s: State) { const row = (id: string, name: string) => ({ id, name, mode: "hosted", through_coderhelm: "The sign-in only.", stays_with_you: "Every page Coderhelm reads.", uses_coderhelm: s.coderhelm.has(id) }); return { + apps_mode: s.coderhelm.size > 0 ? "coderhelm" : "private", available: true, hosted_url: "https://app.coderhelm.com", registered: true, @@ -101,7 +103,7 @@ async function shot(page: Page, name: string) { for (const kind of ["notion", "confluence"] as const) { const label = LABEL[kind]; - test.describe(`${label}: the app choice decides what the dialog asks for`, () => { + test.describe(`${label}: the install's Other apps choice decides what the dialog asks for`, () => { test(`Coderhelm's app: one sign-in button, no token steps or fields`, async ({ page }) => { await mockApi(page, { coderhelm: new Set([kind]), brokerReady: true, puts: [] }); await page.goto("/knowledge/"); @@ -119,7 +121,7 @@ for (const kind of ["notion", "confluence"] as const) { await expect(step.getByTestId("token-path")).toBeVisible(); }); - test(`my own app (none set up): the token steps, and no sign-in button`, async ({ page }) => { + test(`fully private (no own app set up): the token steps, and no sign-in button`, async ({ page }) => { await mockApi(page, { coderhelm: new Set(), brokerReady: true, puts: [] }); await page.goto("/knowledge/"); await page.getByTestId(`start-${kind}`).click(); @@ -131,18 +133,17 @@ for (const kind of ["notion", "confluence"] as const) { await shot(page, `${kind}-own`); }); - test(`switching to Coderhelm's app swaps the form for the sign-in button`, async ({ page }) => { + test(`no per-tool switch here: the dialog says which app and links to the one choice`, async ({ page }) => { const s: State = { coderhelm: new Set(), brokerReady: true, puts: [] }; await mockApi(page, s); await page.goto("/knowledge/"); await page.getByTestId(`start-${kind}`).click(); const step = page.getByTestId("connect-step"); - await expect(step.getByTestId("token-path")).toBeVisible(); - await step.getByRole("button", { name: "Use Coderhelm's app (easiest)" }).click(); - await expect(step).toHaveAttribute("data-state", "sign-in"); - await expect(step.getByTestId("connect-button")).toHaveText(`Sign in with ${label}`); - await expect(step.getByTestId("token-path")).toHaveCount(0); - expect(s.puts).toContainEqual({ apps: { [kind]: "coderhelm" } }); + const choice = step.getByTestId("hybrid-app-choice"); + await expect(choice).toContainText(`This install is fully private, so ${label} uses your team's own app.`); + await expect(choice.getByRole("button")).toHaveCount(0); + await expect(choice.getByRole("link", { name: "Change it for every tool in Settings, Version and updates, Hybrid" })).toHaveAttribute("href", /\/settings\/system\/?#hybrid/); + expect(s.puts).toEqual([]); }); test(`Coderhelm's app not ready yet: says so, still no form`, async ({ page }) => { diff --git a/dashboard/src/components/hybrid-app-choice.tsx b/dashboard/src/components/hybrid-app-choice.tsx index 571af0a6..547f937a 100644 --- a/dashboard/src/components/hybrid-app-choice.tsx +++ b/dashboard/src/components/hybrid-app-choice.tsx @@ -2,7 +2,7 @@ import Link from "next/link"; import { useState } from "react"; -import { HYBRID_HREF, appChoice, canUseCoderhelm, useHybrid } from "@/lib/hybrid"; +import { HYBRID_HREF, appsModeOf, canUseCoderhelm, useHybrid } from "@/lib/hybrid"; import { Segmented } from "./segmented"; import { useToast } from "./toast"; import { linkButton } from "./ui"; @@ -24,10 +24,12 @@ export function useHybridChoice(id: string): Choice | null { } /** - * On a self-hosted install: whether this integration uses Coderhelm's app - * (easiest) or the install's own (fully private). Reads and saves the same - * settings as Settings, then System, Hybrid. Shows nothing on the hosted - * service, on an install without hybrid, or where there is no choice. + * On a self-hosted install: which app this integration uses. GitHub has its + * own choice, made here or in Settings, then System, Hybrid. Every other + * tool follows the install's one Other apps choice (Coderhelm's apps or + * fully private), so it only says which, with a link to change it. Shows + * nothing on the hosted service, on an install without hybrid, or where + * Coderhelm has no app for it. */ export function HybridAppChoice({ id, @@ -38,7 +40,7 @@ export function HybridAppChoice({ id: string; name: string; className?: string; - /** After the choice is saved (what the dialog offers depends on it). */ + /** After GitHub's choice is saved. */ onChanged?: (next: Choice) => void; }) { const hybrid = useHybrid(); @@ -63,13 +65,30 @@ export function HybridAppChoice({ const integration = s.integrations.find((i) => i.id === id); // Not hosted, or Coderhelm's app for it isn't set up: there is no choice. if (id !== "github" && !canUseCoderhelm(integration)) return null; - const value: Choice = id === "github" ? (s.github.mode === "hosted" ? "coderhelm" : "own") : integration?.uses_coderhelm ? "coderhelm" : "own"; + if (id !== "github") { + const value: Choice = integration?.uses_coderhelm ? "coderhelm" : "own"; + const text = integration?.own_app + ? `${name} uses your own app, set up on this install.` + : appsModeOf(s) === "coderhelm" + ? `${name} signs in through Coderhelm's app, like every tool on this install.` + : `This install is fully private, so ${name} uses your team's own app.`; + return ( +
+

+ {text}{" "} + Change it for every tool in Settings, Version and updates, Hybrid +

+
+ ); + } + + const value: Choice = s.github.mode === "hosted" ? "coderhelm" : "own"; const change = async (next: Choice) => { if (next === value || busy) return; setBusy(true); try { - await hybrid.save(id === "github" ? { github_mode: next === "coderhelm" ? "hosted" : "own" } : appChoice(id, next === "coderhelm")); + await hybrid.save({ github_mode: next === "coderhelm" ? "hosted" : "own" }); toast(next === "coderhelm" ? `${name} now uses Coderhelm's app` : `${name} now uses your own app`); onChanged?.(next); } catch (e) { @@ -82,7 +101,7 @@ export function HybridAppChoice({ const note = value === "coderhelm" ? integration?.through_coderhelm || "Events reach your install through Coderhelm." - : integration?.stays_with_you || "Everything goes straight to your install. Nothing passes through Coderhelm."; + : "Everything goes straight to your install. Nothing passes through Coderhelm."; return (
diff --git a/dashboard/src/components/hybrid-section.tsx b/dashboard/src/components/hybrid-section.tsx index f1ceb722..717f7454 100644 --- a/dashboard/src/components/hybrid-section.tsx +++ b/dashboard/src/components/hybrid-section.tsx @@ -2,8 +2,8 @@ import Link from "next/link"; import { useEffect, useId, useRef, useState, type ReactNode } from "react"; -import { api, type HybridCheck, type HybridGithubLink, type HybridIntegration, type HybridNameCheck, type HybridStatus } from "@/lib/api"; -import { GITHUB_OUTCOMES, NAME_CODES, TRUST_MODEL_URL, appChoice, cleanName, useHybrid, type HybridState } from "@/lib/hybrid"; +import { api, type HybridAppsMode, type HybridCheck, type HybridGithubLink, type HybridNameCheck, type HybridStatus } from "@/lib/api"; +import { APPS_MODES, GITHUB_OUTCOMES, NAME_CODES, TRUST_MODEL_URL, appTools, appsModeOf, appsModePatch, cleanName, useHybrid, type HybridState } from "@/lib/hybrid"; import { Callout } from "./callout"; import { CopyButton } from "./copy-button"; import { useConfirm } from "./confirm-dialog"; @@ -686,75 +686,77 @@ function GithubLinkCard({ link, hybrid }: { link: HybridGithubLink; hybrid: Hybr ); } -// ── Other integrations ───────────────────────────────────────────── +// ── Other apps ───────────────────────────────────────────────────── +/** + * One choice for the whole install: Coderhelm's apps for every tool the + * catalog has one for (new ones included), or fully private. The tools are + * the gateway's catalog, never a list kept here. + */ function IntegrationsRow({ hybrid, s }: RowProps) { - const list = (s.integrations ?? []).filter((i) => i.id !== "github"); - if (list.length === 0) return null; + const { busy, act } = useAct(); + const tools = appTools(s); + const others = (s.integrations ?? []).filter((i) => i.id !== "github" && !tools.includes(i)); + if (tools.length === 0 && others.length === 0) return null; + const mode = appsModeOf(s); + const current = APPS_MODES.find((m) => m.value === mode) ?? APPS_MODES[0]; + const direct = others.filter((i) => i.mode === "direct"); + const included = others.filter((i) => i.mode === "included"); + const unavailable = others.filter((i) => i.mode === "unavailable"); return ( -
+
-

For each tool, use Coderhelm's app, or create your own so nothing passes through Coderhelm.

+

One choice for every tool Coderhelm has an app for, now and later. GitHub has its own choice above.

-
    - {list.map((i) => ( - - ))} -
-
- ); -} - -function IntegrationItem({ i, hybrid, s }: { i: HybridIntegration } & RowProps) { - const { busy, act } = useAct(); - const value = i.uses_coderhelm ? "coderhelm" : "own"; - const notOffered = i.mode === "hosted" && i.offered === false; - return ( -
  • -
    -

    {i.name}

    - {notOffered ? ( - Coderhelm's app isn't set up yet - ) : i.mode === "hosted" ? ( - - label={`Which ${i.name} app to use`} - value={value} - disabled={!!busy} - onChange={(v) => - void act("set", () => hybrid.save(appChoice(i.id, v === "coderhelm")), v === "coderhelm" ? `${i.name} uses Coderhelm's app` : `${i.name} uses your own app`) - } - options={[ - { value: "coderhelm", label: "Use Coderhelm's app (easiest)" }, - { value: "own", label: "Use my own app (fully private)" }, - ]} - /> - ) : i.mode === "direct" ? ( - Works from your install, no app needed - ) : i.mode === "included" ? ( - On through Coderhelm's app - ) : ( - Not available - )} -
    - {notOffered &&

    Use your own {i.name} app for now.

    } - {(i.mode === "hosted" || i.mode === "included") && !notOffered && (i.through_coderhelm || i.stays_with_you) && ( -
    - {i.through_coderhelm && ( -
    -
    Through Coderhelm
    -
    {i.through_coderhelm}
    + {tools.length > 0 && ( + <> +
    + + label="Other apps" + value={mode} + disabled={!!busy} + onChange={(v) => + void act("apps", () => hybrid.save(appsModePatch(s, v)), v === "coderhelm" ? "Other apps use Coderhelm's apps" : "Other apps are fully private") + } + options={APPS_MODES.map(({ value, label }) => ({ value, label }))} + /> +
    +

    {current.line}

    +
      + {tools.map((i) => ( +
    • + + {i.name} + {i.own_app ? ", your own app" : i.offered === false && mode === "coderhelm" ? ", not ready yet" : ""} + +
    • + ))} +
    + + )} + {(direct.length > 0 || included.length > 0 || unavailable.length > 0) && ( +
    + {direct.length > 0 && ( +
    +
    No app needed:
    +
    {direct.map((i) => i.name).join("; ")}
    +
    + )} + {included.length > 0 && ( +
    +
    Always through Coderhelm's app:
    +
    {included.map((i) => i.name).join("; ")}
    )} - {i.stays_with_you && ( -
    -
    Stays with you
    -
    {i.stays_with_you}
    + {unavailable.length > 0 && ( +
    +
    Not through Coderhelm:
    +
    {unavailable.map((i) => i.name).join("; ")}
    )}
    )} - {i.mode === "unavailable" && i.reason &&

    {i.reason}

    } -
  • +
    ); } diff --git a/dashboard/src/lib/api.ts b/dashboard/src/lib/api.ts index 0befe7d9..3c077eef 100644 --- a/dashboard/src/lib/api.ts +++ b/dashboard/src/lib/api.ts @@ -4950,6 +4950,8 @@ export interface HybridIntegration { uses_coderhelm: boolean; /** False when Coderhelm's own app for it isn't set up, so it can't be chosen now. Missing from older gateways. */ offered?: boolean; + /** Tools under Other apps: the install has its own app for it, which it uses either way. Missing from older gateways. */ + own_app?: boolean; } export interface HybridCheck { @@ -4970,6 +4972,8 @@ export interface HybridStatus { name: { name: string; hostname: string; code: string } | null; github: { mode: "own" | "hosted"; links: HybridGithubLink[]; app_slug: string | null }; integrations: HybridIntegration[]; + /** Other apps, for the whole install. Missing from older gateways (then read from `integrations`). */ + apps_mode?: HybridAppsMode; sharing: { enabled: boolean; payloads: boolean }; /** Jira through Coderhelm: a hosted team's site linked to this install (absent on an older install). */ jira?: { enabled: boolean; link: HybridJiraLink | null; synced: boolean }; @@ -5001,11 +5005,14 @@ export interface HybridNameCheck { error: string | null; } +/** Other apps: every tool on Coderhelm's app (new ones included), or none. */ +export type HybridAppsMode = "coderhelm" | "private"; + export interface HybridSettingsPatch { github_mode?: "own" | "hosted"; - /** The hosted-app integrations among jira, notion, confluence, google_drive (github follows github_mode). Older installs; newer ones take `apps`. */ - integrations?: string[]; - /** Other apps, per tool (jira, notion, confluence, google_drive): only the tools named change. A tool nobody chose uses Coderhelm's app. */ + /** Other apps, for the whole install. */ + apps_mode?: HybridAppsMode; + /** The same choice per tool, for a gateway from before `apps_mode` (it ignores `apps_mode`; a newer one ignores this). */ apps?: Record; sharing?: { enabled: boolean; payloads: boolean }; /** Settings, Integrations, Jira: link a hosted team's Jira site through Coderhelm. */ diff --git a/dashboard/src/lib/hybrid.ts b/dashboard/src/lib/hybrid.ts index 04b277b8..9771ac0e 100644 --- a/dashboard/src/lib/hybrid.ts +++ b/dashboard/src/lib/hybrid.ts @@ -4,7 +4,7 @@ // the System page, the integration pages and the tests agree. import { useCallback, useEffect, useState } from "react"; -import { api, errorStatus, type HybridIntegration, type HybridStatus, type HybridSettingsPatch } from "./api"; +import { api, errorStatus, type HybridAppsMode, type HybridIntegration, type HybridStatus, type HybridSettingsPatch } from "./api"; import { apiBase, isSelfHosted } from "./runtime-config"; /** Where the trust model is written down. */ @@ -81,9 +81,6 @@ export function cleanName(raw: string): string { return raw.trim().toLowerCase().replace(/\.coderhelm\.com$/, ""); } -/** The integrations a person can switch between Coderhelm's app and their own. */ -export const HOSTED_CHOICES = ["github", "jira", "notion", "confluence", "google_drive"] as const; - // ── Hosted dashboard hand-offs ───────────────────────────────────────── // // A self-hosted install borrows Coderhelm's apps, whose callbacks land on the @@ -217,7 +214,28 @@ export function canUseCoderhelm(i: HybridIntegration | undefined): boolean { return i?.mode === "hosted" && i.offered !== false; } -/** The settings change for one Other apps tool (GitHub follows its own mode). Only that tool changes. */ -export function appChoice(id: string, useCoderhelm: boolean): HybridSettingsPatch { - return { apps: { [id]: useCoderhelm ? "coderhelm" : "own" } }; +/** The tools the Other apps choice covers, from the catalog: every hosted one but GitHub, which has its own choice. */ +export function appTools(s: Pick): HybridIntegration[] { + return (s.integrations ?? []).filter((i) => i.mode === "hosted" && i.id !== "github"); +} + +/** The install's Other apps choice. A gateway from before it says only which tools use Coderhelm's app. */ +export function appsModeOf(s: Pick): HybridAppsMode { + if (s.apps_mode) return s.apps_mode; + const tools = appTools(s); + return tools.length === 0 || tools.some((i) => i.uses_coderhelm) ? "coderhelm" : "private"; +} + +/** + * The settings change for the Other apps choice. It also carries the same + * choice per tool, which only a gateway from before `apps_mode` reads. + */ +export function appsModePatch(s: Pick, mode: HybridAppsMode): HybridSettingsPatch { + return { apps_mode: mode, apps: Object.fromEntries(appTools(s).map((i) => [i.id, mode === "coderhelm" ? "coderhelm" : "own"])) }; } + +/** The two Other apps options, with their one line each. */ +export const APPS_MODES: { value: HybridAppsMode; label: string; line: string }[] = [ + { value: "coderhelm", label: "Use Coderhelm's apps (easiest)", line: "Sign in with one click through Coderhelm's app for each tool below, and for any Coderhelm adds later." }, + { value: "private", label: "Fully private", line: "Nothing goes through Coderhelm. Each tool uses your team's own app, set up on its card in Settings, Integrations." }, +]; diff --git a/dashboard/src/lib/openapi-fields.ts b/dashboard/src/lib/openapi-fields.ts index 1263c3bb..f78e5221 100644 --- a/dashboard/src/lib/openapi-fields.ts +++ b/dashboard/src/lib/openapi-fields.ts @@ -2,7 +2,7 @@ // docs/api/openapi.json. Do not edit; run `npm run openapi:fields` instead. /** The platform commit this was generated from. */ -export const OPENAPI_REF = "57cf0414f53f3bcf44f718adec33b8114e7499bf"; +export const OPENAPI_REF = "cda5c901bdf47b81e30c292856055967886c59d3"; /** The fields each public API schema has. */ export interface OpenApiFields { diff --git a/docs/components/install/wizard.tsx b/docs/components/install/wizard.tsx index 1d44d8ac..adfe18ec 100644 --- a/docs/components/install/wizard.tsx +++ b/docs/components/install/wizard.tsx @@ -31,9 +31,7 @@ import { HYBRID_GITHUB_OUTCOMES, NAME_ZONE, SETUPS, - ALL_HOSTED_APPS, - ALL_OWN_APPS, - OTHER_APPS, + APPS_MODES, appsBody, wantsHybrid, STEP_TIME, @@ -898,7 +896,7 @@ export function InstallWizard() { // CoderHelm's Jira app: Link through CoderHelm turned on now, so the // install reports hybrid_jira and the Jira step can follow the link. // Other apps: each tool's choice, applied as the install registers. - body = { ...body, github_mode: s.githubChoice, sharing: { enabled: s.sharing, payloads: false }, apps: appsBody(s), ...(s.jiraChoice === 'hosted' ? { jira_link: true } : {}) }; + body = { ...body, github_mode: s.githubChoice, sharing: { enabled: s.sharing, payloads: false }, ...appsBody(s), ...(s.jiraChoice === 'hosted' && s.appsMode !== 'private' ? { jira_link: true } : {}) }; } else if (s.domainChoice === 'coderhelm' && !nm && !hyb.claimRefused && cleanName(s.coderhelmName)) { path = '/name'; body = { ...body, name: cleanName(s.coderhelmName) }; @@ -999,8 +997,8 @@ export function InstallWizard() { const hybrid = s.setup === 'hybrid'; const pickSetup = (id: Setup) => update(id === 'hybrid' - ? { setup: 'hybrid', domainChoice: 'coderhelm', githubChoice: 'hosted', jiraChoice: 'hosted', appChoices: { ...ALL_HOSTED_APPS } } - : { setup: 'private', domainChoice: s.domainChoice === 'coderhelm' ? 'aws' : s.domainChoice, githubChoice: 'own', jiraChoice: 'own', appChoices: { ...ALL_OWN_APPS } }); + ? { setup: 'hybrid', domainChoice: 'coderhelm', githubChoice: 'hosted', jiraChoice: 'hosted', appsMode: 'coderhelm' } + : { setup: 'private', domainChoice: s.domainChoice === 'coderhelm' ? 'aws' : s.domainChoice, githubChoice: 'own', jiraChoice: 'own', appsMode: 'private' }); screen = (
    @@ -1079,23 +1077,27 @@ export function InstallWizard() { title="Use CoderHelm’s GitHub App" help="Install one app on your organization instead of creating your own. Events come through CoderHelm, checked and re-signed; your install gets short-lived tokens only for the repositories you pick." /> - update({ jiraChoice: v ? 'hosted' : 'own' })} - testId="hosted-jira" - title="Use CoderHelm’s Jira app" - help="Link your Jira site through CoderHelm’s Jira app instead of setting up your own. Events come through CoderHelm, checked and re-signed; your install never holds the app’s secret and calls Jira through CoderHelm. Needs a team on app.coderhelm.com that runs the Jira app on your site." - /> - {OTHER_APPS.map((a) => ( + {s.appsMode !== 'private' ? ( update({ appChoices: { ...ALL_HOSTED_APPS, ...s.appChoices, [a.id]: v ? 'hosted' : 'own' } })} - testId={`hosted-${a.id}`} - title={a.title} - help={`${a.help} Nothing passes through CoderHelm until someone connects it.`} + checked={s.jiraChoice === 'hosted'} + onChange={(v) => update({ jiraChoice: v ? 'hosted' : 'own' })} + testId="hosted-jira" + title="Use CoderHelm’s Jira app" + help="Link your Jira site through CoderHelm’s Jira app instead of setting up your own. Events come through CoderHelm, checked and re-signed; your install never holds the app’s secret and calls Jira through CoderHelm. Needs a team on app.coderhelm.com that runs the Jira app on your site." /> - ))} + ) : null} +
    + Other apps + {APPS_MODES.map((m) => ( + + ))} +
    update({ sharing: v })} diff --git a/docs/e2e/install.spec.ts b/docs/e2e/install.spec.ts index d54624c3..72b80fcf 100644 --- a/docs/e2e/install.spec.ts +++ b/docs/e2e/install.spec.ts @@ -1142,7 +1142,7 @@ test('hybrid Jira: the toggle sits next to GitHub, on by default, can be turned await page.locator('[data-setup="hybrid"]').click(); const options = page.getByTestId('hybrid-options'); await expect(jira).toBeChecked(); - await expect(options.locator('label')).toHaveText([/Use CoderHelm’s GitHub App/, /Use CoderHelm’s Jira app/, /Use CoderHelm’s Notion app/, /Use CoderHelm’s Confluence app/, /Use CoderHelm’s Google Drive app/, /Share delivery data/]); + await expect(options.locator('label')).toHaveText([/Use CoderHelm’s GitHub App/, /Use CoderHelm’s Jira app/, /Use CoderHelm’s apps \(easiest\)/, /Fully private/, /Share delivery data/]); await expect(options.locator('label').nth(1)).toContainText('your install never holds the app’s secret'); await expect(options.locator('label').nth(1)).toContainText('Events come through CoderHelm, checked and re-signed'); // The whole row is the control, with the hand cursor. @@ -1167,32 +1167,55 @@ test('hybrid Jira: the toggle sits next to GitHub, on by default, can be turned await expect(page.getByTestId('hosted-jira')).toBeChecked(); }); -test('hybrid other apps: Notion, Confluence and Google Drive are on by default, each says what passes through CoderHelm, and fully private turns them off', async ({ page }) => { +test('hybrid other apps: one choice, CoderHelm\u2019s apps by default, covering every tool and any added later', async ({ page }) => { await mock(page, newMock()); await mockHybrid(page, newHybrid()); await page.goto('/self-host/install/'); - const options = page.getByTestId('hybrid-options'); - for (const id of ['notion', 'confluence', 'google_drive']) await expect(page.getByTestId(`hosted-${id}`)).toBeChecked(); - const notion = options.locator('label', { hasText: 'Use CoderHelm’s Notion app' }); - await expect(notion).toContainText('CoderHelm keeps the sign-in (encrypted) and hands your install an access token when it syncs.'); - await expect(notion).toContainText('Nothing passes through CoderHelm until someone connects it.'); - await expect(options.locator('label', { hasText: 'Use CoderHelm’s Google Drive app' })).toContainText('read-only Drive access'); - await notion.click(); - await expect(page.getByTestId('hosted-notion')).not.toBeChecked(); - await expect(page.getByTestId('hosted-confluence')).toBeChecked(); - // Fully private hides them; hybrid again brings every one back on. + const apps = page.getByTestId('apps-mode'); + await expect(page.getByTestId('apps-mode-coderhelm')).toBeChecked(); + await expect(page.getByTestId('apps-mode-private')).not.toBeChecked(); + // One line per option; the tools are named once, Figma among them. + await expect(apps.locator('label').nth(0)).toContainText('Jira, Notion, Confluence, Google Drive, Figma and any app CoderHelm adds later'); + await expect(apps.locator('label').nth(1)).toContainText('Nothing goes through CoderHelm'); + // No per-tool toggles any more. + for (const id of ['notion', 'confluence', 'google_drive', 'figma']) await expect(page.getByTestId(`hosted-${id}`)).toHaveCount(0); + // Fully private hides the Jira link too; CoderHelm's apps brings it back (off). + await page.getByTestId('apps-mode-private').check(); + await expect(page.getByTestId('hosted-jira')).toHaveCount(0); + await page.getByTestId('apps-mode-coderhelm').check(); + await expect(page.getByTestId('hosted-jira')).not.toBeChecked(); + // The private setup hides the whole block; hybrid again starts on CoderHelm's apps. await page.locator('[data-setup="private"]').click(); - await expect(page.getByTestId('hosted-notion')).toHaveCount(0); + await expect(apps).toHaveCount(0); await page.locator('[data-setup="hybrid"]').click(); - for (const id of ['notion', 'confluence', 'google_drive']) await expect(page.getByTestId(`hosted-${id}`)).toBeChecked(); + await expect(page.getByTestId('apps-mode-coderhelm')).toBeChecked(); }); -test('hybrid other apps: the choices are applied to the install as it registers, a tool turned off as its own app', async ({ page }) => { +test('hybrid other apps: the choice is applied as the install registers, with the per-tool copy for an older install', async ({ page, browser }) => { const m = newMock({ setup: withHybrid(setupDoc(NO_APP), REG_OK) }); const h = newHybrid(); await mockHybrid(page, h); - await seeded(page, m, { ...JIRA_STATE, jiraChoice: 'own', appChoices: { notion: 'hosted', confluence: 'own', google_drive: 'hosted' } }); - await expect.poll(() => h.calls.find((c) => c.path === '/settings')?.body.apps).toEqual({ jira: 'own', notion: 'coderhelm', confluence: 'own', google_drive: 'coderhelm' }); + await seeded(page, m, { ...JIRA_STATE, appsMode: 'private' }); + await expect.poll(() => h.calls.find((c) => c.path === '/settings')?.body).toMatchObject({ apps_mode: 'private', apps: { jira: 'own', notion: 'own', confluence: 'own', google_drive: 'own' } }); + expect(h.calls.find((c) => c.path === '/settings')!.body.jira_link).toBeUndefined(); + + // A guide saved with the per-tool choices: any tool on means CoderHelm's apps. + const p2 = await browser.newPage(); + const m2 = newMock({ setup: withHybrid(setupDoc(NO_APP), REG_OK) }); + const h2 = newHybrid(); + await mockHybrid(p2, h2); + await seeded(p2, m2, { ...JIRA_STATE, jiraChoice: 'own', appChoices: { notion: 'hosted', confluence: 'own', google_drive: 'own' } }); + await expect.poll(() => h2.calls.find((c) => c.path === '/settings')?.body).toMatchObject({ apps_mode: 'coderhelm', apps: { jira: 'coderhelm', notion: 'coderhelm', confluence: 'coderhelm', google_drive: 'coderhelm' } }); + await p2.close(); + + // All off: fully private. + const p3 = await browser.newPage(); + const m3 = newMock({ setup: withHybrid(setupDoc(NO_APP), REG_OK) }); + const h3 = newHybrid(); + await mockHybrid(p3, h3); + await seeded(p3, m3, { ...JIRA_STATE, jiraChoice: 'own', appChoices: { notion: 'own', confluence: 'own', google_drive: 'own' } }); + await expect.poll(() => h3.calls.find((c) => c.path === '/settings')?.body?.apps_mode).toBe('private'); + await p3.close(); }); test('hybrid Jira: the guide turns on Link through CoderHelm with the setup key, and only when chosen', async ({ page, browser }) => { diff --git a/docs/lib/install/core.ts b/docs/lib/install/core.ts index 508cf0b8..0bf225cc 100644 --- a/docs/lib/install/core.ts +++ b/docs/lib/install/core.ts @@ -66,45 +66,41 @@ export const SETUPS: { id: Setup; title: string; tag?: string; gets: string[]; t id: 'hybrid', title: 'Hybrid', tag: 'Easiest', - gets: ['yourname.coderhelm.com, set up for you', 'CoderHelm\u2019s GitHub App: install it and you\u2019re done', 'CoderHelm\u2019s Jira app for your Jira site, linked in a minute', 'CoderHelm\u2019s Notion, Confluence and Google Drive apps: sign in with one click', 'Your code and data still stay in your AWS account'], + gets: ['yourname.coderhelm.com, set up for you', 'CoderHelm\u2019s GitHub App: install it and you\u2019re done', 'CoderHelm\u2019s Jira app for your Jira site, linked in a minute', 'CoderHelm\u2019s Notion, Confluence, Google Drive and Figma apps: sign in with one click', 'Your code and data still stay in your AWS account'], tradeoff: 'GitHub and Jira events pass through CoderHelm on their way to you (checked, re-signed, never stored past retries).', }, ]; -// ── Other apps: CoderHelm's app or the install's own, per tool ────────── - -/** The tools besides GitHub and Jira a hybrid install can use CoderHelm's app for. */ -export type OtherApp = 'notion' | 'confluence' | 'google_drive'; - -export type AppChoices = Record; +// ── Other apps: one choice for the whole install ───────────────────────── /** - * Each tool's toggle under What CoderHelm sets up for you. The help is the - * line Settings, System, Hybrid, Other apps shows for "Through Coderhelm". + * Settings, System, Hybrid, Other apps: CoderHelm's app for every tool it has + * one for (new ones included, with nothing more to choose), or fully private. */ -export const OTHER_APPS: { id: OtherApp; title: string; help: string }[] = [ - { id: 'notion', title: 'Use CoderHelm\u2019s Notion app', help: 'You sign in through CoderHelm\u2019s Notion integration. CoderHelm keeps the sign-in (encrypted) and hands your install an access token when it syncs.' }, - { id: 'confluence', title: 'Use CoderHelm\u2019s Confluence app', help: 'You sign in through CoderHelm\u2019s Atlassian app. CoderHelm keeps the sign-in (encrypted) and hands your install access tokens that expire within the hour.' }, - { id: 'google_drive', title: 'Use CoderHelm\u2019s Google Drive app', help: 'You sign in through CoderHelm\u2019s Google app (read-only Drive access). CoderHelm keeps the sign-in (encrypted) and hands your install access tokens that expire within the hour.' }, +export type AppsMode = 'coderhelm' | 'private'; + +/** The two options under What CoderHelm sets up for you, one line each. */ +export const APPS_MODES: { id: AppsMode; title: string; help: string }[] = [ + { id: 'coderhelm', title: 'Use CoderHelm\u2019s apps (easiest)', help: 'Jira, Notion, Confluence, Google Drive, Figma and any app CoderHelm adds later sign in with one click. Nothing passes through CoderHelm until someone connects a tool.' }, + { id: 'private', title: 'Fully private', help: 'Nothing goes through CoderHelm. Each tool uses your team\u2019s own app, set up on its card in Settings, Integrations.' }, ]; -export const ALL_HOSTED_APPS: AppChoices = { notion: 'hosted', confluence: 'hosted', google_drive: 'hosted' }; -export const ALL_OWN_APPS: AppChoices = { notion: 'own', confluence: 'own', google_drive: 'own' }; +/** The tools an install from an earlier release reads per tool (`apps`); it ignores `apps_mode`. */ +const LEGACY_APP_TOOLS = ['jira', 'notion', 'confluence', 'google_drive'] as const; /** - * The Other apps choices as the install takes them (`apps` on - * /api/setup/hybrid/settings): every tool, Jira included. A tool with no - * choice saved is CoderHelm's app, like the install's own default. + * The Other apps choice as the install takes it (/api/setup/hybrid/settings): + * `apps_mode`, and for one release the same choice per tool, which only an + * install from before `apps_mode` reads. */ -export function appsBody(s: Partial>): Record<'jira' | OtherApp, 'coderhelm' | 'own'> { - const c = { ...ALL_HOSTED_APPS, ...s.appChoices }; - const one = (v: 'own' | 'hosted' | undefined) => (v === 'own' ? 'own' : 'coderhelm'); - return { jira: one(s.jiraChoice), notion: one(c.notion), confluence: one(c.confluence), google_drive: one(c.google_drive) }; +export function appsBody(s: Partial>): { apps_mode: AppsMode; apps: Record } { + const mode: AppsMode = s.appsMode === 'private' ? 'private' : 'coderhelm'; + return { apps_mode: mode, apps: Object.fromEntries(LEGACY_APP_TOOLS.map((t) => [t, mode === 'coderhelm' ? 'coderhelm' : 'own'])) }; } /** Does any choice need the install registered with CoderHelm? */ -export function wantsHybrid(s: Partial>): boolean { - return s.domainChoice === 'coderhelm' || s.githubChoice === 'hosted' || s.jiraChoice === 'hosted' || s.emailTransport === 'coderhelm' || Object.values(s.appChoices ?? {}).includes('hosted'); +export function wantsHybrid(s: Partial>): boolean { + return s.domainChoice === 'coderhelm' || s.githubChoice === 'hosted' || s.jiraChoice === 'hosted' || s.emailTransport === 'coderhelm' || s.appsMode === 'coderhelm'; } /** The suffix every CoderHelm address has. */ @@ -299,11 +295,11 @@ export interface InstallState { */ jiraChoice?: 'own' | 'hosted'; /** - * Other apps, per tool (Settings, System, Hybrid, Other apps): CoderHelm's - * app or their own. Sent when the install registers. Older saved guides - * have none: they follow the setup they were saved with. + * Other apps, for the whole install (Settings, System, Hybrid, Other + * apps): CoderHelm's apps or fully private. Sent when the install + * registers. Older saved guides have per-tool `appChoices` instead. */ - appChoices?: AppChoices; + appsMode?: AppsMode; /** The Jira site to link, as typed (example.atlassian.net). */ jiraSite?: string; /** They chose to link the Jira site later, in Settings. */ @@ -388,7 +384,7 @@ export function newState(over: Partial = {}): InstallState { coderhelmName: '', githubChoice: 'hosted', jiraChoice: 'hosted', - appChoices: { ...ALL_HOSTED_APPS }, + appsMode: 'coderhelm', jiraSite: '', jiraSkipped: false, dataChoice: 'fresh', @@ -1067,7 +1063,7 @@ export function parseStored(raw: string | null): InstallState | null { // Saved before the setup choice existed: that guide was fully private // (the old default), so the hybrid default never applies to it. const before = v.setup !== 'private' && v.setup !== 'hybrid' - ? { setup: 'private' as const, domainChoice: 'aws' as const, githubChoice: 'own' as const, jiraChoice: 'own' as const, appChoices: { ...ALL_OWN_APPS } } + ? { setup: 'private' as const, domainChoice: 'aws' as const, githubChoice: 'own' as const, jiraChoice: 'own' as const, appsMode: 'private' as const } : {}; const s: InstallState = { ...newState(), ...before, ...v }; // Saved before the Your data step existed: the guide goes on as it was. @@ -1081,12 +1077,16 @@ export function parseStored(raw: string | null): InstallState | null { if (v.jiraChoice !== 'own' && v.jiraChoice !== 'hosted') { s.jiraChoice = s.setup === 'hybrid' || s.githubChoice === 'hosted' ? 'hosted' : 'own'; } - // Saved before the Other apps choices: on for hybrid, like the install's default. - if (!v.appChoices || typeof v.appChoices !== 'object') { - s.appChoices = s.setup === 'hybrid' ? { ...ALL_HOSTED_APPS } : { ...ALL_OWN_APPS }; - } else { - s.appChoices = { ...ALL_HOSTED_APPS, ...v.appChoices }; + // Saved before the one Other apps choice: per-tool choices count as + // CoderHelm's apps when any tool was on (a tool never set was on), as + // fully private when all were off; none saved follows the setup. + if (v.appsMode !== 'coderhelm' && v.appsMode !== 'private') { + const old = v.appChoices && typeof v.appChoices === 'object' ? (v.appChoices as Record) : null; + s.appsMode = old + ? ['notion', 'confluence', 'google_drive'].some((t) => old[t] !== 'own') ? 'coderhelm' : 'private' + : s.setup === 'hybrid' ? 'coderhelm' : 'private'; } + delete (s as { appChoices?: unknown }).appChoices; return s; } catch { return null; @@ -1414,7 +1414,7 @@ export function optionalSetup(s: Pick Date: Sun, 8 Nov 2026 19:18:38 -0500 Subject: [PATCH 2/2] API field list at platform main --- dashboard/src/lib/openapi-fields.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dashboard/src/lib/openapi-fields.ts b/dashboard/src/lib/openapi-fields.ts index f78e5221..42de6520 100644 --- a/dashboard/src/lib/openapi-fields.ts +++ b/dashboard/src/lib/openapi-fields.ts @@ -2,7 +2,7 @@ // docs/api/openapi.json. Do not edit; run `npm run openapi:fields` instead. /** The platform commit this was generated from. */ -export const OPENAPI_REF = "cda5c901bdf47b81e30c292856055967886c59d3"; +export const OPENAPI_REF = "7a14dce62aabf4827fc6ecdd14b578f930143b2e"; /** The fields each public API schema has. */ export interface OpenApiFields {