mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-05 16:04:43 +00:00
fix(server): a plugin provider's reported options are stored like any provider's
A control's `defaultValue` only says what the control shows for a key with no value. Opening and applying store every option the session reports, defaults and values nobody set included, as built-in providers do; the special case that left a value at the default unset is removed.
This commit is contained in:
@@ -1148,12 +1148,10 @@ describe("PluginAgentClientRegistry", () => {
|
||||
await session.close();
|
||||
});
|
||||
|
||||
test("options the plugin opened with that nobody set are in the open patch, unless they are the control's default", async () => {
|
||||
test("options the plugin opened with that nobody set are in the open patch, defaults included", async () => {
|
||||
const { session, events } = await openStubbornVoiceSession({});
|
||||
|
||||
expect(session.openOptionsPatch).toEqual(
|
||||
shape === "controls" ? {} : { voice: "direct", loud: false },
|
||||
);
|
||||
expect(session.openOptionsPatch).toEqual({ voice: "direct", loud: false });
|
||||
expect(eventsOfType(events, "options_changed")).toEqual([]);
|
||||
await session.close();
|
||||
});
|
||||
@@ -1181,8 +1179,8 @@ describe("PluginAgentClientRegistry", () => {
|
||||
expect(lastConfigure(harness.inputs)).toMatchObject({
|
||||
changes: { providerOptions: { loud: null } },
|
||||
});
|
||||
// It went back to its default; only a plugin without a declared default pins that value.
|
||||
expect(ended).toEqual(shape === "controls" ? {} : { loud: false });
|
||||
// It went back to its default, and what it ended up with is reported like any provider's.
|
||||
expect(ended).toEqual({ loud: false });
|
||||
await session.close();
|
||||
});
|
||||
|
||||
|
||||
@@ -1639,19 +1639,11 @@ class PluginAgentSession implements AgentSession {
|
||||
return readPluginOptionState(this.bridge.config).options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options whose value differs from `known`: the plugin's own change or its opening state. A key
|
||||
* with no value in `known` that the plugin reports at its control's declared default stays
|
||||
* unset, so the agent follows the default instead of pinning it.
|
||||
*/
|
||||
/** Options whose value differs from `known`: the plugin's own change or its opening state. */
|
||||
private optionDifferences(known: Readonly<Record<string, JsonValue>>): Record<string, JsonValue> {
|
||||
const { controls, options } = readPluginOptionState(this.bridge.config);
|
||||
const patch: Record<string, JsonValue> = {};
|
||||
for (const [id, value] of Object.entries(options)) {
|
||||
if (isDeepStrictEqual(known[id], value)) continue;
|
||||
const control = controls.find((candidate) => candidate.key === id);
|
||||
if (known[id] == null && control?.defaultValue === value) continue;
|
||||
patch[id] = value;
|
||||
for (const [id, value] of Object.entries(this.currentOptions())) {
|
||||
if (!isDeepStrictEqual(known[id], value)) patch[id] = value;
|
||||
}
|
||||
return patch;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user