Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

refactor(settings): regroup the per-model advanced sheet

vastsaa61f165d8c25
diff --git a/apps/desktop/src/components/settings/ModelAdvancedSettings.tsx b/apps/desktop/src/components/settings/ModelAdvancedSettings.tsx
new file mode 100644
index 000000000..751a407d4
--- /dev/null
+++ b/apps/desktop/src/components/settings/ModelAdvancedSettings.tsx
@@ -0,0 +1,422 @@
+/**
+ * The folded per-model sheet under a chosen model row.
+ *
+ * Three sections, each read top to bottom: identity and token limits, the
+ * thinking ladder with every thinking selector in one aligned grid, and the
+ * capability checkboxes in one aligned grid. Selectors used to hang off the
+ * label rows at different offsets, which read as clutter rather than order.
+ */
+import { useTranslation } from "react-i18next";
+import {
+ THINKING_LEVELS,
+ bindingDefaultThinkingMenuLevels,
+ modelMatchesFilter,
+ resolveBindingDefaultThinkingLevel,
+ sortThinkingLevels,
+ type FastModeBilling,
+ type ModelBinding,
+ type ModelInfo,
+ type SessionThinkingLevel,
+ type ThinkingLevel,
+ type ThinkingProtocol,
+} from "@pi-desktop/shared";
+import {
+ CONTEXT_WINDOW_PRESETS,
+ MAX_OUTPUT_PRESETS,
+ matchPresetIndex,
+ type LimitPreset,
+} from "../../lib/model-limit-presets";
+import { Checkbox, HelpIcon, Input, TooltipButton, cx } from "../ui";
+import { ReasoningEffortSelect } from "./ReasoningEffortSelect";
+import { SettingsMenuSelect } from "./SettingsMenuSelect";
+
+type FastModeHintKey =
+ | "settings.fastModeAllowedSubscriptionHint"
+ | "settings.fastModeAllowedUsageHint"
+ | "settings.fastModeAllowedUnsupported";
+
+export type ModelAdvancedSettingsProps = {
+ id: string;
+ hidden: boolean;
+ binding: ModelBinding;
+ /** Published record, the baseline the capability checkboxes follow. */
+ info?: ModelInfo;
+ publishedLevels: readonly ThinkingLevel[];
+ /** The context window still follows models.dev until the user pins it. */
+ followsCatalog: boolean;
+ apiStyle?: string;
+ busy: boolean;
+ imageModelSelected: boolean;
+ onImageModelChange?: (id: string, selected: boolean) => void;
+ nativeWebSearchWireCapable: boolean;
+ fastModeBilling: FastModeBilling | undefined;
+ fastModeHint: FastModeHintKey;
+ updateBinding: (id: string, patch: Partial<ModelBinding>) => void;
+};
+
+export function ModelAdvancedSettings({
+ id,
+ hidden,
+ binding,
+ info,
+ publishedLevels,
+ followsCatalog,
+ apiStyle,
+ busy,
+ imageModelSelected,
+ onImageModelChange,
+ nativeWebSearchWireCapable,
+ fastModeBilling,
+ fastModeHint,
+ updateBinding,
+}: ModelAdvancedSettingsProps) {
+ const { t } = useTranslation();
+ // The catalog is a baseline, not a capability gate. Always show the
+ // canonical ladder so a proxy or newly released model can be configured
+ // before models.dev catches up.
+ const levelChoices = THINKING_LEVELS;
+ const enabledLevels = sortThinkingLevels(binding.thinkingLevels);
+ const publishedImages = info ? modelMatchesFilter(info, "vision") : false;
+ const publishedDocuments = info ? modelMatchesFilter(info, "pdf") : false;
+ const showReasoningEffort =
+ !apiStyle || apiStyle === "chat_completions" || apiStyle === "opencode_go";
+ const nativeWebSearchHint = t(
+ nativeWebSearchWireCapable
+ ? "settings.nativeWebSearchHint"
+ : "settings.nativeWebSearchUnsupported",
+ );
+
+ return (
+ <div className="provider-chosen-row-body" id={id} hidden={hidden}>
+ <section className="provider-advanced-section">
+ <label className="provider-chosen-field">
+ <span className="provider-chosen-field-label">
+ {t("settings.modelAlias")}
+ <HelpIcon label={t("settings.modelAliasHint")} />
+ </span>
+ <Input
+ value={binding.alias ?? ""}
+ placeholder={t("settings.modelAliasPlaceholder")}
+ spellCheck={false}
+ autoCorrect="off"
+ autoCapitalize="off"
+ onChange={(event) =>
+ updateBinding(binding.id, {
+ // Host-core caps the alias at 60 Unicode scalars, so
+ // clamp by code point rather than UTF-16 unit.
+ alias: [...event.target.value].slice(0, 60).join(""),
+ })
+ }
+ />
+ </label>
+ <div className="provider-chosen-limits">
+ <TokenLimitField
+ label={t("settings.contextWindow")}
+ // A catalog window keeps following models.dev until the user
+ // pins a number; the mark beside the label says so.
+ hint={followsCatalog ? t("settings.contextWindowCatalogHint") : undefined}
+ presets={CONTEXT_WINDOW_PRESETS}
+ value={binding.contextWindow}
+ onChange={(tokens) =>
+ updateBinding(binding.id, {
+ contextWindow: tokens,
+ contextWindowSource: "user",
+ })
+ }
+ />
+ <TokenLimitField
+ label={t("settings.maxOutput")}
+ presets={MAX_OUTPUT_PRESETS}
+ value={binding.maxTokens}
+ onChange={(tokens) =>
+ updateBinding(binding.id, {
+ maxTokens: tokens,
+ maxTokensSource: "user",
+ })
+ }
+ />
+ </div>
+ </section>
+
+ <section className="provider-advanced-section provider-chosen-thinking">
+ <span className="provider-advanced-heading">
+ {t("settings.supportedThinkingLevels")}
+ {/* Nothing published means every level here is a manual override;
+ that is what the mark explains. */}
+ {publishedLevels.length === 0 ? (
+ <HelpIcon label={t("settings.thinkingManualOverrideHint")} />
+ ) : null}
+ </span>
+ <div
+ className="provider-chosen-thinking-chips"
+ role="group"
+ aria-label={t("settings.supportedThinkingLevels")}
+ >
+ {levelChoices.map((level) => {
+ const on = binding.thinkingLevels.includes(level);
+ return (
+ <TooltipButton
+ key={level}
+ type="button"
+ className={cx("provider-thinking-chip", on && "selected")}
+ ariaLabel={level}
+ tooltip={level}
+ aria-pressed={on}
+ onClick={() => {
+ const next: ThinkingLevel[] = on
+ ? binding.thinkingLevels.filter((entry) => entry !== level)
+ : [...binding.thinkingLevels, level];
+ updateBinding(binding.id, {
+ thinkingLevels: next,
+ defaultThinkingLevel: resolveBindingDefaultThinkingLevel(
+ binding.defaultThinkingLevel,
+ sortThinkingLevels(next),
+ ),
+ });
+ }}
+ >
+ {level}
+ </TooltipButton>
+ );
+ })}
+ </div>
+ <div className="provider-advanced-options">
+ {bindingDefaultThinkingMenuLevels(enabledLevels).length > 1 ? (
+ <div className="provider-advanced-option">
+ <span className="provider-chosen-thinking-label">
+ {t("settings.defaultThinkingLevel")}
+ </span>
+ <SettingsMenuSelect
+ className="provider-chosen-thinking-select"
+ fullWidth
+ label={t("settings.defaultThinkingLevel")}
+ value={
+ resolveBindingDefaultThinkingLevel(
+ binding.defaultThinkingLevel,
+ enabledLevels,
+ ) ?? ""
+ }
+ onChange={(id) =>
+ updateBinding(binding.id, {
+ defaultThinkingLevel: id as SessionThinkingLevel,
+ })
+ }
+ options={bindingDefaultThinkingMenuLevels(enabledLevels).map((level) => ({
+ id: level,
+ label: level,
+ }))}
+ />
+ </div>
+ ) : null}
+ <div className="provider-advanced-option">
+ <span className="provider-chosen-thinking-label">
+ {t("settings.thinkingProtocol")}
+ </span>
+ <SettingsMenuSelect
+ className="provider-chosen-thinking-select"
+ fullWidth
+ label={t("settings.thinkingProtocol")}
+ value={binding.thinkingProtocol ?? info?.thinkingProtocol ?? "legacy"}
+ onChange={(id) =>
+ updateBinding(binding.id, {
+ thinkingProtocol: id as ThinkingProtocol,
+ })
+ }
+ options={[
+ { id: "legacy", label: t("settings.thinkingProtocolLegacy") },
+ { id: "adaptive", label: t("settings.thinkingProtocolAdaptive") },
+ ]}
+ />
+ </div>
+ {showReasoningEffort ? (
+ <ReasoningEffortSelect
+ value={binding.supportsReasoningEffort}
+ onChange={(supportsReasoningEffort) =>
+ updateBinding(binding.id, { supportsReasoningEffort })
+ }
+ />
+ ) : null}
+ </div>
+ </section>
+
+ <section className="provider-advanced-section provider-chosen-capabilities">
+ <span className="provider-advanced-heading">{t("settings.modelCapabilities")}</span>
+ <div className="provider-chosen-capability-rows">
+ <CapabilityToggle
+ label={t("settings.imageInput")}
+ published={publishedImages}
+ value={binding.supportsImages}
+ onChange={(next) => updateBinding(binding.id, { supportsImages: next })}
+ />
+ <CapabilityToggle
+ label={t("settings.documentInput")}
+ published={publishedDocuments}
+ value={binding.supportsDocuments}
+ onChange={(next) => updateBinding(binding.id, { supportsDocuments: next })}
+ />
+ <span className="provider-chosen-capability-item">
+ <Checkbox
+ className="provider-chosen-capability"
+ checked={binding.availableForSubagents ?? false}
+ onChange={(event) =>
+ updateBinding(binding.id, {
+ availableForSubagents: event.target.checked || undefined,
+ })
+ }
+ label={t("settings.availableForSubagents")}
+ />
+ <HelpIcon label={t("settings.availableForSubagentsHint")} />
+ </span>
+ {onImageModelChange ? (
+ <ImageModelToggle
+ selected={imageModelSelected}
+ disabled={busy}
+ onChange={(next) => onImageModelChange(binding.id, next)}
+ />
+ ) : null}
+ {/* Wire-dependent opt-ins last: they are the ones often disabled. */}
+ <span className="provider-chosen-capability-item">
+ <Checkbox
+ className="provider-chosen-capability"
+ checked={binding.nativeWebSearch === true}
+ disabled={!nativeWebSearchWireCapable}
+ onChange={(event) =>
+ updateBinding(binding.id, {
+ nativeWebSearch: event.target.checked || undefined,
+ })
+ }
+ label={t("settings.nativeWebSearch")}
+ />
+ <HelpIcon label={nativeWebSearchHint} />
+ </span>
+ <span className="provider-chosen-capability-item">
+ <Checkbox
+ className="provider-chosen-capability"
+ checked={binding.fastModeAllowed === true}
+ disabled={!fastModeBilling}
+ onChange={(event) =>
+ updateBinding(binding.id, {
+ fastModeAllowed: event.target.checked || undefined,
+ })
+ }
+ label={t("settings.fastModeAllowed")}
+ />
+ <HelpIcon label={t(fastModeHint)} />
+ </span>
+ </div>
+ </section>
+ </div>
+ );
+}
+
+/** Marks the model as an image-generation candidate; the mark explains why
+ * that keeps it out of chat. */
+function ImageModelToggle({
+ selected,
+ disabled,
+ onChange,
+}: {
+ selected: boolean;
+ disabled: boolean;
+ onChange: (next: boolean) => void;
+}) {
+ const { t } = useTranslation();
+ const label = t(selected ? "settings.imageModelSelected" : "settings.setImageModel");
+ return (
+ <span className="provider-chosen-capability-item">
+ <Checkbox
+ className="provider-chosen-capability"
+ checked={selected}
+ disabled={disabled}
+ aria-label={label}
+ onChange={(event) => onChange(event.target.checked)}
+ label={label}
+ />
+ <HelpIcon label={t("settings.imageModelChatExclusionHint")} />
+ </span>
+ );
+}
+
+type TokenLimitFieldProps = {
+ label: string;
+ hint?: string;
+ presets: readonly LimitPreset[];
+ value: number | undefined;
+ onChange: (tokens: number) => void;
+};
+
+/**
+ * One token limit: the exact number sits on the label row, the preset ladder
+ * (#202) below it. Clicking a stop writes its token count; the input stays
+ * hand-editable off the ladder.
+ */
+function TokenLimitField({ label, hint, presets, value, onChange }: TokenLimitFieldProps) {
+ const active = matchPresetIndex(presets, value);
+ return (
+ <div className="provider-chosen-field provider-limit-field">
+ <div className="provider-limit-field-head">
+ <span className="provider-chosen-field-label">
+ {label}
+ {hint ? <HelpIcon label={hint} /> : null}
+ </span>
+ <Input
+ type="number"
+ min={1}
+ inputMode="numeric"
+ aria-label={label}
+ className="provider-limit-input"
+ value={value}
+ onChange={(event) => onChange(Number(event.target.value) || 0)}
+ />
+ </div>
+ <div className="provider-limit-presets" role="group" aria-label={label}>
+ {presets.map((preset, index) => {
+ const on = active === index;
+ return (
+ <TooltipButton
+ key={preset.label}
+ type="button"
+ className={cx("provider-thinking-chip", on && "selected")}
+ ariaLabel={preset.label}
+ tooltip={preset.label}
+ aria-pressed={on}
+ onClick={() => onChange(preset.tokens)}
+ >
+ {preset.label}
+ </TooltipButton>
+ );
+ })}
+ </div>
+ </div>
+ );
+}
+
+type CapabilityToggleProps = {
+ label: string;
+ /** What models.dev publishes for this model. */
+ published: boolean;
+ /** Stored override: `true`/`false` explicit, `null`/undefined follows. */
+ value: boolean | null | undefined;
+ onChange: (next: boolean) => void;
+};
+
+/**
+ * One attachment capability as a plain checkbox showing the effective answer.
+ *
+ * An untouched checkbox follows the catalog. Once the user changes it, the
+ * selected boolean is explicit and stays pinned even if it currently agrees
+ * with models.dev; catalog refreshes must not undo a deliberate choice.
+ */
+function CapabilityToggle({ label, published, value, onChange }: CapabilityToggleProps) {
+ const effective = typeof value === "boolean" ? value : published;
+ return (
+ <span className="provider-chosen-capability-item">
+ <Checkbox
+ className="provider-chosen-capability"
+ checked={effective}
+ onChange={(event) => onChange(event.target.checked)}
+ label={label}
+ />
+ </span>
+ );
+}
diff --git a/apps/desktop/src/components/settings/ModelSelectionPanes.tsx b/apps/desktop/src/components/settings/ModelSelectionPanes.tsx
index 3e04b7057..19ca72bfa 100644
--- a/apps/desktop/src/components/settings/ModelSelectionPanes.tsx
+++ b/apps/desktop/src/components/settings/ModelSelectionPanes.tsx
@@ -11,34 +11,23 @@
import { useEffect, useMemo, useState, type Ref } from "react";
import { useTranslation } from "react-i18next";
import {
- THINKING_LEVELS,
- bindingDefaultThinkingMenuLevels,
bindingForCustomModel,
bindingForCustomModelInfo,
bindingFromModelInfo,
fastModeBillingOn,
formatTokenCount,
- modelMatchesFilter,
nativeWebSearchSupportedOn,
publishedThinkingLevels,
resolveBindingDefaultThinkingLevel,
sortThinkingLevels,
type ModelBinding,
type ModelInfo,
- type SessionThinkingLevel,
type ThinkingLevel,
- type ThinkingProtocol,
} from "@pi-desktop/shared";
-import {
- CONTEXT_WINDOW_PRESETS,
- MAX_OUTPUT_PRESETS,
- matchPresetIndex,
-} from "../../lib/model-limit-presets";
import { api } from "../../lib/api";
-import { Badge, Button, Checkbox, Field, HelpIcon, Input, Tooltip, TooltipButton, cx } from "../ui";
-import { IconClose, IconGripVertical, IconHelp, IconPlus, IconRefresh, IconSearch } from "../icons";
-import { ReasoningEffortSelect } from "./ReasoningEffortSelect";
-import { SettingsMenuSelect } from "./SettingsMenuSelect";
+import { Badge, Button, Field, HelpIcon, Input, TooltipButton, cx } from "../ui";
+import { IconClose, IconGripVertical, IconPlus, IconRefresh, IconSearch } from "../icons";
+import { ModelAdvancedSettings } from "./ModelAdvancedSettings";
import { filterChosenModels, hidesAddedBinding } from "./model-chosen-filter";
import {
applyCustomModelLookup,
@@ -612,15 +601,9 @@ export function ModelSelectionPanes({
) : (
<ul className="provider-chosen-list">
{visibleChosen.map((binding) => {
- // The catalog is a baseline, not a capability gate. Always show
- // the canonical ladder so a proxy or newly released model can be
- // configured before models.dev catches up.
- const levelChoices = THINKING_LEVELS;
const publishedLevels =
publishedLevelsById.get(binding.id.toLowerCase()) ?? [];
- const enabledLevels = sortThinkingLevels(binding.thinkingLevels);
const info = infoById.get(binding.id.toLowerCase());
- const publishedImages = info ? modelMatchesFilter(info, "vision") : false;
// The row's published window, so the hint below the field can say
// the number still follows it.
const publishedContextWindow = publishedModelLimit(info, "contextWindow");
@@ -638,7 +621,6 @@ export function ModelSelectionPanes({
publishedMaxTokens === undefined
? undefined
: binding.maxTokens;
- const publishedDocuments = info ? modelMatchesFilter(info, "pdf") : false;
const expanded = expandedModelId === binding.id;
const imageModelSelected = imageModelIds?.some((modelId) =>
modelId.toLowerCase() === binding.id.toLowerCase(),
@@ -705,375 +687,22 @@ export function ModelSelectionPanes({
<IconClose size={12} />
</TooltipButton>
</div>
- {/* Dense sheet: 2xs labels, explanations behind the help marks. */}
- <div
- className="provider-chosen-row-body"
+ <ModelAdvancedSettings
id={advancedId}
hidden={!expanded}
- >
- <label className="provider-chosen-field">
- <span className="provider-chosen-field-label">
- {t("settings.modelAlias")}
- <HelpIcon label={t("settings.modelAliasHint")} />
- </span>
- <Input
- value={binding.alias ?? ""}
- placeholder={t("settings.modelAliasPlaceholder")}
- spellCheck={false}
- autoCorrect="off"
- autoCapitalize="off"
- onChange={(event) =>
- updateBinding(binding.id, {
- // Host-core caps the alias at 60 Unicode scalars, so
- // clamp by code point rather than UTF-16 unit.
- alias: [...event.target.value].slice(0, 60).join(""),
- })
- }
- />
- </label>
- <div className="provider-chosen-limits">
- <label className="provider-chosen-field">
- {/* A catalog window keeps following models.dev until the
- user pins a number; the mark beside the label is the
- only place that still says so. */}
- <span className="provider-chosen-field-label">
- {t("settings.contextWindow")}
- {followsCatalog ? (
- <HelpIcon label={t("settings.contextWindowCatalogHint")} />
- ) : null}
- </span>
- {/* Preset ladder (#202): click writes the token count;
- the input stays hand-editable off the ladder. */}
- <div
- className="provider-limit-presets"
- role="group"
- aria-label={t("settings.contextWindow")}
- >
- {CONTEXT_WINDOW_PRESETS.map((preset, index) => {
- const on =
- matchPresetIndex(
- CONTEXT_WINDOW_PRESETS,
- binding.contextWindow,
- ) === index;
- return (
- <TooltipButton
- key={preset.label}
- type="button"
- className={cx(
- "provider-thinking-chip",
- on && "selected",
- )}
- ariaLabel={preset.label}
- tooltip={preset.label}
- aria-pressed={on}
- onClick={() =>
- updateBinding(binding.id, {
- contextWindow: preset.tokens,
- contextWindowSource: "user",
- })
- }
- >
- {preset.label}
- </TooltipButton>
- );
- })}
- </div>
- <Input
- type="number"
- min={1}
- inputMode="numeric"
- value={binding.contextWindow}
- onChange={(event) =>
- updateBinding(binding.id, {
- contextWindow: Number(event.target.value) || 0,
- contextWindowSource: "user",
- })
- }
- />
- </label>
- <label className="provider-chosen-field">
- <span className="provider-chosen-field-label">
- {t("settings.maxOutput")}
- </span>
- <div
- className="provider-limit-presets"
- role="group"
- aria-label={t("settings.maxOutput")}
- >
- {MAX_OUTPUT_PRESETS.map((preset, index) => {
- const on =
- matchPresetIndex(
- MAX_OUTPUT_PRESETS,
- binding.maxTokens,
- ) === index;
- return (
- <TooltipButton
- key={preset.label}
- type="button"
- className={cx(
- "provider-thinking-chip",
- on && "selected",
- )}
- ariaLabel={preset.label}
- tooltip={preset.label}
- aria-pressed={on}
- onClick={() =>
- updateBinding(binding.id, {
- maxTokens: preset.tokens,
- maxTokensSource: "user",
- })
- }
- >
- {preset.label}
- </TooltipButton>
- );
- })}
- </div>
- <Input
- type="number"
- min={1}
- inputMode="numeric"
- value={binding.maxTokens}
- onChange={(event) =>
- updateBinding(binding.id, {
- maxTokens: Number(event.target.value) || 0,
- maxTokensSource: "user",
- })
- }
- />
- </label>
- </div>
- <div className="provider-chosen-thinking">
- <div className="provider-chosen-thinking-head">
- <span className="provider-chosen-thinking-label">
- {t("settings.supportedThinkingLevels")}
- {/* Nothing published means every level here is a
- manual override; that is what the mark explains. */}
- {publishedLevels.length === 0 ? (
- <HelpIcon label={t("settings.thinkingManualOverrideHint")} />
- ) : null}
- </span>
- <div className="provider-chosen-thinking-controls">
- <div className="provider-chosen-thinking-protocol">
- <span className="provider-chosen-thinking-label">
- {t("settings.thinkingProtocol")}
- </span>
- <SettingsMenuSelect
- className="provider-chosen-thinking-select"
- label={t("settings.thinkingProtocol")}
- value={
- binding.thinkingProtocol ?? info?.thinkingProtocol ?? "legacy"
- }
- onChange={(id) =>
- updateBinding(binding.id, {
- thinkingProtocol: id as ThinkingProtocol,
- })
- }
- options={[
- {
- id: "legacy",
- label: t("settings.thinkingProtocolLegacy"),
- },
- {
- id: "adaptive",
- label: t("settings.thinkingProtocolAdaptive"),
- },
- ]}
- />
- </div>
- {bindingDefaultThinkingMenuLevels(enabledLevels).length > 1 ? (
- <div className="provider-chosen-thinking-default">
- <span className="provider-chosen-thinking-label">
- {t("settings.defaultThinkingLevel")}
- </span>
- <SettingsMenuSelect
- className="provider-chosen-thinking-select"
- label={t("settings.defaultThinkingLevel")}
- value={
- resolveBindingDefaultThinkingLevel(
- binding.defaultThinkingLevel,
- enabledLevels,
- ) ?? ""
- }
- onChange={(id) =>
- updateBinding(binding.id, {
- defaultThinkingLevel: id as SessionThinkingLevel,
- })
- }
- options={bindingDefaultThinkingMenuLevels(enabledLevels).map(
- (level) => ({
- id: level,
- label: level,
- }),
- )}
- />
- </div>
- ) : null}
- </div>
- </div>
- <div
- className="provider-chosen-thinking-chips"
- role="group"
- aria-label={t("settings.supportedThinkingLevels")}
- >
- {levelChoices.map((level) => {
- const on = binding.thinkingLevels.includes(level);
- return (
- <TooltipButton
- key={level}
- type="button"
- className={cx("provider-thinking-chip", on && "selected")}
- ariaLabel={level}
- tooltip={level}
- aria-pressed={on}
- onClick={() => {
- const next: ThinkingLevel[] = on
- ? binding.thinkingLevels.filter(
- (entry) => entry !== level,
- )
- : [...binding.thinkingLevels, level];
- updateBinding(binding.id, {
- thinkingLevels: next,
- defaultThinkingLevel: resolveBindingDefaultThinkingLevel(
- binding.defaultThinkingLevel,
- sortThinkingLevels(next),
- ),
- });
- }}
- >
- {level}
- </TooltipButton>
- );
- })}
- </div>
- </div>
- {(!apiStyle || apiStyle === "chat_completions" || apiStyle === "opencode_go") ? (
- <ReasoningEffortSelect
- value={binding.supportsReasoningEffort}
- onChange={(supportsReasoningEffort) => updateBinding(binding.id, { supportsReasoningEffort })}
- />
- ) : null}
- <div className="provider-chosen-capabilities">
- <span className="provider-chosen-thinking-label">
- {t("settings.modelCapabilities")}
- </span>
- <div className="provider-chosen-capability-rows">
- <CapabilityToggle
- label={t("settings.imageInput")}
- published={publishedImages}
- value={binding.supportsImages}
- onChange={(next) =>
- updateBinding(binding.id, { supportsImages: next })
- }
- />
- <CapabilityToggle
- label={t("settings.documentInput")}
- published={publishedDocuments}
- value={binding.supportsDocuments}
- onChange={(next) =>
- updateBinding(binding.id, { supportsDocuments: next })
- }
- />
- {onImageModelChange ? (
- <span className="provider-chosen-delegation">
- <Checkbox
- className="provider-chosen-capability"
- checked={imageModelSelected}
- disabled={busy}
- aria-label={t(
- imageModelSelected
- ? "settings.imageModelSelected"
- : "settings.setImageModel",
- )}
- onChange={(event) =>
- onImageModelChange(binding.id, event.target.checked)
- }
- label={t(
- imageModelSelected
- ? "settings.imageModelSelected"
- : "settings.setImageModel",
- )}
- />
- <HelpIcon label={t("settings.imageModelChatExclusionHint")} />
- </span>
- ) : null}
- <span className="provider-chosen-delegation">
- <label className="provider-chosen-capability">
- <input
- type="checkbox"
- checked={binding.availableForSubagents ?? false}
- onChange={(event) =>
- updateBinding(binding.id, {
- availableForSubagents:
- event.target.checked || undefined,
- })
- }
- />
- <span>{t("settings.availableForSubagents")}</span>
- </label>
- <Tooltip
- className="provider-chosen-delegation-help"
- label={t("settings.availableForSubagentsHint")}
- ariaLabel={t("settings.availableForSubagentsHint")}
- >
- <IconHelp size={13} />
- </Tooltip>
- </span>
- <span className="provider-chosen-delegation">
- <label className="provider-chosen-capability">
- <input
- type="checkbox"
- checked={binding.nativeWebSearch === true}
- disabled={!nativeWebSearchWireCapable}
- onChange={(event) =>
- updateBinding(binding.id, {
- nativeWebSearch: event.target.checked || undefined,
- })
- }
- />
- <span>{t("settings.nativeWebSearch")}</span>
- </label>
- <Tooltip
- className="provider-chosen-delegation-help"
- label={t(
- nativeWebSearchWireCapable
- ? "settings.nativeWebSearchHint"
- : "settings.nativeWebSearchUnsupported",
- )}
- ariaLabel={t(
- nativeWebSearchWireCapable
- ? "settings.nativeWebSearchHint"
- : "settings.nativeWebSearchUnsupported",
- )}
- >
- <IconHelp size={13} />
- </Tooltip>
- </span>
- <span className="provider-chosen-delegation">
- <label className="provider-chosen-capability">
- <input
- type="checkbox"
- checked={binding.fastModeAllowed === true}
- disabled={!fastModeBilling}
- onChange={(event) =>
- updateBinding(binding.id, {
- fastModeAllowed: event.target.checked || undefined,
- })
- }
- />
- <span>{t("settings.fastModeAllowed")}</span>
- </label>
- <Tooltip
- className="provider-chosen-delegation-help"
- label={t(fastModeHint)}
- ariaLabel={t(fastModeHint)}
- >
- <IconHelp size={13} />
- </Tooltip>
- </span>
- </div>
- </div>
- </div>
+ binding={binding}
+ info={info}
+ publishedLevels={publishedLevels}
+ followsCatalog={followsCatalog}
+ apiStyle={apiStyle}
+ busy={busy}
+ imageModelSelected={imageModelSelected}
+ onImageModelChange={onImageModelChange}
+ nativeWebSearchWireCapable={nativeWebSearchWireCapable}
+ fastModeBilling={fastModeBilling}
+ fastModeHint={fastModeHint}
+ updateBinding={updateBinding}
+ />
</li>
);
})}
@@ -1112,33 +741,3 @@ export function ModelSelectionPanes({
</div>
);
}
-
-type CapabilityToggleProps = {
- label: string;
- /** What models.dev publishes for this model. */
- published: boolean;
- /** Stored override: `true`/`false` explicit, `null`/undefined follows. */
- value: boolean | null | undefined;
- onChange: (next: boolean) => void;
-};
-
-/**
- * One attachment capability as a plain checkbox showing the effective answer.
- *
- * An untouched checkbox follows the catalog. Once the user changes it, the
- * selected boolean is explicit and stays pinned even if it currently agrees
- * with models.dev; catalog refreshes must not undo a deliberate choice.
- */
-function CapabilityToggle({ label, published, value, onChange }: CapabilityToggleProps) {
- const effective = typeof value === "boolean" ? value : published;
- return (
- <label className="provider-chosen-capability">
- <input
- type="checkbox"
- checked={effective}
- onChange={(event) => onChange(event.target.checked)}
- />
- <span>{label}</span>
- </label>
- );
-}
diff --git a/apps/desktop/src/components/settings/ReasoningEffortSelect.tsx b/apps/desktop/src/components/settings/ReasoningEffortSelect.tsx
index 7bd681d0f..0e70ae7df 100644
--- a/apps/desktop/src/components/settings/ReasoningEffortSelect.tsx
+++ b/apps/desktop/src/components/settings/ReasoningEffortSelect.tsx
@@ -8,13 +8,14 @@ export function ReasoningEffortSelect({ value, onChange }: {
}) {
const { t } = useTranslation();
return (
- <div className="provider-chosen-reasoning-effort">
+ <div className="provider-advanced-option">
<span className="provider-chosen-thinking-label">
{t("settings.reasoningEffortParameter")}
<HelpIcon label={t("settings.reasoningEffortParameterHint")} />
</span>
<SettingsMenuSelect
className="provider-chosen-thinking-select"
+ fullWidth
label={t("settings.reasoningEffortParameter")}
value={value == null ? "auto" : value ? "send" : "omit"}
onChange={(id) => onChange(id === "auto" ? null : id === "send")}
diff --git a/apps/desktop/src/styles/model-config.css b/apps/desktop/src/styles/model-config.css
index d98a2962c..a7863a1ad 100644
--- a/apps/desktop/src/styles/model-config.css
+++ b/apps/desktop/src/styles/model-config.css
@@ -1064,15 +1064,52 @@
Compact property sheet in a half-pane: 2xs labels, dense fields, no helper
paragraphs. Native number spinners are hidden so the two limit fields match.
Author `display: flex` would otherwise override the HTML hidden attribute.
+ Three sections (identity and limits, thinking, capabilities) split by a
+ hairline so each group reads as one unit.
*/
.provider-chosen-row-body {
display: flex;
flex-direction: column;
- gap: 8px;
+ gap: 0;
padding: 2px 8px 8px;
font-size: var(--text-sm);
}
+.provider-advanced-section {
+ display: flex;
+ flex-direction: column;
+ gap: 8px;
+ min-width: 0;
+ padding: 10px 0;
+}
+
+.provider-advanced-section:first-child {
+ padding-top: 4px;
+}
+
+.provider-advanced-section:last-child {
+ padding-bottom: 2px;
+}
+
+.provider-advanced-section + .provider-advanced-section {
+ border-top: 1px solid var(--ds-border-subtle);
+}
+
+.provider-advanced-heading {
+ display: inline-flex;
+ align-items: center;
+ color: var(--ds-text-primary);
+ font-size: var(--text-2xs);
+ font-weight: var(--font-weight-semibold);
+ line-height: var(--leading-normal);
+}
+
+.provider-advanced-heading .ui-help-icon,
+.provider-chosen-field-label .ui-help-icon,
+.provider-chosen-thinking-label .ui-help-icon {
+ margin-left: 4px;
+}
+
.provider-chosen-row-body[hidden] {
display: none;
}
@@ -1105,16 +1142,41 @@
}
.provider-chosen-field-label {
+ display: inline-flex;
+ align-items: center;
+ min-width: 0;
color: var(--ds-text-secondary);
font-size: var(--text-2xs);
font-weight: var(--font-weight-medium);
line-height: var(--leading-normal);
}
+/* Side by side when the pane allows, stacked in a narrow pane. */
.provider-chosen-limits {
display: grid;
- grid-template-columns: repeat(2, minmax(0, 1fr));
+ grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
+ gap: 8px 12px;
+}
+
+/* The exact number shares the label row, so each limit is two rows: label and
+ value, then the preset ladder. */
+.provider-limit-field-head {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
gap: 8px;
+ min-width: 0;
+}
+
+.provider-limit-field-head > .provider-chosen-field-label {
+ white-space: nowrap;
+}
+
+.provider-chosen-row-body .provider-limit-input {
+ flex: 0 1 112px;
+ width: 112px;
+ min-width: 72px;
+ text-align: right;
}
/* Preset ladders above the two numeric limit inputs (#202): the same
@@ -1134,18 +1196,27 @@
.provider-chosen-thinking {
display: flex;
flex-direction: column;
- gap: 6px;
+ gap: 8px;
}
-.provider-chosen-thinking-head {
+/* Every thinking selector shares one equal-width grid: label above, menu
+ below, so the three menus line up instead of hanging off label rows. */
+.provider-advanced-options {
display: grid;
- grid-template-columns: minmax(0, 1fr) auto;
- align-items: center;
- gap: 4px 12px;
+ grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
+ gap: 8px 12px;
min-width: 0;
}
-.provider-chosen-thinking-head > .provider-chosen-thinking-label {
+.provider-advanced-option {
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ min-width: 0;
+}
+
+.provider-advanced-option .settings-menu-select-anchor {
+ width: 100%;
min-width: 0;
}
@@ -1169,32 +1240,11 @@
line-height: var(--leading-normal);
}
-.provider-chosen-thinking-controls {
- display: flex;
- align-items: center;
- justify-self: end;
- gap: 12px;
-}
-
-.provider-chosen-reasoning-effort {
- display: flex;
- flex-wrap: wrap;
- align-items: center;
- justify-content: flex-end;
- gap: 6px;
-}
-
-.provider-chosen-thinking-default,
-.provider-chosen-thinking-protocol {
- display: flex;
- align-items: center;
- gap: 6px;
-}
-
/* The row body keeps its own compact field metric (28px inputs and selects), so
the default-thinking dropdown takes that height instead of a chip-sized box
that would read as a different control than the fields around it. */
.provider-chosen-thinking-select .settings-menu-select-trigger {
+ width: 100%;
height: 28px;
padding: 0 8px;
border-radius: var(--radius-sm);
@@ -1213,22 +1263,43 @@
gap: 6px;
}
+/* Equal columns, so every checkbox starts on the same vertical line. */
.provider-chosen-capability-rows {
- display: flex;
- flex-wrap: wrap;
+ display: grid;
+ grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
align-items: center;
- gap: 6px 12px;
+ gap: 2px 12px;
}
-.provider-chosen-capability {
+.provider-chosen-capability-item {
display: flex;
align-items: center;
- gap: 5px;
min-width: 0;
+}
+
+.provider-chosen-capability-item .ui-help-icon {
+ flex: none;
+ margin-left: 4px;
+}
+
+.provider-chosen-capability {
+ gap: 6px;
+ min-width: 0;
+ min-height: 26px;
color: var(--ds-text-primary);
font-size: var(--text-2xs);
line-height: var(--leading-normal);
- cursor: pointer;
+}
+
+.provider-chosen-capability > span {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.provider-chosen-capability > .ds-checkbox {
+ width: 15px;
+ height: 15px;
}
.provider-chosen-thinking-chips {
@@ -1279,25 +1350,6 @@
outline-offset: 1px;
}
-.provider-chosen-delegation {
- display: flex;
- align-items: center;
- gap: 2px;
-}
-
-.provider-chosen-delegation-help {
- position: relative;
- display: inline-flex;
- align-items: center;
- color: var(--ds-text-faint);
- cursor: help;
- transition: color var(--motion-duration-fast) var(--motion-ease-out);
-}
-
-.provider-chosen-delegation-help:hover {
- color: var(--ds-text-secondary);
-}
-
.provider-custom-model {
flex: none;
@@ -1878,18 +1930,6 @@
grid-template-columns: repeat(4, minmax(0, 1fr));
}
- .provider-chosen-thinking-head {
- grid-template-columns: minmax(0, 1fr) auto;
- }
-
- .provider-chosen-thinking-head > .provider-chosen-thinking-label {
- grid-column: 1 / -1;
- }
-
- .provider-chosen-thinking-controls {
- grid-column: 1 / -1;
- justify-self: end;
- }
}
diff --git a/apps/desktop/test/model-advanced-capabilities.test.mjs b/apps/desktop/test/model-advanced-capabilities.test.mjs
index f7b457b0c..641a291bd 100644
--- a/apps/desktop/test/model-advanced-capabilities.test.mjs
+++ b/apps/desktop/test/model-advanced-capabilities.test.mjs
@@ -8,10 +8,18 @@ import { readFile } from "node:fs/promises";
import test from "node:test";
import { loadStyles } from "./helpers/styles.mjs";
-const pickerSource = await readFile(
- new URL("../src/components/settings/ModelSelectionPanes.tsx", import.meta.url),
+// The chosen-model row lives in the picker; its folded sheet is its own file.
+const advancedSource = await readFile(
+ new URL("../src/components/settings/ModelAdvancedSettings.tsx", import.meta.url),
"utf8",
);
+const pickerSource = [
+ await readFile(
+ new URL("../src/components/settings/ModelSelectionPanes.tsx", import.meta.url),
+ "utf8",
+ ),
+ advancedSource,
+].join("\n");
const imageModelRowSource = await readFile(
new URL("../src/components/settings/ImageGenerationModelRow.tsx", import.meta.url),
"utf8",
@@ -96,7 +104,8 @@ test("image generation selection hides the summary when nothing can be chosen",
/className="provider-chosen-advanced-toggle"[^\n]*settings\.setImageModel/,
);
assert.match(pickerSource, /imageModelIds\?\.some\([\s\S]*?modelId\.toLowerCase\(\) === binding\.id\.toLowerCase\(\)/);
- assert.match(pickerSource, /onImageModelChange\(binding\.id, event\.target\.checked\)/);
+ assert.match(pickerSource, /onChange=\{\(next\) => onImageModelChange\(binding\.id, next\)\}/);
+ assert.match(pickerSource, /onChange=\{\(event\) => onChange\(event\.target\.checked\)\}/);
// The row's own rule — the stored candidate list, the legacy single binding
// only while no list was ever saved, plus a signed-in vendor account's image
// model — now lives in the shared helper, pinned by image-generation-default.test.mjs.
@@ -140,11 +149,11 @@ test("selected thinking chips keep high contrast in both themes", () => {
test("thinking levels use a compact accessible grouped control", () => {
assert.match(
- pickerSource,
- /className="provider-chosen-thinking-head">[\s\S]*?thinkingManualOverrideHint[\s\S]*?<\/div>\s*<div[\s\S]*?className="provider-chosen-thinking-chips"/,
+ advancedSource,
+ /className="provider-advanced-heading">[\s\S]*?thinkingManualOverrideHint[\s\S]*?<\/span>\s*<div[\s\S]*?className="provider-chosen-thinking-chips"/,
);
assert.match(pickerSource, /role="group"/);
- assert.match(styles, /\.provider-chosen-thinking-head \{/);
+ assert.match(styles, /\.provider-advanced-heading \{/);
assert.match(styles, /\.provider-chosen-thinking-hint \{/);
assert.match(
styles,
@@ -247,14 +256,17 @@ test("the advanced body is a compact sheet without helper paragraphs", () => {
// Every row starts folded so chosen models stay scannable (D625).
assert.match(pickerSource, /useState<string \| null>\(null\)/);
assert.doesNotMatch(pickerSource, /models\[0\]\?\.id \?\? null/);
+ // Sections read top to bottom: identity and limits, the thinking ladder
+ // followed by one aligned grid of every thinking selector, then capabilities.
assert.match(
- pickerSource,
- /className="provider-chosen-thinking-head">[\s\S]*?provider-chosen-thinking-default[\s\S]*?provider-chosen-thinking-chips/,
- );
- assert.match(
- pickerSource,
- /className="provider-chosen-capability-rows">[\s\S]*?provider-chosen-delegation/,
+ advancedSource,
+ /className="provider-chosen-limits"[\s\S]*?className="provider-chosen-thinking-chips"[\s\S]*?className="provider-advanced-options"[\s\S]*?settings\.defaultThinkingLevel[\s\S]*?settings\.thinkingProtocol[\s\S]*?<ReasoningEffortSelect[\s\S]*?className="provider-chosen-capability-rows"/,
);
+ // Every capability uses the shared Checkbox and the shared help mark.
+ assert.doesNotMatch(advancedSource, /<input\s+type="checkbox"/);
+ assert.doesNotMatch(advancedSource, /provider-chosen-delegation/);
+ assert.match(styles, /\.provider-advanced-options \{[\s\S]*?grid-template-columns:/);
+ assert.match(styles, /\.provider-chosen-capability-rows \{[\s\S]*?display: grid;/);
assert.match(styles, /\.provider-chosen-field \{/);
assert.match(styles, /\.provider-chosen-row-body\[hidden\] \{/);
assert.match(
diff --git a/apps/desktop/test/model-limit-presets.test.mjs b/apps/desktop/test/model-limit-presets.test.mjs
index 29edca2a6..261041032 100644
--- a/apps/desktop/test/model-limit-presets.test.mjs
+++ b/apps/desktop/test/model-limit-presets.test.mjs
@@ -48,22 +48,17 @@ test("matchPresetIndex highlights only an exact token count", () => {
});
test("both limit fields wire a preset ladder above their numeric input", async () => {
- const pane = await read("../src/components/settings/ModelSelectionPanes.tsx");
- // One ladder group per field, each chip applying its preset to the binding.
- assert.equal(pane.split("provider-limit-presets").length - 1, 2);
- assert.match(pane, /CONTEXT_WINDOW_PRESETS\.map\(\(preset, index\) =>/);
- assert.match(pane, /MAX_OUTPUT_PRESETS\.map\(\(preset, index\) =>/);
- assert.match(pane, /contextWindow: preset\.tokens/);
- assert.match(pane, /maxTokens: preset\.tokens/);
+ const pane = await read("../src/components/settings/ModelAdvancedSettings.tsx");
+ // One shared limit field renders the ladder; both limits use it.
+ assert.equal(pane.split("<TokenLimitField").length - 1, 2);
+ assert.match(pane, /className="provider-limit-presets"/);
+ assert.match(pane, /presets=\{CONTEXT_WINDOW_PRESETS\}\s*value=\{binding\.contextWindow\}/);
+ assert.match(pane, /presets=\{MAX_OUTPUT_PRESETS\}\s*value=\{binding\.maxTokens\}/);
+ assert.match(pane, /contextWindow: tokens,\s*contextWindowSource: "user"/);
+ assert.match(pane, /maxTokens: tokens,\s*maxTokensSource: "user"/);
+ assert.match(pane, /onClick=\{\(\) => onChange\(preset\.tokens\)\}/);
// The current value highlights (aria-pressed) via the shared match helper.
- assert.match(
- pane,
- /matchPresetIndex\(\s*CONTEXT_WINDOW_PRESETS,\s*binding\.contextWindow,\s*\)/,
- );
- assert.match(
- pane,
- /matchPresetIndex\(\s*MAX_OUTPUT_PRESETS,\s*binding\.maxTokens,\s*\)/,
- );
+ assert.match(pane, /matchPresetIndex\(presets, value\)/);
// Chips reuse the thinking controls' segmented-track style.
assert.match(pane, /"provider-thinking-chip",\s*on && "selected"/);
});
diff --git a/apps/desktop/test/provider-model-config.test.mjs b/apps/desktop/test/provider-model-config.test.mjs
index 74eaa856d..4cdf20521 100644
--- a/apps/desktop/test/provider-model-config.test.mjs
+++ b/apps/desktop/test/provider-model-config.test.mjs
@@ -26,7 +26,11 @@ const setupSource = await read("../src/components/settings/ProviderSetupDialog.t
const hookSource = await read("../src/components/settings/useProviderModels.ts");
const pageSource = await read("../src/components/settings/ModelConfigPage.tsx");
const vendorDialogSource = await read("../src/components/settings/VendorAccountDialog.tsx");
-const pickerSource = await read("../src/components/settings/ModelSelectionPanes.tsx");
+// The picker and its per-model Advanced sheet form one surface.
+const pickerSource = [
+ await read("../src/components/settings/ModelSelectionPanes.tsx"),
+ await read("../src/components/settings/ModelAdvancedSettings.tsx"),
+].join("\n");
const fieldsSource = await read("../src/components/settings/ProviderConnectionFields.tsx");
const filterSource = await read("../src/components/settings/model-chosen-filter.ts");
const vendorAccountsSource = await read("../src/components/settings/useVendorAccounts.ts");
diff --git a/apps/desktop/test/thinking-ui.test.mjs b/apps/desktop/test/thinking-ui.test.mjs
index 5dc7e8ed7..a03bcb3a5 100644
--- a/apps/desktop/test/thinking-ui.test.mjs
+++ b/apps/desktop/test/thinking-ui.test.mjs
@@ -61,6 +61,7 @@ const settingsSource = (
"../src/components/settings/ProviderSetupDialog.tsx",
// The picker both credential kinds render owns the thinking chips (D270).
"../src/components/settings/ModelSelectionPanes.tsx",
+ "../src/components/settings/ModelAdvancedSettings.tsx",
"../src/components/settings/VendorAccountDialog.tsx",
"../src/components/settings/useProviderModels.ts",
].map((path) => readFile(new URL(path, import.meta.url), "utf8")),