Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

feat(onboarding): align setup and connection to the approved design (#2048)

Maxdf9e29147c24
diff --git a/core/handlers/model_hub/migration.py b/core/handlers/model_hub/migration.py
index ac11cf271..bb67666cc 100644
--- a/core/handlers/model_hub/migration.py
+++ b/core/handlers/model_hub/migration.py
@@ -136,8 +136,18 @@ class NativeMigrationItem:
secret: Optional[str] = field(default=None, repr=False)
account_label: Optional[str] = None
manual_models: tuple[NativeManualModel, ...] = ()
+ # Already-masked credential text, produced by the same `mask_credential` the
+ # producer used for `masked_detail`. Carried as its own field so a client can
+ # render provider and key as separate elements without re-parsing the
+ # composed detail string; never holds plaintext.
+ masked_credential: Optional[str] = None
def to_payload(self) -> dict[str, object]:
+ # Presentation metadata is additive: `vendor` and `display_name` let a
+ # client name and draw the provider instead of inferring identity from
+ # `backend` (which cannot tell an OpenCode config key from an auth.json
+ # one). Every pre-existing key keeps its exact value so the broader
+ # settings migration surface is untouched.
return {
"id": self.id,
"backend": self.backend,
@@ -146,6 +156,9 @@ class NativeMigrationItem:
"proposed_action": self.proposed_action,
"selected": self.selected,
"notes_key": self.notes_key,
+ "vendor": self.vendor,
+ "display_name": self.display_name,
+ "masked_credential": self.masked_credential,
}
@@ -221,6 +234,7 @@ def _claude_items(
display_name="Anthropic",
base_url=base_url,
secret=api_key,
+ masked_credential=detail,
)
)
@@ -248,6 +262,7 @@ def _claude_items(
protocol="anthropic",
display_name="Anthropic",
base_url=base_url,
+ masked_credential=detail,
)
)
@@ -335,6 +350,7 @@ def _codex_items(
display_name="OpenAI",
base_url=base_url,
secret=api_key,
+ masked_credential=detail,
)
)
@@ -530,7 +546,8 @@ def _opencode_items(
*(f"{model.id}\0{model.display_name or ''}" for model in manual_models),
),
)
- detail = f"{provider_id} · {mask_credential(secret)}"
+ masked_secret = mask_credential(secret)
+ detail = f"{provider_id} · {masked_secret}"
items.append(
NativeMigrationItem(
id=item_id,
@@ -547,6 +564,7 @@ def _opencode_items(
base_url=base_url,
secret=secret,
manual_models=manual_models,
+ masked_credential=masked_secret,
)
)
return items
diff --git a/docs/plans/model-hub-contracts/migration-scan.schema.json b/docs/plans/model-hub-contracts/migration-scan.schema.json
index eb041974e..791fda604 100644
--- a/docs/plans/model-hub-contracts/migration-scan.schema.json
+++ b/docs/plans/model-hub-contracts/migration-scan.schema.json
@@ -23,7 +23,10 @@
"description": "Claude and Codex native OAuth logins remain in the sanctioned CLI store via keep_native; subscription OAuth tokens are never copied by this file-import surface. Hub-held subscriptions are established only by the explicit OAuth add flow. controlled_import remains reserved for a future engine-owned import capability. API keys and Base URLs use import."
},
"selected": { "type": "boolean" },
- "notes_key": { "type": ["string", "null"], "description": "i18n key for the row's secondary line" }
+ "notes_key": { "type": ["string", "null"], "description": "i18n key for the row's secondary line" },
+ "vendor": { "type": "string", "description": "Additive presentation metadata (ratified 2026-09-19). The provider this credential belongs to — an OpenCode row carries its native provider id. Optional: a client that does not receive it falls back to masked_detail and a generic icon, and never infers provider identity from `backend`." },
+ "display_name": { "type": "string", "description": "Additive presentation metadata. The server's own label for the provider. Not guaranteed friendly — OpenCode currently emits the provider id — so a client maps known vendors to brand names and falls back to this label, then to the slug." },
+ "masked_credential": { "type": ["string", "null"], "description": "Additive presentation metadata. The masked credential alone, produced by the same masking the composed masked_detail used, so a client can render provider and key separately without re-parsing that string. Never a plaintext secret; null on rows that have no credential of their own." }
}
}
}
diff --git a/tests/scenarios/INDEX.yaml b/tests/scenarios/INDEX.yaml
index de9243edd..0c9996b4f 100644
--- a/tests/scenarios/INDEX.yaml
+++ b/tests/scenarios/INDEX.yaml
@@ -173,6 +173,9 @@ capabilities:
- ui/src/components/settings/models/RouteChainDialog.test.tsx
- ui/src/components/settings/models/BackendModelCatalogDialog.test.tsx
- ui/src/components/settings/models/AgentCard.test.tsx
+ - ui/src/components/settings/models/MigrationDialog.test.tsx
+ - ui/src/components/settings/models/migrationScan.test.ts
+ - ui/src/components/onboarding/ImportKeysNotice.test.tsx
- ui/scripts/scenarioCatalog.test.mjs
- id: harness_failure_recovery
name: Harness per-Session failure recovery
diff --git a/tests/scenarios/model_hub/catalog.yaml b/tests/scenarios/model_hub/catalog.yaml
index 197765cb0..71eaa7b32 100644
--- a/tests/scenarios/model_hub/catalog.yaml
+++ b/tests/scenarios/model_hub/catalog.yaml
@@ -32,6 +32,11 @@ capability:
- ui/src/components/settings/models/RouteChainDialog.test.tsx
- ui/src/components/settings/models/BackendModelCatalogDialog.test.tsx
- ui/src/components/settings/models/AgentCard.test.tsx
+ # Migration: the setup key-import entry and the broader settings dialog it
+ # narrows, plus the one predicate that separates them.
+ - ui/src/components/settings/models/MigrationDialog.test.tsx
+ - ui/src/components/settings/models/migrationScan.test.ts
+ - ui/src/components/onboarding/ImportKeysNotice.test.tsx
# The gate that resolves those rows against vitest's own collection, and
# its own evidence.
- ui/scripts/scenarioCatalog.test.mjs
@@ -704,6 +709,24 @@ scenarios:
kind: migration
layer: scenario
test: tests/scenarios/model_hub/test_model_hub_migration_scenarios.py::test_mh_mig_002_oauth_defaults_to_native_sources
+ - id: MH-MIG-003
+ name: A scan row names the provider it belongs to without ever carrying a plaintext credential
+ status: covered
+ kind: migration
+ layer: scenario
+ test: tests/scenarios/model_hub/test_model_hub_migration_scenarios.py::test_mh_mig_003_scan_rows_name_their_provider_without_exposing_plaintext
+ related_tests:
+ - tests/scenarios/model_hub/test_model_hub_migration_scenarios.py::test_masked_credential_is_the_same_masking_the_detail_already_showed
+ - tests/scenarios/model_hub/test_model_hub_migration_scenarios.py::test_presentation_metadata_leaves_every_pre_existing_value_and_id_alone
+ - id: MH-MIG-004
+ name: Setup's key-import entry counts, offers and submits one and the same set, and leaves subscriptions and reauth rows to the settings migration
+ status: covered
+ kind: migration
+ layer: unit
+ test: "ui/src/components/onboarding/ImportKeysNotice.test.tsx::MH-MIG-004: submits only the rows still ticked"
+ related_tests:
+ - ui/src/components/settings/models/migrationScan.test.ts::counts an OpenCode key, which never arrives as kind api_key
+ - ui/src/components/settings/models/MigrationDialog.test.tsx::applies a keep_native row — it is a real action here, not a leftover
- id: MH-TAKEOVER-001
name: Recoverable failures walk the configured route and exhaust only at its end
status: covered
diff --git a/tests/scenarios/model_hub/test_model_hub_migration_scenarios.py b/tests/scenarios/model_hub/test_model_hub_migration_scenarios.py
index e248157b8..d5f4f3bdf 100644
--- a/tests/scenarios/model_hub/test_model_hub_migration_scenarios.py
+++ b/tests/scenarios/model_hub/test_model_hub_migration_scenarios.py
@@ -1226,3 +1226,207 @@ def test_apply_rejects_a_credential_changed_after_scan(
assert error.value.code == "migration_item_conflict"
assert adapter.provisioned == []
assert store.config.sources == []
+
+
+# --- Additive provider-presentation metadata (ratified 2026-09-19) -----------
+#
+# `vendor`, `display_name` and `masked_credential` let a client name and draw the
+# provider a credential belongs to. They exist because `backend` cannot: it says
+# which CLI held the key, not whose key it is, and an OpenCode row can come from
+# either of two stores. The tests below hold the three properties that make them
+# safe to add — every source shape carries them, the masked credential is the same
+# masking the composed detail already used, and no pre-existing value or id moves.
+
+_KEY_FROM_OPENCODE_CONFIG = "sk-config-deepseek-123456"
+_KEY_FROM_OPENCODE_AUTH = "sk-auth-zhipu-123456"
+_CLAUDE_KEY = "sk-ant-meta-123456789"
+_CLAUDE_TOKEN = "bearer-meta-123456"
+_CODEX_KEY = "sk-openai-meta-123456"
+
+_ALL_PLAINTEXT = (
+ _KEY_FROM_OPENCODE_CONFIG,
+ _KEY_FROM_OPENCODE_AUTH,
+ _CLAUDE_KEY,
+ _CLAUDE_TOKEN,
+ _CODEX_KEY,
+ "claude-oauth-meta-token",
+ "codex-oauth-meta-token",
+)
+
+
+def _write_key_sources(home: Path) -> None:
+ """Every shape that yields an importable key, in one home."""
+ _write(
+ home / ".claude" / "settings.json",
+ json.dumps({"env": {"ANTHROPIC_API_KEY": _CLAUDE_KEY, "ANTHROPIC_AUTH_TOKEN": _CLAUDE_TOKEN}}),
+ )
+ _write(home / ".codex" / "auth.json", json.dumps({"OPENAI_API_KEY": _CODEX_KEY}))
+ _write(home / ".codex" / "config.toml", 'cli_auth_credentials_store = "file"\n')
+ # deepseek keeps its key in the OpenCode config file, zhipuai in auth.json —
+ # the two stores `backend` + `kind` cannot tell apart.
+ _write(
+ home / ".config" / "opencode" / "opencode.json",
+ json.dumps(
+ {
+ "provider": {
+ "deepseek": {"options": {"apiKey": _KEY_FROM_OPENCODE_CONFIG}},
+ "zhipuai": {"options": {"baseURL": "https://zhipu.example/v1"}},
+ }
+ }
+ ),
+ )
+ _write(
+ home / ".local" / "share" / "opencode" / "auth.json",
+ json.dumps({"zhipuai": {"type": "api", "key": _KEY_FROM_OPENCODE_AUTH}}),
+ )
+ _write(
+ home / ".cache" / "opencode" / "models.json",
+ json.dumps(
+ {
+ "deepseek": {
+ "id": "deepseek",
+ "npm": "@ai-sdk/openai-compatible",
+ "api": "https://api.deepseek.com/v1",
+ },
+ "zhipuai": {
+ "id": "zhipuai",
+ "npm": "@ai-sdk/openai-compatible",
+ "api": "https://zhipu.example/v1",
+ },
+ }
+ ),
+ )
+
+
+def _write_oauth_sources(home: Path) -> None:
+ """The subscription shapes, which carry no credential of their own."""
+ _write(
+ home / ".claude" / ".credentials.json",
+ json.dumps({"claudeAiOauth": {"accessToken": "claude-oauth-meta-token"}}),
+ )
+ _write(
+ home / ".codex" / "auth.json",
+ json.dumps({"auth_mode": "chatgpt", "tokens": {"access_token": "codex-oauth-meta-token"}}),
+ )
+ _write(home / ".codex" / "config.toml", 'cli_auth_credentials_store = "file"\n')
+
+
+def test_mh_mig_003_scan_rows_name_their_provider_without_exposing_plaintext(
+ tmp_path: Path,
+) -> None:
+ """MH-MIG-003: every shape the scan produces carries the provider it belongs
+ to, and no shape carries a plaintext credential."""
+ home = tmp_path / "keys"
+ _write_key_sources(home)
+ items = scan_native_configs(ModelHubConfig(), home=home, mask_credential=_mask_credential)
+ payload = {"items": [item.to_payload() for item in items]}
+ _validate_scan(payload)
+
+ by_shape = {
+ (row["backend"], row["kind"], row["proposed_action"]): row for row in payload["items"]
+ }
+ # Claude's API key and its Auth Token, Codex's API key, and an OpenCode key
+ # from each of the two stores. The Auth Token is `reauth` and still needs a
+ # name to show, so metadata is not conditional on being importable.
+ assert set(by_shape) == {
+ ("claude", "api_key", "import"),
+ ("claude", "api_key", "reauth"),
+ ("codex", "api_key", "import"),
+ ("opencode", "opencode_provider", "import"),
+ }
+ assert len([r for r in payload["items"] if r["backend"] == "opencode"]) == 2
+
+ for row in payload["items"]:
+ assert row["vendor"], row
+ assert row["display_name"], row
+ assert row["masked_credential"], row
+
+ serialized = json.dumps(payload)
+ for secret in _ALL_PLAINTEXT:
+ assert secret not in serialized
+
+
+def test_masked_credential_is_the_same_masking_the_detail_already_showed(
+ tmp_path: Path,
+) -> None:
+ home = tmp_path / "keys"
+ _write_key_sources(home)
+ rows = [
+ item.to_payload()
+ for item in scan_native_configs(
+ ModelHubConfig(), home=home, mask_credential=_mask_credential
+ )
+ ]
+
+ for row in rows:
+ if row["backend"] == "opencode":
+ # The composed detail is provider + masked key; splitting it in the
+ # client would be re-parsing a display string, so the field carries
+ # the same text the composition used.
+ assert row["masked_detail"] == f"{row['vendor']} · {row['masked_credential']}"
+ else:
+ # Claude and Codex show the masked key alone, so the two agree exactly.
+ assert row["masked_detail"] == row["masked_credential"]
+
+ for plaintext in (_KEY_FROM_OPENCODE_CONFIG, _KEY_FROM_OPENCODE_AUTH, _CLAUDE_KEY):
+ masked = _mask_credential(plaintext)
+ assert masked != plaintext
+ assert any(row["masked_credential"] == masked for row in rows), masked
+
+
+def test_subscription_rows_carry_a_name_but_no_credential(tmp_path: Path) -> None:
+ home = tmp_path / "oauth"
+ _write_oauth_sources(home)
+ rows = [
+ item.to_payload()
+ for item in scan_native_configs(
+ ModelHubConfig(), home=home, mask_credential=_mask_credential
+ )
+ ]
+ _validate_scan({"items": rows})
+
+ assert {(row["backend"], row["kind"], row["proposed_action"]) for row in rows} == {
+ ("claude", "oauth_native", "keep_native"),
+ ("codex", "oauth_native", "keep_native"),
+ }
+ for row in rows:
+ assert row["vendor"] and row["display_name"]
+ # There is no key here to mask; a client falls back to `masked_detail`.
+ assert row["masked_credential"] is None
+
+
+def test_presentation_metadata_leaves_every_pre_existing_value_and_id_alone(
+ tmp_path: Path,
+) -> None:
+ home = tmp_path / "keys"
+ _write_key_sources(home)
+
+ def scan() -> list:
+ return scan_native_configs(
+ ModelHubConfig(), home=home, mask_credential=_mask_credential
+ )
+
+ established = (
+ "id",
+ "backend",
+ "kind",
+ "masked_detail",
+ "proposed_action",
+ "selected",
+ "notes_key",
+ )
+ first = [item.to_payload() for item in scan()]
+ second = [item.to_payload() for item in scan()]
+
+ # Ids are content-derived, so a second scan of untouched files must reproduce
+ # them exactly — an id that moved would orphan a selection made before it.
+ assert [{k: row[k] for k in established} for row in first] == [
+ {k: row[k] for k in established} for row in second
+ ]
+ # And the established half still reads off the dataclass it always did.
+ for item, row in zip(scan(), first):
+ assert row["id"] == item.id
+ assert row["masked_detail"] == item.masked_detail
+ assert row["proposed_action"] == item.proposed_action
+ assert row["selected"] == item.selected
+ assert row["notes_key"] == item.notes_key
diff --git a/ui/e2e/onboarding-fidelity/connections.spec.ts b/ui/e2e/onboarding-fidelity/connections.spec.ts
index 0f500ca98..d27efa0b5 100644
--- a/ui/e2e/onboarding-fidelity/connections.spec.ts
+++ b/ui/e2e/onboarding-fidelity/connections.spec.ts
@@ -68,6 +68,132 @@ for (const lang of ['en', 'zh']) for (const theme of ['dark', 'light']) {
});
}
+/**
+ * The reported defect: switching Subscription/API Key re-measured the dialog and moved
+ * its own top edge, because a centred box with content height moves by half of every
+ * content change. The fix is a fixed frame whose height belongs to the assistant, so this
+ * measures the anchors the contract names — heading, tab bar, dialog bounds, footer —
+ * across repeated switches in BOTH directions. Repetition matters: a one-way switch can
+ * be stable while the way back is not, and a frame that settles a frame late would pass a
+ * single comparison.
+ */
+const anchorBoxes = (page: Page) => page.evaluate(() => {
+ const round = (value: number) => Math.round(value * 10) / 10;
+ const read = (selector: string) => {
+ const node = document.querySelector(selector);
+ if (!node) return null;
+ const rect = node.getBoundingClientRect();
+ return { x: round(rect.x), y: round(rect.y), width: round(rect.width), height: round(rect.height) };
+ };
+ return {
+ frame: read('.connection-dialog'),
+ heading: read('.connection-heading'),
+ description: read('.connection-description'),
+ // The method tabs are the dialog's first radio group; a credential group, when a
+ // method has one, lives inside the scrolling middle and is not an anchor.
+ tabs: read('.connection-dialog [role="radiogroup"]'),
+ close: read('.connection-dialog > button:last-of-type'),
+ footer: read('.connection-actions'),
+ };
+});
+
+/** Only the middle may scroll: a scroller inside the frame's other rows — or the frame
+ * itself — would mean it had been asked to hold more than it has room for. */
+const scrollers = (page: Page) => page.evaluate(() => [...document.querySelectorAll('.connection-dialog, .connection-dialog *')]
+ .filter((node) => node.scrollHeight > node.clientHeight + 1 && ['auto', 'scroll'].includes(getComputedStyle(node).overflowY))
+ .map((node) => node.className.toString())
+ .filter((name) => name !== 'connection-body'));
+
+/**
+ * What the window leaves a frame. The dialog asks for its assistant's own height and the
+ * shared primitive caps it — `100dvh - 32` on a desktop, and below 768 the mobile sheet's
+ * `90dvh`. Deriving that here keeps the check about the ASSISTANT deciding the height
+ * while staying exact at a window too short to grant it.
+ */
+const room = (viewport: { width: number; height: number }) =>
+ (viewport.width < 768 ? viewport.height * 0.9 : viewport.height - 32);
+
+for (const viewport of [{ width: 1200, height: 800 }, { width: 390, height: 640 }]) {
+ test(`the connection frame holds while its methods change ${viewport.width}x${viewport.height}`, async ({ page }, info) => {
+ const denied = await serveProduct(page); await authFixtures(page);
+ await page.setViewportSize(viewport);
+ await openOnboarding(page); await openSetup(page, 'en');
+ await page.getByLabel('Claude Code', { exact: true }).getByRole('button', { name: 'Add subscription' }).click();
+ const dialog = page.getByRole('dialog');
+ const method = dialog.getByRole('radiogroup', { name: 'Connection method' });
+ await expect(dialog.getByRole('button', { name: 'Sign in with Claude' })).toBeVisible();
+ await settleEffects(page);
+
+ const baseline = await anchorBoxes(page);
+ // The height is the assistant's, so it cannot be a function of what is on screen.
+ expect(baseline.frame!.height).toBeCloseTo(Math.min(620, room(viewport)), 0);
+ for (const anchor of Object.values(baseline)) expect(anchor).not.toBeNull();
+ expect(baseline.frame!.y + baseline.frame!.height).toBeLessThanOrEqual(viewport.height);
+
+ // Subscription ⇄ API Key, four times, with the anchors measured after each.
+ for (const label of ['API credentials', 'Claude account', 'API credentials', 'Claude account']) {
+ await method.getByRole('radio', { name: label, exact: true }).click();
+ await expect(method.getByRole('radio', { name: label, exact: true })).toHaveAttribute('aria-checked', 'true');
+ await settleEffects(page);
+ expect(await anchorBoxes(page)).toEqual(baseline);
+ expect(await scrollers(page)).toEqual([]);
+ }
+
+ // API Key ⇄ Auth Token, the second switch the contract names. It lives inside the
+ // middle, so it is exactly the kind of change that used to move everything above it.
+ await method.getByRole('radio', { name: 'API credentials', exact: true }).click();
+ const credential = dialog.getByRole('radiogroup', { name: 'Credential type' });
+ await expect(credential).toBeVisible();
+ for (const label of ['Auth Token', 'API Key', 'Auth Token', 'API Key']) {
+ await credential.getByRole('radio', { name: label, exact: true }).click();
+ await expect(credential.getByRole('radio', { name: label, exact: true })).toHaveAttribute('aria-checked', 'true');
+ await settleEffects(page);
+ expect(await anchorBoxes(page)).toEqual(baseline);
+ }
+ // The label the field asks for follows the choice, which is the only thing that
+ // should have changed across all of that.
+ await expect(dialog.getByLabel('Auth Token', { exact: true })).toHaveCount(0);
+ await expect(dialog.getByLabel('API Key', { exact: true })).toBeVisible();
+ await settleEffects(page);
+ await dialog.screenshot({ path: info.outputPath(`frame-stability-claude-${viewport.width}x${viewport.height}.png`) });
+
+ // A radio group is ONE tab stop that answers arrow keys, and the selected tab keeps
+ // the focus so the next press continues from where the reader is. The loop above left
+ // the second tab selected, so that is the one Tab reaches.
+ const tabs = method.getByRole('radio');
+ expect(await tabs.evaluateAll((nodes) => nodes.map((node) => (node as HTMLElement).tabIndex))).toEqual([-1, 0]);
+ await tabs.nth(1).focus();
+ await page.keyboard.press('ArrowRight'); // wraps
+ await expect(tabs.first()).toBeFocused();
+ await expect(tabs.first()).toHaveAttribute('aria-checked', 'true');
+ await page.keyboard.press('ArrowRight');
+ await expect(tabs.nth(1)).toBeFocused();
+ await expect(tabs.nth(1)).toHaveAttribute('aria-checked', 'true');
+ await page.keyboard.press('Home');
+ await expect(tabs.first()).toBeFocused();
+ await page.keyboard.press('End');
+ await expect(tabs.nth(1)).toBeFocused();
+ await expect(tabs.nth(1)).toHaveAttribute('aria-checked', 'true');
+ expect(await anchorBoxes(page)).toEqual(baseline);
+
+ await page.keyboard.press('Escape'); await expect(dialog).toHaveCount(0);
+
+ // The frame is the assistant's own: Codex is the shorter one, and it holds too.
+ await page.getByLabel('Codex', { exact: true }).getByRole('button', { name: 'Add API Key' }).click();
+ await expect(dialog.getByLabel('Base URL (optional)')).toBeVisible();
+ await settleEffects(page);
+ const codex = await anchorBoxes(page);
+ expect(codex.frame!.height).toBeCloseTo(Math.min(580, room(viewport)), 0);
+ for (const label of ['Sign in with ChatGPT', 'OpenAI API Key', 'Sign in with ChatGPT']) {
+ await dialog.getByRole('radiogroup', { name: 'Connection method' }).getByRole('radio', { name: label, exact: true }).click();
+ await settleEffects(page);
+ expect(await anchorBoxes(page)).toEqual(codex);
+ }
+ await page.keyboard.press('Escape');
+ expect(denied).toEqual([]);
+ });
+}
+
for (const lang of ['en', 'zh']) {
test(`corrected compact labels and Light action ${lang}`, async ({ page }, info) => {
const denied = await serveProduct(page); await authFixtures(page);
diff --git a/ui/e2e/onboarding-fidelity/geometry.spec.ts b/ui/e2e/onboarding-fidelity/geometry.spec.ts
index cee0ec604..0c1a094bd 100644
--- a/ui/e2e/onboarding-fidelity/geometry.spec.ts
+++ b/ui/e2e/onboarding-fidelity/geometry.spec.ts
@@ -1,24 +1,26 @@
import { expect, test, type Page } from '@playwright/test';
import {
PHASES, VIEWPORTS, cssEffects, freezeAt, openOnboarding, openSetup, renderedPhase,
- serveProduct, setDocumentHidden, settleEffects, size, storeThemePreference,
+ serveModelHub, serveProduct, setDocumentHidden, settleEffects, size, storeThemePreference,
} from './support';
/**
- * The 2026-09-17 design is a set of exact numbers, so this suite measures the shipped
- * component in a browser instead of asserting that nothing overflows. Screenshots are
- * written as artifacts from the same runs that make the assertions, so the evidence and
- * the guard can never describe two different builds.
+ * The design is a set of exact relations, so this suite measures the shipped component in
+ * a browser instead of asserting that nothing overflows. Screenshots are written as
+ * artifacts from the same runs that make the assertions, so the evidence and the guard can
+ * never describe two different builds.
*
* Sizes: a Playwright viewport IS the web content box, so nothing is subtracted for
- * chrome. The design's own 1200x800 frames include the native 44px titlebar above the
- * web view, which makes the design's content box 1200x756 — that is the size to overlay
- * a frame against (DESIGN_FRAME below). The dispatch's 1200x800 of effective content is
- * the larger window that same content box needs, and is what the matrix captures.
+ * chrome. The design's own 1200x800 frames include the native 44px titlebar above the web
+ * view, which makes the design's content box 1200x756 — that is the size to overlay a
+ * frame against (DESIGN_FRAME below).
*
- * The owner accepted 1104 as the desktop content cap on 2026-09-17, superseding the
- * frames' authored 880. Every number below is that decision applied to the frame's
- * proportion (1104/880 = 1.2545...), not a re-measured design.
+ * What is asserted is the RULE, not a row of copied numbers. The composition is one
+ * content column whose width is `clamp(976px, 62.5vw, 1200px)` inside the shell's gutter,
+ * and one card height taken from the window; everything else is a ratio of those two. So
+ * the helpers below re-derive the column and the card from what the browser reports, and
+ * the tests check that every dependent box is the share of them the design draws. A test
+ * that hard-coded 976 and 299 would pass on a layout that had stopped deriving them.
*/
const DESIGN_FRAME = { width: 1200, height: 756 };
/**
@@ -31,6 +33,15 @@ const DESIGN_FRAME = { width: 1200, height: 756 };
const CAPTURE_PHASE = 'codex-working';
const CAPTURE_STATES = ['complete', 'working', 'waiting'];
+/** The card's share of the content column: three 299s and two 39.5 gaps in 976, which is
+ * the same fraction as three 367s in 1200. One percentage, both authored rows. */
+const CARD_SHARE = 0.306352;
+/** The diagram is the card plus the return wire's band beneath it (271 drawn around 232). */
+const DIAGRAM_RATIO = 271 / 232;
+/** What the stage reserves beyond the card, spent by the introduction on the return band
+ * and by the connection on the 20 + 44 import capsule. */
+const STAGE_EXTRA = 64;
+
const box = async (page: Page, selector: string, index = 0) => {
const rect = await page.locator(selector).nth(index).boundingBox();
if (!rect) throw new Error(`${selector} is not rendered`);
@@ -47,103 +58,199 @@ const boxes = (page: Page, selector: string) =>
const round = (value: number) => Math.round(value * 100) / 100;
const spread = (values: number[]) => Math.max(...values) - Math.min(...values);
+/**
+ * Returns whatever is scrolled to the top, so a measurement is of the LAYOUT rather than of
+ * where a click left the view. A phone composition is taller than the screen, and reaching
+ * the button that advances the step carries the page down with it; comparing two steps'
+ * viewport coordinates across that would compare positions that never coexisted.
+ */
+const toTop = (page: Page) => page.evaluate(() => {
+ document.scrollingElement?.scrollTo(0, 0);
+ for (const node of document.querySelectorAll<HTMLElement>('*')) if (node.scrollTop) node.scrollTop = 0;
+});
+
+/**
+ * The two numbers the whole composition is derived from, read from the page rather than
+ * from the requested viewport: `vw` and `dvh` are the window including its scrollbar,
+ * which is not always the size a test asked for, and the gutter is a band the stylesheet
+ * chooses. Deriving the expectation from these is what makes the checks below a test of
+ * the RULE at whatever size the browser actually produced.
+ */
+async function frame(page: Page) {
+ const window = await page.evaluate(() => {
+ const shell = document.querySelector('.onboarding-shell') as HTMLElement;
+ const content = document.querySelector('.onboarding-shell-content') as HTMLElement;
+ return {
+ vw: globalThis.innerWidth,
+ vh: globalThis.innerHeight,
+ gutter: parseFloat(getComputedStyle(shell).paddingLeft),
+ available: content.getBoundingClientRect().width,
+ };
+ });
+ const clamp = Math.min(Math.max(976, 0.625 * window.vw), 1200);
+ // Stacked, the three cards ARE the composition, so the phone band gives them the height
+ // the reference draws rather than a share of a window that should scroll instead.
+ const stacked = window.vw < 760;
+ return {
+ ...window,
+ column: Math.min(clamp, window.available),
+ card: stacked ? 258 : Math.min(window.vh * 0.3, Math.min(window.available, clamp) * 0.3),
+ stacked,
+ };
+}
+
test.describe('desktop reference geometry', () => {
test.use({ viewport: { width: 1200, height: 800 } });
- test('welcome matches the accepted 1104 collaboration and 802.9 access spans', async ({ page }, info) => {
+ test('the welcome draws the content column, its three card tracks and their handoff gaps', async ({ page }, info) => {
const denied = await serveProduct(page);
await openOnboarding(page);
await freezeAt(page, PHASES['codex-working']);
+ const reference = await frame(page);
+ // The reference's own numbers, reached by the rule at its own frame size: a 976
+ // column of three 299 cards with 39.5 between them. Stated once, here, so a reader
+ // can see that the ratios below are the design and not an arbitrary proportion.
+ expect(round(reference.column)).toBe(976);
+ expect(round(reference.card)).toBe(240);
- const collaboration = await box(page, '.onboarding-collaboration');
- expect(round(collaboration.width)).toBe(1104);
- expect(collaboration.height).toBeCloseTo(341.24, 1);
- // Card size comes from a percentage track and the diagram's own width, so the
- // proportion holds at every width; those ratios are not representable on the
- // engine's 1/64px grid, so the numbers are met to within a sixty-fourth of a pixel.
- for (let index = 0; index < 3; index += 1) {
- const card = await box(page, '.onboarding-collaboration-card', index);
- expect(card.width).toBeCloseTo(301.09, 1);
- expect(card.height).toBeCloseTo(286.04, 1);
- }
- const [first, second, third] = await Promise.all([0, 1, 2].map((index) => box(page, '.onboarding-collaboration-card', index)));
- expect(second.x - (first.x + first.width)).toBeCloseTo(100.36, 1);
- expect(third.x - (second.x + second.width)).toBeCloseTo(100.36, 1);
- // What has to be exact is that the wire endpoints sit on the card edges: both are
- // driven by the same percentage basis, so a port can never drift off its card.
- const port = await box(page, '.onboarding-port', 0);
- expect(port.x + port.width / 2).toBeCloseTo(first.x + first.width, 1);
-
- const access = await box(page, '.onboarding-access');
- expect(access.width).toBeCloseTo(802.91, 1);
- expect(access.x - collaboration.x).toBeCloseTo(150.55, 1);
+ const welcome = await box(page, '.onboarding-welcome');
+ expect(welcome.width).toBeCloseTo(reference.column, 1);
- const action = await box(page, '.onboarding-primary-action');
- expect(round(action.height)).toBe(44);
- expect(action.width).toBeGreaterThanOrEqual(144);
+ const cards = await boxes(page, '.onboarding-collaboration-card');
+ expect(cards).toHaveLength(3);
+ for (const card of cards) {
+ expect(card.width).toBeCloseTo(reference.column * CARD_SHARE, 1);
+ expect(card.height).toBeCloseTo(reference.card, 1);
+ }
+ const gaps = [1, 2].map((index) => cards[index].x - (cards[index - 1].x + cards[index - 1].width));
+ for (const gap of gaps) expect(gap).toBeCloseTo((reference.column - 3 * cards[0].width) / 2, 1);
+ // 39.5, to the tenth: the track is a percentage, so the browser's own rounding of it
+ // lands a hundredth away and a stricter claim would only be testing that.
+ expect(gaps[0]).toBeCloseTo(39.5, 1);
+
+ // The diagram is sized from the card it contains, which is what keeps the handoff
+ // wire on the cards' midline at every window rather than only at the authored one.
+ const collaboration = await box(page, '.onboarding-collaboration');
+ expect(collaboration.width).toBeCloseTo(reference.column, 1);
+ expect(collaboration.height).toBeCloseTo(reference.card * DIAGRAM_RATIO, 1);
+
+ // What has to be exact is that the wire endpoints sit on the card edges: the stretched
+ // viewBox and the card grid answer to the same width, so a port cannot drift off. To
+ // the pixel — a card sized by a percentage has edges on halves, so a tighter claim
+ // would be about which way the browser rounded rather than about where the wire is.
+ const ports = await boxes(page, '.onboarding-port');
+ expect(ports).toHaveLength(4);
+ const onPixel = (value: number, target: number) => expect(Math.abs(value - target)).toBeLessThanOrEqual(1);
+ onPixel(ports[0].x + ports[0].width / 2, cards[0].x + cards[0].width);
+ onPixel(ports[1].x + ports[1].width / 2, cards[1].x);
+ onPixel(ports[2].x + ports[2].width / 2, cards[1].x + cards[1].width);
+ onPixel(ports[3].x + ports[3].width / 2, cards[2].x);
+ // And the handoff runs along the cards' shared midline.
+ const midline = cards[0].y + reference.card * 116 / 232;
+ for (const port of ports) onPixel(port.y + port.height / 2, midline);
await settleEffects(page);
await page.screenshot({ path: info.outputPath('welcome-1200x800-dark-en.png') });
expect(denied).toEqual([]);
});
- // The design stacks the welcome with one rhythm: a 79 tall message block, then 24
- // between every block (frame bi8Au, whose blocks sit at y=65/168/464/648 of its 756
- // content box). The 1104 amendment makes the collaboration taller, so the blocks below
- // it move down by that much and no other number changes.
- test('welcome keeps the design vertical rhythm between its blocks', async ({ page }) => {
+ /**
+ * The reference stacks both steps with one rhythm — heading, 20, stage, 20, action — and
+ * reserves the stage at the card plus 64 in both. That reservation is the whole reason
+ * the two steps' buttons land on the same coordinates, so it is measured directly rather
+ * than inferred from the two steps agreeing.
+ */
+ test('the welcome spends its column on the reference rhythm', async ({ page }) => {
const denied = await serveProduct(page);
await openOnboarding(page);
await freezeAt(page, PHASES['codex-working']);
+ const reference = await frame(page);
const heading = await box(page, '.onboarding-heading');
- // The same type the design specifies: a 34/1.35 title, a 10 gap and a 14/1.57
- // subtitle. The design reports 79 because it rounds each text box up on its own
- // (46 + 10 + 23); the browser stacks the unrounded boxes to 77.9.
- expect(heading.height).toBeCloseTo(78, 1);
-
- const story = await box(page, '.onboarding-story');
- const access = await box(page, '.onboarding-access');
+ const stage = await box(page, '.onboarding-stage');
const action = await box(page, '.onboarding-primary-action');
- expect(story.y - (heading.y + heading.height)).toBeCloseTo(24, 0);
- expect(access.y - (story.y + story.height)).toBeCloseTo(24, 0);
- expect(action.y - (access.y + access.height)).toBeCloseTo(24, 0);
- // The access block's own height is content, not cap: two 42 rows, an 8 gap, the
- // caption and 17 of padding — the design's 160 at any width.
- expect(round(access.height)).toBe(160);
+ const access = await box(page, '.onboarding-access');
+ expect(stage.y - (heading.y + heading.height)).toBeCloseTo(20, 0);
+ expect(action.y - (stage.y + stage.height)).toBeCloseTo(20, 0);
+ expect(stage.height).toBeCloseTo(reference.card + STAGE_EXTRA, 1);
+
+ // The access row is an epilogue under the action, not a block inside the stage: the
+ // connection step has no counterpart to it, and the stage is what the two steps share.
+ expect(access.y).toBeGreaterThan(action.y + action.height);
expect(denied).toEqual([]);
});
- for (const lang of ['en', 'zh']) {
- for (const viewport of [{ width: 1200, height: 800 }, { width: 1200, height: 1200 }, { width: 390, height: 844 }]) {
- test(`Welcome → setup preserves title/subtitle anchors ${lang} ${size(viewport)}`, async ({ page }) => {
- await page.setViewportSize(viewport);
- const denied = await serveProduct(page);
- await openOnboarding(page, { lang });
- const title = await box(page, '.onboarding-heading h1');
- const subtitle = await box(page, '.onboarding-heading p');
- await expect(page.getByRole('img', { name: 'avibe', exact: true })).toBeVisible();
- await openSetup(page, lang);
- const nextTitle = await box(page, '.onboarding-heading h2');
- const nextSubtitle = await box(page, '.onboarding-heading p');
- expect(nextTitle.y).toBeCloseTo(title.y, 0);
- expect(nextSubtitle.y).toBeCloseTo(subtitle.y, 0);
- expect(nextTitle.height).toBeCloseTo(title.height, 0);
- const action = page.locator('.onboarding-setup .onboarding-primary-action');
- await action.scrollIntoViewIfNeeded();
- await expect(action).toBeInViewport();
- expect(denied).toEqual([]);
- });
+ /**
+ * "Align Get started and Enter Workbench at identical coordinates and dimensions,
+ * centered under the Codex column on desktop and as wide as its card."
+ *
+ * Three claims, each measured: the action is the middle card's column, the cards are the
+ * same boxes in both steps, and the action does not move between them. The last one is
+ * what a person actually feels — a button that shifts under a pointer when the screen
+ * changes — so it is asserted as exact box equality, not as a tolerance.
+ */
+ test('both steps put the same action under the same middle card', async ({ page }, info) => {
+ const denied = await serveProduct(page);
+ await openOnboarding(page);
+ await freezeAt(page, PHASES['codex-working']);
+
+ const introCards = await boxes(page, '.onboarding-collaboration-card');
+ const introIdentities = await boxes(page, '.onboarding-card-identity');
+ const introAction = await box(page, '.onboarding-primary-action');
+ const introHeader = await box(page, '.onboarding-shell > header');
+ // Centred on the middle card, and exactly its width.
+ expect(introAction.x).toBeCloseTo(introCards[1].x, 1);
+ expect(introAction.width).toBeCloseTo(introCards[1].width, 1);
+ expect(round(introAction.height)).toBe(52);
+ // The introduction's trailing slot is the assistant's role.
+ await expect(page.locator('.onboarding-card-role')).toHaveCount(3);
+
+ await openSetup(page, 'en');
+ const setupCards = await boxes(page, '.onboarding-assistant');
+ const setupIdentities = await boxes(page, '.onboarding-card-identity');
+ const setupAction = await box(page, '.onboarding-primary-action');
+ const setupHeader = await box(page, '.onboarding-shell > header');
+
+ // The top bar does not move, and neither does the action.
+ expect(setupHeader).toEqual(introHeader);
+ for (const key of ['x', 'y', 'width', 'height'] as const) {
+ expect(round(setupAction[key])).toBeCloseTo(round(introAction[key]), 1);
}
- }
+ // Same three columns, so the cards read as taking on work rather than being replaced.
+ for (let index = 0; index < 3; index += 1) {
+ expect(setupCards[index].x).toBeCloseTo(introCards[index].x, 1);
+ expect(setupCards[index].width).toBeCloseTo(introCards[index].width, 1);
+ expect(setupCards[index].y).toBeCloseTo(introCards[index].y, 1);
+ // The connection's card may grow for an error or a wrapped action; it may not shrink.
+ expect(setupCards[index].height).toBeGreaterThanOrEqual(introCards[index].height - 1);
+ // "The assistant logo and name stay at the top in both states; connection state
+ // replaces roles with enable switches" — the identity header, same offset into the
+ // same card, in both steps.
+ expect(setupIdentities[index].y - setupCards[index].y)
+ .toBeCloseTo(introIdentities[index].y - introCards[index].y, 1);
+ expect(setupIdentities[index].x).toBeCloseTo(introIdentities[index].x, 1);
+ }
+ // …and the trailing slot is now the enable switch, in the header rather than below it.
+ await expect(page.locator('.onboarding-card-identity .onboarding-assistant-enable')).toHaveCount(3);
+ expect(spread(setupIdentities.map((one) => one.y))).toBeLessThanOrEqual(1);
+
+ // The way back is the same object one row down, per the reference.
+ const back = await box(page, '.onboarding-back-action');
+ expect(back.x).toBeCloseTo(setupAction.x, 1);
+ expect(back.width).toBeCloseTo(setupAction.width, 1);
+
+ await settleEffects(page);
+ await page.screenshot({ path: info.outputPath('setup-1200x800-dark-en.png') });
+ expect(denied).toEqual([]);
+ });
/**
- * A short window used to buy about 30px by taking the step gaps from 24 to 16 and
- * squeezing the access block — spending the design's own spacing at 1200x800, the
- * reference's own frame size, where nothing was wrong. Whitespace IS the composition,
- * so the shell scrolls instead and nothing about the type or the controls changes.
+ * A short window used to buy about 30px by taking the step gaps down and squeezing the
+ * access block — spending the design's own spacing at the reference's own frame size,
+ * where nothing was wrong. Whitespace IS the composition, so the card answers to the
+ * window height instead and anything left over scrolls.
*/
- test('a short window scrolls rather than compressing the composition', async ({ page }) => {
+ test('a short window shortens the card rather than the composition', async ({ page }) => {
await serveProduct(page);
await openOnboarding(page);
const metrics = () => page.evaluate(() => {
@@ -152,107 +259,77 @@ test.describe('desktop reference geometry', () => {
const style = node ? getComputedStyle(node) : null;
return style ? `${style.fontSize}/${style.lineHeight}` : 'missing';
};
- const rect = (selector: string) => {
- const found = document.querySelector(selector)?.getBoundingClientRect();
- return found ? `${Math.round(found.width)}x${Math.round(found.height)}` : 'missing';
- };
- return {
- type: [read('.onboarding-heading :is(h1, h2)'), read('.onboarding-heading p'), read('.onboarding-access-tile span')],
- action: [rect('.onboarding-primary-action'), read('.onboarding-primary-action')],
- access: rect('.onboarding-access'),
- };
+ return [read('.onboarding-heading :is(h1, h2)'), read('.onboarding-heading p'),
+ read('.onboarding-access-tile span'), read('.onboarding-primary-action')];
});
const tall = await metrics();
await page.setViewportSize(DESIGN_FRAME);
await freezeAt(page, PHASES['codex-working']);
+ // Type never pays for a short window.
expect(await metrics()).toEqual(tall);
-
+ const reference = await frame(page);
const heading = await box(page, '.onboarding-heading');
- const story = await box(page, '.onboarding-story');
- const access = await box(page, '.onboarding-access');
+ const stage = await box(page, '.onboarding-stage');
const action = await box(page, '.onboarding-primary-action');
- for (const gap of [story.y - (heading.y + heading.height), access.y - (story.y + story.height), action.y - (access.y + access.height)]) {
- expect(gap).toBeCloseTo(24, 0);
- }
- // Scrolling is the accepted outcome, and it has to actually be reachable.
- expect(await page.evaluate(() => document.documentElement.scrollHeight > window.innerHeight
- || (document.querySelector('.onboarding-shell') as HTMLElement).scrollHeight > window.innerHeight)).toBe(true);
- await page.locator('.onboarding-primary-action').scrollIntoViewIfNeeded();
- await expect(page.locator('.onboarding-primary-action')).toBeInViewport();
- });
-
- test('assistant setup keeps the shared width, 88px rows and 12px spacing', async ({ page }, info) => {
- const denied = await serveProduct(page);
- await openOnboarding(page);
- const welcomeTitle = await box(page, '.onboarding-heading :is(h1, h2)');
- await openSetup(page, 'en');
-
- const setupTitle = await box(page, '.onboarding-heading :is(h1, h2)');
- // The title's box is shared between the steps; only its y differs, because only the
- // welcome is centred. Asserting the height keeps the two from drifting apart.
- expect(round(setupTitle.height)).toBe(round(welcomeTitle.height));
-
- const assistants = await box(page, '.onboarding-assistants');
- expect(round(assistants.width)).toBe(1104);
- // The block keeps native sNs1V's 360 slot as a reserved minimum: small content growth
- // — a detection error, an install chip — is absorbed by the slack already there
- // instead of moving the button, and anything larger grows the block naturally.
- expect(await page.locator('.onboarding-assistants').evaluate((node) => getComputedStyle(node).minHeight)).toBe('360px');
- expect(assistants.height).toBeGreaterThanOrEqual(360);
- await expect(page.locator('.onboarding-assistant')).toHaveCount(3);
- for (let index = 0; index < 3; index += 1) {
- const row = await box(page, '.onboarding-assistant', index);
- // Width follows the shared cap; height stays the design's 88 because the row's
- // content fits it, not because a fixed height forces it.
- expect([round(row.width), round(row.height)]).toEqual([1104, 88]);
- // Inside the row nothing was rescaled: a 44 well 20 from the edge, then identity
- // 16 further in, exactly as frame i3vw9 lays every backend row out.
- const logo = await box(page, '.onboarding-assistant-logo', index);
- expect([round(logo.width), round(logo.height)]).toEqual([44, 44]);
- expect(round(logo.x - row.x)).toBe(20);
- expect(round(logo.y - row.y)).toBe(22);
- const identity = await box(page, '.onboarding-assistant-identity', index);
- expect(round(identity.x - row.x)).toBe(80);
- }
- // 12 between the section bar and the first row, and between rows (design pitch 100).
- const header = await box(page, '.onboarding-assistants-header');
- const [firstRow, secondRow] = await Promise.all([0, 1].map((index) => box(page, '.onboarding-assistant', index)));
- expect(firstRow.y - (header.y + header.height)).toBeCloseTo(12, 0);
- expect(round(secondRow.y - firstRow.y)).toBe(100);
- // The setup heading keeps the welcome's 24 to the block below it.
- const setupHeading = await box(page, '.onboarding-heading');
- expect(header.y - (setupHeading.y + setupHeading.height)).toBeCloseTo(24, 0);
- // And the same 24 below the slot, which puts the button 52 under the last row: the
- // slot's own spare height plus that gap. Measuring both is what proves the 52 comes
- // from the 360 slot rather than from a margin someone tuned to match it.
- const footer = await box(page, '.onboarding-setup-footer');
- const lastRow = await box(page, '.onboarding-assistant', 2);
- const cta = await box(page, '.onboarding-primary-action');
- expect(footer.y - (assistants.y + assistants.height)).toBeCloseTo(24, 0);
- expect(cta.y - (lastRow.y + lastRow.height)).toBeCloseTo(52, 0);
-
- await settleEffects(page);
- await page.screenshot({ path: info.outputPath('setup-1200x800-dark-en.png') });
- expect(denied).toEqual([]);
+ expect(stage.y - (heading.y + heading.height)).toBeCloseTo(20, 0);
+ expect(action.y - (stage.y + stage.height)).toBeCloseTo(20, 0);
+ // The card, and the whole composition with it, follows the window: 30% of 756.
+ const card = await box(page, '.onboarding-collaboration-card');
+ expect(card.height).toBeCloseTo(reference.card, 1);
+ expect(round(card.height)).toBe(226.8);
+
+ // And at the reference's own frame the composition then fits it exactly: the card
+ // paying for the window is what removes the scroll, not a shorter gap or smaller type.
+ const overflows = () => page.evaluate(() =>
+ (document.querySelector('.onboarding-shell') as HTMLElement).scrollHeight > globalThis.innerHeight);
+ expect(await overflows()).toBe(false);
+ await expect(page.locator('.onboarding-access')).toBeInViewport();
+
+ // Shorter than the frame it was drawn at, the card keeps paying and the leftover
+ // scrolls — the spacing and the type are never the budget, at any height.
+ await page.setViewportSize({ width: DESIGN_FRAME.width, height: 520 });
+ await freezeAt(page, 0);
+ expect(await metrics()).toEqual(tall);
+ const short = { heading: await box(page, '.onboarding-heading'), stage: await box(page, '.onboarding-stage') };
+ const shortAction = await box(page, '.onboarding-primary-action');
+ expect(short.stage.y - (short.heading.y + short.heading.height)).toBeCloseTo(20, 0);
+ expect(shortAction.y - (short.stage.y + short.stage.height)).toBeCloseTo(20, 0);
+ expect(round((await box(page, '.onboarding-collaboration-card')).height)).toBe(156);
+ expect(await overflows()).toBe(true);
+ await page.locator('.onboarding-access').scrollIntoViewIfNeeded();
+ await expect(page.locator('.onboarding-access')).toBeInViewport();
});
- // The live design sets one headline everywhere: 34/1.35/600 at -1.6 tracking (XKQOx,
- // Igagh and hv9DA all agree), which is tighter than the browser default this shipped
- // with. Both steps read it from the same rule, so both are checked.
- test('both steps use the live design headline tracking', async ({ page }) => {
- await serveProduct(page);
- await openOnboarding(page);
- const type = () => page.evaluate(() => {
- const node = document.querySelector('.onboarding-heading :is(h1, h2)');
- const style = node ? getComputedStyle(node) : null;
- return style ? { size: style.fontSize, tracking: style.letterSpacing, weight: style.fontWeight } : null;
+ /**
+ * The reference's four headline rows are one rule, not four sizes: 32 at 1366, 34 at
+ * 1440, 50 at 1920 and 30 on a phone are all `3.333vw - 14` held between 30 and 50, with
+ * the tracking following the size proportionally so a larger headline is never tighter
+ * than the one drawn. Both steps read it from the same rule, so both are checked.
+ */
+ for (const width of [1920, 1440, 1366, 1200, 390]) {
+ test(`the headline follows the design's own size rule at ${width}`, async ({ page }) => {
+ await page.setViewportSize({ width, height: 900 });
+ await serveProduct(page);
+ await openOnboarding(page);
+ const type = () => page.evaluate(() => {
+ const node = document.querySelector('.onboarding-heading :is(h1, h2)')!;
+ const style = getComputedStyle(node);
+ return {
+ vw: globalThis.innerWidth,
+ size: parseFloat(style.fontSize),
+ tracking: parseFloat(style.letterSpacing),
+ weight: style.fontWeight,
+ };
+ });
+ const intro = await type();
+ expect(intro.size).toBeCloseTo(Math.min(Math.max(30, 3.333 * intro.vw / 100 - 14), 50), 1);
+ expect(intro.tracking / intro.size).toBeCloseTo(-0.047, 3);
+ expect(intro.weight).toBe('600');
+ await openSetup(page, 'en');
+ expect(await type()).toEqual(intro);
});
- const expected = { size: '34px', tracking: '-1.6px', weight: '600' };
- expect(await type()).toEqual(expected);
- await openSetup(page, 'en');
- expect(await type()).toEqual(expected);
- });
+ }
test('every handoff pulse rides the wire that connects its two cards', async ({ page }, info) => {
const denied = await serveProduct(page);
@@ -277,15 +354,30 @@ test.describe('capped fluid width', () => {
const denied = await serveProduct(page);
await openOnboarding(page);
await freezeAt(page, PHASES['codex-working']);
-
- expect(await page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth)).toBe(true);
- const collaboration = await box(page, '.onboarding-collaboration');
- // Capped fluid: never wider than the accepted cap, never wider than the viewport.
- expect(collaboration.width).toBeLessThanOrEqual(1104);
- expect(collaboration.width).toBeLessThanOrEqual(viewport.width);
- const wires = await box(page, '.onboarding-wires');
- // The stretched wire box always covers the cards, so no pulse can detach.
- expect(round(wires.width)).toBe(round(collaboration.width));
+ const reference = await frame(page);
+
+ expect(await page.evaluate(() => document.documentElement.scrollWidth <= globalThis.innerWidth)).toBe(true);
+ // Capped fluid: the rule's own width, never wider than the window's content box.
+ const welcome = await box(page, '.onboarding-welcome');
+ expect(welcome.width).toBeCloseTo(reference.column, 1);
+ expect(welcome.width).toBeLessThanOrEqual(reference.available + 0.5);
+
+ const cards = await boxes(page, '.onboarding-collaboration-card');
+ if (reference.stacked) {
+ // Stacked: one column, and each card the height the reference draws.
+ expect(spread(cards.map((card) => card.x))).toBeLessThanOrEqual(1);
+ for (const card of cards) expect(card.height).toBeGreaterThanOrEqual(reference.card - 1);
+ } else {
+ const collaboration = await box(page, '.onboarding-collaboration');
+ for (const card of cards) {
+ expect(card.width).toBeCloseTo(reference.column * CARD_SHARE, 1);
+ expect(card.height).toBeCloseTo(reference.card, 1);
+ }
+ // The stretched wire box always covers the cards, so no pulse can detach.
+ const wires = await box(page, '.onboarding-wires');
+ expect(round(wires.width)).toBe(round(collaboration.width));
+ expect(collaboration.height).toBeCloseTo(reference.card * DIAGRAM_RATIO, 1);
+ }
// The primary action stays reachable: short viewports scroll rather than clip.
const action = page.locator('.onboarding-primary-action');
@@ -301,62 +393,224 @@ test.describe('capped fluid width', () => {
}
/**
- * The access block is drawn 640 wide on the diagram's own 880 box, so its edges land
- * on the vertical legs of the return wire — the ports at x=120 and x=760. Checking
- * that at the cap alone would pass on a block sized from a fixed number that happens
- * to agree there, so it is checked at every width in between: only a width derived
- * from the diagram's ACTUAL width can hold the relation at all of them.
+ * "Six access points … using circular logo containers, compact spacing and names
+ * underneath", drawn as a centred 560 row. It is the one block here that does not grow
+ * with the window, and deliberately: stretching six destinations to 1200 turns a row of
+ * logos into a rule across the bottom of the page. So the span is checked at widths where
+ * everything else around it is a different size.
*/
- for (const width of [1440, 1200, 1100, 1024, 900, 768]) {
- test(`the access block spans the return wire legs at ${width}`, async ({ page }) => {
+ for (const width of [1920, 1366, 1024, 768]) {
+ test(`the access row is a centred 560 of six circles at ${width}`, async ({ page }) => {
await page.setViewportSize({ width, height: 900 });
await serveProduct(page);
await openOnboarding(page);
- await freezeAt(page, PHASES['codex-working']);
const access = await box(page, '.onboarding-access');
- // PORTS index 5 is the x=120 leg and index 4 the x=760 one; `preserveAspectRatio`
- // is none, so each maps to that share of the rendered width.
- const left = await box(page, '.onboarding-port', 5);
- const right = await box(page, '.onboarding-port', 4);
- expect(access.x).toBeCloseTo(left.x + left.width / 2, 0);
- expect(access.x + access.width).toBeCloseTo(right.x + right.width / 2, 0);
+ const welcome = await box(page, '.onboarding-welcome');
+ expect(round(access.width)).toBe(560);
+ expect(access.x + access.width / 2).toBeCloseTo(welcome.x + welcome.width / 2, 0);
+
+ const tiles = await boxes(page, '.onboarding-access-tile');
+ expect(tiles).toHaveLength(6);
+ // One row, on the 560/6 pitch the tracks produce rather than a gap someone typed.
+ expect(spread(tiles.map((tile) => tile.y))).toBeLessThanOrEqual(1);
+ for (let index = 1; index < tiles.length; index += 1) {
+ expect(tiles[index].x - tiles[index - 1].x).toBeCloseTo(560 / 6, 1);
+ }
+ const icons = await page.locator('.onboarding-access-icon').evaluateAll((nodes) => nodes.map((node) => {
+ const rect = node.getBoundingClientRect();
+ return { width: rect.width, height: rect.height, radius: getComputedStyle(node).borderRadius };
+ }));
+ for (const icon of icons) expect(icon).toEqual({ width: 52, height: 52, radius: '50%' });
});
}
- /**
- * The one documented exception. Two columns of 640/880 of a phone would be about
- * 200px of tiles inside a 360px screen, so below 600 the block takes the full content
- * width and the tiles stay a readable target — deliberately leaving the wire relation
- * rather than following it into an unusable size.
- */
- test('phones take the full content width instead, on purpose', async ({ page }) => {
+ test('phones fold the access row into two rows of three and keep full labels', async ({ page }) => {
await page.setViewportSize({ width: 390, height: 844 });
await serveProduct(page);
await openOnboarding(page);
const access = await box(page, '.onboarding-access');
const welcome = await box(page, '.onboarding-welcome');
+ // Six 52px circles cannot sit on one 350px row, so the fixed span is given up here.
expect(round(access.width)).toBe(round(welcome.width));
- });
- test('access tiles drop to two columns on phones and keep full labels', async ({ page }) => {
- await page.setViewportSize({ width: 390, height: 844 });
- await serveProduct(page);
- await openOnboarding(page);
const tiles = page.locator('.onboarding-access-tile');
await expect(tiles).toHaveCount(6);
- const rects = await tiles.evaluateAll((nodes) => nodes.map((node) => node.getBoundingClientRect().top));
- expect(new Set(rects.map((top) => Math.round(top))).size).toBe(3);
- const labels = await tiles.evaluateAll((nodes) => nodes.map((node) => node.scrollWidth <= node.clientWidth + 1));
+ const rows = await tiles.evaluateAll((nodes) => nodes.map((node) => Math.round(node.getBoundingClientRect().top)));
+ expect(new Set(rows).size).toBe(2);
+ const labels = await page.locator('.onboarding-access-label')
+ .evaluateAll((nodes) => nodes.map((node) => node.scrollWidth <= node.clientWidth + 1));
expect(labels).toEqual([true, true, true, true, true, true]);
});
});
+/**
+ * The reservation, checked where it is hardest rather than only where it was designed.
+ * The action's coordinates are shared by the two steps at every accepted size and in both
+ * languages, which is a claim about the HEADING and the STAGE holding their heights when
+ * the copy, the step and the locale all change under them. A screen-sized tolerance would
+ * make it vacuous, so this is exact box equality.
+ */
+test.describe('shared action anchor', () => {
+ for (const viewport of [
+ { width: 1920, height: 1080 }, { width: 1366, height: 768 }, { width: 1200, height: 800 },
+ { width: 768, height: 1024 }, { width: 390, height: 844 }, { width: 320, height: 568 },
+ ]) {
+ for (const lang of ['en', 'zh'] as const) {
+ test(`${size(viewport)} ${lang} keeps one action anchor across both steps`, async ({ page }) => {
+ await page.setViewportSize(viewport);
+ const denied = await serveProduct(page);
+ await openOnboarding(page, { lang });
+ await toTop(page);
+ const heading = await box(page, '.onboarding-heading');
+ const title = await box(page, '.onboarding-heading h1');
+ const subtitle = await box(page, '.onboarding-heading p');
+ const stage = await box(page, '.onboarding-stage');
+ const action = await box(page, '.onboarding-primary-action');
+ await expect(page.getByRole('img', { name: 'avibe', exact: true })).toBeVisible();
+
+ await openSetup(page, lang);
+ await toTop(page);
+ const nextHeading = await box(page, '.onboarding-heading');
+ const nextTitle = await box(page, '.onboarding-heading h2');
+ const nextSubtitle = await box(page, '.onboarding-heading p');
+ const nextStage = await box(page, '.onboarding-stage');
+ const nextAction = await box(page, '.onboarding-primary-action');
+
+ // The heading block is reserved, so a title that wraps in one step or one language
+ // and not in the other cannot move the stage below it.
+ expect(round(nextHeading.height)).toBeCloseTo(round(heading.height), 1);
+ expect(nextTitle.y).toBeCloseTo(title.y, 0);
+ expect(nextSubtitle.y).toBeCloseTo(subtitle.y, 0);
+ expect(round(nextStage.height)).toBeCloseTo(round(stage.height), 1);
+ for (const key of ['x', 'y', 'width', 'height'] as const) {
+ expect(round(nextAction[key])).toBeCloseTo(round(action[key]), 1);
+ }
+ await page.locator('.onboarding-primary-action').scrollIntoViewIfNeeded();
+ await expect(page.locator('.onboarding-primary-action')).toBeInViewport();
+ expect(denied).toEqual([]);
+ });
+ }
+ }
+});
+
+/**
+ * The import offer. Everything about WHICH keys it counts is a component-level rule and is
+ * tested there; what only a browser can show is that the capsule is an aside rather than a
+ * banner, that refusing it does not move the button underneath, and that its help text can
+ * actually be reached by a pointer, a keyboard and a finger.
+ */
+test.describe('import capsule', () => {
+ test('is a centred capsule whose dismissal leaves the action where it was', async ({ page }, info) => {
+ await page.setViewportSize({ width: 1200, height: 800 });
+ const denied = await serveProduct(page);
+ await serveModelHub(page);
+ await openOnboarding(page, { lang: 'zh' });
+ await openSetup(page, 'zh');
+
+ const notice = page.locator('.onboarding-import-notice');
+ // Three importable keys among five scanned rows: the two native subscription tokens
+ // are the settings migration's business, never this entry's.
+ await expect(notice).toHaveText(/发现 3 个可导入模型网关的 API Key/);
+
+ const capsule = await box(page, '.onboarding-import-notice');
+ const cards = await box(page, '.onboarding-assistants');
+ const action = await box(page, '.onboarding-primary-action');
+ expect(round(capsule.height)).toBe(44);
+ // Content width, centred under the cards — not a full-width banner.
+ expect(capsule.width).toBeLessThan(cards.width);
+ expect(capsule.x + capsule.width / 2).toBeCloseTo(cards.x + cards.width / 2, 0);
+ expect(capsule.y - (cards.y + cards.height)).toBeCloseTo(20, 0);
+ expect(action.y - (capsule.y + capsule.height)).toBeCloseTo(20, 0);
+ expect(await page.locator('.onboarding-import-notice').evaluate((node) => getComputedStyle(node).boxShadow)).toBe('none');
+
+ await settleEffects(page);
+ await page.screenshot({ path: info.outputPath('import-capsule-1200x800-dark-zh.png') });
+
+ // The layout space is reserved, so refusing the offer moves nothing.
+ await page.getByRole('button', { name: '关闭导入提示' }).click();
+ await expect(notice).toHaveCount(0);
+ const after = await box(page, '.onboarding-primary-action');
+ expect(round(after.y)).toBe(round(action.y));
+ expect(round(after.x)).toBe(round(action.x));
+ expect(denied).toEqual([]);
+ });
+
+ test('phones put the offer and its refusal on one line and the actions on the next', async ({ page }, info) => {
+ await page.setViewportSize({ width: 390, height: 844 });
+ await serveProduct(page);
+ await serveModelHub(page);
+ await openOnboarding(page, { lang: 'zh' });
+ await openSetup(page, 'zh');
+
+ const text = await box(page, '.onboarding-import-notice-text');
+ const dismiss = await box(page, '.onboarding-import-notice-dismiss');
+ const actions = await box(page, '.onboarding-import-notice-actions');
+ expect(dismiss.y).toBeCloseTo(text.y + text.height / 2 - dismiss.height / 2, 0);
+ expect(actions.y).toBeGreaterThanOrEqual(text.y + text.height);
+ // The full Chinese sentence at the verified width: wrapped if it must be, never cut.
+ const intact = await page.locator('.onboarding-import-notice-text')
+ .evaluate((node) => node.scrollWidth <= node.clientWidth + 1 && getComputedStyle(node).textOverflow !== 'ellipsis');
+ expect(intact).toBe(true);
+ expect(await page.evaluate(() => document.documentElement.scrollWidth <= globalThis.innerWidth)).toBe(true);
+ await settleEffects(page);
+ await page.screenshot({ path: info.outputPath('import-capsule-390x844-dark-zh.png') });
+ });
+
+ // A real touch context, because the whole point of the hint's pointer handling is that
+ // a finger and a mouse arrive differently: Chromium only reports `pointerType: 'touch'`
+ // when the context actually has a touchscreen, so a synthetic event could not show that
+ // a tap produces one clean toggle instead of hover-open-then-click-closed.
+ test.describe(() => {
+ test.use({ hasTouch: true });
+
+ test('the help text opens on hover, on focus and on tap, and closes on Escape or outside', async ({ page }) => {
+ await page.setViewportSize({ width: 1200, height: 800 });
+ await serveProduct(page);
+ await serveModelHub(page);
+ await openOnboarding(page, { lang: 'zh' });
+ await openSetup(page, 'zh');
+
+ const help = page.getByRole('button', { name: '什么是模型网关?' });
+ const body = page.getByText(/模型网关集中管理 API Key 和模型连接/);
+
+ // Pointer: the panel is portalled, so it must survive the trip from trigger to panel.
+ await help.hover();
+ await expect(body).toBeVisible();
+ await body.hover();
+ await expect(body).toBeVisible();
+ await page.mouse.move(10, 10);
+ // Leaving defers the close by 120ms, which is exactly what let the pointer make
+ // the trip above. The fixture's clock is frozen, so that delay has to be spent.
+ await expect(body).toBeVisible();
+ await page.clock.runFor(200);
+ await expect(body).toBeHidden();
+
+ // Keyboard: focus reveals it and Escape takes it back, without trapping the tab order.
+ await help.focus();
+ await expect(body).toBeVisible();
+ await page.keyboard.press('Escape');
+ await expect(body).toBeHidden();
+ await expect(help).toBeFocused();
+
+ // Touch: one clean toggle, and a tap elsewhere dismisses it.
+ const target = (await help.boundingBox())!;
+ await page.touchscreen.tap(target.x + target.width / 2, target.y + target.height / 2);
+ await expect(body).toBeVisible();
+ // The dismissable layer arms its outside listener in a zero-delay timeout, which a
+ // frozen clock never reaches. Spending it is the fixture's business, not a wait.
+ await page.clock.runFor(50);
+ await page.touchscreen.tap(8, 400);
+ await expect(body).toBeHidden();
+ });
+ });
+});
+
/**
* Narrow widths are where a card stops being a scaled copy of the design and becomes an
- * adaptation, so the thing to check is that the adaptation is ONE arrangement rather
- * than whichever one each label's length happens to produce. Every assertion here reads
- * real bounding boxes: three status rows that start and end together, three identities
+ * adaptation, so the thing to check is that the adaptation is ONE arrangement rather than
+ * whichever one each label's length happens to produce. Every assertion here reads real
+ * bounding boxes: three identity headers that start and end together, three status rows
* that do, and no label clipped or truncated to make that true.
*/
test.describe('narrow identity alignment', () => {
@@ -379,37 +633,43 @@ test.describe('narrow identity alignment', () => {
// freezeAt advances the clock; these phase offsets are absolute.
await freezeAt(page, elapsed - previous);
previous = elapsed;
+ const identities = await boxes(page, '.onboarding-card-identity');
const statuses = await boxes(page, '.onboarding-story-status');
const skeletons = await boxes(page, '.onboarding-skeleton');
- const identities = await boxes(page, '.onboarding-story-identity');
const cards = await boxes(page, '.onboarding-collaboration-card');
- expect([statuses.length, identities.length]).toEqual([3, 3]);
- // The header and footer boundaries belong to the row, not to whichever
- // caption happens to be short enough at this point in the animation.
- for (const row of [statuses, skeletons, identities]) {
- expect(spread(row.map((one) => one.y))).toBeLessThanOrEqual(1);
+ expect([identities.length, statuses.length, skeletons.length]).toEqual([3, 3, 3]);
+ // The header and status boundaries belong to the arrangement, not to whichever
+ // caption happens to be short enough at this point in the animation. Below 760
+ // the three cards stack, so the boundary they share is the offset INSIDE the
+ // card: the same claim, and on one row the same measurement.
+ for (const row of [identities, statuses, skeletons]) {
+ expect(spread(row.map((one, index) => one.y - cards[index].y))).toBeLessThanOrEqual(1);
expect(spread(row.map((one) => one.height))).toBeLessThanOrEqual(1);
}
+ // Side by side, that offset is also one screen row; stacked, it cannot be.
+ expect(spread(cards.map((card) => card.y)) <= 1).toBe(viewport.width >= 760);
for (let index = 0; index < cards.length; index++) {
- for (const row of [statuses, skeletons, identities]) {
+ for (const row of [identities, statuses, skeletons]) {
expect(row[index].x).toBeGreaterThanOrEqual(cards[index].x);
expect(row[index].x + row[index].width).toBeLessThanOrEqual(cards[index].x + cards[index].width);
}
expect(skeletons[index].height).toBeGreaterThan(0);
+ // Identity first, then the status line, then the work — in both steps.
+ expect(identities[index].y).toBeGreaterThanOrEqual(cards[index].y - 1);
+ expect(identities[index].y + identities[index].height).toBeLessThanOrEqual(statuses[index].y + 1);
expect(statuses[index].y + statuses[index].height).toBeLessThanOrEqual(skeletons[index].y + 1);
- expect(skeletons[index].y + skeletons[index].height).toBeLessThanOrEqual(identities[index].y + 1);
- expect(identities[index].y + identities[index].height).toBeLessThanOrEqual(cards[index].y + cards[index].height);
+ expect(skeletons[index].y + skeletons[index].height).toBeLessThanOrEqual(cards[index].y + cards[index].height + 1);
}
- // Equal rows must not be bought with clipping, truncation or overflow
- // into an adjacent row/card. Check the actual visible label boxes.
+ // Equal rows must not be bought with clipping, truncation or overflow into an
+ // adjacent row/card. Check the actual visible label boxes.
const clipped = await page.locator(
- '.onboarding-story-identity strong, .onboarding-story-identity > span:last-child, .onboarding-status-text',
+ '.onboarding-card-name, .onboarding-card-role, .onboarding-status-text',
).evaluateAll((nodes) => nodes
.filter((node) => {
const style = getComputedStyle(node);
const label = node.getBoundingClientRect();
- const row = node.closest('.onboarding-story-status, .onboarding-story-identity')!.getBoundingClientRect();
+ const row = node.closest('.onboarding-card-identity, .onboarding-story-status')!.getBoundingClientRect();
return node.scrollWidth > node.clientWidth + 1
|| node.scrollHeight > node.clientHeight + 1
|| style.textOverflow === 'ellipsis'
@@ -421,9 +681,9 @@ test.describe('narrow identity alignment', () => {
});
}
// …and the labels are still the product's own words at a readable size.
- const names = await page.locator('.onboarding-story-identity strong').allInnerTexts();
+ const names = await page.locator('.onboarding-card-name').allInnerTexts();
expect(names.map((name) => name.replace(/\s+/g, ' ').trim())).toEqual(['Claude Code', 'Codex', 'OpenCode']);
- const smallest = await page.locator('.onboarding-story-identity > span:last-child')
+ const smallest = await page.locator('.onboarding-card-role')
.evaluateAll((nodes) => Math.min(...nodes.map((node) => parseFloat(getComputedStyle(node).fontSize))));
expect(smallest).toBeGreaterThanOrEqual(10);
@@ -525,7 +785,7 @@ test.describe('motion lifecycle', () => {
scroller.scrollTop += amount;
}, delta);
- await page.locator('.onboarding-primary-action').scrollIntoViewIfNeeded();
+ await page.locator('.onboarding-access').scrollIntoViewIfNeeded();
expect((await rect()).bottom).toBeLessThanOrEqual(0);
expect(await page.evaluate(() => document.hidden)).toBe(false);
await expect(diagram).toHaveAttribute('data-motion', 'paused');
@@ -652,6 +912,7 @@ test.describe('capture', () => {
test(`${size(viewport)} ${theme} ${lang}`, async ({ page }, info) => {
await page.setViewportSize(viewport);
await serveProduct(page);
+ await serveModelHub(page);
await openOnboarding(page, { lang, theme });
await freezeAt(page, PHASES[CAPTURE_PHASE]);
expect((await renderedPhase(page)).states).toEqual(CAPTURE_STATES);
@@ -665,23 +926,20 @@ test.describe('capture', () => {
}
}
- // The design's own content box, for overlaying an exported frame at 1:1. This still is
- // a VIEWPORT CROP, not the whole composition: at 756 the primary action sits below the
- // fold, which is the accepted outcome rather than a layout the product should shrink to
- // fit. The companion below shows it scrolled to, so the pair covers what one cannot.
+ // The design's own content box, for overlaying an exported frame at 1:1. A viewport crop
+ // is the whole composition here — both steps end inside 756 with nothing cut off — so
+ // these stills are directly comparable to the exported frames and not a partial view.
test('design frame content box', async ({ page }, info) => {
await page.setViewportSize(DESIGN_FRAME);
await serveProduct(page);
await openOnboarding(page);
await freezeAt(page, PHASES[CAPTURE_PHASE]);
expect((await renderedPhase(page)).states).toEqual(CAPTURE_STATES);
+ await expect(page.locator('.onboarding-access')).toBeInViewport({ ratio: 1 });
await settleEffects(page);
await page.screenshot({ path: info.outputPath(`welcome-design-frame-1200x756-${CAPTURE_PHASE}.png`) });
- await page.locator('.onboarding-primary-action').scrollIntoViewIfNeeded();
- await expect(page.locator('.onboarding-primary-action')).toBeInViewport();
- await settleEffects(page);
- await page.screenshot({ path: info.outputPath(`welcome-design-frame-1200x756-cta-${CAPTURE_PHASE}.png`) });
await openSetup(page, 'en');
+ await expect(page.locator('.onboarding-primary-action')).toBeInViewport({ ratio: 1 });
await settleEffects(page);
await page.screenshot({ path: info.outputPath('setup-design-frame-1200x756.png') });
});
diff --git a/ui/e2e/onboarding-fidelity/support.ts b/ui/e2e/onboarding-fidelity/support.ts
index 2321c0dbc..97ee3aa65 100644
--- a/ui/e2e/onboarding-fidelity/support.ts
+++ b/ui/e2e/onboarding-fidelity/support.ts
@@ -13,12 +13,21 @@ export const PHASES = {
'pm-summary': 8000,
} as const;
+/**
+ * The accepted responsive matrix, plus the two widths between its rows that the
+ * composition actually changes at. 1920 and 1440 are the wide desktop that takes the
+ * 1200 content box; 1366 and 1200 are the standard desktop on 976; 1024 and 768 are
+ * where the diagram stops following its proportion; 390, 375 and 320 are the phones.
+ */
export const VIEWPORTS = [
- { width: 1200, height: 800 },
+ { width: 1920, height: 1080 },
{ width: 1440, height: 900 },
+ { width: 1366, height: 768 },
+ { width: 1200, height: 800 },
{ width: 1024, height: 768 },
{ width: 768, height: 1024 },
{ width: 390, height: 844 },
+ { width: 375, height: 812 },
{ width: 320, height: 568 },
] as const;
@@ -205,3 +214,46 @@ export async function openSetup(page: Page, lang: string) {
await page.getByRole('button', { name: lang === 'zh' ? '开始使用' : 'Get started' }).click();
await page.locator('.onboarding-assistants').waitFor();
}
+
+/**
+ * The two shapes a migration scan really returns. Three credentials the gateway can
+ * take over, and two native subscription tokens it must leave where they are — the
+ * setup notice counts only the first kind, so a fixture without the second could not
+ * show that it does. The detail strings are the server's own masked form, Chinese
+ * included, because that is what the capsule has to stay one line tall around.
+ */
+export const MIGRATION_KEYS = [
+ { id: 'claude-key', backend: 'claude', kind: 'api_key', masked_detail: 'sk-ant-…4f2a + 自定义 Base URL', proposed_action: 'import', selected: true, vendor: 'anthropic', display_name: 'Anthropic', masked_credential: 'sk-ant-…4f2a' },
+ { id: 'codex-key', backend: 'codex', kind: 'api_key', masked_detail: 'sk-…9d31', proposed_action: 'import', selected: true, vendor: 'openai', display_name: 'OpenAI', masked_credential: 'sk-…9d31' },
+ { id: 'opencode-qwen', backend: 'opencode', kind: 'opencode_provider', masked_detail: 'sk-…7c08 · 阿里云百炼', proposed_action: 'import', selected: true, vendor: 'qwen', display_name: 'alibaba-cn', masked_credential: 'sk-…7c08' },
+] as const;
+export const MIGRATION_NATIVE = [
+ { id: 'claude-oauth', backend: 'claude', kind: 'oauth_native', masked_detail: 'Claude 订阅令牌', proposed_action: 'keep_native', selected: false },
+ { id: 'codex-oauth', backend: 'codex', kind: 'oauth_native', masked_detail: 'ChatGPT 订阅令牌', proposed_action: 'keep_native', selected: false },
+] as const;
+
+/**
+ * Turns the Model Gateway capability on and answers its migration scan, so the setup
+ * step draws the API-key import offer. Call it AFTER `serveProduct`: Playwright matches
+ * routes newest-first, which is what lets this override that fixture's `/api/config`
+ * and answer the scan POST the catch-all would otherwise refuse.
+ */
+export async function serveModelHub(page: Page) {
+ const applied: string[][] = [];
+ let items = [...MIGRATION_KEYS, ...MIGRATION_NATIVE] as { id: string }[];
+ // The scan is a POST, so the product asks for a CSRF token before issuing it. The
+ // base fixture refuses every write and everything that enables one, which is what
+ // keeps a capture honest; an opt-in write surface has to answer this itself.
+ await page.route('**/api/csrf-token', (route) => route.fulfill({ json: { csrf_token: 'fixture-token' } }));
+ await page.route('**/api/config', (route) =>
+ route.fulfill({ json: { ...CONFIG, capabilities: { model_hub: { enabled: true } } } }),
+ );
+ await page.route('**/api/models/migration/scan', (route) => route.fulfill({ json: { scan: { items } } }));
+ await page.route('**/api/models/migration/apply', (route) => {
+ const ids: string[] = JSON.parse(route.request().postData() || '{}').item_ids ?? [];
+ applied.push(ids);
+ items = items.filter((item) => !ids.includes(item.id));
+ return route.fulfill({ json: { applied: ids.length, sources: [] } });
+ });
+ return applied;
+}
diff --git a/ui/src/components/onboarding/AccessTiles.tsx b/ui/src/components/onboarding/AccessTiles.tsx
index 5a71c9064..05fa2fe1a 100644
--- a/ui/src/components/onboarding/AccessTiles.tsx
+++ b/ui/src/components/onboarding/AccessTiles.tsx
@@ -30,9 +30,14 @@ export function AccessTiles() {
<ul className="onboarding-access-grid" onPointerEnter={() => setPointerInside(true)} onPointerLeave={() => setPointerInside(false)}
onFocus={() => setFocusInside(true)} onBlur={(event) => { if (!event.currentTarget.contains(event.relatedTarget)) setFocusInside(false); }}>
{PLATFORMS.map((platform, index) => (
- <li key={platform} tabIndex={0} className="onboarding-access-tile" data-emphasis={automatic && emphasis === index}>
- <span className="onboarding-access-icon"><PlatformIcon platform={platform} size={22} aria-hidden="true" /></span>
- <span>{t(`onboarding.access.${platform}`)}</span>
+ // `data-connects` is what the mint emphasis is keyed on. The five chat
+ // platforms are the ones Avibe connects *to*; the mobile app is Avibe
+ // itself, so it lifts on hover like the rest but is never lit up as a
+ // connection the user still has to make.
+ <li key={platform} tabIndex={0} className="onboarding-access-tile"
+ data-connects={platform !== 'avibe'} data-emphasis={automatic && emphasis === index}>
+ <span className="onboarding-access-icon"><PlatformIcon platform={platform} size={26} aria-hidden="true" /></span>
+ <span className="onboarding-access-label">{t(`onboarding.access.${platform}`)}</span>
</li>
))}
</ul>
diff --git a/ui/src/components/onboarding/AssistantRow.tsx b/ui/src/components/onboarding/AssistantRow.tsx
index 3844a60c2..6b2a65752 100644
--- a/ui/src/components/onboarding/AssistantRow.tsx
+++ b/ui/src/components/onboarding/AssistantRow.tsx
@@ -28,29 +28,47 @@ export interface AssistantRowProps {
connection?: 'subscription' | 'api_key';
}
+/**
+ * One assistant, drawn as the card the welcome already showed it in.
+ *
+ * The frame, the column it sits in and the identity header at its top are the story
+ * card's, from the same classes; only the body under them changes. The reference says
+ * it directly — "the assistant logo and name stay at the top in both states; connection
+ * state replaces roles with enable switches" — so this card reuses that header and puts
+ * its switch in the slot the story fills with a role. Moving from the intro to the
+ * connection therefore reads as the cards taking on work rather than as one screen
+ * being swapped for another. `geometry.spec.ts` holds both steps to the same boxes,
+ * which is what keeps that true as either step changes.
+ */
export function AssistantRow({ backend, status, installing, detecting, error, lifecycle, enabledControl,
onInstall, onDetect, onConfigure, configuringDisabled = false, connection, onAddKey, onRefreshConnection, connectionPending, connectionError }: AssistantRowProps) {
const { t } = useTranslation();
const label = getBackendUiMeta(backend).label;
return (
<Card className="onboarding-assistant" aria-label={label}>
- <div className="onboarding-assistant-main">
- <div className="onboarding-assistant-logo"><BackendIcon backend={backend} variant="brand" brandFit="mark" size={28} aria-hidden="true" /></div>
- <div className="onboarding-assistant-identity">
- <h3>{label}</h3>
- <p title={t(`onboarding.setup.${backend}Description`)}>{t(connection ? `onboarding.setup.${connection}` : `onboarding.setup.${backend}Description`)}</p>
- </div>
- <div className="onboarding-assistant-status">
- {installing || detecting || status === 'unknown' ? (
- <Badge variant="secondary"><RefreshCw size={12} className={installing || detecting ? 'motion-safe:animate-spin' : ''} />
- {t(installing ? 'agentDetection.installing' : detecting ? 'onboarding.welcome.detecting' : 'common.notChecked')}
- </Badge>
- ) : status === 'ok' ? lifecycle : (
- <Badge variant={error ? 'destructive' : 'secondary'}><span className="size-2 rounded-full bg-current" />
- {t(error ? 'onboarding.setup.installFailed' : 'onboarding.setup.notInstalled')}
- </Badge>
- )}
- </div>
+ <div className="onboarding-card-identity">
+ <BackendIcon backend={backend} size={28} variant="brand" aria-hidden="true" />
+ {/* A heading here and a `strong` on the welcome: the setup's three cards are
+ a real document structure a person navigates, the welcome's are an
+ illustration the card already labels. Same class, so same geometry. */}
+ <h3 className="onboarding-card-name">{label}</h3>
+ <div className="onboarding-assistant-enable">{enabledControl}</div>
+ </div>
+ <div className="onboarding-assistant-state">
+ {installing || detecting || status === 'unknown' ? (
+ <Badge variant="secondary"><RefreshCw size={12} className={installing || detecting ? 'motion-safe:animate-spin' : ''} />
+ {t(installing ? 'agentDetection.installing' : detecting ? 'onboarding.welcome.detecting' : 'common.notChecked')}
+ </Badge>
+ ) : status === 'ok' ? lifecycle : (
+ <Badge variant={error ? 'destructive' : 'secondary'}><span className="size-2 rounded-full bg-current" />
+ {t(error ? 'onboarding.setup.installFailed' : 'onboarding.setup.notInstalled')}
+ </Badge>
+ )}
+ </div>
+ <div className="onboarding-assistant-body">
+ <p className="onboarding-assistant-note" title={t(`onboarding.setup.${backend}Description`)}>
+ {t(connection ? `onboarding.setup.${connection}` : `onboarding.setup.${backend}Description`)}
+ </p>
<div className="onboarding-assistant-actions">
{status === 'missing' && <Button variant="secondary" size="sm" className="h-[34px]" onClick={onInstall} disabled={installing || detecting}>
{installing ? <RefreshCw size={14} className="motion-safe:animate-spin" /> : <Download size={14} />}
@@ -62,17 +80,16 @@ export function AssistantRow({ backend, status, installing, detecting, error, li
{t(connection ? `onboarding.setup.${connection}Connected` : 'onboarding.connection.addSubscription')}
</Button>
{!connection && onAddKey && <Button variant="secondary" size="sm" className="h-[34px]" onClick={onAddKey} disabled={configuringDisabled || installing || detecting}>{t('onboarding.connection.addKey')}</Button>}
- {enabledControl}
</div>
+ {(connectionError || connectionPending) && <div className="onboarding-assistant-error" role={connectionError ? 'alert' : 'status'}>
+ {connectionPending ? t('common.loading') : connectionError}
+ {!connectionPending && onRefreshConnection && <Button variant="link" size="xs" onClick={onRefreshConnection}>{t('common.retry')}</Button>}
+ </div>}
+ {error && <div className="onboarding-assistant-error" role="alert">
+ <p>{error.message}</p>
+ {error.output && <details><summary>{t('onboarding.details')}</summary><pre>{error.output}</pre></details>}
+ </div>}
</div>
- {(connectionError || connectionPending) && <div className="onboarding-assistant-error" role={connectionError ? 'alert' : 'status'}>
- {connectionPending ? t('common.loading') : connectionError}
- {!connectionPending && onRefreshConnection && <Button variant="link" size="xs" onClick={onRefreshConnection}>{t('common.retry')}</Button>}
- </div>}
- {error && <div className="onboarding-assistant-error" role="alert">
- <p>{error.message}</p>
- {error.output && <details><summary>{t('onboarding.details')}</summary><pre>{error.output}</pre></details>}
- </div>}
</Card>
);
}
diff --git a/ui/src/components/onboarding/AssistantSetup.test.tsx b/ui/src/components/onboarding/AssistantSetup.test.tsx
index e7e7a6fe3..6bcdb927b 100644
--- a/ui/src/components/onboarding/AssistantSetup.test.tsx
+++ b/ui/src/components/onboarding/AssistantSetup.test.tsx
@@ -42,7 +42,15 @@ describe('assistant installation presentation', () => {
? new Promise((resolve) => { finishClaude = resolve; })
: Promise.resolve({ ok: true, path: '/isolated/bin/codex' }));
render(wrap(<AgentDetection data={data()} onNext={vi.fn()} />));
- expect(screen.getAllByRole('heading', { level: 3 }).map((node) => node.textContent)).toEqual(['AI assistants', 'Claude Code', 'Codex', 'OpenCode']);
+ // The three cards are the whole section: the design keeps each assistant's name at
+ // the top of its own card and gives the section no heading of its own.
+ expect(screen.getAllByRole('heading', { level: 3 }).map((node) => node.textContent)).toEqual(['Claude Code', 'Codex', 'OpenCode']);
+ // "Connection state replaces roles with enable switches": the switch belongs to the
+ // same identity header as the name, not to a separate strip.
+ for (const name of ['Claude Code', 'Codex', 'OpenCode']) {
+ const identity = screen.getByRole('heading', { name }).closest('.onboarding-card-identity')!;
+ expect(within(identity as HTMLElement).getByRole('checkbox', { name: 'Enabled' })).toBeTruthy();
+ }
fireEvent.click(row('Claude Code').getByRole('button', { name: 'Install' }));
fireEvent.click(row('Codex').getByRole('button', { name: 'Install' }));
await waitFor(() => expect(row('Codex').getByRole('button', { name: 'Installed' })).toBeTruthy());
diff --git a/ui/src/components/onboarding/BackendConnection.test.tsx b/ui/src/components/onboarding/BackendConnection.test.tsx
index 38628f279..3654e67e8 100644
--- a/ui/src/components/onboarding/BackendConnection.test.tsx
+++ b/ui/src/components/onboarding/BackendConnection.test.tsx
@@ -539,3 +539,127 @@ describe('shared Settings and onboarding connection owner', () => {
});
});
+
+// What a fixed frame means in behavior rather than in pixels: the parts that
+// anchor it must not be able to say anything that depends on what is inside it.
+// jsdom has no layout, so these hold the cause — a heading, a description and a
+// footer that are the same strings before and after every method change — and
+// `geometry.spec.ts` holds the resulting geometry in a real browser.
+describe('connection dialog frame', () => {
+ const frame = () => {
+ const dialog = screen.getByRole('dialog');
+ return {
+ title: within(dialog).getByRole('heading', { level: 2 }).textContent,
+ description: dialog.querySelector('.connection-description')?.textContent,
+ // The regions the grid anchors, by the classes `connection.css` places.
+ rows: ['.connection-heading', '.connection-description', '.connection-actions']
+ .map((selector) => dialog.querySelectorAll(selector).length),
+ };
+ };
+ it.each(['claude', 'codex'] as const)('%s keeps one heading, description and footer across every method switch', async (backend) => {
+ mock.api.getBackendConnection.mockResolvedValue(connection({ backend, auth: 'none', ready: false, entry_eligible: false }));
+ render(wrap(<BackendConnectionDialog backend={backend} method="oauth" onConnected={vi.fn()} onClose={vi.fn()} onWriteState={vi.fn()} />));
+ await screen.findByRole('radiogroup', { name: en.onboarding.connection.method });
+ const opened = frame();
+ expect(opened.title).toBe(`Connect ${backend === 'claude' ? 'Claude Code' : 'Codex'}`);
+ expect(opened.rows).toEqual([1, 1, 1]);
+
+ const tabs = screen.getAllByRole('radio');
+ // Repeatedly, both directions: a heading computed from the method would
+ // change here, and a changed heading is what used to move the frame.
+ for (const tab of [...tabs].reverse().concat(tabs, [...tabs].reverse(), tabs)) {
+ fireEvent.click(tab);
+ expect(frame()).toEqual(opened);
+ }
+ // The method still actually changed the body underneath the fixed frame.
+ fireEvent.click(screen.getByRole('radio', { name: backend === 'claude' ? en.onboarding.connection.claudeCredentials : en.onboarding.connection.openaiKey }));
+ // `find`, not `get`: the dialog's own readiness read resolves on its own schedule and
+ // re-renders the body, so the credential form is not guaranteed on the click's tick.
+ expect(await screen.findByRole('button', { name: en.onboarding.connection.saveConnect })).toBeTruthy();
+ expect(frame()).toEqual(opened);
+ });
+
+ it('moves the method with arrows, Home and End, and leaves focus on the selected tab', async () => {
+ mock.api.getBackendConnection.mockResolvedValue(connection({ backend: 'claude', auth: 'none', ready: false, entry_eligible: false }));
+ render(wrap(<BackendConnectionDialog backend="claude" method="oauth" onConnected={vi.fn()} onClose={vi.fn()} onWriteState={vi.fn()} />));
+ const group = await screen.findByRole('radiogroup', { name: en.onboarding.connection.method });
+ const [subscription, apiKey] = screen.getAllByRole('radio');
+ expect(subscription.getAttribute('aria-checked')).toBe('true');
+ // One tab stop, so Tab lands on the selection the arrows then continue from — the
+ // other half of the pattern, and what stops focus resting on an unselected tab.
+ expect([subscription.tabIndex, apiKey.tabIndex]).toEqual([0, -1]);
+ for (const [key, expected] of [['ArrowRight', apiKey], ['ArrowLeft', subscription], ['End', apiKey], ['Home', subscription]] as const) {
+ fireEvent.keyDown(group, { key });
+ expect(expected.getAttribute('aria-checked')).toBe('true');
+ expect(document.activeElement).toBe(expected);
+ expect([subscription.tabIndex, apiKey.tabIndex]).toEqual(expected === subscription ? [0, -1] : [-1, 0]);
+ }
+ // A key the group does not own is left to the dialog (Escape closes it).
+ fireEvent.keyDown(group, { key: 'Escape' });
+ expect(subscription.getAttribute('aria-checked')).toBe('true');
+ });
+
+ it('offers the eight setup providers first, keeps a configured one out of More, and lets search reach the rest', async () => {
+ const entry = (id: string, name: string, patch: Partial<{ configured: boolean; models: string[] }> = {}) =>
+ ({ id, name, description: '', configured: false, oauth_available: false, local: false, models: [], ...patch });
+ mock.api.getOpencodeProviders.mockResolvedValue({ ok: true, providers: [
+ // `alibaba-cn`, `moonshot` and `google` arrive as bare ids — the case the
+ // brand table exists for. `mistral` arrives with a real name of its own.
+ entry('mistral', 'Mistral AI'), entry('openrouter', 'OpenRouter'), entry('alibaba-cn', 'alibaba-cn', { configured: true }),
+ entry('openai', 'OpenAI'), entry('moonshot', 'moonshot'), entry('google', 'google'),
+ entry('deepseek', 'DeepSeek'), entry('anthropic', 'Anthropic'), entry('xai', 'xAI'),
+ entry('cerebras', 'Cerebras', { configured: true }), entry('groq', 'Groq', { models: ['llama-3.3-70b'] }),
+ entry('ollama', 'Ollama local', { configured: false }),
+ ] });
+ mock.api.getBackendConnection.mockResolvedValue(connection({ backend: 'opencode', auth: 'none', ready: false, entry_eligible: false }));
+ render(wrap(<BackendConnectionDialog backend="opencode" method="api_key" onConnected={vi.fn()} onClose={vi.fn()} onWriteState={vi.fn()} />));
+
+ const names = () => screen.getAllByRole('button').map((node) => node.querySelector('strong')?.textContent).filter(Boolean);
+ await waitFor(() => expect(names().length).toBeGreaterThan(0));
+ // The ratified default order, by friendly name rather than by the internal
+ // id: `google`, `moonshot` and `alibaba-cn` are not what anyone calls them.
+ expect(names().slice(0, 8)).toEqual(['OpenAI', 'Anthropic', 'xAI', 'Gemini', 'DeepSeek', 'Qwen', 'Kimi', 'OpenRouter']);
+ // A configured provider outside the eight stays reachable without More.
+ expect(names()).toContain('Cerebras');
+ expect(names()).not.toContain('Mistral AI');
+ // The id it is filed under stays on the row, next to the brand name.
+ expect(screen.getByRole('button', { name: /Qwen/ }).textContent).toContain('alibaba-cn');
+
+ fireEvent.click(screen.getByRole('button', { name: /More providers \(3\)/ }));
+ // A server that already sent a friendly name keeps it; nothing is renamed
+ // to a catalog brand it did not claim.
+ expect(names()).toContain('Mistral AI');
+
+ // Search reaches a provider that More would otherwise hold, by model id too.
+ fireEvent.change(screen.getByLabelText(en.settings.backends.opencodeSearchPlaceholder), { target: { value: 'llama-3.3' } });
+ expect(names()).toEqual(['Groq']);
+ expect(screen.queryByRole('button', { name: /More providers/ })).toBeNull();
+
+ // Picking one hands the middle to the form and keeps the same frame rows.
+ fireEvent.change(screen.getByLabelText(en.settings.backends.opencodeSearchPlaceholder), { target: { value: 'Qwen' } });
+ fireEvent.click(screen.getByRole('button', { name: /Qwen/ }));
+ expect(await screen.findByLabelText(en.onboarding.connection.apiKeyLabel)).toBeTruthy();
+ expect(frame().title).toBe('Connect OpenCode');
+ expect(frame().rows).toEqual([1, 1, 1]);
+ // The internal id the rest of OpenCode uses stays visible after the choice.
+ expect(screen.getByRole('button', { name: en.onboarding.connection.changeProvider }).closest('.connection-chosen')?.textContent).toContain('Qwen');
+ });
+
+ it('never offers a local provider for an API Key, and follows OAuth capability for subscriptions', async () => {
+ const entry = (id: string, name: string, patch: Partial<{ local: boolean; oauth_available: boolean }> = {}) =>
+ ({ id, name, description: '', configured: false, oauth_available: false, local: false, models: [], ...patch });
+ mock.api.getOpencodeProviders.mockResolvedValue({ ok: true, providers: [
+ entry('openai', 'OpenAI'), entry('ollama', 'Ollama', { local: true }), entry('github-copilot', 'GitHub Copilot', { oauth_available: true }),
+ ] });
+ mock.api.getBackendConnection.mockResolvedValue(connection({ backend: 'opencode', auth: 'none', ready: false, entry_eligible: false }));
+ const { unmount } = render(wrap(<BackendConnectionDialog backend="opencode" method="api_key" onConnected={vi.fn()} onClose={vi.fn()} onWriteState={vi.fn()} />));
+ const names = () => screen.getAllByRole('button').map((node) => node.querySelector('strong')?.textContent).filter(Boolean);
+ await waitFor(() => expect(names()).toContain('OpenAI'));
+ expect(names()).not.toContain('Ollama');
+ unmount();
+
+ render(wrap(<BackendConnectionDialog backend="opencode" method="oauth" onConnected={vi.fn()} onClose={vi.fn()} onWriteState={vi.fn()} />));
+ // A subscription list is whatever can actually sign in, not the eight brands.
+ await waitFor(() => expect(names()).toEqual(['GitHub Copilot']));
+ });
+});
diff --git a/ui/src/components/onboarding/BackendConnectionDialog.tsx b/ui/src/components/onboarding/BackendConnectionDialog.tsx
index 754e7eade..6e98dfb71 100644
--- a/ui/src/components/onboarding/BackendConnectionDialog.tsx
+++ b/ui/src/components/onboarding/BackendConnectionDialog.tsx
@@ -1,5 +1,22 @@
-import { useCallback, useEffect, useRef, useState } from 'react';
-import { ChevronRight, Search } from 'lucide-react';
+// The setup step's connection dialog.
+//
+// Its frame is fixed per assistant (`connection.css`): heading, description, the
+// method row, a scrolling middle and the action footer each own a row of a grid
+// whose height does not depend on what is inside it. That is the whole point —
+// the reported defect was that switching Subscription/API Key re-measured the
+// dialog and moved its top edge, because a centered box with content height
+// moves by half of every content change. So the heading here names the assistant
+// and nothing else, the description says what a connection is for regardless of
+// method, and everything method-specific — including each method's own
+// instructions — belongs to the scrolling middle, which is the only part allowed
+// to change size.
+//
+// For OpenCode the dialog also has to choose a provider first. That step reuses
+// the same five rows: the method row holds the search field, the middle holds
+// the list, the footer holds Cancel. Picking a provider replaces the search with
+// the chosen row and hands the middle to the form, and the frame never moves.
+import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
+import { ChevronDown, ChevronRight, Search } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { useApi, type OpencodeProvider } from '@/context/ApiContext';
import { errorMessage } from '@/lib/errorMessage';
@@ -8,9 +25,30 @@ import { Dialog, DialogContent, DialogDescription, DialogTitle } from '../ui/dia
import { Button } from '../ui/button';
import { Input } from '../ui/input';
import { BackendIcon } from '../visual';
-import { BackendConnectionForm, type ConnectionHeading } from '../settings/providers/BackendConnectionForm';
+import { VendorGlyph } from '../settings/models/vendorGlyph';
+import { providerLabel, providerVendorId, setupPrimaryRank } from '../settings/providers/providerIdentity';
+import { BackendConnectionForm } from '../settings/providers/BackendConnectionForm';
import type { BackendId } from '../settings/shared/useBackendRuntime';
+/** One provider choice: its brand mark, the name a person recognises, and the id
+ * OpenCode files it under — shown because that id is what the rest of OpenCode,
+ * its config file and its model identifiers use. */
+function ProviderRow({ entry, onPick }: { entry: OpencodeProvider; onPick: () => void }) {
+ const { t } = useTranslation();
+ const label = providerLabel(entry.id, entry.name);
+ return (
+ <button type="button" className="connection-provider focus-visible:outline-2 focus-visible:outline-ring" onClick={onPick}>
+ <span className="connection-provider-mark"><VendorGlyph vendor={providerVendorId(entry.id)} /></span>
+ <span className="connection-provider-text">
+ <strong>{label}</strong>
+ <small>{label.toLowerCase() === entry.id.toLowerCase() ? entry.description || entry.id : entry.id}</small>
+ </span>
+ {entry.configured && <span className="connection-provider-configured">{t('onboarding.connection.providerConfigured')}</span>}
+ <ChevronRight size={16} />
+ </button>
+ );
+}
+
export function BackendConnectionDialog({ backend, method, onClose, onConnected, onWriteState }: {
backend: BackendId;
method: 'oauth' | 'api_key';
@@ -19,12 +57,12 @@ export function BackendConnectionDialog({ backend, method, onClose, onConnected,
onWriteState: (pending: boolean) => void;
}) {
const api = useApi(); const { t } = useTranslation();
- const [heading, setHeading] = useState<ConnectionHeading>({ method, active: false, credential: 'api_key' });
const [providers, setProviders] = useState<OpencodeProvider[]>([]);
const [provider, setProvider] = useState<OpencodeProvider>();
const [loading, setLoading] = useState(backend === 'opencode');
const [error, setError] = useState('');
const [query, setQuery] = useState('');
+ const [showMore, setShowMore] = useState(false);
const [busy, setBusy] = useState(false);
const readToken = useRef(0);
const mounted = useRef(true);
@@ -41,35 +79,84 @@ export function BackendConnectionDialog({ backend, method, onClose, onConnected,
finally { if (token === readToken.current) setLoading(false); }
}, [api, t]);
useEffect(() => { if (backend === 'opencode') void load(); return () => { readToken.current++; }; }, [backend, load]);
- const isKey = heading.method === 'api_key';
- const title = backend === 'claude' ? t(heading.active ? 'onboarding.connection.claudeComplete' : isKey ? heading.credential === 'auth_token' ? 'onboarding.connection.claudeTokenTitle' : 'onboarding.connection.claudeKeyTitle' : 'onboarding.connection.claudeTitle')
- : backend === 'codex' ? t(isKey ? 'onboarding.connection.codexKeyTitle' : heading.active ? 'onboarding.connection.codexComplete' : 'onboarding.connection.codexTitle')
- : provider ? t(isKey ? 'onboarding.connection.providerKeyTitle' : 'onboarding.connection.providerTitle', { name: provider.name })
- : t(isKey ? 'onboarding.connection.opencodeKeyTitle' : 'onboarding.connection.opencodeTitle');
- const intro = backend === 'claude' ? t(heading.active ? 'onboarding.connection.claudeCompleteIntro' : isKey ? 'onboarding.connection.claudeKeyIntro' : 'onboarding.connection.claudeIntro')
- : backend === 'codex' ? t(isKey ? 'onboarding.connection.codexKeyIntro' : heading.active ? 'onboarding.connection.codexCompleteIntro' : 'onboarding.connection.codexIntro')
- : provider ? t('onboarding.connection.providerIntro', { name: provider.name }) : t(isKey ? 'onboarding.connection.pickKey' : 'onboarding.connection.pickSubscription');
- const filtered = providers.filter((entry) => (method === 'api_key' ? !entry.local : entry.oauth_available)
- && `${entry.name} ${entry.id}`.toLowerCase().includes(query.toLowerCase()));
- return <Dialog open onOpenChange={(open) => { if (!open) onClose(); }}><DialogContent className="connection-dialog" closeLabel={t('common.close')}>
- <div className="connection-heading"><div className="connection-logo"><BackendIcon backend={backend} variant="brand" brandFit="mark" size={28} aria-hidden="true" /></div>
- <div><DialogTitle>{title}</DialogTitle><p>{t('onboarding.connection.target', { name: getBackendUiMeta(backend).label })}</p></div>
- </div>
- <DialogDescription className="connection-intro">{intro}</DialogDescription>
- {backend === 'opencode' && !provider ? <>
- {loading && <p role="status">{t('common.loading')}</p>}
- {error && <div className="connection-error" role="alert">{error}<Button variant="secondary" onClick={() => void load()}>{t('common.retry')}</Button></div>}
- {method === 'api_key' && <div className="relative"><Search size={15} className="absolute left-3 top-3 text-muted" /><Input className="h-[38px] pl-9" aria-label={t('settings.backends.opencodeSearchPlaceholder')} placeholder={t('settings.backends.opencodeSearchPlaceholder')} value={query} onChange={(event) => setQuery(event.target.value)} /></div>}
- <div className="connection-provider-list">{filtered.map((entry) => <button type="button" key={entry.id} className="connection-provider focus-visible:outline-2 focus-visible:outline-ring" onClick={() => setProvider(entry)}>
- <span><strong>{entry.name}</strong><small>{entry.description || entry.id}</small></span><ChevronRight size={16} /></button>)}</div>
- {!loading && !error && filtered.length === 0 && <p className="connection-intro">{t('onboarding.connection.noProviders')}</p>}
- <p className="connection-intro">{t('onboarding.connection.catalogHint')}</p>
- <div className="connection-actions"><Button variant="secondary" onClick={onClose}>{t('common.cancel')}</Button></div>
- </> : <>
- {provider && <div className="connection-provider"><span><strong>{provider.name}</strong><small>{t('onboarding.connection.providerDescription')}</small></span><Button variant="ghost" size="xs" disabled={busy} onClick={() => setProvider(undefined)}>{t('onboarding.connection.changeProvider')}</Button></div>}
- <BackendConnectionForm key={provider?.id || backend} backend={backend} provider={provider} initialMethod={method} compact
- onHeading={setHeading} onBusyChange={setBusy} onWriteState={onWriteState} onCancel={onClose}
- onConnected={async () => { await onConnected(); if (mounted.current) onClose(); }} />
- </>}
- </DialogContent></Dialog>;
+
+ const picking = backend === 'opencode' && !provider;
+ const name = getBackendUiMeta(backend).label;
+ // Method-independent, by contract. Whatever the person is about to do, this
+ // dialog is for this assistant and says so the same way in every state.
+ const title = t('onboarding.connection.dialogTitle', { name });
+ const intro = t(backend === 'claude' ? 'onboarding.connection.claudeDialogIntro'
+ : backend === 'codex' ? 'onboarding.connection.codexDialogIntro'
+ : 'onboarding.connection.opencodeDialogIntro');
+
+ const { shortlist, more } = useMemo(() => {
+ const term = query.trim().toLowerCase();
+ // Subscriptions follow OpenCode's real OAuth capability; the eight brands
+ // below are an API-key presentation order, not an authentication catalog.
+ const eligible = providers.filter((entry) => (method === 'api_key' ? !entry.local : entry.oauth_available));
+ const matching = eligible.filter((entry) => !term
+ || `${providerLabel(entry.id, entry.name)} ${entry.name} ${entry.id} ${entry.models.join(' ')}`.toLowerCase().includes(term));
+ const rank = (entry: OpencodeProvider) => method === 'api_key' ? setupPrimaryRank(entry.id) : null;
+ const ordered = [...matching].sort((left, right) => {
+ const [a, b] = [rank(left), rank(right)];
+ if (a !== null && b !== null) return a - b;
+ if (a !== null) return -1;
+ if (b !== null) return 1;
+ // Providers already holding credentials stay reachable without More.
+ if (left.configured !== right.configured) return left.configured ? -1 : 1;
+ return providerLabel(left.id, left.name).localeCompare(providerLabel(right.id, right.name));
+ });
+ // A search has to reach every provider, so it collapses nothing. Neither
+ // does the subscription list: it is already only what can sign in, and
+ // there is no shortlist to be the remainder of.
+ if (term || method !== 'api_key') return { shortlist: ordered, more: [] as OpencodeProvider[] };
+ const promoted = (entry: OpencodeProvider) => rank(entry) !== null || entry.configured;
+ return { shortlist: ordered.filter(promoted), more: ordered.filter((entry) => !promoted(entry)) };
+ }, [providers, method, query]);
+
+ return <Dialog open onOpenChange={(open) => { if (!open) onClose(); }}>
+ <DialogContent className="connection-dialog" data-backend={backend} closeLabel={t('common.close')}>
+ <div className="connection-heading"><div className="connection-logo"><BackendIcon backend={backend} variant="brand" brandFit="mark" size={28} aria-hidden="true" /></div>
+ <div><DialogTitle>{title}</DialogTitle><p>{t(`onboarding.setup.${backend}Description`)}</p></div>
+ </div>
+ <DialogDescription className="connection-intro connection-description">{intro}</DialogDescription>
+ {picking ? (
+ <div className="connection-controls connection-search">
+ <Search size={15} aria-hidden="true" />
+ <Input aria-label={t('settings.backends.opencodeSearchPlaceholder')} placeholder={t('settings.backends.opencodeSearchPlaceholder')}
+ value={query} onChange={(event) => setQuery(event.target.value)} />
+ </div>
+ ) : provider ? (
+ <div className="connection-controls connection-chosen">
+ <span className="connection-provider-mark"><VendorGlyph vendor={providerVendorId(provider.id)} /></span>
+ <span className="connection-provider-text"><strong>{providerLabel(provider.id, provider.name)}</strong><small>{t('onboarding.connection.providerDescription')}</small></span>
+ <Button variant="ghost" size="xs" disabled={busy} onClick={() => setProvider(undefined)}>{t('onboarding.connection.changeProvider')}</Button>
+ </div>
+ ) : null}
+ {picking ? <>
+ <div className="connection-body connection-pick">
+ {loading && <p role="status">{t('common.loading')}</p>}
+ {error && <div className="connection-error" role="alert">{error}<Button variant="secondary" onClick={() => void load()}>{t('common.retry')}</Button></div>}
+ <p className="connection-intro">{t(method === 'api_key' ? 'onboarding.connection.pickKey' : 'onboarding.connection.pickSubscription')}</p>
+ <div className="connection-provider-list">
+ {shortlist.map((entry) => <ProviderRow key={entry.id} entry={entry} onPick={() => setProvider(entry)} />)}
+ {more.length > 0 && <>
+ <Button type="button" variant="secondary" className="connection-more" aria-expanded={showMore} onClick={() => setShowMore((open) => !open)}>
+ {showMore ? <ChevronDown size={15} /> : <ChevronRight size={15} />}
+ {t('onboarding.connection.moreProviders')} ({more.length})
+ </Button>
+ {showMore && more.map((entry) => <ProviderRow key={entry.id} entry={entry} onPick={() => setProvider(entry)} />)}
+ </>}
+ </div>
+ {!loading && !error && shortlist.length === 0 && more.length === 0 && <p className="connection-intro">{t('onboarding.connection.noProviders')}</p>}
+ <p className="connection-intro">{t('onboarding.connection.catalogHint')}</p>
+ </div>
+ <div className="connection-actions"><Button variant="secondary" onClick={onClose}>{t('common.cancel')}</Button></div>
+ </> : (
+ <BackendConnectionForm key={provider?.id || backend} backend={backend} provider={provider} initialMethod={method} compact
+ onBusyChange={setBusy} onWriteState={onWriteState} onCancel={onClose}
+ onConnected={async () => { await onConnected(); if (mounted.current) onClose(); }} />
+ )}
+ </DialogContent>
+ </Dialog>;
}
diff --git a/ui/src/components/onboarding/CollaborationStory.tsx b/ui/src/components/onboarding/CollaborationStory.tsx
index 516420810..a3368f6ac 100644
--- a/ui/src/components/onboarding/CollaborationStory.tsx
+++ b/ui/src/components/onboarding/CollaborationStory.tsx
@@ -6,13 +6,20 @@ import { Card } from '../ui/card';
import { ASSISTANT_ORDER, WORK_LINES, collaborationFrame } from './collaborationTimeline';
import { useOnboardingMotion } from './motion';
-/** Wire geometry in the 880x272 collaboration box: two handoffs and the rounded return loop. */
+/**
+ * Wire geometry in the 976x271 collaboration box: two handoffs and the rounded return
+ * loop. Every coordinate is the reference's own — the cards take the top 232 rows, so a
+ * handoff crosses the 39.5 gap between them at y=116, their shared midline, and the
+ * return runs from the third card's centre to the first's along y=261. The box is
+ * stretched to whatever the diagram currently measures, so these hold at every width.
+ */
const WIRES = [
- 'M240 118H320',
- 'M560 118H640',
- 'M760 228V246Q760 262 744 262H136Q120 262 120 246V228',
+ 'M299 116H339',
+ 'M637 116H677',
+ 'M826 232V245Q826 261 810 261H165Q149 261 149 245V232',
];
-const PORTS: [number, number][] = [[240, 118], [320, 118], [560, 118], [640, 118], [760, 228], [120, 228]];
+/** Only the four handoff ends are drawn: the return loop leaves its cards unmarked. */
+const PORTS: [number, number][] = [[299, 116], [339, 116], [637, 116], [677, 116]];
const ICONS = [FileText, CodeXml, ListChecks];
// Every skeleton line as its share of the block it is measured in, so the three cards
// draw the widths design_desktop.pen draws at any scale. The card's content box is 198
@@ -104,7 +111,7 @@ function Circuit({ handoff }: { handoff: { wire: number; progress: number } | nu
opacity: Math.max(0, Math.min(1, handoff.progress / 0.08, (1 - handoff.progress) / 0.06)),
};
return (
- <svg className="onboarding-wires" viewBox="0 0 880 272" fill="none" preserveAspectRatio="none" aria-hidden="true">
+ <svg className="onboarding-wires" viewBox="0 0 976 271" fill="none" preserveAspectRatio="none" aria-hidden="true">
<defs>
<filter id={glowId} x="-100%" y="-500%" width="300%" height="1100%"><feGaussianBlur stdDeviation="3" /></filter>
</defs>
@@ -165,6 +172,14 @@ export function CollaborationStory() {
return (
<Card key={backend} className="onboarding-collaboration-card" data-active={active}
data-state={state} aria-label={t(`onboarding.story.${backend}.name`)}>
+ {/* The same identity header the connection step wears, in the same
+ place: logo, name, and the trailing slot this step fills with the
+ assistant's role and the next one with its enable switch. */}
+ <div className="onboarding-card-identity">
+ <BackendIcon backend={backend} size={28} variant="brand" aria-hidden="true" />
+ <strong className="onboarding-card-name">{t(`onboarding.story.${backend}.name`)}</strong>
+ <span className="onboarding-card-role">{t(`onboarding.story.${backend}.role`)}</span>
+ </div>
<div className="onboarding-story-status" aria-hidden="true">
<Icon size={13} strokeWidth={1.7} className="onboarding-status-icon" />
<span key={caption} className="onboarding-status-text onboarding-status-enter">
@@ -173,11 +188,6 @@ export function CollaborationStory() {
<WorkStatus active={active} done={done} progress={frame.progress[index]} />
</div>
<Skeleton backend={backend} done={done} written={reducedMotion ? WORK_LINES : frame.written[index]} />
- <div className="onboarding-story-identity">
- <BackendIcon backend={backend} size={28} variant="brand" aria-hidden="true" />
- <strong>{t(`onboarding.story.${backend}.name`)}</strong>
- <span>{t(`onboarding.story.${backend}.role`)}</span>
- </div>
</Card>
);
})}
diff --git a/ui/src/components/onboarding/ImportKeysNotice.test.tsx b/ui/src/components/onboarding/ImportKeysNotice.test.tsx
new file mode 100644
index 000000000..6291cc1ae
--- /dev/null
+++ b/ui/src/components/onboarding/ImportKeysNotice.test.tsx
@@ -0,0 +1,276 @@
+// @vitest-environment jsdom
+//
+// The setup import entry, driven through the real dialog it opens. Only the two
+// boundaries are stubbed — the HTTP calls and the capability probe — so what is
+// under test is the thing that actually matters here: that the number in the
+// sentence, the rows a person is offered, and the ids finally submitted are all
+// the same set. A count computed from one rule and rows rendered from another is
+// the failure this fixture exists to catch.
+//
+// The scan fixture carries the shapes `migration.py` really produces, including
+// a row with no presentation metadata at all (an older server) and non-ASCII
+// detail text.
+import { cleanup, render, screen, waitFor, within } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { I18nextProvider } from 'react-i18next';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+
+import i18n from '@/i18n';
+import type { MigrationItem } from '@/components/settings/models/types';
+
+const showToast = vi.hoisted(() => vi.fn());
+const capability = vi.hoisted(() => ({ value: true as boolean | null }));
+
+vi.mock('@/context/ToastContext', () => ({ useToast: () => ({ showToast }) }));
+vi.mock('@/components/settings/models/useModelHubCapability', () => ({
+ useModelHubCapability: () => capability.value,
+}));
+
+import { modelsApi } from '@/components/settings/models/modelsApi';
+import { ImportKeysNotice } from './ImportKeysNotice';
+
+const CLAUDE_KEY: MigrationItem = {
+ id: 'mig_claude_key',
+ backend: 'claude',
+ kind: 'api_key',
+ masked_detail: 'sk-…dd3c',
+ proposed_action: 'import',
+ selected: true,
+ notes_key: null,
+ vendor: 'anthropic',
+ display_name: 'Anthropic',
+ masked_credential: 'sk-…dd3c',
+};
+
+// A native subscription. Legitimately applied by the settings migration; never
+// part of this entry.
+const CLAUDE_SUBSCRIPTION: MigrationItem = {
+ id: 'mig_claude_oauth',
+ backend: 'claude',
+ kind: 'oauth_native',
+ masked_detail: 'Claude 账号登录(OAuth)',
+ proposed_action: 'keep_native',
+ selected: true,
+ notes_key: null,
+ vendor: 'anthropic',
+ display_name: 'Anthropic',
+ masked_credential: null,
+};
+
+// Key-shaped, but needs the interactive browser flow — not batchable.
+const CODEX_REAUTH: MigrationItem = {
+ id: 'mig_codex_reauth',
+ backend: 'codex',
+ kind: 'api_key',
+ masked_detail: 'sk-…9f21',
+ proposed_action: 'reauth',
+ selected: true,
+ notes_key: null,
+ vendor: 'openai',
+ display_name: 'OpenAI',
+ masked_credential: 'sk-…9f21',
+};
+
+// An OpenCode key: `opencode_provider`, never `api_key`, and its display_name is
+// only the provider id echoed back.
+const OPENCODE_ZHIPU: MigrationItem = {
+ id: 'mig_opencode_zhipu',
+ backend: 'opencode',
+ kind: 'opencode_provider',
+ masked_detail: 'zhipu · sk-…3456',
+ proposed_action: 'import',
+ selected: true,
+ notes_key: null,
+ vendor: 'zhipu',
+ display_name: 'zhipu',
+ masked_credential: 'sk-…3456',
+};
+
+// An older server, or a provider nothing recognises: no presentation metadata at
+// all, so the row has only its composed detail to show.
+const OPENCODE_LEGACY: MigrationItem = {
+ id: 'mig_opencode_legacy',
+ backend: 'opencode',
+ kind: 'opencode_provider',
+ masked_detail: '自建中转 · sk-…abcd',
+ proposed_action: 'import',
+ selected: true,
+ notes_key: null,
+};
+
+const FULL_SCAN = [CLAUDE_KEY, CLAUDE_SUBSCRIPTION, CODEX_REAUTH, OPENCODE_ZHIPU, OPENCODE_LEGACY];
+
+// A fake server rather than a queue of canned replies: the notice and the dialog
+// it opens each scan on their own schedule, so a fixed reply order would decide
+// which surface saw what. Applying removes the imported rows, which is what makes
+// the notice's post-import remainder a real answer instead of arithmetic.
+let stored: MigrationItem[] = [];
+const applied: string[][] = [];
+
+const serve = (items: MigrationItem[]) => {
+ stored = items.map((i) => ({ ...i }));
+ vi.spyOn(modelsApi, 'scanMigration').mockImplementation(async () => ({
+ items: stored.map((i) => ({ ...i })),
+ }));
+ vi.spyOn(modelsApi, 'applyMigration').mockImplementation(async (ids) => {
+ applied.push([...ids]);
+ stored = stored.filter((i) => !ids.includes(i.id));
+ return { applied: ids.length, sources: [] };
+ });
+};
+
+const renderNotice = (onApplied?: (applied: number) => void) =>
+ render(
+ <I18nextProvider i18n={i18n}>
+ <ImportKeysNotice onApplied={onApplied} />
+ </I18nextProvider>,
+ );
+
+const openDialog = async (user: ReturnType<typeof userEvent.setup>) => {
+ await user.click(await screen.findByRole('button', { name: 'Review and import' }));
+ return screen.findByRole('dialog');
+};
+
+beforeEach(async () => {
+ capability.value = true;
+ applied.length = 0;
+ window.localStorage.clear();
+ await i18n.changeLanguage('en');
+});
+
+afterEach(() => {
+ cleanup();
+ vi.restoreAllMocks();
+ showToast.mockReset();
+});
+
+describe('ImportKeysNotice', () => {
+ it('counts the importable keys — not the rows the scan returned', async () => {
+ serve(FULL_SCAN);
+ renderNotice();
+
+ // Three of five: the subscription and the reauth row are not offers.
+ expect(await screen.findByText('Found 3 API keys to import into Model Gateway')).toBeTruthy();
+ });
+
+ it('offers exactly the rows it counted, and no subscription or reauth row', async () => {
+ serve(FULL_SCAN);
+ renderNotice();
+ const user = userEvent.setup();
+
+ const dialog = await openDialog(user);
+
+ expect(within(dialog).getByText('Anthropic')).toBeTruthy();
+ // `display_name` was only the provider id; the shared brand mapping names it.
+ expect(within(dialog).getByText('Zhipu AI')).toBeTruthy();
+ // No metadata at all: the composed detail stays the title rather than a
+ // provider guessed from the backend that held the key.
+ expect(within(dialog).getByText('自建中转 · sk-…abcd')).toBeTruthy();
+
+ expect(within(dialog).queryByText('Claude 账号登录(OAuth)')).toBeNull();
+ expect(within(dialog).queryByText(/Keep native/)).toBeNull();
+ expect(within(dialog).queryByText(/Re-authorize/)).toBeNull();
+ expect(within(dialog).getByRole('button', { name: /Import 3 items/ })).toBeTruthy();
+ });
+
+ it('MH-MIG-004: submits only the rows still ticked', async () => {
+ serve(FULL_SCAN);
+ const onApplied = vi.fn();
+ renderNotice(onApplied);
+ const user = userEvent.setup();
+
+ const dialog = await openDialog(user);
+ await user.click(within(dialog).getByRole('checkbox', { name: /Anthropic/ }));
+ await user.click(within(dialog).getByRole('button', { name: /Import 2 items/ }));
+
+ await waitFor(() => expect(applied).toHaveLength(1));
+ expect(applied[0]).toEqual(['mig_opencode_zhipu', 'mig_opencode_legacy']);
+ expect(onApplied).toHaveBeenCalledWith(2);
+ });
+
+ it('stays to report what was imported and what is still available', async () => {
+ serve(FULL_SCAN);
+ renderNotice();
+ const user = userEvent.setup();
+
+ const dialog = await openDialog(user);
+ await user.click(within(dialog).getByRole('checkbox', { name: /Anthropic/ }));
+ await user.click(within(dialog).getByRole('button', { name: /Import 2 items/ }));
+
+ // The remainder is the server's answer after the rescan, not a subtraction.
+ expect(await screen.findByText('Imported 2 · 1 API key still available')).toBeTruthy();
+ // A partial selection can still be finished from here.
+ expect(screen.getByRole('button', { name: 'Review and import' })).toBeTruthy();
+ });
+
+ it('reports a finished import with no review action left', async () => {
+ serve(FULL_SCAN);
+ renderNotice();
+ const user = userEvent.setup();
+
+ const dialog = await openDialog(user);
+ await user.click(within(dialog).getByRole('button', { name: /Import 3 items/ }));
+
+ expect(await screen.findByText('Imported 3 API keys into Model Gateway')).toBeTruthy();
+ expect(screen.queryByRole('button', { name: 'Review and import' })).toBeNull();
+ // The subscription and the reauth row are still on this machine, untouched.
+ expect(stored.map((i) => i.id)).toEqual(['mig_claude_oauth', 'mig_codex_reauth']);
+ });
+
+ it('remembers a dismissal so the same keys do not ask again', async () => {
+ serve(FULL_SCAN);
+ const { unmount } = renderNotice();
+ const user = userEvent.setup();
+
+ await user.click(await screen.findByRole('button', { name: 'Dismiss import notice' }));
+ expect(screen.queryByText(/API keys to import/)).toBeNull();
+
+ unmount();
+ cleanup();
+ renderNotice();
+ await waitFor(() => expect(modelsApi.scanMigration).toHaveBeenCalledTimes(2));
+ expect(screen.queryByText(/API keys to import/)).toBeNull();
+ });
+
+ it('asks again when a genuinely new key appears', async () => {
+ serve(FULL_SCAN);
+ const { unmount } = renderNotice();
+ const user = userEvent.setup();
+
+ await user.click(await screen.findByRole('button', { name: 'Dismiss import notice' }));
+ unmount();
+ cleanup();
+ stored = [...stored, { ...CLAUDE_KEY, id: 'mig_claude_key_2', masked_detail: 'sk-…7a10' }];
+ renderNotice();
+
+ expect(await screen.findByText('Found 4 API keys to import into Model Gateway')).toBeTruthy();
+ });
+
+ it('says nothing when there is nothing to import', async () => {
+ serve([CLAUDE_SUBSCRIPTION, CODEX_REAUTH]);
+ renderNotice();
+
+ await waitFor(() => expect(modelsApi.scanMigration).toHaveBeenCalled());
+ expect(screen.queryByText(/Model Gateway/)).toBeNull();
+ });
+
+ it('says nothing when the scan fails', async () => {
+ // Advertising rows after a failed scan would open a dialog that rescans,
+ // fails again and shows nothing.
+ vi.spyOn(modelsApi, 'scanMigration').mockRejectedValue(new Error('offline'));
+ renderNotice();
+
+ await waitFor(() => expect(modelsApi.scanMigration).toHaveBeenCalled());
+ expect(screen.queryByText(/Model Gateway/)).toBeNull();
+ });
+
+ it('does not scan at all when the gateway capability is off', async () => {
+ capability.value = false;
+ serve(FULL_SCAN);
+ renderNotice();
+
+ await Promise.resolve();
+ expect(modelsApi.scanMigration).not.toHaveBeenCalled();
+ expect(screen.queryByText(/Model Gateway/)).toBeNull();
+ });
+});
diff --git a/ui/src/components/onboarding/ImportKeysNotice.tsx b/ui/src/components/onboarding/ImportKeysNotice.tsx
new file mode 100644
index 000000000..a4f0441ba
--- /dev/null
+++ b/ui/src/components/onboarding/ImportKeysNotice.tsx
@@ -0,0 +1,142 @@
+// Setup's API-key import offer: one line under the assistant list saying how many
+// keys already on this machine the Model Gateway can take over, with a way to look
+// at them before anything happens.
+//
+// It is deliberately narrower than the settings migration. That surface legitimately
+// offers native OAuth rows and `keep_native`, which is a real applied action there;
+// this one is about keys and only keys, so the sentence, the rows in the dialog, the
+// batch submitted and the count left afterwards all read the single
+// `isImportableKey` predicate. A number produced by a different rule than the rows
+// behind it is the failure this shape exists to make impossible.
+//
+// It stays visible after an import to say what happened and what is left, so a
+// partial selection can be finished without hunting for the entry again.
+import * as React from 'react';
+import { KeyRound, X } from 'lucide-react';
+import { useTranslation } from 'react-i18next';
+
+import { Button } from '@/components/ui/button';
+import { InfoHint } from '@/components/ui/info-hint';
+import { MigrationDialog } from '@/components/settings/models/MigrationDialog';
+import { importableKeys, isImportableKey, scanMigrationWhenEnabled } from '@/components/settings/models/migrationScan';
+import type { MigrationItem } from '@/components/settings/models/types';
+import { useModelHubCapability } from '@/components/settings/models/useModelHubCapability';
+import { isMigrationDismissed, writeMigrationDismissed } from '@/lib/modelHubMigrationDismiss';
+
+export const ImportKeysNotice: React.FC<{
+ /** Bubble the applied count so the host step can refresh assistants/sources. */
+ onApplied?: (applied: number) => void;
+}> = ({ onApplied }) => {
+ const { t } = useTranslation();
+ const modelHubEnabled = useModelHubCapability();
+
+ const [candidates, setCandidates] = React.useState<MigrationItem[]>([]);
+ const [imported, setImported] = React.useState(0);
+ const [dialogOpen, setDialogOpen] = React.useState(false);
+ const [dismissed, setDismissed] = React.useState(false);
+ const [scanToken, setScanToken] = React.useState(0);
+ const aliveRef = React.useRef(true);
+ React.useEffect(() => {
+ aliveRef.current = true;
+ return () => {
+ aliveRef.current = false;
+ };
+ }, []);
+
+ React.useEffect(() => {
+ if (modelHubEnabled !== true) {
+ setCandidates([]);
+ return;
+ }
+ let cancelled = false;
+ scanMigrationWhenEnabled(true)
+ .then((scan) => {
+ if (cancelled || !aliveRef.current || scan === null) return;
+ const keys = importableKeys(scan.items);
+ setCandidates(keys);
+ // Only the first scan consults the persisted dismissal. A rescan follows an
+ // import the person just asked for, and hiding their own result because an
+ // older batch was once dismissed would lose the outcome report.
+ if (scanToken === 0) setDismissed(isMigrationDismissed(keys));
+ })
+ .catch(() => {
+ // A failed scan must not keep advertising the previous rows: the dialog it
+ // opens would rescan too, and land on its own error with nothing to show.
+ if (!cancelled && aliveRef.current) setCandidates([]);
+ });
+ return () => {
+ cancelled = true;
+ };
+ }, [modelHubEnabled, scanToken]);
+
+ const remaining = candidates.length;
+ if (modelHubEnabled !== true || dismissed) return null;
+ // Nothing found and nothing done — there is no offer and no outcome to report.
+ if (remaining === 0 && imported === 0) return null;
+
+ const dismiss = () => {
+ // An empty set would overwrite the remembered signature with nothing, so a batch
+ // dismissed earlier would start nagging again. With nothing left to import there
+ // is nothing to remember: this is just closing a receipt.
+ if (remaining > 0) writeMigrationDismissed(candidates);
+ setDismissed(true);
+ };
+
+ const message = imported === 0
+ ? t('settings.models.importNotice.found', { count: remaining })
+ : remaining > 0
+ ? t('settings.models.importNotice.importedRemaining', { imported, count: remaining })
+ : t('settings.models.importNotice.imported', { count: imported });
+
+ return (
+ <>
+ <div className="onboarding-import-notice">
+ <KeyRound size={16} className="onboarding-import-notice-icon" aria-hidden="true" />
+ <span className="onboarding-import-notice-text">{message}</span>
+ <div className="onboarding-import-notice-actions">
+ {remaining > 0 && (
+ // A light button, not a text link: this is the capsule's own action and
+ // it has to read as one next to the primary CTA below it.
+ <Button type="button" variant="secondary" size="sm" className="onboarding-import-notice-action"
+ onClick={() => setDialogOpen(true)}>
+ {t('settings.models.importNotice.review')}
+ </Button>
+ )}
+ <InfoHint
+ align="end"
+ hover
+ className="onboarding-import-notice-help"
+ label={t('settings.models.importNotice.help') as string}
+ trigger={t('settings.models.importNotice.help')}
+ content={t('settings.models.importNotice.helpBody')}
+ contentClassName="w-72"
+ />
+ </div>
+ <button
+ type="button"
+ className="onboarding-import-notice-dismiss"
+ aria-label={t('settings.models.importNotice.dismiss') as string}
+ onClick={dismiss}
+ >
+ <X size={14} aria-hidden="true" />
+ </button>
+ </div>
+
+ {dialogOpen && (
+ <MigrationDialog
+ open
+ eligible={isImportableKey}
+ onClose={() => setDialogOpen(false)}
+ onApplied={(applied) => {
+ setDialogOpen(false);
+ setImported((total) => total + applied);
+ // Rescan so "what is left" is the server's answer, not arithmetic on a
+ // count this component happened to be holding.
+ setScanToken((n) => n + 1);
+ onApplied?.(applied);
+ }}
+ />
+ )}
+ </>
+ );
+};
diff --git a/ui/src/components/onboarding/onboarding.css b/ui/src/components/onboarding/onboarding.css
index 8a3195f05..5fc953f75 100644
--- a/ui/src/components/onboarding/onboarding.css
+++ b/ui/src/components/onboarding/onboarding.css
@@ -4,10 +4,22 @@
* animation in Show session `ses36vg559de2`. The values below are component-scoped on
* purpose: they encode exact approved design numbers without moving any global token.
*
+ * The `Web setup` frames and the `Web setup · Responsive rules & states` note are the
+ * measured reference for everything below: a 976 content box on a standard desktop
+ * growing to 1200 on a large one, a 299-wide relay card whose height follows the
+ * window rather than the width, and one heading / stage / action column that the
+ * introduction and the connection both stand in.
+ *
* Widths are capped fluid, never fixed: the card grid uses percentage tracks and the
- * diagram is sized from its own width, so card width, handoff gaps, diagram height and
- * the stretched wire viewBox stay proportional at every container width. The owner
- * accepted 1104 as the desktop cap; only the narrow bands choose a height directly.
+ * diagram is sized from the card it contains, so card width, handoff gaps, diagram
+ * height and the stretched wire viewBox stay proportional at every container width.
+ *
+ * The welcome and the setup are one composition seen twice. The three cards keep the
+ * same frame, the same tracks and the same identity header in both — logo, name, and
+ * a right-hand slot the introduction fills with a role and the connection with an
+ * enable switch — so moving between them changes what a card holds and never where it
+ * is. That is why the card frame and the identity header below are written once and
+ * worn by both steps.
*/
.onboarding-shell {
--ob-card: linear-gradient(150deg, #151521, #101019);
@@ -28,7 +40,6 @@
--ob-check-bg: #ffffff05;
--ob-check-border: #5bffa044;
--ob-check-done: #5bffa012;
- --ob-identity-line: #ffffff0e;
--ob-wire: #5bffa031;
--ob-port: #15281f;
--ob-port-border: #5bffa066;
@@ -39,20 +50,46 @@
--ob-tile-hover: #ffffff0a;
--ob-well: #ffffff04;
--ob-tile-label: #d3d7e2;
+ /* The import notice, drawn as its own mint-tinted plate rather than a variant of
+ the assistant row: it is an offer, not part of the list it sits under. */
+ --ob-notice-bg: #172f27;
+ --ob-notice-border: #30473e;
- /* One content width for the header, the story and the assistant rows. 1104 is the
- setup frame's own container (i3vw9 lays it out at x=48 of a 1200 frame); the owner
- accepted it for the welcome too, whose blocks are authored at 880. Every dependent
- number is therefore expressed as its ratio to 880 rather than re-typed: the cap
- alone moves the whole composition and nothing can drift out of proportion.
- At 1104 that yields 301.1 cards, a 1104x341.2 diagram and an 802.9 access span. */
- --ob-content-w: 1104px;
+ /* One content width for the header, the story and the assistant cards, written as the
+ rule the reference's four rows describe rather than as four numbers: 976 on a
+ standard desktop, growing only once the window can spend 62.5% of itself on it, and
+ stopping at 1200. That reaches exactly 976 at both 1366 and 1440 and exactly 1200 at
+ 1920 — the three authored desktop rows — with no breakpoint between them.
+ Every dependent number is a ratio of this box, so the cap alone moves the whole
+ composition and nothing can drift out of proportion. */
+ --ob-content-w: clamp(976px, 62.5vw, 1200px);
/* 20px shell padding plus this bar is the setup's authored 64.5 top offset (IWQi6),
which it holds at every window height. The welcome is centred instead and reaches
the same 65 only at the design's own 756 content box. */
--ob-header-h: 45px;
/* The design's own side padding, so the cap is reached at exactly its 1200 frame. */
--ob-gutter: 48px;
+ /* The relay card, and the one number the rest of the composition is measured from.
+ The reference grows it with the WINDOW, not with the width: 232 at 1366x768, 262 at
+ 1440x900, 330 at 1920x1080 — all three within a few pixels of 30% of the window
+ height, and all three almost exactly a third of the main column. Height is the right
+ source: a card holds a fixed stack of rows, and it is vertical room that decides how
+ much of one fits. The width term is the guard for a short, wide window, where 30% of
+ the height would be taller than the card is wide. */
+ --ob-card-h: min(calc(var(--app-shell-h) * 0.3), calc(min(100cqw, var(--ob-content-w)) * 0.3));
+ /* One design unit, taken from the card the interior belongs to: the frames are drawn
+ on a 232-tall card, so a radius, a padding or a skeleton bar is its authored number
+ times this unit and the interior stays in proportion as the card grows. It is
+ defined once, here, so the story's cards and the connection's cannot be given
+ different units by editing one of them. */
+ --ob-u: calc(var(--ob-card-h) / 232);
+ /* The block between the heading and the action, floored so both steps spend the same
+ height on it. The reference draws exactly 64 more than the card in all three desktop
+ rows, and spends it the same way in both steps: the introduction on the return wire's
+ band under the cards, the connection on a 20 gap and the 44 import capsule. So one
+ number holds the action still both when the step changes and when the offer is
+ dismissed — see `.onboarding-stage`. */
+ --ob-stage-h: calc(var(--ob-card-h) + 64px);
background: var(--background);
color: var(--foreground);
@@ -88,7 +125,6 @@
--ob-check-bg: #eef1f7;
--ob-check-border: #aae6d2;
--ob-check-done: #10b98114;
- --ob-identity-line: #08081214;
--ob-wire: #10b98124;
--ob-port: #10b98124;
--ob-port-border: #aae6d2;
@@ -99,7 +135,9 @@
--ob-tile-bg: #ffffff;
--ob-tile-hover: #0808120a;
--ob-well: #eef1f780;
- --ob-tile-label: #0a0a14;
+ --ob-tile-label: #5c6079;
+ --ob-notice-bg: #edf7f1;
+ --ob-notice-border: #cedfd5;
}
}
[data-theme="light"] .onboarding-shell {
@@ -119,7 +157,6 @@
--ob-check-bg: #eef1f7;
--ob-check-border: #aae6d2;
--ob-check-done: #10b98114;
- --ob-identity-line: #08081214;
--ob-wire: #10b98124;
--ob-port: #10b98124;
--ob-port-border: #aae6d2;
@@ -129,7 +166,9 @@
--ob-tile-bg: #ffffff;
--ob-tile-hover: #0808120a;
--ob-well: #eef1f780;
- --ob-tile-label: #0a0a14;
+ --ob-tile-label: #5c6079;
+ --ob-notice-bg: #edf7f1;
+ --ob-notice-border: #cedfd5;
}
.onboarding-shell > header {
@@ -150,6 +189,10 @@
display: flex;
align-items: flex-start;
justify-content: center;
+ /* Makes the content box measurable in `cqw`, which is how `--ob-stage-h` turns
+ the diagram's own proportion into a height a step without a diagram can
+ match. A percentage cannot: `min-height: %` resolves against height. */
+ container-type: inline-size;
}
/* Owner amendment, 2026-09-18: both steps share the same top anchor.
Normal flow scrolls on short windows; only the lower composition changes. */
@@ -160,78 +203,121 @@
width: 100%;
max-width: var(--ob-content-w);
margin: 0 auto;
- gap: 24px;
+ /* The reference's own rhythm: 20 from the heading to the stage and 20 from the stage
+ to the action, in every desktop row and on the phone. */
+ gap: 20px;
+}
+/* The block between the heading and the action, in both steps, and the one owner of
+ every layout reservation this screen makes. Its floor is `--ob-card-h + 64`, which is
+ what the reference spends on it in both steps at every accepted width — so the
+ shorter step is padded to exactly the taller one's height instead of both being given
+ a number to keep in sync by hand. That is what puts "Get started" and "Enter
+ Workbench" on identical coordinates: same heading above, same stage height, same
+ action width below.
+ The same floor is what keeps the action still when the import notice is dismissed:
+ the notice lives inside this box, so removing it changes the box's content, not its
+ height. One owner answers both invariants and neither needs an empty placeholder
+ node to hold a line nothing is drawn on.
+ It applies at every width, phones included: the stack band re-derives the same floor
+ from the stacked card instead of the side-by-side one (see the 759 band), so the
+ invariant holds there too. Matching the two costs slack at the bottom of whichever
+ step is shorter — accepted, because a person moving between the two steps, or
+ refusing the offer, should not have the button move out from under their finger. */
+.onboarding-stage {
+ width: 100%;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: 20px;
+ min-height: var(--ob-stage-h);
}
+
.onboarding-heading { text-align: center; width: 100%; }
.onboarding-heading h1, .onboarding-heading h2 { min-height: 46px; }
.onboarding-heading p { min-height: 22px; }
-/* The live design's headline: 34/1.35/600 at -1.6 tracking (nodes XKQOx, Igagh and
- hv9DA all agree), shared by the welcome and the setup title. */
+/* The reference's four rows read as one line rather than four sizes: 32 at 1366, 34 at
+ 1440, 50 at 1920 and 30 on a phone are all `3.333vw - 14`, held between 30 and 50 —
+ and the body under it is `1.042vw` between 14 and 20, which lands on its authored
+ 14 / 15 / 20 / 14 the same way. The tracking follows the size proportionally
+ (-1.6 at 34 is -0.047em), so a larger headline is never tighter than the one drawn. */
.onboarding-heading h1, .onboarding-heading h2 {
- font-size: 34px;
+ font-size: clamp(30px, calc(3.333vw - 14px), 50px);
line-height: 1.35;
font-weight: 600;
- letter-spacing: -1.6px;
+ letter-spacing: -0.047em;
+}
+.onboarding-heading p {
+ margin-top: 10px;
+ font-size: clamp(14px, 1.042vw, 20px);
+ line-height: 1.55;
+ color: var(--muted);
}
-.onboarding-heading p { margin-top: 10px; font-size: 14px; line-height: 22px; color: var(--muted); }
/* ---- Collaboration story ------------------------------------------------ */
.onboarding-story { position: relative; width: 100%; display: flex; align-items: flex-start; justify-content: center; }
+/* The diagram is the card plus the return wire's band: the reference draws a 271-tall
+ box around a 232-tall card at 1366, a 306 around a 262 at 1440 and a 385 around a 330
+ at 1920 — one ratio, held exactly. Sizing it from the card rather than from its own
+ width is what keeps the handoff wire on the cards' vertical midpoint at every window,
+ because the stretched viewBox and the card grid now answer to the same number. */
.onboarding-collaboration {
position: relative;
width: 100%;
max-width: var(--ob-content-w);
- /* The diagram is sized from its own width, so the authored 880x272 proportion holds
- at every width up to the cap, where it is the approved 1104x341.2. Narrow bands
- set an explicit height instead: wrapped labels need more room than the proportion. */
- aspect-ratio: 880 / 272;
- height: var(--ob-diagram-h, auto);
+ height: calc(var(--ob-card-h) * 271 / 232);
container-type: inline-size;
}
+/* Three 299-wide cards in a 976 box, which is the same fraction as three 367 in 1200 —
+ so one percentage draws the reference's own tracks and its own 39.5 / 49.5 handoff
+ gaps without either being typed in. */
.onboarding-collaboration-cards {
display: grid;
- grid-template-columns: repeat(3, minmax(0, 27.272727%));
+ grid-template-columns: repeat(3, minmax(0, 30.6352%));
justify-content: space-between;
- /* The cards occupy 228 of the 272 rows; the rest is the return wire's band. */
- height: calc(100% * 228 / 272);
+ height: var(--ob-card-h);
position: relative;
z-index: 1;
- /* One design unit: the frames are drawn on an 880 box, so everything the card draws
- is written as its authored number times this unit and stays proportional as the
- diagram grows to the cap. Text and icons keep their own sizes on purpose — a card
- that is a quarter taller should not read as a zoomed screenshot. */
- --ob-u: calc(100cqw / 880);
}
-.onboarding-collaboration-card {
+/* One frame, worn by the story card and the connection card. Everything that decides
+ where a card sits and how big it is lives here, so the two steps cannot drift apart
+ by editing one of them: the radius and the padding resolve from the same design unit,
+ the tracks are the same percentage, and both steps take their height from
+ `--ob-card-h`. The reference's own 19/17 padding at 1366 and 21/20 at 1440 are this
+ one pair of authored numbers seen at two card heights. */
+.onboarding-collaboration-card, .onboarding-assistant {
display: flex;
flex-direction: column;
- height: 100%;
min-width: 0;
border-radius: calc(16 * var(--ob-u));
border: 1px solid var(--ob-card-border);
background: var(--ob-card);
- padding: calc(18 * var(--ob-u)) calc(20 * var(--ob-u));
- overflow: hidden;
+ padding: calc(17 * var(--ob-u)) calc(19 * var(--ob-u));
transition: border-color 650ms, box-shadow 650ms;
}
+/* The story's cards are cut from a box whose height the diagram already fixed; the
+ connection's take that height as a floor, because an error or a wrapped action has
+ to be readable rather than clipped. Growing is a grid row, so the three grow as one
+ and their identity headers stay level. */
+.onboarding-collaboration-card { height: 100%; overflow: hidden; }
+.onboarding-assistant { min-height: var(--ob-card-h); }
.onboarding-collaboration-card[data-active="true"],
.onboarding-assistant:hover, .onboarding-assistant:focus-within {
border-color: var(--ob-active-border);
box-shadow: var(--ob-active-shadow);
}
-/* The card's 192 of content is authored as 14 status + 119 skeleton + 15 + 44 identity.
- The skeleton is the flexible one, so anything the other three fail to claim pools
- below the last bar — which is exactly what an unscaled 16px glyph and 28px logo did
- at the cap. Both ends therefore reserve their authored share in design units, and the
- skeleton keeps the 119 it was drawn at. Reserving rather than fixing also aligns the
- three separators, since the rows above them are now the same height by construction. */
+/* The card's 198 of content is authored as a 39 identity header, 11, a 23 status line
+ and the 118 skeleton under it. The skeleton is the flexible one, so anything the
+ others fail to claim pools below the last bar — which is exactly what an unscaled
+ 16px glyph and 28px logo did at the cap. The fixed rows therefore reserve their
+ authored share in design units, which also keeps the three cards' status lines level
+ even when one caption is longer than another. */
.onboarding-story-status {
display: flex;
align-items: center;
gap: 7px;
flex-shrink: 0;
- min-height: calc(14 * var(--ob-u));
+ min-height: calc(23 * var(--ob-u));
color: var(--muted);
font-size: 10px;
}
@@ -352,22 +438,34 @@
100% { color: var(--mint-ink); border-color: var(--ob-check-border); background: var(--ob-check-done); }
}
-/* 44 from the separator to the card's inner edge, 15 of clear space above it. The
- 28px logo does not scale, so without the reserved height this block shrank as the
- diagram grew and handed the difference to the skeleton above it. */
-.onboarding-story-identity {
+/* The card's identity, at its head — "the assistant logo and name stay at the top in
+ both states; connection state replaces roles with enable switches", which is the one
+ rule the whole intro/connection invariant rests on. Both steps draw this from the same
+ class and the same three slots: logo, name, and a trailing slot the introduction fills
+ with a role and the connection with an enable switch. There is one identity header in
+ the stylesheet, so the two steps cannot place it differently, and the body underneath
+ takes every difference between them.
+ The 28px logo does not scale, so the row reserves its authored height in design units
+ rather than being sized by the logo — otherwise it shrinks as the card grows and hands
+ the difference to the body below. */
+.onboarding-card-identity {
display: flex;
align-items: center;
gap: 11px;
flex-shrink: 0;
- min-height: calc(44 * var(--ob-u));
- border-top: 1px solid var(--ob-identity-line);
- padding-top: calc(16 * var(--ob-u));
- margin-top: calc(15 * var(--ob-u));
-}
-.onboarding-story-identity > svg { flex-shrink: 0; }
-.onboarding-story-identity strong { font-size: 14px; font-weight: 550; letter-spacing: -0.3px; white-space: nowrap; }
-.onboarding-story-identity > span:last-child { margin-left: auto; font-size: 11px; color: var(--muted); white-space: nowrap; }
+ min-height: calc(39 * var(--ob-u));
+ margin-bottom: calc(11 * var(--ob-u));
+}
+.onboarding-card-identity > svg { flex-shrink: 0; }
+.onboarding-card-name { font-size: 14px; font-weight: 550; letter-spacing: -0.3px; white-space: nowrap; }
+/* The trailing slot. The role is text; the connection puts its switch here instead, and
+ both are pushed to the card's inner edge by the same rule. */
+.onboarding-card-role, .onboarding-card-identity > .onboarding-assistant-enable {
+ margin-left: auto;
+ font-size: 11px;
+ color: var(--muted);
+ white-space: nowrap;
+}
.onboarding-wires { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.onboarding-wire { stroke: var(--ob-wire); stroke-width: 1; }
@@ -382,13 +480,21 @@
.onboarding-pulse-core { stroke: var(--ob-pulse); stroke-width: 1.6; }
.onboarding-pulse-halo { stroke: var(--ob-pulse-glow); stroke-width: 4; }
+/* The caption rides the return wire rather than the container floor: the wire's
+ horizontal run is at y=261 of the 271 viewBox, so this is the same fraction of
+ whatever height the diagram currently has. Centring on that line (rather than
+ sitting under it) is what makes the capsule read as a label cut into the wire,
+ and it holds at every band because both numbers come from the same box.
+ The fill is the page at 90% so the wire stays faintly legible through it
+ instead of being erased — a mask, not a patch. */
.onboarding-story-caption {
position: absolute;
- bottom: -1px;
+ top: calc(100% * 261 / 271);
left: 50%;
- transform: translateX(-50%);
+ transform: translate(-50%, -50%);
padding: 0 12px;
- background: var(--background);
+ border-radius: 999px;
+ background: color-mix(in srgb, var(--background) 90%, transparent);
color: var(--ob-caption);
font-size: 10px;
line-height: 18px;
@@ -399,226 +505,317 @@
/* ---- Access tiles -------------------------------------------------------- */
-/* The outer tile edges land on the two vertical legs of the return wire (x=120 and
- x=760 of the 880 viewBox), so this block is 640/880 of the diagram — and of the
- diagram as it currently is, not of the cap. Both are laid out in the same column, so
- one percentage keeps the edges on the legs at every width: 802.9 at the 1104 cap,
- 674.9 at a 928 content box, and so on down to the phone band. */
-.onboarding-access { width: calc(100% * 640 / 880); text-align: center; padding: 17px 0; }
-.onboarding-access > p { font-size: 12px; line-height: 20px; color: var(--muted); margin-bottom: 14px; }
-.onboarding-access-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 10px; list-style: none; }
+/* "The six access icons form a centred 560px row" — a fixed span, not a fraction of the
+ content box. It is the one block on this screen that does not grow with the window,
+ and deliberately: six destinations a person picks one of read as a row of logos at the
+ size a logo is legible, and stretching them to 1200 turns that row into a rule across
+ the bottom of the page. 20 above the lead and the step's own 20 below the action put
+ the reference's 40 between the two, and the lead's 12 puts its 22 above the row. */
+.onboarding-access { width: 560px; max-width: 100%; margin-top: 20px; text-align: center; padding: 22px 0; }
+.onboarding-access > p { font-size: 12px; line-height: 22px; color: var(--muted); margin-bottom: 12px; }
+/* Six entries on one row: a circular logo container with its name under it, and no
+ plate around the pair. The six read as a row of destinations rather than six
+ buttons competing with the action below, which is what the tiled version did.
+ The tracks take the row whole — the reference's 92.7 pitch is 560/6 — and the tile's
+ own 52 circle is what sets it apart from its neighbour, not a column gap. */
+.onboarding-access-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px 0; list-style: none; }
.onboarding-access-tile {
min-width: 0;
- min-height: 42px;
- padding: 0 10px;
display: flex;
+ flex-direction: column;
align-items: center;
- gap: 9px;
- border: 1px solid var(--border);
- border-radius: 10px;
- background: var(--ob-tile-bg);
+ gap: 10px;
color: var(--ob-tile-label);
font-size: 12px;
line-height: 18px;
- text-align: left;
+ text-align: center;
outline: none;
- transition: background-color 180ms ease;
-}
-.onboarding-access-tile:hover, .onboarding-access-tile:focus-visible, .onboarding-access-tile[data-emphasis="true"] {
- background: var(--ob-tile-hover);
+ border-radius: 10px;
}
+/* One line is reserved so the block is the same height in every language, which is
+ what lets the shared stage floor above be one number rather than one per locale.
+ Nothing is truncated: a longer name would take a second line and grow the row. */
+.onboarding-access-label { min-height: 18px; overflow-wrap: anywhere; }
.onboarding-access-tile:focus-visible { outline: 1px solid var(--mint); outline-offset: 2px; }
.onboarding-access-icon {
- height: 28px;
- width: 28px;
+ height: 52px;
+ width: 52px;
flex-shrink: 0;
- border-radius: 7px;
- background: var(--ob-well);
+ border-radius: 50%;
+ border: 1px solid var(--border);
+ background: var(--ob-tile-bg);
display: grid;
place-items: center;
- transition: transform 180ms ease;
-}
+ transition: transform 180ms ease, background-color 180ms ease, border-color 180ms ease;
+}
+/* The reference draws the Avibe tile as the row's only settled one: its label is the
+ page's own ink where the other five are muted, and its circle already carries the
+ wash the others only take on hover. It reads as "this one is yours" rather than as a
+ sixth connection still to be made. */
+.onboarding-access-tile:not([data-connects="true"]) { color: var(--foreground); }
+.onboarding-access-tile:not([data-connects="true"]) .onboarding-access-icon { background: var(--ob-tile-hover); }
+/* The mint emphasis belongs to the chat apps Avibe connects *to*. The Avibe app is
+ not one of them — it is this product on a phone — so it lights up the same way
+ every other control on this screen does and never borrows the connection colour. */
.onboarding-access-tile:hover .onboarding-access-icon,
.onboarding-access-tile:focus-visible .onboarding-access-icon,
-.onboarding-access-tile[data-emphasis="true"] .onboarding-access-icon { transform: scale(1.18); }
+.onboarding-access-tile[data-emphasis="true"] .onboarding-access-icon { transform: scale(1.12); }
+.onboarding-access-tile[data-connects="true"]:hover .onboarding-access-icon,
+.onboarding-access-tile[data-connects="true"]:focus-visible .onboarding-access-icon,
+.onboarding-access-tile[data-connects="true"][data-emphasis="true"] .onboarding-access-icon {
+ border-color: var(--ob-port-border);
+ background: var(--ob-port);
+}
+.onboarding-access-tile:not([data-connects="true"]):hover .onboarding-access-icon,
+.onboarding-access-tile:not([data-connects="true"]):focus-visible .onboarding-access-icon,
+.onboarding-access-tile:not([data-connects="true"])[data-emphasis="true"] .onboarding-access-icon {
+ background: var(--ob-tile-hover);
+}
/* ---- Primary action ------------------------------------------------------ */
-/* The reference draws this CTA as a flat mint fill — design.pen has no glow on any
- button, and `brand` carries one at rest. The fill, the label pairing and the hover
- stay the variant's; only the halo goes, which is presentation and nothing else. */
-.onboarding-primary-action {
- box-shadow: none;
+/* Both steps put their action under the middle column of the composition above, and at
+ exactly that column's width: 299 of 976, which is the same fraction as the 367 of
+ 1200 the reference draws on a large screen. Expressing it as that fraction — not a
+ fixed 299px — is what keeps the intro's "Get started" and the connection step's
+ "Enter Workbench" on the same coordinates at every width, since both live in the same
+ capped box and take the same percentage of it. The 144 floor still applies once the
+ fraction falls under a comfortable target. */
+.onboarding-action-w {
+ width: calc(100% * 299 / 976);
+ max-width: 100%;
+ min-width: 144px;
+ height: 52px;
border-radius: 10px;
font-size: 13px;
font-weight: 600;
- min-width: 144px;
- height: 44px;
padding: 0 22px;
gap: 10px;
}
+/* The reference draws this CTA as a flat mint fill — design.pen has no glow on any
+ button, and `brand` carries one at rest. The fill, the label pairing and the hover
+ stay the variant's; only the halo goes, which is presentation and nothing else. */
+.onboarding-primary-action {
+ box-shadow: none;
+}
+
+/* The way back is the same object as the way forward, one row down — same box, no
+ fill. Hover stays transparent: a plate lighting up under a secondary control reads
+ as a second CTA competing with the one above it, so the label's contrast carries
+ the affordance alone. One rule for both themes, since `--muted` → `--foreground` is
+ a real contrast step in each; the focus ring is untouched and still draws. */
+.onboarding-back-action {
+ color: var(--muted);
+}
+.onboarding-back-action:hover, .onboarding-back-action:focus-visible {
+ background: transparent;
+ color: var(--foreground);
+}
+
/* ---- Assistant setup ----------------------------------------------------- */
-/* The design spaces the section bar and every row by 12 (frame i3vw9: rows at 41, 141
- and 241 below a 29 tall bar), so one gap owns both.
- sNs1V draws this as a 360 slot holding a 329 bar-and-list, and the 24 below it is the
- step's own gap. That 31 of remainder is the breathing space before the footer, so it
- is reserved here rather than left over: a row that grows for an error or a wrapped
- label takes it back, and the slot grows past 360 only once it is used up. */
-.onboarding-assistants { width: 100%; display: flex; flex-direction: column; gap: 12px; min-height: 360px; }
-.onboarding-assistants-header { display: flex; justify-content: space-between; align-items: center; }
-.onboarding-assistants-header h3 { font-size: 14px; font-weight: 600; color: var(--foreground); }
-/* The design's 88 is the row's own height, border included, so it lives here rather
- than on the inner block; the row still grows when an error is shown. */
-.onboarding-assistant {
+/* The connection step has no section bar above its cards: the page heading already
+ names what the three are, and the reference draws them directly under it. */
+.onboarding-assistants { width: 100%; display: flex; flex-direction: column; }
+/* The three assistants keep the identity the intro gave them: this is the story's own
+ grid, track for track, so Claude/Codex/OpenCode occupy the same x and the same width
+ on both steps and the transition between them reads as the cards staying put while
+ their contents change. The container makes `--ob-card-h`'s width guard resolve
+ against this box, exactly as the story's resolves against the diagram. */
+.onboarding-assistants-list {
+ display: grid;
+ grid-template-columns: repeat(3, minmax(0, 30.6352%));
+ justify-content: space-between;
+ container-type: inline-size;
+}
+/* The card's body reads top to bottom the way the story's does: the identity header,
+ then a state line where the story puts its caption, then the work. The body is the
+ flexible one, so an error or a wrapped action grows downward and the three identity
+ headers stay level with each other and with the intro's. */
+.onboarding-assistant-state {
+ display: flex;
+ align-items: center;
+ flex-wrap: wrap;
+ gap: 8px;
+ flex-shrink: 0;
+ min-height: calc(28 * var(--ob-u));
+}
+.onboarding-assistant-body {
+ flex: 1;
+ min-height: 0;
+ margin-top: calc(6 * var(--ob-u));
display: flex;
flex-direction: column;
- min-height: 88px;
- border-radius: 12px;
- background: var(--surface-2);
- transition: border-color 650ms, box-shadow 650ms;
+ gap: 8px;
}
-/* The design's 20 is measured from the row's outer edge and the row carries a 1px
- border, so the padding inside it is 19. */
-.onboarding-assistant-main { flex: 1; display: flex; align-items: center; gap: 16px; padding: 16px 19px; }
-.onboarding-assistant-logo {
- width: 44px;
- height: 44px;
+/* Two lines at this width, and the `title` carries the rest: a third line would come
+ out of the actions' room, and the card's height is the welcome's, not its own. */
+.onboarding-assistant-note {
+ font-size: 12px;
+ line-height: 18px;
+ color: var(--muted);
+ display: -webkit-box;
+ -webkit-box-orient: vertical;
+ -webkit-line-clamp: 2;
+ line-clamp: 2;
+ overflow: hidden;
+ overflow-wrap: anywhere;
+}
+.onboarding-assistant-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
+.onboarding-assistant-error { font-size: 12px; color: var(--destructive-ink); overflow-wrap: anywhere; }
+.onboarding-assistant-error pre { margin-top: 8px; max-height: 160px; overflow: auto; white-space: pre-wrap; }
+.onboarding-assistant-error summary { margin-top: 8px; cursor: pointer; }
+/* "Open workspace and Back to introduction share a width and stack vertically." The
+ full width is what makes that true: without it this column shrink-wraps its widest
+ child, and the action's own `299/976` then resolves against that shrunken box and
+ collapses to its floor — which is how the connection step's button ended up 144 wide
+ under a 299 one. The reference's 10 between the two rows is this gap. */
+.onboarding-setup-footer { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; }
+
+/* ---- Import notice ------------------------------------------------------- */
+
+/* An offer, not a row of the list above it: a capsule that takes the width of what it
+ says and sits centred under the cards, flat and one line tall. A full-width banner
+ read as a fourth row of the list and as the loudest thing on a step whose subject is
+ the three assistants; a capsule is an aside.
+ The reference gives it 20 above, 44 of its own and 20 below, which is exactly the 64
+ the stage reserves beyond the card — so the offer costs the composition nothing it
+ was not already spending. Nothing below it moves when it is dismissed: the stage that
+ holds it is floored (see `.onboarding-stage`), so what changes is this box's content,
+ not the height of the box it sits in. */
+.onboarding-import-notice {
+ max-width: 100%;
+ min-height: 44px;
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ padding: 0 8px 0 14px;
+ border: 1px solid var(--ob-notice-border);
+ border-radius: 999px;
+ background: var(--ob-notice-bg);
+ box-shadow: none;
+}
+.onboarding-import-notice-icon { flex-shrink: 0; color: var(--mint-ink); }
+.onboarding-import-notice-text {
+ min-width: 0;
+ font-size: 13px;
+ line-height: 20px;
+ color: var(--foreground);
+}
+.onboarding-import-notice-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
+/* A light control rather than a green word: the sentence already carries the mint, and
+ an action a person is meant to press should look pressable. Height and radius sit
+ inside the 44 capsule with 6 of clearance top and bottom. */
+.onboarding-import-notice-action {
+ height: 32px;
+ border-radius: 999px;
+ padding: 0 14px;
+ font-size: 12px;
+ white-space: nowrap;
+}
+.onboarding-import-notice-help { font-size: 12px; color: var(--muted); white-space: nowrap; }
+.onboarding-import-notice-help:hover, .onboarding-import-notice-help:focus-visible { color: var(--foreground); }
+.onboarding-import-notice-dismiss {
flex-shrink: 0;
display: grid;
place-items: center;
- border: 1px solid var(--border);
- border-radius: 10px;
- background: var(--ob-well);
+ width: 24px;
+ height: 24px;
+ margin-right: -4px;
+ border-radius: 6px;
+ color: var(--muted);
+ transition: color 150ms, background 150ms;
+}
+.onboarding-import-notice-dismiss:hover, .onboarding-import-notice-dismiss:focus-visible {
+ color: var(--foreground);
+ background: var(--ob-tile-hover);
}
-.onboarding-assistant-identity { flex: 1; min-width: 0; }
-.onboarding-assistant-identity h3 { font-size: 15px; font-weight: 600; }
-.onboarding-assistant-identity p { font-size: 12px; margin-top: 4px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
-.onboarding-assistant-status, .onboarding-assistant-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
-.onboarding-assistant-error { padding: 0 19px 16px; font-size: 12px; color: var(--destructive-ink); overflow-wrap: anywhere; }
-.onboarding-assistant-error pre { margin-top: 8px; max-height: 160px; overflow: auto; white-space: pre-wrap; }
-.onboarding-assistant-error summary { margin-top: 8px; cursor: pointer; }
-.onboarding-setup-footer { display: flex; flex-direction: column; align-items: center; gap: 10px; }
/* ---- Bands --------------------------------------------------------------- */
-/* Below the design width the collaboration keeps its proportions and only loses
- height; the grid percentages carry the rest. A band's `--ob-diagram-h` is the whole
- 272-row box, of which the cards keep 228 — so 250px is a 210px card. */
+/* The gutter is the only thing a mid-sized window changes. There is nothing between the
+ reference's desktop rows to adapt: the content box stops growing on its own, and the
+ card answers to the window rather than to a breakpoint, so 1366, 1440 and 1920 are
+ three readings of one rule rather than three layouts. */
@media (max-width: 1023px) {
.onboarding-shell { --ob-gutter: 24px; }
}
-@media (max-width: 959px) {
- .onboarding-shell { --ob-diagram-h: 250px; }
- /* Below the proportional bands the card is sized by hand, so the interior returns to
- its authored rhythm instead of following the diagram's width. */
- .onboarding-collaboration-cards { --ob-u: 1px; }
- /* A deliberate narrow-screen adaptation, not the design's number: the title drops to
- 30 here, and its tracking follows it proportionally (-1.6 at 34 is -0.047em). */
- .onboarding-heading h1, .onboarding-heading h2 { font-size: 30px; letter-spacing: -1.4px; }
- .onboarding-collaboration-card { padding: 16px; }
- .onboarding-story-identity { gap: 8px; padding-top: 12px; margin-top: 10px; }
- .onboarding-story-identity strong { font-size: 13px; }
- .onboarding-story-identity > span:last-child { font-size: 10px; }
- .onboarding-story-identity > svg { width: 25px; height: 25px; }
-}
-/* Tablet portrait and below: the caption moves under the icon row so a full label
- wraps instead of shrinking to an unreadable size. */
-@media (max-width: 767px) {
- /* One row owner for all three cards: a wrapped caption must grow its peers'
- status rows too. Independent flex columns only aligned while every label
- fit the same minimum height. Keep the skeleton as the flexible middle row. */
- .onboarding-collaboration-cards { grid-template-rows: max-content minmax(0, 1fr) max-content; }
- .onboarding-collaboration-card {
- display: grid;
- grid-row: 1 / -1;
- grid-template-columns: minmax(0, 1fr);
- grid-template-rows: subgrid;
+
+/* "Stack the three assistant cards below 760px and allow natural scrolling."
+ Both steps stack, not only the connection's. That is the same rule the rest of this
+ sheet is built on — the two steps are one composition seen twice — and it is also
+ what lets the shared reservation keep working here: the reference reaches the same
+ action anchor on a phone by drawing the introduction's stacked cards taller than the
+ connection's by exactly the import band, rather than by leaving a gap where the
+ capsule would be. The floor below says the same thing in one number. */
+@media (max-width: 759px) {
+ .onboarding-shell {
+ --ob-gutter: 20px;
+ /* A stacked card is as tall as the reference draws it, not a share of the window:
+ stacked, the three cards ARE the composition, and a short phone should scroll
+ them rather than compress them. */
+ --ob-card-h: 258px;
+ /* The same reservation, re-derived for the stack: three cards, the two 16 gaps
+ between them, and the connection step's 20 + 90 import band under them. The
+ introduction spends the identical total on three taller cards, so the action
+ stays put between the steps and when the offer is dismissed. */
+ --ob-stage-h: calc(var(--ob-card-h) * 3 + 142px);
}
- .onboarding-story-status { flex-wrap: wrap; row-gap: 4px; min-height: 32px; align-content: flex-start; }
- .onboarding-status-text { order: 3; width: 100%; white-space: normal; overflow-wrap: anywhere; font-size: 11px; line-height: 13px; }
- .onboarding-story-identity { flex-wrap: wrap; gap: 6px; }
- .onboarding-story-identity > span:last-child { margin-left: 0; width: 100%; }
- .onboarding-assistant-main { flex-wrap: wrap; }
- .onboarding-assistant-identity { flex-basis: calc(100% - 60px); }
- .onboarding-assistant-actions { margin-left: auto; flex-wrap: wrap; }
-}
-@media (max-width: 599px) {
- .onboarding-shell { --ob-gutter: 16px; --ob-diagram-h: 300px; }
- /* Phones loosen rather than follow the proportion: -1.2 would be the 34/-1.6 ratio at
- this size, and tight tracking is exactly what costs legibility on a small screen. */
- .onboarding-heading h1, .onboarding-heading h2 { font-size: 25px; line-height: 1.4; letter-spacing: -0.8px; }
- .onboarding-heading h1, .onboarding-heading h2 { min-height: 70px; display: flex; align-items: flex-start; justify-content: center; }
- .onboarding-heading p { min-height: 40px; font-size: 12px; line-height: 20px; }
- .onboarding-welcome, .onboarding-setup { gap: 20px; }
- .onboarding-collaboration-card { padding: 10px 8px; border-radius: 10px; }
- /* The kind glyph stays: it is the one mark that says which of the three kinds of work
- a card is doing, and at 13px it costs a third of a row it already reserves. */
- .onboarding-story-status { min-height: 46px; }
- .onboarding-skeleton { padding-top: 12px; }
- .onboarding-bar { height: 4px; }
- .onboarding-bar-heading { height: 6px; margin-bottom: 8px; }
- .onboarding-skeleton-document > .onboarding-bar:not(.onboarding-bar-heading) { margin-bottom: 5px; }
- .onboarding-skeleton-paragraph { gap: 5px; margin-top: 8px; }
- .onboarding-bar-subheading { height: 5px; }
- .onboarding-skeleton-code { gap: 6px; padding-top: 12px; }
- .onboarding-code-row { gap: 4px; height: 6px; }
- .onboarding-code-number { font-size: 6px; }
- .onboarding-code-bars { gap: 3px; padding-left: 0 !important; }
- .onboarding-skeleton-tests { gap: 7px; padding-top: 12px; }
- .onboarding-test-row { gap: 5px; }
- .onboarding-test-check { width: 10px; height: 10px; border-radius: 2px; }
- .onboarding-test-check svg { width: 8px; height: 8px; }
- /* One arrangement for all three cards, rather than whichever one each name's length
- produces. A card is ~62px wide here, so "Claude Code" wraps and "Codex" does not:
- free flex wrapping therefore put two logos above their names and the third beside
- one, and left the three separators as much as 21px apart. An explicit stack — logo,
- name, role, each on its own row — with the name's box holding the two lines the
- longest of them needs makes the three identities the same height by construction,
- and the skeleton above absorbs the difference, so the separators line up. Nothing
- is truncated or scaled to fit: both lines of a wrapped name are shown. */
- .onboarding-story-identity {
- display: grid;
+ /* Two lines reserved for both, so a heading that wraps in one language or one step
+ and not in the other still leaves the cards on the same line. In `em`, because the
+ size here is a clamp rather than a number. */
+ .onboarding-heading h1, .onboarding-heading h2 { min-height: 2.7em; }
+ .onboarding-heading p { min-height: 3.1em; }
+ /* The story becomes the stack the connection already is. The wires go with the
+ columns — there is no handoff to draw between cards that are above one another —
+ and the caption, which rode the return wire, returns to normal flow under them.
+ The cards take the rest of the reserved height in three equal rows, which is how
+ the introduction reaches the same floor as the connection. */
+ .onboarding-story { flex: 1; align-items: stretch; }
+ .onboarding-collaboration { height: auto; display: flex; flex-direction: column; gap: 16px; }
+ .onboarding-collaboration-cards {
grid-template-columns: minmax(0, 1fr);
- justify-items: start;
- padding-top: 9px;
- margin-top: 8px;
- gap: 4px;
+ grid-template-rows: repeat(3, minmax(0, 1fr));
+ gap: 16px;
+ height: auto;
+ flex: 1;
}
- .onboarding-story-identity > svg { width: 20px; height: 20px; }
- .onboarding-story-identity strong {
- font-size: 11px;
- line-height: 14px;
- letter-spacing: -0.4px;
- white-space: normal;
- min-height: 28px;
+ .onboarding-wires { display: none; }
+ .onboarding-story-caption { position: static; transform: none; align-self: center; }
+ .onboarding-assistants-list { grid-template-columns: minmax(0, 1fr); gap: 16px; }
+ /* Six 52px logos cannot sit on one 350px row, so the row folds into two of three —
+ the reference's own mobile arrangement — and gives up the fixed 560 span with it. */
+ .onboarding-access { width: 100%; margin-top: 12px; padding: 16px 0; }
+ .onboarding-access-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 8px; }
+ /* A 30% action inside a phone's content box is a 107px target sitting alone in the
+ middle of the screen. The column it was aligned to is stacked away here, so the
+ fraction has nothing left to point at and the action takes the width instead. */
+ .onboarding-action-w { width: 100%; }
+ /* Four things do not fit on one 44px line at this width. The sentence and its
+ dismiss keep the first row — a person must be able to read the offer and refuse
+ it without scanning further — and the two actions take the second. Placement is
+ explicit so it does not depend on the order the component happens to render in. */
+ .onboarding-import-notice {
+ display: grid;
+ grid-template-columns: auto minmax(0, 1fr) auto;
+ align-items: center;
+ row-gap: 8px;
+ padding: 10px 12px;
+ /* Two rows is not a capsule: the pill radius would bow the long sides. */
+ border-radius: 14px;
}
- .onboarding-story-identity > span:last-child { font-size: 10px; line-height: 13px; min-height: 13px; }
- /* The one width that deliberately leaves the wire relation: two columns of 640/880 of
- a phone would be ~200px of tiles inside a 360px screen, so below this band the
- block takes the full width and the tiles stay a readable target. */
- .onboarding-access { width: 100%; padding: 10px 0; }
- .onboarding-access-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
- .onboarding-access-tile { min-height: 44px; padding: 0 9px; gap: 8px; }
- /* Small screens let the row follow its wrapped contents instead of the design's 88. */
- .onboarding-assistant { min-height: 0; }
- .onboarding-assistant-main { gap: 12px; padding: 14px 16px; }
- .onboarding-assistant-logo { width: 36px; height: 36px; }
- .onboarding-assistant-identity { flex-basis: calc(100% - 48px); }
- .onboarding-assistant-identity p { white-space: normal; }
- .onboarding-assistant-status, .onboarding-assistant-actions { margin-left: 0; flex-wrap: wrap; }
-}
-/* The narrowest supported width still shows every label; English needs a third line. */
-@media (max-width: 374px) {
- .onboarding-shell { --ob-diagram-h: 320px; }
- .onboarding-story-status { min-height: 62px; }
+ .onboarding-import-notice-icon { grid-area: 1 / 1; }
+ .onboarding-import-notice-text { grid-area: 1 / 2; }
+ .onboarding-import-notice-dismiss { grid-area: 1 / 3; }
+ .onboarding-import-notice-actions { grid-area: 2 / 1 / 2 / -1; flex-wrap: wrap; }
}
/* A short window scrolls. There used to be a `max-height: 760px` rule here that took
the step gaps from 24 to 16 and squeezed the access block, which bought roughly 30px
and spent the design's own spacing to do it — at 1200x800, the reference's own frame
- size, where nothing was wrong. Whitespace is the composition; scrolling is an
- accepted outcome. Only the narrow bands adapt, and they adapt by width. */
+ size, where nothing was wrong. The card now answers to the window height directly, so
+ a short window gets a shorter card instead of a compressed composition; below the
+ stack band it scrolls, which the reference asks for in as many words. */
/* ---- Stopping ------------------------------------------------------------ */
diff --git a/ui/src/components/settings/models/MigrationBanner.tsx b/ui/src/components/settings/models/MigrationBanner.tsx
deleted file mode 100644
index 0aaa929a6..000000000
--- a/ui/src/components/settings/models/MigrationBanner.tsx
+++ /dev/null
@@ -1,129 +0,0 @@
-// First-open-after-upgrade / setup-wizard migration trigger (spec §5-03). A
-// self-contained, dismissible strip: it scans on mount and, when importable
-// native configs exist, offers a one-click 导入中枢 that opens the shared
-// MigrationDialog. Non-nagging — dismissal is persisted by a stable signature of
-// the importable set (see modelHubMigrationDismiss), so it stays hidden until a
-// genuinely new config appears. Self-gates to null when nothing is importable,
-// the scan fails, or it was dismissed, so it's safe to drop anywhere.
-import * as React from 'react';
-import { ArrowDownToLine, X } from 'lucide-react';
-import { useTranslation } from 'react-i18next';
-
-import { Button } from '@/components/ui/button';
-import { isMigrationDismissed, writeMigrationDismissed } from '@/lib/modelHubMigrationDismiss';
-import { MigrationDialog } from './MigrationDialog';
-import { scanMigrationWhenEnabled } from './migrationScan';
-import type { MigrationItem } from './types';
-import { useModelHubCapability } from './useModelHubCapability';
-
-export const MigrationBanner: React.FC<{
- /** Bubble the applied count so a host page can refresh sources/agents. */
- onApplied?: (applied: number) => void;
-}> = ({ onApplied }) => {
- const { t } = useTranslation();
- const modelHubEnabled = useModelHubCapability();
-
- const [importable, setImportable] = React.useState<MigrationItem[]>([]);
- const [dialogOpen, setDialogOpen] = React.useState(false);
- const [dismissed, setDismissed] = React.useState(false);
- const [scanToken, setScanToken] = React.useState(0);
- const aliveRef = React.useRef(true);
- React.useEffect(() => {
- aliveRef.current = true;
- return () => {
- aliveRef.current = false;
- };
- }, []);
-
- React.useEffect(() => {
- if (modelHubEnabled !== true) {
- setImportable([]);
- return;
- }
- let cancelled = false;
- scanMigrationWhenEnabled(true)
- .then((scan) => {
- if (cancelled || !aliveRef.current || scan === null) return;
- // reauth rows need the interactive OAuth flow and can't be bulk-applied,
- // so they don't count as importable (they'd open a dead-end dialog).
- const items = scan.items.filter((i) => i.proposed_action !== 'reauth');
- setImportable(items);
- // Hidden while the current set is a subset of what was dismissed; a
- // genuinely new id/action resurfaces it.
- setDismissed(isMigrationDismissed(items));
- })
- .catch(() => {
- // A rescan (after apply, or a transient outage) that fails must not keep
- // advertising the previous importable rows — self-hide instead of leaving
- // a stale strip that reopens a dead migration dialog.
- if (!cancelled && aliveRef.current) setImportable([]);
- });
- return () => {
- cancelled = true;
- };
- }, [modelHubEnabled, scanToken]);
-
- if (modelHubEnabled !== true || importable.length === 0 || dismissed) return null;
-
- const dismiss = () => {
- writeMigrationDismissed(importable);
- setDismissed(true);
- };
-
- return (
- <>
- {/* Icon + two-line copy + import button + dismiss do not fit one 390px
- row, so phones stack the action under the copy; dismiss stays on the
- title line where it reads as "close this strip". */}
- <div className="flex flex-col gap-2.5 rounded-xl border border-gold/40 bg-gold/[0.08] px-4 py-3 sm:flex-row sm:items-center sm:gap-3">
- <div className="flex min-w-0 flex-1 items-center gap-3">
- <span className="model-hub-ink-gold flex size-9 shrink-0 items-center justify-center rounded-[10px] bg-gold/15">
- <ArrowDownToLine className="size-[18px]" />
- </span>
- <div className="flex min-w-0 flex-1 flex-col gap-0.5">
- <span className="text-[14px] font-semibold text-foreground">{t('settings.models.migrationBanner.title')}</span>
- <span className="text-[12px] leading-relaxed text-muted">
- {t('settings.models.migrationBanner.body', { count: importable.length })}
- </span>
- </div>
- <button
- type="button"
- aria-label={t('settings.models.migrationBanner.dismiss') as string}
- onClick={dismiss}
- className="flex size-10 shrink-0 items-center justify-center rounded-md text-muted transition-colors hover:bg-surface-2 hover:text-foreground sm:hidden"
- >
- <X className="size-4" />
- </button>
- </div>
- <Button
- variant="outline"
- size="sm"
- className="model-hub-ink-gold h-10 shrink-0 border-gold/40 hover:bg-gold/10 sm:h-9"
- onClick={() => setDialogOpen(true)}
- >
- <ArrowDownToLine className="size-3.5" />
- {t('settings.models.migrationBanner.import')}
- </Button>
- <button
- type="button"
- aria-label={t('settings.models.migrationBanner.dismiss') as string}
- onClick={dismiss}
- className="hidden size-7 shrink-0 items-center justify-center rounded-md text-muted transition-colors hover:bg-surface-2 hover:text-foreground sm:flex"
- >
- <X className="size-4" />
- </button>
- </div>
-
- <MigrationDialog
- open={dialogOpen}
- onClose={() => setDialogOpen(false)}
- onApplied={(applied) => {
- setDialogOpen(false);
- // Re-scan so the strip reflects what's left (imported rows drop out).
- setScanToken((n) => n + 1);
- onApplied?.(applied);
- }}
- />
- </>
- );
-};
diff --git a/ui/src/components/settings/models/MigrationDialog.test.tsx b/ui/src/components/settings/models/MigrationDialog.test.tsx
new file mode 100644
index 000000000..aefd92494
--- /dev/null
+++ b/ui/src/components/settings/models/MigrationDialog.test.tsx
@@ -0,0 +1,195 @@
+// @vitest-environment jsdom
+//
+// The settings migration, which is deliberately broader than setup's key-import
+// entry. `keep_native` is a real applied action here — it files the native CLI
+// login as a native_cli-channel source — so narrowing the dialog for one caller
+// must not quietly narrow it for this one. That, and the row's own presentation
+// rules: a provider name only when the server sent the metadata for it, never
+// one inferred from whichever backend happened to hold the key.
+import { cleanup, render, screen, waitFor, within } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { I18nextProvider } from 'react-i18next';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+
+import i18n from '@/i18n';
+import type { MigrationItem } from './types';
+
+const showToast = vi.hoisted(() => vi.fn());
+vi.mock('@/context/ToastContext', () => ({ useToast: () => ({ showToast }) }));
+
+import { MigrationDialog } from './MigrationDialog';
+import { isImportableKey } from './migrationScan';
+import { modelsApi } from './modelsApi';
+
+const SUBSCRIPTION: MigrationItem = {
+ id: 'mig_claude_oauth',
+ backend: 'claude',
+ kind: 'oauth_native',
+ masked_detail: 'Claude 账号登录(OAuth)',
+ proposed_action: 'keep_native',
+ selected: true,
+ notes_key: null,
+ vendor: 'anthropic',
+ display_name: 'Anthropic',
+ masked_credential: null,
+};
+
+const CODEX_KEY: MigrationItem = {
+ id: 'mig_codex_key',
+ backend: 'codex',
+ kind: 'api_key',
+ masked_detail: 'sk-…9f21',
+ proposed_action: 'import',
+ selected: true,
+ notes_key: null,
+ vendor: 'openai',
+ display_name: 'OpenAI',
+ masked_credential: 'sk-…9f21',
+};
+
+// Pre-selected by the scan, and still never batchable: it needs the browser flow.
+const REAUTH: MigrationItem = {
+ id: 'mig_claude_reauth',
+ backend: 'claude',
+ kind: 'api_key',
+ masked_detail: 'sk-ant-…4b7e',
+ proposed_action: 'reauth',
+ selected: true,
+ notes_key: null,
+ vendor: 'anthropic',
+ display_name: 'Anthropic',
+ masked_credential: 'sk-ant-…4b7e',
+};
+
+// An older server that sends none of the presentation metadata.
+const LEGACY: MigrationItem = {
+ id: 'mig_opencode_legacy',
+ backend: 'opencode',
+ kind: 'opencode_provider',
+ masked_detail: '自建中转 · sk-…abcd',
+ proposed_action: 'import',
+ selected: true,
+ notes_key: null,
+};
+
+const SCAN = [SUBSCRIPTION, REAUTH, CODEX_KEY, LEGACY];
+
+const applied: string[][] = [];
+
+const serve = (items: MigrationItem[] = SCAN) => {
+ vi.spyOn(modelsApi, 'scanMigration').mockResolvedValue({ items: items.map((i) => ({ ...i })) });
+ vi.spyOn(modelsApi, 'applyMigration').mockImplementation(async (ids) => {
+ applied.push([...ids]);
+ return { applied: ids.length, sources: [] };
+ });
+};
+
+const renderDialog = (props: Partial<React.ComponentProps<typeof MigrationDialog>> = {}) =>
+ render(
+ <I18nextProvider i18n={i18n}>
+ <MigrationDialog open onClose={vi.fn()} {...props} />
+ </I18nextProvider>,
+ );
+
+beforeEach(async () => {
+ applied.length = 0;
+ await i18n.changeLanguage('en');
+});
+
+afterEach(() => {
+ cleanup();
+ vi.restoreAllMocks();
+ showToast.mockReset();
+});
+
+describe('MigrationDialog — the settings default', () => {
+ it('shows every scanned row, subscriptions included', async () => {
+ serve();
+ renderDialog();
+
+ const dialog = await screen.findByRole('dialog');
+ await waitFor(() => expect(within(dialog).getByText('OpenAI')).toBeTruthy());
+ expect(within(dialog).getByText(/Claude 账号登录/)).toBeTruthy();
+ expect(within(dialog).getByText('Keep native')).toBeTruthy();
+ expect(within(dialog).getByText(/Re-authorize/)).toBeTruthy();
+ });
+
+ it('applies a keep_native row — it is a real action here, not a leftover', async () => {
+ serve();
+ renderDialog();
+ const user = userEvent.setup();
+
+ const dialog = await screen.findByRole('dialog');
+ await waitFor(() => expect(within(dialog).getByText('OpenAI')).toBeTruthy());
+ // Three of the four: everything except the reauth row.
+ await user.click(within(dialog).getByRole('button', { name: /Import 3 items/ }));
+
+ await waitFor(() => expect(applied).toHaveLength(1));
+ expect(applied[0]).toContain('mig_claude_oauth');
+ expect(applied[0]).toEqual(['mig_claude_oauth', 'mig_codex_key', 'mig_opencode_legacy']);
+ });
+
+ it('never submits a reauth row, even pre-selected', async () => {
+ serve();
+ renderDialog();
+ const user = userEvent.setup();
+
+ const dialog = await screen.findByRole('dialog');
+ await waitFor(() => expect(within(dialog).getByText('OpenAI')).toBeTruthy());
+ expect(within(dialog).getByRole('checkbox', { name: /sk-ant-…4b7e/ })).toHaveProperty('disabled', true);
+ await user.click(within(dialog).getByRole('button', { name: /Import 3 items/ }));
+
+ await waitFor(() => expect(applied).toHaveLength(1));
+ expect(applied[0]).not.toContain('mig_claude_reauth');
+ });
+
+ it('narrows to a caller-supplied predicate without changing its own default', async () => {
+ serve();
+ renderDialog({ eligible: isImportableKey });
+
+ const dialog = await screen.findByRole('dialog');
+ await waitFor(() => expect(within(dialog).getByText('OpenAI')).toBeTruthy());
+ expect(within(dialog).queryByText(/Claude 账号登录/)).toBeNull();
+ expect(within(dialog).queryByText(/Re-authorize/)).toBeNull();
+ expect(within(dialog).getByRole('button', { name: /Import 2 items/ })).toBeTruthy();
+ });
+});
+
+describe('MigrationDialog — how a row names itself', () => {
+ it('uses the provider metadata when the server sent it', async () => {
+ serve([CODEX_KEY]);
+ renderDialog();
+
+ const dialog = await screen.findByRole('dialog');
+ await waitFor(() => expect(within(dialog).getByText('OpenAI')).toBeTruthy());
+ // The masked key and the source sit under the provider, so two keys of the
+ // same provider are still tellable apart.
+ expect(within(dialog).getByText('sk-…9f21 · Codex configuration')).toBeTruthy();
+ });
+
+ it('keeps the composed detail when the server sent none', async () => {
+ serve([LEGACY]);
+ renderDialog();
+
+ const dialog = await screen.findByRole('dialog');
+ // The composed detail stays the title, with no provider name above it: the
+ // assistant the key came from is known, the provider it belongs to is not.
+ await waitFor(() => expect(within(dialog).getByText('自建中转 · sk-…abcd')).toBeTruthy());
+ expect(
+ within(dialog).getByRole('checkbox', { name: '自建中转 · sk-…abcd · OpenCode configuration' }),
+ ).toBeTruthy();
+ });
+
+ it('names an OpenCode source generically, never a specific store', async () => {
+ // `backend` + `kind` cannot tell an opencode.json key from an auth.json one,
+ // so the row must not claim either.
+ const fromAuthStore: MigrationItem = { ...LEGACY, id: 'mig_zhipu', vendor: 'zhipu', display_name: 'zhipu', masked_credential: 'sk-…3456' };
+ serve([fromAuthStore]);
+ renderDialog();
+
+ const dialog = await screen.findByRole('dialog');
+ await waitFor(() => expect(within(dialog).getByText('Zhipu AI')).toBeTruthy());
+ expect(within(dialog).getByText('sk-…3456 · OpenCode configuration')).toBeTruthy();
+ expect(within(dialog).queryByText(/auth\.json|opencode\.json/)).toBeNull();
+ });
+});
diff --git a/ui/src/components/settings/models/MigrationDialog.tsx b/ui/src/components/settings/models/MigrationDialog.tsx
index ddcdfb482..168a8cc40 100644
--- a/ui/src/components/settings/models/MigrationDialog.tsx
+++ b/ui/src/components/settings/models/MigrationDialog.tsx
@@ -21,13 +21,35 @@ import {
} from '@/components/ui/dialog';
import { cn } from '@/lib/utils';
import { useToast } from '@/context/ToastContext';
+import { providerLabel, providerVendorId } from '../providers/providerIdentity';
import { modelsApi } from './modelsApi';
import { serverText } from './serverCopy';
+import { VendorGlyph } from './vendorGlyph';
import { ACCENT_ICON, ACCENT_TILE, type Accent } from './vendorMeta';
import type { AgentBackend, MigrationItem, MigrationAction } from './types';
const BACKEND_ORDER: AgentBackend[] = ['claude', 'codex', 'opencode'];
+// Where a row's credential was read from, named only as far as the payload can
+// honestly support. An OpenCode key may come from the config file or from
+// auth.json and `backend` + `kind` cannot tell the two apart, so all three say
+// "<assistant> configuration" rather than claiming a specific store.
+const SOURCE_KEY: Record<AgentBackend, TranslationKey> = {
+ claude: 'settings.models.migration.source.claude',
+ codex: 'settings.models.migration.source.codex',
+ opencode: 'settings.models.migration.source.opencode',
+};
+
+/** The provider a row belongs to, or `null` when the server sent no metadata —
+ * in which case the row falls back to `masked_detail` rather than guessing an
+ * identity from the backend that happened to hold the key. */
+function migrationProvider(item: MigrationItem): string | null {
+ const vendor = item.vendor?.trim() ?? '';
+ const name = item.display_name?.trim() ?? '';
+ if (!vendor && !name) return null;
+ return providerLabel(vendor, name) || null;
+}
+
function migrationVisual(item: MigrationItem): { Icon: React.ComponentType<{ size?: number; className?: string }>; accent: Accent } {
if (item.kind === 'oauth_native') {
if (item.backend === 'codex') return { Icon: Bot, accent: 'gold' };
@@ -53,12 +75,19 @@ const ActionBadge: React.FC<{ action: MigrationAction }> = ({ action }) => {
);
};
-const ItemRow: React.FC<{ item: MigrationItem; onToggle: () => void }> = ({ item, onToggle }) => {
+const ItemRow: React.FC<{ item: MigrationItem; onToggle: () => void; selectable: boolean }> = ({ item, onToggle, selectable }) => {
const { t } = useTranslation();
const { Icon, accent } = migrationVisual(item);
const note = serverText(t, item.notes_key);
- // reauth needs the interactive browser flow, so it can't be bulk-applied here.
- const selectable = item.proposed_action !== 'reauth';
+ const provider = migrationProvider(item);
+ const vendor = item.vendor?.trim();
+ // The masked key and the source it came from are the two things that tell two
+ // rows of the same provider apart. Without provider metadata there is nothing
+ // to put above them, so the composed detail stays the title as before.
+ const title = provider ?? item.masked_detail;
+ const maskedKey = provider ? (item.masked_credential?.trim() || item.masked_detail) : '';
+ const origin = t(SOURCE_KEY[item.backend]);
+ const detail = [maskedKey, origin].filter(Boolean).join(' · ');
return (
// The action badge is nowrap and shrink-0 (up to ~151px), so beside the
// detail column it pushed this row's min-content to 374px — wider than the
@@ -72,12 +101,15 @@ const ItemRow: React.FC<{ item: MigrationItem; onToggle: () => void }> = ({ item
)}
>
<div className="flex min-w-0 flex-1 items-center gap-3">
- <Checkbox checked={item.selected} onCheckedChange={onToggle} disabled={!selectable} label={item.masked_detail} />
+ <Checkbox checked={item.selected} onCheckedChange={onToggle} disabled={!selectable} label={detail ? `${title} · ${detail}` : title} />
<span className={cn('flex size-9 shrink-0 items-center justify-center rounded-[10px]', ACCENT_TILE[accent])}>
- <Icon size={18} className={ACCENT_ICON[accent]} />
+ {vendor
+ ? <VendorGlyph vendor={providerVendorId(vendor)} className={cn('h-[14px] w-auto shrink-0 aspect-[10/7]', ACCENT_ICON[accent])} />
+ : <Icon size={18} className={ACCENT_ICON[accent]} />}
</span>
<div className="flex min-w-0 flex-1 flex-col gap-0.5">
- <span className="truncate text-[14px] font-semibold text-foreground">{item.masked_detail}</span>
+ <span className="truncate text-[14px] font-semibold text-foreground">{title}</span>
+ {detail && <span className="truncate text-[12px] text-muted">{detail}</span>}
{/* `notes_key` is runtime-declared and optional, so an entry this
bundle doesn't carry drops the line instead of printing the key. */}
{note && <span className="truncate text-[12px] text-muted">{note}</span>}
@@ -90,12 +122,21 @@ const ItemRow: React.FC<{ item: MigrationItem; onToggle: () => void }> = ({ item
);
};
+// The broad settings migration: everything the scan returned, minus the reauth
+// rows that need the interactive browser flow and so cannot be bulk-applied.
+const DEFAULT_ELIGIBLE = (item: MigrationItem) => item.proposed_action !== 'reauth';
+
export const MigrationDialog: React.FC<{
open: boolean;
onClose: () => void;
/** Fired after a successful apply so callers can refresh sources/agents. */
onApplied?: (applied: number) => void;
-}> = ({ open, onClose, onApplied }) => {
+ /** Narrows the dialog to one entry's candidates — the rows shown, the rows
+ * selectable and the ids submitted all come from this one predicate, so a
+ * caller's count can never describe a different set than the dialog applies.
+ * Defaults to the broad settings migration. */
+ eligible?: (item: MigrationItem) => boolean;
+}> = ({ open, onClose, onApplied, eligible }) => {
const { t } = useTranslation();
const { showToast } = useToast();
@@ -137,10 +178,12 @@ export const MigrationDialog: React.FC<{
const toggle = (id: string) =>
setItems((prev) => prev.map((i) => (i.id === id ? { ...i, selected: !i.selected } : i)));
- // reauth rows can't be bulk-applied (they need the interactive OAuth flow),
- // and their checkbox is disabled — so exclude them from both the count and
- // the submitted ids, even if a scan returned one pre-selected.
- const appliable = items.filter((i) => i.selected && i.proposed_action !== 'reauth');
+ // One predicate decides what this dialog shows, what a person can tick, and
+ // what gets submitted — a row that fails it is never counted and never sent,
+ // even if the scan returned it pre-selected.
+ const isEligible = eligible ?? DEFAULT_ELIGIBLE;
+ const candidates = eligible ? items.filter(isEligible) : items;
+ const appliable = candidates.filter((i) => i.selected && isEligible(i));
const selectedCount = appliable.length;
const apply = async () => {
@@ -162,7 +205,7 @@ export const MigrationDialog: React.FC<{
const grouped = BACKEND_ORDER.map((backend) => ({
backend,
- rows: items.filter((i) => i.backend === backend),
+ rows: candidates.filter((i) => i.backend === backend),
})).filter((g) => g.rows.length > 0);
return (
@@ -190,7 +233,7 @@ export const MigrationDialog: React.FC<{
{t(`settings.models.backends.${group.backend}`, { defaultValue: group.backend })}
</span>
{group.rows.map((item) => (
- <ItemRow key={item.id} item={item} onToggle={() => toggle(item.id)} />
+ <ItemRow key={item.id} item={item} selectable={isEligible(item)} onToggle={() => toggle(item.id)} />
))}
</div>
))}
diff --git a/ui/src/components/settings/models/migrationScan.test.ts b/ui/src/components/settings/models/migrationScan.test.ts
index 1670212f2..7dbbf5c4a 100644
--- a/ui/src/components/settings/models/migrationScan.test.ts
+++ b/ui/src/components/settings/models/migrationScan.test.ts
@@ -1,6 +1,7 @@
import { describe, expect, it, vi } from 'vitest';
-import { scanMigrationWhenEnabled } from './migrationScan';
+import { importableKeys, isImportableKey, scanMigrationWhenEnabled } from './migrationScan';
+import type { MigrationItem } from './types';
describe('scanMigrationWhenEnabled', () => {
it('does not issue a migration scan while Model Hub is disabled', async () => {
@@ -18,3 +19,70 @@ describe('scanMigrationWhenEnabled', () => {
expect(scan).toHaveBeenCalledTimes(1);
});
});
+
+// The predicate the setup import entry is defined by. It is stated over the real
+// shapes `migration.py` produces, because the mistake it guards against is a
+// plausible-looking `kind === 'api_key'` filter: every OpenCode key-backed import
+// is `opencode_provider`, so that filter silently offers zero OpenCode keys.
+const row = (over: Partial<MigrationItem>): MigrationItem => ({
+ id: 'mig_1',
+ backend: 'opencode',
+ kind: 'opencode_provider',
+ masked_detail: 'zhipuai · sk-…3456',
+ proposed_action: 'import',
+ selected: true,
+ notes_key: null,
+ ...over,
+});
+
+describe('isImportableKey', () => {
+ it('counts an OpenCode key, which never arrives as kind api_key', () => {
+ expect(isImportableKey(row({ backend: 'opencode', kind: 'opencode_provider' }))).toBe(true);
+ });
+
+ it('counts Claude and Codex API keys', () => {
+ expect(isImportableKey(row({ backend: 'claude', kind: 'api_key' }))).toBe(true);
+ expect(isImportableKey(row({ backend: 'codex', kind: 'api_key' }))).toBe(true);
+ });
+
+ it('leaves native subscriptions out — they are kept, not imported', () => {
+ expect(isImportableKey(row({ kind: 'oauth_native', proposed_action: 'keep_native' }))).toBe(false);
+ });
+
+ it('leaves keep_native out even on a key-shaped row', () => {
+ // keep_native is a legitimate applied action in the broader settings
+ // migration; this entry is about keys the gateway takes over, so it is out
+ // here without being disabled there.
+ expect(isImportableKey(row({ kind: 'api_key', proposed_action: 'keep_native' }))).toBe(false);
+ });
+
+ it('leaves reauth out — it needs the interactive flow, not a batch', () => {
+ expect(isImportableKey(row({ kind: 'api_key', proposed_action: 'reauth' }))).toBe(false);
+ });
+
+ it('leaves the reserved controlled_import out', () => {
+ expect(isImportableKey(row({ proposed_action: 'controlled_import' }))).toBe(false);
+ });
+});
+
+describe('importableKeys', () => {
+ it('keeps scan order and drops everything the predicate rejects', () => {
+ const items = [
+ row({ id: 'a', backend: 'claude', kind: 'api_key' }),
+ row({ id: 'b', kind: 'oauth_native', proposed_action: 'keep_native' }),
+ row({ id: 'c', backend: 'codex', kind: 'api_key', proposed_action: 'reauth' }),
+ row({ id: 'd' }),
+ ];
+
+ expect(importableKeys(items).map((i) => i.id)).toEqual(['a', 'd']);
+ });
+
+ it('counts a row the scan pre-selected and one it did not, alike', () => {
+ // The notice reports what CAN be imported; what is ticked is the dialog's
+ // business. A count that silently followed `selected` would disagree with
+ // the rows the dialog then shows.
+ const items = [row({ id: 'a', selected: true }), row({ id: 'b', selected: false })];
+
+ expect(importableKeys(items)).toHaveLength(2);
+ });
+});
diff --git a/ui/src/components/settings/models/migrationScan.ts b/ui/src/components/settings/models/migrationScan.ts
index 9b895f120..bf9806610 100644
--- a/ui/src/components/settings/models/migrationScan.ts
+++ b/ui/src/components/settings/models/migrationScan.ts
@@ -1,9 +1,34 @@
// Whether a migration scan may run at all. Gated on the Model Hub capability so a
-// disabled instance issues no scan request; separated from MigrationBanner so the
-// gate is testable without rendering the strip.
+// disabled instance issues no scan request; separated from its callers so the gate
+// is testable without rendering a surface.
+//
+// This module also owns the one predicate the API-key import entry is defined
+// by. Setup's notice is about keys the gateway can actually take over, so the
+// count, the rows offered, the batch submitted and the remainder after an import
+// all read `isImportableKey` — a number that came from a different rule than the
+// rows behind it is the bug this exists to prevent.
+//
+// It is NOT the settings migration's rule. The broader surface legitimately
+// applies `keep_native` (that path creates a native_cli-channel source, see
+// `migration.py`) and shows `reauth` rows for context; this entry copies neither.
import { modelsApi } from './modelsApi';
+import type { MigrationItem, MigrationKind } from './types';
export const scanMigrationWhenEnabled = async (
enabled: boolean,
scan: typeof modelsApi.scanMigration = modelsApi.scanMigration,
) => (enabled ? scan() : null);
+
+/** The kinds whose credential is a key the gateway can hold. `oauth_native` is
+ * a native subscription token and is excluded by kind, not by action — an
+ * OpenCode key arrives as `opencode_provider`, not `api_key`, so filtering on
+ * `api_key` alone would silently drop every OpenCode import. */
+export const IMPORTABLE_KEY_KINDS: readonly MigrationKind[] = ['api_key', 'opencode_provider'];
+
+/** One candidate the API-key import entry may count, offer, submit and re-count. */
+export const isImportableKey = (item: Pick<MigrationItem, 'proposed_action' | 'kind'>): boolean =>
+ item.proposed_action === 'import' && IMPORTABLE_KEY_KINDS.includes(item.kind);
+
+/** The candidates of a scan, in scan order. */
+export const importableKeys = (items: readonly MigrationItem[]): MigrationItem[] =>
+ items.filter(isImportableKey);
diff --git a/ui/src/components/settings/models/types.ts b/ui/src/components/settings/models/types.ts
index b8a1ff6a1..fc0bb7f4d 100644
--- a/ui/src/components/settings/models/types.ts
+++ b/ui/src/components/settings/models/types.ts
@@ -451,6 +451,17 @@ export type MigrationItem = {
selected: boolean;
/** i18n key for the row's secondary line. */
notes_key?: string | null;
+ /** Provider slug the row's credential belongs to — the join key to the shipped
+ * vendor catalog. Optional: an older server omits it, and a row without it
+ * falls back to `masked_detail` and a generic mark rather than guessing an
+ * identity from `backend`. */
+ vendor?: string;
+ /** Server-side label for the provider. For OpenCode rows this is the raw
+ * provider id, so `providerIdentity` upgrades known ids to a brand label. */
+ display_name?: string;
+ /** The already-masked credential that also appears inside `masked_detail`,
+ * carried separately so provider and key can render as two elements. */
+ masked_credential?: string | null;
};
export type MigrationScan = { items: MigrationItem[] };
diff --git a/ui/src/components/settings/models/vendorMarks.ts b/ui/src/components/settings/models/vendorMarks.ts
index 35d6918d2..52d315380 100644
--- a/ui/src/components/settings/models/vendorMarks.ts
+++ b/ui/src/components/settings/models/vendorMarks.ts
@@ -92,6 +92,12 @@ export const VENDOR_MARKS: Record<string, VendorMark | undefined> = {
path: 'M11.04 19.32Q12 21.51 12 24q0-2.49.93-4.68.96-2.19 2.58-3.81t3.81-2.55Q21.51 12 24 12q-2.49 0-4.68-.93a12.3 12.3 0 0 1-3.81-2.58 12.3 12.3 0 0 1-2.58-3.81Q12 2.49 12 0q0 2.49-.96 4.68-.93 2.19-2.55 3.81a12.3 12.3 0 0 1-3.81 2.58Q2.49 12 0 12q2.49 0 4.68.96 2.19.93 3.81 2.55t2.55 3.81',
ink: [0, 0, 24, 24],
},
+ // Four straight-edged slashes in one path; every segment is a line, so this
+ // ink was computed from the path's own extremes rather than measured.
+ xai: {
+ path: 'M6.469 8.776L16.512 23h-4.464L2.005 8.776H6.47zm-.004 7.9l2.233 3.164L6.467 23H2l4.465-6.324zM22 2.582V23h-3.659V7.764L22 2.582zM22 1l-9.952 14.095-2.233-3.163L17.533 1H22z',
+ ink: [2, 1, 20, 22],
+ },
openai: OPENAI_MARK,
anthropic: ANTHROPIC_MARK,
};
diff --git a/ui/src/components/settings/providers/BackendConnectionForm.tsx b/ui/src/components/settings/providers/BackendConnectionForm.tsx
index ed90384b5..235818cde 100644
--- a/ui/src/components/settings/providers/BackendConnectionForm.tsx
+++ b/ui/src/components/settings/providers/BackendConnectionForm.tsx
@@ -7,7 +7,7 @@ import { errorMessage } from '@/lib/errorMessage';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
-import { SegmentedRadio } from '../shared/SegmentedRadio';
+import { MethodRadio } from './MethodRadio';
import { surfaceBackendNotices } from '../shared/surfaceBackendNotices';
import { useBackendOAuth, type OAuthBackend } from '../oauth/useBackendOAuth';
import { BackendOAuthPanel } from '../BackendOAuthPanel';
@@ -224,13 +224,30 @@ export function BackendConnectionForm({ backend, provider, initialMethod = 'oaut
const credentialLabel = t(compact ? 'onboarding.connection.credentialType' : 'settings.backends.claudeCredentialTypeLabel');
const secretLabel = credential === 'auth_token' && backend === 'claude' ? tokenLabel : apiKeyLabel;
const startLabel = backend === 'claude' ? t('onboarding.connection.claudeSignIn') : backend === 'codex' ? t('onboarding.connection.codexSignIn') : t('settings.backends.opencodeProviderSignIn');
- if (loading) return <div className="connection-loading" role="status"><LoaderCircle className="animate-spin" size={16} />{t('common.loading')}</div>;
+ // Settings keeps its old content-sized loading row. The dialog does not: its
+ // frame is anchored, so loading has to arrive inside the same three regions as
+ // every other state or the tabs and the footer would appear late and move.
+ if (loading && !compact) return <div className="connection-loading" role="status"><LoaderCircle className="animate-spin" size={16} />{t('common.loading')}</div>;
+ // Exactly three children, always in this order: the method row, the scrolling
+ // body, and the action footer. `connection.css` anchors the first and last to
+ // their own rows of the dialog grid, which is what keeps the heading, tabs and
+ // footer still while the body changes underneath them.
return <div className="backend-connection-form">
- {!(compact && active && backend !== 'codex') && (backend !== 'opencode' || (!compact && provider?.oauth_available)) && <SegmentedRadio
- value={method} onChange={(value) => { if (!busy) { pendingConfirmation.current = null; draftTouched.current = true; setMethod(value); setError(''); setConnected(false); } }} disabled={busy}
+ {!(compact && active && backend !== 'codex') && (backend !== 'opencode' || (!compact && provider?.oauth_available)) && <MethodRadio
+ value={method} onChange={(value) => { if (!busy && !loading) { pendingConfirmation.current = null; draftTouched.current = true; setMethod(value); setError(''); setConnected(false); } }} disabled={busy || loading}
ariaLabel={t('onboarding.connection.method')}
options={[{ id: 'oauth', label: backend === 'claude' ? t('onboarding.connection.claudeLogin') : backend === 'codex' ? t('onboarding.connection.codexSignIn') : t('onboarding.connection.subscription') },
{ id: 'api_key', label: backend === 'claude' ? t('onboarding.connection.claudeCredentials') : backend === 'codex' ? t('onboarding.connection.openaiKey') : apiKeyLabel }]} />}
+ <div className="connection-body">
+ {loading && <div className="connection-loading" role="status"><LoaderCircle className="animate-spin" size={16} />{t('common.loading')}</div>}
+ {/* The method's own instructions live here, not in the dialog heading: the
+ heading and description are anchored and method-independent. */}
+ {!loading && compact && <p className="connection-intro">{t(method === 'api_key'
+ ? backend === 'claude' ? 'onboarding.connection.claudeKeyIntro' : backend === 'codex' ? 'onboarding.connection.codexKeyIntro' : 'onboarding.connection.providerKeyIntro'
+ : backend === 'claude' ? active ? 'onboarding.connection.claudeCompleteIntro' : 'onboarding.connection.claudeIntro'
+ : backend === 'codex' ? active ? 'onboarding.connection.codexCompleteIntro' : 'onboarding.connection.codexIntro'
+ : 'onboarding.connection.providerIntro', { name: provider?.name })}</p>}
+ {!loading && <>
{uncertain && <p className="connection-notice">{t('onboarding.connection.uncertain')}</p>}
{native && 'file_store_active' in native && method === 'api_key' && !native.file_store_active && !uncertain && <p className="connection-notice">{t('settings.backends.codexCredentialsStoreKeyringWarn', { store: native.credentials_store })}</p>}
{native && 'settings_conflict' in native && native.settings_conflict && <p className="connection-notice">{t('settings.backends.claudeSettingsConflictTitle')}: {t('settings.backends.claudeSettingsConflictBody', { var: native.settings_env_key_var || 'ANTHROPIC_API_KEY', path: native.settings_path })}</p>}
@@ -257,7 +274,7 @@ export function BackendConnectionForm({ backend, provider, initialMethod = 'oaut
</div>}
</>)}
{method === 'api_key' && <>
- {backend === 'claude' && <div className="connection-field"><Label>{credentialLabel}</Label><SegmentedRadio value={credential} onChange={(value) => { draftTouched.current = true; setCredential(value); }} disabled={busy} ariaLabel={credentialLabel}
+ {backend === 'claude' && <div className="connection-field"><Label>{credentialLabel}</Label><MethodRadio value={credential} onChange={(value) => { draftTouched.current = true; setCredential(value); }} disabled={busy} ariaLabel={credentialLabel}
options={[{ id: 'api_key', label: apiKeyLabel }, { id: 'auth_token', label: tokenLabel }]} /></div>}
<div className="connection-field"><Label htmlFor={`${prefix}-connection-key`}>{secretLabel}</Label>
{hasKey && !editing ? <div className="connection-secret"><KeyRound size={15} /><code>{mask}</code><Button variant="ghost" size="xs" disabled={busy} onClick={() => { draftTouched.current = true; setEditing(true); setKey(''); }}><Pencil size={14} />{t('settings.backends.replaceApiKey')}</Button></div>
@@ -272,6 +289,8 @@ export function BackendConnectionForm({ backend, provider, initialMethod = 'oaut
{!urlValid && <p className="connection-error">{t('onboarding.connection.invalidUrl')}</p>}
</div>
</>}
+ </>}
+ </div>
{(compact || method === 'api_key') && <div className="connection-actions">
{compact && <Button variant="secondary" onClick={onCancel}>{t('common.cancel')}</Button>}
{!compact && hasKey && method === 'api_key' && <Button variant="ghost" disabled={busy} onClick={() => void remove(true)}>{t('settings.backends.claudeApiKeyRemove')}</Button>}
diff --git a/ui/src/components/settings/providers/MethodRadio.tsx b/ui/src/components/settings/providers/MethodRadio.tsx
new file mode 100644
index 000000000..46ce46e46
--- /dev/null
+++ b/ui/src/components/settings/providers/MethodRadio.tsx
@@ -0,0 +1,54 @@
+// Keyboard navigation for the connection dialog's method tabs.
+//
+// `SegmentedRadio` draws a real `radiogroup`, and a radio group is expected to
+// answer arrow keys: Tab reaches the group, arrows move within it, Home and End
+// jump to its ends. The primitive is shared with surfaces outside this lane, so
+// the behavior is added here, around it, rather than inside it.
+//
+// The wrapper is `display: contents` (see `connection.css`): it lays nothing
+// out, so the group keeps its own anchored row in the dialog grid, and keydown
+// still reaches this handler because DOM events do not care about boxes.
+//
+// Selection and focus move together — the approved contract asks for focus to
+// stay on the selected tab, which is also the standard single-select radio
+// behavior a screen reader announces correctly. That is also why the group is a
+// single tab stop: the arrows move from the SELECTION, so the focus Tab leaves
+// behind has to be the selection too.
+import * as React from 'react';
+
+import { SegmentedRadio, type SegmentedRadioProps } from '@/components/ui/segmented';
+
+const BACKWARD = new Set(['ArrowLeft', 'ArrowUp']);
+const FORWARD = new Set(['ArrowRight', 'ArrowDown']);
+
+export function MethodRadio<T extends string>({ value, onChange, options, disabled, ...rest }: SegmentedRadioProps<T>) {
+ const ref = React.useRef<HTMLDivElement>(null);
+ // The other half of the same pattern: a radio group is ONE tab stop, so Tab has to
+ // reach the selection and the arrows continue from there. Without this every option is
+ // its own stop, and a reader can hold focus on a tab that is not the selected one —
+ // which is the state the arrows have no sensible answer for.
+ React.useEffect(() => {
+ const radios = ref.current?.querySelectorAll<HTMLElement>('[role="radio"]') ?? [];
+ radios.forEach((radio, index) => { radio.tabIndex = options[index]?.id === value ? 0 : -1; });
+ }, [options, value]);
+ const onKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {
+ if (disabled || options.length < 2) return;
+ const current = options.findIndex((option) => option.id === value);
+ const index = BACKWARD.has(event.key) ? (current - 1 + options.length) % options.length
+ : FORWARD.has(event.key) ? (current + 1) % options.length
+ : event.key === 'Home' ? 0
+ : event.key === 'End' ? options.length - 1
+ : -1;
+ if (index < 0) return;
+ event.preventDefault();
+ if (index !== current) onChange(options[index].id);
+ // The selected tab keeps the focus, so the next arrow press continues from
+ // where the reader is rather than from wherever Tab last left the group.
+ ref.current?.querySelectorAll<HTMLElement>('[role="radio"]')[index]?.focus();
+ };
+ return (
+ <div ref={ref} className="connection-radio" onKeyDown={onKeyDown}>
+ <SegmentedRadio value={value} onChange={onChange} options={options} disabled={disabled} {...rest} />
+ </div>
+ );
+}
diff --git a/ui/src/components/settings/providers/connection.css b/ui/src/components/settings/providers/connection.css
index 9ba541749..1f1c4bb4d 100644
--- a/ui/src/components/settings/providers/connection.css
+++ b/ui/src/components/settings/providers/connection.css
@@ -1,13 +1,69 @@
-/* Native dialogs eKlyp/Q0wFN/DZesH/JEkvL and their Light variants. */
+/* Native dialogs eKlyp/Q0wFN/DZesH/JEkvL and their Light variants.
+
+ The dialog is a fixed frame, not a box that fits its content. A centred modal
+ with content height moves its own top edge by half of every content change,
+ so switching Subscription/API Key — or a provider list growing by one row —
+ used to slide the heading and the tabs out from under the pointer. Five rows
+ own the layout instead: heading, description, the method row, the only part
+ allowed to scroll, and the action footer. Four of them are a fixed height, so
+ the frame's height is decided by the assistant alone and every anchor inside
+ it holds still while the middle changes.
+
+ The height per assistant is the tallest state each one can reach, so its own
+ middle never scrolls without cause: Codex 580, Claude 620, OpenCode 640 (it
+ also has to hold a provider list). Everything else follows from the rows —
+ 50 + 40 + 40 + 56 of fixed rows, 4 × 20 gaps and 2 × 24 padding leave the
+ middle exactly H − 314. */
.connection-dialog {
--connection-overlay-shadow: #00000088;
--connection-selected-border: #5bffa059;
--connection-logo-well: #ffffff04;
+ --connection-h: 620px;
+ --connection-pad: 24px;
+ --connection-gap: 20px;
+ --connection-head: 50px;
+ --connection-desc: 40px;
+ --connection-controls: 40px;
+ --connection-footer: 56px;
width: min(568px, calc(100vw - 32px)); max-width: 568px;
- padding: 24px; gap: 20px; border-radius: 16px;
+ height: min(var(--connection-h), calc(100dvh - 32px));
+ grid-template-columns: minmax(0, 1fr);
+ grid-template-rows: var(--connection-head) var(--connection-desc) var(--connection-controls) minmax(0, 1fr) var(--connection-footer);
+ /* The frame never scrolls; its middle does. */
+ overflow: hidden;
+ padding: var(--connection-pad); gap: var(--connection-gap); border-radius: 16px;
border-color: var(--border-strong); background: var(--surface-2);
box-shadow: 0 18px 48px var(--desktop-overlay-shadow, var(--connection-overlay-shadow));
}
+.connection-dialog[data-backend='codex'] { --connection-h: 580px; }
+.connection-dialog[data-backend='opencode'] { --connection-h: 640px; }
+/* `display: contents` keeps the form one component while its three regions sit
+ in the dialog's own rows. Settings renders the same form as an ordinary
+ column, so both rules stay scoped to the dialog. */
+.connection-dialog .backend-connection-form,
+.connection-dialog .backend-connection-form > .connection-radio { display: contents; }
+.connection-dialog .connection-heading { grid-row: 1; }
+.connection-dialog .connection-description { grid-row: 2; }
+.connection-dialog .connection-controls,
+.connection-dialog .backend-connection-form > .connection-radio > [role='radiogroup'] { grid-row: 3; }
+.connection-dialog .connection-body { grid-row: 4; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: var(--connection-gap); min-width: 0; }
+.connection-dialog .connection-body.connection-pick { gap: 12px; }
+.connection-dialog .connection-actions { grid-row: 5; margin: 0; }
+.connection-description { line-height: 20px; overflow: hidden; }
+.connection-search { position: relative; display: flex; align-items: center; }
+.connection-search > svg { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
+.connection-search input { height: 40px; padding-left: 34px; border-radius: 9px; }
+.connection-chosen { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 10px 0 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
+.connection-chosen .connection-provider-text { flex: 1; min-width: 0; }
+.connection-provider-mark { display: grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 7px; background: var(--logo-well-background, var(--connection-logo-well)); border: 1px solid var(--border); }
+.connection-provider-mark svg { height: 15px; width: auto; }
+.connection-chosen .connection-provider-mark { width: 24px; height: 24px; border-radius: 6px; }
+.connection-chosen .connection-provider-mark svg { height: 13px; }
+.connection-provider-text { min-width: 0; }
+.connection-provider-text strong { display: block; font-size: 13px; font-weight: 600; }
+.connection-provider-text small { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.connection-provider-configured { flex: none; font-size: 11px; font-weight: 600; color: var(--mint-ink); }
+.connection-dialog .connection-more { width: 100%; justify-content: flex-start; gap: 8px; height: 38px; border-radius: 8px; font-size: 12px; font-weight: 600; color: var(--muted); }
[data-theme='light'] .connection-dialog { --connection-overlay-shadow: #0a0a1424; --connection-selected-border: #10b98160; --connection-logo-well: #eef1f780; }
@media (prefers-color-scheme: light) {
:root:not([data-theme='dark']) .connection-dialog { --connection-overlay-shadow: #0a0a1424; --connection-selected-border: #10b98160; --connection-logo-well: #eef1f780; }
@@ -48,18 +104,35 @@
.connection-waiting svg, .connection-confirmed { color: var(--mint-ink); }
.connection-error, .connection-field .connection-error { color: var(--destructive-ink); font-size: 12px; overflow-wrap: anywhere; }
.connection-notice { font-size: 12px; color: var(--gold-ink); }
-.connection-provider-list { display: flex; flex-direction: column; gap: 10px; max-height: 300px; overflow-y: auto; }
-.connection-provider { width: 100%; min-height: 64px; border-radius: 10px; padding: 10px 14px; gap: 12px; border: 1px solid var(--border); background: var(--surface); display: flex; align-items: center; justify-content: space-between; text-align: left; }
-.connection-provider strong { display: block; font-size: 13px; font-weight: 600; }
-.connection-provider small { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; overflow-wrap: anywhere; }
-.connection-provider svg { flex: none; }
+/* The list does not scroll on its own: the dialog's middle already does, and a
+ scroller inside a scroller gives the same content two ways to move. */
+.connection-provider-list { display: flex; flex-direction: column; gap: 10px; }
+.connection-provider { width: 100%; min-height: 56px; border-radius: 10px; padding: 10px 14px; gap: 12px; border: 1px solid var(--border); background: var(--surface); display: flex; align-items: center; text-align: left; }
+.connection-provider .connection-provider-text { flex: 1; }
+.connection-provider > svg { flex: none; color: var(--muted); }
/* No narrow native frames exist: preserve a centered, scrollable dialog, type,
- focus and reachable actions rather than inheriting the management sheet. */
+ focus and reachable actions rather than inheriting the management sheet.
+ The band is the primitive's own `md` edge, so the sheet shape and the phone
+ metrics change on the same pixel instead of leaving a few widths half-way
+ between the two. The description gets a third line here because the same
+ sentence wraps further at phone width. */
@media (max-width: 767px) {
- .connection-dialog { left: 50%; right: auto; top: 50%; bottom: auto; transform: translate(-50%, -50%); max-width: 568px; width: calc(100vw - 24px); padding: 20px; max-height: calc(100dvh - 24px); border-radius: 16px; }
+ .connection-dialog {
+ left: 50%; right: auto; top: 50%; bottom: auto; transform: translate(-50%, -50%);
+ max-width: 568px; width: calc(100vw - 32px); border-radius: 16px;
+ --connection-pad: 20px; --connection-gap: 16px; --connection-desc: 60px;
+ }
.connection-dialog > div[aria-hidden='true']:first-child { display: none; }
.connection-heading h2 { font-size: 19px; }
}
+/* A short window keeps every anchor the contract names — tabs, close, footer —
+ and pays for them out of the parts that are only breathing room. The middle
+ is `minmax(0, 1fr)`, so it is what gives way, down to nothing, before the
+ frame is ever asked to exceed the viewport. */
+@media (max-height: 640px) {
+ .connection-dialog { --connection-pad: 16px; --connection-gap: 12px; --connection-head: 44px; --connection-desc: 40px; }
+ .connection-heading h2 { font-size: 18px; line-height: 22px; }
+}
.connection-auth-steps > div > a[data-slot="button"] { height: 38px; border-radius: 8px; padding: 0 14px; font-size: 13px; font-weight: 600; }
.connection-dialog .connection-auth-steps > div > a:not(:has(+ button)) { height: 38px; border-radius: 8px; padding: 0 14px; font-size: 13px; font-weight: 600; }
diff --git a/ui/src/components/settings/providers/providerIdentity.test.ts b/ui/src/components/settings/providers/providerIdentity.test.ts
new file mode 100644
index 000000000..8282b7110
--- /dev/null
+++ b/ui/src/components/settings/providers/providerIdentity.test.ts
@@ -0,0 +1,102 @@
+// The promise `providerIdentity.ts` makes in its own doc comment: every alias
+// target and every shortlist entry names a real row in the shipped catalog, so
+// the table and the catalog cannot drift apart silently. A dropped catalog row
+// would otherwise surface as a provider rendering its internal slug — or, for
+// the shortlist, as a setup picker with a hole in it.
+import { describe, expect, it } from 'vitest';
+
+import { apiKeyVendorPreset } from '../models/apiKeyVendors';
+import {
+ CATALOG_VENDOR_IDS,
+ PROVIDER_VENDOR_ALIAS,
+ SETUP_PRIMARY_VENDORS,
+ providerLabel,
+ providerVendorId,
+ setupPrimaryRank,
+} from './providerIdentity';
+
+describe('the alias table', () => {
+ it('resolves every alias to a catalog row that exists', () => {
+ for (const target of Object.values(PROVIDER_VENDOR_ALIAS)) {
+ expect(CATALOG_VENDOR_IDS, `alias target ${target}`).toContain(target);
+ }
+ });
+
+ it('never aliases an id the catalog already owns', () => {
+ // An id that is itself a catalog row must resolve to itself; aliasing one
+ // would silently redirect a provider onto a neighbour's brand.
+ for (const source of Object.keys(PROVIDER_VENDOR_ALIAS)) {
+ expect(CATALOG_VENDOR_IDS, `alias source ${source}`).not.toContain(source);
+ }
+ });
+
+ it('maps the ids OpenCode actually uses onto their catalog brand', () => {
+ expect(providerVendorId('google')).toBe('gemini');
+ expect(providerVendorId('moonshotai')).toBe('kimi');
+ expect(providerVendorId('alibaba-cn')).toBe('qwen');
+ expect(providerVendorId('zhipu')).toBe('zhipuai');
+ });
+
+ it('leaves an unrecognised provider as itself', () => {
+ // A self-hosted or relay provider should show its own slug, not borrow one.
+ expect(providerVendorId('my-internal-relay')).toBe('my-internal-relay');
+ });
+
+ it('reads ids case- and whitespace-insensitively', () => {
+ expect(providerVendorId(' Google ')).toBe('gemini');
+ });
+});
+
+describe('providerLabel', () => {
+ it('keeps a server label that says more than the id', () => {
+ expect(providerLabel('alibaba-cn', 'Alibaba (China)')).toBe('Alibaba (China)');
+ });
+
+ it('keeps a non-ASCII server label untouched', () => {
+ expect(providerLabel('zhipu', '智谱 AI')).toBe('智谱 AI');
+ });
+
+ it('falls back to the catalog brand when the server only echoed the id', () => {
+ // Every OpenCode migration row does exactly this, which is why the row
+ // cannot be trusted to be friendly on its own.
+ const label = providerLabel('moonshot', 'moonshot');
+ expect(label).toBe(apiKeyVendorPreset('kimi')?.label);
+ expect(label).not.toBe('moonshot');
+ });
+
+ it('falls back to the catalog brand when the server sent nothing', () => {
+ expect(providerLabel('google')).toBe(apiKeyVendorPreset('gemini')?.label);
+ });
+
+ it('keeps the slug when neither the catalog nor the server knows the name', () => {
+ expect(providerLabel('my-internal-relay')).toBe('my-internal-relay');
+ expect(providerLabel('my-internal-relay', 'my-internal-relay')).toBe('my-internal-relay');
+ });
+});
+
+describe('the setup shortlist', () => {
+ it('names only providers the shipped catalog can render', () => {
+ for (const vendor of SETUP_PRIMARY_VENDORS) {
+ expect(apiKeyVendorPreset(vendor), `shortlist entry ${vendor}`).not.toBeNull();
+ }
+ });
+
+ it('lists each provider once', () => {
+ expect(new Set(SETUP_PRIMARY_VENDORS).size).toBe(SETUP_PRIMARY_VENDORS.length);
+ });
+
+ it('ranks in declared order, which is the order setup renders', () => {
+ const ranks = SETUP_PRIMARY_VENDORS.map((id) => setupPrimaryRank(id));
+ expect(ranks).toEqual(SETUP_PRIMARY_VENDORS.map((_, index) => index));
+ });
+
+ it('ranks an aliased id where its brand ranks', () => {
+ // An OpenCode `google` row belongs next to Gemini, not under More.
+ expect(setupPrimaryRank('google')).toBe(setupPrimaryRank('gemini'));
+ expect(setupPrimaryRank('alibaba-cn')).toBe(setupPrimaryRank('qwen'));
+ });
+
+ it('puts everything else under More rather than inventing a rank', () => {
+ expect(setupPrimaryRank('my-internal-relay')).toBeNull();
+ });
+});
diff --git a/ui/src/components/settings/providers/providerIdentity.ts b/ui/src/components/settings/providers/providerIdentity.ts
new file mode 100644
index 000000000..f1152b226
--- /dev/null
+++ b/ui/src/components/settings/providers/providerIdentity.ts
@@ -0,0 +1,87 @@
+// One place that turns a provider *id* into the two things a surface needs to
+// present it: a brand label a person recognises, and the catalog vendor id its
+// artwork is filed under.
+//
+// It exists because the same provider arrives under different ids depending on
+// who is talking. The shipped API-key catalog files Gemini under `gemini`; an
+// OpenCode config calls the same provider `google`, Kimi `moonshot` and Qwen
+// `alibaba-cn`. A surface that renders those ids raw shows an internal name, and
+// one that maps them ad hoc grows a second, drifting table. So the alias lives
+// here once, and both the setup provider picker and the import rows read it.
+//
+// The mapping only ever *adds* recognition: an id with no alias and no catalog
+// row keeps its own slug, which is what a self-hosted or relay provider should
+// show. Nothing here infers identity from a backend name.
+import {
+ apiKeyVendorPreset,
+ API_KEY_VENDOR_PRESETS,
+} from '../models/apiKeyVendors';
+
+/** OpenCode/native provider id → the id the shipped vendor catalog files the
+ * same brand under. Only ids that genuinely name the same provider belong
+ * here; ids that already match the catalog need no row. */
+export const PROVIDER_VENDOR_ALIAS: Readonly<Record<string, string>> = {
+ google: 'gemini',
+ 'google-vertex': 'gemini',
+ moonshot: 'kimi',
+ moonshotai: 'kimi',
+ 'alibaba-cn': 'qwen',
+ alibaba: 'qwen',
+ dashscope: 'qwen',
+ zhipu: 'zhipuai',
+};
+
+/** The catalog vendor id a provider id resolves to — itself when it is already
+ * a catalog id or has no known alias. */
+export function providerVendorId(providerId: string): string {
+ const id = providerId.trim().toLowerCase();
+ return PROVIDER_VENDOR_ALIAS[id] ?? id;
+}
+
+/**
+ * What to call a provider.
+ *
+ * `serverName` wins when the server already sent something friendlier than the
+ * id — the OpenCode catalog does this ("Alibaba (China)"), and Claude/Codex
+ * migration rows carry real brand names ("Anthropic", "ChatGPT"). When the
+ * server only echoed the id back (every OpenCode migration row does), the
+ * shipped catalog supplies the brand label instead. An id nothing recognises
+ * keeps its slug rather than borrowing a neighbour's name.
+ */
+export function providerLabel(providerId: string, serverName?: string | null): string {
+ const id = providerId.trim();
+ const name = serverName?.trim();
+ if (name && name.toLowerCase() !== id.toLowerCase()) return name;
+ return apiKeyVendorPreset(providerVendorId(id))?.label ?? name ?? id;
+}
+
+/**
+ * The API-key providers the setup picker offers before More.
+ *
+ * Declared here rather than taken as "the catalog's first eight": the catalog is
+ * ranked for the Add-API-key dropdown, and setup's shortlist is its own product
+ * decision. `providerIdentity.test.ts` holds every entry to a real catalog row,
+ * so the two cannot drift apart silently.
+ */
+export const SETUP_PRIMARY_VENDORS: readonly string[] = [
+ 'openai',
+ 'anthropic',
+ 'xai',
+ 'gemini',
+ 'deepseek',
+ 'qwen',
+ 'kimi',
+ 'openrouter',
+];
+
+const PRIMARY_RANK = new Map(SETUP_PRIMARY_VENDORS.map((id, index) => [id, index]));
+
+/** Rank within the primary shortlist, or `null` for a provider that belongs
+ * under More. Resolves through the alias, so an OpenCode `google` row ranks
+ * where Gemini does. */
+export function setupPrimaryRank(providerId: string): number | null {
+ return PRIMARY_RANK.get(providerVendorId(providerId)) ?? null;
+}
+
+/** Every catalog id, for tests and for callers that need the full vendor set. */
+export const CATALOG_VENDOR_IDS: readonly string[] = API_KEY_VENDOR_PRESETS.map((preset) => preset.id);
diff --git a/ui/src/components/steps/AgentDetection.tsx b/ui/src/components/steps/AgentDetection.tsx
index 902adbbd9..8bedf41e5 100644
--- a/ui/src/components/steps/AgentDetection.tsx
+++ b/ui/src/components/steps/AgentDetection.tsx
@@ -24,7 +24,7 @@ import { BackendConnectionDialog } from '../onboarding/BackendConnectionDialog';
import type { BackendConnectionState } from '@/context/ApiContext';
import { setConfigField } from '@/lib/configMutations';
import { OpencodePermissionSetup } from '../settings/shared/OpencodePermissionSetup';
-import { MigrationBanner } from '../settings/models/MigrationBanner';
+import { ImportKeysNotice } from '../onboarding/ImportKeysNotice';
import { useModelHubCapability } from '../settings/models/useModelHubCapability';
import type { BackendId as RuntimeBackendId } from '../settings/shared/useBackendRuntime';
import { useOpencodePermission } from '../settings/shared/useOpencodePermission';
@@ -309,12 +309,6 @@ export const AgentDetection: React.FC<AgentDetectionProps> = ({ data, onNext, on
// Page mode keeps the existing settings shell — render the inner content only
const Inner = isPage ? (
<>
- {/* Setup-wizard migration trigger (spec §5-03): offer to import pre-existing
- native CLI configs into the Hub. Wizard-only — the Settings → Backends
- page already surfaces this via BackendSupplyModeCard. Self-hides when
- nothing is importable or the hub isn't reachable yet. */}
- {!isPage && modelHubEnabled === true && <MigrationBanner />}
-
<div className="flex flex-col gap-3 rounded-xl border border-border bg-background px-4 py-3 sm:flex-row sm:items-center sm:justify-between">
<div className="min-w-0">
<span className="text-[11px] font-semibold uppercase tracking-[0.12em] text-muted">
@@ -503,17 +497,17 @@ export const AgentDetection: React.FC<AgentDetectionProps> = ({ data, onNext, on
<h2>{t('onboarding.setup.title')}</h2>
<p>{t('onboarding.setup.subtitle')}</p>
</header>
- {modelHubEnabled === true && <MigrationBanner />}
+ {/* The stage both steps share, so the action below lands on the same
+ coordinates as the intro's — see `.onboarding-stage` in onboarding.css. */}
+ <div className="onboarding-stage">
<div className="onboarding-assistants">
- <div className="onboarding-assistants-header">
- <h3>{t('onboarding.setup.assistants')}</h3>
- {/* n4ATm draws this as an outlined control on its own surface, not a bare
- text button: `secondary` is that pair, and `xs` its 12px/12px metrics. */}
- <Button type="button" variant="secondary" size="xs" onClick={() => void detectAll()}
- disabled={isAnyInstalling || Object.values(detectingAgents).some(Boolean)}>
- <RefreshCw size={14} />{t('agentDetection.rescan')}
- </Button>
- </div>
+ {/* No section bar above the cards: the page heading already names the three,
+ and a second title here pushed them below the line the intro left them on.
+ Rescanning moved to the footer hint, which is where a person looks once the
+ cards have not told them what they expected. */}
+ {/* The intro's three tracks, reused rather than restated — see
+ `.onboarding-assistants-list` in onboarding.css. */}
+ <div className="onboarding-assistants-list">
{ASSISTANT_ORDER.map((name) => {
const agent = agents[name];
const result = installResults[name];
@@ -547,21 +541,37 @@ export const AgentDetection: React.FC<AgentDetectionProps> = ({ data, onNext, on
}} />}
/>;
})}
+ </div>
</div>
<OpencodePermissionSetup cliReady={opencodeAgent?.status === 'ok'}
permissionAllowed={permission.permissionAllowed} state={permission.state} message={permission.message}
onSetup={() => void permission.setupPermission().then(() => refreshConnection('opencode'))} className="w-full" />
+ {/* Wizard-only: the offer to take over API keys already on this machine.
+ Settings → Backends reaches the same migration through
+ BackendSupplyModeCard, with its broader scope intact. Self-hides when
+ there is nothing importable or the gateway isn't reachable. */}
+ {modelHubEnabled === true && <ImportKeysNotice />}
+ </div>
{providerDialog}
{completionRecovery}
<div className="onboarding-setup-footer">
- <Button type="button" variant="brand" className="group onboarding-primary-action" onClick={() => void handlePrimaryAction()}
+ <Button type="button" variant="brand" className="group onboarding-action-w onboarding-primary-action" onClick={() => void handlePrimaryAction()}
disabled={!canContinue || syncing || entering || Boolean(completionRecovery)}>
{t(entering ? 'onboarding.connection.connecting' : 'onboarding.connection.enter')}
<ArrowRight size={16} className="motion-safe:transition-transform motion-safe:duration-180 motion-safe:group-hover:translate-x-1" />
</Button>
- <p className="text-center text-xs text-muted">{t(readyBackends.some((name) => connections[name]?.ready) ? 'onboarding.connection.entryReady' : canContinue ? 'onboarding.connection.entryStopped' : 'onboarding.connection.entryHint')}</p>
+ <p className="text-center text-xs text-muted">
+ {t(readyBackends.some((name) => connections[name]?.ready) ? 'onboarding.connection.entryReady' : canContinue ? 'onboarding.connection.entryStopped' : 'onboarding.connection.entryHint')}{' '}
+ {/* The whole-screen rescan, kept as part of the sentence that explains why a
+ card might not say what was expected rather than as a control competing
+ with the action above it. */}
+ <Button type="button" variant="link" size="xs" className="h-auto p-0 align-baseline text-xs"
+ onClick={() => void detectAll()} disabled={isAnyInstalling || Object.values(detectingAgents).some(Boolean)}>
+ <RefreshCw size={12} />{t('agentDetection.rescan')}
+ </Button>
+ </p>
{entryError && <div role="alert" className="connection-error">{entryError} <Button variant="link" size="sm" disabled={entering} onClick={() => void handlePrimaryAction()}>{t('common.retry')}</Button></div>}
- {onBack && <Button type="button" variant="ghost" size="sm" disabled={syncing || entering || Boolean(completionRecovery)} onClick={() => onBack({ agents })}><ArrowLeft size={14} />{t('common.back')}</Button>}
+ {onBack && <Button type="button" variant="ghost" className="onboarding-action-w onboarding-back-action" disabled={syncing || entering || Boolean(completionRecovery)} onClick={() => onBack({ agents })}><ArrowLeft size={14} />{t('common.back')}</Button>}
</div>
</div>
);
diff --git a/ui/src/components/steps/Welcome.tsx b/ui/src/components/steps/Welcome.tsx
index 7a1b91980..f17de5785 100644
--- a/ui/src/components/steps/Welcome.tsx
+++ b/ui/src/components/steps/Welcome.tsx
@@ -45,9 +45,12 @@ export function Welcome({ data, onNext }: WelcomeProps) {
<h1>{t('onboarding.welcome.title')}</h1>
<p>{t('onboarding.welcome.subtitle')}</p>
</header>
- <CollaborationStory />
- <AccessTiles />
- <Button type="button" variant="brand" className="group onboarding-primary-action" onClick={() => void start()} disabled={pending}>
+ {/* The stage both steps share, so this button and the setup step's land on the
+ same coordinates — see `.onboarding-stage` in onboarding.css. */}
+ <div className="onboarding-stage">
+ <CollaborationStory />
+ </div>
+ <Button type="button" variant="brand" className="group onboarding-action-w onboarding-primary-action" onClick={() => void start()} disabled={pending}>
{t(pending ? 'onboarding.welcome.detecting' : error ? 'common.retry' : 'onboarding.welcome.getStarted')}
{pending ? <RefreshCw size={16} className="motion-safe:animate-spin" /> : <ArrowRight size={16} className="motion-safe:transition-transform motion-safe:duration-180 motion-safe:group-hover:translate-x-1" />}
</Button>
@@ -55,6 +58,11 @@ export function Welcome({ data, onNext }: WelcomeProps) {
<p>{t('onboarding.welcome.detectionFailed')}</p>
<details className="mt-2 max-w-xl break-words"><summary>{t('onboarding.details')}</summary>{error}</details>
</div>}
+ {/* Below the action, not inside the stage: where a person can reach Avibe from is
+ an epilogue to the introduction, and the reference draws it under the button
+ for that reason. Keeping it out of the stage is also what lets the stage be a
+ shared reservation — the connection step has no counterpart to this block. */}
+ <AccessTiles />
</div>
);
}
diff --git a/ui/src/components/ui/info-hint.tsx b/ui/src/components/ui/info-hint.tsx
index d815cb4ee..85292abeb 100644
--- a/ui/src/components/ui/info-hint.tsx
+++ b/ui/src/components/ui/info-hint.tsx
@@ -11,6 +11,14 @@ interface InfoHintProps {
label: string;
className?: string;
align?: 'start' | 'center' | 'end';
+ /** What the trigger draws. Defaults to the ⓘ badge. A caller that already has
+ * its own wording ("What is Model Gateway?") passes that text instead. */
+ trigger?: React.ReactNode;
+ /** Also reveal on mouse hover and keyboard focus. Off by default so existing
+ * hints keep their click-only behavior. */
+ hover?: boolean;
+ /** Width of the revealed panel. Defaults to the 16rem hint width. */
+ contentClassName?: string;
}
// A small "ⓘ" affordance that reveals a hint on click / tap — uniform across
@@ -20,8 +28,46 @@ interface InfoHintProps {
// as a sibling of the dialog, where Radix marks it aria-hidden/inert — the same
// reason AgentRoutePicker takes a `modal` prop. Click toggles; Escape / outside
// click dismiss via Radix.
-export const InfoHint: React.FC<InfoHintProps> = ({ content, label, className, align = 'start' }) => {
+export const InfoHint: React.FC<InfoHintProps> = ({
+ content,
+ label,
+ className,
+ align = 'start',
+ trigger,
+ hover = false,
+ contentClassName,
+}) => {
const [open, setOpen] = React.useState(false);
+ // Hover-close is deferred so the pointer can travel from the trigger into the
+ // panel — which is portalled, so no wrapper can hold both.
+ const closeTimer = React.useRef<number | null>(null);
+ const cancelClose = React.useCallback(() => {
+ if (closeTimer.current !== null) {
+ window.clearTimeout(closeTimer.current);
+ closeTimer.current = null;
+ }
+ }, []);
+ const scheduleClose = React.useCallback(() => {
+ cancelClose();
+ closeTimer.current = window.setTimeout(() => setOpen(false), 120);
+ }, [cancelClose]);
+ React.useEffect(() => cancelClose, [cancelClose]);
+
+ // Only a mouse hovers. A tap reports pointerType 'touch' and is left to the
+ // click handler, so a phone gets one clean toggle instead of open-then-close.
+ const hoverProps = hover
+ ? {
+ onPointerEnter: (event: React.PointerEvent) => {
+ if (event.pointerType === 'mouse') { cancelClose(); setOpen(true); }
+ },
+ onPointerLeave: (event: React.PointerEvent) => {
+ if (event.pointerType === 'mouse') scheduleClose();
+ },
+ onFocus: () => { cancelClose(); setOpen(true); },
+ onBlur: scheduleClose,
+ }
+ : {};
+
return (
<Popover open={open} onOpenChange={setOpen} modal>
<PopoverTrigger asChild>
@@ -29,12 +75,15 @@ export const InfoHint: React.FC<InfoHintProps> = ({ content, label, className, a
type="button"
aria-label={label}
onClick={() => setOpen((prev) => !prev)}
+ {...hoverProps}
className={cn(
- 'inline-flex size-4 shrink-0 items-center justify-center rounded-full text-muted outline-none transition hover:text-foreground focus-visible:text-foreground',
+ trigger
+ ? 'inline-flex shrink-0 items-center outline-none transition'
+ : 'inline-flex size-4 shrink-0 items-center justify-center rounded-full text-muted outline-none transition hover:text-foreground focus-visible:text-foreground',
className,
)}
>
- <Info className="size-3.5" />
+ {trigger ?? <Info className="size-3.5" />}
</button>
</PopoverTrigger>
<PopoverContent
@@ -42,7 +91,9 @@ export const InfoHint: React.FC<InfoHintProps> = ({ content, label, className, a
sideOffset={6}
// Don't steal focus from the trigger on hover-open, so tabbing isn't trapped.
onOpenAutoFocus={(event) => event.preventDefault()}
- className="w-64 p-3 text-[12px] font-normal leading-relaxed text-muted"
+ onPointerEnter={hover ? cancelClose : undefined}
+ onPointerLeave={hover ? scheduleClose : undefined}
+ className={cn('w-64 p-3 text-[12px] font-normal leading-relaxed text-muted', contentClassName)}
>
{content}
</PopoverContent>
diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.json
index 81b90cd23..6b32fc40a 100644
--- a/ui/src/i18n/en.json
+++ b/ui/src/i18n/en.json
@@ -1680,6 +1680,11 @@
"keepNativeSanctioned": "Stays in the CLI's own store (sanctioned)",
"keepNativeReauthHint": "Kept native; add a separate gateway-held subscription explicitly",
"fromOpencode": "From the opencode config"
+ },
+ "source": {
+ "claude": "Claude Code configuration",
+ "codex": "Codex configuration",
+ "opencode": "OpenCode configuration"
}
},
"backends": {
@@ -1909,12 +1914,17 @@
"unresolved": "Still not working",
"failed": "Couldn't do that, please retry"
},
- "migrationBanner": {
- "title": "Native configs ready to import",
- "body_one": "Found {{count}} native sign-in or API key you can move into the gateway.",
- "body_other": "Found {{count}} native sign-ins or API keys you can move into the gateway.",
- "import": "Import to gateway",
- "dismiss": "Dismiss"
+ "importNotice": {
+ "found_one": "Found {{count}} API key to import into Model Gateway",
+ "found_other": "Found {{count}} API keys to import into Model Gateway",
+ "review": "Review and import",
+ "help": "What is Model Gateway?",
+ "helpBody": "Model Gateway keeps your API keys and model connections in one place, so every AI assistant has a single way in. Importing only copies the keys you select; your existing configuration is left as it is.",
+ "dismiss": "Dismiss import notice",
+ "imported_one": "Imported {{count}} API key into Model Gateway",
+ "imported_other": "Imported {{count}} API keys into Model Gateway",
+ "importedRemaining_one": "Imported {{imported}} · {{count}} API key still available",
+ "importedRemaining_other": "Imported {{imported}} · {{count}} API keys still available"
}
}
},
@@ -5282,7 +5292,6 @@
"setup": {
"title": "Connect AI. Get to work",
"subtitle": "Install an assistant and connect a model to get started",
- "assistants": "AI assistants",
"claudeDescription": "Anthropic’s coding assistant",
"codexDescription": "OpenAI’s coding assistant",
"opencodeDescription": "An open-source coding assistant for multiple models",
@@ -5333,18 +5342,11 @@
"unconfirmed": "The effective connection could not be confirmed. Try again.",
"uncertain": "Credentials may be in the system keychain. Their effective state could not be confirmed. You can sign in or save a key here.",
"partial": "Saved with a warning. Review the connection state.",
+ "dialogTitle": "Connect {{name}}",
+ "claudeDialogIntro": "Claude Code can use your Anthropic subscription or an API Key. Choose one below.",
+ "codexDialogIntro": "Codex can use your ChatGPT subscription or an OpenAI API Key. Choose one below.",
+ "opencodeDialogIntro": "OpenCode works with many providers. Choose one, then sign in or save its API Key.",
"removeConfirm": "Remove this saved credential?",
- "claudeTitle": "Add Claude subscription",
- "claudeComplete": "Complete Claude authorization",
- "claudeKeyTitle": "Add Anthropic API Key",
- "claudeTokenTitle": "Add Claude Auth Token",
- "codexTitle": "Add ChatGPT subscription",
- "codexKeyTitle": "Add OpenAI API Key",
- "opencodeTitle": "Add a subscription for OpenCode",
- "opencodeKeyTitle": "Add an API Key for OpenCode",
- "providerTitle": "Connect {{name}}",
- "providerKeyTitle": "Add {{name}} API Key",
- "target": "For {{name}}",
"claudeIntro": "Authorize Claude Code with your Anthropic account",
"claudeCompleteIntro": "Approve access in your browser, then paste the returned authorization code",
"claudeKeyIntro": "Connect Anthropic or a compatible provider to Claude Code",
@@ -5360,8 +5362,9 @@
"entryReady": "Connected. You can start working.",
"entryStopped": "Connection saved. Enter workspace to start the service.",
"entryFailed": "A ready assistant could not be confirmed. Refresh and try again.",
- "addSubscription": "Add subscription",
+ "addSubscription": "Add subscription / sign in",
"addKey": "Add API Key",
+ "moreProviders": "More providers",
"refresh": "Refresh connection",
"enableFirst": "Enable this assistant to connect it.",
"checkSettings": "Review settings",
@@ -5372,9 +5375,10 @@
"openDevice": "2 Open the sign-in page and enter the code",
"openChatGPT": "Open ChatGPT sign-in",
"openProvider": "Open authorization page",
- "codexComplete": "Connect your ChatGPT subscription",
"codexCompleteIntro": "Sign in through your browser. Codex will connect automatically",
"providerIntro": "Connect {{name}} to OpenCode",
+ "providerKeyIntro": "Save an API Key for {{name}} in OpenCode",
+ "providerConfigured": "Connected",
"providerCredentialHint": "This credential is only used for {{name}} in OpenCode",
"providerDescription": "Provider · For OpenCode",
"modelTitle": "Choose a model for this connection",
diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.json
index e354fb648..aab16126c 100644
--- a/ui/src/i18n/zh.json
+++ b/ui/src/i18n/zh.json
@@ -1680,6 +1680,11 @@
"keepNativeSanctioned": "保留在 Agent 自己的凭据库(受官方认可)",
"keepNativeReauthHint": "保留给 Agent 管理;需要模型网关管理时另行添加订阅",
"fromOpencode": "来自 opencode 配置"
+ },
+ "source": {
+ "claude": "Claude Code 配置",
+ "codex": "Codex 配置",
+ "opencode": "OpenCode 配置"
}
},
"backends": {
@@ -1909,12 +1914,17 @@
"unresolved": "仍然不可用",
"failed": "没能处理,请重试"
},
- "migrationBanner": {
- "title": "发现可导入模型网关的 Agent 配置",
- "body_one": "检测到 {{count}} 项登录 / API Key 可导入模型网关。",
- "body_other": "检测到 {{count}} 项登录 / API Key 可导入模型网关。",
- "import": "导入模型网关",
- "dismiss": "忽略"
+ "importNotice": {
+ "found_one": "发现 {{count}} 个可导入模型网关的 API Key",
+ "found_other": "发现 {{count}} 个可导入模型网关的 API Key",
+ "review": "查看并导入",
+ "help": "什么是模型网关?",
+ "helpBody": "模型网关集中管理 API Key 和模型连接,为 AI 助手提供统一的模型入口。导入只会复制你选中的 API Key,原有配置会保留。",
+ "dismiss": "关闭导入提示",
+ "imported_one": "已导入 {{count}} 个 API Key 到模型网关",
+ "imported_other": "已导入 {{count}} 个 API Key 到模型网关",
+ "importedRemaining_one": "已导入 {{imported}} 个 · 还有 {{count}} 个可导入",
+ "importedRemaining_other": "已导入 {{imported}} 个 · 还有 {{count}} 个可导入"
}
}
},
@@ -5280,9 +5290,8 @@
"wechat": "微信"
},
"setup": {
- "title": "连接AI,开始工作",
+ "title": "连接 AI,开始工作",
"subtitle": "安装助手,连接模型,即可开始工作",
- "assistants": "AI 助手",
"claudeDescription": "Anthropic 的 AI 编程助手",
"codexDescription": "OpenAI 的 AI 编程助手",
"opencodeDescription": "开源 AI 编程助手,支持多种模型",
@@ -5333,18 +5342,11 @@
"unconfirmed": "无法确认当前生效的连接,请重试",
"uncertain": "凭据可能保存在系统钥匙串,暂时无法确认其生效状态。可以在此登录或保存密钥",
"partial": "已保存,但有警告,请检查连接状态",
+ "dialogTitle": "连接 {{name}}",
+ "claudeDialogIntro": "Claude Code 可以使用 Anthropic 订阅,也可以使用 API Key,在下方选择一种。",
+ "codexDialogIntro": "Codex 可以使用 ChatGPT 订阅,也可以使用 OpenAI API Key,在下方选择一种。",
+ "opencodeDialogIntro": "OpenCode 支持多家服务商,先选择一家,再登录或保存它的 API Key。",
"removeConfirm": "移除此已保存凭据?",
- "claudeTitle": "添加 Claude 订阅",
- "claudeComplete": "完成 Claude 授权",
- "claudeKeyTitle": "添加 Anthropic API Key",
- "claudeTokenTitle": "添加 Claude Auth Token",
- "codexTitle": "添加 ChatGPT 订阅",
- "codexKeyTitle": "添加 OpenAI API Key",
- "opencodeTitle": "为 OpenCode 添加订阅",
- "opencodeKeyTitle": "为 OpenCode 添加 API Key",
- "providerTitle": "连接 {{name}}",
- "providerKeyTitle": "添加 {{name}} API Key",
- "target": "用于 {{name}}",
"claudeIntro": "使用 Anthropic 账号授权 Claude Code",
"claudeCompleteIntro": "在浏览器中批准访问,然后粘贴返回的授权码",
"claudeKeyIntro": "为 Claude Code 连接 Anthropic 或兼容服务商",
@@ -5360,8 +5362,9 @@
"entryReady": "已连接,可以开始工作",
"entryStopped": "连接已保存,进入工作台即可启动服务",
"entryFailed": "无法确认可用助手,请刷新后重试",
- "addSubscription": "添加订阅",
+ "addSubscription": "添加订阅 / 登录",
"addKey": "添加 API Key",
+ "moreProviders": "更多服务商",
"refresh": "刷新连接",
"enableFirst": "请先启用此助手以连接",
"checkSettings": "检查设置",
@@ -5372,9 +5375,10 @@
"openDevice": "2 打开授权页并输入设备码",
"openChatGPT": "打开 ChatGPT 授权页",
"openProvider": "打开授权页",
- "codexComplete": "连接 ChatGPT 订阅",
"codexCompleteIntro": "在浏览器中登录,授权完成后 Codex 将自动连接",
"providerIntro": "将 {{name}} 连接到 OpenCode",
+ "providerKeyIntro": "在 OpenCode 中保存 {{name}} 的 API Key",
+ "providerConfigured": "已连接",
"providerCredentialHint": "此凭据只用于 OpenCode 中的 {{name}} 服务商",
"providerDescription": "服务商 · 用于 OpenCode",
"modelTitle": "为此连接选择模型",