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
29 changes: 27 additions & 2 deletions src/shared/ipc.transport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1439,9 +1439,14 @@ describe("tolerant configuration readers (#3019)", () => {
} finally { restore(); }
});

it.each(["legacy", "canonical"])("projects complete %s backend fixtures through complete APIs", async (shape) => {
it.each(["legacy", "canonical"].flatMap((shape) =>
[undefined, "cid1:literal-pair-metadata"].map((idHash) => ({ shape, idHash })),
))("projects complete $shape backend fixtures with pair hash $idHash through complete APIs", async ({ shape, idHash }) => {
const ipc = await import("./ipc");
const cell: ProfileCellConfig = { command: "--model x", enabled: true, env: { KEY: "value" }, notes: "keep" };
const cell: ProfileCellConfig = {
command: "--model x", enabled: true, env: { KEY: "value" }, notes: "keep",
...(idHash === undefined ? {} : { id_hash: idHash }),
};
const agent = { id: "a", label: "Agent", color: "blue", command: "agent --base", envs: [], isolatedHome: false };
const definition: CodingAgentDefinition = {
key: "a", label: "Agent", description: "Description", color: "blue", command: "agent --base",
Expand All @@ -1466,6 +1471,9 @@ describe("tolerant configuration readers (#3019)", () => {
fake.resolve("get_settings", response(wire));
fake.resolve("get_coding_agent_catalog", response([wireDefinition]));
fake.resolve("get_coding_agent_catalog_report", response({ ...report, catalog: [wireDefinition] }));
fake.resolve("update_settings", undefined);
fake.resolve("save_settings_draft", undefined);
fake.resolve("update_coding_agent_profiles", undefined);
const restore = ipc.__setTransportForTests(fake);
try {
const settings: SettingsSnapshot = await ipc.SettingsAPI.get();
Expand All @@ -1474,6 +1482,23 @@ describe("tolerant configuration readers (#3019)", () => {
expect(settings).toEqual(expected);
expect(catalog).toEqual([definition]);
expect(decodedReport).toEqual(report);
expect(settings.codingAgentProfiles.profilesByAgent.a.A.id_hash).toBe(idHash);
await ipc.SettingsAPI.update(settings);
await ipc.SettingsAPI.saveDraft(settings);
await expect(ipc.SettingsAPI.updateCodingAgentProfiles(settings.codingAgentProfiles)).resolves.toBeUndefined();
const sentProfiles = [
(fake.lastCall("update_settings")?.args?.newSettings as Record<string, unknown>).codingAgentProfiles,
(fake.lastCall("save_settings_draft")?.args?.draft as Record<string, unknown>).codingAgentProfiles,
fake.lastCall("update_coding_agent_profiles")?.args?.profiles,
];
const { command, ...rest } = cell;
for (const profiles of sentProfiles) {
expect(profiles).toEqual({
...expected.codingAgentProfiles,
profilesByAgent: { a: { A: { ...rest, additionalArguments: command } } },
});
}
expect(settings.codingAgentProfiles.profilesByAgent.a.A).toEqual(cell);
} finally { restore(); }
});

Expand Down
4 changes: 3 additions & 1 deletion src/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ export interface AgentBackendConfig {

export interface AgentConfig {
id: string;
/** Backend-derived from final command/envs; informational, not authority or an alternate lookup. */
/** Backend-derived legacy base command/env identity; informational, not authority or an alternate lookup. */
id_hash?: string;
label: string;
command: string;
Expand Down Expand Up @@ -565,6 +565,8 @@ export interface ProfileSlotConfig {
}

export interface ProfileCellConfig {
/** Backend-derived identity of this pair's configured baseCommand + additionalArguments/env; not authority or a lookup. */
id_hash?: string;
enabled: boolean;
command: string;
env: Record<string, string>;
Expand Down
Loading