diff --git a/frontend/src/components/settings/CommandsEditor.test.tsx b/frontend/src/components/settings/CommandsEditor.test.tsx index 2d069456..2b0b9e9b 100644 --- a/frontend/src/components/settings/CommandsEditor.test.tsx +++ b/frontend/src/components/settings/CommandsEditor.test.tsx @@ -61,12 +61,13 @@ describe('CommandsEditor', () => { expect(screen.getByText('Add your first command to get started.')).toBeInTheDocument() }) - it('renders command names with leading slash', () => { + it('renders command names without a leading slash', () => { const onChange = vi.fn() render(, { wrapper: createWrapper() }) - expect(screen.getByText('/review')).toBeInTheDocument() - expect(screen.getByText('/build')).toBeInTheDocument() + expect(screen.getByText('review')).toBeInTheDocument() + expect(screen.getByText('build')).toBeInTheDocument() + expect(screen.queryByText('/review')).not.toBeInTheDocument() }) it('renders uploaded directory command files', () => { @@ -80,7 +81,7 @@ describe('CommandsEditor', () => { { wrapper: createWrapper() }, ) - expect(screen.getByText('/deploy')).toBeInTheDocument() + expect(screen.getByText('deploy')).toBeInTheDocument() expect(screen.getByText('Uploaded file: project/deploy.md')).toBeInTheDocument() expect(screen.getByText('File')).toBeInTheDocument() expect(screen.queryByText('No commands configured')).not.toBeInTheDocument() @@ -103,7 +104,7 @@ describe('CommandsEditor', () => { const onChange = vi.fn() render(, { wrapper: createWrapper() }) - await user.click(screen.getByText('/review')) + await user.click(screen.getByText('review')) expect(screen.getByTestId('command-dialog')).toBeInTheDocument() }) @@ -124,7 +125,7 @@ describe('CommandsEditor', () => { const onChange = vi.fn() render(, { wrapper: createWrapper() }) - await user.click(screen.getByLabelText('Actions for /review')) + await user.click(screen.getByLabelText('Actions for review')) await user.click(screen.getByText('Delete')) expect(onChange).toHaveBeenCalledTimes(1) diff --git a/frontend/src/components/settings/CommandsEditor.tsx b/frontend/src/components/settings/CommandsEditor.tsx index cf6a1d28..721d37dc 100644 --- a/frontend/src/components/settings/CommandsEditor.tsx +++ b/frontend/src/components/settings/CommandsEditor.tsx @@ -84,7 +84,7 @@ export function CommandsEditor({ commands, directoryCommands = [], onChange }: C {Object.entries(commands).map(([name, command]) => ( {command.agent} @@ -92,10 +92,10 @@ export function CommandsEditor({ commands, directoryCommands = [], onChange }: C onClick={() => startEdit(name, command)} primaryAction={{ label: 'Edit', onClick: () => startEdit(name, command) }} actions={[{ label: 'Delete', destructive: true, onClick: () => deleteCommand(name) }]} - actionsLabel={`Actions for /${name}`} + actionsLabel={`Actions for ${name}`} /> ))} - + (null) const [deletingFile, setDeletingFile] = useState(null) @@ -71,7 +70,7 @@ export function DirectoryFilesList({ kind, files, titlePrefix = '' }: DirectoryF return ( {`${titlePrefix}${file.name}`}} + title={{file.name}} description={isNested ? `Uploaded file: ${file.relativePath}` : undefined} badges={File} onClick={() => setEditingFile(file)} diff --git a/frontend/src/components/settings/OpenCodeConfigManager.test.tsx b/frontend/src/components/settings/OpenCodeConfigManager.test.tsx index 60f6b090..a29722ff 100644 --- a/frontend/src/components/settings/OpenCodeConfigManager.test.tsx +++ b/frontend/src/components/settings/OpenCodeConfigManager.test.tsx @@ -110,7 +110,7 @@ describe('OpenCodeConfigManager', () => { }) await user.click(screen.getByRole('button', { name: /Commands/i })) - expect(await screen.findByText('/deploy')).toBeInTheDocument() + expect(await screen.findByText('deploy')).toBeInTheDocument() expect(screen.getByText('Uploaded file: project/deploy.md')).toBeInTheDocument() const agentsButton = screen.getAllByRole('button', { name: /Agents/i }).find(button => button.textContent?.startsWith('Agents')) diff --git a/frontend/src/components/settings/SettingsDialog.tsx b/frontend/src/components/settings/SettingsDialog.tsx index bcb5f800..1901eac6 100644 --- a/frontend/src/components/settings/SettingsDialog.tsx +++ b/frontend/src/components/settings/SettingsDialog.tsx @@ -15,6 +15,7 @@ import { VoiceSettings } from '@/components/settings/VoiceSettings' import { NotificationSettings } from '@/components/settings/NotificationSettings' import { VersionSelectDialog } from '@/components/settings/VersionSelectDialog' import { Dialog, DialogContent, DialogTitle } from '@/components/ui/dialog' +import { RowActionsMenuContext } from '@/components/ui/settings-list' import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs' import { Settings2, Keyboard, Code, ChevronLeft, Key, GitBranch, User, Volume2, Bell, X, ScrollText, type LucideIcon } from 'lucide-react' import { Button } from '@/components/ui/button' @@ -28,19 +29,21 @@ function OpenCodeSettings({ onOpenVersionDialog }: { onOpenVersionDialog: () => const toggleAuthSections = useCallback(() => setAuthSectionsOpen((open) => !open), []) return ( -
- - -
-

Server maintenance

-
- - -
- - -
-
+ +
+ + +
+

Server maintenance

+
+ + +
+ + +
+
+
) } diff --git a/frontend/src/components/ui/settings-list.test.tsx b/frontend/src/components/ui/settings-list.test.tsx index 018fd6bd..ef93025b 100644 --- a/frontend/src/components/ui/settings-list.test.tsx +++ b/frontend/src/components/ui/settings-list.test.tsx @@ -1,8 +1,8 @@ import { render, screen } from '@testing-library/react' import userEvent from '@testing-library/user-event' import { QueryClient, QueryClientProvider } from '@tanstack/react-query' -import { describe, it, expect, vi } from 'vitest' -import { SettingsList, SettingsListRow } from './settings-list' +import { afterEach, describe, it, expect, vi } from 'vitest' +import { RowActionsMenuContext, SettingsList, SettingsListRow } from './settings-list' import { DirectoryFilesList } from '@/components/settings/DirectoryFilesList' vi.mock('@/api/settings', () => ({ @@ -114,20 +114,40 @@ describe('SettingsListRow', () => { expect(actionClick).toHaveBeenCalledTimes(1) }) - it('keeps primary and overflow actions reachable inside the compact settings scope', async () => { + afterEach(() => { + vi.unstubAllGlobals() + }) + + const mockViewport = (isDesktop: boolean) => { + vi.stubGlobal('matchMedia', (query: string) => ({ + matches: query === '(min-width: 640px)' ? isDesktop : false, + media: query, + addEventListener: vi.fn(), + removeEventListener: vi.fn(), + addListener: vi.fn(), + removeListener: vi.fn(), + onchange: null, + dispatchEvent: vi.fn(), + })) + } + + it('keeps primary and overflow actions reachable inside the compact settings scope on desktop', async () => { const user = userEvent.setup() const primaryClick = vi.fn() const deleteClick = vi.fn() + mockViewport(true) render( -
- -
, + +
+ +
+
, ) await user.click(screen.getByText('Edit')) @@ -137,6 +157,36 @@ describe('SettingsListRow', () => { await user.click(screen.getByText('Delete')) expect(deleteClick).toHaveBeenCalledTimes(1) }) + + it('collapses the primary action into the overflow menu on mobile settings rows', async () => { + const user = userEvent.setup() + const primaryClick = vi.fn() + const deleteClick = vi.fn() + mockViewport(false) + + render( + +
+ +
+
, + ) + + expect(screen.queryByText('Edit')).not.toBeInTheDocument() + + await user.click(screen.getByLabelText('More options')) + await user.click(screen.getByText('Edit')) + expect(primaryClick).toHaveBeenCalledTimes(1) + + await user.click(screen.getByLabelText('More options')) + await user.click(screen.getByText('Delete')) + expect(deleteClick).toHaveBeenCalledTimes(1) + }) }) describe('DirectoryFilesList', () => { diff --git a/frontend/src/components/ui/settings-list.tsx b/frontend/src/components/ui/settings-list.tsx index 4a66024d..b58ae82e 100644 --- a/frontend/src/components/ui/settings-list.tsx +++ b/frontend/src/components/ui/settings-list.tsx @@ -1,6 +1,7 @@ -import { Fragment, type ReactNode } from 'react' +import { createContext, Fragment, useContext, type ReactNode } from 'react' import { MoreHorizontal, Loader2, AlertCircle } from 'lucide-react' import { Button } from '@/components/ui/button' +import { DESKTOP_MEDIA_QUERY, useMediaQuery } from '@/hooks/useMediaQuery' import { DropdownMenu, DropdownMenuContent, @@ -10,6 +11,8 @@ import { } from '@/components/ui/dropdown-menu' import { cn } from '@/lib/utils' +export const RowActionsMenuContext = createContext(false) + export interface SettingsListRowAction { label: string onClick: () => void @@ -104,18 +107,28 @@ export function SettingsListRow({ onClick, className, }: SettingsListRowProps) { + const inSettingsScope = useContext(RowActionsMenuContext) + const isDesktop = useMediaQuery(DESKTOP_MEDIA_QUERY) + const actionsInMenu = inSettingsScope && !isDesktop + const overflowActions = primaryAction && actionsInMenu + ? [ + { label: primaryAction.label, onClick: primaryAction.onClick }, + ...(actions ?? []).map((action, index) => (index === 0 ? { ...action, separatorBefore: true } : action)), + ] + : actions + return (
-
-
+
+

{title}

{badges}
@@ -127,17 +140,17 @@ export function SettingsListRow({ onClick={(e) => e.stopPropagation()} > {trailing} - {primaryAction && ( + {primaryAction && !actionsInMenu && ( )} - {actions && actions.length > 0 && ( + {overflowActions && overflowActions.length > 0 && ( - {actions.map((action, i) => ( + {overflowActions.map((action, i) => ( {action.separatorBefore && i > 0 && }