fix(ui): keep theme text and selections readable (#6226)

* fix(ui): keep theme text and selections readable

* fix(tui): theme the blank composer cursor cell

* refactor(webui): centralize diff theme colors

* fix(tui): keep conversation selections readable

* fix(ui): preserve nested syntax colors and selection lifetimes
This commit is contained in:
chengyongru authored and GitHub committed 2026-10-15 15:21:28 +08:00
1 parent 73c2441abc
commit c24153db86
32 files changed
+451 -165

No files matched your search

@@ -131,7 +131,7 @@ export function ComposerUsagePopover({
aria-label={triggerLabel}
className={cn(
"touch-target inline-flex size-5 shrink-0 items-center justify-center rounded-full",
"text-muted-foreground/75 transition-colors hover:text-foreground/85",
"text-muted-foreground transition-colors hover:text-foreground",
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
showLabel && "w-auto gap-1.5 px-2 text-xs",
)}
@@ -154,7 +154,7 @@ export function ComposerUsagePopover({
"size-[15px] shrink-0 -rotate-90",
status === "critical" && "text-destructive",
status === "caution" && "text-amber-600 dark:text-amber-400",
status === "normal" && "text-muted-foreground/75",
status === "normal" && "text-muted-foreground",
)}
>
<circle
@@ -38,7 +38,7 @@ export function StreamErrorNotice({ error, onDismiss }: StreamErrorNoticeProps)
/>
<div className="flex-1">
<p className="font-medium">{title}</p>
<p className="mt-0.5 text-destructive/80">{body}</p>
<p className="mt-0.5 text-destructive">{body}</p>
</div>
<Button
variant="ghost"
@@ -2645,7 +2645,7 @@ export function ThreadComposer({
aria-label={inputAriaLabel ?? t("thread.composer.inputAria")}
className={cn(
inputTextClasses,
"relative z-10 block caret-foreground placeholder:text-muted-foreground/70",
"relative z-10 block caret-foreground placeholder:text-muted-foreground",
"focus:outline-none focus-visible:outline-none",
"disabled:cursor-not-allowed",
hasMentionDecorations && "text-transparent selection:bg-primary/20",
@@ -9,12 +9,12 @@ export function DiffPair({ added, deleted }: { added: number; deleted: number })
<DiffValue
sign="+"
value={added}
className="text-emerald-600/75 dark:text-emerald-300/75"
className="text-diff-added-foreground"
/>
<DiffValue
sign="-"
value={deleted}
className="text-rose-600/70 dark:text-rose-300/75"
className="text-diff-deleted-foreground"
/>
</span>
);
@@ -1,7 +1,6 @@
import { Suspense, lazy, type ReactNode } from "react";
import type { SyntaxHighlighterProps } from "react-syntax-highlighter";
import { useThemeValue } from "@/hooks/useTheme";
import type { RenderableFileDiffLine } from "@/lib/file-diff";
import { cn } from "@/lib/utils";
@@ -10,10 +9,6 @@ interface DiffSyntaxHighlightProps {
lines: RenderableFileDiffLine[];
}
interface LoadedDiffSyntaxHighlightProps extends DiffSyntaxHighlightProps {
isDark: boolean;
}
type RendererArgs = Parameters<NonNullable<SyntaxHighlighterProps["renderer"]>>[0];
type SyntaxNode = RendererArgs["rows"][number];
@@ -33,26 +28,21 @@ const LazyDiffSyntaxHighlight = lazy(async () => {
const [
{ default: SyntaxHighlighter },
{ default: createSyntaxElement },
{ default: oneDark },
{ default: oneLight },
] = await Promise.all([
import("react-syntax-highlighter/dist/esm/prism-async-light"),
import("react-syntax-highlighter/dist/esm/create-element"),
import("react-syntax-highlighter/dist/esm/styles/prism/one-dark"),
import("react-syntax-highlighter/dist/esm/styles/prism/one-light"),
]);
return {
default: function LoadedDiffSyntaxHighlight({
language,
lines,
isDark,
}: LoadedDiffSyntaxHighlightProps) {
const theme = isDark ? oneDark : oneLight;
}: DiffSyntaxHighlightProps) {
const code = lines.map((line) => line.content || " ").join("\n");
return (
<SyntaxHighlighter
language={language}
style={theme}
useInlineStyles={false}
style={{}}
PreTag="div"
CodeTag="div"
customStyle={{
@@ -71,6 +61,7 @@ const LazyDiffSyntaxHighlight = lazy(async () => {
},
}}
data-language={language}
className="code-content"
data-testid="syntax-highlighted-diff-hunk"
renderer={({ rows, stylesheet, useInlineStyles }) => (
<DiffLineTable
@@ -96,10 +87,9 @@ const LazyDiffSyntaxHighlight = lazy(async () => {
});
export function DiffSyntaxHighlight({ language, lines }: DiffSyntaxHighlightProps) {
const isDark = useThemeValue() === "dark";
return (
<Suspense fallback={<PlainDiffLines lines={lines} />}>
<LazyDiffSyntaxHighlight language={language} lines={lines} isDark={isDark} />
<LazyDiffSyntaxHighlight language={language} lines={lines} />
</Suspense>
);
}
@@ -148,22 +138,22 @@ function DiffLineRow({
<tr
className={cn(
"border-0",
kind === "add" && "bg-emerald-500/[0.09] dark:bg-emerald-300/[0.11]",
kind === "delete" && "bg-rose-500/[0.09] dark:bg-rose-300/[0.11]",
kind === "add" && "bg-diff-added",
kind === "delete" && "bg-diff-deleted",
)}
>
<td className="w-10 select-none border-r border-border/35 px-1.5 text-right text-muted-foreground/55">
<td className="w-10 select-none border-r border-border/35 px-1.5 text-right text-muted-foreground">
{line.old_lineno ?? ""}
</td>
<td className="w-10 select-none border-r border-border/35 px-1.5 text-right text-muted-foreground/55">
<td className="w-10 select-none border-r border-border/35 px-1.5 text-right text-muted-foreground">
{line.new_lineno ?? ""}
</td>
<td
className={cn(
"w-5 select-none px-1 text-center",
kind === "add" && "text-emerald-600/80 dark:text-emerald-300/85",
kind === "delete" && "text-rose-600/80 dark:text-rose-300/85",
kind === "context" && "text-muted-foreground/45",
kind === "add" && "text-diff-added-foreground",
kind === "delete" && "text-diff-deleted-foreground",
kind === "context" && "text-muted-foreground",
)}
>
{marker}
@@ -326,7 +326,7 @@ function FileUnifiedDiff({
aria-hidden
/>
<span className="min-w-0 flex-1">{viewDiffLabel}</span>
<span className="shrink-0 text-muted-foreground/65">{lineCountLabel}</span>
<span className="shrink-0 text-muted-foreground">{lineCountLabel}</span>
</button>
<DisclosureContent id={contentId} open={open} onExitComplete={releaseBody}>
{shouldRenderBody ? renderBody() : null}
@@ -35,13 +35,13 @@ export function ThinkingReasoningShell({
const headerClassName = "touch-target inline-flex h-7 min-w-0 items-center gap-1.5 rounded-md px-1.5";
const headerContent = (
<>
<Activity className={cn("h-3.5 w-3.5 shrink-0", active ? "activity-current" : "text-muted-foreground/65")} strokeWidth={1.5} aria-hidden>
<Activity className={cn("h-3.5 w-3.5 shrink-0", active ? "activity-current" : "text-muted-foreground")} strokeWidth={1.5} aria-hidden>
{active ? <path className="activity-current-trace" pathLength={100} d="M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2" /> : null}
</Activity>
<span
data-sheen-text={active ? label : undefined}
className={cn(
"min-w-0 truncate text-[12px] font-normal leading-4 text-muted-foreground/65",
"min-w-0 truncate text-[12px] font-normal leading-4 text-muted-foreground",
active && "streaming-text-sheen",
)}
>