fix(browser): show browser profiles inline and tidy settings copy (#65174)

This commit is contained in:
usrnk1
2026-11-20 14:44:55 +01:00
committed by GitHub
Unverified
parent 85951cb086
commit 22ecda23a9
3 changed files with 37 additions and 29 deletions
@@ -106,9 +106,9 @@ story("each switch is named by its row's title, and each row says what it does i
// The switch's accessible name is the row's title, so a screen reader hears what the row shows.
for (const [id, title, description] of [
["settings-browser-links", "Open links in OpenCode", "Hold Shift and click a link to use your default browser."],
["settings-browser-remote", "Share sign-ins with remote servers", "Only turn on for servers you trust, since they can access your signed\u2011in sites."],
["settings-browser-agent-pages", "Open browser automatically", "Show the tab when the agent opens a page or file for you."],
["settings-browser-links", "Open links in OpenCode", "Hold Shift and click a link to use your default browser"],
["settings-browser-remote", "Share sign-ins with remote servers", "Only turn on for servers you trust, since they can access your signed\u2011in sites"],
["settings-browser-agent-pages", "Open browser automatically", "Show the tab when the agent opens a page or file for you"],
] as const) {
await expect(row(id).locator('[data-slot="settings-row-title"]')).toHaveText(title)
await expect(row(id).locator('[data-slot="settings-row-description"]')).toHaveText(description)
@@ -116,7 +116,7 @@ story("each switch is named by its row's title, and each row says what it does i
}
await expect(row("settings-browser-extensions").locator('[data-slot="settings-row-description"]')).toHaveText(
"Install from the Chrome Web Store, Edge Add-ons, or your other browsers.",
"Install from the Chrome Web Store, Edge Add-ons, or your other browsers",
)
const sites = view.root.getByRole("region", { name: "Site permissions", exact: true })
await expect(sites.locator('[data-slot="settings-row-title"]')).toHaveText("No saved permissions")
@@ -128,7 +128,7 @@ story("the red button asks first: Cancel, Escape, Enter on Cancel and a click ou
const cancel = view.confirm.getByRole("button", { name: "Cancel", exact: true })
const confirm = view.confirm.getByRole("button", { name: "Clear data", exact: true })
await expect(view.data.getByText("0 cookies. Sign-ins are shared across sessions.", { exact: true })).toBeVisible()
await expect(view.data.getByText("0 cookies. Sign-ins are shared across sessions", { exact: true })).toBeVisible()
await view.clear.click()
// One title, one line, two buttons: no close button, as the app's other confirmations.
await expect(view.confirm.getByText("This signs you out of all sites and deletes history in OpenCode, leaving your other browsers untouched.", { exact: true })).toBeVisible()
@@ -156,7 +156,7 @@ story("the red button asks first: Cancel, Escape, Enter on Cancel and a click ou
}
// Nothing ran: the row still shows the count, the window's last pages are there, and the button is ready again.
await expect(view.data.getByText("0 cookies. Sign-ins are shared across sessions.", { exact: true })).toBeVisible()
await expect(view.data.getByText("0 cookies. Sign-ins are shared across sessions", { exact: true })).toBeVisible()
await expect(view.visits).toHaveText("1")
await expect(view.clear).toBeEnabled()
@@ -203,7 +203,7 @@ for (const [name, file, line] of [
const view = await open(page, { target: "settings-browser-cookies", file })
await expect(view.root.getByText("Import cookie file", { exact: true })).toBeVisible()
await expect(view.root.getByText("Supports cookies.txt or JSON from browser extensions or Playwright.", { exact: true })).toBeVisible()
await expect(view.root.getByText("Supports cookies.txt or JSON from browser extensions or Playwright", { exact: true })).toBeVisible()
await view.root.getByRole("button", { name: "Choose file", exact: true }).click()
await expect(view.root.getByText(line, { exact: true })).toBeVisible()
})
+8 -8
View File
@@ -191,9 +191,9 @@ export default {
"settings.open": "Browser settings",
"settings.unavailable": "The browser is available in the desktop app.",
"settings.links.title": "Open links in OpenCode",
"settings.links.description": "Hold Shift and click a link to use your default browser.",
"settings.links.description": "Hold Shift and click a link to use your default browser",
"settings.remote.title": "Share sign-ins with remote servers",
"settings.remote.description": "Only turn on for servers you trust, since they can access your signed\u2011in sites.",
"settings.remote.description": "Only turn on for servers you trust, since they can access your signed\u2011in sites",
"settings.import.title": "Import from another browser",
"settings.import.none": "No other browser found on this computer",
"settings.import.choose": "Choose sites",
@@ -211,14 +211,14 @@ export default {
"sites.empty": "This profile has no sites to import.",
"sites.unmatched": "No site matches your search.",
"settings.import.file.title": "Import cookie file",
"settings.import.file.description": "Supports cookies.txt or JSON from browser extensions or Playwright.",
"settings.import.file.description": "Supports cookies.txt or JSON from browser extensions or Playwright",
"settings.import.file.action": "Choose file",
"settings.import.file.pick": "Choose a cookie file",
"settings.extensions.title": "Extensions",
"settings.extensions.note": "Some extensions may not work here yet.",
"settings.extensions.note": "Some extensions may not work here yet",
"settings.extensions.add.title": "Add an extension",
"settings.extensions.confirm.title": 'Add "{{name}}"?',
"settings.extensions.add.description": "Install from the Chrome Web Store, Edge Add-ons, or your other browsers.",
"settings.extensions.add.description": "Install from the Chrome Web Store, Edge Add-ons, or your other browsers",
"settings.extensions.dialog.description": "Extensions run on every page in this browser.",
"settings.extensions.store.label": "Link to the extension",
"settings.extensions.store.placeholder": "Paste a Chrome Web Store or Edge Add-ons link",
@@ -235,8 +235,8 @@ export default {
"settings.extensions.enable": "Turn on {{name}}",
"settings.data.title": "Browser data",
"settings.cookies.title": "Cookies and site data",
"settings.cookies.count.one": "{{count}} cookie. Sign-ins are shared across sessions.",
"settings.cookies.count.other": "{{count}} cookies. Sign-ins are shared across sessions.",
"settings.cookies.count.one": "{{count}} cookie. Sign-ins are shared across sessions",
"settings.cookies.count.other": "{{count}} cookies. Sign-ins are shared across sessions",
"settings.cookies.clear": "Clear browsing data",
"settings.cleared": "Cleared browsing data.",
"settings.cleared.history": "Cleared sign-ins and site data, but history could not be cleared.",
@@ -254,7 +254,7 @@ export default {
"menu.pageUnavailable": "This page can't open in your default browser",
"menu.privateAddress": "This address only works in OpenCode's browser.",
"settings.agentPages.title": "Open browser automatically",
"settings.agentPages.description": "Show the tab when the agent opens a page or file for you.",
"settings.agentPages.description": "Show the tab when the agent opens a page or file for you",
"tab.activity": "The agent used this tab",
"menu.failed": "Couldn't open this page in your default browser.",
"menu.copyLink": "Copy link address",
+22 -14
View File
@@ -109,8 +109,7 @@ export default function BrowserSettings(props: { target?: string }) {
image={choice.source.icon}
fallback="outline-globe"
name={choice.source.name}
detail={choice.source.profiles.length > 1 ? choice.profile.name : undefined}
keep
aside={choice.source.profiles.length > 1 ? choice.profile.name : undefined}
message={
jobs.importing(choice) ? jobs.notice() : results().get(resultKey(choice.source.id, choice.profile.id))
}
@@ -230,13 +229,18 @@ export default function BrowserSettings(props: { target?: string }) {
</ui.SettingsSection>
<ui.SettingsSection>
<ui.SettingsRow
title={
<Identity
fallback="file-document"
name={ctx.t("settings.import.file.title")}
detail={ctx.t("settings.import.file.description")}
message={fileMessage()}
/>
title={ctx.t("settings.import.file.title")}
description={
<Show when={fileMessage()} fallback={ctx.t("settings.import.file.description")}>
{(message) => (
<span
role={message().error ? "alert" : "status"}
classList={{ "text-v2-state-fg-danger": message().error }}
>
{message().text}
</span>
)}
</Show>
}
>
<ui.Button
@@ -836,16 +840,16 @@ function Verdict(props: { level: ExtensionCompatibility["level"] }) {
}
/**
* A row's subject: its icon, its name, and under it a detail or what the last action on it did; with `keep`, the
* detail stays before the message, so rows of one browser still say which profile each is.
* A row's subject: its icon, its name with an optional muted aside beside it, and under it a detail, a note, or what
* the last action on it did.
*/
function Identity(props: {
image?: string
fallback: IconName
name: string
aside?: string
detail?: string
note?: JSX.Element
keep?: boolean
message?: JobMessage
}) {
const note = children(() => props.note)
@@ -854,7 +858,12 @@ function Identity(props: {
<span class="flex min-w-0 items-center gap-3">
<Glyph image={props.image} fallback={props.fallback} />
<span class="flex min-w-0 flex-col gap-1">
<span class="truncate">{props.name}</span>
<span class="flex min-w-0 items-baseline gap-1.5">
<span class="truncate">{props.name}</span>
<Show when={props.aside}>
{(aside) => <span class="min-w-0 truncate font-[440] text-v2-text-text-muted">{aside()}</span>}
</Show>
</span>
<Show
when={props.message}
fallback={
@@ -871,7 +880,6 @@ function Identity(props: {
>
{(message) => (
<span class="text-[13px] font-[440] leading-[var(--line-height-base)]">
<Show when={props.keep && props.detail}>{(detail) => <span class="text-v2-text-text-muted">{detail()} · </span>}</Show>
<span
role={message().error ? "alert" : "status"}
classList={{ "text-v2-state-fg-danger": message().error, "text-v2-text-text-muted": !message().error }}