Files
opencode-manager/frontend/src/components/settings/ManagerTokenSettings.tsx
T
ioplex 4ec62cd4e7 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.
2026-10-23 11:42:37 -04:00

95 lines
3.3 KiB
TypeScript

import { useState } from 'react'
import { useManagerToken } from '@/hooks/useManagerToken'
import { Button, buttonVariants } from '@/components/ui/button'
import { Input } from '@/components/ui/input'
import { Alert, AlertDescription } from '@/components/ui/alert'
import { AlertTriangle, Eye, EyeOff, RefreshCw } from 'lucide-react'
import { CopyButton } from '@/components/ui/copy-button'
import { SettingsDisclosure } from './SettingsDisclosure'
interface ManagerTokenSettingsProps {
isOpen?: boolean
onToggle?: () => void
}
export function ManagerTokenSettings({ isOpen: controlledOpen, onToggle }: ManagerTokenSettingsProps = {}) {
const { token, isLoading, rotate } = useManagerToken()
const [showToken, setShowToken] = useState(false)
const [confirmRotate, setConfirmRotate] = useState(false)
const [uncontrolledOpen, setUncontrolledOpen] = useState(true)
const isOpen = controlledOpen ?? uncontrolledOpen
const handleToggle = onToggle ?? (() => setUncontrolledOpen((open) => !open))
const handleRotate = () => {
if (!confirmRotate) {
setConfirmRotate(true)
setTimeout(() => setConfirmRotate(false), 4000)
return
}
rotate.mutate()
setConfirmRotate(false)
}
return (
<SettingsDisclosure
title="Manager Internal Token"
isOpen={isOpen}
onToggle={handleToggle}
contentClassName="space-y-3"
meta={
<span className="text-xs text-muted-foreground truncate hidden sm:inline">
Bearer token for workspace plugin and API clients
</span>
}
>
<div className="flex items-center gap-2">
<div className="relative flex-1">
<Input
id="manager-token"
type={showToken ? 'text' : 'password'}
value={isLoading ? 'Loading...' : token ?? ''}
readOnly
className="flex-1 font-mono text-xs pr-9"
autoComplete="new-password"
name="manager-token-input"
/>
<button
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" />}
</button>
</div>
<CopyButton
content={token ?? ''}
title="Copy"
className={buttonVariants({ variant: 'outline', size: 'icon' })}
/>
<Button
variant={confirmRotate ? 'destructive' : 'outline'}
size="icon"
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>
</div>
{confirmRotate && (
<Alert variant="destructive">
<AlertTriangle className="h-4 w-4" />
<AlertDescription>
Rotating will invalidate the existing token. Any plugin or client using it must be updated. Click Rotate again to confirm.
</AlertDescription>
</Alert>
)}
</SettingsDisclosure>
)
}