Skip to content
Open
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
62 changes: 31 additions & 31 deletions .aoci/baseline.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": 1,
"created_at": "2026-11-19T05:53:26Z",
"updated_at": "2026-11-20T10:44:13Z",
"updated_at": "2026-11-20T13:38:12Z",
"files": {
".agents/skills/changelog-card-publish/SKILL.md": {
"role": "index",
Expand Down Expand Up @@ -773,9 +773,9 @@
},
"aoci.code.txt": {
"role": "index",
"sha256": "a8c909897c9fd56baac348d81d13888fe6a67cface1601909d50041cacd43ff7",
"size": 638265,
"normalized_sha256": "a8c909897c9fd56baac348d81d13888fe6a67cface1601909d50041cacd43ff7"
"sha256": "d3b40b8fc163405aa92f3e6f7d1abccca3e8efd7f93c282c5129282d9ac21283",
"size": 638875,
"normalized_sha256": "d3b40b8fc163405aa92f3e6f7d1abccca3e8efd7f93c282c5129282d9ac21283"
},
"aoci.meta.txt": {
"role": "index",
Expand Down Expand Up @@ -24676,9 +24676,9 @@
},
"packages/webui/src/client/features/miniapp/application/miniapp-workflows.ts": {
"role": "index",
"sha256": "1b8a1ab8af8178d756664a40fc135b5c5981464cd335e2fa406a62d53dd72974",
"size": 54343,
"normalized_sha256": "1b8a1ab8af8178d756664a40fc135b5c5981464cd335e2fa406a62d53dd72974"
"sha256": "b8919e0a18fb5117afd0e4e6c57d26990219c3ce0d5d45484723ed30812cdeba",
"size": 54643,
"normalized_sha256": "b8919e0a18fb5117afd0e4e6c57d26990219c3ce0d5d45484723ed30812cdeba"
},
"packages/webui/src/client/features/miniapp/bindings/use-miniapp-catalogue.public.ts": {
"role": "index",
Expand Down Expand Up @@ -26217,9 +26217,9 @@
},
"packages/webui/src/client/platform/event-channel.ts": {
"role": "index",
"sha256": "fae86f2709bfc7b79babb225d00591b93a8a963883b81165e41c012f690595a7",
"size": 24078,
"normalized_sha256": "fae86f2709bfc7b79babb225d00591b93a8a963883b81165e41c012f690595a7"
"sha256": "aaa819d1d116843220db7f4a9bdbb8896f565731ccff39b6cbcfada33c123b08",
"size": 24114,
"normalized_sha256": "aaa819d1d116843220db7f4a9bdbb8896f565731ccff39b6cbcfada33c123b08"
},
"packages/webui/src/client/platform/miniapp-frame-url.ts": {
"role": "index",
Expand Down Expand Up @@ -26295,9 +26295,9 @@
},
"packages/webui/src/client/platform/wire.ts": {
"role": "index",
"sha256": "8a53501fb7ce146941d81fdea485859d981e1439271be3eaecd36e509ada6cf7",
"size": 38361,
"normalized_sha256": "8a53501fb7ce146941d81fdea485859d981e1439271be3eaecd36e509ada6cf7"
"sha256": "8ee603cab0f2fdf669ffba8f74187fd57676476b18ceadfb4c888adf527567a0",
"size": 38379,
"normalized_sha256": "8ee603cab0f2fdf669ffba8f74187fd57676476b18ceadfb4c888adf527567a0"
},
"packages/webui/src/client/projection/common/context-menu.ts": {
"role": "index",
Expand Down Expand Up @@ -27908,9 +27908,9 @@
},
"packages/webui/src/server/operation/operation-dispatch.ts": {
"role": "index",
"sha256": "03c1a80198e1a7a64d1951bd0f5effabe8827a2b20e602cbd069436485c55722",
"size": 6817,
"normalized_sha256": "03c1a80198e1a7a64d1951bd0f5effabe8827a2b20e602cbd069436485c55722"
"sha256": "f069d78ac61b888848e2c6824b6ddb5c1eb3dc922c0628beb2a77e3f28c0d5cf",
"size": 7610,
"normalized_sha256": "f069d78ac61b888848e2c6824b6ddb5c1eb3dc922c0628beb2a77e3f28c0d5cf"
},
"packages/webui/src/server/operation/operations.ts": {
"role": "index",
Expand Down Expand Up @@ -28346,9 +28346,9 @@
},
"packages/webui/src/shared/envelope.ts": {
"role": "index",
"sha256": "98044229fce3336f71eedc0d377a1bc80381969a26772dd274602e89d887fe3e",
"size": 10158,
"normalized_sha256": "98044229fce3336f71eedc0d377a1bc80381969a26772dd274602e89d887fe3e"
"sha256": "2fa53f2fe61ddd8813593efd076d6187279350001f9de5a4bcd2f78c011cfe30",
"size": 10391,
"normalized_sha256": "2fa53f2fe61ddd8813593efd076d6187279350001f9de5a4bcd2f78c011cfe30"
},
"packages/webui/src/shared/operation-codecs.ts": {
"role": "index",
Expand Down Expand Up @@ -29462,9 +29462,9 @@
},
"packages/webui/test/integration/miniapp-real-flow.test.ts": {
"role": "observe",
"sha256": "b25bdbed07987d6c1538d449164a355c83145dcec1fe392965b0dee0bd0538df",
"size": 10215,
"normalized_sha256": "b25bdbed07987d6c1538d449164a355c83145dcec1fe392965b0dee0bd0538df"
"sha256": "dce9b2952cc6327ad0cd3644207fcb64d458dbcfd45fe8607bcaf3fda5c12e30",
"size": 11867,
"normalized_sha256": "dce9b2952cc6327ad0cd3644207fcb64d458dbcfd45fe8607bcaf3fda5c12e30"
},
"packages/webui/test/integration/miniapp-ui-flow.test.ts": {
"role": "observe",
Expand Down Expand Up @@ -30104,9 +30104,9 @@
},
"packages/webui/test/unit/miniapp-client-state.test.ts": {
"role": "observe",
"sha256": "5258988f815dd7da3526f29649385cd9d39a6f1ed81743f7500d3db1c90c87fc",
"size": 21759,
"normalized_sha256": "5258988f815dd7da3526f29649385cd9d39a6f1ed81743f7500d3db1c90c87fc"
"sha256": "8424fe8d741cef4115011c1cbb88a6b607621b4058f99696d7336d61a0590f5a",
"size": 22008,
"normalized_sha256": "8424fe8d741cef4115011c1cbb88a6b607621b4058f99696d7336d61a0590f5a"
},
"packages/webui/test/unit/miniapp-operations.test.ts": {
"role": "observe",
Expand Down Expand Up @@ -31100,9 +31100,9 @@
},
"packages/webui/test/unit/webui-transport-wire.test.ts": {
"role": "observe",
"sha256": "4d9e5b0ad87ad203d683b024d2c6c4c56fca16f5565e9df396ba0aee393a5362",
"size": 33999,
"normalized_sha256": "4d9e5b0ad87ad203d683b024d2c6c4c56fca16f5565e9df396ba0aee393a5362"
"sha256": "793d0ab954ed7e9c0dc897dbde379d4deb20d2c2259fb7df0227e6e8bb89b827",
"size": 34703,
"normalized_sha256": "793d0ab954ed7e9c0dc897dbde379d4deb20d2c2259fb7df0227e6e8bb89b827"
},
"packages/webui/test/unit/webui-unary-operation-typing.test.ts": {
"role": "observe",
Expand Down Expand Up @@ -31148,9 +31148,9 @@
},
"packages/webui/test/unit/webui-wire-envelope.test.ts": {
"role": "observe",
"sha256": "5b570c3d47c613becb621bc7447ca6f075aff96fa17da8a6cd7185c534f49e38",
"size": 10190,
"normalized_sha256": "5b570c3d47c613becb621bc7447ca6f075aff96fa17da8a6cd7185c534f49e38"
"sha256": "aa62fbfeba2cc0ba43bbfa9ba62d7a8a6c352dc3d0ac5d50e17d37b8e11c4228",
"size": 11014,
"normalized_sha256": "aa62fbfeba2cc0ba43bbfa9ba62d7a8a6c352dc3d0ac5d50e17d37b8e11c4228"
},
"packages/webui/test/unit/webui-workspace-archive.test.ts": {
"role": "observe",
Expand Down
10 changes: 5 additions & 5 deletions aoci.code.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4873,7 +4873,7 @@ miniapp-agent-bridge.ts[SE4L]: F:Bridges Mini App requests to agent operations.
miniapp-bridge.ts[SE4S]: F:Constructs Mini App bridge requests. | R:- | A:- | S:-
miniapp-tool-bridge.ts[SE4T]: F:Bridges Mini App tool calls through the client tool port. | R:- | A:- | S:-
miniapp-window-bridge.ts[SE4T]: F:Defines Mini App window request messages and bridges window operations. | R:- | A:- | S:-
miniapp-workflows.ts[SE4L]: F:Coordinates Mini App workflows through a client port slice. | R:- | A:- | S:-
miniapp-workflows.ts[SE4L]: F:Coordinates Mini App workflows and maps preparation refusal details to client state. | R:code:packages/webui/src/shared/envelope.ts | A:- | S:Only a preparation failure with OWNED_ELSEWHERE is promoted to the takeover refusal code.

===/<repository>/packages/webui/src/client/features/miniapp/bindings/===
use-miniapp-catalogue.public.ts[SE4T]: F:Exposes Mini App catalogue summaries to React consumers. | R:- | A:- | S:-
Expand Down Expand Up @@ -5250,7 +5250,7 @@ app-mode.ts[SE4T]: F:Defines coding and work application modes. | R:- | A:- | S:
browser-auto-open.ts[SE4T]: F:Persists the browser auto-open preference. | R:- | A:- | S:-
browser-dom.ts[SE4L]: F:Provides browser drawing helpers and exports canvas and image types. | R:- | A:- | S:-
connection-health.ts[SE4S]: F:Provides connection health helpers including unref for timers. | R:- | A:- | S:-
event-channel.ts[SE4L]: F:Adapts and exposes client event watching for the browser. | R:- | A:- | S:-
event-channel.ts[SE4L]: F:Defines WebUI socket and wire frame contracts, including optional refusal reason codes, and adapts event watching. | R:code:packages/webui/src/shared/envelope.ts | A:- | S:-
miniapp-frame-url.ts[SE4T]: F:Builds the URL for a Mini App frame. | R:- | A:- | S:-
no-project.ts[SE4T]: F:Recognizes the flag for a session without a project. | R:- | A:- | S:-
page-host.ts[SE4T]: F:Reads the hostname of the hosting page. | R:- | A:- | S:-
Expand All @@ -5263,7 +5263,7 @@ team-mode.ts[SE4T]: F:Models and resolves team mode for sessions. | R:- | A:- |
transport-origin.ts[SE4T]: F:Converts WebSocket URLs to HTTP transport origins. | R:- | A:- | S:-
transport.ts[SE4L]: F:Implements the browser transport over the WebUI wire. | R:- | A:- | S:-
webui-shutdown.ts[SE4T]: F:Requests WebUI service shutdown and reports refusals. | R:- | A:- | S:-
wire.ts[SE4L]: F:Defines and implements the WebSocket wire and its options. | R:- | A:- | S:-
wire.ts[SE4L]: F:Manages the browser WebSocket wire and preserves refusal codes when rejecting a pending request. | R:code:packages/webui/src/shared/envelope.ts | A:- | S:-

===/<repository>/packages/webui/src/client/projection/common/===
context-menu.ts[SE4T]: F:Places browser context menus relative to the viewport. | R:- | A:- | S:-
Expand Down Expand Up @@ -5560,7 +5560,7 @@ messages.ts[SE4S]: F:Defines message history retrieval. | R:- | A:- | S:-
miniapp-agent.ts[SE4S]: F:Defines Mini App agent turn operations. | R:- | A:- | S:-
miniapp.ts[SE4M]: F:Defines Mini App catalogue and runtime operations. | R:- | A:- | S:-
operation-contract.ts[SE4S]: F:Defines server operation and context contracts. | R:- | A:- | S:-
operation-dispatch.ts[SE4M]: F:Dispatches WebUI transport frames to operations. | R:- | A:- | S:-
operation-dispatch.ts[SE4M]: F:Dispatches WebUI frames and carries validated Mini App preparation refusal reasons back to the caller. | R:code:packages/webui/src/shared/envelope.ts | A:- | S:Surfaces reasonCode only for open Mini App preparation failures, using a bounded uppercase identifier.
operations.ts[SE4L]: F:Exports the server operation catalogue. | R:- | A:- | S:-
permission-mode.ts[SE4T]: F:Defines permission mode operations. | R:- | A:- | S:-
personalization.ts[SE4T]: F:Defines personalization and global instructions operations. | R:- | A:- | S:-
Expand Down Expand Up @@ -5598,7 +5598,7 @@ usage.ts[SE4T]: F:Projects turn usage and identifies compaction messages. | R:-
account-legal-links.ts[SE4T]: F:Resolves account legal links by scope. | R:- | A:- | S:-
capability-manifest.ts[SE4M]: F:Enumerates capabilities exposed by the WebUI. | R:- | A:- | S:-
design-input.ts[SE4T]: F:Validates Design input and caps media bytes. | R:- | A:- | S:-
envelope.ts[SE4M]: F:Defines the versioned WebUI transport envelope. | R:- | A:- | S:-
envelope.ts[SE4M]: F:Defines and decodes versioned WebUI frames and request errors with an optional refusal reason. | R:- | A:WebuiWireError,decodeWebuiServerFrame | S:-
operation-codecs.ts[SE4M]: F:Defines result codecs for WebUI operations. | R:- | A:- | S:-
operation-names.ts[SE4L]: F:Enumerates operation names used by the WebUI protocol. | R:- | A:- | S:-
plugin-management.ts[SE4T]: F:Defines plugin management action payloads. | R:- | A:- | S:-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,13 @@ function refusalOf(error: unknown): WebuiMiniAppRefusal {
error && typeof error === "object" && typeof (error as { code?: unknown }).code === "string"
? ((error as { code: string }).code)
: "harness_error";
const message = error instanceof Error ? error.message : String(error);
const reasonCode = code === "MINIAPP_PREPARATION_FAILED" && error instanceof Error
? (error as { reasonCode?: unknown }).reasonCode
: undefined;
return {
code,
message: error instanceof Error ? error.message : String(error),
code: reasonCode === "OWNED_ELSEWHERE" ? reasonCode : code,
message: typeof reasonCode === "string" ? `${message} (${reasonCode})` : message,
};
}

Expand Down
1 change: 1 addition & 0 deletions packages/webui/src/client/platform/event-channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export type WireFrame =
readonly requestId: string;
readonly code: WebuiWireErrorCode;
readonly message: string;
readonly reasonCode?: string;
};

export interface WebuiSocket {
Expand Down
2 changes: 1 addition & 1 deletion packages/webui/src/client/platform/wire.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ export function createWebuiWire({
// stable code intact instead of turning every refusal into one shape.
fail(
session,
new WebuiWireError(frame.code, frame.message, frame.requestId),
new WebuiWireError(frame.code, frame.message, frame.requestId, frame.reasonCode),
);
return;
}
Expand Down
17 changes: 16 additions & 1 deletion packages/webui/src/server/operation/operation-dispatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
type WebuiWireErrorCode,
} from "../../shared/envelope.js";
import type { WebuiOperationRegistryEntry } from "./operations.js";
import { OPEN_MINI_APP_OPERATION_NAME } from "../../shared/operation-names.js";

/**
* The stable code a thrown failure carries, if it names one.
Expand Down Expand Up @@ -150,11 +151,23 @@ export async function dispatchWebuiFrame(
sendFrame(ws, responseFrame(parsed.requestId, result.body));
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
const code = stableCodeOf(error);
const miniAppPreparationFailed = parsed.operation === OPEN_MINI_APP_OPERATION_NAME &&
code === "MINIAPP_PREPARATION_FAILED";
let reasonCode: string | undefined;
if (miniAppPreparationFailed) {
const reason = (error as { reasonCode?: unknown }).reasonCode ??
(error instanceof Error ? stableCodeOf(error.cause) : undefined);
if (typeof reason === "string" && /^[A-Z][A-Z0-9_]{0,63}$/u.test(reason)) {
reasonCode = reason;
}
console.warn("[webui] Mini App publication preparation failed", { code, reasonCode });
}
// The capability's own stable code is preserved; only a failure that names
// no code at all becomes `harness_error`.
sendFrame(
ws,
errorFrame(parsed.requestId, stableCodeOf(error), message),
errorFrame(parsed.requestId, code, message, reasonCode),
);
}
}
Expand Down Expand Up @@ -201,12 +214,14 @@ export function errorFrame(
requestId: string,
code: string,
message: string,
reasonCode?: string,
): WebuiErrorFrame {
return {
protocolVersion: WEBUI_PROTOCOL_VERSION,
kind: "error",
requestId,
code,
message,
...(reasonCode !== undefined ? { reasonCode } : {}),
};
}
5 changes: 5 additions & 0 deletions packages/webui/src/shared/envelope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export interface WebuiErrorFrame {
readonly requestId: string;
readonly code: string;
readonly message: string;
readonly reasonCode?: string;
}

export interface WebuiEventFrame {
Expand Down Expand Up @@ -218,6 +219,7 @@ export function decodeWebuiServerFrame(text: string): WebuiFrameDecode {
requestId: candidate.requestId,
code: candidate.code,
message: candidate.message,
...(typeof candidate.reasonCode === "string" ? { reasonCode: candidate.reasonCode } : {}),
},
};
}
Expand Down Expand Up @@ -245,16 +247,19 @@ export class WebuiWireError extends Error {
readonly code: WebuiWireErrorCode;
/** The request this refusal answers, or {@link WEBUI_ANONYMOUS_REQUEST_ID} for one that could not be attributed. */
readonly requestId: string;
readonly reasonCode: string | undefined;

constructor(
code: WebuiWireErrorCode,
message: string,
requestId: string = WEBUI_ANONYMOUS_REQUEST_ID,
reasonCode?: string,
) {
super(message);
this.name = "WebuiWireError";
this.code = code;
this.requestId = requestId;
this.reasonCode = reasonCode;
}
}

Expand Down
38 changes: 38 additions & 0 deletions packages/webui/test/integration/miniapp-real-flow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@
// is `miniapp-ui-flow.test.ts`. The data directory is a temporary one, so a
// run can never reach the operator's own `~/.minimax`.

import { mkdir } from "node:fs/promises";
import { join } from "node:path";
import { afterEach, describe, expect, it } from "vitest";
import { acquireMiniAppOwner } from "../../../local-runtime-v2/src/service/miniapp/process/node-runtime/owner-lease.js";

import {
LOCAL_SOURCE,
Expand Down Expand Up @@ -135,6 +138,40 @@ describe("the Mini App business flow against the real host", () => {
expect(rowsOf(await client.call("listMiniApps"))).toEqual([]);
}, 60_000);

it("reports another client's ownership and opens after that client releases the lease", async () => {
const host = await bootRealHost();
const client = await connect(host.url);
const name = "ownership-flow.miniapp";
await publishLocalPackage(host.dataDir, name);
expectAnswered(await client.call("pluginManagement", {
action: "enablePlugin",
input: { pluginName: name, source: LOCAL_SOURCE },
}));
const pluginDataDir = join(host.dataDir, "v2", "plugin-data", "liveboards", name);
await mkdir(pluginDataDir, { recursive: true });
const owner = await acquireMiniAppOwner({
pluginDataDir,
pluginId: name,
identity: { client: "desktop" },
});
if (owner.kind !== "acquired") throw new Error("The fixture could not acquire the ownership lease");
try {
const refused = await client.call("openMiniApp", { pluginId: name });
expect(refused).toMatchObject({
kind: "error",
code: "MINIAPP_PREPARATION_FAILED",
reasonCode: "OWNED_ELSEWHERE",
});
} finally {
await owner.release();
}
const opened = await client.call("openMiniApp", { pluginId: name });
expectAnswered(opened);
const page = await fetch(String(bodyOf(opened).viewUrl));
expect(page.status).toBe(200);
expect(await page.text()).toContain(PAGE_MARKER);
}, 120_000);

it("keeps a Mini App that failed to start out of the running set", async () => {
const host = await bootRealHost();
const client = await connect(host.url);
Expand All @@ -161,6 +198,7 @@ describe("the Mini App business flow against the real host", () => {
// person has to act on: the entry refused to start.
const cause = await openCause(host, name);
expect(cause.join(" <- ")).toContain("RUNNER_START_FAILED");
expect(opened.reasonCode, cause.join(" <- ")).toBe("RUNNER_START_FAILED");

// And the Mini App is not left claiming to be running: the row says the
// start failed, and names the reason, instead of reading as a Mini App
Expand Down
Loading
Loading