mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 12:28:37 +00:00
refactor: declone model picker model ref parsing
This commit is contained in:
@@ -60,6 +60,15 @@ describe("Mattermost model picker", () => {
|
||||
expect(view.buttons[0]?.[0]?.text).toBe("Browse providers");
|
||||
});
|
||||
|
||||
it("trims accidental model spacing in Mattermost current-model text", () => {
|
||||
const view = renderMattermostModelSummaryView({
|
||||
ownerUserId: "user-1",
|
||||
currentModel: " OpenAI/ gpt-5 ",
|
||||
});
|
||||
|
||||
expect(view.text).toContain("Current: openai/gpt-5");
|
||||
});
|
||||
|
||||
it("renders providers and models with Telegram-style navigation", () => {
|
||||
const providersView = renderMattermostProviderPickerView({
|
||||
ownerUserId: "user-1",
|
||||
|
||||
@@ -36,15 +36,13 @@ export type MattermostModelPickerRenderedView = {
|
||||
|
||||
function splitModelRef(modelRef?: string | null): { provider: string; model: string } | null {
|
||||
const trimmed = modelRef?.trim();
|
||||
if (!trimmed) {
|
||||
const match = trimmed?.match(/^([^/]+)\/(.+)$/u);
|
||||
if (!match) {
|
||||
return null;
|
||||
}
|
||||
const slashIndex = trimmed.indexOf("/");
|
||||
if (slashIndex <= 0 || slashIndex >= trimmed.length - 1) {
|
||||
return null;
|
||||
}
|
||||
const provider = normalizeProviderId(trimmed.slice(0, slashIndex));
|
||||
const model = trimmed.slice(slashIndex + 1).trim();
|
||||
const provider = normalizeProviderId(match[1]);
|
||||
// Mattermost copy should normalize accidental whitespace around the model.
|
||||
const model = match[2].trim();
|
||||
if (!provider || !model) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user