refactor(web): prune unused UI and provider code (#9959)
This commit is contained in:
1 parent
126ea5c3bc
commit
4a42fc62e1
5 files changed
+4
-150
No files matched your search
@@ -1,101 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { cn } from "~/lib/utils";
|
||||
|
||||
interface ColorSelectorProps {
|
||||
colors: string[];
|
||||
size?: "default" | "sm" | "lg";
|
||||
defaultValue: string;
|
||||
name?: string;
|
||||
onColorSelect?: (color: string) => void;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const colorMap = {
|
||||
default: "var(--contrast-foreground)",
|
||||
red: "var(--color-red-500)",
|
||||
green: "var(--color-green-500)",
|
||||
blue: "var(--color-blue-500)",
|
||||
yellow: "var(--color-yellow-500)",
|
||||
purple: "var(--color-purple-500)",
|
||||
pink: "var(--color-pink-500)",
|
||||
indigo: "var(--color-indigo-500)",
|
||||
orange: "var(--color-orange-500)",
|
||||
teal: "var(--color-teal-500)",
|
||||
cyan: "var(--color-cyan-500)",
|
||||
lime: "var(--color-lime-500)",
|
||||
emerald: "var(--color-emerald-500)",
|
||||
violet: "var(--color-violet-500)",
|
||||
fuchsia: "var(--color-fuchsia-500)",
|
||||
rose: "var(--color-rose-500)",
|
||||
sky: "var(--color-sky-500)",
|
||||
amber: "var(--color-amber-500)",
|
||||
} as const;
|
||||
|
||||
function getSizeClass(size: "default" | "sm" | "lg") {
|
||||
switch (size) {
|
||||
case "sm":
|
||||
return "size-4";
|
||||
case "default":
|
||||
return "size-5";
|
||||
case "lg":
|
||||
return "size-6";
|
||||
default:
|
||||
return "size-5";
|
||||
}
|
||||
}
|
||||
|
||||
function getColorValue(color: string): string {
|
||||
return colorMap[color as keyof typeof colorMap] || color;
|
||||
}
|
||||
|
||||
export function ColorSelector({
|
||||
colors,
|
||||
size = "default",
|
||||
defaultValue,
|
||||
name,
|
||||
onColorSelect,
|
||||
className,
|
||||
}: ColorSelectorProps) {
|
||||
const [selectedColor, setSelectedColor] = useState<string>(defaultValue);
|
||||
|
||||
const handleColorSelect = (color: string) => {
|
||||
setSelectedColor(color);
|
||||
onColorSelect?.(color);
|
||||
};
|
||||
|
||||
const sizeClass = getSizeClass(size);
|
||||
|
||||
return (
|
||||
<div className={cn("flex gap-2", className)}>
|
||||
{name && <input type="hidden" name={name} value={selectedColor} />}
|
||||
{colors.map((color) => {
|
||||
const colorValue = getColorValue(color);
|
||||
return (
|
||||
<div
|
||||
key={color}
|
||||
className={`${sizeClass} cursor-pointer rounded-full transition-transform duration-200 active:scale-90`}
|
||||
style={{
|
||||
backgroundColor: colorValue,
|
||||
...(selectedColor === color && {
|
||||
boxShadow: `inset 0 0 0 2px var(--card), 0 0 0 2px ${colorValue}`,
|
||||
}),
|
||||
}}
|
||||
onClick={() => handleColorSelect(color)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter" || e.key === " ") {
|
||||
e.preventDefault();
|
||||
handleColorSelect(color);
|
||||
}
|
||||
}}
|
||||
tabIndex={0}
|
||||
role="button"
|
||||
aria-label={`Select ${color} color`}
|
||||
aria-pressed={selectedColor === color}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -153,7 +153,7 @@ function applyInstanceModelPreferences(
|
||||
);
|
||||
}
|
||||
|
||||
export function normalizeCustomModelEntries(
|
||||
function normalizeCustomModelEntries(
|
||||
models: ReadonlyArray<CustomModelDefinition>,
|
||||
builtInModelSlugs: ReadonlySet<string>,
|
||||
): CustomModelDefinition[] {
|
||||
@@ -179,7 +179,7 @@ export function normalizeCustomModelEntries(
|
||||
return normalizedModels;
|
||||
}
|
||||
|
||||
export function getAppModelOptions(
|
||||
function getAppModelOptions(
|
||||
settings: UnifiedSettings,
|
||||
providers: ReadonlyArray<ServerProvider>,
|
||||
provider: ProviderDriverKind,
|
||||
|
||||
@@ -298,7 +298,7 @@ export function sortProviderInstanceEntries(
|
||||
* Look up a single instance entry by exact `instanceId`. Missing snapshots
|
||||
* are not inferred from driver kind in UI routing code.
|
||||
*/
|
||||
export function getProviderInstanceEntry(
|
||||
function getProviderInstanceEntry(
|
||||
providers: ReadonlyArray<ServerProvider>,
|
||||
instanceId: ProviderInstanceId,
|
||||
): ProviderInstanceEntry | undefined {
|
||||
|
||||
@@ -30,7 +30,7 @@ export function getProviderModels(
|
||||
return getProviderSnapshot(providers, provider)?.models ?? [];
|
||||
}
|
||||
|
||||
export function getProviderSnapshot(
|
||||
function getProviderSnapshot(
|
||||
providers: ReadonlyArray<ServerProvider>,
|
||||
provider: ProviderDriverKind,
|
||||
): ServerProvider | undefined {
|
||||
@@ -38,13 +38,6 @@ export function getProviderSnapshot(
|
||||
return providers.find((candidate) => candidate.instanceId === defaultInstanceId);
|
||||
}
|
||||
|
||||
export function getProviderInteractionModeToggle(
|
||||
providers: ReadonlyArray<ServerProvider>,
|
||||
provider: ProviderDriverKind,
|
||||
): boolean {
|
||||
return getProviderSnapshot(providers, provider)?.showInteractionModeToggle ?? true;
|
||||
}
|
||||
|
||||
// Resolve an instance selection to the correlated live driver. If the
|
||||
// instance is absent, fall back to a live enabled provider instead of
|
||||
// inferring a driver from the missing instance id.
|
||||
|
||||
@@ -16,7 +16,6 @@ import {
|
||||
type OrchestrationLatestTurn,
|
||||
type OrchestrationThreadActivity,
|
||||
type OrchestrationProposedPlanId,
|
||||
ProviderDriverKind,
|
||||
ProviderApprovalOption,
|
||||
ProviderRequestKind,
|
||||
type ToolLifecycleItemType,
|
||||
@@ -38,43 +37,6 @@ import {
|
||||
|
||||
export { formatDuration, formatElapsed } from "@t3tools/shared/orchestrationTiming";
|
||||
|
||||
export type ProviderPickerKind = ProviderDriverKind;
|
||||
|
||||
export const PROVIDER_OPTIONS: Array<{
|
||||
value: ProviderPickerKind;
|
||||
label: string;
|
||||
available: boolean;
|
||||
/** Shown on the model picker sidebar when relevant */
|
||||
pickerSidebarBadge?: "new" | "soon";
|
||||
}> = [
|
||||
{ value: ProviderDriverKind.make("codex"), label: "Codex", available: true },
|
||||
{ value: ProviderDriverKind.make("claudeAgent"), label: "Claude", available: true },
|
||||
{
|
||||
value: ProviderDriverKind.make("opencode"),
|
||||
label: "OpenCode",
|
||||
available: true,
|
||||
pickerSidebarBadge: "new",
|
||||
},
|
||||
{
|
||||
value: ProviderDriverKind.make("cursor"),
|
||||
label: "Cursor",
|
||||
available: true,
|
||||
pickerSidebarBadge: "new",
|
||||
},
|
||||
{
|
||||
value: ProviderDriverKind.make("grok"),
|
||||
label: "Grok",
|
||||
available: true,
|
||||
pickerSidebarBadge: "new",
|
||||
},
|
||||
{
|
||||
value: ProviderDriverKind.make("antigravity"),
|
||||
label: "Antigravity",
|
||||
available: true,
|
||||
pickerSidebarBadge: "new",
|
||||
},
|
||||
];
|
||||
|
||||
export type WorkLogToolLifecycleStatus =
|
||||
| "inProgress"
|
||||
| "completed"
|
||||
|
||||
Reference in new issue
Block a user