diff --git a/apps/web/src/components/chat/ComposerModelEffort.tsx b/apps/web/src/components/chat/ComposerModelEffort.tsx index f56997ff2a6a..13bcb1e1e9d8 100644 --- a/apps/web/src/components/chat/ComposerModelEffort.tsx +++ b/apps/web/src/components/chat/ComposerModelEffort.tsx @@ -24,7 +24,7 @@ import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip"; import type { ComposerControlSize } from "./ComposerControl"; import { ComposerPermissionsSection, type RuntimeModeOption } from "./ComposerFooterControls"; import { composerFloatingLayerProps, focusCheckedPermission } from "./composerEventScope"; -import { EffortGlyph, FastBolt, resolveEffortGlyph } from "./EffortGlyph"; +import { EffortGauge, EffortGlyph, FastBolt, resolveEffortGlyph } from "./EffortGlyph"; import { DockedPickerContext } from "./ProviderModelPicker"; import { getTraitsSectionVisibility, @@ -77,7 +77,7 @@ function columnControls( } /** - * What the model trigger shows after the model name: the effort word (or bars, per the + * What the model trigger shows after the model name: the effort word (or bars or a gauge, per the * Appearance setting), a bolt for Fast, a workflow icon for Ultracode, and other traits such as a * context window. */ @@ -155,7 +155,11 @@ export function describeComposerEffort( {word} ) : glyph ? ( - + effortDisplay === "gauge" ? ( + + ) : ( + + ) ) : null} {fast ? : null} {display.ultracode ? ( diff --git a/apps/web/src/components/chat/EffortGlyph.test.ts b/apps/web/src/components/chat/EffortGlyph.test.ts index 0b73e89e4f83..3531250e193d 100644 --- a/apps/web/src/components/chat/EffortGlyph.test.ts +++ b/apps/web/src/components/chat/EffortGlyph.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from "vite-plus/test"; -import { effortBarHeights, resolveEffortGlyph } from "./EffortGlyph"; +import { effortBarHeights, effortGaugeAngle, resolveEffortGlyph } from "./EffortGlyph"; const descriptor = (ids: ReadonlyArray, promptInjectedValues?: ReadonlyArray) => ({ id: "effort", @@ -67,3 +67,11 @@ describe("effortBarHeights", () => { }, ); }); + +describe("effortGaugeAngle", () => { + it("sweeps the needle from left to right and rests off at the arc's start", () => { + expect([1, 2, 3, 4].map((filled) => effortGaugeAngle(4, filled))).toEqual([180, 120, 60, 0]); + expect(effortGaugeAngle(4, 0)).toBe(210); + expect(effortGaugeAngle(1, 1)).toBe(0); + }); +}); diff --git a/apps/web/src/components/chat/EffortGlyph.tsx b/apps/web/src/components/chat/EffortGlyph.tsx index ae90228b8da1..c886dbb41903 100644 --- a/apps/web/src/components/chat/EffortGlyph.tsx +++ b/apps/web/src/components/chat/EffortGlyph.tsx @@ -1,6 +1,8 @@ import type { ProviderOptionDescriptor } from "@t3tools/contracts"; import { ZapIcon } from "lucide-react"; +import { cn } from "~/lib/utils"; + import type { ComposerControlSize } from "./ComposerControl"; const GLYPH_HEIGHT_SM = 14; @@ -88,6 +90,50 @@ export function EffortGlyph(props: { count: number; filled: number; size?: Compo ); } +// Lucide's gauge: a 10-unit arc around (12, 14) from 210° to -30°, and a 5.66-unit needle. +const GAUGE_ARC_START = "M3.34 19"; +const GAUGE_RADIUS = 10; +const GAUGE_NEEDLE_LENGTH = 5.66; +const GAUGE_OFF_ANGLE = 210; + +/** The needle sweeps left to right across the levels; off rests it at the arc's start. */ +export function effortGaugeAngle(count: number, filled: number): number { + if (filled === 0) return GAUGE_OFF_ANGLE; + return count === 1 ? 0 : 180 - (180 * (filled - 1)) / (count - 1); +} + +function gaugePoint(angle: number, radius: number): string { + const radians = (angle * Math.PI) / 180; + const x = 12 + radius * Math.cos(radians); + const y = 14 - radius * Math.sin(radians); + return `${x.toFixed(2)} ${y.toFixed(2)}`; +} + +/** Lucide's gauge with the needle at the current level and the arc filled up to it. */ +export function EffortGauge(props: { count: number; filled: number; size?: ComposerControlSize }) { + const angle = effortGaugeAngle(props.count, props.filled); + const largeArc = GAUGE_OFF_ANGLE - angle > 180 ? 1 : 0; + return ( + + ); +} + /** One bolt for Fast. Ultrafast adds an outlined echo behind it, cut away by the surface color. */ export function FastBolt(props: { ultra: boolean }) { if (!props.ultra) { diff --git a/apps/web/src/components/settings/AppearanceSettingsPanel.tsx b/apps/web/src/components/settings/AppearanceSettingsPanel.tsx index 00783b085d60..e7b20448a3c7 100644 --- a/apps/web/src/components/settings/AppearanceSettingsPanel.tsx +++ b/apps/web/src/components/settings/AppearanceSettingsPanel.tsx @@ -82,6 +82,7 @@ const CHAT_WIDTH_LABELS: Record = { const EFFORT_DISPLAY_LABELS: Record = { label: "Word", bars: "Bars", + gauge: "Gauge", }; export function AppearanceSettingsPanel() { @@ -292,7 +293,7 @@ export function AppearanceSettingsPanel() { { - if (value === "bars" || value === "label") + if (value === "bars" || value === "gauge" || value === "label") updateSettings({ effortDisplay: value }); }} > @@ -318,6 +319,7 @@ export function AppearanceSettingsPanel() { Word (default) Bars + Gauge diff --git a/apps/web/src/components/settings/settingsSearch.ts b/apps/web/src/components/settings/settingsSearch.ts index 937e37dd8ec3..8a463c59541c 100644 --- a/apps/web/src/components/settings/settingsSearch.ts +++ b/apps/web/src/components/settings/settingsSearch.ts @@ -359,7 +359,7 @@ export const SETTINGS_SEARCH_ITEMS = [ id: "effort-display", title: "Effort display", to: "/settings/appearance", - searchTerms: ["reasoning effort thinking bars graph word label level composer"], + searchTerms: ["reasoning effort thinking bars graph gauge word label level composer"], }, { id: "math-rendering", diff --git a/packages/contracts/src/settings.ts b/packages/contracts/src/settings.ts index 0013e288983e..b15ed576571e 100644 --- a/packages/contracts/src/settings.ts +++ b/packages/contracts/src/settings.ts @@ -345,8 +345,8 @@ export const DiffColorScheme = Schema.Literals(["red-green", "blue-orange"]); export const ChatWidth = Schema.Literals(["comfortable", "wide", "full"]); export type ChatWidth = typeof ChatWidth.Type; -/** How the composer shows reasoning effort: the level's name, or rising bars. */ -export const EffortDisplay = Schema.Literals(["label", "bars"]); +/** How the composer shows reasoning effort: the level's name, rising bars, or a gauge. */ +export const EffortDisplay = Schema.Literals(["label", "bars", "gauge"]); export type EffortDisplay = typeof EffortDisplay.Type; export const ToolCallVisibility = Schema.Literals(["showAll", "hideSuccessful", "hideAll", "zen"]);