Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a02ed3dd81 | ||
|
|
7acd0d3a3f |
No files matched your search
@@ -0,0 +1,114 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useMemo, type ReactNode } from "react";
|
||||||
|
import { Equal, Schema } from "effect";
|
||||||
|
import { ClientSettingsSchema, ServerSettings } from "@t3tools/contracts/settings";
|
||||||
|
import {
|
||||||
|
schemaFormOptionLabels,
|
||||||
|
type SchemaFormControl as SchemaFormControlKind,
|
||||||
|
} from "@t3tools/contracts/schemaForm";
|
||||||
|
|
||||||
|
import { SchemaFormFieldControl } from "./SchemaFormControl";
|
||||||
|
import { SettingResetButton, SettingsRow } from "./settingsLayout";
|
||||||
|
import {
|
||||||
|
deriveSchemaFormFields,
|
||||||
|
type SchemaFormFieldModel,
|
||||||
|
type SchemaFormSchema,
|
||||||
|
} from "./schemaForm";
|
||||||
|
|
||||||
|
const ThemePreference = Schema.Literals(["system", "light", "dark"]);
|
||||||
|
|
||||||
|
type MainSettingsFormControl = Extract<
|
||||||
|
SchemaFormControlKind,
|
||||||
|
"select" | "switch" | "text" | "textGenerationModelSelection"
|
||||||
|
>;
|
||||||
|
|
||||||
|
export type MainSettingsFieldModel = SchemaFormFieldModel<MainSettingsFormControl>;
|
||||||
|
|
||||||
|
export const ThemeSettingsSchema = Schema.Struct({
|
||||||
|
theme: ThemePreference.pipe(
|
||||||
|
Schema.annotateKey({
|
||||||
|
title: "Theme",
|
||||||
|
description: "Choose how T3 Code looks across the app.",
|
||||||
|
schemaForm: {
|
||||||
|
order: 0,
|
||||||
|
resetLabel: "theme",
|
||||||
|
ariaLabel: "Theme preference",
|
||||||
|
optionLabels: schemaFormOptionLabels(ThemePreference, {
|
||||||
|
system: "System",
|
||||||
|
light: "Light",
|
||||||
|
dark: "Dark",
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const MAIN_SETTINGS_FORM_SCHEMAS: readonly SchemaFormSchema[] = [
|
||||||
|
ThemeSettingsSchema,
|
||||||
|
ClientSettingsSchema,
|
||||||
|
ServerSettings,
|
||||||
|
];
|
||||||
|
|
||||||
|
export function deriveMainSettingsFields(
|
||||||
|
schemas: readonly SchemaFormSchema[] = MAIN_SETTINGS_FORM_SCHEMAS,
|
||||||
|
): ReadonlyArray<MainSettingsFieldModel> {
|
||||||
|
return deriveSchemaFormFields({
|
||||||
|
schemas,
|
||||||
|
allowedControls: ["select", "switch", "text", "textGenerationModelSelection"],
|
||||||
|
includeUnannotatedFields: false,
|
||||||
|
sortByFormOrder: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MainSettingsFormProps {
|
||||||
|
readonly values: Readonly<Record<string, unknown>>;
|
||||||
|
readonly defaultValues: Readonly<Record<string, unknown>>;
|
||||||
|
readonly customControls?: Readonly<Record<string, ReactNode | undefined>> | undefined;
|
||||||
|
readonly onChange: (key: string, value: unknown) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function MainSettingsForm({
|
||||||
|
values,
|
||||||
|
defaultValues,
|
||||||
|
customControls,
|
||||||
|
onChange,
|
||||||
|
}: MainSettingsFormProps) {
|
||||||
|
const fields = useMemo(() => deriveMainSettingsFields(), []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{fields.map((field) => {
|
||||||
|
const value = values[field.key];
|
||||||
|
const defaultValue = defaultValues[field.key];
|
||||||
|
const isDirty = !Equal.equals(value, defaultValue);
|
||||||
|
return (
|
||||||
|
<SettingsRow
|
||||||
|
key={field.key}
|
||||||
|
title={field.label}
|
||||||
|
description={field.description ?? ""}
|
||||||
|
resetAction={
|
||||||
|
isDirty ? (
|
||||||
|
<SettingResetButton
|
||||||
|
label={field.resetLabel}
|
||||||
|
onClick={() => onChange(field.key, defaultValue)}
|
||||||
|
/>
|
||||||
|
) : null
|
||||||
|
}
|
||||||
|
control={
|
||||||
|
<SchemaFormFieldControl
|
||||||
|
field={field}
|
||||||
|
value={value}
|
||||||
|
className="w-full sm:w-72"
|
||||||
|
selectClassName="w-full sm:w-44"
|
||||||
|
commitOnBlur
|
||||||
|
customControls={customControls}
|
||||||
|
onChange={(next) => onChange(field.key, next)}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,122 +1,50 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useMemo, type ReactNode } from "react";
|
import { useMemo, type ReactNode } from "react";
|
||||||
import { Schema } from "effect";
|
import type { SchemaFormControl as SchemaFormControlKind } from "@t3tools/contracts/schemaForm";
|
||||||
import type {
|
|
||||||
ProviderSettingsFormAnnotation,
|
|
||||||
ProviderSettingsFormControl,
|
|
||||||
ProviderSettingsFormSchemaAnnotation,
|
|
||||||
} from "@t3tools/contracts";
|
|
||||||
|
|
||||||
import { cn } from "../../lib/utils";
|
import { cn } from "../../lib/utils";
|
||||||
import { DraftInput } from "../ui/draft-input";
|
|
||||||
import { Input } from "../ui/input";
|
|
||||||
import { Switch } from "../ui/switch";
|
|
||||||
import { Textarea } from "../ui/textarea";
|
|
||||||
import type { ProviderClientDefinition } from "./providerDriverMeta";
|
import type { ProviderClientDefinition } from "./providerDriverMeta";
|
||||||
|
import {
|
||||||
|
getSchemaFormFieldLayout,
|
||||||
|
readSchemaFormBoolean,
|
||||||
|
readSchemaFormFieldValue,
|
||||||
|
readSchemaFormString,
|
||||||
|
SchemaFormFieldControl,
|
||||||
|
} from "./SchemaFormControl";
|
||||||
|
import { deriveSchemaFormFields, type SchemaFormFieldModel } from "./schemaForm";
|
||||||
|
|
||||||
export interface ProviderSettingsFieldModel {
|
type ProviderSettingsFormControl = Extract<
|
||||||
|
SchemaFormControlKind,
|
||||||
|
"text" | "password" | "textarea" | "switch"
|
||||||
|
>;
|
||||||
|
|
||||||
|
export type ProviderSettingsFieldModel = SchemaFormFieldModel<ProviderSettingsFormControl>;
|
||||||
|
|
||||||
|
interface ProviderSettingsValueField {
|
||||||
readonly key: string;
|
readonly key: string;
|
||||||
readonly control: ProviderSettingsFormControl;
|
readonly control: ProviderSettingsFormControl;
|
||||||
readonly label: string;
|
readonly label?: string | undefined;
|
||||||
readonly description?: string | undefined;
|
|
||||||
readonly placeholder?: string | undefined;
|
|
||||||
readonly clearWhenEmpty: "omit" | "persist";
|
readonly clearWhenEmpty: "omit" | "persist";
|
||||||
readonly defaultBooleanValue?: boolean | undefined;
|
readonly defaultBooleanValue?: boolean | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
function titleizeFieldKey(key: string): string {
|
|
||||||
return key
|
|
||||||
.replace(/([a-z0-9])([A-Z])/g, "$1 $2")
|
|
||||||
.replace(/[-_]+/g, " ")
|
|
||||||
.replace(/^./, (char) => char.toUpperCase());
|
|
||||||
}
|
|
||||||
|
|
||||||
function readFieldAnnotations(
|
|
||||||
fieldSchema: ProviderClientDefinition["settingsSchema"]["fields"][string],
|
|
||||||
) {
|
|
||||||
return Schema.resolveAnnotationsKey(fieldSchema) ?? Schema.resolveAnnotations(fieldSchema);
|
|
||||||
}
|
|
||||||
|
|
||||||
function readFieldAnnotationString(
|
|
||||||
fieldSchema: ProviderClientDefinition["settingsSchema"]["fields"][string],
|
|
||||||
key: "title" | "description",
|
|
||||||
): string | undefined {
|
|
||||||
const annotations = readFieldAnnotations(fieldSchema);
|
|
||||||
const value = annotations?.[key];
|
|
||||||
return typeof value === "string" ? value : undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
function readProviderSettingsFormAnnotation(
|
|
||||||
fieldSchema: ProviderClientDefinition["settingsSchema"]["fields"][string],
|
|
||||||
): ProviderSettingsFormAnnotation {
|
|
||||||
const annotation = readFieldAnnotations(fieldSchema)?.providerSettingsForm;
|
|
||||||
return annotation ?? {};
|
|
||||||
}
|
|
||||||
|
|
||||||
function readProviderSettingsFormSchemaAnnotation(
|
|
||||||
definition: ProviderClientDefinition,
|
|
||||||
): ProviderSettingsFormSchemaAnnotation {
|
|
||||||
return Schema.resolveAnnotations(definition.settingsSchema)?.providerSettingsFormSchema ?? {};
|
|
||||||
}
|
|
||||||
|
|
||||||
function readFieldBooleanDefault(
|
|
||||||
fieldSchema: ProviderClientDefinition["settingsSchema"]["fields"][string],
|
|
||||||
): boolean | undefined {
|
|
||||||
try {
|
|
||||||
const decoded = Schema.decodeUnknownSync(fieldSchema as Schema.Decoder<unknown>)(undefined);
|
|
||||||
return typeof decoded === "boolean" ? decoded : undefined;
|
|
||||||
} catch {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function deriveProviderSettingsFields(
|
export function deriveProviderSettingsFields(
|
||||||
definition: ProviderClientDefinition,
|
definition: ProviderClientDefinition,
|
||||||
): ReadonlyArray<ProviderSettingsFieldModel> {
|
): ReadonlyArray<ProviderSettingsFieldModel> {
|
||||||
const schemaAnnotation = readProviderSettingsFormSchemaAnnotation(definition);
|
return deriveSchemaFormFields({
|
||||||
const orderedKeys = new Map(
|
schemas: [definition.settingsSchema],
|
||||||
(schemaAnnotation.order ?? []).map((key, index) => [key, index] as const),
|
allowedControls: ["text", "password", "textarea", "switch"],
|
||||||
);
|
includeUnannotatedFields: true,
|
||||||
const orderFallbackOffset = orderedKeys.size;
|
defaultControl: ({ inferredControl }) => {
|
||||||
|
return inferredControl?.control === "switch" ? "switch" : "text";
|
||||||
return Object.keys(definition.settingsSchema.fields)
|
},
|
||||||
.map((key, index) => ({ key, index }))
|
});
|
||||||
.toSorted((left, right) => {
|
|
||||||
return (
|
|
||||||
(orderedKeys.get(left.key) ?? orderFallbackOffset + left.index) -
|
|
||||||
(orderedKeys.get(right.key) ?? orderFallbackOffset + right.index)
|
|
||||||
);
|
|
||||||
})
|
|
||||||
.flatMap(({ key }) => {
|
|
||||||
const fieldSchema = definition.settingsSchema.fields[key]!;
|
|
||||||
const formAnnotation = readProviderSettingsFormAnnotation(fieldSchema);
|
|
||||||
if (formAnnotation.hidden) return [];
|
|
||||||
|
|
||||||
const annotatedTitle = readFieldAnnotationString(fieldSchema, "title");
|
|
||||||
const annotatedDescription = readFieldAnnotationString(fieldSchema, "description");
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
key,
|
|
||||||
control: formAnnotation.control ?? "text",
|
|
||||||
label: annotatedTitle ?? titleizeFieldKey(key),
|
|
||||||
...(annotatedDescription !== undefined ? { description: annotatedDescription } : {}),
|
|
||||||
...(formAnnotation.placeholder !== undefined
|
|
||||||
? { placeholder: formAnnotation.placeholder }
|
|
||||||
: {}),
|
|
||||||
clearWhenEmpty: formAnnotation.clearWhenEmpty ?? "omit",
|
|
||||||
...(formAnnotation.control === "switch"
|
|
||||||
? { defaultBooleanValue: readFieldBooleanDefault(fieldSchema) }
|
|
||||||
: {}),
|
|
||||||
} satisfies ProviderSettingsFieldModel,
|
|
||||||
];
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function readProviderConfigString(config: unknown, key: string): string {
|
export function readProviderConfigString(config: unknown, key: string): string {
|
||||||
if (config === null || typeof config !== "object") return "";
|
if (config === null || typeof config !== "object") return "";
|
||||||
const value = (config as Record<string, unknown>)[key];
|
return readSchemaFormString((config as Record<string, unknown>)[key]);
|
||||||
return typeof value === "string" ? value : "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function readProviderConfigBoolean(
|
export function readProviderConfigBoolean(
|
||||||
@@ -125,13 +53,24 @@ export function readProviderConfigBoolean(
|
|||||||
defaultValue = false,
|
defaultValue = false,
|
||||||
): boolean {
|
): boolean {
|
||||||
if (config === null || typeof config !== "object") return defaultValue;
|
if (config === null || typeof config !== "object") return defaultValue;
|
||||||
const value = (config as Record<string, unknown>)[key];
|
return readSchemaFormBoolean((config as Record<string, unknown>)[key], defaultValue);
|
||||||
return typeof value === "boolean" ? value : defaultValue;
|
}
|
||||||
|
|
||||||
|
function readProviderConfigFieldValue(config: unknown, field: ProviderSettingsValueField) {
|
||||||
|
if (config === null || typeof config !== "object") {
|
||||||
|
return readSchemaFormFieldValue(field, undefined, field.defaultBooleanValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
return readSchemaFormFieldValue(
|
||||||
|
field,
|
||||||
|
(config as Record<string, unknown>)[field.key],
|
||||||
|
field.defaultBooleanValue,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function nextProviderConfigWithFieldValue(
|
export function nextProviderConfigWithFieldValue(
|
||||||
config: unknown,
|
config: unknown,
|
||||||
field: ProviderSettingsFieldModel,
|
field: ProviderSettingsValueField,
|
||||||
value: string | boolean,
|
value: string | boolean,
|
||||||
): Record<string, unknown> | undefined {
|
): Record<string, unknown> | undefined {
|
||||||
const base: Record<string, unknown> =
|
const base: Record<string, unknown> =
|
||||||
@@ -198,8 +137,19 @@ function ProviderSettingsFieldRow({
|
|||||||
const description = field.description ? (
|
const description = field.description ? (
|
||||||
<span className={descriptionClassName}>{field.description}</span>
|
<span className={descriptionClassName}>{field.description}</span>
|
||||||
) : null;
|
) : null;
|
||||||
|
const control = (
|
||||||
|
<SchemaFormFieldControl
|
||||||
|
field={field}
|
||||||
|
value={readProviderConfigFieldValue(value, field)}
|
||||||
|
booleanDefault={field.defaultBooleanValue}
|
||||||
|
id={inputId}
|
||||||
|
className={variant === "card" ? "mt-1.5" : "bg-background"}
|
||||||
|
commitOnBlur={variant === "card"}
|
||||||
|
onChange={(next) => onChange(nextProviderConfigWithFieldValue(value, field, next))}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
if (field.control === "switch") {
|
if (getSchemaFormFieldLayout(field) === "inline") {
|
||||||
return (
|
return (
|
||||||
<FieldFrame variant={variant}>
|
<FieldFrame variant={variant}>
|
||||||
<div className="flex items-center justify-between gap-3">
|
<div className="flex items-center justify-between gap-3">
|
||||||
@@ -207,69 +157,17 @@ function ProviderSettingsFieldRow({
|
|||||||
{label}
|
{label}
|
||||||
{description}
|
{description}
|
||||||
</div>
|
</div>
|
||||||
<Switch
|
{control}
|
||||||
checked={readProviderConfigBoolean(value, field.key, field.defaultBooleanValue)}
|
|
||||||
onCheckedChange={(checked) =>
|
|
||||||
onChange(nextProviderConfigWithFieldValue(value, field, Boolean(checked)))
|
|
||||||
}
|
|
||||||
aria-label={field.label}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</FieldFrame>
|
</FieldFrame>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (field.control === "textarea") {
|
|
||||||
return (
|
|
||||||
<FieldFrame variant={variant}>
|
|
||||||
<label htmlFor={inputId} className={cn(variant === "card" && "block")}>
|
|
||||||
{label}
|
|
||||||
<Textarea
|
|
||||||
id={inputId}
|
|
||||||
className={cn(variant === "card" && "mt-1.5")}
|
|
||||||
value={readProviderConfigString(value, field.key)}
|
|
||||||
onChange={(event) =>
|
|
||||||
onChange(nextProviderConfigWithFieldValue(value, field, event.target.value))
|
|
||||||
}
|
|
||||||
placeholder={field.placeholder}
|
|
||||||
spellCheck={false}
|
|
||||||
/>
|
|
||||||
{description}
|
|
||||||
</label>
|
|
||||||
</FieldFrame>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const type = field.control === "password" ? "password" : undefined;
|
|
||||||
return (
|
return (
|
||||||
<FieldFrame variant={variant}>
|
<FieldFrame variant={variant}>
|
||||||
<label htmlFor={inputId} className={cn(variant === "card" && "block")}>
|
<label htmlFor={inputId} className={cn(variant === "card" && "block")}>
|
||||||
{label}
|
{label}
|
||||||
{variant === "card" ? (
|
{control}
|
||||||
<DraftInput
|
|
||||||
id={inputId}
|
|
||||||
className="mt-1.5"
|
|
||||||
type={type}
|
|
||||||
autoComplete={field.control === "password" ? "off" : undefined}
|
|
||||||
value={readProviderConfigString(value, field.key)}
|
|
||||||
onCommit={(next) => onChange(nextProviderConfigWithFieldValue(value, field, next))}
|
|
||||||
placeholder={field.placeholder}
|
|
||||||
spellCheck={false}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<Input
|
|
||||||
id={inputId}
|
|
||||||
className="bg-background"
|
|
||||||
type={type}
|
|
||||||
autoComplete={field.control === "password" ? "off" : undefined}
|
|
||||||
value={readProviderConfigString(value, field.key)}
|
|
||||||
onChange={(event) =>
|
|
||||||
onChange(nextProviderConfigWithFieldValue(value, field, event.target.value))
|
|
||||||
}
|
|
||||||
placeholder={field.placeholder}
|
|
||||||
spellCheck={false}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{description}
|
{description}
|
||||||
</label>
|
</label>
|
||||||
</FieldFrame>
|
</FieldFrame>
|
||||||
|
|||||||
@@ -0,0 +1,229 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import type { ReactNode } from "react";
|
||||||
|
import { DraftInput } from "../ui/draft-input";
|
||||||
|
import { Input } from "../ui/input";
|
||||||
|
import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "../ui/select";
|
||||||
|
import { Switch } from "../ui/switch";
|
||||||
|
import { Textarea } from "../ui/textarea";
|
||||||
|
import type { SchemaFormSelectOption } from "./schemaForm";
|
||||||
|
|
||||||
|
export interface SchemaFormControlField {
|
||||||
|
readonly key: string;
|
||||||
|
readonly control: string;
|
||||||
|
readonly label: string;
|
||||||
|
readonly ariaLabel?: string | undefined;
|
||||||
|
readonly placeholder?: string | undefined;
|
||||||
|
readonly options?: readonly SchemaFormSelectOption[] | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getSchemaFormFieldLayout(field: SchemaFormControlField): "inline" | "block" {
|
||||||
|
return field.control === "switch" ? "inline" : "block";
|
||||||
|
}
|
||||||
|
|
||||||
|
export function readSchemaFormFieldValue(
|
||||||
|
field: Pick<SchemaFormControlField, "control">,
|
||||||
|
value: unknown,
|
||||||
|
booleanDefault?: boolean | undefined,
|
||||||
|
): string | boolean {
|
||||||
|
return field.control === "switch"
|
||||||
|
? readSchemaFormBoolean(value, booleanDefault)
|
||||||
|
: readSchemaFormString(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
type SchemaFormControlProps =
|
||||||
|
| {
|
||||||
|
readonly control: "switch";
|
||||||
|
readonly checked: boolean;
|
||||||
|
readonly ariaLabel: string;
|
||||||
|
readonly onChange: (checked: boolean) => void;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
readonly control: "select";
|
||||||
|
readonly value: string;
|
||||||
|
readonly options: readonly SchemaFormSelectOption[];
|
||||||
|
readonly ariaLabel: string;
|
||||||
|
readonly className?: string | undefined;
|
||||||
|
readonly onChange: (value: string) => void;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
readonly control: "text" | "password";
|
||||||
|
readonly value: string;
|
||||||
|
readonly id?: string | undefined;
|
||||||
|
readonly className?: string | undefined;
|
||||||
|
readonly placeholder?: string | undefined;
|
||||||
|
readonly ariaLabel?: string | undefined;
|
||||||
|
readonly spellCheck?: boolean | undefined;
|
||||||
|
readonly commitOnBlur: boolean;
|
||||||
|
readonly onChange: (value: string) => void;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
readonly control: "textarea";
|
||||||
|
readonly value: string;
|
||||||
|
readonly id?: string | undefined;
|
||||||
|
readonly className?: string | undefined;
|
||||||
|
readonly placeholder?: string | undefined;
|
||||||
|
readonly spellCheck?: boolean | undefined;
|
||||||
|
readonly onChange: (value: string) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function readSchemaFormString(value: unknown): string {
|
||||||
|
return typeof value === "string" ? value : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
export function readSchemaFormBoolean(value: unknown, defaultValue = false): boolean {
|
||||||
|
return typeof value === "boolean" ? value : defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function SchemaFormControl(props: SchemaFormControlProps) {
|
||||||
|
if (props.control === "switch") {
|
||||||
|
return (
|
||||||
|
<Switch
|
||||||
|
checked={props.checked}
|
||||||
|
onCheckedChange={(checked) => props.onChange(Boolean(checked))}
|
||||||
|
aria-label={props.ariaLabel}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (props.control === "select") {
|
||||||
|
const selectedLabel =
|
||||||
|
props.options.find((option) => option.value === props.value)?.label ?? props.value;
|
||||||
|
return (
|
||||||
|
<Select
|
||||||
|
value={props.value}
|
||||||
|
onValueChange={(nextValue) => {
|
||||||
|
if (
|
||||||
|
typeof nextValue === "string" &&
|
||||||
|
props.options.some((option) => option.value === nextValue)
|
||||||
|
) {
|
||||||
|
props.onChange(nextValue);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<SelectTrigger className={props.className} aria-label={props.ariaLabel}>
|
||||||
|
<SelectValue>{selectedLabel}</SelectValue>
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectPopup align="end" alignItemWithTrigger={false}>
|
||||||
|
{props.options.map((option) => (
|
||||||
|
<SelectItem hideIndicator key={option.value} value={option.value}>
|
||||||
|
{option.label}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectPopup>
|
||||||
|
</Select>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (props.control === "textarea") {
|
||||||
|
return (
|
||||||
|
<Textarea
|
||||||
|
id={props.id}
|
||||||
|
className={props.className}
|
||||||
|
value={props.value}
|
||||||
|
onChange={(event) => props.onChange(event.target.value)}
|
||||||
|
placeholder={props.placeholder}
|
||||||
|
spellCheck={props.spellCheck}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const type = props.control === "password" ? "password" : undefined;
|
||||||
|
const autoComplete = props.control === "password" ? "off" : undefined;
|
||||||
|
const commonProps = {
|
||||||
|
id: props.id,
|
||||||
|
className: props.className,
|
||||||
|
type,
|
||||||
|
autoComplete,
|
||||||
|
value: props.value,
|
||||||
|
placeholder: props.placeholder,
|
||||||
|
spellCheck: props.spellCheck,
|
||||||
|
"aria-label": props.ariaLabel,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (props.commitOnBlur) {
|
||||||
|
return <DraftInput {...commonProps} onCommit={props.onChange} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
return <Input {...commonProps} onChange={(event) => props.onChange(event.target.value)} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function SchemaFormFieldControl({
|
||||||
|
field,
|
||||||
|
value,
|
||||||
|
booleanDefault,
|
||||||
|
id,
|
||||||
|
className,
|
||||||
|
selectClassName,
|
||||||
|
commitOnBlur,
|
||||||
|
customControls,
|
||||||
|
onChange,
|
||||||
|
}: {
|
||||||
|
readonly field: SchemaFormControlField;
|
||||||
|
readonly value: unknown;
|
||||||
|
readonly booleanDefault?: boolean | undefined;
|
||||||
|
readonly id?: string | undefined;
|
||||||
|
readonly className?: string | undefined;
|
||||||
|
readonly selectClassName?: string | undefined;
|
||||||
|
readonly commitOnBlur?: boolean | undefined;
|
||||||
|
readonly customControls?: Readonly<Record<string, ReactNode | undefined>> | undefined;
|
||||||
|
readonly onChange: (value: string | boolean) => void;
|
||||||
|
}) {
|
||||||
|
const ariaLabel = field.ariaLabel ?? field.label;
|
||||||
|
|
||||||
|
if (field.control === "switch") {
|
||||||
|
return (
|
||||||
|
<SchemaFormControl
|
||||||
|
control="switch"
|
||||||
|
checked={readSchemaFormFieldValue(field, value, booleanDefault) === true}
|
||||||
|
ariaLabel={ariaLabel}
|
||||||
|
onChange={onChange}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (field.control === "select") {
|
||||||
|
return (
|
||||||
|
<SchemaFormControl
|
||||||
|
control="select"
|
||||||
|
value={String(readSchemaFormFieldValue(field, value))}
|
||||||
|
options={field.options ?? []}
|
||||||
|
className={selectClassName ?? className}
|
||||||
|
ariaLabel={ariaLabel}
|
||||||
|
onChange={onChange}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (field.control === "text" || field.control === "password") {
|
||||||
|
return (
|
||||||
|
<SchemaFormControl
|
||||||
|
control={field.control}
|
||||||
|
id={id}
|
||||||
|
className={className}
|
||||||
|
value={String(readSchemaFormFieldValue(field, value))}
|
||||||
|
commitOnBlur={commitOnBlur ?? false}
|
||||||
|
placeholder={field.placeholder}
|
||||||
|
spellCheck={false}
|
||||||
|
ariaLabel={ariaLabel}
|
||||||
|
onChange={onChange}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (field.control === "textarea") {
|
||||||
|
return (
|
||||||
|
<SchemaFormControl
|
||||||
|
control="textarea"
|
||||||
|
id={id}
|
||||||
|
className={className}
|
||||||
|
value={String(readSchemaFormFieldValue(field, value))}
|
||||||
|
placeholder={field.placeholder}
|
||||||
|
spellCheck={false}
|
||||||
|
onChange={onChange}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return customControls?.[field.key] ?? null;
|
||||||
|
}
|
||||||
@@ -50,12 +50,11 @@ import {
|
|||||||
import { formatRelativeTime, formatRelativeTimeLabel } from "../../timestampFormat";
|
import { formatRelativeTime, formatRelativeTimeLabel } from "../../timestampFormat";
|
||||||
import { Button } from "../ui/button";
|
import { Button } from "../ui/button";
|
||||||
import { Empty, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from "../ui/empty";
|
import { Empty, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from "../ui/empty";
|
||||||
import { DraftInput } from "../ui/draft-input";
|
|
||||||
import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "../ui/select";
|
import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "../ui/select";
|
||||||
import { Switch } from "../ui/switch";
|
|
||||||
import { stackedThreadToast, toastManager } from "../ui/toast";
|
import { stackedThreadToast, toastManager } from "../ui/toast";
|
||||||
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
|
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
|
||||||
import { AddProviderInstanceDialog } from "./AddProviderInstanceDialog";
|
import { AddProviderInstanceDialog } from "./AddProviderInstanceDialog";
|
||||||
|
import { deriveMainSettingsFields, MainSettingsForm } from "./MainSettingsForm";
|
||||||
import { ProviderInstanceCard } from "./ProviderInstanceCard";
|
import { ProviderInstanceCard } from "./ProviderInstanceCard";
|
||||||
import { DRIVER_OPTIONS, getDriverOption } from "./providerDriverMeta";
|
import { DRIVER_OPTIONS, getDriverOption } from "./providerDriverMeta";
|
||||||
import { buildProviderInstanceUpdatePatch } from "./SettingsPanels.logic";
|
import { buildProviderInstanceUpdatePatch } from "./SettingsPanels.logic";
|
||||||
@@ -74,27 +73,6 @@ import {
|
|||||||
useServerProviders,
|
useServerProviders,
|
||||||
} from "../../rpc/serverState";
|
} from "../../rpc/serverState";
|
||||||
|
|
||||||
const THEME_OPTIONS = [
|
|
||||||
{
|
|
||||||
value: "system",
|
|
||||||
label: "System",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: "light",
|
|
||||||
label: "Light",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: "dark",
|
|
||||||
label: "Dark",
|
|
||||||
},
|
|
||||||
] as const;
|
|
||||||
|
|
||||||
const TIMESTAMP_FORMAT_LABELS = {
|
|
||||||
locale: "System default",
|
|
||||||
"12-hour": "12-hour",
|
|
||||||
"24-hour": "24-hour",
|
|
||||||
} as const;
|
|
||||||
|
|
||||||
const DEFAULT_DRIVER_KIND = ProviderDriverKind.make("codex");
|
const DEFAULT_DRIVER_KIND = ProviderDriverKind.make("codex");
|
||||||
|
|
||||||
function withoutProviderInstanceKey<V>(
|
function withoutProviderInstanceKey<V>(
|
||||||
@@ -347,10 +325,6 @@ export function useSettingsRestore(onRestored?: () => void) {
|
|||||||
const settings = useSettings();
|
const settings = useSettings();
|
||||||
const { resetSettings } = useUpdateSettings();
|
const { resetSettings } = useUpdateSettings();
|
||||||
|
|
||||||
const isGitWritingModelDirty = !Equal.equals(
|
|
||||||
settings.textGenerationModelSelection ?? null,
|
|
||||||
DEFAULT_UNIFIED_SETTINGS.textGenerationModelSelection ?? null,
|
|
||||||
);
|
|
||||||
// A provider surface is "dirty" if either the legacy per-kind
|
// A provider surface is "dirty" if either the legacy per-kind
|
||||||
// `settings.providers[kind]` struct differs from defaults (for users
|
// `settings.providers[kind]` struct differs from defaults (for users
|
||||||
// on pre-migration data) or the new `settings.providerInstances` map
|
// on pre-migration data) or the new `settings.providerInstances` map
|
||||||
@@ -377,54 +351,17 @@ export function useSettingsRestore(onRestored?: () => void) {
|
|||||||
Object.keys(settings.providerModelPreferences ?? {}).length > 0 ||
|
Object.keys(settings.providerModelPreferences ?? {}).length > 0 ||
|
||||||
(settings.favorites ?? []).length > 0;
|
(settings.favorites ?? []).length > 0;
|
||||||
|
|
||||||
const changedSettingLabels = useMemo(
|
const mainSettingsFields = useMemo(() => deriveMainSettingsFields(), []);
|
||||||
() => [
|
const changedSettingLabels = useMemo(() => {
|
||||||
...(theme !== "system" ? ["Theme"] : []),
|
const values: Record<string, unknown> = { ...settings, theme };
|
||||||
...(settings.timestampFormat !== DEFAULT_UNIFIED_SETTINGS.timestampFormat
|
const defaultValues: Record<string, unknown> = { ...DEFAULT_UNIFIED_SETTINGS, theme: "system" };
|
||||||
? ["Time format"]
|
return [
|
||||||
: []),
|
...mainSettingsFields.flatMap((field) =>
|
||||||
...(settings.diffWordWrap !== DEFAULT_UNIFIED_SETTINGS.diffWordWrap
|
Equal.equals(values[field.key], defaultValues[field.key]) ? [] : [field.label],
|
||||||
? ["Diff line wrapping"]
|
),
|
||||||
: []),
|
|
||||||
...(settings.diffIgnoreWhitespace !== DEFAULT_UNIFIED_SETTINGS.diffIgnoreWhitespace
|
|
||||||
? ["Diff whitespace changes"]
|
|
||||||
: []),
|
|
||||||
...(settings.autoOpenPlanSidebar !== DEFAULT_UNIFIED_SETTINGS.autoOpenPlanSidebar
|
|
||||||
? ["Auto-open task panel"]
|
|
||||||
: []),
|
|
||||||
...(settings.enableAssistantStreaming !== DEFAULT_UNIFIED_SETTINGS.enableAssistantStreaming
|
|
||||||
? ["Assistant output"]
|
|
||||||
: []),
|
|
||||||
...(settings.defaultThreadEnvMode !== DEFAULT_UNIFIED_SETTINGS.defaultThreadEnvMode
|
|
||||||
? ["New thread mode"]
|
|
||||||
: []),
|
|
||||||
...(settings.addProjectBaseDirectory !== DEFAULT_UNIFIED_SETTINGS.addProjectBaseDirectory
|
|
||||||
? ["Add project base directory"]
|
|
||||||
: []),
|
|
||||||
...(settings.confirmThreadArchive !== DEFAULT_UNIFIED_SETTINGS.confirmThreadArchive
|
|
||||||
? ["Archive confirmation"]
|
|
||||||
: []),
|
|
||||||
...(settings.confirmThreadDelete !== DEFAULT_UNIFIED_SETTINGS.confirmThreadDelete
|
|
||||||
? ["Delete confirmation"]
|
|
||||||
: []),
|
|
||||||
...(isGitWritingModelDirty ? ["Git writing model"] : []),
|
|
||||||
...(areProviderSettingsDirty ? ["Providers"] : []),
|
...(areProviderSettingsDirty ? ["Providers"] : []),
|
||||||
],
|
];
|
||||||
[
|
}, [areProviderSettingsDirty, mainSettingsFields, settings, theme]);
|
||||||
areProviderSettingsDirty,
|
|
||||||
isGitWritingModelDirty,
|
|
||||||
settings.autoOpenPlanSidebar,
|
|
||||||
settings.confirmThreadArchive,
|
|
||||||
settings.confirmThreadDelete,
|
|
||||||
settings.addProjectBaseDirectory,
|
|
||||||
settings.defaultThreadEnvMode,
|
|
||||||
settings.diffIgnoreWhitespace,
|
|
||||||
settings.diffWordWrap,
|
|
||||||
settings.enableAssistantStreaming,
|
|
||||||
settings.timestampFormat,
|
|
||||||
theme,
|
|
||||||
],
|
|
||||||
);
|
|
||||||
|
|
||||||
const restoreDefaults = useCallback(async () => {
|
const restoreDefaults = useCallback(async () => {
|
||||||
if (changedSettingLabels.length === 0) return;
|
if (changedSettingLabels.length === 0) return;
|
||||||
@@ -527,11 +464,6 @@ export function GeneralSettingsPanel() {
|
|||||||
textGenInstanceId,
|
textGenInstanceId,
|
||||||
textGenModel,
|
textGenModel,
|
||||||
);
|
);
|
||||||
const isGitWritingModelDirty = !Equal.equals(
|
|
||||||
settings.textGenerationModelSelection ?? null,
|
|
||||||
DEFAULT_UNIFIED_SETTINGS.textGenerationModelSelection ?? null,
|
|
||||||
);
|
|
||||||
|
|
||||||
const openInPreferredEditor = useCallback(
|
const openInPreferredEditor = useCallback(
|
||||||
(target: "keybindings" | "logsDirectory", path: string | null, failureMessage: string) => {
|
(target: "keybindings" | "logsDirectory", path: string | null, failureMessage: string) => {
|
||||||
if (!path) return;
|
if (!path) return;
|
||||||
@@ -794,377 +726,76 @@ export function GeneralSettingsPanel() {
|
|||||||
return (
|
return (
|
||||||
<SettingsPageContainer>
|
<SettingsPageContainer>
|
||||||
<SettingsSection title="General">
|
<SettingsSection title="General">
|
||||||
<SettingsRow
|
<MainSettingsForm
|
||||||
title="Theme"
|
values={{ ...settings, theme }}
|
||||||
description="Choose how T3 Code looks across the app."
|
defaultValues={{ ...DEFAULT_UNIFIED_SETTINGS, theme: "system" }}
|
||||||
resetAction={
|
onChange={(key, value) => {
|
||||||
theme !== "system" ? (
|
if (key === "theme") {
|
||||||
<SettingResetButton label="theme" onClick={() => setTheme("system")} />
|
if (value === "system" || value === "light" || value === "dark") {
|
||||||
) : null
|
setTheme(value);
|
||||||
}
|
|
||||||
control={
|
|
||||||
<Select
|
|
||||||
value={theme}
|
|
||||||
onValueChange={(value) => {
|
|
||||||
if (value === "system" || value === "light" || value === "dark") {
|
|
||||||
setTheme(value);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<SelectTrigger className="w-full sm:w-40" aria-label="Theme preference">
|
|
||||||
<SelectValue>
|
|
||||||
{THEME_OPTIONS.find((option) => option.value === theme)?.label ?? "System"}
|
|
||||||
</SelectValue>
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectPopup align="end" alignItemWithTrigger={false}>
|
|
||||||
{THEME_OPTIONS.map((option) => (
|
|
||||||
<SelectItem hideIndicator key={option.value} value={option.value}>
|
|
||||||
{option.label}
|
|
||||||
</SelectItem>
|
|
||||||
))}
|
|
||||||
</SelectPopup>
|
|
||||||
</Select>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<SettingsRow
|
|
||||||
title="Time format"
|
|
||||||
description="System default follows your browser or OS clock preference."
|
|
||||||
resetAction={
|
|
||||||
settings.timestampFormat !== DEFAULT_UNIFIED_SETTINGS.timestampFormat ? (
|
|
||||||
<SettingResetButton
|
|
||||||
label="time format"
|
|
||||||
onClick={() =>
|
|
||||||
updateSettings({
|
|
||||||
timestampFormat: DEFAULT_UNIFIED_SETTINGS.timestampFormat,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
) : null
|
|
||||||
}
|
|
||||||
control={
|
|
||||||
<Select
|
|
||||||
value={settings.timestampFormat}
|
|
||||||
onValueChange={(value) => {
|
|
||||||
if (value === "locale" || value === "12-hour" || value === "24-hour") {
|
|
||||||
updateSettings({ timestampFormat: value });
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<SelectTrigger className="w-full sm:w-40" aria-label="Timestamp format">
|
|
||||||
<SelectValue>{TIMESTAMP_FORMAT_LABELS[settings.timestampFormat]}</SelectValue>
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectPopup align="end" alignItemWithTrigger={false}>
|
|
||||||
<SelectItem hideIndicator value="locale">
|
|
||||||
{TIMESTAMP_FORMAT_LABELS.locale}
|
|
||||||
</SelectItem>
|
|
||||||
<SelectItem hideIndicator value="12-hour">
|
|
||||||
{TIMESTAMP_FORMAT_LABELS["12-hour"]}
|
|
||||||
</SelectItem>
|
|
||||||
<SelectItem hideIndicator value="24-hour">
|
|
||||||
{TIMESTAMP_FORMAT_LABELS["24-hour"]}
|
|
||||||
</SelectItem>
|
|
||||||
</SelectPopup>
|
|
||||||
</Select>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<SettingsRow
|
|
||||||
title="Diff line wrapping"
|
|
||||||
description="Set the default wrap state when the diff panel opens."
|
|
||||||
resetAction={
|
|
||||||
settings.diffWordWrap !== DEFAULT_UNIFIED_SETTINGS.diffWordWrap ? (
|
|
||||||
<SettingResetButton
|
|
||||||
label="diff line wrapping"
|
|
||||||
onClick={() =>
|
|
||||||
updateSettings({
|
|
||||||
diffWordWrap: DEFAULT_UNIFIED_SETTINGS.diffWordWrap,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
) : null
|
|
||||||
}
|
|
||||||
control={
|
|
||||||
<Switch
|
|
||||||
checked={settings.diffWordWrap}
|
|
||||||
onCheckedChange={(checked) => updateSettings({ diffWordWrap: Boolean(checked) })}
|
|
||||||
aria-label="Wrap diff lines by default"
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<SettingsRow
|
|
||||||
title="Hide whitespace changes"
|
|
||||||
description="Set whether the diff panel ignores whitespace-only edits by default."
|
|
||||||
resetAction={
|
|
||||||
settings.diffIgnoreWhitespace !== DEFAULT_UNIFIED_SETTINGS.diffIgnoreWhitespace ? (
|
|
||||||
<SettingResetButton
|
|
||||||
label="diff whitespace changes"
|
|
||||||
onClick={() =>
|
|
||||||
updateSettings({
|
|
||||||
diffIgnoreWhitespace: DEFAULT_UNIFIED_SETTINGS.diffIgnoreWhitespace,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
) : null
|
|
||||||
}
|
|
||||||
control={
|
|
||||||
<Switch
|
|
||||||
checked={settings.diffIgnoreWhitespace}
|
|
||||||
onCheckedChange={(checked) =>
|
|
||||||
updateSettings({ diffIgnoreWhitespace: Boolean(checked) })
|
|
||||||
}
|
}
|
||||||
aria-label="Hide whitespace changes by default"
|
return;
|
||||||
/>
|
}
|
||||||
}
|
updateSettings({ [key]: value } as Partial<typeof settings>);
|
||||||
/>
|
}}
|
||||||
|
customControls={{
|
||||||
<SettingsRow
|
textGenerationModelSelection: (
|
||||||
title="Assistant output"
|
<div className="flex flex-wrap items-center justify-end gap-1.5">
|
||||||
description="Show token-by-token output while a response is in progress."
|
<ProviderModelPicker
|
||||||
resetAction={
|
activeInstanceId={textGenInstanceId}
|
||||||
settings.enableAssistantStreaming !==
|
model={textGenModel}
|
||||||
DEFAULT_UNIFIED_SETTINGS.enableAssistantStreaming ? (
|
lockedProvider={null}
|
||||||
<SettingResetButton
|
instanceEntries={gitModelInstanceEntries}
|
||||||
label="assistant output"
|
modelOptionsByInstance={gitModelOptionsByInstance}
|
||||||
onClick={() =>
|
triggerVariant="outline"
|
||||||
updateSettings({
|
triggerClassName="min-w-0 max-w-none shrink-0 text-foreground/90 hover:text-foreground"
|
||||||
enableAssistantStreaming: DEFAULT_UNIFIED_SETTINGS.enableAssistantStreaming,
|
onInstanceModelChange={(instanceId, model) => {
|
||||||
})
|
updateSettings({
|
||||||
}
|
textGenerationModelSelection: resolveAppModelSelectionState(
|
||||||
/>
|
{
|
||||||
) : null
|
...settings,
|
||||||
}
|
textGenerationModelSelection: createModelSelection(instanceId, model),
|
||||||
control={
|
},
|
||||||
<Switch
|
serverProviders,
|
||||||
checked={settings.enableAssistantStreaming}
|
),
|
||||||
onCheckedChange={(checked) =>
|
});
|
||||||
updateSettings({ enableAssistantStreaming: Boolean(checked) })
|
}}
|
||||||
}
|
/>
|
||||||
aria-label="Stream assistant messages"
|
<TraitsPicker
|
||||||
/>
|
provider={textGenProvider}
|
||||||
}
|
models={
|
||||||
/>
|
// Use the exact instance's models (rather than the
|
||||||
|
// first-kind-match) so a custom text-gen instance like
|
||||||
<SettingsRow
|
// `codex_personal` gets its own model list, not the
|
||||||
title="Auto-open task panel"
|
// default Codex one.
|
||||||
description="Open the right-side plan and task panel automatically when steps appear."
|
textGenInstanceEntry?.models ?? []
|
||||||
resetAction={
|
}
|
||||||
settings.autoOpenPlanSidebar !== DEFAULT_UNIFIED_SETTINGS.autoOpenPlanSidebar ? (
|
model={textGenModel}
|
||||||
<SettingResetButton
|
prompt=""
|
||||||
label="auto-open task panel"
|
onPromptChange={() => {}}
|
||||||
onClick={() =>
|
modelOptions={textGenModelOptions}
|
||||||
updateSettings({
|
allowPromptInjectedEffort={false}
|
||||||
autoOpenPlanSidebar: DEFAULT_UNIFIED_SETTINGS.autoOpenPlanSidebar,
|
triggerVariant="outline"
|
||||||
})
|
triggerClassName="min-w-0 max-w-none shrink-0 text-foreground/90 hover:text-foreground"
|
||||||
}
|
onModelOptionsChange={(nextOptions) => {
|
||||||
/>
|
updateSettings({
|
||||||
) : null
|
textGenerationModelSelection: resolveAppModelSelectionState(
|
||||||
}
|
{
|
||||||
control={
|
...settings,
|
||||||
<Switch
|
textGenerationModelSelection: createModelSelection(
|
||||||
checked={settings.autoOpenPlanSidebar}
|
textGenInstanceId,
|
||||||
onCheckedChange={(checked) =>
|
textGenModel,
|
||||||
updateSettings({ autoOpenPlanSidebar: Boolean(checked) })
|
nextOptions,
|
||||||
}
|
),
|
||||||
aria-label="Open the task panel automatically"
|
},
|
||||||
/>
|
serverProviders,
|
||||||
}
|
),
|
||||||
/>
|
});
|
||||||
|
}}
|
||||||
<SettingsRow
|
/>
|
||||||
title="New threads"
|
</div>
|
||||||
description="Pick the default workspace mode for newly created draft threads."
|
),
|
||||||
resetAction={
|
}}
|
||||||
settings.defaultThreadEnvMode !== DEFAULT_UNIFIED_SETTINGS.defaultThreadEnvMode ? (
|
|
||||||
<SettingResetButton
|
|
||||||
label="new threads"
|
|
||||||
onClick={() =>
|
|
||||||
updateSettings({
|
|
||||||
defaultThreadEnvMode: DEFAULT_UNIFIED_SETTINGS.defaultThreadEnvMode,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
) : null
|
|
||||||
}
|
|
||||||
control={
|
|
||||||
<Select
|
|
||||||
value={settings.defaultThreadEnvMode}
|
|
||||||
onValueChange={(value) => {
|
|
||||||
if (value === "local" || value === "worktree") {
|
|
||||||
updateSettings({ defaultThreadEnvMode: value });
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<SelectTrigger className="w-full sm:w-44" aria-label="Default thread mode">
|
|
||||||
<SelectValue>
|
|
||||||
{settings.defaultThreadEnvMode === "worktree" ? "New worktree" : "Local"}
|
|
||||||
</SelectValue>
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectPopup align="end" alignItemWithTrigger={false}>
|
|
||||||
<SelectItem hideIndicator value="local">
|
|
||||||
Local
|
|
||||||
</SelectItem>
|
|
||||||
<SelectItem hideIndicator value="worktree">
|
|
||||||
New worktree
|
|
||||||
</SelectItem>
|
|
||||||
</SelectPopup>
|
|
||||||
</Select>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<SettingsRow
|
|
||||||
title="Add project starts in"
|
|
||||||
description='Leave empty to use "~/" when the Add Project browser opens.'
|
|
||||||
resetAction={
|
|
||||||
settings.addProjectBaseDirectory !==
|
|
||||||
DEFAULT_UNIFIED_SETTINGS.addProjectBaseDirectory ? (
|
|
||||||
<SettingResetButton
|
|
||||||
label="add project base directory"
|
|
||||||
onClick={() =>
|
|
||||||
updateSettings({
|
|
||||||
addProjectBaseDirectory: DEFAULT_UNIFIED_SETTINGS.addProjectBaseDirectory,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
) : null
|
|
||||||
}
|
|
||||||
control={
|
|
||||||
<DraftInput
|
|
||||||
className="w-full sm:w-72"
|
|
||||||
value={settings.addProjectBaseDirectory}
|
|
||||||
onCommit={(next) => updateSettings({ addProjectBaseDirectory: next })}
|
|
||||||
placeholder="~/"
|
|
||||||
spellCheck={false}
|
|
||||||
aria-label="Add project base directory"
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<SettingsRow
|
|
||||||
title="Archive confirmation"
|
|
||||||
description="Require a second click on the inline archive action before a thread is archived."
|
|
||||||
resetAction={
|
|
||||||
settings.confirmThreadArchive !== DEFAULT_UNIFIED_SETTINGS.confirmThreadArchive ? (
|
|
||||||
<SettingResetButton
|
|
||||||
label="archive confirmation"
|
|
||||||
onClick={() =>
|
|
||||||
updateSettings({
|
|
||||||
confirmThreadArchive: DEFAULT_UNIFIED_SETTINGS.confirmThreadArchive,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
) : null
|
|
||||||
}
|
|
||||||
control={
|
|
||||||
<Switch
|
|
||||||
checked={settings.confirmThreadArchive}
|
|
||||||
onCheckedChange={(checked) =>
|
|
||||||
updateSettings({ confirmThreadArchive: Boolean(checked) })
|
|
||||||
}
|
|
||||||
aria-label="Confirm thread archiving"
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<SettingsRow
|
|
||||||
title="Delete confirmation"
|
|
||||||
description="Ask before deleting a thread and its chat history."
|
|
||||||
resetAction={
|
|
||||||
settings.confirmThreadDelete !== DEFAULT_UNIFIED_SETTINGS.confirmThreadDelete ? (
|
|
||||||
<SettingResetButton
|
|
||||||
label="delete confirmation"
|
|
||||||
onClick={() =>
|
|
||||||
updateSettings({
|
|
||||||
confirmThreadDelete: DEFAULT_UNIFIED_SETTINGS.confirmThreadDelete,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
) : null
|
|
||||||
}
|
|
||||||
control={
|
|
||||||
<Switch
|
|
||||||
checked={settings.confirmThreadDelete}
|
|
||||||
onCheckedChange={(checked) =>
|
|
||||||
updateSettings({ confirmThreadDelete: Boolean(checked) })
|
|
||||||
}
|
|
||||||
aria-label="Confirm thread deletion"
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<SettingsRow
|
|
||||||
title="Text generation model"
|
|
||||||
description="Configure the model used for generated commit messages, PR titles, and similar Git text."
|
|
||||||
resetAction={
|
|
||||||
isGitWritingModelDirty ? (
|
|
||||||
<SettingResetButton
|
|
||||||
label="text generation model"
|
|
||||||
onClick={() =>
|
|
||||||
updateSettings({
|
|
||||||
textGenerationModelSelection:
|
|
||||||
DEFAULT_UNIFIED_SETTINGS.textGenerationModelSelection,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
) : null
|
|
||||||
}
|
|
||||||
control={
|
|
||||||
<div className="flex flex-wrap items-center justify-end gap-1.5">
|
|
||||||
<ProviderModelPicker
|
|
||||||
activeInstanceId={textGenInstanceId}
|
|
||||||
model={textGenModel}
|
|
||||||
lockedProvider={null}
|
|
||||||
instanceEntries={gitModelInstanceEntries}
|
|
||||||
modelOptionsByInstance={gitModelOptionsByInstance}
|
|
||||||
triggerVariant="outline"
|
|
||||||
triggerClassName="min-w-0 max-w-none shrink-0 text-foreground/90 hover:text-foreground"
|
|
||||||
onInstanceModelChange={(instanceId, model) => {
|
|
||||||
updateSettings({
|
|
||||||
textGenerationModelSelection: resolveAppModelSelectionState(
|
|
||||||
{
|
|
||||||
...settings,
|
|
||||||
textGenerationModelSelection: createModelSelection(instanceId, model),
|
|
||||||
},
|
|
||||||
serverProviders,
|
|
||||||
),
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<TraitsPicker
|
|
||||||
provider={textGenProvider}
|
|
||||||
models={
|
|
||||||
// Use the exact instance's models (rather than the
|
|
||||||
// first-kind-match) so a custom text-gen instance like
|
|
||||||
// `codex_personal` gets its own model list, not the
|
|
||||||
// default Codex one.
|
|
||||||
textGenInstanceEntry?.models ?? []
|
|
||||||
}
|
|
||||||
model={textGenModel}
|
|
||||||
prompt=""
|
|
||||||
onPromptChange={() => {}}
|
|
||||||
modelOptions={textGenModelOptions}
|
|
||||||
allowPromptInjectedEffort={false}
|
|
||||||
triggerVariant="outline"
|
|
||||||
triggerClassName="min-w-0 max-w-none shrink-0 text-foreground/90 hover:text-foreground"
|
|
||||||
onModelOptionsChange={(nextOptions) => {
|
|
||||||
updateSettings({
|
|
||||||
textGenerationModelSelection: resolveAppModelSelectionState(
|
|
||||||
{
|
|
||||||
...settings,
|
|
||||||
textGenerationModelSelection: createModelSelection(
|
|
||||||
textGenInstanceId,
|
|
||||||
textGenModel,
|
|
||||||
nextOptions,
|
|
||||||
),
|
|
||||||
},
|
|
||||||
serverProviders,
|
|
||||||
),
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
</SettingsSection>
|
</SettingsSection>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,239 @@
|
|||||||
|
import { Schema } from "effect";
|
||||||
|
import type {
|
||||||
|
SchemaFormAnnotation,
|
||||||
|
SchemaFormControl,
|
||||||
|
SchemaFormSchemaAnnotation,
|
||||||
|
} from "@t3tools/contracts/schemaForm";
|
||||||
|
|
||||||
|
export type SchemaFormSchema = {
|
||||||
|
readonly fields: Readonly<Record<string, Schema.Top>>;
|
||||||
|
} & Schema.Top;
|
||||||
|
|
||||||
|
export interface SchemaFormFieldEntry {
|
||||||
|
readonly key: string;
|
||||||
|
readonly fieldSchema: Schema.Top;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SchemaFormFieldBase {
|
||||||
|
readonly key: string;
|
||||||
|
readonly label: string;
|
||||||
|
readonly description?: string | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SchemaFormSelectOption {
|
||||||
|
readonly value: string;
|
||||||
|
readonly label: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SchemaFormFieldModel<
|
||||||
|
Control extends SchemaFormControl = SchemaFormControl,
|
||||||
|
> extends SchemaFormFieldBase {
|
||||||
|
readonly control: Control;
|
||||||
|
readonly resetLabel: string;
|
||||||
|
readonly ariaLabel?: string | undefined;
|
||||||
|
readonly placeholder?: string | undefined;
|
||||||
|
readonly options?: readonly SchemaFormSelectOption[] | undefined;
|
||||||
|
readonly order: number;
|
||||||
|
readonly clearWhenEmpty: "omit" | "persist";
|
||||||
|
readonly defaultBooleanValue?: boolean | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type InferredSchemaFormControl =
|
||||||
|
| {
|
||||||
|
readonly control: "switch";
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
readonly control: "select";
|
||||||
|
readonly literalValues: readonly string[];
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
readonly control: "text";
|
||||||
|
};
|
||||||
|
|
||||||
|
export function titleizeSchemaFieldKey(key: string): string {
|
||||||
|
return key
|
||||||
|
.replace(/([a-z0-9])([A-Z])/g, "$1 $2")
|
||||||
|
.replace(/[-_]+/g, " ")
|
||||||
|
.replace(/^./, (char) => char.toUpperCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
export function readSchemaAnnotations(schema: Schema.Top) {
|
||||||
|
return Schema.resolveAnnotationsKey(schema) ?? Schema.resolveAnnotations(schema);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function readSchemaAnnotation<Annotation>(schema: Schema.Top, key: string) {
|
||||||
|
return readSchemaAnnotations(schema)?.[key] as Annotation | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function readSchemaAnnotationString(
|
||||||
|
schema: Schema.Top,
|
||||||
|
key: "title" | "description",
|
||||||
|
): string | undefined {
|
||||||
|
const value = readSchemaAnnotations(schema)?.[key];
|
||||||
|
return typeof value === "string" ? value : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function makeSchemaFormFieldBase(key: string, fieldSchema: Schema.Top): SchemaFormFieldBase {
|
||||||
|
const label = readSchemaAnnotationString(fieldSchema, "title") ?? titleizeSchemaFieldKey(key);
|
||||||
|
const description = readSchemaAnnotationString(fieldSchema, "description");
|
||||||
|
return {
|
||||||
|
key,
|
||||||
|
label,
|
||||||
|
...(description !== undefined ? { description } : {}),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function readSchemaFieldBooleanDefault(fieldSchema: Schema.Top): boolean | undefined {
|
||||||
|
try {
|
||||||
|
const decoded = Schema.decodeUnknownSync(fieldSchema as Schema.Decoder<unknown>)(undefined);
|
||||||
|
return typeof decoded === "boolean" ? decoded : undefined;
|
||||||
|
} catch {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function inferSchemaFormControl(fieldSchema: Schema.Top): InferredSchemaFormControl | null {
|
||||||
|
const ast = fieldSchema.ast;
|
||||||
|
|
||||||
|
if (ast._tag === "Boolean") {
|
||||||
|
return { control: "switch" };
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ast._tag === "String") {
|
||||||
|
return { control: "text" };
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ast._tag === "Union") {
|
||||||
|
const literalValues = ast.types.flatMap((type) => {
|
||||||
|
if (type._tag !== "Literal" || typeof type.literal !== "string") return [];
|
||||||
|
return [type.literal];
|
||||||
|
});
|
||||||
|
return literalValues.length === ast.types.length ? { control: "select", literalValues } : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function orderedSchemaFieldEntries(
|
||||||
|
schema: SchemaFormSchema,
|
||||||
|
orderedKeys: readonly string[] = [],
|
||||||
|
): ReadonlyArray<SchemaFormFieldEntry> {
|
||||||
|
const orderIndexes = new Map(orderedKeys.map((key, index) => [key, index] as const));
|
||||||
|
const orderFallbackOffset = orderIndexes.size;
|
||||||
|
|
||||||
|
return Object.keys(schema.fields)
|
||||||
|
.map((key, index) => ({ key, index }))
|
||||||
|
.toSorted((left, right) => {
|
||||||
|
return (
|
||||||
|
(orderIndexes.get(left.key) ?? orderFallbackOffset + left.index) -
|
||||||
|
(orderIndexes.get(right.key) ?? orderFallbackOffset + right.index)
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.map(({ key }) => ({
|
||||||
|
key,
|
||||||
|
fieldSchema: schema.fields[key]!,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
function readSchemaFormSchemaAnnotation(schema: SchemaFormSchema): SchemaFormSchemaAnnotation {
|
||||||
|
return readSchemaAnnotation<SchemaFormSchemaAnnotation>(schema, "schemaFormSchema") ?? {};
|
||||||
|
}
|
||||||
|
|
||||||
|
function isAllowedSchemaFormControl<Control extends SchemaFormControl>(
|
||||||
|
control: SchemaFormControl,
|
||||||
|
allowedControls: readonly Control[],
|
||||||
|
): control is Control {
|
||||||
|
return allowedControls.includes(control as Control);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface DeriveSchemaFormFieldsOptions<Control extends SchemaFormControl> {
|
||||||
|
readonly schemas: readonly SchemaFormSchema[];
|
||||||
|
readonly allowedControls: readonly Control[];
|
||||||
|
readonly includeUnannotatedFields: boolean;
|
||||||
|
readonly sortByFormOrder?: boolean | undefined;
|
||||||
|
readonly defaultControl?:
|
||||||
|
| Control
|
||||||
|
| ((input: {
|
||||||
|
readonly key: string;
|
||||||
|
readonly fieldSchema: Schema.Top;
|
||||||
|
readonly inferredControl: InferredSchemaFormControl | null;
|
||||||
|
readonly annotation: SchemaFormAnnotation | undefined;
|
||||||
|
}) => Control | undefined)
|
||||||
|
| undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolveDefaultSchemaFormControl<Control extends SchemaFormControl>(
|
||||||
|
options: DeriveSchemaFormFieldsOptions<Control>,
|
||||||
|
input: {
|
||||||
|
readonly key: string;
|
||||||
|
readonly fieldSchema: Schema.Top;
|
||||||
|
readonly inferredControl: InferredSchemaFormControl | null;
|
||||||
|
readonly annotation: SchemaFormAnnotation | undefined;
|
||||||
|
},
|
||||||
|
): Control | undefined {
|
||||||
|
if (typeof options.defaultControl === "function") {
|
||||||
|
return options.defaultControl(input);
|
||||||
|
}
|
||||||
|
return options.defaultControl;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function deriveSchemaFormFields<Control extends SchemaFormControl>({
|
||||||
|
schemas,
|
||||||
|
allowedControls,
|
||||||
|
includeUnannotatedFields,
|
||||||
|
sortByFormOrder,
|
||||||
|
defaultControl,
|
||||||
|
}: DeriveSchemaFormFieldsOptions<Control>): ReadonlyArray<SchemaFormFieldModel<Control>> {
|
||||||
|
const fields = schemas.flatMap((schema) => {
|
||||||
|
const schemaAnnotation = readSchemaFormSchemaAnnotation(schema);
|
||||||
|
|
||||||
|
return orderedSchemaFieldEntries(schema, schemaAnnotation.order).flatMap(
|
||||||
|
({ key, fieldSchema }) => {
|
||||||
|
const annotation = readSchemaAnnotation<SchemaFormAnnotation>(fieldSchema, "schemaForm");
|
||||||
|
if (annotation?.hidden) return [];
|
||||||
|
if (annotation === undefined && !includeUnannotatedFields) return [];
|
||||||
|
|
||||||
|
const baseField = makeSchemaFormFieldBase(key, fieldSchema);
|
||||||
|
const inferredControl = inferSchemaFormControl(fieldSchema);
|
||||||
|
const control =
|
||||||
|
annotation?.control ??
|
||||||
|
resolveDefaultSchemaFormControl(
|
||||||
|
{ schemas, allowedControls, includeUnannotatedFields, sortByFormOrder, defaultControl },
|
||||||
|
{ key, fieldSchema, inferredControl, annotation },
|
||||||
|
) ??
|
||||||
|
inferredControl?.control;
|
||||||
|
if (control === undefined || !isAllowedSchemaFormControl(control, allowedControls)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
const selectOptions =
|
||||||
|
control === "select" && inferredControl?.control === "select"
|
||||||
|
? inferredControl.literalValues.map((value) => ({
|
||||||
|
value,
|
||||||
|
label: annotation?.optionLabels?.[value] ?? value,
|
||||||
|
}))
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
...baseField,
|
||||||
|
control,
|
||||||
|
resetLabel: annotation?.resetLabel ?? baseField.label.toLowerCase(),
|
||||||
|
...(annotation?.ariaLabel !== undefined ? { ariaLabel: annotation.ariaLabel } : {}),
|
||||||
|
...(annotation?.placeholder !== undefined
|
||||||
|
? { placeholder: annotation.placeholder }
|
||||||
|
: {}),
|
||||||
|
...(selectOptions !== undefined ? { options: selectOptions } : {}),
|
||||||
|
order: annotation?.order ?? Number.MAX_SAFE_INTEGER,
|
||||||
|
clearWhenEmpty: annotation?.clearWhenEmpty ?? "omit",
|
||||||
|
...(control === "switch"
|
||||||
|
? { defaultBooleanValue: readSchemaFieldBooleanDefault(fieldSchema) }
|
||||||
|
: {}),
|
||||||
|
} satisfies SchemaFormFieldModel<Control>,
|
||||||
|
];
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
return sortByFormOrder ? fields.toSorted((left, right) => left.order - right.order) : fields;
|
||||||
|
}
|
||||||
@@ -10,6 +10,11 @@
|
|||||||
"module": "./dist/index.mjs",
|
"module": "./dist/index.mjs",
|
||||||
"types": "./src/index.ts",
|
"types": "./src/index.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
|
"./schemaForm": {
|
||||||
|
"types": "./src/schemaForm.ts",
|
||||||
|
"import": "./src/schemaForm.ts",
|
||||||
|
"require": "./src/schemaForm.ts"
|
||||||
|
},
|
||||||
"./settings": {
|
"./settings": {
|
||||||
"types": "./src/settings.ts",
|
"types": "./src/settings.ts",
|
||||||
"import": "./src/settings.ts",
|
"import": "./src/settings.ts",
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ export * from "./providerRuntime.ts";
|
|||||||
export * from "./model.ts";
|
export * from "./model.ts";
|
||||||
export * from "./keybindings.ts";
|
export * from "./keybindings.ts";
|
||||||
export * from "./server.ts";
|
export * from "./server.ts";
|
||||||
|
export * from "./schemaForm.ts";
|
||||||
export * from "./settings.ts";
|
export * from "./settings.ts";
|
||||||
export * from "./git.ts";
|
export * from "./git.ts";
|
||||||
export * from "./vcs.ts";
|
export * from "./vcs.ts";
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
import * as Schema from "effect/Schema";
|
||||||
|
|
||||||
|
export type SchemaFormControl =
|
||||||
|
| "select"
|
||||||
|
| "switch"
|
||||||
|
| "text"
|
||||||
|
| "password"
|
||||||
|
| "textarea"
|
||||||
|
| "textGenerationModelSelection";
|
||||||
|
|
||||||
|
export type SchemaFormOptionLabels<Value extends string> = {
|
||||||
|
readonly [Key in Value]: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface SchemaFormAnnotation {
|
||||||
|
readonly control?: SchemaFormControl | undefined;
|
||||||
|
readonly order?: number | undefined;
|
||||||
|
readonly resetLabel?: string | undefined;
|
||||||
|
readonly ariaLabel?: string | undefined;
|
||||||
|
readonly placeholder?: string | undefined;
|
||||||
|
readonly optionLabels?: Readonly<Record<string, string>> | undefined;
|
||||||
|
readonly hidden?: boolean | undefined;
|
||||||
|
readonly clearWhenEmpty?: "omit" | "persist" | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SchemaFormSchemaAnnotation {
|
||||||
|
readonly order?: readonly string[] | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function schemaFormOptionLabels<const Literals extends readonly string[]>(
|
||||||
|
_schema: Schema.Literals<Literals>,
|
||||||
|
labels: SchemaFormOptionLabels<Literals[number]>,
|
||||||
|
): SchemaFormOptionLabels<Literals[number]> {
|
||||||
|
return labels;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module "effect/Schema" {
|
||||||
|
namespace Annotations {
|
||||||
|
interface Annotations {
|
||||||
|
readonly schemaForm?: SchemaFormAnnotation | undefined;
|
||||||
|
readonly schemaFormSchema?: SchemaFormSchemaAnnotation | undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import { TrimmedNonEmptyString, TrimmedString } from "./baseSchemas.ts";
|
|||||||
import { DEFAULT_GIT_TEXT_GENERATION_MODEL, ProviderOptionSelections } from "./model.ts";
|
import { DEFAULT_GIT_TEXT_GENERATION_MODEL, ProviderOptionSelections } from "./model.ts";
|
||||||
import { ModelSelection } from "./orchestration.ts";
|
import { ModelSelection } from "./orchestration.ts";
|
||||||
import { ProviderInstanceConfig, ProviderInstanceId } from "./providerInstance.ts";
|
import { ProviderInstanceConfig, ProviderInstanceId } from "./providerInstance.ts";
|
||||||
|
import { schemaFormOptionLabels } from "./schemaForm.ts";
|
||||||
|
|
||||||
// ── Client Settings (local-only) ───────────────────────────────
|
// ── Client Settings (local-only) ───────────────────────────────
|
||||||
|
|
||||||
@@ -29,11 +30,67 @@ export type SidebarProjectGroupingMode = typeof SidebarProjectGroupingMode.Type;
|
|||||||
export const DEFAULT_SIDEBAR_PROJECT_GROUPING_MODE: SidebarProjectGroupingMode = "repository";
|
export const DEFAULT_SIDEBAR_PROJECT_GROUPING_MODE: SidebarProjectGroupingMode = "repository";
|
||||||
|
|
||||||
export const ClientSettingsSchema = Schema.Struct({
|
export const ClientSettingsSchema = Schema.Struct({
|
||||||
autoOpenPlanSidebar: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
|
autoOpenPlanSidebar: Schema.Boolean.pipe(
|
||||||
confirmThreadArchive: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
|
Schema.withDecodingDefault(Effect.succeed(true)),
|
||||||
confirmThreadDelete: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
|
Schema.annotateKey({
|
||||||
diffIgnoreWhitespace: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
|
title: "Auto-open task panel",
|
||||||
diffWordWrap: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
|
description: "Open the right-side plan and task panel automatically when steps appear.",
|
||||||
|
schemaForm: {
|
||||||
|
order: 50,
|
||||||
|
resetLabel: "auto-open task panel",
|
||||||
|
ariaLabel: "Open the task panel automatically",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
confirmThreadArchive: Schema.Boolean.pipe(
|
||||||
|
Schema.withDecodingDefault(Effect.succeed(false)),
|
||||||
|
Schema.annotateKey({
|
||||||
|
title: "Archive confirmation",
|
||||||
|
description:
|
||||||
|
"Require a second click on the inline archive action before a thread is archived.",
|
||||||
|
schemaForm: {
|
||||||
|
order: 80,
|
||||||
|
resetLabel: "archive confirmation",
|
||||||
|
ariaLabel: "Confirm thread archiving",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
confirmThreadDelete: Schema.Boolean.pipe(
|
||||||
|
Schema.withDecodingDefault(Effect.succeed(true)),
|
||||||
|
Schema.annotateKey({
|
||||||
|
title: "Delete confirmation",
|
||||||
|
description: "Ask before deleting a thread and its chat history.",
|
||||||
|
schemaForm: {
|
||||||
|
order: 90,
|
||||||
|
resetLabel: "delete confirmation",
|
||||||
|
ariaLabel: "Confirm thread deletion",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
diffIgnoreWhitespace: Schema.Boolean.pipe(
|
||||||
|
Schema.withDecodingDefault(Effect.succeed(true)),
|
||||||
|
Schema.annotateKey({
|
||||||
|
title: "Hide whitespace changes",
|
||||||
|
description: "Set whether the diff panel ignores whitespace-only edits by default.",
|
||||||
|
schemaForm: {
|
||||||
|
order: 30,
|
||||||
|
resetLabel: "diff whitespace changes",
|
||||||
|
ariaLabel: "Hide whitespace changes by default",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
diffWordWrap: Schema.Boolean.pipe(
|
||||||
|
Schema.withDecodingDefault(Effect.succeed(false)),
|
||||||
|
Schema.annotateKey({
|
||||||
|
title: "Diff line wrapping",
|
||||||
|
description: "Set the default wrap state when the diff panel opens.",
|
||||||
|
schemaForm: {
|
||||||
|
order: 20,
|
||||||
|
resetLabel: "diff line wrapping",
|
||||||
|
ariaLabel: "Wrap diff lines by default",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
),
|
||||||
// Model favorites. Historically keyed by provider kind, now
|
// Model favorites. Historically keyed by provider kind, now
|
||||||
// widened to `ProviderInstanceId` so users can favorite a specific model
|
// widened to `ProviderInstanceId` so users can favorite a specific model
|
||||||
// on a custom provider instance (e.g. "Codex Personal · gpt-5") without
|
// on a custom provider instance (e.g. "Codex Personal · gpt-5") without
|
||||||
@@ -74,6 +131,20 @@ export const ClientSettingsSchema = Schema.Struct({
|
|||||||
),
|
),
|
||||||
timestampFormat: TimestampFormat.pipe(
|
timestampFormat: TimestampFormat.pipe(
|
||||||
Schema.withDecodingDefault(Effect.succeed(DEFAULT_TIMESTAMP_FORMAT)),
|
Schema.withDecodingDefault(Effect.succeed(DEFAULT_TIMESTAMP_FORMAT)),
|
||||||
|
Schema.annotateKey({
|
||||||
|
title: "Time format",
|
||||||
|
description: "System default follows your browser or OS clock preference.",
|
||||||
|
schemaForm: {
|
||||||
|
order: 10,
|
||||||
|
resetLabel: "time format",
|
||||||
|
ariaLabel: "Timestamp format",
|
||||||
|
optionLabels: schemaFormOptionLabels(TimestampFormat, {
|
||||||
|
locale: "System default",
|
||||||
|
"12-hour": "12-hour",
|
||||||
|
"24-hour": "24-hour",
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
}),
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
export type ClientSettings = typeof ClientSettingsSchema.Type;
|
export type ClientSettings = typeof ClientSettingsSchema.Type;
|
||||||
@@ -97,28 +168,6 @@ const makeBinaryPathSetting = (fallback: string) =>
|
|||||||
Schema.withDecodingDefault(Effect.succeed(fallback)),
|
Schema.withDecodingDefault(Effect.succeed(fallback)),
|
||||||
);
|
);
|
||||||
|
|
||||||
export type ProviderSettingsFormControl = "text" | "password" | "textarea" | "switch";
|
|
||||||
|
|
||||||
export interface ProviderSettingsFormAnnotation {
|
|
||||||
readonly control?: ProviderSettingsFormControl | undefined;
|
|
||||||
readonly placeholder?: string | undefined;
|
|
||||||
readonly hidden?: boolean | undefined;
|
|
||||||
readonly clearWhenEmpty?: "omit" | "persist" | undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ProviderSettingsFormSchemaAnnotation {
|
|
||||||
readonly order?: readonly string[] | undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
declare module "effect/Schema" {
|
|
||||||
namespace Annotations {
|
|
||||||
interface Annotations {
|
|
||||||
readonly providerSettingsForm?: ProviderSettingsFormAnnotation | undefined;
|
|
||||||
readonly providerSettingsFormSchema?: ProviderSettingsFormSchemaAnnotation | undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export type ProviderSettingsOrder<Fields extends Schema.Struct.Fields> = readonly Extract<
|
export type ProviderSettingsOrder<Fields extends Schema.Struct.Fields> = readonly Extract<
|
||||||
keyof Fields,
|
keyof Fields,
|
||||||
string
|
string
|
||||||
@@ -132,8 +181,7 @@ export function makeProviderSettingsSchema<const Fields extends Schema.Struct.Fi
|
|||||||
): Schema.Struct<Fields> {
|
): Schema.Struct<Fields> {
|
||||||
return Schema.Struct(fields).pipe(
|
return Schema.Struct(fields).pipe(
|
||||||
Schema.annotate({
|
Schema.annotate({
|
||||||
providerSettingsFormSchema:
|
schemaFormSchema: options?.order === undefined ? undefined : { order: options.order },
|
||||||
options?.order === undefined ? undefined : { order: options.order },
|
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -142,13 +190,13 @@ export const CodexSettings = makeProviderSettingsSchema(
|
|||||||
{
|
{
|
||||||
enabled: Schema.Boolean.pipe(
|
enabled: Schema.Boolean.pipe(
|
||||||
Schema.withDecodingDefault(Effect.succeed(true)),
|
Schema.withDecodingDefault(Effect.succeed(true)),
|
||||||
Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
|
Schema.annotateKey({ schemaForm: { hidden: true } }),
|
||||||
),
|
),
|
||||||
binaryPath: makeBinaryPathSetting("codex").pipe(
|
binaryPath: makeBinaryPathSetting("codex").pipe(
|
||||||
Schema.annotateKey({
|
Schema.annotateKey({
|
||||||
title: "Binary path",
|
title: "Binary path",
|
||||||
description: "Path to the Codex binary used by this instance.",
|
description: "Path to the Codex binary used by this instance.",
|
||||||
providerSettingsForm: { placeholder: "codex", clearWhenEmpty: "omit" },
|
schemaForm: { placeholder: "codex", clearWhenEmpty: "omit" },
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
homePath: TrimmedString.pipe(
|
homePath: TrimmedString.pipe(
|
||||||
@@ -156,7 +204,7 @@ export const CodexSettings = makeProviderSettingsSchema(
|
|||||||
Schema.annotateKey({
|
Schema.annotateKey({
|
||||||
title: "CODEX_HOME path",
|
title: "CODEX_HOME path",
|
||||||
description: "Custom Codex home and config directory.",
|
description: "Custom Codex home and config directory.",
|
||||||
providerSettingsForm: {
|
schemaForm: {
|
||||||
placeholder: "~/.codex",
|
placeholder: "~/.codex",
|
||||||
clearWhenEmpty: "omit",
|
clearWhenEmpty: "omit",
|
||||||
},
|
},
|
||||||
@@ -168,7 +216,7 @@ export const CodexSettings = makeProviderSettingsSchema(
|
|||||||
title: "Shadow home path",
|
title: "Shadow home path",
|
||||||
description:
|
description:
|
||||||
"Account-specific Codex home. Keeps auth.json separate while sharing state from CODEX_HOME.",
|
"Account-specific Codex home. Keeps auth.json separate while sharing state from CODEX_HOME.",
|
||||||
providerSettingsForm: {
|
schemaForm: {
|
||||||
placeholder: "~/.codex-t3/personal",
|
placeholder: "~/.codex-t3/personal",
|
||||||
clearWhenEmpty: "omit",
|
clearWhenEmpty: "omit",
|
||||||
},
|
},
|
||||||
@@ -176,7 +224,7 @@ export const CodexSettings = makeProviderSettingsSchema(
|
|||||||
),
|
),
|
||||||
customModels: Schema.Array(Schema.String).pipe(
|
customModels: Schema.Array(Schema.String).pipe(
|
||||||
Schema.withDecodingDefault(Effect.succeed([])),
|
Schema.withDecodingDefault(Effect.succeed([])),
|
||||||
Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
|
Schema.annotateKey({ schemaForm: { hidden: true } }),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -189,13 +237,13 @@ export const ClaudeSettings = makeProviderSettingsSchema(
|
|||||||
{
|
{
|
||||||
enabled: Schema.Boolean.pipe(
|
enabled: Schema.Boolean.pipe(
|
||||||
Schema.withDecodingDefault(Effect.succeed(true)),
|
Schema.withDecodingDefault(Effect.succeed(true)),
|
||||||
Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
|
Schema.annotateKey({ schemaForm: { hidden: true } }),
|
||||||
),
|
),
|
||||||
binaryPath: makeBinaryPathSetting("claude").pipe(
|
binaryPath: makeBinaryPathSetting("claude").pipe(
|
||||||
Schema.annotateKey({
|
Schema.annotateKey({
|
||||||
title: "Binary path",
|
title: "Binary path",
|
||||||
description: "Path to the Claude binary used by this instance.",
|
description: "Path to the Claude binary used by this instance.",
|
||||||
providerSettingsForm: { placeholder: "claude", clearWhenEmpty: "omit" },
|
schemaForm: { placeholder: "claude", clearWhenEmpty: "omit" },
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
homePath: TrimmedString.pipe(
|
homePath: TrimmedString.pipe(
|
||||||
@@ -204,19 +252,19 @@ export const ClaudeSettings = makeProviderSettingsSchema(
|
|||||||
title: "Claude HOME path",
|
title: "Claude HOME path",
|
||||||
description:
|
description:
|
||||||
"Custom HOME used when running this Claude instance. Keeps .claude.json and .claude separate.",
|
"Custom HOME used when running this Claude instance. Keeps .claude.json and .claude separate.",
|
||||||
providerSettingsForm: { placeholder: "~", clearWhenEmpty: "omit" },
|
schemaForm: { placeholder: "~", clearWhenEmpty: "omit" },
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
customModels: Schema.Array(Schema.String).pipe(
|
customModels: Schema.Array(Schema.String).pipe(
|
||||||
Schema.withDecodingDefault(Effect.succeed([])),
|
Schema.withDecodingDefault(Effect.succeed([])),
|
||||||
Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
|
Schema.annotateKey({ schemaForm: { hidden: true } }),
|
||||||
),
|
),
|
||||||
launchArgs: Schema.String.pipe(
|
launchArgs: Schema.String.pipe(
|
||||||
Schema.withDecodingDefault(Effect.succeed("")),
|
Schema.withDecodingDefault(Effect.succeed("")),
|
||||||
Schema.annotateKey({
|
Schema.annotateKey({
|
||||||
title: "Launch arguments",
|
title: "Launch arguments",
|
||||||
description: "Additional CLI arguments passed on session start.",
|
description: "Additional CLI arguments passed on session start.",
|
||||||
providerSettingsForm: {
|
schemaForm: {
|
||||||
placeholder: "e.g. --chrome",
|
placeholder: "e.g. --chrome",
|
||||||
clearWhenEmpty: "omit",
|
clearWhenEmpty: "omit",
|
||||||
},
|
},
|
||||||
@@ -233,13 +281,13 @@ export const CursorSettings = makeProviderSettingsSchema(
|
|||||||
{
|
{
|
||||||
enabled: Schema.Boolean.pipe(
|
enabled: Schema.Boolean.pipe(
|
||||||
Schema.withDecodingDefault(Effect.succeed(false)),
|
Schema.withDecodingDefault(Effect.succeed(false)),
|
||||||
Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
|
Schema.annotateKey({ schemaForm: { hidden: true } }),
|
||||||
),
|
),
|
||||||
binaryPath: makeBinaryPathSetting("agent").pipe(
|
binaryPath: makeBinaryPathSetting("agent").pipe(
|
||||||
Schema.annotateKey({
|
Schema.annotateKey({
|
||||||
title: "Binary path",
|
title: "Binary path",
|
||||||
description: "Path to the Cursor agent binary.",
|
description: "Path to the Cursor agent binary.",
|
||||||
providerSettingsForm: { placeholder: "agent", clearWhenEmpty: "omit" },
|
schemaForm: { placeholder: "agent", clearWhenEmpty: "omit" },
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
apiEndpoint: TrimmedString.pipe(
|
apiEndpoint: TrimmedString.pipe(
|
||||||
@@ -247,7 +295,7 @@ export const CursorSettings = makeProviderSettingsSchema(
|
|||||||
Schema.annotateKey({
|
Schema.annotateKey({
|
||||||
title: "API endpoint",
|
title: "API endpoint",
|
||||||
description: "Override the Cursor API endpoint for this instance.",
|
description: "Override the Cursor API endpoint for this instance.",
|
||||||
providerSettingsForm: {
|
schemaForm: {
|
||||||
placeholder: "https://...",
|
placeholder: "https://...",
|
||||||
clearWhenEmpty: "omit",
|
clearWhenEmpty: "omit",
|
||||||
},
|
},
|
||||||
@@ -255,7 +303,7 @@ export const CursorSettings = makeProviderSettingsSchema(
|
|||||||
),
|
),
|
||||||
customModels: Schema.Array(Schema.String).pipe(
|
customModels: Schema.Array(Schema.String).pipe(
|
||||||
Schema.withDecodingDefault(Effect.succeed([])),
|
Schema.withDecodingDefault(Effect.succeed([])),
|
||||||
Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
|
Schema.annotateKey({ schemaForm: { hidden: true } }),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -267,13 +315,13 @@ export const OpenCodeSettings = makeProviderSettingsSchema(
|
|||||||
{
|
{
|
||||||
enabled: Schema.Boolean.pipe(
|
enabled: Schema.Boolean.pipe(
|
||||||
Schema.withDecodingDefault(Effect.succeed(true)),
|
Schema.withDecodingDefault(Effect.succeed(true)),
|
||||||
Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
|
Schema.annotateKey({ schemaForm: { hidden: true } }),
|
||||||
),
|
),
|
||||||
binaryPath: makeBinaryPathSetting("opencode").pipe(
|
binaryPath: makeBinaryPathSetting("opencode").pipe(
|
||||||
Schema.annotateKey({
|
Schema.annotateKey({
|
||||||
title: "Binary path",
|
title: "Binary path",
|
||||||
description: "Path to the OpenCode binary.",
|
description: "Path to the OpenCode binary.",
|
||||||
providerSettingsForm: {
|
schemaForm: {
|
||||||
placeholder: "opencode",
|
placeholder: "opencode",
|
||||||
clearWhenEmpty: "omit",
|
clearWhenEmpty: "omit",
|
||||||
},
|
},
|
||||||
@@ -284,7 +332,7 @@ export const OpenCodeSettings = makeProviderSettingsSchema(
|
|||||||
Schema.annotateKey({
|
Schema.annotateKey({
|
||||||
title: "Server URL",
|
title: "Server URL",
|
||||||
description: "Leave blank to let T3 Code spawn the server when needed.",
|
description: "Leave blank to let T3 Code spawn the server when needed.",
|
||||||
providerSettingsForm: {
|
schemaForm: {
|
||||||
placeholder: "http://127.0.0.1:4096",
|
placeholder: "http://127.0.0.1:4096",
|
||||||
clearWhenEmpty: "omit",
|
clearWhenEmpty: "omit",
|
||||||
},
|
},
|
||||||
@@ -295,7 +343,7 @@ export const OpenCodeSettings = makeProviderSettingsSchema(
|
|||||||
Schema.annotateKey({
|
Schema.annotateKey({
|
||||||
title: "Server password",
|
title: "Server password",
|
||||||
description: "Stored in plain text on disk.",
|
description: "Stored in plain text on disk.",
|
||||||
providerSettingsForm: {
|
schemaForm: {
|
||||||
control: "password",
|
control: "password",
|
||||||
placeholder: "Optional",
|
placeholder: "Optional",
|
||||||
clearWhenEmpty: "omit",
|
clearWhenEmpty: "omit",
|
||||||
@@ -304,7 +352,7 @@ export const OpenCodeSettings = makeProviderSettingsSchema(
|
|||||||
),
|
),
|
||||||
customModels: Schema.Array(Schema.String).pipe(
|
customModels: Schema.Array(Schema.String).pipe(
|
||||||
Schema.withDecodingDefault(Effect.succeed([])),
|
Schema.withDecodingDefault(Effect.succeed([])),
|
||||||
Schema.annotateKey({ providerSettingsForm: { hidden: true } }),
|
Schema.annotateKey({ schemaForm: { hidden: true } }),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -320,11 +368,47 @@ export const ObservabilitySettings = Schema.Struct({
|
|||||||
export type ObservabilitySettings = typeof ObservabilitySettings.Type;
|
export type ObservabilitySettings = typeof ObservabilitySettings.Type;
|
||||||
|
|
||||||
export const ServerSettings = Schema.Struct({
|
export const ServerSettings = Schema.Struct({
|
||||||
enableAssistantStreaming: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
|
enableAssistantStreaming: Schema.Boolean.pipe(
|
||||||
|
Schema.withDecodingDefault(Effect.succeed(false)),
|
||||||
|
Schema.annotateKey({
|
||||||
|
title: "Assistant output",
|
||||||
|
description: "Show token-by-token output while a response is in progress.",
|
||||||
|
schemaForm: {
|
||||||
|
order: 40,
|
||||||
|
resetLabel: "assistant output",
|
||||||
|
ariaLabel: "Stream assistant messages",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
),
|
||||||
defaultThreadEnvMode: ThreadEnvMode.pipe(
|
defaultThreadEnvMode: ThreadEnvMode.pipe(
|
||||||
Schema.withDecodingDefault(Effect.succeed("local" as const satisfies ThreadEnvMode)),
|
Schema.withDecodingDefault(Effect.succeed("local" as const satisfies ThreadEnvMode)),
|
||||||
|
Schema.annotateKey({
|
||||||
|
title: "New threads",
|
||||||
|
description: "Pick the default workspace mode for newly created draft threads.",
|
||||||
|
schemaForm: {
|
||||||
|
order: 60,
|
||||||
|
resetLabel: "new threads",
|
||||||
|
ariaLabel: "Default thread mode",
|
||||||
|
optionLabels: schemaFormOptionLabels(ThreadEnvMode, {
|
||||||
|
local: "Local",
|
||||||
|
worktree: "New worktree",
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
addProjectBaseDirectory: TrimmedString.pipe(
|
||||||
|
Schema.withDecodingDefault(Effect.succeed("")),
|
||||||
|
Schema.annotateKey({
|
||||||
|
title: "Add project starts in",
|
||||||
|
description: 'Leave empty to use "~/" when the Add Project browser opens.',
|
||||||
|
schemaForm: {
|
||||||
|
order: 70,
|
||||||
|
resetLabel: "add project base directory",
|
||||||
|
ariaLabel: "Add project base directory",
|
||||||
|
placeholder: "~/",
|
||||||
|
},
|
||||||
|
}),
|
||||||
),
|
),
|
||||||
addProjectBaseDirectory: TrimmedString.pipe(Schema.withDecodingDefault(Effect.succeed(""))),
|
|
||||||
textGenerationModelSelection: ModelSelection.pipe(
|
textGenerationModelSelection: ModelSelection.pipe(
|
||||||
Schema.withDecodingDefault(
|
Schema.withDecodingDefault(
|
||||||
Effect.succeed({
|
Effect.succeed({
|
||||||
@@ -332,6 +416,16 @@ export const ServerSettings = Schema.Struct({
|
|||||||
model: DEFAULT_GIT_TEXT_GENERATION_MODEL,
|
model: DEFAULT_GIT_TEXT_GENERATION_MODEL,
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
|
Schema.annotateKey({
|
||||||
|
title: "Text generation model",
|
||||||
|
description:
|
||||||
|
"Configure the model used for generated commit messages, PR titles, and similar Git text.",
|
||||||
|
schemaForm: {
|
||||||
|
control: "textGenerationModelSelection",
|
||||||
|
order: 100,
|
||||||
|
resetLabel: "text generation model",
|
||||||
|
},
|
||||||
|
}),
|
||||||
),
|
),
|
||||||
|
|
||||||
// Legacy single-instance-per-driver settings. Continues to be the source
|
// Legacy single-instance-per-driver settings. Continues to be the source
|
||||||
|
|||||||
Reference in new issue
Block a user