status: compact fallback model presentation

This commit is contained in:
Gustavo Madeira Santana
2026-02-19 03:15:39 -05:00
committed by joshavant
parent 848511fda7
commit 9baae38704
10 changed files with 106 additions and 65 deletions

View File

@@ -51,13 +51,13 @@ describe("app-tool-stream fallback lifecycle handling", () => {
selectedModel: "fireworks/minimax-m2p5",
activeProvider: "deepinfra",
activeModel: "moonshotai/Kimi-K2.5",
reasonSummary: "fireworks/fireworks/minimax-m2p5 rate limit",
reasonSummary: "rate limit",
},
});
expect(host.fallbackStatus?.selected).toBe("fireworks/fireworks/minimax-m2p5");
expect(host.fallbackStatus?.selected).toBe("fireworks/minimax-m2p5");
expect(host.fallbackStatus?.active).toBe("deepinfra/moonshotai/Kimi-K2.5");
expect(host.fallbackStatus?.reason).toBe("fireworks/fireworks/minimax-m2p5 rate limit");
expect(host.fallbackStatus?.reason).toBe("rate limit");
vi.useRealTimers();
});

View File

@@ -49,6 +49,13 @@ function resolveModelLabel(provider: unknown, model: unknown): string | null {
}
const providerValue = toTrimmedString(provider);
if (providerValue) {
const prefix = `${providerValue}/`;
if (modelValue.toLowerCase().startsWith(prefix.toLowerCase())) {
const trimmedModel = modelValue.slice(prefix.length).trim();
if (trimmedModel) {
return `${providerValue}/${trimmedModel}`;
}
}
return `${providerValue}/${modelValue}`;
}
const slashIndex = modelValue.indexOf("/");
@@ -347,9 +354,10 @@ function handleLifecycleFallbackEvent(host: CompactionHost, payload: AgentEventP
if (summaries.length > 0) {
return summaries;
}
return parseFallbackAttempts(data.attempts).map(
(attempt) => `${attempt.provider}/${attempt.model}: ${attempt.reason}`,
);
return parseFallbackAttempts(data.attempts).map((attempt) => {
const modelRef = resolveModelLabel(attempt.provider, attempt.model);
return `${modelRef ?? `${attempt.provider}/${attempt.model}`}: ${attempt.reason}`;
});
})();
if (host.fallbackClearTimer != null) {

View File

@@ -119,9 +119,9 @@ describe("chat view", () => {
renderChat(
createProps({
fallbackStatus: {
selected: "fireworks/fireworks/minimax-m2p5",
selected: "fireworks/minimax-m2p5",
active: "deepinfra/moonshotai/Kimi-K2.5",
attempts: ["fireworks/fireworks/minimax-m2p5: rate limit"],
attempts: ["fireworks/minimax-m2p5: rate limit"],
occurredAt: 900,
},
}),
@@ -142,7 +142,7 @@ describe("chat view", () => {
renderChat(
createProps({
fallbackStatus: {
selected: "fireworks/fireworks/minimax-m2p5",
selected: "fireworks/minimax-m2p5",
active: "deepinfra/moonshotai/Kimi-K2.5",
attempts: [],
occurredAt: 0,
@@ -164,8 +164,8 @@ describe("chat view", () => {
createProps({
fallbackStatus: {
phase: "cleared",
selected: "fireworks/fireworks/minimax-m2p5",
active: "fireworks/fireworks/minimax-m2p5",
selected: "fireworks/minimax-m2p5",
active: "fireworks/minimax-m2p5",
previous: "deepinfra/moonshotai/Kimi-K2.5",
attempts: [],
occurredAt: 900,
@@ -177,7 +177,7 @@ describe("chat view", () => {
const indicator = container.querySelector(".compaction-indicator--fallback-cleared");
expect(indicator).not.toBeNull();
expect(indicator?.textContent).toContain("Fallback cleared: fireworks/fireworks/minimax-m2p5");
expect(indicator?.textContent).toContain("Fallback cleared: fireworks/minimax-m2p5");
nowSpy.mockRestore();
});