Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(conversations): add reasoning effort picker

Steven Enamakel248923014838
diff --git a/app/src/features/conversations/aui/ReasoningEffortPicker.test.tsx b/app/src/features/conversations/aui/ReasoningEffortPicker.test.tsx
index bd70deca44..3c51a5b1c7 100644
--- a/app/src/features/conversations/aui/ReasoningEffortPicker.test.tsx
+++ b/app/src/features/conversations/aui/ReasoningEffortPicker.test.tsx
@@ -1,7 +1,11 @@
import { fireEvent, render, screen } from '@testing-library/react';
import { describe, expect, it, vi } from 'vitest';
-import { ReasoningEffortPicker, toReasoningEffortChoice } from './ReasoningEffortPicker';
+import {
+ gaugeAngleFor,
+ ReasoningEffortPicker,
+ toReasoningEffortChoice,
+} from './ReasoningEffortPicker';
vi.mock('../../../lib/i18n/I18nContext', () => ({ useT: () => ({ t: (key: string) => key }) }));
@@ -15,6 +19,7 @@ describe('ReasoningEffortPicker', () => {
expect(Array.from(select.options).map(o => o.value)).toEqual([
'default',
'none',
+ 'minimal',
'low',
'medium',
'high',
@@ -33,12 +38,32 @@ describe('ReasoningEffortPicker', () => {
});
});
+describe('gaugeAngleFor', () => {
+ it('sweeps from off to max and points up for the provider default', () => {
+ expect(gaugeAngleFor('default')).toBe(0);
+ expect(gaugeAngleFor('none')).toBe(-120);
+ expect(gaugeAngleFor('xhigh')).toBe(120);
+ expect(gaugeAngleFor('low')).toBeLessThan(gaugeAngleFor('high'));
+ });
+});
+
+describe('ReasoningEffortPicker per-model tooltip', () => {
+ it('names the model the level is remembered for', () => {
+ render(<ReasoningEffortPicker value="high" onChange={vi.fn()} modelLabel="opus" />);
+ expect(screen.getByTestId('composer-reasoning-effort')).toHaveAttribute(
+ 'title',
+ 'composer.reasoning.forModel'
+ );
+ });
+});
+
describe('toReasoningEffortChoice', () => {
it('normalizes config values and aliases', () => {
expect(toReasoningEffortChoice('HIGH')).toBe('high');
expect(toReasoningEffortChoice('off')).toBe('none');
expect(toReasoningEffortChoice('max')).toBe('xhigh');
- expect(toReasoningEffortChoice('minimal')).toBe('default');
+ expect(toReasoningEffortChoice('minimal')).toBe('minimal');
+ expect(toReasoningEffortChoice('turbo')).toBe('default');
expect(toReasoningEffortChoice(null)).toBe('default');
expect(toReasoningEffortChoice('')).toBe('default');
});
diff --git a/app/src/features/conversations/aui/ReasoningEffortPicker.tsx b/app/src/features/conversations/aui/ReasoningEffortPicker.tsx
index e3da2f3fa9..8d6c6d9de8 100644
--- a/app/src/features/conversations/aui/ReasoningEffortPicker.tsx
+++ b/app/src/features/conversations/aui/ReasoningEffortPicker.tsx
@@ -3,10 +3,22 @@
* picks the reasoning effort every send asks for (`reasoning_effort` on
* `openhuman.channel_web_chat`), which the core turns into the provider's
* reasoning setting. `default` leaves the choice to the provider.
+ *
+ * The level is remembered per model (`runtime.reasoning_effort_by_model`), so
+ * switching models brings back the level last used with that model. The gauge
+ * beside the label sweeps with the level, after OpenClaw's effort pill.
*/
import { useT } from '../../../lib/i18n/I18nContext';
-export const REASONING_EFFORTS = ['default', 'none', 'low', 'medium', 'high', 'xhigh'] as const;
+export const REASONING_EFFORTS = [
+ 'default',
+ 'none',
+ 'minimal',
+ 'low',
+ 'medium',
+ 'high',
+ 'xhigh',
+] as const;
export type ReasoningEffortChoice = (typeof REASONING_EFFORTS)[number];
@@ -20,33 +32,78 @@ export function toReasoningEffortChoice(value: string | null | undefined): Reaso
: 'default';
}
+/**
+ * Needle angle for a level: -120° (off) to +120° (max). `default` points
+ * straight up, since the provider decides.
+ */
+export function gaugeAngleFor(value: ReasoningEffortChoice): number {
+ if (value === 'default') return 0;
+ const levels = REASONING_EFFORTS.slice(1);
+ const index = levels.indexOf(value);
+ return -120 + (240 * index) / (levels.length - 1);
+}
+
+function ThinkingGauge({ value }: { value: ReasoningEffortChoice }) {
+ return (
+ <svg
+ data-testid="composer-reasoning-gauge"
+ className="pointer-events-none h-3.5 w-3.5 flex-none"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ strokeWidth={2}
+ strokeLinecap="round"
+ aria-hidden="true">
+ <path d="M4.5 18a9 9 0 1 1 15 0" />
+ <line
+ x1="12"
+ y1="15"
+ x2="12"
+ y2="8"
+ transform={`rotate(${gaugeAngleFor(value)} 12 15)`}
+ className="transition-transform duration-200 motion-reduce:transition-none"
+ />
+ <circle cx="12" cy="15" r="1.25" fill="currentColor" stroke="none" />
+ </svg>
+ );
+}
+
export function ReasoningEffortPicker({
value,
onChange,
disabled = false,
+ modelLabel,
}: {
value: ReasoningEffortChoice;
onChange: (value: ReasoningEffortChoice) => void;
disabled?: boolean;
+ /** The model this level is remembered for; named in the tooltip. */
+ modelLabel?: string | null;
}) {
const { t } = useT();
const label = t('composer.reasoning.label');
+ const title = modelLabel
+ ? t('composer.reasoning.forModel').replace('{model}', modelLabel)
+ : label;
return (
- <select
+ <span className="inline-flex h-7 min-w-0 items-center gap-1 rounded-md pl-2 text-content-muted transition-colors hover:bg-surface-hover hover:text-content">
+ <ThinkingGauge value={value} />
+ <select
data-testid="composer-reasoning-effort"
data-analytics-id="chat-reasoning-effort"
aria-label={label}
- title={label}
+ title={title}
value={value}
disabled={disabled}
onChange={event => onChange(toReasoningEffortChoice(event.target.value))}
- className="h-7 min-w-0 cursor-pointer rounded-md border-none bg-transparent px-2 text-xs font-medium text-content-muted transition-colors hover:bg-surface-hover hover:text-content focus:outline-none focus-visible:ring-1 focus-visible:ring-line disabled:opacity-50">
+ className="h-7 min-w-0 cursor-pointer rounded-md border-none bg-transparent pr-2 text-xs font-medium text-inherit focus:outline-none focus-visible:ring-1 focus-visible:ring-line disabled:opacity-50">
{REASONING_EFFORTS.map(effort => (
<option key={effort} value={effort}>
{t(`composer.reasoning.${effort}`)}
</option>
))}
- </select>
+ </select>
+ </span>
);
}