TypeScript
fix(clients): subagent bar stops guessing the subagent's effort (#15710)
fixfon53ef45feac9a
diff --git a/packages/client-runtime/src/state/threadExecution.test.ts b/packages/client-runtime/src/state/threadExecution.test.tsindex 231f200f375..86a0986256b 100644--- a/packages/client-runtime/src/state/threadExecution.test.ts+++ b/packages/client-runtime/src/state/threadExecution.test.ts@@ -464,20 +464,43 @@ describe("formatModelSelectionEffort", () => {},];- it("shows the model's default effort when the user never picked one", () => {- expect(formatModelSelectionEffort(selection(), catalog({}))).toBe("High");- });-- it("names a stored effort the way the catalog does", () => {+ it("names stored and matching reported effort, preferring the stored choice", () => {expect(formatModelSelectionEffort(selection([{ id: "effort", value: "xhigh" }]), catalog({})),).toBe("Extra High");+ const reported = selection([{ id: "effort", value: "xhigh" }]);+ expect(formatModelSelectionEffort(selection(), catalog({}), reported)).toBe("Extra High");+ expect(+ formatModelSelectionEffort(+ selection([{ id: "effort", value: "medium" }]),+ catalog({}),+ reported,+ ),+ ).toBe("Medium");+ expect(+ formatModelSelectionEffort(+ selection([{ id: "effort", value: "retired-effort" }]),+ catalog({ currentValue: "medium" }),+ reported,+ ),+ ).toBeNull();});- it("uses the descriptor's current value over the default", () => {- expect(formatModelSelectionEffort(selection(), catalog({ currentValue: "medium" }))).toBe(- "Medium",- );+ it("shows nothing when neither the selection nor the provider states an effort", () => {+ expect(formatModelSelectionEffort(selection(), catalog({}))).toBeNull();+ expect(formatModelSelectionEffort(selection(), catalog({ currentValue: "medium" }))).toBeNull();+ expect(+ formatModelSelectionEffort(selection(), catalog({}), {+ ...selection([{ id: "effort", value: "xhigh" }]),+ model: "claude-opus-5-5",+ }),+ ).toBeNull();+ expect(+ formatModelSelectionEffort(selection(), catalog({}), {+ ...selection([{ id: "effort", value: "xhigh" }]),+ instanceId: ProviderInstanceId.make("claudeAgent-other"),+ }),+ ).toBeNull();});it("shows nothing for a model the catalog does not describe", () => {diff --git a/packages/client-runtime/src/state/threadExecution.ts b/packages/client-runtime/src/state/threadExecution.tsindex e3e1cd92f74..2f85fb6ed79 100644--- a/packages/client-runtime/src/state/threadExecution.ts+++ b/packages/client-runtime/src/state/threadExecution.ts@@ -22,7 +22,7 @@ import {backgroundWorkHoldsCompletion,derivePendingBackgroundWork,} from "@t3tools/shared/orchestrationV2PendingBackgroundWork";-import { getProviderOptionCurrentLabel, getProviderOptionDescriptors } from "@t3tools/shared/model";+import { getProviderOptionCurrentLabel, getProviderOptionStatedValue } from "@t3tools/shared/model";import { formatDuration } from "@t3tools/shared/orchestrationTiming";import * as DateTime from "effect/DateTime";@@ -160,11 +160,18 @@ export function formatModelSelectionEffort(): string | null {const caps = models.find((model) => model.slug === selection.model)?.capabilities;if (!caps) return null;- const descriptors = getProviderOptionDescriptors({ caps, selections: selection.options });for (const id of REASONING_EFFORT_OPTION_IDS) {- const descriptor = descriptors.find((candidate) => candidate.id === id);+ const descriptor = caps.optionDescriptors?.find((candidate) => candidate.id === id);if (descriptor?.type !== "select") continue;- const label = getProviderOptionCurrentLabel(descriptor, selection, reportedSelection);+ const value = getProviderOptionStatedValue(id, selection, reportedSelection);+ if (value === undefined && id !== "variant") continue;+ if (typeof value === "boolean") continue;+ // Bypass picker normalization so an obsolete choice cannot become a catalog default.+ const label = getProviderOptionCurrentLabel(+ { ...descriptor, currentValue: value },+ selection,+ reportedSelection,+ );if (label) return label;}return null;diff --git a/packages/shared/src/model.ts b/packages/shared/src/model.tsindex c4f5fe61322..b1e7a7bd7cc 100644--- a/packages/shared/src/model.ts+++ b/packages/shared/src/model.ts@@ -213,6 +213,17 @@ function getReportedOptionValue(return getRawSelectionValueById(reportedSelection.options, id);}+export function getProviderOptionStatedValue(+ id: string,+ selection?: ModelSelection | null,+ reportedSelection?: ModelSelection | null,+) {+ return (+ getRawSelectionValueById(selection?.options, id) ??+ getReportedOptionValue(id, selection, reportedSelection)+ );+}+export function getProviderOptionCurrentValue(descriptor: ProviderOptionDescriptor | null | undefined,selection?: ModelSelection | null,