diff --git a/.aoci/baseline.json b/.aoci/baseline.json index aa1370f37..23109986a 100644 --- a/.aoci/baseline.json +++ b/.aoci/baseline.json @@ -1,7 +1,7 @@ { "version": 1, "created_at": "2026-11-19T05:53:26Z", - "updated_at": "2026-11-20T13:38:12Z", + "updated_at": "2026-11-20T13:38:55Z", "files": { ".agents/skills/changelog-card-publish/SKILL.md": { "role": "index", @@ -773,9 +773,9 @@ }, "aoci.code.txt": { "role": "index", - "sha256": "d3b40b8fc163405aa92f3e6f7d1abccca3e8efd7f93c282c5129282d9ac21283", - "size": 638875, - "normalized_sha256": "d3b40b8fc163405aa92f3e6f7d1abccca3e8efd7f93c282c5129282d9ac21283" + "sha256": "490837ea440b1661fd7cb6b706c0e1158a4812ce96b0c97bf1bb7f984883d666", + "size": 639503, + "normalized_sha256": "490837ea440b1661fd7cb6b706c0e1158a4812ce96b0c97bf1bb7f984883d666" }, "aoci.meta.txt": { "role": "index", @@ -22776,9 +22776,9 @@ }, "packages/webui/docs/adr/0020-webui-miniapp-view-and-runtime-seams.md": { "role": "index", - "sha256": "093af098f08ab1b753765ab02fb31fd824c2326671c989e735f976fb0c174c39", - "size": 33062, - "normalized_sha256": "093af098f08ab1b753765ab02fb31fd824c2326671c989e735f976fb0c174c39" + "sha256": "409c416b5be1718e641d0e74d9fd5aad809487af903f31422afa9cdea9976ab4", + "size": 33570, + "normalized_sha256": "409c416b5be1718e641d0e74d9fd5aad809487af903f31422afa9cdea9976ab4" }, "packages/webui/docs/adr/0021-webui-model-picker-is-one-popup-with-two-states.md": { "role": "index", @@ -24676,9 +24676,9 @@ }, "packages/webui/src/client/features/miniapp/application/miniapp-workflows.ts": { "role": "index", - "sha256": "b8919e0a18fb5117afd0e4e6c57d26990219c3ce0d5d45484723ed30812cdeba", - "size": 54643, - "normalized_sha256": "b8919e0a18fb5117afd0e4e6c57d26990219c3ce0d5d45484723ed30812cdeba" + "sha256": "a10f4aba499ea4b0a04224fa66c5df936a60c25aafbbb4cbc5a5083f314dfa08", + "size": 54881, + "normalized_sha256": "a10f4aba499ea4b0a04224fa66c5df936a60c25aafbbb4cbc5a5083f314dfa08" }, "packages/webui/src/client/features/miniapp/bindings/use-miniapp-catalogue.public.ts": { "role": "index", @@ -24730,9 +24730,9 @@ }, "packages/webui/src/client/features/miniapp/ui/MiniAppView.public.tsx": { "role": "index", - "sha256": "10676230ea9092b22d32182402847b42964e129f6ebc8a0a689df1bafc6030d1", - "size": 32714, - "normalized_sha256": "10676230ea9092b22d32182402847b42964e129f6ebc8a0a689df1bafc6030d1" + "sha256": "308de7796f998b2e817e0696127cfd913baf69b8779431d9ae4b5d57b10d27a5", + "size": 33586, + "normalized_sha256": "308de7796f998b2e817e0696127cfd913baf69b8779431d9ae4b5d57b10d27a5" }, "packages/webui/src/client/features/models/application/models-workflows.ts": { "role": "index", @@ -28514,9 +28514,9 @@ }, "packages/webui/test/browser/fixture.mjs": { "role": "index", - "sha256": "1651e894fe6cb84888fae9f57dd88aa7a9295d2cd15f62365dd10710fdcc198e", - "size": 53680, - "normalized_sha256": "1651e894fe6cb84888fae9f57dd88aa7a9295d2cd15f62365dd10710fdcc198e" + "sha256": "1586e6f5a983eebf111eedd5cf3dbec5378e1396c04d48cd5ded9d3d96423cce", + "size": 53704, + "normalized_sha256": "1586e6f5a983eebf111eedd5cf3dbec5378e1396c04d48cd5ded9d3d96423cce" }, "packages/webui/test/browser/fonts/LICENSE.noto-fonts": { "role": "observe", @@ -28554,9 +28554,9 @@ }, "packages/webui/test/browser/miniapp-standalone-tab.spec.mjs": { "role": "index", - "sha256": "44b91da6c1676f6f2d8ffd626107b0f1a7a7fb83fcbb93eb483ef39d4a73c2a1", - "size": 8332, - "normalized_sha256": "44b91da6c1676f6f2d8ffd626107b0f1a7a7fb83fcbb93eb483ef39d4a73c2a1" + "sha256": "8140b9faa509494c1c8d7a8d095b44be24c3a0b2bbd5e5e012a1cd463f1f3251", + "size": 11052, + "normalized_sha256": "8140b9faa509494c1c8d7a8d095b44be24c3a0b2bbd5e5e012a1cd463f1f3251" }, "packages/webui/test/browser/model-picker-interactions.spec.mjs": { "role": "index", @@ -30104,9 +30104,9 @@ }, "packages/webui/test/unit/miniapp-client-state.test.ts": { "role": "observe", - "sha256": "8424fe8d741cef4115011c1cbb88a6b607621b4058f99696d7336d61a0590f5a", - "size": 22008, - "normalized_sha256": "8424fe8d741cef4115011c1cbb88a6b607621b4058f99696d7336d61a0590f5a" + "sha256": "502777dedaca3f81aaf417795345a70275691673e1ada0a57df66569b277fc26", + "size": 22029, + "normalized_sha256": "502777dedaca3f81aaf417795345a70275691673e1ada0a57df66569b277fc26" }, "packages/webui/test/unit/miniapp-operations.test.ts": { "role": "observe", @@ -30146,9 +30146,9 @@ }, "packages/webui/test/unit/miniapp-surfaces.test.tsx": { "role": "observe", - "sha256": "bc8ea9a79cfed05ec6d2dded05d60c6e2a513e9151e76d252459896864b2dc56", - "size": 44761, - "normalized_sha256": "bc8ea9a79cfed05ec6d2dded05d60c6e2a513e9151e76d252459896864b2dc56" + "sha256": "e7e3254a7a8a5d2d512c5f9e15954b2452884f22692c70ab290457ea809d6cd9", + "size": 46943, + "normalized_sha256": "e7e3254a7a8a5d2d512c5f9e15954b2452884f22692c70ab290457ea809d6cd9" }, "packages/webui/test/unit/miniapp-tool-approvals.test.tsx": { "role": "observe", @@ -31640,9 +31640,9 @@ }, "scripts/lib/webui-presentation-inventory.json": { "role": "index", - "sha256": "a5d9d9cd5417f0c33c361343c1e06c7ef199882e716158a48e10af418f9ebe25", + "sha256": "b030576cd28af7ccb7605cd462d763f45a063929381d0e728620722fe933f634", "size": 56142, - "normalized_sha256": "a5d9d9cd5417f0c33c361343c1e06c7ef199882e716158a48e10af418f9ebe25" + "normalized_sha256": "b030576cd28af7ccb7605cd462d763f45a063929381d0e728620722fe933f634" }, "scripts/lib/webui-publication.d.mts": { "role": "index", diff --git a/aoci.code.txt b/aoci.code.txt index 5ffb0f3b2..54b7db287 100644 --- a/aoci.code.txt +++ b/aoci.code.txt @@ -4541,7 +4541,7 @@ releasing.md[SE4T]: F:Documents publication of the WebUI npm package. | R:- | A: 0017-webui-fences-resource-results-and-separates-delivery-from-execution.md[SE4T]: F:Defines resource result fences and separates delivery from execution settlement. | R:- | A:- | S:- 0018-webui-business-cohesion-owners-and-measured-observation.md[SE4T]: F:Defines single business ownership and submission paths and evidence requirements for observation. | R:- | A:- | S:- 0019-webui-browser-use-surfaces-and-external-browser-bridge.md[SE4L]: F:Documents Browser Use surfaces, extension distribution, and external browser bridging. | R:- | A:- | S:- -0020-webui-miniapp-view-and-runtime-seams.md[SE4L]: F:Defines WebUI Mini App browser hosting and presentation boundaries. | R:- | A:- | S:- +0020-webui-miniapp-view-and-runtime-seams.md[SE4L]: F:Defines WebUI Mini App runtime, hosting and presentation boundaries. | R:code:packages/webui/src/client/features/miniapp/application/miniapp-workflows.ts | A:- | S:An explicit retry uses ordinary open. Polling does not restart failed presentations. 0021-webui-model-picker-is-one-popup-with-two-states.md[SE4T]: F:Combines provider and model selection into two states in one popup. | R:- | A:- | S:- 0022-webui-workspace-panel-is-a-browser-tab-strip.md[SE4M]: F:Models the WebUI workspace panel as a browser-style tab strip. | R:- | A:- | S:- 0023-webui-test-coverage-follows-user-workflows-and-evidence-levels.md[SE4S]: F:Defines WebUI workflow test coverage and evidence levels. | R:- | A:- | S:- @@ -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 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. +miniapp-workflows.ts[SE4L]: F:Coordinates Mini App workflows and retains preparation refusals for explicit recovery. | R:code:packages/webui/src/shared/envelope.ts | A:- | S:Retain failed presentation independently of the toast. Polling must not retry failed starts. ===//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:- @@ -4890,7 +4890,7 @@ MiniAppAppsList.public.tsx[SE4M]: F:Lists installed plugins that expose Mini App MiniAppPicker.public.tsx[SE4M]: F:Renders the Mini App launcher for a session. | R:- | A:- | S:- MiniAppStandalone.public.tsx[SE4S]: F:Hosts standalone Mini App presentation. | R:- | A:- | S:- MiniAppToolApprovals.public.tsx[SE4T]: F:Renders approval controls for Mini App tool calls. | R:- | A:- | S:- -MiniAppView.public.tsx[SE4L]: F:Renders Mini Apps inline or as standalone surfaces. | R:- | A:- | S:- +MiniAppView.public.tsx[SE4L]: F:Renders inline and standalone Mini App views and persistent start recovery. | R:code:packages/webui/src/client/features/miniapp/application/miniapp-workflows.ts | A:MiniAppView | S:Only OWNED_ELSEWHERE asks the user to close another client. ===//packages/webui/src/client/features/models/application/=== models-workflows.ts[SE4L]: F:Coordinates WebUI model workflows through a client port slice. | R:- | A:- | S:- @@ -5680,11 +5680,11 @@ context-usage-ring.spec.mjs[SE4M]: F:Tests context usage ring rendering from run dropdown-dismissal.spec.mjs[SE4T]: F:Tests dismissal of WebUI dropdowns through their triggers. | R:- | A:- | S:- feedback.spec.mjs[SE4S]: F:Tests accessible field error feedback. | R:- | A:- | S:- field-contract.spec.mjs[SE4S]: F:Tests that form controls have accessible names. | R:- | A:- | S:- -fixture.mjs[SE4L]: F:Installs the browser fixture transport. | R:- | A:- | S:- +fixture.mjs[SE4L]: F:Installs the browser fixture transport and supports named Mini App refusal reasons. | R:- | A:- | S:- goal-retention.spec.mjs[SE4S]: F:Tests retention of session goal state during a pending refresh. | R:- | A:- | S:- harness.mjs[TQ4M]: F:Provides built-client browser fixtures, readiness checks and failure artifacts. | R:code:playwright.config.mjs,code:packages/webui/test/browser/server.mjs | A:openApp, waitForLocalImages | S:Assert the synchronously injected server ID after navigation without polling. Windows buffer errors trigger a bounded TCP census; image evidence omits URL queries. miniapp-panel.spec.mjs[SE4L]: F:Tests Mini App launcher refresh behavior. | R:- | A:- | S:- -miniapp-standalone-tab.spec.mjs[SE4S]: F:Tests promotion of inline Mini Apps to standalone tabs. | R:- | A:- | S:- +miniapp-standalone-tab.spec.mjs[SE4M]: F:Exercises standalone Mini App presentation and explicit retry after preparation refusal. | R:code:packages/webui/test/browser/fixture.mjs | A:- | S:Verifies the failed view persists after toast dismissal. model-picker-interactions.spec.mjs[SE4M]: F:Tests model picker interactions and display of the selected model. | R:- | A:- | S:- motion.spec.mjs[SE4S]: F:Tests shared WebUI motion contracts. | R:- | A:- | S:- native-design-tasks.spec.mjs[TB6L]: F:Exercises native Design node runs, reference understanding, authenticated media and cancellation through the browser. | R:code:packages/webui/test/browser/support/native-design-browser-host.ts | A:- | S:Wait for the connected image reference to render after an out-of-band setup write before triggering the slow understanding run. Preserve provider and host evidence for uncompleted runs. @@ -5838,7 +5838,7 @@ webui-font-environment.mjs[SE4S]: F:Configures the font environment used for Web webui-overlay-inventory.json[SE4S]: F:Inventories overlays covered by WebUI checks. | R:- | A:- | S:- webui-presentation-coverage.d.mts[SE4S]: F:Declares the shared presentation coverage API. | R:- | A:- | S:- webui-presentation-coverage.mjs[SE4L]: F:Calculates coverage of shared WebUI presentation contracts. | R:- | A:- | S:- -webui-presentation-inventory.json[SE4M]: F:Inventories WebUI presentation surfaces. | R:- | A:- | S:- +webui-presentation-inventory.json[SE4M]: F:Records classified WebUI presentation surfaces and their reviewed content digests. | R:code:packages/webui/src/client/features/miniapp/ui/MiniAppView.public.tsx | A:- | S:- webui-publication.d.mts[SE4S]: F:Declares helpers for WebUI package publication. | R:- | A:- | S:- webui-publication.mjs[SE4M]: F:Implements validation and preparation for WebUI publication. | R:- | A:- | S:- webui-raw-control-budget.json[SE4T]: F:Tracks allowances for raw WebUI controls. | R:- | A:- | S:- diff --git a/packages/webui/docs/adr/0020-webui-miniapp-view-and-runtime-seams.md b/packages/webui/docs/adr/0020-webui-miniapp-view-and-runtime-seams.md index 326e9dddb..b8b10897f 100644 --- a/packages/webui/docs/adr/0020-webui-miniapp-view-and-runtime-seams.md +++ b/packages/webui/docs/adr/0020-webui-miniapp-view-and-runtime-seams.md @@ -326,6 +326,13 @@ An absent session is reported as `none`; no session lookup or ended-session noti A runtime that stops while the tab is open clears the view and reports the stop reason; it does not restart the Mini App, because the tab may be unattended and a retry would start work the user did not ask for. A retry is a user action. +A failed start leaves an actionable “not opened” state in the mounted view, alongside the +attempt's error toast. Dismissing the toast does not remove the state or its explicit retry +control. Only an `OWNED_ELSEWHERE` refusal tells the user to close the other client's app; +a generic preparation failure does not establish ownership. Retry uses the normal open +operation, never a takeover, and polling does not restart a failed presentation. Stop or +lease failures do not create this failed-start state. + ### The standalone presentation is a lease diff --git a/packages/webui/src/client/features/miniapp/application/miniapp-workflows.ts b/packages/webui/src/client/features/miniapp/application/miniapp-workflows.ts index 683ffb2e3..128731aa3 100644 --- a/packages/webui/src/client/features/miniapp/application/miniapp-workflows.ts +++ b/packages/webui/src/client/features/miniapp/application/miniapp-workflows.ts @@ -81,10 +81,12 @@ const MINIAPP_PRESENTATION_RECONNECT_GRACE_MS = 300; * `open` carries the proxy's view URL and nothing else — not the Mini App's * origin, not its surface path, not the credential its guard demands. `stopped` * is a cleared view that remembers why, which is what the panel renders instead - * of a dead frame. + * of a dead frame. `failed` retains an unsuccessful start until the person + * retries; a stop or lease failure cannot create that state. */ export type WebuiMiniAppPresentation = | { readonly kind: "opening" } + | { readonly kind: "failed"; readonly refusal: WebuiMiniAppRefusal } | { readonly kind: "open"; readonly viewUrl: string; @@ -667,7 +669,7 @@ export function createWebuiMiniAppWorkflows(deps: { } catch (error) { if (!isCurrent()) return false; const refusal = refusalOf(error); - setPresentation(pluginId, undefined); + setPresentation(pluginId, { kind: "failed", refusal }); setRefusal(pluginId, refusal); // The runtime refused to start, so the row it refused about is stale: a // capacity refusal names the running apps, and those names come from here. @@ -877,7 +879,7 @@ export function createWebuiMiniAppWorkflows(deps: { const existing = current.presentations[pluginId]; if (existing?.kind === "opening") return "presented"; // A cleared presentation or a refusal is the person's to retry, never a timer's. - if (existing?.kind === "stopped" || current.refusals[pluginId] !== undefined) return "blocked"; + if (existing?.kind === "stopped" || existing?.kind === "failed" || current.refusals[pluginId] !== undefined) return "blocked"; let catalogue: WebuiMiniAppCatalogue | undefined; try { catalogue = observed ? observed.catalogue : await readCatalogue(); diff --git a/packages/webui/src/client/features/miniapp/ui/MiniAppView.public.tsx b/packages/webui/src/client/features/miniapp/ui/MiniAppView.public.tsx index 27f0621be..6a8e7b3c2 100644 --- a/packages/webui/src/client/features/miniapp/ui/MiniAppView.public.tsx +++ b/packages/webui/src/client/features/miniapp/ui/MiniAppView.public.tsx @@ -80,7 +80,7 @@ import { import { sessionHash } from "../../../projection/common/router.js"; import { FeedbackLiveRegion } from "../../../ui/feedback.js"; import { useWebuiToastError } from "../../../ui/toast.js"; -import { WebuiIconButton } from "../../../ui/button.js"; +import { WebuiButton, WebuiIconButton } from "../../../ui/button.js"; import { WebuiSkeletonProjection } from "../../../ui/page.js"; import { FeedbackEmpty } from "../../../ui/feedback.js"; import { @@ -739,6 +739,23 @@ export function MiniAppView({ ) : null} + {presentation?.kind === "failed" && !detached ? ( + // The toast reports the attempt; this state remains until another + // explicit open succeeds. Polling must never restart a failed app. +
+ workflows?.open(pluginId)} + >重试打开应用} + /> +
+ ) : null} {detached ? (
{ + ${refusal ? `window.__fixture.refuseOperation("openMiniApp", ${JSON.stringify(refusal.code)}, ${JSON.stringify(refusal.message)}, ${JSON.stringify(refusal.reasonCode)});` : ""} window.__fixture.setResponse("listMiniApps", { miniApps: [${JSON.stringify(catalogueRow(false, 0))}], }); @@ -191,3 +192,50 @@ test("a deep link naming a session that has ended still shows the Mini App", asy // Still no way back inline. await expect(page.getByTestId("miniapp-switch-standalone")).toHaveCount(0); }); + +for (const [code, message, reasonCode] of [ + ["MINIAPP_PREPARATION_FAILED", "Mini App publication preparation failed"], + ["OWNED_ELSEWHERE", "Mini App is running in another client"], + ["MINIAPP_PREPARATION_FAILED", "Mini App publication preparation failed", "OWNED_ELSEWHERE"], +]) { + test(`a standalone start refusal stays actionable and an explicit retry recovers (${code}${reasonCode ? "/" + reasonCode : ""})`, async ({ page }) => { + await configureDocuments(page, { code, message, reasonCode }); + await page.goto(`/miniapp?token=synthetic-token&plugin=${PLUGIN}`); + const failed = page.getByTestId("miniapp-view-start-failed"); + await expect(failed).toBeVisible(); + await expect(failed).toContainText("应用尚未打开"); + if (code === "OWNED_ELSEWHERE" || reasonCode === "OWNED_ELSEWHERE") { + await expect(failed).toContainText("请先在其他客户端关闭该应用,再重试。"); + } else { + await expect(failed).toContainText(message); + await expect(failed).not.toContainText("请先在其他客户端关闭"); + } + await expect(page.getByTestId("miniapp-view-frame")).toHaveCount(0); + await page.getByTestId("miniapp-view-refusal").getByRole("button", { name: "关闭", exact: true }).click(); + await expect(failed).toBeVisible(); + // A repeated refusal keeps the recovery control instead of erasing the page. + const retry = page.getByRole("button", { name: "重试打开应用" }); + await retry.click(); + await expect(failed).toBeVisible(); + await expect.poll(() => page.evaluate(() => window.__fixture.requests.filter( + (request) => request.operation === "openMiniApp", + ).length)).toBe(2); + await page.evaluate(() => { + window.__fixture.allowOperation("openMiniApp"); + window.__fixture.delayNext("openMiniApp", {}); + }); + await retry.click(); + await expect(page.getByTestId("miniapp-view-opening")).toBeVisible(); + await expect(retry).toHaveCount(0); + await expect(failed).toHaveCount(0); + await page.evaluate(({ pluginId, path }) => window.__fixture.resolve("openMiniApp", {}, { + pluginId, viewUrl: window.location.origin + path, + }), { pluginId: PLUGIN, path: STANDALONE_STUB }); + await expect(page.getByTestId("miniapp-view-frame")).toBeVisible(); + await expect(failed).toHaveCount(0); + await expect(retry).toHaveCount(0); + expect(await page.evaluate(() => window.__fixture.requests.filter( + (request) => request.operation === "openMiniApp", + ).length)).toBe(3); + }); +} diff --git a/packages/webui/test/unit/miniapp-client-state.test.ts b/packages/webui/test/unit/miniapp-client-state.test.ts index 97f42ac24..e9b83ce29 100644 --- a/packages/webui/test/unit/miniapp-client-state.test.ts +++ b/packages/webui/test/unit/miniapp-client-state.test.ts @@ -389,7 +389,7 @@ describe("the Mini App business", () => { }); expect(text).not.toContain("electron"); expect(text).toContain(wrapped ? "OWNED_ELSEWHERE" : "4242"); - expect(snapshot.presentations["shared-app"]).toBeUndefined(); + expect(snapshot.presentations["shared-app"]).toEqual({ kind: "failed", refusal }); }, ); diff --git a/packages/webui/test/unit/miniapp-surfaces.test.tsx b/packages/webui/test/unit/miniapp-surfaces.test.tsx index 8d758317f..2201f899a 100644 --- a/packages/webui/test/unit/miniapp-surfaces.test.tsx +++ b/packages/webui/test/unit/miniapp-surfaces.test.tsx @@ -11,8 +11,9 @@ // The failures and the confirmations are said through the shared toast (ADR // 0030), which is raised in an effect and drawn over the page: a server render // never sees it. So what a case pins about a failure here is that the layout -// does not carry it — and, from the surfaces' own sources, that it is still -// reported at all. +// does not carry transient errors — and, from the surfaces' own sources, that +// they are still reported at all. A failed start additionally leaves a persistent +// not-opened state with an explicit recovery control. // // The registry half is real: an actual upstream `http.Server`, an actual listener, // and a close that has to free its port — because the whole reason it exists is @@ -439,7 +440,7 @@ describe("the Mini App view the panel frames", () => { expect(opens).toBe(1); }); - it("reports the refusal through the toast, and shows no frame", async () => { + it("keeps an actionable state after another client refuses the start", async () => { const workflows = createWebuiMiniAppWorkflows({ port: port({ miniApps: [summary("shared", "stopped")], @@ -456,14 +457,59 @@ describe("the Mini App view the panel frames", () => { createElement(MiniAppView, { pluginId: "shared", sessionId: "session-1" }), workflows, ); - // The refusal is an event, not a state: it is said once, through the shared - // toast (ADR 0030). A server render never sees it. + // The toast reports the attempt; the retained state gives a safe next step + // without repeating the other process's details. expect(markup).not.toContain("pid 99"); expect(markup).not.toContain("electron"); expect(markup).not.toContain("miniapp-view-frame"); // The view itself still renders, so there is a surface to look at. expect(markup).toContain('data-testid="miniapp-view"'); - expect(markup).toContain('data-state="idle"'); + expect(markup).toContain("应用尚未打开"); + expect(markup).toContain("请先在其他客户端关闭该应用,再重试。"); + expect(markup).toContain("重试打开应用"); + }); + + it("does not offer a start retry for a refused stop without a presentation", async () => { + const workflows = createWebuiMiniAppWorkflows({ + port: port({ + miniApps: [summary("shared", "running")], + stop: async () => { throw new Error("Stop was refused"); }, + }), + }); + await workflows.stop("shared"); + const markup = render(createElement(MiniAppView, { pluginId: "shared" }), workflows); + expect(workflows.getSnapshot().refusals.shared?.message).toBe("Stop was refused"); + expect(markup).not.toContain("应用尚未打开"); + expect(markup).not.toContain("重试打开应用"); + }); + + it("retains a preparation failure until an explicit retry succeeds", async () => { + let succeeds = false; + const workflows = createWebuiMiniAppWorkflows({ + port: port({ + miniApps: [summary("shared", "stopped")], + open: async () => { + if (!succeeds) throw Object.assign(new Error("Mini App publication preparation failed"), { + code: "MINIAPP_PREPARATION_FAILED", + }); + return { pluginId: "shared", viewUrl: "http://127.0.0.1:49152" }; + }, + }), + }); + await workflows.open("shared"); + const view = createElement(MiniAppView, { pluginId: "shared", surface: "standalone" }); + const failed = render(view, workflows); + expect(failed).toContain("应用尚未打开"); + expect(failed).toContain("Mini App publication preparation failed"); + expect(failed).toContain("重试打开应用"); + expect(failed).not.toContain("请先在其他客户端关闭"); + expect(failed).not.toContain("miniapp-view-frame"); + succeeds = true; + await workflows.open("shared"); + const recovered = render(view, workflows); + expect(recovered).toContain("miniapp-view-frame"); + expect(recovered).not.toContain("应用尚未打开"); + expect(recovered).not.toContain("重试打开应用"); }); }); diff --git a/scripts/lib/webui-presentation-inventory.json b/scripts/lib/webui-presentation-inventory.json index 0277d7b29..637f33383 100644 --- a/scripts/lib/webui-presentation-inventory.json +++ b/scripts/lib/webui-presentation-inventory.json @@ -213,7 +213,7 @@ "features/miniapp/ui/MiniAppPicker.public.tsx": "7b631ebd095435d5", "features/miniapp/ui/MiniAppStandalone.public.tsx": "cb4684d8ffa3f32f", "features/miniapp/ui/MiniAppToolApprovals.public.tsx": "a123d341198a1b26", - "features/miniapp/ui/MiniAppView.public.tsx": "7245af70ea92ed94", + "features/miniapp/ui/MiniAppView.public.tsx": "92707a60570eba49", "features/models/ui/ModelEffortSlider.tsx": "4b36ea2127bcc1c3", "features/models/ui/ModelListPanel.tsx": "9be8a8e124de5e7e", "features/models/ui/ModelPanel.tsx": "8f68051cc0c54706",