Skip to content

πŸ™Œ OpenHands: AI-Driven Development

fix(theme): keep composer context feedback readable (#18504)

Engel Nyst3419bdb4f710
diff --git a/__tests__/themes/color-themes.test.tsx b/__tests__/themes/color-themes.test.tsx
index 522b7152c8..34c96c32f6 100644
--- a/__tests__/themes/color-themes.test.tsx
+++ b/__tests__/themes/color-themes.test.tsx
@@ -134,13 +134,35 @@ describe("color themes", () => {
`${role} against the context meter raised surface`,
).toBeGreaterThanOrEqual(4.5);
}
- for (const role of ["--oh-feedback-warning", "--oh-status-error"]) {
+ for (const role of [
+ "--oh-foreground",
+ "--oh-feedback-warning",
+ "--oh-status-error",
+ ]) {
expect(
contrast(luminance(resolve(role)), contextMeterTrack),
`${role} against the context meter track`,
).toBeGreaterThanOrEqual(3);
}
+ // The composer popover outlines the full range even when its tertiary
+ // track sits close to the raised background. The button background paints
+ // under its translucent border; compare that composite with the popover.
+ const boundaryWeight =
+ Number.parseFloat(resolve("--oh-context-window-track-weight")) / 100;
+ const trackBackground = channels(resolve("--oh-color-tertiary"));
+ const popoverBoundary = channels(
+ resolve("--oh-context-window-foreground"),
+ ).map(
+ (channel, index) =>
+ channel * boundaryWeight +
+ trackBackground[index] * (1 - boundaryWeight),
+ );
+ expect(
+ contrast(luminance(popoverBoundary), contextMeterSurface),
+ "context range boundary against the composer popover raised surface",
+ ).toBeGreaterThanOrEqual(3);
+
const warningInk = luminance(resolve("--oh-feedback-warning"));
const trustBackground = channels(resolve("--oh-background"));
const warningTint = channels(resolve("--oh-warning"));
diff --git a/src/components/features/chat/components/context-window-meter.tsx b/src/components/features/chat/components/context-window-meter.tsx
index de69303826..b17770596c 100644
--- a/src/components/features/chat/components/context-window-meter.tsx
+++ b/src/components/features/chat/components/context-window-meter.tsx
@@ -25,14 +25,14 @@ import {
const TONE_BAR_CLASS = {
neutral: "bg-foreground",
- warning: "bg-amber-500",
- danger: "bg-red-500",
+ warning: "bg-feedback-warning",
+ danger: "bg-status-error",
} as const;
const TONE_LABEL_CLASS = {
neutral: "text-muted",
- warning: "text-amber-500",
- danger: "text-red-500",
+ warning: "text-feedback-warning",
+ danger: "text-feedback-error",
} as const;
export function ContextWindowMeter() {
@@ -102,7 +102,7 @@ export function ContextWindowMeter() {
data-testid="context-window-meter-popover"
className={cn(
"absolute bottom-full right-0 z-[60] mb-2 w-70",
- "flex flex-col gap-0.5 rounded-md border border-border-subtle bg-tertiary px-1 py-1 shadow-lg",
+ "flex flex-col gap-0.5 rounded-md border border-border-subtle bg-surface-raised px-1 py-1 shadow-lg",
)}
>
<div className="flex flex-col gap-2 px-2 py-1.5">
@@ -118,8 +118,8 @@ export function ContextWindowMeter() {
<button
type="button"
data-testid="context-window-meter-bar-button"
- className="relative h-1.5 w-full rounded-full cursor-pointer"
- style={{ backgroundColor: CONTEXT_WINDOW_TRACK_COLOR }}
+ className="relative h-1.5 w-full rounded-full border bg-tertiary cursor-pointer"
+ style={{ borderColor: CONTEXT_WINDOW_TRACK_COLOR }}
aria-label={t(I18nKey.COMMON$USAGE)}
onClick={(event) => {
event.preventDefault();