mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
fix: address findings from the full Docker evaluation of main
Critical and high: - repos: unlinking a local repo removes only the Manager reference and alias, never the repository files; confirm button reads "Unlink" - auth: rate-limit by the socket address; trust proxy headers only when AUTH_TRUSTED_PROXY_HEADERS is set (documented and forwarded in compose) - composer: per-session in-memory drafts (text, bash mode, attachments); Escape no longer clears the prompt - url params: compose same-tick updates so schedule dialogs stay closed after create/delete; delete dialog names the job Medium: - tool rows show failures (non-zero shell exit, failed exploration members) - voice conversation shows the specific error and a starting state - settings: Escape in dropdowns and the shortcut recorder no longer closes the dialog; mobile deep links open the requested section; one content tree per platform - closing pushed sheets, settings, tool panels and schedule dialogs goes back in history - login returns to the requested page; signed-out pages make no authenticated requests - action terminals keep their output (Manager-side output capture and replay) - unpushed-commit detection, commit message kept on failure - binary files with unknown extensions are detected and not editable - tool panel resizes when docked and floats as a dismissible sheet when the page is too narrow - Docker image runs tini as PID 1 Low: not-found states, add-repo and branch validation errors (4xx), search-aware empty states, mobile repo sort/filter/select cues, sidebar resize affordance and collapse shortcut, mobile unread badge, preview port filtering, terminal close handling, walkthrough empty state and helper session filtering, placeholder contrast, permission labels and focus, TTS task-list sanitizing, git identity email validation, quieter git logging, hermetic worktree tests, and accessible names for icon-only controls.
This commit is contained in:
1 parent
1c22ef6ea1
commit
4ec62cd4e7
191 files changed
+6674
-696
No files matched your search
@@ -164,7 +164,7 @@ export function AccountSettings() {
|
||||
<CardTitle className="text-base sm:text-lg">Profile</CardTitle>
|
||||
</div>
|
||||
{!editingProfile && (
|
||||
<Button variant="ghost" size="sm" onClick={() => setEditingProfile(true)} className="h-8">
|
||||
<Button variant="ghost" size="sm" onClick={() => setEditingProfile(true)} aria-label="Edit profile" className="h-8">
|
||||
<Edit2 className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
)}
|
||||
|
||||
@@ -229,6 +229,24 @@ describe('GitSettings draft preservation', () => {
|
||||
await waitFor(() => expect(invalidateSpy).toHaveBeenCalledWith({ queryKey: ['repoGitIdentity'] }))
|
||||
})
|
||||
|
||||
it('blocks saving and shows an inline error for an invalid identity email', async () => {
|
||||
const user = userEvent.setup()
|
||||
setupServer(buildPreferences())
|
||||
renderGitSettings()
|
||||
|
||||
const emailInput = await screen.findByLabelText('Email', { selector: 'input#git-email' })
|
||||
await user.type(emailInput, 'not-an-email')
|
||||
|
||||
expect(emailInput).toHaveAttribute('aria-invalid', 'true')
|
||||
expect(screen.getByText('Enter a valid email address')).toBeInTheDocument()
|
||||
|
||||
await user.click(screen.getByRole('button', { name: /save changes/i }))
|
||||
|
||||
expect(updateSettingsMock).not.toHaveBeenCalled()
|
||||
expect(showToastMock.success).not.toHaveBeenCalled()
|
||||
expect(emailInput).toHaveValue('not-an-email')
|
||||
})
|
||||
|
||||
it('retains identity drafts when saving fails', async () => {
|
||||
const user = userEvent.setup()
|
||||
setupServer(buildPreferences())
|
||||
|
||||
@@ -10,6 +10,7 @@ import { Button } from '@/components/ui/button'
|
||||
import { Input } from '@/components/ui/input'
|
||||
import { randomId } from '@/lib/utils'
|
||||
import type { GitCredential, GitIdentity, GitIdentityProfile, UserPreferences } from '@/api/types/settings'
|
||||
import { isValidGitIdentityEmail } from '@opencode-manager/shared'
|
||||
import { listRepos, updateRepoGitCredential } from '@/api/repos'
|
||||
import { useOpenCodeServerActions } from '@/hooks/useOpenCodeServerActions'
|
||||
|
||||
@@ -191,6 +192,9 @@ export function GitSettings() {
|
||||
}
|
||||
|
||||
const saveAll = async () => {
|
||||
if (![gitIdentity, ...gitIdentities].every((identity) => isValidGitIdentityEmail(identity.email))) {
|
||||
return
|
||||
}
|
||||
setIsSaving(true)
|
||||
try {
|
||||
showToast.loading('Saving git configuration...', { id: 'git-config' })
|
||||
@@ -265,7 +269,7 @@ export function GitSettings() {
|
||||
value={gitIdentity.name}
|
||||
onChange={(e) => updateIdentity('name', e.target.value)}
|
||||
disabled={isSaving}
|
||||
className="bg-background border-border text-foreground placeholder:text-muted-foreground"
|
||||
className="bg-background border-border text-foreground placeholder:text-placeholder"
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
@@ -277,8 +281,13 @@ export function GitSettings() {
|
||||
value={gitIdentity.email}
|
||||
onChange={(e) => updateIdentity('email', e.target.value)}
|
||||
disabled={isSaving}
|
||||
className="bg-background border-border text-foreground placeholder:text-muted-foreground"
|
||||
aria-invalid={!isValidGitIdentityEmail(gitIdentity.email)}
|
||||
aria-describedby={!isValidGitIdentityEmail(gitIdentity.email) ? 'git-email-error' : undefined}
|
||||
className="bg-background border-border text-foreground placeholder:text-placeholder"
|
||||
/>
|
||||
{!isValidGitIdentityEmail(gitIdentity.email) && (
|
||||
<p id="git-email-error" className="text-xs text-destructive">Enter a valid email address</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -439,7 +448,7 @@ export function GitSettings() {
|
||||
value={identity.name}
|
||||
onChange={(e) => updateSavedIdentity(index, 'name', e.target.value)}
|
||||
disabled={isSaving}
|
||||
className="bg-background border-border text-foreground placeholder:text-muted-foreground"
|
||||
className="bg-background border-border text-foreground placeholder:text-placeholder"
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
@@ -451,8 +460,13 @@ export function GitSettings() {
|
||||
value={identity.email}
|
||||
onChange={(e) => updateSavedIdentity(index, 'email', e.target.value)}
|
||||
disabled={isSaving}
|
||||
className="bg-background border-border text-foreground placeholder:text-muted-foreground"
|
||||
aria-invalid={!isValidGitIdentityEmail(identity.email)}
|
||||
aria-describedby={!isValidGitIdentityEmail(identity.email) ? `git-identity-${index}-email-error` : undefined}
|
||||
className="bg-background border-border text-foreground placeholder:text-placeholder"
|
||||
/>
|
||||
{!isValidGitIdentityEmail(identity.email) && (
|
||||
<p id={`git-identity-${index}-email-error`} className="text-xs text-destructive">Enter a valid email address</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
import { render, screen, fireEvent, within, waitFor } from '@testing-library/react'
|
||||
import { KeyboardShortcuts } from './KeyboardShortcuts'
|
||||
import { Dialog, DialogContent, DialogTitle } from '@/components/ui/dialog'
|
||||
import { DEFAULT_DIRECT_SHORTCUTS, DEFAULT_KEYBOARD_SHORTCUTS, DEFAULT_LEADER_KEY } from '@/api/types/settings'
|
||||
|
||||
const { updateSettings, parseTuiKeybindConfig, applyTuiKeybindImport, showToast } = vi.hoisted(() => ({
|
||||
@@ -18,7 +19,10 @@ const { updateSettings, parseTuiKeybindConfig, applyTuiKeybindImport, showToast
|
||||
},
|
||||
}))
|
||||
|
||||
vi.mock('@/hooks/useMobile', () => ({ useMobile: () => false }))
|
||||
vi.mock('@/hooks/useMobile', () => ({
|
||||
useMobile: () => false,
|
||||
useSwipeBack: () => ({ bind: vi.fn(), swipeProgress: 0, swipeStyles: {} }),
|
||||
}))
|
||||
vi.mock('@/hooks/useSettings', () => ({
|
||||
useSettings: () => ({
|
||||
preferences: { keyboardShortcuts: { customAction: 'Alt+J' } },
|
||||
@@ -26,7 +30,10 @@ vi.mock('@/hooks/useSettings', () => ({
|
||||
updateSettings,
|
||||
}),
|
||||
}))
|
||||
vi.mock('@/lib/tuiKeybindImport', () => ({ parseTuiKeybindConfig, applyTuiKeybindImport }))
|
||||
vi.mock('@/lib/tuiKeybindImport', async () => {
|
||||
const actual = await vi.importActual<typeof import('@/lib/tuiKeybindImport')>('@/lib/tuiKeybindImport')
|
||||
return { parseTuiKeybindConfig, applyTuiKeybindImport, applyRecordedShortcut: actual.applyRecordedShortcut }
|
||||
})
|
||||
vi.mock('@/lib/toast', () => ({ showToast }))
|
||||
|
||||
const getFileInput = (container: HTMLElement) => {
|
||||
@@ -95,6 +102,69 @@ describe('KeyboardShortcuts layout', () => {
|
||||
expect(updateSettings).toHaveBeenCalledWith({ keyboardShortcuts: expect.objectContaining({ customAction: '' }) })
|
||||
expect(within(row).getByRole('button', { name: 'Not set' })).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('cancels recording on Escape without saving a binding', () => {
|
||||
render(<KeyboardShortcuts />)
|
||||
fireEvent.click(screen.getByRole('button', { name: /Alt\+J/ }))
|
||||
const input = screen.getByPlaceholderText('Press keys...')
|
||||
|
||||
expect(fireEvent.keyDown(input, { key: 'Escape' })).toBe(false)
|
||||
|
||||
expect(screen.queryByPlaceholderText('Press keys...')).not.toBeInTheDocument()
|
||||
expect(updateSettings).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('cancels recording a leader key on Escape without binding Escape as the leader', () => {
|
||||
render(<KeyboardShortcuts />)
|
||||
fireEvent.click(screen.getByRole('button', { name: DEFAULT_LEADER_KEY }))
|
||||
const input = screen.getByPlaceholderText('Press keys...')
|
||||
|
||||
fireEvent.keyDown(input, { key: 'Escape' })
|
||||
|
||||
expect(screen.queryByPlaceholderText('Press keys...')).not.toBeInTheDocument()
|
||||
expect(updateSettings).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('keeps an open Radix dialog open when Escape cancels recording', () => {
|
||||
const onOpenChange = vi.fn()
|
||||
render(
|
||||
<Dialog open onOpenChange={onOpenChange}>
|
||||
<DialogContent>
|
||||
<DialogTitle>Settings</DialogTitle>
|
||||
<KeyboardShortcuts />
|
||||
</DialogContent>
|
||||
</Dialog>,
|
||||
)
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: /Alt\+J/ }))
|
||||
fireEvent.keyDown(screen.getByPlaceholderText('Press keys...'), { key: 'Escape' })
|
||||
|
||||
expect(screen.queryByPlaceholderText('Press keys...')).not.toBeInTheDocument()
|
||||
expect(updateSettings).not.toHaveBeenCalled()
|
||||
expect(onOpenChange).not.toHaveBeenCalledWith(false)
|
||||
})
|
||||
|
||||
it('unbinds the action already using the recorded binding and names it in a toast', () => {
|
||||
render(<KeyboardShortcuts />)
|
||||
fireEvent.click(screen.getByRole('button', { name: /Alt\+J/ }))
|
||||
fireEvent.keyDown(screen.getByPlaceholderText('Press keys...'), { key: 't', ctrlKey: true })
|
||||
|
||||
expect(updateSettings).toHaveBeenCalledWith({
|
||||
keyboardShortcuts: expect.objectContaining({ customAction: 'Ctrl+T', variantCycle: '' }),
|
||||
directShortcuts: [...DEFAULT_DIRECT_SHORTCUTS, 'customAction'],
|
||||
})
|
||||
expect(showToast.info).toHaveBeenCalledWith('Shortcut conflict resolved', {
|
||||
description: 'Unbound to avoid conflicts: variant cycle',
|
||||
})
|
||||
})
|
||||
|
||||
it('resets custom shortcuts and the leader key to the defaults', () => {
|
||||
render(<KeyboardShortcuts />)
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Reset to defaults' }))
|
||||
|
||||
expect(updateSettings).toHaveBeenCalledWith({ keyboardShortcuts: {}, directShortcuts: [], leaderKey: '' })
|
||||
expect(showToast.success).toHaveBeenCalledWith('Keyboard shortcuts reset to defaults')
|
||||
})
|
||||
})
|
||||
|
||||
describe('KeyboardShortcuts TUI import', () => {
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useMobile } from '@/hooks/useMobile'
|
||||
import { Loader2, X } from 'lucide-react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { formatEventModifiers, formatShortcutEvent, formatShortcutLabel, isModifierOnlyEvent, normalizeShortcut, resolveShortcutBindings } from '@/lib/keyboardShortcuts'
|
||||
import { applyTuiKeybindImport, parseTuiKeybindConfig } from '@/lib/tuiKeybindImport'
|
||||
import { applyRecordedShortcut, applyTuiKeybindImport, parseTuiKeybindConfig } from '@/lib/tuiKeybindImport'
|
||||
import { showToast } from '@/lib/toast'
|
||||
|
||||
const CONVERSATION_ACTIONS = ['submit', 'abort', 'clearPrompt', 'toggleMode', 'undo', 'redo', 'compact', 'fork', 'timeline', 'exportSession', 'selectModel', 'variantCycle', 'favoriteCycle', 'halfPageUp', 'halfPageDown', 'speakVisible']
|
||||
@@ -180,6 +180,14 @@ export function KeyboardShortcuts() {
|
||||
})
|
||||
}, [])
|
||||
|
||||
const resetShortcuts = () => {
|
||||
stopRecording()
|
||||
setTempShortcuts({})
|
||||
setTempLeaderKey(null)
|
||||
updateSettings({ keyboardShortcuts: {}, directShortcuts: [], leaderKey: '' })
|
||||
showToast.success('Keyboard shortcuts reset to defaults')
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (!recordingKey && !recordingLeader) return
|
||||
|
||||
@@ -190,6 +198,11 @@ export function KeyboardShortcuts() {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
|
||||
if (e.key === 'Escape') {
|
||||
stopRecording()
|
||||
return
|
||||
}
|
||||
|
||||
const shortcut = formatShortcutEvent(e)
|
||||
if (!shortcut) {
|
||||
setCurrentKeys(leaderPrefix() + formatEventModifiers(e))
|
||||
@@ -212,14 +225,22 @@ export function KeyboardShortcuts() {
|
||||
return
|
||||
}
|
||||
|
||||
const otherDirectShortcuts = directShortcutsRef.current.filter((action) => action !== recordingKey)
|
||||
setTempShortcuts(prev => ({ ...prev, [recordingKey]: shortcut }))
|
||||
const applied = applyRecordedShortcut(recordingKey, shortcut, leaderPressed, {
|
||||
keyboardShortcuts: shortcutsRef.current,
|
||||
directShortcuts: directShortcutsRef.current,
|
||||
})
|
||||
setTempShortcuts(applied.keyboardShortcuts)
|
||||
setRecordingKey(null)
|
||||
setCurrentKeys('')
|
||||
updateSettingsRef.current({
|
||||
keyboardShortcuts: { ...shortcutsRef.current, [recordingKey]: shortcut },
|
||||
directShortcuts: leaderPressed ? otherDirectShortcuts : [...otherDirectShortcuts, recordingKey],
|
||||
keyboardShortcuts: applied.keyboardShortcuts,
|
||||
directShortcuts: applied.directShortcuts,
|
||||
})
|
||||
if (applied.cleared.length > 0) {
|
||||
showToast.info('Shortcut conflict resolved', {
|
||||
description: `Unbound to avoid conflicts: ${applied.cleared.map((action) => formatActionLabel(action).toLowerCase()).join(', ')}`,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const handleKeyUp = (e: KeyboardEvent) => {
|
||||
@@ -228,13 +249,13 @@ export function KeyboardShortcuts() {
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('keydown', handleKeyDown, true)
|
||||
document.addEventListener('keyup', handleKeyUp)
|
||||
window.addEventListener('keydown', handleKeyDown, true)
|
||||
window.addEventListener('keyup', handleKeyUp)
|
||||
return () => {
|
||||
document.removeEventListener('keydown', handleKeyDown, true)
|
||||
document.removeEventListener('keyup', handleKeyUp)
|
||||
window.removeEventListener('keydown', handleKeyDown, true)
|
||||
window.removeEventListener('keyup', handleKeyUp)
|
||||
}
|
||||
}, [recordingKey, recordingLeader])
|
||||
}, [recordingKey, recordingLeader, stopRecording])
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
@@ -321,9 +342,14 @@ export function KeyboardShortcuts() {
|
||||
<h2 className="text-lg font-semibold text-foreground">Keyboard Shortcuts</h2>
|
||||
|
||||
<div className="flex flex-col items-end gap-1">
|
||||
<Button variant="outline" size="sm" onClick={() => fileInputRef.current?.click()}>
|
||||
Import from OpenCode TUI
|
||||
</Button>
|
||||
<div className="flex flex-wrap justify-end gap-2">
|
||||
<Button variant="outline" size="sm" onClick={resetShortcuts}>
|
||||
Reset to defaults
|
||||
</Button>
|
||||
<Button variant="outline" size="sm" onClick={() => fileInputRef.current?.click()}>
|
||||
Import from OpenCode TUI
|
||||
</Button>
|
||||
</div>
|
||||
<input
|
||||
ref={fileInputRef}
|
||||
type="file"
|
||||
|
||||
@@ -57,6 +57,7 @@ export function ManagerTokenSettings({ isOpen: controlledOpen, onToggle }: Manag
|
||||
type="button"
|
||||
onClick={() => setShowToken(!showToken)}
|
||||
disabled={!token}
|
||||
aria-label={showToken ? 'Hide token' : 'Show token'}
|
||||
className="absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground"
|
||||
>
|
||||
{showToken ? <EyeOff className="h-4 w-4" /> : <Eye className="h-4 w-4" />}
|
||||
@@ -73,6 +74,8 @@ export function ManagerTokenSettings({ isOpen: controlledOpen, onToggle }: Manag
|
||||
type="button"
|
||||
onClick={handleRotate}
|
||||
disabled={rotate.isPending || isLoading}
|
||||
aria-label="Rotate token"
|
||||
title="Rotate token"
|
||||
>
|
||||
<RefreshCw className={`h-4 w-4 ${rotate.isPending ? 'animate-spin' : ''}`} />
|
||||
</Button>
|
||||
|
||||
@@ -77,6 +77,7 @@ export function OpenCodeServerAuthSettings({ isOpen: controlledOpen, onToggle }:
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setShowPassword(!showPassword)}
|
||||
aria-label={showPassword ? 'Hide password' : 'Show password'}
|
||||
className="absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground"
|
||||
>
|
||||
{showPassword ? <EyeOff className="h-4 w-4" /> : <Eye className="h-4 w-4" />}
|
||||
|
||||
@@ -273,7 +273,7 @@ export function STTSettings() {
|
||||
<input
|
||||
type="text"
|
||||
placeholder="https://api.openai.com"
|
||||
className="flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-[16px] md:text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
|
||||
className="flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-[16px] md:text-sm ring-offset-background placeholder:text-placeholder focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
|
||||
{...field}
|
||||
/>
|
||||
</FormControl>
|
||||
@@ -296,7 +296,7 @@ export function STTSettings() {
|
||||
<input
|
||||
type={showApiKey ? 'text' : 'password'}
|
||||
placeholder="sk-..."
|
||||
className="flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 pr-10 text-[16px] md:text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
|
||||
className="flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 pr-10 text-[16px] md:text-sm ring-offset-background placeholder:text-placeholder focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
|
||||
{...field}
|
||||
/>
|
||||
<button
|
||||
|
||||
@@ -1,12 +1,20 @@
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
|
||||
import { render, screen, fireEvent, within, act } from '@testing-library/react'
|
||||
import { render, screen, fireEvent, within, act, waitFor } from '@testing-library/react'
|
||||
import { MemoryRouter, useLocation, useNavigate } from 'react-router-dom'
|
||||
import { SettingsDialog } from './SettingsDialog'
|
||||
import { useSettingsDialog } from '@/hooks/useSettingsDialog'
|
||||
import { Dialog, DialogContent, DialogTitle } from '@/components/ui/dialog'
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'
|
||||
import { stubMatchMedia } from '@/test/test-utils'
|
||||
|
||||
vi.mock('@/components/settings/GeneralSettings', () => ({
|
||||
GeneralSettings: () => <div data-testid="general-settings">General Settings Content</div>,
|
||||
GeneralSettings: () => (
|
||||
<div data-testid="general-settings">
|
||||
General Settings Content
|
||||
<label htmlFor="settings-general-field">Appearance</label>
|
||||
<input id="settings-general-field" data-testid="general-field" />
|
||||
</div>
|
||||
),
|
||||
}))
|
||||
|
||||
vi.mock('@/components/settings/GitSettings', () => ({
|
||||
@@ -136,6 +144,38 @@ describe('SettingsDialog', () => {
|
||||
expect(mobile.queryByTestId('logs-settings')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('shows the mobile settings menu when opened through the settings action', () => {
|
||||
function TestWrapper() {
|
||||
const { open } = useSettingsDialog()
|
||||
const location = useLocation()
|
||||
|
||||
return (
|
||||
<>
|
||||
<button onClick={open}>Open Settings</button>
|
||||
<span data-testid="location-search">{location.search}</span>
|
||||
<SettingsDialog />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
render(
|
||||
<MemoryRouter initialEntries={['/']}>
|
||||
<TestWrapper />
|
||||
</MemoryRouter>,
|
||||
)
|
||||
|
||||
fireEvent.click(screen.getByText('Open Settings'))
|
||||
|
||||
expect(screen.getByTestId('location-search')).toHaveTextContent('settings=open')
|
||||
expect(screen.getByTestId('location-search')).not.toHaveTextContent('settingsTab')
|
||||
|
||||
const mobileContainer = document.querySelector('.sm\\:hidden') as HTMLElement
|
||||
const mobile = within(mobileContainer)
|
||||
expect(mobile.getByRole('heading', { name: 'Settings' })).toBeInTheDocument()
|
||||
expect(mobileContainer.querySelector('svg.lucide-chevron-left')).toBeNull()
|
||||
expect(mobile.queryByTestId('account-settings')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('navigates to the Logs section and reflects settingsTab=logs in the URL', () => {
|
||||
function TestWrapper() {
|
||||
const location = useLocation()
|
||||
@@ -171,20 +211,14 @@ describe('SettingsDialog', () => {
|
||||
expect(screen.getByTestId('location-search')).toHaveTextContent('settingsTab=logs')
|
||||
})
|
||||
|
||||
it('starts at the menu on mobile even with a deep-linked settingsTab and navigates from there', () => {
|
||||
it('opens the deep-linked settingsTab on mobile and returns to the menu from it', () => {
|
||||
stubMatchMedia(false)
|
||||
function TestWrapper() {
|
||||
const location = useLocation()
|
||||
const navigate = useNavigate()
|
||||
|
||||
const searchParams = new URLSearchParams(location.search)
|
||||
const isOpen = searchParams.get('settings') === 'open'
|
||||
|
||||
return (
|
||||
<>
|
||||
<button onClick={() => navigate('/')}>Close Settings</button>
|
||||
{isOpen && <span data-testid="dialog-open">Dialog Open</span>}
|
||||
{isOpen && <span data-testid="location-search">{location.search}</span>}
|
||||
<span data-testid="location-search">{location.search}</span>
|
||||
<SettingsDialog />
|
||||
</>
|
||||
)
|
||||
@@ -196,24 +230,11 @@ describe('SettingsDialog', () => {
|
||||
</MemoryRouter>
|
||||
)
|
||||
|
||||
expect(screen.getByTestId('dialog-open')).toBeInTheDocument()
|
||||
|
||||
const mobileContainer = document.querySelector('.sm\\:hidden') as HTMLElement
|
||||
const mobile = within(mobileContainer)
|
||||
|
||||
expect(mobile.getByRole('heading', { name: 'Settings' })).toBeInTheDocument()
|
||||
expect(mobile.getByText('Live manager and OpenCode server logs')).toBeInTheDocument()
|
||||
expect(mobile.queryByTestId('logs-settings')).not.toBeInTheDocument()
|
||||
expect(mobileContainer.querySelector('svg.lucide-chevron-left')).toBeNull()
|
||||
expect(screen.queryByTestId('logs-settings')).not.toBeInTheDocument()
|
||||
|
||||
const logsMenuButton = mobile.getByText('Live manager and OpenCode server logs').closest('button')
|
||||
expect(logsMenuButton).not.toBeNull()
|
||||
fireEvent.click(logsMenuButton!)
|
||||
|
||||
expect(mobile.getByTestId('logs-settings')).toBeInTheDocument()
|
||||
expect(mobile.getByRole('heading', { name: 'Logs' })).toBeInTheDocument()
|
||||
expect(screen.getAllByTestId('logs-settings')).toHaveLength(1)
|
||||
expect(screen.getByTestId('location-search')).toHaveTextContent('settingsTab=logs')
|
||||
|
||||
const backButton = mobileContainer.querySelector('svg.lucide-chevron-left')?.closest('button')
|
||||
@@ -225,6 +246,36 @@ describe('SettingsDialog', () => {
|
||||
expect(mobileContainer.querySelector('svg.lucide-chevron-left')).toBeNull()
|
||||
})
|
||||
|
||||
it('switches the mobile section when the settingsTab param changes while open', () => {
|
||||
stubMatchMedia(false)
|
||||
function TestWrapper() {
|
||||
const navigate = useNavigate()
|
||||
|
||||
return (
|
||||
<>
|
||||
<button onClick={() => navigate('?settings=open')}>Open Settings</button>
|
||||
<button onClick={() => navigate('?settings=open&settingsTab=git')}>Open Git</button>
|
||||
<SettingsDialog />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
render(
|
||||
<MemoryRouter initialEntries={['/']}>
|
||||
<TestWrapper />
|
||||
</MemoryRouter>
|
||||
)
|
||||
|
||||
fireEvent.click(screen.getByText('Open Settings'))
|
||||
const mobileContainer = document.querySelector('.sm\\:hidden') as HTMLElement
|
||||
const mobile = within(mobileContainer)
|
||||
expect(mobile.getByRole('heading', { name: 'Settings' })).toBeInTheDocument()
|
||||
|
||||
fireEvent.click(screen.getByText('Open Git'))
|
||||
expect(mobile.getByTestId('git-settings')).toBeInTheDocument()
|
||||
expect(mobile.getByRole('heading', { name: 'Git' })).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('mounts exactly one LogsViewer on desktop when the Logs tab is selected', () => {
|
||||
stubMatchMedia(true)
|
||||
function TestWrapper() {
|
||||
@@ -252,12 +303,23 @@ describe('SettingsDialog', () => {
|
||||
fireEvent.click(screen.getByText('Open Logs'))
|
||||
|
||||
expect(screen.getAllByTestId('logs-settings')).toHaveLength(1)
|
||||
const mobileContainer = document.querySelector('.sm\\:hidden') as HTMLElement
|
||||
expect(within(mobileContainer).queryByTestId('logs-settings')).not.toBeInTheDocument()
|
||||
expect(within(mobileContainer).getByRole('heading', { name: 'Logs' })).toBeInTheDocument()
|
||||
expect(document.querySelector('.sm\\:hidden')).toBeNull()
|
||||
})
|
||||
|
||||
it('falls back to the menu and account tab for an unknown settingsTab value', () => {
|
||||
it('mounts the deep-linked tab content once on desktop', () => {
|
||||
stubMatchMedia(true)
|
||||
render(
|
||||
<MemoryRouter initialEntries={['/?settings=open&settingsTab=general']}>
|
||||
<SettingsDialog />
|
||||
</MemoryRouter>
|
||||
)
|
||||
|
||||
expect(screen.getAllByTestId('general-settings')).toHaveLength(1)
|
||||
expect(document.querySelectorAll('#settings-general-field')).toHaveLength(1)
|
||||
expect(document.querySelector('.sm\\:hidden')).toBeNull()
|
||||
})
|
||||
|
||||
it('falls back to the menu for an unknown settingsTab value', () => {
|
||||
function TestWrapper() {
|
||||
const location = useLocation()
|
||||
const isOpen = new URLSearchParams(location.search).get('settings') === 'open'
|
||||
@@ -284,8 +346,38 @@ describe('SettingsDialog', () => {
|
||||
expect(mobile.queryByTestId('logs-settings')).not.toBeInTheDocument()
|
||||
expect(mobileContainer.querySelector('svg.lucide-chevron-left')).toBeNull()
|
||||
|
||||
const desktopTrigger = screen.getByRole('tab', { name: 'Account' })
|
||||
expect(desktopTrigger).toHaveAttribute('data-state', 'active')
|
||||
expect(screen.queryByRole('tablist')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('selects the account tab on desktop for an unknown settingsTab value', () => {
|
||||
stubMatchMedia(true)
|
||||
render(
|
||||
<MemoryRouter initialEntries={['/?settings=open&settingsTab=log']}>
|
||||
<SettingsDialog />
|
||||
</MemoryRouter>
|
||||
)
|
||||
|
||||
expect(screen.getByRole('tab', { name: 'Account' })).toHaveAttribute('data-state', 'active')
|
||||
expect(document.querySelector('.sm\\:hidden')).toBeNull()
|
||||
})
|
||||
|
||||
it('mounts a deep-linked mobile section once and keeps label associations', () => {
|
||||
stubMatchMedia(false)
|
||||
render(
|
||||
<MemoryRouter initialEntries={['/?settings=open&settingsTab=general']}>
|
||||
<SettingsDialog />
|
||||
</MemoryRouter>
|
||||
)
|
||||
|
||||
expect(screen.getAllByTestId('general-settings')).toHaveLength(1)
|
||||
expect(document.querySelectorAll('#settings-general-field')).toHaveLength(1)
|
||||
|
||||
const mobileContainer = document.querySelector('.sm\\:hidden') as HTMLElement
|
||||
const mobile = within(mobileContainer)
|
||||
const mobileField = mobile.getByTestId('general-field')
|
||||
const label = mobile.getByText('Appearance') as HTMLLabelElement
|
||||
expect(label.control).toBe(mobileField)
|
||||
expect(document.getElementById('settings-general-field')).toBe(mobileField)
|
||||
})
|
||||
|
||||
it('renders a vertical desktop sidebar driven by menu items with URL and keyboard navigation', async () => {
|
||||
@@ -361,4 +453,63 @@ describe('SettingsDialog', () => {
|
||||
|
||||
expect(screen.getByTestId('settings-open')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('keeps Settings open when Escape closes an open Select', async () => {
|
||||
function TestWrapper() {
|
||||
const location = useLocation()
|
||||
const settingsOpen = new URLSearchParams(location.search).get('settings') === 'open'
|
||||
return (
|
||||
<>
|
||||
{settingsOpen && <span data-testid="settings-open" />}
|
||||
<SettingsDialog />
|
||||
<Select defaultOpen>
|
||||
<SelectTrigger aria-label="Theme">
|
||||
<SelectValue placeholder="Theme" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="dark">Dark</SelectItem>
|
||||
<SelectItem value="light">Light</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
render(
|
||||
<MemoryRouter initialEntries={['/?settings=open&settingsTab=general']}>
|
||||
<TestWrapper />
|
||||
</MemoryRouter>,
|
||||
)
|
||||
|
||||
const listbox = await screen.findByRole('listbox')
|
||||
fireEvent.keyDown(listbox, { key: 'Escape' })
|
||||
|
||||
await waitFor(() => expect(screen.queryByRole('listbox')).not.toBeInTheDocument())
|
||||
expect(screen.getByTestId('settings-open')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('closes Settings on Escape when no dropdown or nested dialog is open', () => {
|
||||
function TestWrapper() {
|
||||
const location = useLocation()
|
||||
const settingsOpen = new URLSearchParams(location.search).get('settings') === 'open'
|
||||
return (
|
||||
<>
|
||||
{settingsOpen && <span data-testid="settings-open" />}
|
||||
<SettingsDialog />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
render(
|
||||
<MemoryRouter initialEntries={['/?settings=open']}>
|
||||
<TestWrapper />
|
||||
</MemoryRouter>,
|
||||
)
|
||||
|
||||
expect(screen.getByTestId('settings-open')).toBeInTheDocument()
|
||||
|
||||
fireEvent.keyDown(document.body, { key: 'Escape' })
|
||||
|
||||
expect(screen.queryByTestId('settings-open')).not.toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useState, useEffect, useCallback } from 'react'
|
||||
import { useState, useEffect, useCallback, useRef } from 'react'
|
||||
import { GeneralSettings } from '@/components/settings/GeneralSettings'
|
||||
import { GitSettings } from '@/components/settings/GitSettings'
|
||||
import { OpenCodeServersSettings } from '@/components/settings/OpenCodeServersSettings'
|
||||
@@ -25,6 +25,14 @@ import { DESKTOP_MEDIA_QUERY, useMediaQuery } from '@/hooks/useMediaQuery'
|
||||
|
||||
type SettingsView = 'menu' | SettingsContentTab
|
||||
|
||||
const NESTED_OVERLAY_SELECTOR = [
|
||||
'[role="listbox"]',
|
||||
'[role="menu"]',
|
||||
'[data-radix-popper-content-wrapper]',
|
||||
'[role="alertdialog"]',
|
||||
'[role="dialog"]:not([data-settings-dialog])',
|
||||
].join(', ')
|
||||
|
||||
function OpenCodeSettings({ onOpenVersionDialog }: { onOpenVersionDialog: () => void }) {
|
||||
const [authSectionsOpen, setAuthSectionsOpen] = useState(true)
|
||||
const toggleAuthSections = useCallback(() => setAuthSectionsOpen((open) => !open), [])
|
||||
@@ -49,11 +57,12 @@ function OpenCodeSettings({ onOpenVersionDialog }: { onOpenVersionDialog: () =>
|
||||
}
|
||||
|
||||
export function SettingsDialog() {
|
||||
const { isOpen, close, activeTab, setActiveTab } = useSettingsDialog()
|
||||
const { isOpen, close, activeTab, selectedTab, setActiveTab } = useSettingsDialog()
|
||||
const isDesktop = useMediaQuery(DESKTOP_MEDIA_QUERY)
|
||||
const [mobileView, setMobileView] = useState<SettingsView>('menu')
|
||||
const [isVersionDialogOpen, setIsVersionDialogOpen] = useState(false)
|
||||
const [sectionHistory, setSectionHistory] = useState<SettingsView[]>([])
|
||||
const syncedTabRef = useRef<SettingsContentTab | null>(null)
|
||||
|
||||
const pushSectionHistory = useCallback((view: SettingsView) => {
|
||||
if (view === 'menu') return
|
||||
@@ -88,26 +97,35 @@ export function SettingsDialog() {
|
||||
|
||||
useEffect(() => {
|
||||
if (!isOpen) {
|
||||
syncedTabRef.current = null
|
||||
setMobileView('menu')
|
||||
setSectionHistory([])
|
||||
return
|
||||
}
|
||||
const handleKeyDown = (e: KeyboardEvent) => {
|
||||
if (e.key === 'Escape' && !isVersionDialogOpen) {
|
||||
const target = e.target
|
||||
if (target instanceof Element) {
|
||||
const closestDialog = target.closest('[role="dialog"]')
|
||||
if (closestDialog && !closestDialog.hasAttribute('data-settings-dialog')) {
|
||||
return
|
||||
}
|
||||
}
|
||||
close()
|
||||
}
|
||||
if (e.key !== 'Escape' || e.defaultPrevented || isVersionDialogOpen) return
|
||||
if (e.target instanceof Element && e.target.closest(NESTED_OVERLAY_SELECTOR)) return
|
||||
close()
|
||||
}
|
||||
document.addEventListener('keydown', handleKeyDown, { capture: true })
|
||||
return () => document.removeEventListener('keydown', handleKeyDown, { capture: true })
|
||||
document.addEventListener('keydown', handleKeyDown)
|
||||
return () => document.removeEventListener('keydown', handleKeyDown)
|
||||
}, [isOpen, close, isVersionDialogOpen])
|
||||
|
||||
useEffect(() => {
|
||||
if (!isOpen || isDesktop) return
|
||||
if (!selectedTab) {
|
||||
if (syncedTabRef.current === null) return
|
||||
syncedTabRef.current = null
|
||||
setMobileView('menu')
|
||||
setSectionHistory([])
|
||||
return
|
||||
}
|
||||
if (syncedTabRef.current === selectedTab) return
|
||||
syncedTabRef.current = selectedTab
|
||||
setMobileView(selectedTab)
|
||||
pushSectionHistory(selectedTab)
|
||||
}, [isOpen, isDesktop, selectedTab, pushSectionHistory])
|
||||
|
||||
const menuItems: Array<{ id: SettingsContentTab; icon: LucideIcon; label: string; description: string }> = [
|
||||
{ id: 'account', icon: User, label: 'Account', description: 'Profile, passkeys, and sign out' },
|
||||
{ id: 'general', icon: Settings2, label: 'General Settings', description: 'App preferences and behavior' },
|
||||
@@ -147,6 +165,7 @@ export function SettingsDialog() {
|
||||
data-settings-dialog
|
||||
>
|
||||
<DialogTitle className="sr-only">Settings</DialogTitle>
|
||||
{isDesktop && (
|
||||
<div className="hidden sm:flex sm:h-full sm:min-h-0 sm:flex-col">
|
||||
<div className="flex h-12 shrink-0 items-center justify-between border-b border-border bg-background px-4">
|
||||
<h2 className="text-lg font-semibold text-foreground">Settings</h2>
|
||||
@@ -191,12 +210,14 @@ export function SettingsDialog() {
|
||||
<TabsContent key="opencode" value="opencode" className="mt-0 px-0">
|
||||
<OpenCodeSettings onOpenVersionDialog={() => setIsVersionDialogOpen(true)} />
|
||||
</TabsContent>
|
||||
<TabsContent key="logs" value="logs" className="mt-0 h-full min-h-0 px-0">{isDesktop && <LogsViewer />}</TabsContent>
|
||||
<TabsContent key="logs" value="logs" className="mt-0 h-full min-h-0 px-0"><LogsViewer /></TabsContent>
|
||||
<TabsContent key="providers" value="providers" className="mt-0 px-0 max-w-7xl"><ProviderSettings /></TabsContent>
|
||||
</div>
|
||||
</Tabs>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!isDesktop && (
|
||||
<div className="sm:hidden flex flex-col h-full min-h-0">
|
||||
<div className="flex-shrink-0 bg-gradient-to-b from-background via-background to-transparent border-b border-border backdrop-blur-sm px-3 py-3 flex items-center justify-between">
|
||||
<div className="flex items-center gap-2 flex-1">
|
||||
@@ -205,12 +226,13 @@ export function SettingsDialog() {
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
onClick={handleSettingsBack}
|
||||
aria-label="Back"
|
||||
className="text-muted-foreground hover:text-foreground min-w-[44px] min-h-[44px]"
|
||||
>
|
||||
<ChevronLeft className="w-6 h-6" />
|
||||
</Button>
|
||||
)}
|
||||
<h2 className="text-xl font-semibold bg-gradient-to-r from-foreground to-muted-foreground bg-clip-text text-transparent">
|
||||
<h2 className="min-w-0 text-xl font-semibold bg-gradient-to-r from-foreground to-muted-foreground bg-clip-text text-transparent">
|
||||
{mobileView === 'menu' ? 'Settings' : menuItems.find(item => item.id === mobileView)?.label}
|
||||
</h2>
|
||||
</div>
|
||||
@@ -259,9 +281,10 @@ export function SettingsDialog() {
|
||||
<OpenCodeSettings key="opencode" onOpenVersionDialog={() => setIsVersionDialogOpen(true)} />
|
||||
)}
|
||||
{mobileView === 'providers' && <div key="providers"><ProviderSettings /></div>}
|
||||
{mobileView === 'logs' && !isDesktop && <div key="logs" className="h-full min-h-0"><LogsViewer /></div>}
|
||||
{mobileView === 'logs' && <div key="logs" className="h-full min-h-0"><LogsViewer /></div>}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
</DialogContent>
|
||||
<VersionSelectDialog
|
||||
|
||||
@@ -73,8 +73,8 @@ async function settleTime(ms: number): Promise<void> {
|
||||
|
||||
function openLogsFromMenu(): void {
|
||||
const mobileContainer = document.querySelector('.sm\\:hidden') as HTMLElement
|
||||
const logsMenuButton = within(mobileContainer).getByText('Live manager and OpenCode server logs').closest('button')
|
||||
fireEvent.click(logsMenuButton!)
|
||||
const logsMenuButton = within(mobileContainer).queryByText('Live manager and OpenCode server logs')?.closest('button')
|
||||
if (logsMenuButton) fireEvent.click(logsMenuButton)
|
||||
}
|
||||
|
||||
describe('SettingsDialog live Logs view integration', () => {
|
||||
|
||||
@@ -51,7 +51,7 @@ export function SettingsDisclosure({
|
||||
>
|
||||
<div className="flex items-center gap-2 min-w-0">
|
||||
{icon}
|
||||
<h3 className="text-sm font-semibold truncate">{title}</h3>
|
||||
<h3 className="text-sm font-semibold">{title}</h3>
|
||||
{meta}
|
||||
</div>
|
||||
<ChevronDown className={cn('h-4 w-4 shrink-0 transition-transform', isOpen && 'rotate-180')} />
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
|
||||
import { render, screen } from '@testing-library/react'
|
||||
import { render, screen, act } from '@testing-library/react'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
||||
import type { ReactNode } from 'react'
|
||||
@@ -182,4 +182,33 @@ describe('TTSSettings audio cache', () => {
|
||||
expect(screen.getByRole('button', { name: 'Clear audio cache' })).toBeInTheDocument()
|
||||
expect(await screen.findByText('1 voices available in your browser')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('discovers models and voices only when external TTS is configured', async () => {
|
||||
renderTTSSettings()
|
||||
await act(async () => {})
|
||||
expect(vi.mocked(useTTSModels).mock.calls.at(-1)?.[1]).toBe(true)
|
||||
expect(vi.mocked(useTTSVoices).mock.calls.at(-1)?.[1]).toBe(true)
|
||||
})
|
||||
|
||||
it('skips server discovery while TTS is disabled, builtin, or missing credentials', async () => {
|
||||
mockHooks(buildPreferences({ tts: { ...baseTts, enabled: false } }))
|
||||
const disabledRender = renderTTSSettings()
|
||||
await act(async () => {})
|
||||
expect(vi.mocked(useTTSModels).mock.calls.at(-1)?.[1]).toBe(false)
|
||||
expect(vi.mocked(useTTSVoices).mock.calls.at(-1)?.[1]).toBe(false)
|
||||
disabledRender.unmount()
|
||||
|
||||
mockHooks(buildPreferences({ tts: { ...baseTts, provider: 'builtin', voice: 'Alex' } }))
|
||||
const builtinRender = renderTTSSettings()
|
||||
await act(async () => {})
|
||||
expect(vi.mocked(useTTSModels).mock.calls.at(-1)?.[1]).toBe(false)
|
||||
expect(vi.mocked(useTTSVoices).mock.calls.at(-1)?.[1]).toBe(false)
|
||||
builtinRender.unmount()
|
||||
|
||||
mockHooks(buildPreferences({ tts: { ...baseTts, apiKey: '' } }))
|
||||
renderTTSSettings()
|
||||
await act(async () => {})
|
||||
expect(vi.mocked(useTTSModels).mock.calls.at(-1)?.[1]).toBe(false)
|
||||
expect(vi.mocked(useTTSVoices).mock.calls.at(-1)?.[1]).toBe(false)
|
||||
})
|
||||
})
|
||||
@@ -94,15 +94,22 @@ export function TTSSettings() {
|
||||
|
||||
const { reset, formState: { isDirty, isValid }, getValues } = form
|
||||
|
||||
const shouldDiscoverTTS = Boolean(
|
||||
preferences?.tts?.enabled
|
||||
&& preferences.tts.provider === 'external'
|
||||
&& preferences.tts.apiKey
|
||||
&& preferences.tts.endpoint,
|
||||
)
|
||||
|
||||
// Fetch available models and voices for external provider
|
||||
const { data: modelsData, isLoading: isLoadingModels, refetch: refetchModels } = useTTSModels(
|
||||
undefined,
|
||||
true
|
||||
shouldDiscoverTTS
|
||||
)
|
||||
|
||||
const { data: voicesData, isLoading: isLoadingVoices, refetch: refetchVoices } = useTTSVoices(
|
||||
undefined,
|
||||
true
|
||||
shouldDiscoverTTS
|
||||
)
|
||||
|
||||
const availableModels = modelsData?.models || preferences?.tts?.availableModels || []
|
||||
|
||||
Reference in new issue
Block a user