mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-03 07:03:18 +00:00
* fix(app): respect provider label for xhigh thinking option Only fall back to the localized Extra high string for bare forms. Custom labels such as XHigh (56 | 8m) now render with their suffix. * fix(app): show Extra high only for a bare xhigh label A configured xhigh label with extra detail keeps its text; only a label that is just xhigh or Extra high uses the localized string. Co-authored-by: Elior Fureraj <efureraj@gmail.com> --------- Co-authored-by: Elior Fureraj <efureraj@gmail.com> Co-authored-by: paseo-bot[bot] <266920839+paseo-bot[bot]@users.noreply.github.com>
45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
import { i18n } from "@/i18n/i18next";
|
|
|
|
interface ControlLabelInput {
|
|
id: string;
|
|
label?: string | null;
|
|
}
|
|
|
|
function sentenceCase(value: string): string {
|
|
if (!value) {
|
|
return value;
|
|
}
|
|
return value.charAt(0).toUpperCase() + value.slice(1).toLowerCase();
|
|
}
|
|
|
|
function splitCompactLabel(value: string, splitHyphen: boolean): string {
|
|
const separatorPattern = splitHyphen ? /[_-]+/g : /_+/g;
|
|
|
|
return value
|
|
.replace(separatorPattern, " ")
|
|
.replace(/([a-z])([A-Z])/g, "$1 $2")
|
|
.replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2")
|
|
.replace(/\s+/g, " ")
|
|
.trim();
|
|
}
|
|
|
|
function formatControlLabel(option: ControlLabelInput, splitHyphen: boolean): string {
|
|
const rawLabel = (option.label ?? option.id).trim();
|
|
return sentenceCase(splitCompactLabel(rawLabel, splitHyphen));
|
|
}
|
|
|
|
export function formatAgentModeLabel(mode: ControlLabelInput): string {
|
|
return formatControlLabel(mode, mode.label == null);
|
|
}
|
|
|
|
export function formatThinkingOptionLabel(option: ControlLabelInput): string {
|
|
const rawLabel = (option.label ?? option.id).trim();
|
|
const compactLabel = rawLabel.replace(/[\s_-]+/g, "").toLowerCase();
|
|
|
|
if (compactLabel === "xhigh" || compactLabel === "extrahigh") {
|
|
return i18n.t("agentControls.thinking.extraHigh");
|
|
}
|
|
|
|
return formatControlLabel(option, true);
|
|
}
|