feat(themes): apply OpenCode color themes app-wide with a settings picker (#364)

- Vendor the 36 OpenCode theme palettes into the shared package, synced
  from the pinned OpenCode release tag via pnpm themes:sync.
- Add a colorTheme user preference across the settings schema, defaults,
  and the assistant internal API.
- Extend palettes with success, warning, info, and diff colors, and add a
  resolver that maps palettes to CSS tokens and applies them to the DOM.
- Apply the theme app-wide through a ThemeProvider context, adopting the
  tokens in message, repo, session, and settings components, agent
  colors, git status styles, and diff viewers.
- Add a theme picker to General settings and make model quick-select
  follow the active theme (fixes #355).
This commit is contained in:
Chris Scott authored and GitHub committed 2026-09-28 00:19:32 -04:00
1 parent 702e3c4e13
commit 5bd688de4b
116 files changed
+2702 -760

No files matched your search

@@ -150,7 +150,7 @@ export function BackgroundWorkBar({ sessionID, directory, messages, isSessionAct
className="ml-auto flex items-center gap-1 rounded-md border border-border bg-card/60 px-2 py-1 text-muted-foreground hover:text-foreground"
aria-expanded={expanded}
>
<Loader2 className="h-3 w-3 animate-spin text-yellow-600 dark:text-yellow-400" />
<Loader2 className="h-3 w-3 animate-spin text-warning" />
{shells.length} background shell{shells.length === 1 ? '' : 's'}
{expanded ? <ChevronUp className="h-3 w-3" /> : <ChevronDown className="h-3 w-3" />}
</button>
@@ -161,7 +161,7 @@ export function BackgroundWorkBar({ sessionID, directory, messages, isSessionAct
<ul className="rounded-md border border-border bg-card/60">
{shells.map((shell) => (
<li key={shell.id} className="flex items-center gap-2 border-b border-border px-2 py-1 last:border-b-0">
<Terminal className="h-3 w-3 shrink-0 text-green-600 dark:text-green-400" />
<Terminal className="h-3 w-3 shrink-0 text-success" />
<span className="min-w-0 flex-1 truncate font-mono" title={shell.command}>{shell.command}</span>
<Button variant="ghost" size="sm" className="h-6 px-2 text-xs" onClick={() => setViewing(shell)}>
Output
@@ -8,9 +8,9 @@ interface ContextUsageIndicatorProps {
}
const getUsageTextColor = (percentage: number) => {
if (percentage < 50) return 'text-green-700 dark:text-green-400'
if (percentage < 80) return 'text-yellow-700 dark:text-yellow-400'
return 'text-red-700 dark:text-red-400'
if (percentage < 50) return 'text-success'
if (percentage < 80) return 'text-warning'
return 'text-destructive'
}
export function ContextUsageIndicator({ directory, sessionID, isConnected, isReconnecting }: ContextUsageIndicatorProps) {
@@ -25,7 +25,7 @@ export function ContextUsageIndicator({ directory, sessionID, isConnected, isRec
}
if (isReconnecting) {
return <span className="text-xs text-yellow-700 dark:text-yellow-400 font-medium">Reconnecting...</span>
return <span className="text-xs text-warning font-medium">Reconnecting...</span>
}
if (!isConnected) {
@@ -75,7 +75,7 @@ export function EditSessionTitleDialog({ isOpen, currentTitle, onClose, onSave }
setEditTitle("");
inputRef.current?.focus();
}}
className="absolute right-2 top-1/2 -translate-y-1/2 p-1.5 rounded-full hover:bg-red-500/10 text-red-500 transition-colors"
className="absolute right-2 top-1/2 -translate-y-1/2 p-1.5 rounded-full hover:bg-destructive/10 text-destructive transition-colors"
>
<X className="w-5 h-5" />
</button>
+22 -22
View File
@@ -203,7 +203,7 @@ export function FormPrompt({ form, onReply, onCancel, onMinimize }: FormPromptPr
max={typeof field.maximum === 'number' ? field.maximum : undefined}
step={field.type === 'integer' ? 1 : 'any'}
onChange={(e) => setFieldAnswer(field.key, e.target.value === '' ? '' : Number(e.target.value))}
className="w-full rounded-lg border border-border bg-white/60 dark:bg-white/5 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none"
className="w-full rounded-lg border border-border bg-muted/60 dark:bg-muted/5 px-3 py-2 text-sm focus:border-primary focus:outline-none"
/>
</div>
)
@@ -296,19 +296,19 @@ export function FormPrompt({ form, onReply, onCancel, onMinimize }: FormPromptPr
value={typeof value === 'string' ? value : ''}
onChange={(e) => setFieldAnswer(field.key, e.target.value)}
placeholder={field.placeholder ?? 'Type your answer...'}
className="min-h-[60px] sm:min-h-[80px] text-[16px] sm:text-xs md:text-sm resize-none border-blue-500/30 focus:border-blue-500"
className="min-h-[60px] sm:min-h-[80px] text-[16px] sm:text-xs md:text-sm resize-none border-primary/30 focus:border-primary"
/>
</div>
)
}
return (
<div className="w-full bg-gradient-to-br from-blue-100 to-blue-200 dark:from-blue-950 dark:to-blue-900 border-2 border-blue-300 dark:border-blue-700 rounded-xl shadow-lg shadow-blue-500/20 mb-1 overflow-hidden">
<div className="flex items-center px-3 py-2 sm:px-4 sm:py-2.5 border-b border-blue-200 dark:border-blue-800 bg-blue-50 dark:bg-blue-900/50">
<div className="w-full bg-gradient-to-br from-primary/10 to-primary/20 border-2 border-primary/40 rounded-xl shadow-lg shadow-primary/20 mb-1 overflow-hidden">
<div className="flex items-center px-3 py-2 sm:px-4 sm:py-2.5 border-b border-primary/20 bg-primary/5">
<button
onClick={() => (isMinimized ? setIsMinimized(false) : handleMinimize())}
aria-expanded={!isMinimized}
className="flex items-center gap-1.5 flex-1 text-left text-xs sm:text-sm font-semibold text-blue-600 dark:text-white"
className="flex items-center gap-1.5 flex-1 text-left text-xs sm:text-sm font-semibold text-primary"
>
{isMinimized ? (
<ChevronUp className="w-3 h-3 opacity-60 flex-shrink-0" />
@@ -321,14 +321,14 @@ export function FormPrompt({ form, onReply, onCancel, onMinimize }: FormPromptPr
onClick={handleCancel}
disabled={isSubmitting}
aria-label="Dismiss form"
className="p-1.5 sm:p-2 hover:bg-red-500/20 text-muted-foreground hover:text-red-500 transition-colors"
className="p-1.5 sm:p-2 hover:bg-destructive/20 text-muted-foreground hover:text-destructive transition-colors"
>
<X className="w-3.5 h-3.5 sm:w-4 sm:h-4" />
</button>
</div>
{!isMinimized && (
<div className="p-2 sm:p-3 max-h-[50vh] sm:max-h-[70vh] overflow-y-auto overflow-x-hidden bg-background/60 dark:bg-black/30 space-y-3">
<div className="p-2 sm:p-3 max-h-[50vh] sm:max-h-[70vh] overflow-y-auto overflow-x-hidden bg-background/60 dark:bg-background/30 space-y-3">
{renderFields.map((field) =>
field.type === 'external' ? (
<ExternalFieldCard key={field.key} field={field} />
@@ -339,7 +339,7 @@ export function FormPrompt({ form, onReply, onCancel, onMinimize }: FormPromptPr
</div>
)}
<div className="flex gap-1.5 sm:gap-2 px-2 py-2 sm:px-3 sm:py-3 border-t border-blue-200 dark:border-blue-800">
<div className="flex gap-1.5 sm:gap-2 px-2 py-2 sm:px-3 sm:py-3 border-t border-primary/20">
<Button
size="sm"
onClick={handleCancel}
@@ -352,7 +352,7 @@ export function FormPrompt({ form, onReply, onCancel, onMinimize }: FormPromptPr
size="sm"
onClick={handleSubmit}
disabled={isSubmitting || !canSubmit}
className="flex-1 h-8 sm:h-10 text-xs sm:text-sm bg-emerald-600 hover:bg-emerald-700 text-white"
className="flex-1 h-8 sm:h-10 text-xs sm:text-sm bg-success hover:bg-success/90 text-success-foreground"
>
{isSubmitting ? <Loader2 className="w-3.5 h-3.5 sm:w-4 sm:h-4 animate-spin" /> : 'Submit'}
</Button>
@@ -376,7 +376,7 @@ function FieldLabel({
<div className="space-y-0.5">
<label htmlFor={id} className="block text-xs sm:text-sm font-semibold text-foreground">
{label}
{required && <span className="text-red-500 ml-0.5">*</span>}
{required && <span className="text-destructive ml-0.5">*</span>}
</label>
{description && (
<p id={`${id}-description`} className="text-[10px] sm:text-xs text-foreground/70">
@@ -402,7 +402,7 @@ function FieldGroup({
<fieldset className="space-y-2">
<legend className="text-xs sm:text-sm font-semibold text-foreground">
{label}
{required && <span className="text-red-500 ml-0.5">*</span>}
{required && <span className="text-destructive ml-0.5">*</span>}
</legend>
{description && <p className="text-[10px] sm:text-xs text-foreground/70">{description}</p>}
{children}
@@ -429,24 +429,24 @@ function OptionButton({
className={cn(
'w-full text-left p-2 sm:p-3 rounded-lg transition-all duration-200 active:scale-[0.98]',
selected
? 'bg-blue-200 dark:bg-blue-700/50'
: 'bg-white/40 dark:bg-white/5 hover:bg-white/60 dark:hover:bg-white/10',
? 'bg-primary/20'
: 'bg-muted/40 dark:bg-muted/5 hover:bg-muted/60 dark:hover:bg-muted/10',
)}
>
<div className="flex items-start gap-1.5 sm:gap-2">
<div
className={cn(
'w-4 h-4 sm:w-5 sm:h-5 rounded-full border-2 flex items-center justify-center flex-shrink-0 transition-colors',
selected ? 'border-blue-500 bg-blue-500' : 'border-muted-foreground',
selected ? 'border-primary bg-primary' : 'border-muted-foreground',
)}
>
{selected && <Check className="w-2.5 h-2.5 sm:w-3 sm:h-3 text-white" />}
{selected && <Check className="w-2.5 h-2.5 sm:w-3 sm:h-3 text-primary-foreground" />}
</div>
<div className="min-w-0">
<span
className={cn(
'text-xs sm:text-sm font-semibold',
selected ? 'text-blue-600 dark:text-blue-300' : 'text-foreground',
selected ? 'text-primary' : 'text-foreground',
)}
>
{label}
@@ -495,23 +495,23 @@ function CustomOption({
className={cn(
'w-full text-left p-2 sm:p-3 rounded-lg transition-all duration-200',
expanded || selected
? 'bg-blue-200 dark:bg-blue-700/50'
: 'bg-white/40 dark:bg-white/5 hover:bg-white/60 dark:hover:bg-white/10',
? 'bg-primary/20'
: 'bg-muted/40 dark:bg-muted/5 hover:bg-muted/60 dark:hover:bg-muted/10',
)}
>
<div className="flex items-center gap-1.5 sm:gap-2">
<div
className={cn(
'w-4 h-4 sm:w-5 sm:h-5 rounded-full border-2 flex items-center justify-center flex-shrink-0 transition-colors',
selected ? 'border-blue-500 bg-blue-500' : 'border-muted-foreground',
selected ? 'border-primary bg-primary' : 'border-muted-foreground',
)}
>
{selected && <Check className="w-2.5 h-2.5 sm:w-3 sm:h-3 text-white" />}
{selected && <Check className="w-2.5 h-2.5 sm:w-3 sm:h-3 text-primary-foreground" />}
</div>
<span
className={cn(
'text-xs sm:text-sm font-semibold',
expanded || selected ? 'text-blue-600 dark:text-blue-300' : 'text-foreground',
expanded || selected ? 'text-primary' : 'text-foreground',
)}
>
Other...
@@ -527,7 +527,7 @@ function CustomOption({
value={value}
onChange={(e) => onChange(e.target.value)}
placeholder="Type your own answer..."
className="min-h-[60px] sm:min-h-[80px] text-[16px] sm:text-xs md:text-sm resize-none border-blue-500/30 focus:border-blue-500"
className="min-h-[60px] sm:min-h-[80px] text-[16px] sm:text-xs md:text-sm resize-none border-primary/30 focus:border-primary"
onKeyDown={(e) => {
if (e.key === 'Enter' && !e.shiftKey) {
e.preventDefault()
@@ -10,18 +10,18 @@ interface MinimizedFormIndicatorProps {
export function MinimizedFormIndicator({ form, onRestore, onDismiss }: MinimizedFormIndicatorProps) {
return (
<div className="w-full bg-gradient-to-br from-orange-100 to-orange-200 dark:from-orange-950 dark:to-orange-900 border-2 border-orange-300 dark:border-orange-700 rounded-lg shadow-lg mb-2 overflow-hidden">
<div className="flex items-center px-3 py-2 sm:px-4 sm:py-2.5 border-b border-orange-200 dark:border-orange-800 bg-orange-50 dark:bg-orange-900/50">
<div className="w-full bg-gradient-to-br from-highlight/10 to-highlight/20 border-2 border-highlight/40 rounded-lg shadow-lg mb-2 overflow-hidden">
<div className="flex items-center px-3 py-2 sm:px-4 sm:py-2.5 border-b border-highlight/20 bg-highlight/5">
<button
onClick={onRestore}
className="flex-1 text-left text-xs font-semibold text-orange-600 dark:text-white"
className="flex-1 text-left text-xs font-semibold text-highlight"
>
{getFormText(form) || 'Form pending'}
</button>
<button
onClick={onDismiss}
aria-label="Dismiss form"
className="p-1.5 hover:bg-red-500/20 text-muted-foreground hover:text-red-500 transition-colors hidden sm:block"
className="p-1.5 hover:bg-destructive/20 text-muted-foreground hover:text-destructive transition-colors hidden sm:block"
>
<X className="w-3.5 h-3.5" />
</button>
@@ -119,7 +119,7 @@ export function PermissionRequestDialog({
</div>
)}
{isFromDifferentSession ? (
<div className="bg-amber-500/10 text-amber-600 dark:text-amber-400 border border-amber-500/20 rounded-md px-2 py-1.5 truncate">
<div className="bg-warning/10 text-warning border border-warning/20 rounded-md px-2 py-1.5 truncate">
From another session: <span className="font-medium">{displaySessionName}</span>
</div>
) : (
+10 -10
View File
@@ -52,13 +52,13 @@ export const SessionCard = ({
return (
<div className="relative" onClick={close}>
<div
className={`absolute top-0.5 right-0 bottom-0.5 w-20 bg-red-600 flex items-center justify-center rounded-r-lg transition-opacity ${
className={`absolute top-0.5 right-0 bottom-0.5 w-20 bg-destructive flex items-center justify-center rounded-r-lg transition-opacity ${
!isSwipingBack && (isOpen || swipeOffset > 40) ? "opacity-100" : "opacity-0 pointer-events-none"
}`}
>
<button
aria-label="Delete session"
className="h-full w-full flex items-center justify-center text-white hover:bg-red-700"
className="h-full w-full flex items-center justify-center text-destructive-foreground hover:bg-destructive/90"
onClick={handleDeleteClick}
>
<Trash2 className="w-5 h-5" />
@@ -72,7 +72,7 @@ export const SessionCard = ({
: "rounded-r-lg"
} ${
isSelected
? "border-blue-500 shadow-lg shadow-blue-900/30 dark:shadow-blue-900/30 bg-accent"
? "border-primary shadow-lg shadow-primary/30 bg-accent"
: isActive
? "bg-accent border-border"
: "bg-card border-border hover:bg-accent hover:border-border"
@@ -105,8 +105,8 @@ export const SessionCard = ({
</div>
<div className="flex-1 min-w-0">
<div className="flex items-center gap-1">
{isPinned && <Pin className="w-3 h-3 text-orange-500 shrink-0" />}
<h3 className="text-base font-semibold text-orange-600 dark:text-orange-400 truncate">
{isPinned && <Pin className="w-3 h-3 text-highlight shrink-0" />}
<h3 className="text-base font-semibold text-highlight truncate">
{session.title || "Untitled Session"}
</h3>
</div>
@@ -118,7 +118,7 @@ export const SessionCard = ({
})}
</span>
{workspaceLabel ? (
<span className="text-purple-400 truncate max-w-[140px]">{workspaceLabel}</span>
<span className="text-primary truncate max-w-[140px]">{workspaceLabel}</span>
) : null}
</div>
</div>
@@ -127,8 +127,8 @@ export const SessionCard = ({
<>
<div className="flex flex-col flex-1 min-w-0">
<div className="flex items-center gap-1">
{isPinned && <Pin className="w-3 h-3 text-orange-500 shrink-0" />}
<h3 className="text-sm font-semibold text-orange-600 dark:text-orange-400 truncate">
{isPinned && <Pin className="w-3 h-3 text-highlight shrink-0" />}
<h3 className="text-sm font-semibold text-highlight truncate">
{session.title || "Untitled Session"}
</h3>
</div>
@@ -140,7 +140,7 @@ export const SessionCard = ({
})}
</span>
{workspaceLabel ? (
<span className="text-purple-400 truncate max-w-[120px]">{workspaceLabel}</span>
<span className="text-primary truncate max-w-[120px]">{workspaceLabel}</span>
) : null}
<SessionStatusIndicator sessionID={session.id} size="sm" />
</div>
@@ -176,7 +176,7 @@ export const SessionCard = ({
{manageMode && (
<button
aria-label="Delete session"
className="h-6 w-6 p-0 text-foreground hover:text-red-600 dark:hover:text-red-400 bg-transparent border-none cursor-pointer"
className="h-6 w-6 p-0 text-foreground hover:text-destructive bg-transparent border-none cursor-pointer"
onClick={(e) => {
e.stopPropagation();
onDelete(e);