Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e0a2f75d74 | ||
|
|
1ea8881b31 | ||
|
|
4f0f24f055 | ||
|
|
d1e85c4e8f |
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@t3tools/desktop",
|
||||
"version": "0.0.23",
|
||||
"version": "0.0.24",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "dist-electron/main.cjs",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "t3",
|
||||
"version": "0.0.23",
|
||||
"version": "0.0.24",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@t3tools/web",
|
||||
"version": "0.0.23",
|
||||
"version": "0.0.24",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
||||
@@ -727,9 +727,16 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
model: selectedModel,
|
||||
models: selectedProviderModels,
|
||||
prompt,
|
||||
modelOptions: composerModelOptions?.[selectedProvider],
|
||||
modelOptions: composerModelOptions?.[selectedInstanceId],
|
||||
}),
|
||||
[composerModelOptions, prompt, selectedModel, selectedProvider, selectedProviderModels],
|
||||
[
|
||||
composerModelOptions,
|
||||
prompt,
|
||||
selectedInstanceId,
|
||||
selectedModel,
|
||||
selectedProvider,
|
||||
selectedProviderModels,
|
||||
],
|
||||
);
|
||||
|
||||
const selectedPromptEffort = composerProviderState.promptEffort;
|
||||
@@ -1018,21 +1025,23 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
|
||||
|
||||
const providerTraitsMenuContent = renderProviderTraitsMenuContent({
|
||||
provider: selectedProvider,
|
||||
instanceId: selectedInstanceId,
|
||||
...(routeKind === "server" ? { threadRef: routeThreadRef } : {}),
|
||||
...(routeKind === "draft" && draftId ? { draftId } : {}),
|
||||
model: selectedModel,
|
||||
models: selectedProviderModels,
|
||||
modelOptions: composerModelOptions?.[selectedProvider],
|
||||
modelOptions: composerModelOptions?.[selectedInstanceId],
|
||||
prompt,
|
||||
onPromptChange: setPromptFromTraits,
|
||||
});
|
||||
const providerTraitsPicker = renderProviderTraitsPicker({
|
||||
provider: selectedProvider,
|
||||
instanceId: selectedInstanceId,
|
||||
...(routeKind === "server" ? { threadRef: routeThreadRef } : {}),
|
||||
...(routeKind === "draft" && draftId ? { draftId } : {}),
|
||||
model: selectedModel,
|
||||
models: selectedProviderModels,
|
||||
modelOptions: composerModelOptions?.[selectedProvider],
|
||||
modelOptions: composerModelOptions?.[selectedInstanceId],
|
||||
prompt,
|
||||
onPromptChange: setPromptFromTraits,
|
||||
});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
type ProviderDriverKind,
|
||||
type ProviderInstanceId,
|
||||
type ProviderOptionDescriptor,
|
||||
type ProviderOptionSelection,
|
||||
type ScopedThreadRef,
|
||||
@@ -196,6 +197,7 @@ export function shouldRenderTraitsControls(input: {
|
||||
|
||||
export interface TraitsMenuContentProps {
|
||||
provider: ProviderDriverKind;
|
||||
instanceId?: ProviderInstanceId;
|
||||
models: ReadonlyArray<ServerProviderModel>;
|
||||
model: string | null | undefined;
|
||||
prompt: string;
|
||||
@@ -208,6 +210,7 @@ export interface TraitsMenuContentProps {
|
||||
|
||||
export const TraitsMenuContent = memo(function TraitsMenuContentImpl({
|
||||
provider,
|
||||
instanceId,
|
||||
models,
|
||||
model,
|
||||
prompt,
|
||||
@@ -228,11 +231,12 @@ export const TraitsMenuContent = memo(function TraitsMenuContentImpl({
|
||||
return;
|
||||
}
|
||||
setProviderModelOptions(threadTarget, provider, nextOptions, {
|
||||
...(instanceId ? { instanceId } : {}),
|
||||
model,
|
||||
persistSticky: true,
|
||||
});
|
||||
},
|
||||
[model, persistence, provider, setProviderModelOptions],
|
||||
[instanceId, model, persistence, provider, setProviderModelOptions],
|
||||
);
|
||||
const {
|
||||
descriptors,
|
||||
@@ -343,6 +347,7 @@ export const TraitsMenuContent = memo(function TraitsMenuContentImpl({
|
||||
|
||||
export const TraitsPicker = memo(function TraitsPicker({
|
||||
provider,
|
||||
instanceId,
|
||||
models,
|
||||
model,
|
||||
prompt,
|
||||
@@ -431,6 +436,7 @@ export const TraitsPicker = memo(function TraitsPicker({
|
||||
<MenuPopup align="start">
|
||||
<TraitsMenuContent
|
||||
provider={provider}
|
||||
{...(instanceId ? { instanceId } : {})}
|
||||
models={models}
|
||||
model={model}
|
||||
prompt={prompt}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
type ProviderDriverKind,
|
||||
type ProviderInstanceId,
|
||||
type ProviderOptionSelection,
|
||||
type ScopedThreadRef,
|
||||
type ServerProviderModel,
|
||||
@@ -35,6 +36,7 @@ export type ComposerProviderState = {
|
||||
|
||||
type TraitsRenderInput = {
|
||||
provider: ProviderDriverKind;
|
||||
instanceId?: ProviderInstanceId;
|
||||
threadRef?: ScopedThreadRef;
|
||||
draftId?: DraftId;
|
||||
model: string;
|
||||
@@ -76,8 +78,17 @@ function renderTraitsControl(
|
||||
Component: typeof TraitsMenuContent | typeof TraitsPicker,
|
||||
input: TraitsRenderInput,
|
||||
): ReactNode {
|
||||
const { provider, threadRef, draftId, model, models, modelOptions, prompt, onPromptChange } =
|
||||
input;
|
||||
const {
|
||||
provider,
|
||||
instanceId,
|
||||
threadRef,
|
||||
draftId,
|
||||
model,
|
||||
models,
|
||||
modelOptions,
|
||||
prompt,
|
||||
onPromptChange,
|
||||
} = input;
|
||||
const hasTarget = threadRef !== undefined || draftId !== undefined;
|
||||
if (
|
||||
!hasTarget ||
|
||||
@@ -88,6 +99,7 @@ function renderTraitsControl(
|
||||
return (
|
||||
<Component
|
||||
provider={provider}
|
||||
{...(instanceId ? { instanceId } : {})}
|
||||
models={models}
|
||||
{...(threadRef ? { threadRef } : {})}
|
||||
{...(draftId ? { draftId } : {})}
|
||||
|
||||
@@ -114,21 +114,6 @@ interface AddProviderInstanceDialogProps {
|
||||
}
|
||||
|
||||
export function AddProviderInstanceDialog({ open, onOpenChange }: AddProviderInstanceDialogProps) {
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<AddProviderInstanceDialogContent
|
||||
key={open ? "add-provider-open" : "add-provider-closed"}
|
||||
onOpenChange={onOpenChange}
|
||||
/>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
interface AddProviderInstanceDialogContentProps {
|
||||
onOpenChange: (open: boolean) => void;
|
||||
}
|
||||
|
||||
function AddProviderInstanceDialogContent({ onOpenChange }: AddProviderInstanceDialogContentProps) {
|
||||
const settings = useSettings();
|
||||
const { updateSettings } = useUpdateSettings();
|
||||
|
||||
@@ -136,7 +121,8 @@ function AddProviderInstanceDialogContent({ onOpenChange }: AddProviderInstanceD
|
||||
const [driver, setDriver] = useState<ProviderDriverKind>(DEFAULT_DRIVER_KIND);
|
||||
const [label, setLabel] = useState("");
|
||||
const [accentColor, setAccentColor] = useState<string>("");
|
||||
const [customInstanceId, setCustomInstanceId] = useState<string | null>(null);
|
||||
const [customInstanceId, setCustomInstanceId] = useState("");
|
||||
const [instanceIdDirty, setInstanceIdDirty] = useState(false);
|
||||
// Driver-specific config drafts keyed by driver so toggling between drivers
|
||||
// during the same dialog session does not lose in-progress input.
|
||||
const [configByDriver, setConfigByDriver] = useState<Record<string, Record<string, unknown>>>({});
|
||||
@@ -148,13 +134,13 @@ function AddProviderInstanceDialogContent({ onOpenChange }: AddProviderInstanceD
|
||||
() => new Set(Object.keys(settings.providerInstances ?? {})),
|
||||
[settings.providerInstances],
|
||||
);
|
||||
const instanceId = instanceIdDirty ? customInstanceId : deriveInstanceId(driver, label);
|
||||
|
||||
const driverOption = DRIVER_OPTION_BY_VALUE[driver] ?? DEFAULT_DRIVER_OPTION;
|
||||
const driverSettingsFields = useMemo(
|
||||
() => deriveProviderSettingsFields(driverOption),
|
||||
[driverOption],
|
||||
);
|
||||
const instanceId = customInstanceId ?? deriveInstanceId(driver, label);
|
||||
const instanceIdError = validateInstanceId(instanceId, existingIds);
|
||||
const showInstanceIdError = hasAttemptedSubmit && instanceIdError !== null;
|
||||
const previewLabel = label.trim() || `${driverOption.label} Workspace`;
|
||||
@@ -230,250 +216,256 @@ function AddProviderInstanceDialogContent({ onOpenChange }: AddProviderInstanceD
|
||||
]);
|
||||
|
||||
return (
|
||||
<DialogPopup className="max-w-xl overflow-hidden">
|
||||
<div className="flex min-h-0 flex-col overflow-hidden border-foreground/10 bg-background shadow-2xl">
|
||||
<DialogHeader className="border-b border-border/70 bg-background">
|
||||
<DialogTitle>Add provider instance</DialogTitle>
|
||||
<DialogDescription>
|
||||
Configure an additional provider instance — for example, a second Codex install pointed
|
||||
at a different workspace.
|
||||
</DialogDescription>
|
||||
<div className="grid grid-cols-3 gap-2">
|
||||
{wizardSteps.map((step, index) => (
|
||||
<button
|
||||
key={step}
|
||||
type="button"
|
||||
className={cn(
|
||||
"grid min-w-0 grid-cols-[1rem_minmax(0,1fr)] gap-x-2 rounded-lg border px-3 py-2 text-left",
|
||||
index === wizardStep
|
||||
? "border-primary bg-primary/10 ring-1 ring-primary/25"
|
||||
: index < wizardStep
|
||||
? "border-border bg-background"
|
||||
: "border-border bg-muted/40",
|
||||
)}
|
||||
onClick={() => setWizardStep(index)}
|
||||
>
|
||||
<span
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogPopup className="max-w-xl overflow-hidden">
|
||||
<div className="flex min-h-0 flex-col overflow-hidden border-foreground/10 bg-background shadow-2xl">
|
||||
<DialogHeader className="border-b border-border/70 bg-background">
|
||||
<DialogTitle>Add provider instance</DialogTitle>
|
||||
<DialogDescription>
|
||||
Configure an additional provider instance — for example, a second Codex install
|
||||
pointed at a different workspace.
|
||||
</DialogDescription>
|
||||
<div className="grid grid-cols-3 gap-2">
|
||||
{wizardSteps.map((step, index) => (
|
||||
<button
|
||||
key={step}
|
||||
type="button"
|
||||
className={cn(
|
||||
"row-span-2 mt-0.5 grid size-4 place-items-center rounded-full border",
|
||||
index < wizardStep
|
||||
? "border-primary bg-primary text-primary-foreground"
|
||||
: index === wizardStep
|
||||
? "border-primary bg-background"
|
||||
: "border-muted-foreground/35 bg-background",
|
||||
"grid min-w-0 grid-cols-[1rem_minmax(0,1fr)] gap-x-2 rounded-lg border px-3 py-2 text-left",
|
||||
index === wizardStep
|
||||
? "border-primary bg-primary/10 ring-1 ring-primary/25"
|
||||
: index < wizardStep
|
||||
? "border-border bg-background"
|
||||
: "border-border bg-muted/40",
|
||||
)}
|
||||
aria-hidden
|
||||
onClick={() => setWizardStep(index)}
|
||||
>
|
||||
{index < wizardStep ? <CheckIcon className="size-3" /> : null}
|
||||
</span>
|
||||
<span className="text-[10px] font-medium uppercase text-muted-foreground">
|
||||
Step {index + 1}
|
||||
</span>
|
||||
<span className="truncate text-xs font-semibold text-foreground">
|
||||
{step}
|
||||
{index < wizardStep && wizardStepSummaries[index]
|
||||
? `: ${wizardStepSummaries[index]}`
|
||||
: ""}
|
||||
</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</DialogHeader>
|
||||
|
||||
<div
|
||||
data-slot="dialog-panel"
|
||||
className="space-y-4 border-b border-border/70 bg-muted/20 px-6 py-5"
|
||||
>
|
||||
<AnimatedHeight>
|
||||
<div className={cn("grid gap-2", wizardStep !== 0 && "hidden")}>
|
||||
<span id="add-instance-driver-label" className="text-xs font-medium text-foreground">
|
||||
Driver
|
||||
</span>
|
||||
<RadioGroup
|
||||
value={driver}
|
||||
onValueChange={(value) => setDriver(ProviderDriverKind.make(value))}
|
||||
aria-labelledby="add-instance-driver-label"
|
||||
className="grid grid-cols-2 gap-2.5"
|
||||
>
|
||||
{DRIVER_OPTIONS.map((option) => {
|
||||
const IconComponent = option.icon;
|
||||
const isSelected = option.value === driver;
|
||||
return (
|
||||
<RadioPrimitive.Root
|
||||
key={option.value}
|
||||
value={option.value}
|
||||
className={cn(
|
||||
"relative flex cursor-pointer items-center gap-3 rounded-lg border px-3 py-3 text-left outline-none transition-[background-color,border-color,box-shadow]",
|
||||
"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",
|
||||
isSelected
|
||||
? "border-primary bg-background shadow-sm ring-2 ring-primary/35"
|
||||
: "border-border bg-background hover:border-foreground/20 hover:bg-muted/50",
|
||||
)}
|
||||
>
|
||||
<IconComponent className="size-5 shrink-0" aria-hidden />
|
||||
<span className="min-w-0 flex-1 truncate text-sm font-medium text-foreground">
|
||||
{option.label}
|
||||
</span>
|
||||
{option.badgeLabel ? (
|
||||
<Badge variant="warning" size="sm">
|
||||
{option.badgeLabel}
|
||||
</Badge>
|
||||
) : null}
|
||||
</RadioPrimitive.Root>
|
||||
);
|
||||
})}
|
||||
{COMING_SOON_DRIVER_OPTIONS.map((option) => {
|
||||
const IconComponent = option.icon;
|
||||
return (
|
||||
<RadioPrimitive.Root
|
||||
key={option.value}
|
||||
value={option.value}
|
||||
disabled
|
||||
className={cn(
|
||||
"relative flex cursor-not-allowed items-center gap-3 rounded-lg border border-border bg-background px-3 py-3 text-left opacity-55 outline-none",
|
||||
)}
|
||||
>
|
||||
<IconComponent
|
||||
className="size-5 shrink-0 text-muted-foreground"
|
||||
aria-hidden
|
||||
/>
|
||||
<span className="min-w-0 flex-1 truncate text-sm font-medium text-foreground">
|
||||
{option.label}
|
||||
</span>
|
||||
<Badge variant="warning" size="sm">
|
||||
Coming Soon
|
||||
</Badge>
|
||||
</RadioPrimitive.Root>
|
||||
);
|
||||
})}
|
||||
</RadioGroup>
|
||||
<span
|
||||
className={cn(
|
||||
"row-span-2 mt-0.5 grid size-4 place-items-center rounded-full border",
|
||||
index < wizardStep
|
||||
? "border-primary bg-primary text-primary-foreground"
|
||||
: index === wizardStep
|
||||
? "border-primary bg-background"
|
||||
: "border-muted-foreground/35 bg-background",
|
||||
)}
|
||||
aria-hidden
|
||||
>
|
||||
{index < wizardStep ? <CheckIcon className="size-3" /> : null}
|
||||
</span>
|
||||
<span className="text-[10px] font-medium uppercase text-muted-foreground">
|
||||
Step {index + 1}
|
||||
</span>
|
||||
<span className="truncate text-xs font-semibold text-foreground">
|
||||
{step}
|
||||
{index < wizardStep && wizardStepSummaries[index]
|
||||
? `: ${wizardStepSummaries[index]}`
|
||||
: ""}
|
||||
</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</DialogHeader>
|
||||
|
||||
<label className={cn("grid gap-2", wizardStep !== 1 && "hidden")}>
|
||||
<span className="text-xs font-medium text-foreground">Label</span>
|
||||
<Input
|
||||
className="bg-background"
|
||||
placeholder="e.g. Work"
|
||||
value={label}
|
||||
onChange={(event) => setLabel(event.target.value)}
|
||||
/>
|
||||
<span className="text-[11px] text-muted-foreground">
|
||||
Shown in the provider list. Optional.
|
||||
</span>
|
||||
</label>
|
||||
|
||||
<label className={cn("grid gap-2", wizardStep !== 1 && "hidden")}>
|
||||
<span className="text-xs font-medium text-foreground">Instance ID</span>
|
||||
<Input
|
||||
className="bg-background"
|
||||
placeholder={`${driver}_work`}
|
||||
value={instanceId}
|
||||
onChange={(event) => {
|
||||
setCustomInstanceId(event.target.value);
|
||||
}}
|
||||
aria-invalid={showInstanceIdError}
|
||||
/>
|
||||
{showInstanceIdError ? (
|
||||
<span className="text-[11px] text-destructive">{instanceIdError}</span>
|
||||
) : (
|
||||
<span className="text-[11px] text-muted-foreground">
|
||||
Routing key used by threads and sessions. Letters, digits, '-', or '_'.
|
||||
<div
|
||||
data-slot="dialog-panel"
|
||||
className="space-y-4 border-b border-border/70 bg-muted/20 px-6 py-5"
|
||||
>
|
||||
<AnimatedHeight>
|
||||
<div className={cn("grid gap-2", wizardStep !== 0 && "hidden")}>
|
||||
<span
|
||||
id="add-instance-driver-label"
|
||||
className="text-xs font-medium text-foreground"
|
||||
>
|
||||
Driver
|
||||
</span>
|
||||
)}
|
||||
</label>
|
||||
|
||||
<div className={cn("grid gap-2", wizardStep !== 1 && "hidden")}>
|
||||
<span className="text-xs font-medium text-foreground">Accent color</span>
|
||||
<div className="flex min-w-0 flex-wrap items-center gap-2">
|
||||
<input
|
||||
type="color"
|
||||
value={normalizeProviderAccentColor(accentColor) ?? PROVIDER_ACCENT_SWATCHES[0]}
|
||||
onChange={(event) => setAccentColor(event.target.value)}
|
||||
aria-label="Provider instance accent color"
|
||||
className="h-8 w-10 cursor-pointer rounded-xl border border-input bg-background p-0.5"
|
||||
/>
|
||||
<div className="flex flex-wrap gap-1.5">
|
||||
{PROVIDER_ACCENT_SWATCHES.map((swatch) => {
|
||||
const selected = accentColor.toLowerCase() === swatch;
|
||||
<RadioGroup
|
||||
value={driver}
|
||||
onValueChange={(value) => setDriver(ProviderDriverKind.make(value))}
|
||||
aria-labelledby="add-instance-driver-label"
|
||||
className="grid grid-cols-2 gap-2.5"
|
||||
>
|
||||
{DRIVER_OPTIONS.map((option) => {
|
||||
const IconComponent = option.icon;
|
||||
const isSelected = option.value === driver;
|
||||
return (
|
||||
<button
|
||||
key={swatch}
|
||||
type="button"
|
||||
<RadioPrimitive.Root
|
||||
key={option.value}
|
||||
value={option.value}
|
||||
className={cn(
|
||||
"size-6 cursor-pointer rounded-full border transition",
|
||||
selected
|
||||
? "scale-110 border-foreground ring-2 ring-ring ring-offset-1 ring-offset-background"
|
||||
: "border-black/10 hover:scale-105 dark:border-white/20",
|
||||
"relative flex cursor-pointer items-center gap-3 rounded-lg border px-3 py-3 text-left outline-none transition-[background-color,border-color,box-shadow]",
|
||||
"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",
|
||||
isSelected
|
||||
? "border-primary bg-background shadow-sm ring-2 ring-primary/35"
|
||||
: "border-border bg-background hover:border-foreground/20 hover:bg-muted/50",
|
||||
)}
|
||||
style={{ backgroundColor: swatch }}
|
||||
onClick={() => setAccentColor(swatch)}
|
||||
aria-label={`Use ${swatch} accent`}
|
||||
/>
|
||||
>
|
||||
<IconComponent className="size-5 shrink-0" aria-hidden />
|
||||
<span className="min-w-0 flex-1 truncate text-sm font-medium text-foreground">
|
||||
{option.label}
|
||||
</span>
|
||||
{option.badgeLabel ? (
|
||||
<Badge variant="warning" size="sm">
|
||||
{option.badgeLabel}
|
||||
</Badge>
|
||||
) : null}
|
||||
</RadioPrimitive.Root>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
{accentColor ? (
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
className="h-7 px-2 text-xs text-muted-foreground"
|
||||
onClick={() => setAccentColor("")}
|
||||
>
|
||||
Clear
|
||||
</Button>
|
||||
) : null}
|
||||
{COMING_SOON_DRIVER_OPTIONS.map((option) => {
|
||||
const IconComponent = option.icon;
|
||||
return (
|
||||
<RadioPrimitive.Root
|
||||
key={option.value}
|
||||
value={option.value}
|
||||
disabled
|
||||
className={cn(
|
||||
"relative flex cursor-not-allowed items-center gap-3 rounded-lg border border-border bg-background px-3 py-3 text-left opacity-55 outline-none",
|
||||
)}
|
||||
>
|
||||
<IconComponent
|
||||
className="size-5 shrink-0 text-muted-foreground"
|
||||
aria-hidden
|
||||
/>
|
||||
<span className="min-w-0 flex-1 truncate text-sm font-medium text-foreground">
|
||||
{option.label}
|
||||
</span>
|
||||
<Badge variant="warning" size="sm">
|
||||
Coming Soon
|
||||
</Badge>
|
||||
</RadioPrimitive.Root>
|
||||
);
|
||||
})}
|
||||
</RadioGroup>
|
||||
</div>
|
||||
<span className="text-[11px] text-muted-foreground">
|
||||
Optional marker shown in the picker.
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{driverSettingsFields.length > 0 ? (
|
||||
<div className={cn("grid gap-4", wizardStep !== 2 && "hidden")}>
|
||||
<ProviderSettingsForm
|
||||
definition={driverOption}
|
||||
value={configDraft}
|
||||
idPrefix={`add-provider-${driver}`}
|
||||
variant="dialog"
|
||||
onChange={setConfigDraft}
|
||||
<label className={cn("grid gap-2", wizardStep !== 1 && "hidden")}>
|
||||
<span className="text-xs font-medium text-foreground">Label</span>
|
||||
<Input
|
||||
className="bg-background"
|
||||
placeholder="e.g. Work"
|
||||
value={label}
|
||||
onChange={(event) => setLabel(event.target.value)}
|
||||
/>
|
||||
</div>
|
||||
) : wizardStep === 2 ? (
|
||||
<div className="grid gap-2">
|
||||
<p className="text-sm text-muted-foreground">
|
||||
This driver has no required configuration. You can add the instance now.
|
||||
</p>
|
||||
</div>
|
||||
) : null}
|
||||
</AnimatedHeight>
|
||||
</div>
|
||||
<span className="text-[11px] text-muted-foreground">
|
||||
Shown in the provider list. Optional.
|
||||
</span>
|
||||
</label>
|
||||
|
||||
<DialogFooter className="border-t bg-background">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => {
|
||||
if (wizardStep === 0) {
|
||||
onOpenChange(false);
|
||||
return;
|
||||
}
|
||||
setWizardStep((step) => Math.max(0, step - 1));
|
||||
}}
|
||||
>
|
||||
{wizardStep === 0 ? "Cancel" : "Back"}
|
||||
</Button>
|
||||
{wizardStep < wizardSteps.length - 1 ? (
|
||||
<Button size="sm" onClick={() => setWizardStep((step) => Math.min(2, step + 1))}>
|
||||
Next
|
||||
<label className={cn("grid gap-2", wizardStep !== 1 && "hidden")}>
|
||||
<span className="text-xs font-medium text-foreground">Instance ID</span>
|
||||
<Input
|
||||
className="bg-background"
|
||||
placeholder={`${driver}_work`}
|
||||
value={instanceId}
|
||||
onChange={(event) => {
|
||||
setInstanceIdDirty(true);
|
||||
setCustomInstanceId(event.target.value);
|
||||
}}
|
||||
aria-invalid={showInstanceIdError}
|
||||
/>
|
||||
{showInstanceIdError ? (
|
||||
<span className="text-[11px] text-destructive">{instanceIdError}</span>
|
||||
) : (
|
||||
<span className="text-[11px] text-muted-foreground">
|
||||
Routing key used by threads and sessions. Letters, digits, '-', or '_'.
|
||||
</span>
|
||||
)}
|
||||
</label>
|
||||
|
||||
<div className={cn("grid gap-2", wizardStep !== 1 && "hidden")}>
|
||||
<span className="text-xs font-medium text-foreground">Accent color</span>
|
||||
<div className="flex min-w-0 flex-wrap items-center gap-2">
|
||||
<input
|
||||
type="color"
|
||||
value={normalizeProviderAccentColor(accentColor) ?? PROVIDER_ACCENT_SWATCHES[0]}
|
||||
onChange={(event) => setAccentColor(event.target.value)}
|
||||
aria-label="Provider instance accent color"
|
||||
className="h-8 w-10 cursor-pointer rounded-xl border border-input bg-background p-0.5"
|
||||
/>
|
||||
<div className="flex flex-wrap gap-1.5">
|
||||
{PROVIDER_ACCENT_SWATCHES.map((swatch) => {
|
||||
const selected = accentColor.toLowerCase() === swatch;
|
||||
return (
|
||||
<button
|
||||
key={swatch}
|
||||
type="button"
|
||||
className={cn(
|
||||
"size-6 cursor-pointer rounded-full border transition",
|
||||
selected
|
||||
? "scale-110 border-foreground ring-2 ring-ring ring-offset-1 ring-offset-background"
|
||||
: "border-black/10 hover:scale-105 dark:border-white/20",
|
||||
)}
|
||||
style={{ backgroundColor: swatch }}
|
||||
onClick={() => setAccentColor(swatch)}
|
||||
aria-label={`Use ${swatch} accent`}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
{accentColor ? (
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
className="h-7 px-2 text-xs text-muted-foreground"
|
||||
onClick={() => setAccentColor("")}
|
||||
>
|
||||
Clear
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
<span className="text-[11px] text-muted-foreground">
|
||||
Optional marker shown in the picker.
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{driverSettingsFields.length > 0 ? (
|
||||
<div className={cn("grid gap-4", wizardStep !== 2 && "hidden")}>
|
||||
<ProviderSettingsForm
|
||||
definition={driverOption}
|
||||
value={configDraft}
|
||||
idPrefix={`add-provider-${driver}`}
|
||||
variant="dialog"
|
||||
onChange={setConfigDraft}
|
||||
/>
|
||||
</div>
|
||||
) : wizardStep === 2 ? (
|
||||
<div className="grid gap-2">
|
||||
<p className="text-sm text-muted-foreground">
|
||||
This driver has no required configuration. You can add the instance now.
|
||||
</p>
|
||||
</div>
|
||||
) : null}
|
||||
</AnimatedHeight>
|
||||
</div>
|
||||
|
||||
<DialogFooter className="border-t bg-background">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => {
|
||||
if (wizardStep === 0) {
|
||||
onOpenChange(false);
|
||||
return;
|
||||
}
|
||||
setWizardStep((step) => Math.max(0, step - 1));
|
||||
}}
|
||||
>
|
||||
{wizardStep === 0 ? "Cancel" : "Back"}
|
||||
</Button>
|
||||
) : (
|
||||
<Button size="sm" onClick={handleSave}>
|
||||
Add instance
|
||||
</Button>
|
||||
)}
|
||||
</DialogFooter>
|
||||
</div>
|
||||
</DialogPopup>
|
||||
{wizardStep < wizardSteps.length - 1 ? (
|
||||
<Button size="sm" onClick={() => setWizardStep((step) => Math.min(2, step + 1))}>
|
||||
Next
|
||||
</Button>
|
||||
) : (
|
||||
<Button size="sm" onClick={handleSave}>
|
||||
Add instance
|
||||
</Button>
|
||||
)}
|
||||
</DialogFooter>
|
||||
</div>
|
||||
</DialogPopup>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -920,10 +920,15 @@ export function ProviderSettingsPanel() {
|
||||
const serverProviders = useServerProviders();
|
||||
const [isRefreshingProviders, setIsRefreshingProviders] = useState(false);
|
||||
const [isAddInstanceDialogOpen, setIsAddInstanceDialogOpen] = useState(false);
|
||||
const [addInstanceDialogSession, setAddInstanceDialogSession] = useState(0);
|
||||
const [updatingProviderDrivers, setUpdatingProviderDrivers] = useState<
|
||||
ReadonlySet<ProviderDriverKind>
|
||||
>(() => new Set());
|
||||
const [openInstanceDetails, setOpenInstanceDetails] = useState<Record<string, boolean>>({});
|
||||
const openAddInstanceDialog = useCallback(() => {
|
||||
setAddInstanceDialogSession((session) => session + 1);
|
||||
setIsAddInstanceDialogOpen(true);
|
||||
}, []);
|
||||
const refreshingRef = useRef(false);
|
||||
|
||||
const providerUpdateCandidates = useMemo(
|
||||
@@ -1190,7 +1195,7 @@ export function ProviderSettingsPanel() {
|
||||
size="icon-xs"
|
||||
variant="ghost"
|
||||
className="size-5 rounded-sm p-0 text-muted-foreground hover:text-foreground"
|
||||
onClick={() => setIsAddInstanceDialogOpen(true)}
|
||||
onClick={openAddInstanceDialog}
|
||||
aria-label="Add provider instance"
|
||||
>
|
||||
<PlusIcon className="size-3" />
|
||||
@@ -1324,6 +1329,7 @@ export function ProviderSettingsPanel() {
|
||||
</SettingsSection>
|
||||
|
||||
<AddProviderInstanceDialog
|
||||
key={addInstanceDialogSession}
|
||||
open={isAddInstanceDialogOpen}
|
||||
onOpenChange={setIsAddInstanceDialogOpen}
|
||||
/>
|
||||
|
||||
@@ -21,6 +21,7 @@ import { createModelSelection } from "@t3tools/shared/model";
|
||||
// `stickyModelSelectionByProvider` maps are keyed by `ProviderInstanceId`
|
||||
// in production; these aliases keep the legacy-key migration tests concise.
|
||||
const CODEX_INSTANCE = ProviderInstanceId.make("codex");
|
||||
const CODEX_SECONDARY_INSTANCE = ProviderInstanceId.make("codex_secondary");
|
||||
const CLAUDE_AGENT_INSTANCE = ProviderInstanceId.make("claudeAgent");
|
||||
const CURSOR_INSTANCE = ProviderInstanceId.make("cursor");
|
||||
const CODEX_DRIVER = ProviderDriverKind.make("codex");
|
||||
@@ -1201,6 +1202,43 @@ describe("composerDraftStore modelSelection", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("stores provider option changes on a selected custom instance", () => {
|
||||
const store = useComposerDraftStore.getState();
|
||||
|
||||
store.setProviderModelOptions(
|
||||
threadRef,
|
||||
CODEX_DRIVER,
|
||||
toSelections({ reasoningEffort: "low" }),
|
||||
{
|
||||
instanceId: CODEX_SECONDARY_INSTANCE,
|
||||
model: "gpt-5-codex",
|
||||
persistSticky: true,
|
||||
},
|
||||
);
|
||||
|
||||
expect(
|
||||
draftFor(threadId, TEST_ENVIRONMENT_ID)?.modelSelectionByProvider[CODEX_SECONDARY_INSTANCE],
|
||||
).toEqual(
|
||||
expect.objectContaining({
|
||||
instanceId: CODEX_SECONDARY_INSTANCE,
|
||||
options: [{ id: "reasoningEffort", value: "low" }],
|
||||
}),
|
||||
);
|
||||
expect(draftFor(threadId, TEST_ENVIRONMENT_ID)?.activeProvider).toBe(CODEX_SECONDARY_INSTANCE);
|
||||
expect(useComposerDraftStore.getState().stickyActiveProvider).toBe(CODEX_SECONDARY_INSTANCE);
|
||||
expect(useComposerDraftStore.getState().stickyModelSelectionByProvider[CODEX_INSTANCE]).toBe(
|
||||
undefined,
|
||||
);
|
||||
expect(
|
||||
useComposerDraftStore.getState().stickyModelSelectionByProvider[CODEX_SECONDARY_INSTANCE],
|
||||
).toEqual(
|
||||
expect.objectContaining({
|
||||
instanceId: CODEX_SECONDARY_INSTANCE,
|
||||
options: [{ id: "reasoningEffort", value: "low" }],
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("updates only the draft when sticky persistence is disabled", () => {
|
||||
const store = useComposerDraftStore.getState();
|
||||
|
||||
|
||||
@@ -371,6 +371,7 @@ interface ComposerDraftStoreState {
|
||||
provider: ProviderDriverKind,
|
||||
nextProviderOptions: ReadonlyArray<ProviderOptionSelection> | null | undefined,
|
||||
options?: {
|
||||
instanceId?: ProviderInstanceId | null | undefined;
|
||||
model?: string | null | undefined;
|
||||
persistSticky?: boolean;
|
||||
},
|
||||
@@ -2456,7 +2457,7 @@ const composerDraftStore = create<ComposerDraftStoreState>()(
|
||||
if (normalizedProvider === null) {
|
||||
return;
|
||||
}
|
||||
const instanceKey = defaultInstanceIdForDriver(normalizedProvider);
|
||||
const instanceKey = options?.instanceId ?? defaultInstanceIdForDriver(normalizedProvider);
|
||||
const fallbackModel =
|
||||
normalizeModelSlug(options?.model, normalizedProvider) ??
|
||||
DEFAULT_MODEL_BY_PROVIDER[normalizedProvider] ??
|
||||
@@ -2501,7 +2502,9 @@ const composerDraftStore = create<ComposerDraftStoreState>()(
|
||||
const { options: _, ...rest } = stickyBase;
|
||||
nextStickyMap[instanceKey] = rest as ModelSelection;
|
||||
}
|
||||
nextStickyActiveProvider = base.activeProvider ?? instanceKey;
|
||||
nextStickyActiveProvider = options.instanceId
|
||||
? instanceKey
|
||||
: (base.activeProvider ?? instanceKey);
|
||||
}
|
||||
|
||||
if (
|
||||
@@ -2514,6 +2517,7 @@ const composerDraftStore = create<ComposerDraftStoreState>()(
|
||||
|
||||
const nextDraft: ComposerThreadDraftState = {
|
||||
...base,
|
||||
...(options?.instanceId ? { activeProvider: instanceKey } : {}),
|
||||
modelSelectionByProvider: nextMap,
|
||||
};
|
||||
const nextDraftsByThreadKey = { ...state.draftsByThreadKey };
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@t3tools/contracts",
|
||||
"version": "0.0.23",
|
||||
"version": "0.0.24",
|
||||
"private": true,
|
||||
"files": [
|
||||
"dist"
|
||||
|
||||
Reference in new issue
Block a user