惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 三生石上(FineUI控件)
Blog — PlanetScale
Blog — PlanetScale
B
Blog
GbyAI
GbyAI
爱范儿
爱范儿
月光博客
月光博客
N
Netflix TechBlog - Medium
T
Tailwind CSS Blog
G
Google Developers Blog
大猫的无限游戏
大猫的无限游戏
Vercel News
Vercel News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
WordPress大学
WordPress大学
The GitHub Blog
The GitHub Blog
Recent Announcements
Recent Announcements
腾讯CDC
MyScale Blog
MyScale Blog
V
Visual Studio Blog
The Cloudflare Blog
Microsoft Security Blog
Microsoft Security Blog
A
About on SuperTechFans
Google DeepMind News
Google DeepMind News
Last Week in AI
Last Week in AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(model-picker): show effective runtime choices · openc...
steipete · 2026-05-16 · via Recent Commits to openclaw:main

@@ -1,6 +1,9 @@

11

import type { APISelectMenuOption } from "discord-api-types/v10";

22

import { ButtonStyle } from "discord-api-types/v10";

3-

import type { ModelsProviderData } from "openclaw/plugin-sdk/models-provider-runtime";

3+

import type {

4+

ModelsProviderData,

5+

ModelsRuntimeChoice,

6+

} from "openclaw/plugin-sdk/models-provider-runtime";

47

import { normalizeProviderId } from "openclaw/plugin-sdk/provider-model-shared";

58

import {

69

Button,

@@ -76,8 +79,10 @@ export type DiscordModelPickerModelViewParams = {

7679

page?: number;

7780

providerPage?: number;

7881

currentModel?: string;

82+

currentRuntime?: string;

7983

pendingModel?: string;

8084

pendingModelIndex?: number;

85+

pendingRuntime?: string;

8186

quickModels?: string[];

8287

layout?: DiscordModelPickerLayout;

8388

};

@@ -164,6 +169,59 @@ function createModelSelect(params: {

164169

return new DiscordModelPickerSelect();

165170

}

166171172+

function getRuntimeChoices(params: {

173+

data: ModelsProviderData;

174+

provider: string;

175+

}): ModelsRuntimeChoice[] {

176+

const choices = params.data.runtimeChoicesByProvider?.get(normalizeProviderId(params.provider));

177+

if (choices?.length) {

178+

return choices;

179+

}

180+

return [

181+

{

182+

id: "pi",

183+

label: "OpenClaw Pi Default",

184+

description: "Use the built-in OpenClaw Pi runtime.",

185+

},

186+

];

187+

}

188+189+

function resolveSelectedRuntime(params: {

190+

data: ModelsProviderData;

191+

provider: string;

192+

currentRuntime?: string;

193+

pendingRuntime?: string;

194+

}): string {

195+

const choices = getRuntimeChoices({ data: params.data, provider: params.provider });

196+

const allowed = new Set(choices.map((choice) => choice.id));

197+

const pending = params.pendingRuntime?.trim();

198+

if (pending && allowed.has(pending)) {

199+

return pending;

200+

}

201+

const current = params.currentRuntime?.trim();

202+

if (current && allowed.has(current)) {

203+

return current;

204+

}

205+

return choices[0]?.id ?? "pi";

206+

}

207+208+

function resolveExplicitRuntimeState(params: {

209+

choices: ModelsRuntimeChoice[];

210+

currentRuntime?: string;

211+

pendingRuntime?: string;

212+

}): string | undefined {

213+

const allowed = new Set(params.choices.map((choice) => choice.id));

214+

const pending = params.pendingRuntime?.trim();

215+

if (pending && allowed.has(pending)) {

216+

return pending;

217+

}

218+

const current = params.currentRuntime?.trim();

219+

if (current && current !== "auto" && current !== "default" && allowed.has(current)) {

220+

return current;

221+

}

222+

return undefined;

223+

}

224+167225

function buildRenderedShell(

168226

params: DiscordModelPickerRenderShellParams,

169227

): DiscordModelPickerRenderedView {

@@ -241,8 +299,10 @@ function buildModelRows(params: {

241299

providerPage: number;

242300

modelPage: DiscordModelPickerModelPage;

243301

currentModel?: string;

302+

currentRuntime?: string;

244303

pendingModel?: string;

245304

pendingModelIndex?: number;

305+

pendingRuntime?: string;

246306

quickModels?: string[];

247307

}): { rows: DiscordModelPickerRow[]; buttonRow: Row<Button> } {

248308

const parsedCurrentModel = parseCurrentModelRef(params.currentModel);

@@ -279,6 +339,49 @@ function buildModelRows(params: {

279339

]),

280340

);

281341342+

const runtimeChoices = getRuntimeChoices({

343+

data: params.data,

344+

provider: params.modelPage.provider,

345+

});

346+

const selectedRuntime = resolveSelectedRuntime({

347+

data: params.data,

348+

provider: params.modelPage.provider,

349+

currentRuntime: params.currentRuntime,

350+

pendingRuntime: params.pendingRuntime,

351+

});

352+

const stateRuntime = resolveExplicitRuntimeState({

353+

choices: runtimeChoices,

354+

currentRuntime: params.currentRuntime,

355+

pendingRuntime: params.pendingRuntime,

356+

});

357+358+

if (runtimeChoices.length > 1) {

359+

rows.push(

360+

new Row([

361+

createModelSelect({

362+

customId: buildDiscordModelPickerCustomId({

363+

command: params.command,

364+

action: "runtime",

365+

view: "models",

366+

provider: params.modelPage.provider,

367+

runtime: selectedRuntime,

368+

page: params.modelPage.page,

369+

providerPage: providerPage.page,

370+

modelIndex: params.pendingModelIndex,

371+

userId: params.userId,

372+

}),

373+

options: runtimeChoices.map((choice) => ({

374+

label: choice.label,

375+

value: choice.id,

376+

default: choice.id === selectedRuntime,

377+

...(choice.description ? { description: choice.description } : {}),

378+

})),

379+

placeholder: "Select runtime",

380+

}),

381+

]),

382+

);

383+

}

384+282385

const selectedModelRef = parsedPendingModel ?? parsedCurrentModel;

283386

const modelOptions: APISelectMenuOption[] = params.modelPage.items.map((model) => ({

284387

label: model,

@@ -296,6 +399,7 @@ function buildModelRows(params: {

296399

action: "model",

297400

view: "models",

298401

provider: params.modelPage.provider,

402+

runtime: stateRuntime,

299403

page: params.modelPage.page,

300404

providerPage: providerPage.page,

301405

userId: params.userId,

@@ -327,6 +431,7 @@ function buildModelRows(params: {

327431

action: "cancel",

328432

view: "models",

329433

provider: params.modelPage.provider,

434+

runtime: stateRuntime,

330435

page: params.modelPage.page,

331436

providerPage: providerPage.page,

332437

userId: params.userId,

@@ -341,6 +446,7 @@ function buildModelRows(params: {

341446

action: "reset",

342447

view: "models",

343448

provider: params.modelPage.provider,

449+

runtime: stateRuntime,

344450

page: params.modelPage.page,

345451

providerPage: providerPage.page,

346452

userId: params.userId,

@@ -358,6 +464,7 @@ function buildModelRows(params: {

358464

action: "recents",

359465

view: "recents",

360466

provider: params.modelPage.provider,

467+

runtime: stateRuntime,

361468

page: params.modelPage.page,

362469

providerPage: providerPage.page,

363470

userId: params.userId,

@@ -376,6 +483,7 @@ function buildModelRows(params: {

376483

action: "submit",

377484

view: "models",

378485

provider: params.modelPage.provider,

486+

runtime: stateRuntime,

379487

page: params.modelPage.page,

380488

providerPage: providerPage.page,

381489

modelIndex: params.pendingModelIndex,

@@ -457,14 +565,21 @@ export function renderDiscordModelPickerModelsView(

457565

providerPage,

458566

modelPage,

459567

currentModel: params.currentModel,

568+

currentRuntime: params.currentRuntime,

460569

pendingModel: params.pendingModel,

461570

pendingModelIndex: params.pendingModelIndex,

571+

pendingRuntime: params.pendingRuntime,

462572

quickModels: params.quickModels,

463573

});

464574465575

const defaultModel = `${params.data.resolvedDefault.provider}/${params.data.resolvedDefault.model}`;

466576

const pendingLine = params.pendingModel

467-

? `Selected: ${params.pendingModel} (press Submit)`

577+

? `Selected: ${params.pendingModel} · runtime ${resolveSelectedRuntime({

578+

data: params.data,

579+

provider: modelPage.provider,

580+

currentRuntime: params.currentRuntime,

581+

pendingRuntime: params.pendingRuntime,

582+

})} (press Submit)`

468583

: "Select a model, then press Submit.";

469584470585

return buildRenderedShell({

@@ -483,6 +598,7 @@ export type DiscordModelPickerRecentsViewParams = {

483598

data: ModelsProviderData;

484599

quickModels: string[];

485600

currentModel?: string;

601+

runtime?: string;

486602

provider?: string;

487603

page?: number;

488604

providerPage?: number;

@@ -522,6 +638,7 @@ export function renderDiscordModelPickerRecentsView(

522638

view: "recents",

523639

recentSlot: 1,

524640

provider: params.provider,

641+

runtime: params.runtime,

525642

page: params.page,

526643

providerPage: params.providerPage,

527644

userId: params.userId,

@@ -544,6 +661,7 @@ export function renderDiscordModelPickerRecentsView(

544661

view: "recents",

545662

recentSlot: i + 2,

546663

provider: params.provider,

664+

runtime: params.runtime,

547665

page: params.page,

548666

providerPage: params.providerPage,

549667

userId: params.userId,

@@ -563,6 +681,7 @@ export function renderDiscordModelPickerRecentsView(

563681

action: "back",

564682

view: "models",

565683

provider: params.provider,

684+

runtime: params.runtime,

566685

page: params.page,

567686

providerPage: params.providerPage,

568687

userId: params.userId,