Improve toast layout and dev tools (#6782)

Restyle shared Sonner toasts (wrapping, bottom-chrome clearance with mobileOffset, custom delete-failure footer) and add a dev-only Dev Tools settings pane gated behind import.meta.env.DEV. Removes dead devToolsSearch locale keys, aligns toast description opacity/width with sibling toasts, and uses a distinct nav icon for Dev Tools.
This commit is contained in:
Kaylee
2026-06-29 17:02:44 -07:00
committed by GitHub
parent a27278dbea
commit a06a17b6ee
17 changed files with 893 additions and 87 deletions
+46
View File
@@ -295,6 +295,52 @@
--linear-priority-bar-inactive-fill: color-mix(in srgb, lch(39.576 1.25 282) 62%, transparent);
}
[data-sonner-toaster] {
font-family: var(--font-sans);
}
[data-sonner-toaster] [data-sonner-toast][data-styled='true'] {
align-items: flex-start;
flex-wrap: wrap;
gap: 10px;
padding: 14px 16px;
box-shadow: 0 10px 24px rgb(0 0 0 / 0.18);
}
[data-sonner-toaster] [data-sonner-toast][data-styled='true'] [data-icon] {
margin-top: 2px;
}
[data-sonner-toaster] [data-sonner-toast][data-styled='true'] [data-content] {
min-width: 0;
flex: 1 1 calc(100% - 30px);
gap: 6px;
}
[data-sonner-toaster] [data-sonner-toast][data-styled='true'] [data-button] {
/* Why: Sonner's native action slots otherwise share the copy row and squeeze
long notices; indent the wrapped footer to align with text after the icon. */
margin-top: 2px;
margin-left: 26px;
margin-right: 0;
}
[data-sonner-toaster] [data-sonner-toast][data-styled='true'] [data-button] ~ [data-button] {
margin-left: 0;
}
[data-sonner-toaster] [data-sonner-toast][data-styled='true'] [data-title] {
line-height: 1.35;
}
[data-sonner-toaster] [data-sonner-toast][data-styled='true'] [data-description] {
/* Why: match the 80% body-copy opacity used by the custom-React toast bodies
(delete-worktree-failure, local-base-ref-suggestion) so string and JSX
descriptions read at the same weight. */
color: color-mix(in srgb, var(--popover-foreground) 80%, transparent);
line-height: 1.45;
}
[data-sonner-toaster] [data-sonner-toast][data-styled='true'] [data-close-button] {
/* Why: Sonner's dark-theme defaults can resolve the close icon and button
background to the same color; keep the X readable on both Orca themes. */
@@ -0,0 +1,248 @@
import { toast } from 'sonner'
import { Bell, Info, OctagonX, Sparkles, Trash2 } from 'lucide-react'
import { Button } from '../ui/button'
import { Badge } from '../ui/badge'
import { SettingsSubsectionHeader } from './SettingsFormControls'
import { showDeleteWorktreeFailureToast } from '../sidebar/delete-worktree-failure-toast'
import { showLocalBaseRefUpdateSuggestionToast } from '../sidebar/local-base-ref-suggestion-toast'
import { translate } from '@/i18n/i18n'
import type { AppState } from '@/store/types'
const LONG_WORKSPACE_NAME = 'feature/dev-toast-layout-with-a-long-workspace-name'
const DEV_TOAST_DESCRIPTION =
'This is intentionally long copy for checking width, line wrapping, icon alignment, action placement, and close-button overlap in the shared toast frame.'
type DevToastAction = {
title: string
description: string
icon: React.ReactNode
onClick: () => void
}
function DevToastActionButton({ action }: { action: DevToastAction }): React.JSX.Element {
return (
<Button
type="button"
variant="outline"
size="sm"
onClick={action.onClick}
className="h-auto min-h-9 justify-start gap-2 whitespace-normal px-3 py-2 text-left"
>
<span className="mt-0.5 text-muted-foreground">{action.icon}</span>
<span className="min-w-0">
<span className="block text-sm font-medium text-foreground">{action.title}</span>
<span className="block text-xs leading-4 text-muted-foreground">{action.description}</span>
</span>
</Button>
)
}
function showNativeActionToast(): void {
toast.info(
translate(
'auto.components.settings.DevToolsPane.nativeActionLayoutCheck',
'Native action layout check'
),
{
description: DEV_TOAST_DESCRIPTION,
duration: 10000,
cancel: {
label: translate('auto.components.settings.DevToolsPane.secondary', 'Secondary'),
onClick: () =>
toast.message(
translate(
'auto.components.settings.DevToolsPane.secondaryActionClicked',
'Secondary action clicked'
)
)
},
action: {
label: translate('auto.components.settings.DevToolsPane.primaryAction', 'Primary action'),
onClick: () =>
toast.success(
translate(
'auto.components.settings.DevToolsPane.primaryActionClicked',
'Primary action clicked'
)
)
}
}
)
}
function showBehindBaseRefToast(): void {
let enabled = false
showLocalBaseRefUpdateSuggestionToast(
{
baseRef: 'origin/canary',
localBranch: 'canary',
behind: 2
},
{
updateSettings: async (updates) => {
enabled = updates.refreshLocalBaseRefOnWorktreeCreate === true
},
getSettings: () =>
({
refreshLocalBaseRefOnWorktreeCreate: enabled
}) as AppState['settings'],
openSettingsPage: () => {},
openSettingsTarget: () => {}
}
)
}
function showDeleteFailureToast(): void {
showDeleteWorktreeFailureToast({
error: translate(
'auto.components.settings.DevToolsPane.branchHasChanges',
'branch has changes'
),
canForceDelete: true,
onViewChanges: () =>
toast.message(
translate(
'auto.components.settings.DevToolsPane.viewChangesClicked',
'View Changes clicked'
)
),
onForceDelete: () =>
toast.error(
translate(
'auto.components.settings.DevToolsPane.forceDeleteClicked',
'Force Delete clicked'
),
{
description: translate(
'auto.components.settings.DevToolsPane.devOnlyCallback',
'Dev-only callback.'
)
}
),
worktreeId: 'dev-toast-worktree',
worktreeName: LONG_WORKSPACE_NAME
})
}
export function DevToolsPane(): React.JSX.Element {
const actions: DevToastAction[] = [
{
title: translate('auto.components.settings.DevToolsPane.infoToast', 'Info toast'),
description: translate(
'auto.components.settings.DevToolsPane.infoToastDescription',
'Long informational copy with no explicit action.'
),
icon: <Info className="size-4" />,
onClick: () =>
toast.info(
translate(
'auto.components.settings.DevToolsPane.localCanaryBehind',
'Local canary is behind origin/canary'
),
{
description: DEV_TOAST_DESCRIPTION,
duration: 10000
}
)
},
{
title: translate('auto.components.settings.DevToolsPane.successToast', 'Success toast'),
description: translate(
'auto.components.settings.DevToolsPane.successToastDescription',
'Short confirmation state.'
),
icon: <Sparkles className="size-4" />,
onClick: () =>
toast.success(
translate('auto.components.settings.DevToolsPane.settingsSaved', 'Settings saved'),
{
description: translate(
'auto.components.settings.DevToolsPane.shortSuccessCopy',
'Short success copy.'
)
}
)
},
{
title: translate('auto.components.settings.DevToolsPane.errorToast', 'Error toast'),
description: translate(
'auto.components.settings.DevToolsPane.errorToastDescription',
'Long error copy without recovery actions.'
),
icon: <OctagonX className="size-4" />,
onClick: () =>
toast.error(
translate(
'auto.components.settings.DevToolsPane.failedToSyncWorkspaceMetadata',
'Failed to sync workspace metadata'
),
{
description: DEV_TOAST_DESCRIPTION,
duration: 10000
}
)
},
{
title: translate(
'auto.components.settings.DevToolsPane.nativeActionToast',
'Native action toast'
),
description: translate(
'auto.components.settings.DevToolsPane.nativeActionToastDescription',
'Uses Sonner action and cancel slots.'
),
icon: <Bell className="size-4" />,
onClick: showNativeActionToast
},
{
title: translate(
'auto.components.settings.DevToolsPane.deleteFailureToast',
'Delete failure toast'
),
description: translate(
'auto.components.settings.DevToolsPane.deleteFailureToastDescription',
'Custom footer with View and Force Delete.'
),
icon: <Trash2 className="size-4" />,
onClick: showDeleteFailureToast
},
{
title: translate(
'auto.components.settings.DevToolsPane.behindBaseRefToast',
'Behind base ref toast'
),
description: translate(
'auto.components.settings.DevToolsPane.behindBaseRefToastDescription',
'Persistent prompt with an inline Settings link and footer action.'
),
icon: <Bell className="size-4" />,
onClick: showBehindBaseRefToast
}
]
return (
<section className="space-y-3">
<div className="flex items-start justify-between gap-3">
<SettingsSubsectionHeader
title={translate(
'auto.components.settings.DevToolsPane.notificationPlayground',
'Notification playground'
)}
description={translate(
'auto.components.settings.DevToolsPane.notificationPlaygroundDescription',
'Dev-only triggers for checking toast layout, recovery actions, and long-copy wrapping.'
)}
/>
<Badge variant="outline" className="mt-0.5">
{translate('auto.components.settings.DevToolsPane.devOnly', 'Dev only')}
</Badge>
</div>
<div className="grid gap-2 sm:grid-cols-2">
{actions.map((action) => (
<DevToastActionButton key={action.title} action={action} />
))}
</div>
</section>
)
}
@@ -1,5 +1,14 @@
/* eslint-disable max-lines */
import { useCallback, useEffect, useMemo, useRef, useState, type MutableRefObject } from 'react'
import {
lazy,
Suspense,
useCallback,
useEffect,
useMemo,
useRef,
useState,
type MutableRefObject
} from 'react'
import { toast } from 'sonner'
import type { GlobalSettings, OrcaHooks } from '../../../../shared/types'
import type { SpeechModelState } from '../../../../shared/speech-types'
@@ -91,6 +100,10 @@ import {
import { translate } from '@/i18n/i18n'
import { getProjectHostSetupProjectionFromState } from '../../store/selectors'
const DevToolsPane = import.meta.env.DEV
? lazy(() => import('./DevToolsPane').then((module) => ({ default: module.DevToolsPane })))
: null
const SETTINGS_NAV_GROUPS = [
{
id: 'capabilities',
@@ -1564,6 +1577,24 @@ function Settings(): React.JSX.Element {
</SettingsSection>
) : null}
{showDesktopOnlySettings && import.meta.env.DEV ? (
<SettingsSection
id="dev"
title={translate('auto.components.settings.Settings.dev', 'Dev Tools')}
description={translate(
'auto.components.settings.Settings.devDescription',
'Dev-only tools for exercising UI states.'
)}
searchEntries={getSectionSearchEntries('dev')}
>
{DevToolsPane && isSectionMounted('dev') ? (
<Suspense fallback={null}>
<DevToolsPane />
</Suspense>
) : null}
</SettingsSection>
) : null}
<SettingsSection
id="experimental"
title={translate('auto.components.settings.Settings.8b017f2506', 'Experimental')}
@@ -0,0 +1,119 @@
// @vitest-environment happy-dom
import { act } from 'react'
import { createRoot, type Root } from 'react-dom/client'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { toast } from 'sonner'
import { showDeleteWorktreeFailureToast } from './delete-worktree-failure-toast'
vi.mock('sonner', () => ({
toast: {
error: vi.fn(),
info: vi.fn(),
dismiss: vi.fn()
}
}))
const mountedRoots: Root[] = []
function renderToastBody(method: 'error' | 'info'): HTMLElement {
const description = vi.mocked(toast[method]).mock.calls.at(-1)?.[1]
?.description as React.ReactElement
const container = document.createElement('div')
document.body.appendChild(container)
const root = createRoot(container)
mountedRoots.push(root)
act(() => {
root.render(description)
})
return container
}
function clickButton(container: HTMLElement, label: string): void {
const button = [...container.querySelectorAll('button')].find(
(el) => el.textContent?.trim() === label
)
if (!button) {
throw new Error(`button "${label}" not found`)
}
act(() => {
button.dispatchEvent(new MouseEvent('click', { bubbles: true }))
})
}
afterEach(() => {
mountedRoots.splice(0).forEach((root) => act(() => root.unmount()))
document.body.innerHTML = ''
vi.clearAllMocks()
})
describe('showDeleteWorktreeFailureToast', () => {
it('uses a persistent in-body action footer when force delete is available', () => {
const onViewChanges = vi.fn()
const onForceDelete = vi.fn()
showDeleteWorktreeFailureToast({
error: 'branch has changes',
canForceDelete: true,
onViewChanges,
onForceDelete,
worktreeId: 'wt-1',
worktreeName: 'feature/foo'
})
expect(toast.info).toHaveBeenCalledWith(
'Failed to delete workspace feature/foo',
expect.objectContaining({
id: 'delete-worktree-failure:wt-1',
dismissible: true,
duration: Infinity
})
)
const options = vi.mocked(toast.info).mock.calls.at(-1)?.[1] as
| { action?: unknown; cancel?: unknown }
| undefined
expect(options?.action).toBeUndefined()
expect(options?.cancel).toBeUndefined()
const body = renderToastBody('info')
expect(body.textContent).toContain('It has changed files.')
clickButton(body, 'View')
expect(toast.dismiss).toHaveBeenCalledWith('delete-worktree-failure:wt-1')
expect(onViewChanges).toHaveBeenCalled()
clickButton(body, 'Force Delete')
expect(toast.dismiss).toHaveBeenCalledWith('delete-worktree-failure:wt-1')
expect(onForceDelete).toHaveBeenCalled()
})
it('keeps non-forceable failures destructive without a force action', () => {
const onViewChanges = vi.fn()
showDeleteWorktreeFailureToast({
error: 'permission denied',
canForceDelete: false,
onViewChanges,
onForceDelete: vi.fn(),
worktreeId: 'wt-2',
worktreeName: 'feature/bar'
})
expect(toast.error).toHaveBeenCalledWith(
'Failed to delete workspace feature/bar',
expect.objectContaining({
id: 'delete-worktree-failure:wt-2',
dismissible: true,
duration: 10000
})
)
const body = renderToastBody('error')
expect(body.textContent).toContain('permission denied')
expect(body.textContent).not.toContain('Force Delete')
clickButton(body, 'View')
expect(toast.dismiss).toHaveBeenCalledWith('delete-worktree-failure:wt-2')
expect(onViewChanges).toHaveBeenCalled()
})
})
@@ -0,0 +1,88 @@
import { toast } from 'sonner'
import { Button } from '../ui/button'
import { getDeleteWorktreeToastCopy } from './delete-worktree-toast'
import { translate } from '@/i18n/i18n'
type DeleteWorktreeFailureToastOptions = {
error: string
canForceDelete: boolean
onViewChanges: () => void
onForceDelete: () => void
worktreeId: string
worktreeName: string
}
function deleteWorktreeFailureToastId(worktreeId: string): string {
return `delete-worktree-failure:${worktreeId}`
}
function DeleteWorktreeFailureToastBody({
description,
canForceDelete,
onViewChanges,
onForceDelete,
toastId
}: {
description?: string
canForceDelete: boolean
onViewChanges: () => void
onForceDelete: () => void
toastId: string
}): React.JSX.Element {
const viewChanges = (): void => {
toast.dismiss(toastId)
onViewChanges()
}
const forceDelete = (): void => {
toast.dismiss(toastId)
onForceDelete()
}
return (
<div className="flex w-full flex-col gap-3">
{description ? (
<p className="text-sm leading-5 text-popover-foreground/80">{description}</p>
) : null}
<div className="flex flex-wrap justify-end gap-2">
<Button type="button" variant="outline" size="sm" onClick={viewChanges}>
{translate('auto.components.sidebar.delete.worktree.flow.7488ed8711', 'View')}
</Button>
{canForceDelete ? (
<Button type="button" variant="destructive" size="sm" onClick={forceDelete}>
{translate('auto.components.sidebar.delete.worktree.flow.2b20ce87b3', 'Force Delete')}
</Button>
) : null}
</div>
</div>
)
}
export function showDeleteWorktreeFailureToast({
error,
canForceDelete,
onViewChanges,
onForceDelete,
worktreeId,
worktreeName
}: DeleteWorktreeFailureToastOptions): void {
const toastCopy = getDeleteWorktreeToastCopy(worktreeName, canForceDelete, error)
const showToast = toastCopy.isDestructive ? toast.error : toast.info
const id = deleteWorktreeFailureToastId(worktreeId)
// Why: Sonner's native action/cancel slots share the title row and squeeze
// multi-line delete errors. Custom content gives the copy its own line.
showToast(toastCopy.title, {
id,
description: (
<DeleteWorktreeFailureToastBody
description={toastCopy.description}
canForceDelete={canForceDelete}
onViewChanges={onViewChanges}
onForceDelete={onForceDelete}
toastId={id}
/>
),
duration: canForceDelete ? Infinity : 10000,
dismissible: true
})
}
@@ -60,7 +60,12 @@ vi.mock('sonner', () => ({
}
}))
vi.mock('./delete-worktree-failure-toast', () => ({
showDeleteWorktreeFailureToast: vi.fn()
}))
import { toast } from 'sonner'
import { showDeleteWorktreeFailureToast } from './delete-worktree-failure-toast'
import { runWorktreeBatchDelete, runWorktreeDelete } from './delete-worktree-flow'
function setWorktrees(
@@ -100,6 +105,7 @@ describe('runWorktreeBatchDelete', () => {
mocks.state.repos = []
vi.mocked(toast.error).mockClear()
vi.mocked(toast.info).mockClear()
vi.mocked(showDeleteWorktreeFailureToast).mockClear()
setWorktrees([])
})
@@ -178,11 +184,9 @@ describe('runWorktreeBatchDelete', () => {
expect(runWorktreeBatchDelete(['wt-1'], { onDeleted })).toBe(true)
await vi.waitFor(() => expect(toast.info).toHaveBeenCalled())
const toastOptions = vi.mocked(toast.info).mock.calls[0]?.[1] as
| { action?: { onClick?: () => void } }
| undefined
toastOptions?.action?.onClick?.()
await vi.waitFor(() => expect(showDeleteWorktreeFailureToast).toHaveBeenCalled())
const toastOptions = vi.mocked(showDeleteWorktreeFailureToast).mock.calls[0]?.[0]
toastOptions?.onForceDelete()
await vi.waitFor(() => {
expect(mocks.state.removeWorktree).toHaveBeenNthCalledWith(2, 'wt-1', true)
@@ -3,7 +3,7 @@ import { useAppStore } from '@/store'
import { getWorktreeMapFromState } from '@/store/selectors'
import { activateAndRevealWorktree } from '@/lib/worktree-activation'
import { prepareActiveWorktreeFocusAfterDelete } from './active-worktree-focus-after-delete'
import { getDeleteWorktreeToastCopy } from './delete-worktree-toast'
import { showDeleteWorktreeFailureToast } from './delete-worktree-failure-toast'
import { getWorkspaceDeleteLineage } from './workspace-delete-lineage'
import {
isPathInsideOrEqual,
@@ -145,73 +145,62 @@ export function runWorktreeDeleteWithToast(
}
const state = useAppStore.getState().deleteStateByWorktreeId[worktreeId]
const canForceDelete = state?.canForceDelete ?? false
const toastCopy = getDeleteWorktreeToastCopy(worktreeName, canForceDelete, result.error)
const showToast = toastCopy.isDestructive ? toast.error : toast.info
showToast(toastCopy.title, {
description: toastCopy.description,
duration: 10000,
cancel: {
label: translate('auto.components.sidebar.delete.worktree.flow.7488ed8711', 'View'),
onClick: () => viewWorktreeDiff(worktreeId)
},
action: canForceDelete
? {
label: translate(
'auto.components.sidebar.delete.worktree.flow.2b20ce87b3',
'Force Delete'
),
onClick: () => {
// Why: recapture at click time — the user may have navigated away
// while the failed-delete toast was open, so focus only hands off
// when this is still the workspace they are viewing.
const commitForceFocus = prepareActiveWorktreeFocusAfterDelete(worktreeId)
useAppStore
.getState()
.removeWorktree(worktreeId, true)
.then((forceResult) => {
if (!forceResult.ok) {
toast.error(
translate(
'auto.components.sidebar.delete.worktree.flow.4f3876c0f5',
'Force delete failed'
),
{
description: forceResult.error,
action: {
label: translate(
'auto.components.sidebar.delete.worktree.flow.7488ed8711',
'View'
),
onClick: () => viewWorktreeDiff(worktreeId)
}
}
)
return
}
commitForceFocus()
options.onForceDeleted?.(worktreeId)
})
.catch((err: unknown) => {
toast.error(
translate(
'auto.components.sidebar.delete.worktree.flow.ae57cbf6e4',
'Failed to delete workspace'
showDeleteWorktreeFailureToast({
error: result.error,
canForceDelete,
onViewChanges: () => viewWorktreeDiff(worktreeId),
onForceDelete: () => {
// Why: recapture at click time — the user may have navigated away
// while the failed-delete toast was open, so focus only hands off
// when this is still the workspace they are viewing.
const commitForceFocus = prepareActiveWorktreeFocusAfterDelete(worktreeId)
useAppStore
.getState()
.removeWorktree(worktreeId, true)
.then((forceResult) => {
if (!forceResult.ok) {
toast.error(
translate(
'auto.components.sidebar.delete.worktree.flow.4f3876c0f5',
'Force delete failed'
),
{
description: forceResult.error,
action: {
label: translate(
'auto.components.sidebar.delete.worktree.flow.7488ed8711',
'View'
),
{
description: err instanceof Error ? err.message : String(err),
action: {
label: translate(
'auto.components.sidebar.delete.worktree.flow.7488ed8711',
'View'
),
onClick: () => viewWorktreeDiff(worktreeId)
}
}
)
})
onClick: () => viewWorktreeDiff(worktreeId)
}
}
)
return
}
}
: undefined
commitForceFocus()
options.onForceDeleted?.(worktreeId)
})
.catch((err: unknown) => {
toast.error(
translate(
'auto.components.sidebar.delete.worktree.flow.ae57cbf6e4',
'Failed to delete workspace'
),
{
description: err instanceof Error ? err.message : String(err),
action: {
label: translate(
'auto.components.sidebar.delete.worktree.flow.7488ed8711',
'View'
),
onClick: () => viewWorktreeDiff(worktreeId)
}
}
)
})
},
worktreeId,
worktreeName
})
return false
})
@@ -87,8 +87,8 @@ function SuggestionToastBody({
}
return (
<div className="flex flex-col gap-3">
<p className="text-sm text-popover-foreground/80">
<div className="flex w-full flex-col gap-3">
<p className="text-sm leading-5 text-popover-foreground/80">
{translate(
'auto.components.sidebar.local.base.ref.suggestion.toast.f15fd80989',
'Your new worktree is current, but local {{value0}} is {{value1}} {{value2}} behind, so AI diffs may compare to stale history. Let Orca keep it up to date automatically. Change this anytime in',
@@ -109,7 +109,6 @@ function SuggestionToastBody({
{ value0: keepLocalMainUpToDateTitle }
)}
</button>
.
</p>
<div className="flex justify-end">
{/* No explicit Dismiss: the toast is persistent and sonner's close (X)
+9 -1
View File
@@ -15,6 +15,13 @@ const Toaster = ({ ...props }: ToasterProps) => {
<Sonner
theme={theme as ToasterProps['theme']}
position="bottom-right"
// Why: Orca has persistent bottom chrome, so bottom-right toasts need
// breathing room above the status bar instead of sitting on its edge.
// mobileOffset keeps that clearance below Sonner's 600px breakpoint
// (narrow/resized windows and the web client), which otherwise reverts
// to Sonner's default 16px and lets toasts crowd the status bar again.
offset={{ bottom: 'calc(2.5rem + env(safe-area-inset-bottom, 0px))' }}
mobileOffset={{ bottom: 'calc(2.5rem + env(safe-area-inset-bottom, 0px))' }}
className="toaster group"
icons={{
success: <CircleCheckIcon className="size-4" />,
@@ -28,7 +35,8 @@ const Toaster = ({ ...props }: ToasterProps) => {
'--normal-bg': 'var(--popover)',
'--normal-text': 'var(--popover-foreground)',
'--normal-border': 'var(--border)',
'--border-radius': 'var(--radius)'
'--border-radius': 'var(--radius)',
'--width': 'min(26rem, calc(100vw - 2rem))'
} as React.CSSProperties
}
{...props}
@@ -13,11 +13,14 @@ const repo = {
addedAt: 0
} satisfies Repo
function ids(args: { isMac?: boolean; isWindows?: boolean; isWebClient?: boolean } = {}): string[] {
function ids(
args: { isMac?: boolean; isWindows?: boolean; isWebClient?: boolean; isDev?: boolean } = {}
): string[] {
return buildSettingsNavigationMetadata({
isMac: args.isMac ?? false,
isWindows: args.isWindows ?? false,
isWebClient: args.isWebClient ?? false,
isDev: args.isDev ?? false,
repos: [repo]
}).map((section) => section.id)
}
@@ -149,6 +152,17 @@ describe('settings navigation metadata', () => {
expect(desktopIds.indexOf('privacy')).toBeLessThan(desktopIds.indexOf('advanced'))
})
// Note: this exercises the isDev parameter and isWebClient branches only.
// Production safety rests on the hard `import.meta.env.DEV` term in the
// builder, which is compile-time-inlined per build and cannot be flipped from
// a test (vitest always runs with DEV=true) — don't mistake this for full
// prod-gate coverage. The bundle exclusion is what guarantees prod safety.
it('shows Dev tools only in desktop development metadata', () => {
expect(ids()).not.toContain('dev')
expect(ids({ isDev: true })).toContain('dev')
expect(ids({ isDev: true, isWebClient: true })).not.toContain('dev')
})
it('keeps macOS permissions mac-only', () => {
expect(ids({ isMac: false })).not.toContain('developer-permissions')
expect(ids({ isMac: true })).toContain('developer-permissions')
@@ -9,6 +9,7 @@ import {
Bell,
Blocks,
Bot,
Bug,
Cable,
FlaskConical,
GitBranch,
@@ -80,17 +81,44 @@ import { translate } from '@/i18n/i18n'
export { isWebClientLocation } from '@/lib/web-client-location'
function getDevToolsPaneSearchEntries(): SettingsNavSection['searchEntries'] {
return [
{
title: translate(
'auto.hooks.useSettingsNavigationMetadata.devSearchNotificationPlayground',
'Notification playground'
),
description: translate(
'auto.hooks.useSettingsNavigationMetadata.devSearchNotificationPlaygroundDescription',
'Trigger representative toast and notification UI states.'
),
keywords: [
translate('auto.hooks.useSettingsNavigationMetadata.devSearchKeywordDev', 'dev'),
translate('auto.hooks.useSettingsNavigationMetadata.devSearchKeywordToast', 'toast'),
translate('auto.hooks.useSettingsNavigationMetadata.devSearchKeywordSonner', 'sonner'),
translate('auto.hooks.useSettingsNavigationMetadata.devSearchKeywordError', 'error'),
translate(
'auto.hooks.useSettingsNavigationMetadata.devSearchKeywordNotification',
'notification'
)
]
}
]
}
export function buildSettingsNavigationMetadata({
isMac,
isWindows,
isWindowsTerminalHost = isWindows,
isWebClient,
isDev = import.meta.env.DEV,
repos
}: {
isMac: boolean
isWindows: boolean
isWindowsTerminalHost?: boolean
isWebClient: boolean
isDev?: boolean
repos: readonly Repo[]
}): SettingsNavSection[] {
const showDesktopOnlySettings = !isWebClient
@@ -478,6 +506,26 @@ export function buildSettingsNavigationMetadata({
}
]
: []),
// Why: dev tooling must not be reachable from packaged/web builds even if
// this pure metadata builder is called manually with isDev=true.
...(showDesktopOnlySettings && import.meta.env.DEV && isDev
? [
{
id: 'dev',
title: translate('auto.hooks.useSettingsNavigationMetadata.dev', 'Dev Tools'),
description: translate(
'auto.hooks.useSettingsNavigationMetadata.devDescription',
'Dev-only tools for exercising UI states.'
),
// Why: distinct from the sibling Advanced section's Wrench so the two
// entries in the same 'advanced' group stay visually distinguishable.
icon: Bug,
searchEntries: getDevToolsPaneSearchEntries(),
group: 'advanced',
badge: translate('auto.hooks.useSettingsNavigationMetadata.devBadge', 'Dev')
}
]
: []),
{
id: 'experimental',
title: translate('auto.hooks.useSettingsNavigationMetadata.225071c560', 'Experimental'),
@@ -533,6 +581,7 @@ export function useSettingsNavigationMetadata(): SettingsNavSection[] {
isWindows,
isWindowsTerminalHost,
isWebClient,
isDev: import.meta.env.DEV,
repos
}),
[isMac, isWindows, isWindowsTerminalHost, isWebClient, repos]
+44 -2
View File
@@ -638,7 +638,17 @@
"b1c2f8b0ac": "Optional account switching for Claude, Codex, Gemini, and OpenCode Go.",
"f70ac54d38": "AI Provider Accounts",
"4121f7a0a2": "Manage AI agents, set a default, and customize commands.",
"b49abbd2f7": "Agents"
"b49abbd2f7": "Agents",
"dev": "Dev Tools",
"devDescription": "Dev-only tools for exercising UI states.",
"devBadge": "Dev",
"devSearchNotificationPlayground": "Notification playground",
"devSearchNotificationPlaygroundDescription": "Trigger representative toast and notification UI states.",
"devSearchKeywordDev": "dev",
"devSearchKeywordToast": "toast",
"devSearchKeywordSonner": "sonner",
"devSearchKeywordError": "error",
"devSearchKeywordNotification": "notification"
},
"useAppMenuPaste": {
"pasteTooLarge": "Paste is too large."
@@ -6084,7 +6094,9 @@
"9abb9be3bc": "Set Up",
"23c6874fdf": "AI Capabilities",
"2309068a6f": "destructive",
"65358016ea": "Discard"
"65358016ea": "Discard",
"dev": "Dev Tools",
"devDescription": "Dev-only tools for exercising UI states."
},
"SettingsFormControls": {
"42a4d15a30": "No matching fonts.",
@@ -8512,6 +8524,36 @@
},
"AppearanceAdvancedDisclosure": {
"advanced": "Advanced"
},
"DevToolsPane": {
"nativeActionLayoutCheck": "Native action layout check",
"secondary": "Secondary",
"secondaryActionClicked": "Secondary action clicked",
"primaryAction": "Primary action",
"primaryActionClicked": "Primary action clicked",
"branchHasChanges": "branch has changes",
"viewChangesClicked": "View Changes clicked",
"forceDeleteClicked": "Force Delete clicked",
"devOnlyCallback": "Dev-only callback.",
"infoToast": "Info toast",
"infoToastDescription": "Long informational copy with no explicit action.",
"localCanaryBehind": "Local canary is behind origin/canary",
"successToast": "Success toast",
"successToastDescription": "Short confirmation state.",
"settingsSaved": "Settings saved",
"shortSuccessCopy": "Short success copy.",
"errorToast": "Error toast",
"errorToastDescription": "Long error copy without recovery actions.",
"failedToSyncWorkspaceMetadata": "Failed to sync workspace metadata",
"nativeActionToast": "Native action toast",
"nativeActionToastDescription": "Uses Sonner action and cancel slots.",
"deleteFailureToast": "Delete failure toast",
"deleteFailureToastDescription": "Custom footer with View and Force Delete.",
"behindBaseRefToast": "Behind base ref toast",
"behindBaseRefToastDescription": "Persistent prompt with an inline Settings link and footer action.",
"notificationPlayground": "Notification playground",
"notificationPlaygroundDescription": "Dev-only triggers for checking toast layout, recovery actions, and long-copy wrapping.",
"devOnly": "Dev only"
}
},
"right": {
+44 -2
View File
@@ -638,7 +638,17 @@
"b1c2f8b0ac": "Cambio de cuenta opcional para Claude, Codex, Gemini y OpenCode Go.",
"f70ac54d38": "Cuentas de proveedores de IA",
"4121f7a0a2": "Administre agents de IA, establezca un valor predeterminado y personalice comandos.",
"b49abbd2f7": "Agentes"
"b49abbd2f7": "Agentes",
"dev": "Dev Tools",
"devDescription": "Dev-only tools for exercising UI states.",
"devBadge": "Dev",
"devSearchNotificationPlayground": "Notification playground",
"devSearchNotificationPlaygroundDescription": "Trigger representative toast and notification UI states.",
"devSearchKeywordDev": "dev",
"devSearchKeywordToast": "toast",
"devSearchKeywordSonner": "sonner",
"devSearchKeywordError": "error",
"devSearchKeywordNotification": "notification"
},
"useAppMenuPaste": {
"pasteTooLarge": "El contenido pegado es demasiado grande."
@@ -6047,7 +6057,9 @@
"9abb9be3bc": "Configuración",
"23c6874fdf": "Capacidades de IA",
"2309068a6f": "destructivo",
"65358016ea": "Desechar"
"65358016ea": "Desechar",
"dev": "Dev Tools",
"devDescription": "Dev-only tools for exercising UI states."
},
"SettingsFormControls": {
"42a4d15a30": "No hay fuentes coincidentes.",
@@ -8512,6 +8524,36 @@
},
"AppearanceAdvancedDisclosure": {
"advanced": "Avanzado"
},
"DevToolsPane": {
"nativeActionLayoutCheck": "Native action layout check",
"secondary": "Secondary",
"secondaryActionClicked": "Secondary action clicked",
"primaryAction": "Primary action",
"primaryActionClicked": "Primary action clicked",
"branchHasChanges": "branch has changes",
"viewChangesClicked": "View Changes clicked",
"forceDeleteClicked": "Force Delete clicked",
"devOnlyCallback": "Dev-only callback.",
"infoToast": "Info toast",
"infoToastDescription": "Long informational copy with no explicit action.",
"localCanaryBehind": "Local canary is behind origin/canary",
"successToast": "Success toast",
"successToastDescription": "Short confirmation state.",
"settingsSaved": "Settings saved",
"shortSuccessCopy": "Short success copy.",
"errorToast": "Error toast",
"errorToastDescription": "Long error copy without recovery actions.",
"failedToSyncWorkspaceMetadata": "Failed to sync workspace metadata",
"nativeActionToast": "Native action toast",
"nativeActionToastDescription": "Uses Sonner action and cancel slots.",
"deleteFailureToast": "Delete failure toast",
"deleteFailureToastDescription": "Custom footer with View and Force Delete.",
"behindBaseRefToast": "Behind base ref toast",
"behindBaseRefToastDescription": "Persistent prompt with an inline Settings link and footer action.",
"notificationPlayground": "Notification playground",
"notificationPlaygroundDescription": "Dev-only triggers for checking toast layout, recovery actions, and long-copy wrapping.",
"devOnly": "Dev only"
}
},
"right": {
+44 -2
View File
@@ -638,7 +638,17 @@
"b1c2f8b0ac": "Claude、Codex、Gemini、OpenCode Go のオプションのアカウント切り替え。",
"f70ac54d38": "AI プロバイダー アカウント",
"4121f7a0a2": "AI agents を管理し、デフォルトを設定し、コマンドをカスタマイズします。",
"b49abbd2f7": "エージェント"
"b49abbd2f7": "エージェント",
"dev": "Dev Tools",
"devDescription": "Dev-only tools for exercising UI states.",
"devBadge": "Dev",
"devSearchNotificationPlayground": "Notification playground",
"devSearchNotificationPlaygroundDescription": "Trigger representative toast and notification UI states.",
"devSearchKeywordDev": "dev",
"devSearchKeywordToast": "toast",
"devSearchKeywordSonner": "sonner",
"devSearchKeywordError": "error",
"devSearchKeywordNotification": "notification"
},
"useAppMenuPaste": {
"pasteTooLarge": "貼り付け内容が大きすぎます。"
@@ -6069,7 +6079,9 @@
"9abb9be3bc": "セットアップ",
"23c6874fdf": "AI 機能",
"2309068a6f": "破壊的な",
"65358016ea": "破棄"
"65358016ea": "破棄",
"dev": "Dev Tools",
"devDescription": "Dev-only tools for exercising UI states."
},
"SettingsFormControls": {
"42a4d15a30": "一致するフォントがありません。",
@@ -8512,6 +8524,36 @@
},
"AppearanceAdvancedDisclosure": {
"advanced": "詳細設定"
},
"DevToolsPane": {
"nativeActionLayoutCheck": "Native action layout check",
"secondary": "Secondary",
"secondaryActionClicked": "Secondary action clicked",
"primaryAction": "Primary action",
"primaryActionClicked": "Primary action clicked",
"branchHasChanges": "branch has changes",
"viewChangesClicked": "View Changes clicked",
"forceDeleteClicked": "Force Delete clicked",
"devOnlyCallback": "Dev-only callback.",
"infoToast": "Info toast",
"infoToastDescription": "Long informational copy with no explicit action.",
"localCanaryBehind": "Local canary is behind origin/canary",
"successToast": "Success toast",
"successToastDescription": "Short confirmation state.",
"settingsSaved": "Settings saved",
"shortSuccessCopy": "Short success copy.",
"errorToast": "Error toast",
"errorToastDescription": "Long error copy without recovery actions.",
"failedToSyncWorkspaceMetadata": "Failed to sync workspace metadata",
"nativeActionToast": "Native action toast",
"nativeActionToastDescription": "Uses Sonner action and cancel slots.",
"deleteFailureToast": "Delete failure toast",
"deleteFailureToastDescription": "Custom footer with View and Force Delete.",
"behindBaseRefToast": "Behind base ref toast",
"behindBaseRefToastDescription": "Persistent prompt with an inline Settings link and footer action.",
"notificationPlayground": "Notification playground",
"notificationPlaygroundDescription": "Dev-only triggers for checking toast layout, recovery actions, and long-copy wrapping.",
"devOnly": "Dev only"
}
},
"right": {
+44 -2
View File
@@ -638,7 +638,17 @@
"b1c2f8b0ac": "Claude, Codex, Gemini 및 OpenCode Go에 대한 선택적 계정 전환.",
"f70ac54d38": "AI 제공업체 계정",
"4121f7a0a2": "AI agents를 관리하고, 기본값을 설정하고, 명령을 사용자 정의하세요.",
"b49abbd2f7": "에이전트"
"b49abbd2f7": "에이전트",
"dev": "Dev Tools",
"devDescription": "Dev-only tools for exercising UI states.",
"devBadge": "Dev",
"devSearchNotificationPlayground": "Notification playground",
"devSearchNotificationPlaygroundDescription": "Trigger representative toast and notification UI states.",
"devSearchKeywordDev": "dev",
"devSearchKeywordToast": "toast",
"devSearchKeywordSonner": "sonner",
"devSearchKeywordError": "error",
"devSearchKeywordNotification": "notification"
},
"useAppMenuPaste": {
"pasteTooLarge": "붙여넣기 내용이 너무 큽니다."
@@ -6032,7 +6042,9 @@
"9abb9be3bc": "설정 시작",
"23c6874fdf": "AI 기능",
"2309068a6f": "파괴적",
"65358016ea": "버리기"
"65358016ea": "버리기",
"dev": "Dev Tools",
"devDescription": "Dev-only tools for exercising UI states."
},
"SettingsFormControls": {
"42a4d15a30": "일치하는 글꼴이 없습니다.",
@@ -8512,6 +8524,36 @@
},
"AppearanceAdvancedDisclosure": {
"advanced": "고급"
},
"DevToolsPane": {
"nativeActionLayoutCheck": "Native action layout check",
"secondary": "Secondary",
"secondaryActionClicked": "Secondary action clicked",
"primaryAction": "Primary action",
"primaryActionClicked": "Primary action clicked",
"branchHasChanges": "branch has changes",
"viewChangesClicked": "View Changes clicked",
"forceDeleteClicked": "Force Delete clicked",
"devOnlyCallback": "Dev-only callback.",
"infoToast": "Info toast",
"infoToastDescription": "Long informational copy with no explicit action.",
"localCanaryBehind": "Local canary is behind origin/canary",
"successToast": "Success toast",
"successToastDescription": "Short confirmation state.",
"settingsSaved": "Settings saved",
"shortSuccessCopy": "Short success copy.",
"errorToast": "Error toast",
"errorToastDescription": "Long error copy without recovery actions.",
"failedToSyncWorkspaceMetadata": "Failed to sync workspace metadata",
"nativeActionToast": "Native action toast",
"nativeActionToastDescription": "Uses Sonner action and cancel slots.",
"deleteFailureToast": "Delete failure toast",
"deleteFailureToastDescription": "Custom footer with View and Force Delete.",
"behindBaseRefToast": "Behind base ref toast",
"behindBaseRefToastDescription": "Persistent prompt with an inline Settings link and footer action.",
"notificationPlayground": "Notification playground",
"notificationPlaygroundDescription": "Dev-only triggers for checking toast layout, recovery actions, and long-copy wrapping.",
"devOnly": "Dev only"
}
},
"right": {
+44 -2
View File
@@ -638,7 +638,17 @@
"b1c2f8b0ac": "Claude、Codex、Gemini 和 OpenCode Go 的可选账户切换。",
"f70ac54d38": "AI 提供商账户",
"4121f7a0a2": "管理 AI 智能体、设置默认值并自定义命令。",
"b49abbd2f7": "智能体"
"b49abbd2f7": "智能体",
"dev": "Dev Tools",
"devDescription": "Dev-only tools for exercising UI states.",
"devBadge": "Dev",
"devSearchNotificationPlayground": "Notification playground",
"devSearchNotificationPlaygroundDescription": "Trigger representative toast and notification UI states.",
"devSearchKeywordDev": "dev",
"devSearchKeywordToast": "toast",
"devSearchKeywordSonner": "sonner",
"devSearchKeywordError": "error",
"devSearchKeywordNotification": "notification"
},
"useAppMenuPaste": {
"pasteTooLarge": "粘贴内容过大。"
@@ -6032,7 +6042,9 @@
"9abb9be3bc": "初始设置",
"23c6874fdf": "AI 能力",
"2309068a6f": "destructive",
"65358016ea": "放弃"
"65358016ea": "放弃",
"dev": "Dev Tools",
"devDescription": "Dev-only tools for exercising UI states."
},
"SettingsFormControls": {
"42a4d15a30": "没有匹配的字体。",
@@ -8512,6 +8524,36 @@
},
"AppearanceAdvancedDisclosure": {
"advanced": "高级"
},
"DevToolsPane": {
"nativeActionLayoutCheck": "Native action layout check",
"secondary": "Secondary",
"secondaryActionClicked": "Secondary action clicked",
"primaryAction": "Primary action",
"primaryActionClicked": "Primary action clicked",
"branchHasChanges": "branch has changes",
"viewChangesClicked": "View Changes clicked",
"forceDeleteClicked": "Force Delete clicked",
"devOnlyCallback": "Dev-only callback.",
"infoToast": "Info toast",
"infoToastDescription": "Long informational copy with no explicit action.",
"localCanaryBehind": "Local canary is behind origin/canary",
"successToast": "Success toast",
"successToastDescription": "Short confirmation state.",
"settingsSaved": "Settings saved",
"shortSuccessCopy": "Short success copy.",
"errorToast": "Error toast",
"errorToastDescription": "Long error copy without recovery actions.",
"failedToSyncWorkspaceMetadata": "Failed to sync workspace metadata",
"nativeActionToast": "Native action toast",
"nativeActionToastDescription": "Uses Sonner action and cancel slots.",
"deleteFailureToast": "Delete failure toast",
"deleteFailureToastDescription": "Custom footer with View and Force Delete.",
"behindBaseRefToast": "Behind base ref toast",
"behindBaseRefToastDescription": "Persistent prompt with an inline Settings link and footer action.",
"notificationPlayground": "Notification playground",
"notificationPlaygroundDescription": "Dev-only triggers for checking toast layout, recovery actions, and long-copy wrapping.",
"devOnly": "Dev only"
}
},
"right": {
@@ -22,6 +22,7 @@ export type SettingsNavTarget =
| 'developer-permissions'
| 'privacy'
| 'advanced'
| 'dev'
| 'voice'
| 'shortcuts'
| 'stats'