Skip to content

Commit ba1a27e

Browse files
authored
fix: change size-changed to be in correct tense (#83)
* fix: change size-changed to be in correct tense * sdk changes
1 parent a09354b commit ba1a27e

File tree

6 files changed

+41
-41
lines changed

6 files changed

+41
-41
lines changed

specification/draft/apps.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -632,12 +632,12 @@ Host MUST send this notification if the tool execution was cancelled, for any re
632632
Host MUST send this notification before tearing down the UI resource, for any reason, including user action, resource re-allocation, etc. The Host MAY specify the reason.
633633
Host SHOULD wait for a response before tearing down the resource (to prevent data loss).
634634

635-
`ui/notifications/size-change` - UI’s size changed
635+
`ui/notifications/size-changed` - UI’s size changed
636636

637637
```typescript
638638
{
639639
jsonrpc: "2.0",
640-
method: "ui/notifications/size-change",
640+
method: "ui/notifications/size-changed",
641641
params: {
642642
width: number, // Viewport width in pixels
643643
height: number // Viewport height in pixels
@@ -774,7 +774,7 @@ sequenceDiagram
774774
H --> UI: resources/read response
775775
end
776776
opt UI notifications
777-
UI ->> H: notifications (e.g., ui/notifications/size-change)
777+
UI ->> H: notifications (e.g., ui/notifications/size-changed)
778778
end
779779
opt Host notifications
780780
H ->> UI: notifications (e.g., ui/notifications/host-context-changed)

src/app-bridge.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,14 +180,14 @@ describe("App <-> AppBridge integration", () => {
180180
await bridge.connect(bridgeTransport);
181181
});
182182

183-
it("app.sendSizeChange triggers bridge.onsizechange", async () => {
183+
it("app.sendSizeChanged triggers bridge.onsizechange", async () => {
184184
const receivedSizes: unknown[] = [];
185185
bridge.onsizechange = (params) => {
186186
receivedSizes.push(params);
187187
};
188188

189189
await app.connect(appTransport);
190-
await app.sendSizeChange({ width: 400, height: 600 });
190+
await app.sendSizeChanged({ width: 400, height: 600 });
191191

192192
expect(receivedSizes).toEqual([{ width: 400, height: 600 }]);
193193
});

src/app-bridge.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import {
3333

3434
import {
3535
type McpUiSandboxResourceReadyNotification,
36-
type McpUiSizeChangeNotification,
36+
type McpUiSizeChangedNotification,
3737
type McpUiToolInputNotification,
3838
type McpUiToolInputPartialNotification,
3939
type McpUiToolResultNotification,
@@ -57,7 +57,7 @@ import {
5757
McpUiResourceTeardownResultSchema,
5858
McpUiSandboxProxyReadyNotification,
5959
McpUiSandboxProxyReadyNotificationSchema,
60-
McpUiSizeChangeNotificationSchema,
60+
McpUiSizeChangedNotificationSchema,
6161
} from "./types";
6262
export * from "./types";
6363
export { PostMessageTransport } from "./message-transport";
@@ -265,12 +265,12 @@ export class AppBridge extends Protocol<Request, Notification, Result> {
265265
/**
266266
* Register a handler for size change notifications from the Guest UI.
267267
*
268-
* The Guest UI sends `ui/notifications/size-change` when its rendered content
268+
* The Guest UI sends `ui/notifications/size-changed` when its rendered content
269269
* size changes, typically via ResizeObserver. Set this callback to dynamically
270270
* adjust the iframe container dimensions based on the Guest UI's content.
271271
*
272272
* Note: This is for Guest UI → Host communication. To notify the Guest UI of
273-
* host viewport changes, use {@link app.App.sendSizeChange}.
273+
* host viewport changes, use {@link app.App.sendSizeChanged}.
274274
*
275275
* @example
276276
* ```typescript
@@ -284,13 +284,13 @@ export class AppBridge extends Protocol<Request, Notification, Result> {
284284
* };
285285
* ```
286286
*
287-
* @see {@link McpUiSizeChangeNotification} for the notification type
288-
* @see {@link app.App.sendSizeChange} for Host → Guest UI size notifications
287+
* @see {@link McpUiSizeChangedNotification} for the notification type
288+
* @see {@link app.App.sendSizeChanged} for Host → Guest UI size notifications
289289
*/
290290
set onsizechange(
291-
callback: (params: McpUiSizeChangeNotification["params"]) => void,
291+
callback: (params: McpUiSizeChangedNotification["params"]) => void,
292292
) {
293-
this.setNotificationHandler(McpUiSizeChangeNotificationSchema, (n) =>
293+
this.setNotificationHandler(McpUiSizeChangedNotificationSchema, (n) =>
294294
callback(n.params),
295295
);
296296
}

src/app.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import {
3131
McpUiMessageResultSchema,
3232
McpUiOpenLinkRequest,
3333
McpUiOpenLinkResultSchema,
34-
McpUiSizeChangeNotification,
34+
McpUiSizeChangedNotification,
3535
McpUiToolInputNotification,
3636
McpUiToolInputNotificationSchema,
3737
McpUiToolInputPartialNotification,
@@ -88,7 +88,7 @@ type AppOptions = ProtocolOptions & {
8888
* Automatically report size changes to the host using ResizeObserver.
8989
*
9090
* When enabled, the App monitors `document.body` and `document.documentElement`
91-
* for size changes and automatically sends `ui/notifications/size-change`
91+
* for size changes and automatically sends `ui/notifications/size-changed`
9292
* notifications to the host.
9393
*
9494
* @default true
@@ -723,19 +723,19 @@ export class App extends Protocol<Request, Notification, Result> {
723723
*
724724
* @example Manually notify host of size change
725725
* ```typescript
726-
* app.sendSizeChange({
726+
* app.sendSizeChanged({
727727
* width: 400,
728728
* height: 600
729729
* });
730730
* ```
731731
*
732732
* @returns Promise that resolves when the notification is sent
733733
*
734-
* @see {@link McpUiSizeChangeNotification} for notification structure
734+
* @see {@link McpUiSizeChangedNotification} for notification structure
735735
*/
736-
sendSizeChange(params: McpUiSizeChangeNotification["params"]) {
737-
return this.notification(<McpUiSizeChangeNotification>{
738-
method: "ui/notifications/size-change",
736+
sendSizeChanged(params: McpUiSizeChangedNotification["params"]) {
737+
return this.notification(<McpUiSizeChangedNotification>{
738+
method: "ui/notifications/size-changed",
739739
params,
740740
});
741741
}
@@ -744,7 +744,7 @@ export class App extends Protocol<Request, Notification, Result> {
744744
* Set up automatic size change notifications using ResizeObserver.
745745
*
746746
* Observes both `document.documentElement` and `document.body` for size changes
747-
* and automatically sends `ui/notifications/size-change` notifications to the host.
747+
* and automatically sends `ui/notifications/size-changed` notifications to the host.
748748
* The notifications are debounced using requestAnimationFrame to avoid duplicates.
749749
*
750750
* Note: This method is automatically called by `connect()` if the `autoResize`
@@ -759,18 +759,18 @@ export class App extends Protocol<Request, Notification, Result> {
759759
* await app.connect(transport);
760760
*
761761
* // Later, enable auto-resize manually
762-
* const cleanup = app.setupSizeChangeNotifications();
762+
* const cleanup = app.setupSizeChangedNotifications();
763763
*
764764
* // Clean up when done
765765
* cleanup();
766766
* ```
767767
*/
768-
setupSizeChangeNotifications() {
768+
setupSizeChangedNotifications() {
769769
let scheduled = false;
770770
let lastWidth = 0;
771771
let lastHeight = 0;
772772

773-
const sendBodySizeChange = () => {
773+
const sendBodySizeChanged = () => {
774774
if (scheduled) {
775775
return;
776776
}
@@ -801,14 +801,14 @@ export class App extends Protocol<Request, Notification, Result> {
801801
if (width !== lastWidth || height !== lastHeight) {
802802
lastWidth = width;
803803
lastHeight = height;
804-
this.sendSizeChange({ width, height });
804+
this.sendSizeChanged({ width, height });
805805
}
806806
});
807807
};
808808

809-
sendBodySizeChange();
809+
sendBodySizeChanged();
810810

811-
const resizeObserver = new ResizeObserver(sendBodySizeChange);
811+
const resizeObserver = new ResizeObserver(sendBodySizeChanged);
812812
// Observe both html and body to catch all size changes
813813
resizeObserver.observe(document.documentElement);
814814
resizeObserver.observe(document.body);
@@ -824,7 +824,7 @@ export class App extends Protocol<Request, Notification, Result> {
824824
* 2. Sends `ui/initialize` request with app info and capabilities
825825
* 3. Receives host capabilities and context in response
826826
* 4. Sends `ui/notifications/initialized` notification
827-
* 5. Sets up auto-resize using {@link setupSizeChangeNotifications} if enabled (default)
827+
* 5. Sets up auto-resize using {@link setupSizeChangedNotifications} if enabled (default)
828828
*
829829
* If initialization fails, the connection is automatically closed and an error
830830
* is thrown.
@@ -885,7 +885,7 @@ export class App extends Protocol<Request, Notification, Result> {
885885
});
886886

887887
if (this.options?.autoResize) {
888-
this.setupSizeChangeNotifications();
888+
this.setupSizeChangedNotifications();
889889
}
890890
} catch (error) {
891891
// Disconnect if initialization fails.

src/react/useAutoResize.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { App } from "../app";
55
* React hook that automatically reports UI size changes to the host.
66
*
77
* Uses ResizeObserver to watch `document.body` and `document.documentElement` for
8-
* size changes and sends `ui/notifications/size-change` notifications.
8+
* size changes and sends `ui/notifications/size-changed` notifications.
99
*
1010
* **Note**: This hook is rarely needed since the {@link useApp} hook automatically enables
1111
* auto-resize by default. This hook is provided for advanced cases where you
@@ -45,7 +45,7 @@ import { App } from "../app";
4545
* }
4646
* ```
4747
*
48-
* @see {@link App.setupSizeChangeNotifications} for the underlying implementation
48+
* @see {@link App.setupSizeChangedNotifications} for the underlying implementation
4949
* @see {@link useApp} which enables auto-resize by default
5050
* @see {@link App} constructor for configuring `autoResize` option
5151
*/
@@ -58,6 +58,6 @@ export function useAutoResize(
5858
return;
5959
}
6060

61-
return app.setupSizeChangeNotifications();
61+
return app.setupSizeChangedNotifications();
6262
}, [app, elementRef]);
6363
}

src/types.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,11 @@ type _VerifySandboxResourceReadyNotification = VerifySchemaMatches<
258258
* **Host → Guest UI**: Sent by the Host when the viewport size changes (e.g.,
259259
* window resize, orientation change). This allows the Guest UI to adjust its layout.
260260
*
261-
* @see {@link app.App.sendSizeChange} for the method to send this from Guest UI
262-
* @see {@link app.App.setupSizeChangeNotifications} for automatic size reporting
261+
* @see {@link app.App.sendSizeChanged} for the method to send this from Guest UI
262+
* @see {@link app.App.setupSizeChangedNotifications} for automatic size reporting
263263
*/
264-
export interface McpUiSizeChangeNotification {
265-
method: "ui/notifications/size-change";
264+
export interface McpUiSizeChangedNotification {
265+
method: "ui/notifications/size-changed";
266266
params: {
267267
/** New width in pixels */
268268
width?: number;
@@ -272,11 +272,11 @@ export interface McpUiSizeChangeNotification {
272272
}
273273

274274
/**
275-
* Runtime validation schema for {@link McpUiSizeChangeNotification}.
275+
* Runtime validation schema for {@link McpUiSizeChangedNotification}.
276276
* @internal
277277
*/
278-
export const McpUiSizeChangeNotificationSchema = z.object({
279-
method: z.literal("ui/notifications/size-change"),
278+
export const McpUiSizeChangedNotificationSchema = z.object({
279+
method: z.literal("ui/notifications/size-changed"),
280280
params: z.object({
281281
width: z.number().optional(),
282282
height: z.number().optional(),
@@ -285,8 +285,8 @@ export const McpUiSizeChangeNotificationSchema = z.object({
285285

286286
/** @internal - Compile-time verification that schema matches interface */
287287
type _VerifySizeChangeNotification = VerifySchemaMatches<
288-
typeof McpUiSizeChangeNotificationSchema,
289-
McpUiSizeChangeNotification
288+
typeof McpUiSizeChangedNotificationSchema,
289+
McpUiSizeChangedNotification
290290
>;
291291

292292
/**

0 commit comments

Comments
 (0)