Skip to content

Commit eb9edd2

Browse files
Align spec terminology to teardown/termination instead of close/clearnup
1 parent 9a71800 commit eb9edd2

9 files changed

Lines changed: 209 additions & 193 deletions

File tree

specification/draft/apps.mdx

Lines changed: 135 additions & 115 deletions
Large diffs are not rendered by default.

src/app-bridge.test.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -521,30 +521,26 @@ describe("App <-> AppBridge integration", () => {
521521
).rejects.toThrow("Context update failed");
522522
});
523523

524-
it("app.requestClose allows host to initiate teardown flow", async () => {
524+
it("app.requestTeardown allows host to initiate teardown flow", async () => {
525525
const events: string[] = [];
526526

527-
// Host handles close request by initiating teardown
528-
bridge.onrequestclose = async () => {
529-
events.push("close-requested");
530-
// Host decides to proceed with close - initiate teardown
527+
bridge.onrequestteardown = async () => {
528+
events.push("teardown-requested");
531529
await bridge.teardownResource({});
532530
events.push("teardown-complete");
533531
};
534532

535-
// App handles teardown (cleanup before unmount)
536533
app.onteardown = async () => {
537534
events.push("app-cleanup");
538535
return {};
539536
};
540537

541538
await app.connect(appTransport);
542-
await app.requestClose();
539+
await app.requestTeardown();
543540
await flush();
544541

545-
// Verify the full flow: request → teardown → cleanup
546542
expect(events).toEqual([
547-
"close-requested",
543+
"teardown-requested",
548544
"app-cleanup",
549545
"teardown-complete",
550546
]);

src/app-bridge.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ import {
7474
McpUiDownloadFileResult,
7575
McpUiResourceTeardownRequest,
7676
McpUiResourceTeardownResultSchema,
77-
McpUiRequestCloseNotification,
78-
McpUiRequestCloseNotificationSchema,
77+
McpUiRequestTeardownNotification,
78+
McpUiRequestTeardownNotificationSchema,
7979
McpUiSandboxProxyReadyNotification,
8080
McpUiSandboxProxyReadyNotificationSchema,
8181
McpUiSizeChangedNotificationSchema,
@@ -676,20 +676,20 @@ export class AppBridge extends Protocol<
676676
}
677677

678678
/**
679-
* Register a handler for app-initiated close request notifications from the view.
679+
* Register a handler for app-initiated teardown request notifications from the view.
680680
*
681-
* The view sends `ui/notifications/request-close` when it wants the host to close it.
682-
* If the host decides to proceed with the close, it should send
681+
* The view sends `ui/notifications/request-teardown` when it wants the host to tear it down.
682+
* If the host decides to proceed, it should send
683683
* `ui/resource-teardown` (via {@link teardownResource `teardownResource`}) to allow
684684
* the view to perform cleanup, then unmount the iframe after the view responds.
685685
*
686-
* @param callback - Handler that receives close request params
686+
* @param callback - Handler that receives teardown request params
687687
* - params - Empty object (reserved for future use)
688688
*
689689
* @example
690690
* ```typescript
691-
* bridge.onrequestclose = async (params) => {
692-
* console.log("App requested close");
691+
* bridge.onrequestteardown = async (params) => {
692+
* console.log("App requested teardown");
693693
* // Initiate teardown to allow the app to clean up
694694
* // Alternatively, the callback can early return to prevent teardown
695695
* await bridge.teardownResource({});
@@ -698,14 +698,14 @@ export class AppBridge extends Protocol<
698698
* };
699699
* ```
700700
*
701-
* @see {@link McpUiRequestCloseNotification `McpUiRequestCloseNotification`} for the notification type
701+
* @see {@link McpUiRequestTeardownNotification `McpUiRequestTeardownNotification`} for the notification type
702702
* @see {@link teardownResource `teardownResource`} for initiating teardown
703703
*/
704-
set onrequestclose(
705-
callback: (params: McpUiRequestCloseNotification["params"]) => void,
704+
set onrequestteardown(
705+
callback: (params: McpUiRequestTeardownNotification["params"]) => void,
706706
) {
707707
this.setNotificationHandler(
708-
McpUiRequestCloseNotificationSchema,
708+
McpUiRequestTeardownNotificationSchema,
709709
(request) => callback(request.params),
710710
);
711711
}

src/app.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import {
4444
McpUiResourceTeardownRequest,
4545
McpUiResourceTeardownRequestSchema,
4646
McpUiResourceTeardownResult,
47-
McpUiRequestCloseNotification,
47+
McpUiRequestTeardownNotification,
4848
McpUiSizeChangedNotification,
4949
McpUiToolCancelledNotification,
5050
McpUiToolCancelledNotificationSchema,
@@ -1136,45 +1136,45 @@ export class App extends Protocol<AppRequest, AppNotification, AppResult> {
11361136
}
11371137

11381138
/**
1139-
* Request the host to close this app.
1139+
* Request the host to tear down this app.
11401140
*
1141-
* Apps call this method to request that the host close them. The host decides
1142-
* whether to proceed with the close - if approved, the host will send
1141+
* Apps call this method to request that the host tear them down. The host
1142+
* decides whether to proceed - if approved, the host will send
11431143
* `ui/resource-teardown` to allow the app to perform cleanup before being
11441144
* unmounted. This piggybacks on the existing teardown mechanism, ensuring
11451145
* the app only needs a single shutdown procedure (via {@link onteardown `onteardown`})
1146-
* regardless of whether the close was initiated by the app or the host.
1146+
* regardless of whether the teardown was initiated by the app or the host.
11471147
*
11481148
* This is a fire-and-forget notification - no response is expected.
1149-
* If the host approves the close, the app will receive a `ui/resource-teardown`
1149+
* If the host approves, the app will receive a `ui/resource-teardown`
11501150
* request via the {@link onteardown `onteardown`} handler to perform cleanup.
11511151
*
11521152
* @param params - Empty params object (reserved for future use)
11531153
* @returns Promise that resolves when the notification is sent
11541154
*
1155-
* @example App-initiated close after user action
1155+
* @example App-initiated teardown after user action
11561156
* ```typescript
11571157
* // User clicks "Done" button in the app
11581158
* async function handleDoneClick() {
1159-
* // Request the host to close the app
1160-
* await app.requestClose();
1159+
* // Request the host to tear down the app
1160+
* await app.requestTeardown();
11611161
* // If host approves, onteardown handler will be called for cleanup
11621162
* }
11631163
*
1164-
* // Set up teardown handler (called for both app-initiated and host-initiated close)
1164+
* // Set up teardown handler (called for both app-initiated and host-initiated teardown)
11651165
* app.onteardown = async () => {
11661166
* await saveState();
11671167
* closeConnections();
11681168
* return {};
11691169
* };
11701170
* ```
11711171
*
1172-
* @see {@link McpUiRequestCloseNotification `McpUiRequestCloseNotification`} for notification structure
1172+
* @see {@link McpUiRequestTeardownNotification `McpUiRequestTeardownNotification`} for notification structure
11731173
* @see {@link onteardown `onteardown`} for the cleanup handler
11741174
*/
1175-
requestClose(params: McpUiRequestCloseNotification["params"] = {}) {
1176-
return this.notification(<McpUiRequestCloseNotification>{
1177-
method: "ui/notifications/request-close",
1175+
requestTeardown(params: McpUiRequestTeardownNotification["params"] = {}) {
1176+
return this.notification(<McpUiRequestTeardownNotification>{
1177+
method: "ui/notifications/request-teardown",
11781178
params,
11791179
});
11801180
}

src/generated/schema.json

Lines changed: 17 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/generated/schema.test.ts

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/generated/schema.ts

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/spec.types.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -475,15 +475,15 @@ export interface McpUiSupportedContentBlockModalities {
475475
}
476476

477477
/**
478-
* @description Notification for app-initiated close request (View -> Host).
479-
* Views send this to request that the host close them. The host decides
480-
* whether to proceed with the close - if approved, the host will send
478+
* @description Notification for app-initiated teardown request (View -> Host).
479+
* Views send this to request that the host tear them down. The host decides
480+
* whether to proceed - if approved, the host will send
481481
* `ui/resource-teardown` to allow the view to perform cleanup before being
482482
* unmounted.
483-
* @see {@link app.App.requestClose} for the app method that sends this
483+
* @see {@link app.App.requestTeardown} for the app method that sends this
484484
*/
485-
export interface McpUiRequestCloseNotification {
486-
method: "ui/notifications/request-close";
485+
export interface McpUiRequestTeardownNotification {
486+
method: "ui/notifications/request-teardown";
487487
params?: {};
488488
}
489489

@@ -813,8 +813,8 @@ export const TOOL_CANCELLED_METHOD: McpUiToolCancelledNotification["method"] =
813813
"ui/notifications/tool-cancelled";
814814
export const HOST_CONTEXT_CHANGED_METHOD: McpUiHostContextChangedNotification["method"] =
815815
"ui/notifications/host-context-changed";
816-
export const REQUEST_CLOSE_METHOD: McpUiRequestCloseNotification["method"] =
817-
"ui/notifications/request-close";
816+
export const REQUEST_TEARDOWN_METHOD: McpUiRequestTeardownNotification["method"] =
817+
"ui/notifications/request-teardown";
818818
export const RESOURCE_TEARDOWN_METHOD: McpUiResourceTeardownRequest["method"] =
819819
"ui/resource-teardown";
820820
export const INITIALIZE_METHOD: McpUiInitializeRequest["method"] =

src/types.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export {
2323
TOOL_RESULT_METHOD,
2424
TOOL_CANCELLED_METHOD,
2525
HOST_CONTEXT_CHANGED_METHOD,
26-
REQUEST_CLOSE_METHOD,
26+
REQUEST_TEARDOWN_METHOD,
2727
RESOURCE_TEARDOWN_METHOD,
2828
INITIALIZE_METHOD,
2929
INITIALIZED_METHOD,
@@ -53,7 +53,7 @@ export {
5353
type McpUiHostContextChangedNotification,
5454
type McpUiResourceTeardownRequest,
5555
type McpUiResourceTeardownResult,
56-
type McpUiRequestCloseNotification,
56+
type McpUiRequestTeardownNotification,
5757
type McpUiHostCapabilities,
5858
type McpUiAppCapabilities,
5959
type McpUiInitializeRequest,
@@ -87,7 +87,7 @@ import type {
8787
McpUiInitializedNotification,
8888
McpUiSizeChangedNotification,
8989
McpUiSandboxProxyReadyNotification,
90-
McpUiRequestCloseNotification,
90+
McpUiRequestTeardownNotification,
9191
McpUiInitializeResult,
9292
McpUiOpenLinkResult,
9393
McpUiDownloadFileResult,
@@ -121,7 +121,7 @@ export {
121121
McpUiHostContextChangedNotificationSchema,
122122
McpUiResourceTeardownRequestSchema,
123123
McpUiResourceTeardownResultSchema,
124-
McpUiRequestCloseNotificationSchema,
124+
McpUiRequestTeardownNotificationSchema,
125125
McpUiHostCapabilitiesSchema,
126126
McpUiAppCapabilitiesSchema,
127127
McpUiInitializeRequestSchema,
@@ -193,7 +193,7 @@ export type AppRequest =
193193
* - Sandbox resource ready
194194
*
195195
* App to host:
196-
* - Initialized, size-changed, sandbox-proxy-ready, request-close
196+
* - Initialized, size-changed, sandbox-proxy-ready, request-teardown
197197
* - Logging messages
198198
*/
199199
export type AppNotification =
@@ -211,7 +211,7 @@ export type AppNotification =
211211
| McpUiInitializedNotification
212212
| McpUiSizeChangedNotification
213213
| McpUiSandboxProxyReadyNotification
214-
| McpUiRequestCloseNotification
214+
| McpUiRequestTeardownNotification
215215
| LoggingMessageNotification;
216216

217217
/**

0 commit comments

Comments
 (0)