Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions gui/src/combo-workspace-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@ export interface ComboTarget {
provider: string;
model: string;
weight?: number;
/** UI-only stable key for React lists; never sent to the API. */
clientKey?: string;
}

let comboTargetKeySeq = 0;

export function newComboTarget(partial: Partial<ComboTarget> = {}): ComboTarget {
return {
provider: partial.provider ?? "",
model: partial.model ?? "",
...(partial.weight !== undefined ? { weight: partial.weight } : {}),
clientKey: partial.clientKey ?? `ct-${++comboTargetKeySeq}`,
};
}

export interface ComboItem {
Expand Down Expand Up @@ -101,7 +114,7 @@ export function parseComboList(payload: unknown): ComboItem[] {
const model = typeof tr.model === "string" ? tr.model.trim() : "";
if (!provider || !model) continue;
const weight = normalizeWeight(tr.weight);
targets.push(weight !== undefined ? { provider, model, weight } : { provider, model });
targets.push(weight !== undefined ? newComboTarget({ provider, model, weight }) : newComboTarget({ provider, model }));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep client-only keys from breaking the parser contract

Every parsed target now gains an enumerable clientKey, so the existing exact contract assertion in tests/combo-workspace-data.test.ts fails. I reproduced this with bun test tests/combo-workspace-data.test.ts: the parser test receives three unexpected clientKey properties, which means the required test suite cannot pass. Either keep the React key outside the parsed DTO/non-enumerable, or update the parser contract and its assertions if exposing this UI-only field is intentional.

AGENTS.md reference: AGENTS.md:L36-L37

Useful? React with 👍 / 👎.

}
out.push({
id,
Expand Down Expand Up @@ -275,6 +288,6 @@ export function emptyDraft(id = ""): ComboItem {
strategy: "failover",
stickyLimit: 1,
defaultEffort: null,
targets: [{ provider: "", model: "" }],
targets: [newComboTarget()],
};
}
Loading
Loading