Skip to content

armgit / mso

Public Imported from GitHub
0

Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.

fix(workflows): retain approved shared surface placements

Rahman93680b9827f1
diff --git a/docs/PROGRESS.md b/docs/PROGRESS.md
index 5ea559a7..ed2dadc1 100644
--- a/docs/PROGRESS.md
+++ b/docs/PROGRESS.md
@@ -1,3 +1,12 @@
+## 2026-09-18 — Preserve existing MCP Page approval during Workflow metadata edits
+
+The shared registry review found that a Workflow-only save replaced a previously shared
+entry with only the Workflows placement. Preserve an existing explicit MCP Page placement,
+or the legacy implicit Page approval, while adding/updating the Workflow placement. New
+and Workflow-only entries still cannot acquire Page approval through this endpoint. Repeated
+saves, prior explicit/legacy grants and refusal of caller-supplied Page escalation are tested;
+revision checks, owner review, unrelated entries and cookie-scope rejection remain intact.
+
## 2026-09-18 — Keep external editor links outside the cockpit session-cookie scope
The pending external-editor review exposed a domain-cookie leak: different origins can
diff --git a/lib/surfaces/manage.test.ts b/lib/surfaces/manage.test.ts
index d10d546f..be81ce47 100644
--- a/lib/surfaces/manage.test.ts
+++ b/lib/surfaces/manage.test.ts
@@ -19,6 +19,22 @@ describe("owner-reviewed workflow surface configuration", () => {
expect(entries[0]).toEqual(unrelated); expect(entries[1]).toMatchObject({ ...app, placements: ["workflows"] });
expect(out.revision).not.toBe(before.revision); expect((await fs.stat(file)).mode & 0o777).toBe(0o600);
});
+ it.each([undefined, ["mcp-page"], ["workflows", "mcp-page"]])("preserves prior Page approval when updating %j", async placements => {
+ await fs.writeFile(file, JSON.stringify([{ ...app, ...(placements ? { placements } : {}) }]));
+ await save({ ...app, title: "Updated editor" });
+ const saved = (await surfaceRegistrySnapshot()).apps[0];
+ expect(saved.title).toBe("Updated editor");
+ expect(saved.placements).toEqual(["workflows", "mcp-page"]);
+ await save({ ...app, title: "Updated again" });
+ expect((await surfaceRegistrySnapshot()).apps[0].placements).toEqual(["workflows", "mcp-page"]);
+ });
+ it("never adds Page approval to new or workflow-only entries", async () => {
+ await save();
+ expect((await surfaceRegistrySnapshot()).apps[0].placements).toEqual(["workflows"]);
+ await save({ ...app, title: "Only workflows" });
+ expect((await surfaceRegistrySnapshot()).apps[0].placements).toEqual(["workflows"]);
+ await expect(save({ ...app, placements: ["workflows", "mcp-page"] })).rejects.toThrow("invalid_workflow_placement");
+ });
it("rejects stale updates and concurrent lost writes", async () => {
const revision = (await surfaceRegistrySnapshot()).revision;
await save();
diff --git a/lib/surfaces/manage.ts b/lib/surfaces/manage.ts
index c4eeecd9..f236b9e2 100644
--- a/lib/surfaces/manage.ts
+++ b/lib/surfaces/manage.ts
@@ -47,7 +47,15 @@ export async function saveWorkflowSurface(input: Record<string, unknown>) {
if (!Array.isArray(entries) || entries.some((entry) => !entry || typeof entry !== "object" || Array.isArray(entry))) throw new SurfaceConfigError("invalid_existing_surface_registry", 409);
const matches = entries.filter((entry) => entry.id === selected.id);
if (matches.length > 1) throw new SurfaceConfigError("duplicate_surface_identity", 409);
- const next = matches.length ? entries.map((entry) => entry.id === selected.id ? selected : entry) : [...entries, selected];
+ const replacement = { ...selected };
+ // Missing placements is legacy Page approval; this workflow-only operation
+ // may preserve that grant but cannot create a new Page approval.
+ const existing = matches[0];
+ if (existing && (existing.placements === undefined ||
+ (Array.isArray(existing.placements) && existing.placements.includes("mcp-page")))) {
+ replacement.placements = ["workflows", "mcp-page"];
+ }
+ const next = matches.length ? entries.map((entry) => entry.id === selected.id ? replacement : entry) : [...entries, replacement];
const raw = JSON.stringify(next, null, 2) + "\n";
if (next.length > 16 || Buffer.byteLength(raw) > MAX_BYTES) throw new SurfaceConfigError("surface_registry_capacity", 409);
const file = surfaceRegistryPath(), temporary = `${file}.${randomUUID()}.tmp`;