fix: persist subsessions setting

This commit is contained in:
Federico Jaramillo Martinez
2026-06-18 22:17:56 +02:00
parent d93110135b
commit 27bc924d4c
3 changed files with 12 additions and 2 deletions
@@ -0,0 +1,5 @@
---
"@jmfederico/pi-web": patch
---
Persist the Settings → Session daemon tracked subsessions toggle so it remains enabled after restart.
+2 -2
View File
@@ -37,11 +37,11 @@ describe("config routes", () => {
const response = await app.inject({
method: "PUT",
url: "/api/config",
payload: { config: { host: "0.0.0.0", port: 9000, allowedHosts: true, spawnSessions: true, shortcuts: { "core:view.chat": "mod+1", "core:session.stop": null }, plugins: { info: { enabled: false, settings: { note: "hidden" } } } } },
payload: { config: { host: "0.0.0.0", port: 9000, allowedHosts: true, spawnSessions: true, subsessions: true, shortcuts: { "core:view.chat": "mod+1", "core:session.stop": null }, plugins: { info: { enabled: false, settings: { note: "hidden" } } } } },
});
expect(response.statusCode).toBe(200);
expect(savedConfig).toEqual({ host: "0.0.0.0", port: 9000, allowedHosts: true, spawnSessions: true, shortcuts: { "core:view.chat": "mod+1", "core:session.stop": null }, plugins: { info: { enabled: false, settings: { note: "hidden" } } } });
expect(savedConfig).toEqual({ host: "0.0.0.0", port: 9000, allowedHosts: true, spawnSessions: true, subsessions: true, shortcuts: { "core:view.chat": "mod+1", "core:session.stop": null }, plugins: { info: { enabled: false, settings: { note: "hidden" } } } });
expect(response.json<PiWebConfigResponse>().config).toEqual(savedConfig);
});
+5
View File
@@ -59,6 +59,7 @@ function parseConfigRequest(value: unknown): PiWebConfig {
const shortcuts = value["shortcuts"];
const plugins = value["plugins"];
const spawnSessions = value["spawnSessions"];
const subsessions = value["subsessions"];
if (host !== undefined) {
if (typeof host !== "string") throw new Error("PI WEB config host must be a string");
config.host = host;
@@ -74,6 +75,10 @@ function parseConfigRequest(value: unknown): PiWebConfig {
if (typeof spawnSessions !== "boolean") throw new Error("PI WEB config spawnSessions must be a boolean");
config.spawnSessions = spawnSessions;
}
if (subsessions !== undefined) {
if (typeof subsessions !== "boolean") throw new Error("PI WEB config subsessions must be a boolean");
config.subsessions = subsessions;
}
return config;
}