Skip to content

feat: add scrollToBottom parameter#527

Open
tibisabau wants to merge 2 commits intoalpic-ai:mainfrom
tibisabau:feat/send-follow-up-message-api-extension
Open

feat: add scrollToBottom parameter#527
tibisabau wants to merge 2 commits intoalpic-ai:mainfrom
tibisabau:feat/send-follow-up-message-api-extension

Conversation

@tibisabau
Copy link
Copy Markdown

@tibisabau tibisabau commented Mar 4, 2026

Description

Extended the useSendFollowUpMessage hook to support an optional scrollToBottom parameter, aligning with the Apps SDK API update. This parameter allows developers to control whether the conversation view automatically scrolls to the bottom after sending a follow-up message.

The implementation:

  • Updated the Apps SDK type definition to include the optional scrollToBottom parameter
  • Modified the Adaptor interface to accept the new options parameter
  • Updated both AppsSdkAdaptor and McpAppAdaptor implementations to handle the parameter
  • Enhanced the useSendFollowUpMessage hook to pass through the options to the underlying adaptor
  • Added comprehensive test coverage with 4 test cases covering both Apps SDK and MCP app hosts
  • Updated documentation with usage examples demonstrating the new parameter

Closes #512.

The code in this pull request was generated by GitHub Copilot with the Claude Sonnet 4.5 model.

Checklist if Applicable

  • The tests passed – pnpm test src/web/hooks/use-send-follow-up-message.test.ts
  • Linting passed – pnpm biome ci on modified files
  • Documentation has been added – Updated API reference with parameter documentation and usage example
  • CHANGELOG.md has been updated

Greptile Summary

This PR extends useSendFollowUpMessage with an optional scrollToBottom parameter, updating the Adaptor interface, both adaptor implementations, the hook itself, tests, and documentation. The Apps SDK path is implemented correctly, but the MCP app adaptor accepts the parameter and silently discards it — unlike the existing pattern in the same file where unsupported options emit a console.warn. The test suite has good coverage for the Apps SDK host but misses a test for the MCP host with scrollToBottom, which would have exposed this gap. The documentation also claims true is the default value, but no explicit default is set in code.

  • Silent no-op in McpAppAdaptor: scrollToBottom is accepted but never forwarded to the ui/message bridge request. No warning is emitted (contrast with openExternal's handling of redirectUrl).
  • Missing MCP host test: The MCP app describe block only covers the no-options path; a scrollToBottom test case is absent.
  • Inaccurate documentation default: Docs state scrollToBottom defaults to true, but the code relies on the underlying window.openai API's default rather than enforcing one explicitly.

Confidence Score: 2/5

  • Not safe to merge as-is — the scrollToBottom option is silently ignored for MCP app hosts, making the feature incomplete and potentially misleading for that platform.
  • The Apps SDK implementation is correct, but the MCP app adaptor accepts scrollToBottom without forwarding it or warning the caller. The PR description says both adaptors "handle the parameter", which is inaccurate. This constitutes a broken contract for MCP app consumers and should be resolved before merging.
  • packages/core/src/web/bridges/mcp-app/adaptor.ts requires a fix — either forward scrollToBottom to the bridge request (if the MCP protocol supports it) or emit a console.warn that it is unsupported (matching the existing openExternal pattern).

Last reviewed commit: 1d07428

(5/5) You can turn off certain types of comments like style here!

Comment on lines +62 to +98

beforeEach(() => {
vi.stubGlobal("parent", { postMessage: mockPostMessage });
vi.stubGlobal("skybridge", { hostType: "mcp-app" });
});

afterEach(() => {
vi.unstubAllGlobals();
vi.resetAllMocks();
McpAppBridge.resetInstance();
});

it("should return a function that sends ui/message request to the MCP host", () => {
const { result } = renderHook(() => useSendFollowUpMessage());

const prompt = "Test message";
result.current(prompt);

expect(mockPostMessage).toHaveBeenCalledWith(
expect.objectContaining({
jsonrpc: "2.0",
method: "ui/message",
params: expect.objectContaining({
role: "user",
content: [
{
type: "text",
text: prompt,
},
],
}),
}),
"*",
);
});
});
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No test coverage for scrollToBottom in MCP app host

The MCP app host test block only covers the baseline case (no options). There is no test verifying the behaviour when scrollToBottom is passed in the MCP host context — which would immediately reveal that the option is silently dropped by McpAppAdaptor. Adding a test here would have caught the issue in mcp-app/adaptor.ts and made the gap explicit.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/core/src/web/hooks/use-send-follow-up-message.test.ts
Line: 62-98

Comment:
**No test coverage for `scrollToBottom` in MCP app host**

The MCP app host test block only covers the baseline case (no options). There is no test verifying the behaviour when `scrollToBottom` is passed in the MCP host context — which would immediately reveal that the option is silently dropped by `McpAppAdaptor`. Adding a test here would have caught the issue in `mcp-app/adaptor.ts` and made the gap explicit.

How can I resolve this? If you propose a fix, please make it concise.

- `options?: { scrollToBottom?: boolean }`
- **Optional**
- Configuration options for the follow-up message
- `scrollToBottom`: When `true` (default), automatically scrolls to the bottom of the conversation after posting the message. Set to `false` to prevent auto-scroll.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default value documented but not enforced in code

The docs state scrollToBottom defaults to true, but no explicit default is set in the implementation. The actual default behaviour falls through to whatever window.openai.sendFollowUpMessage does when scrollToBottom is absent from the payload. If the underlying API ever changes its default, the documented behaviour would silently diverge. Consider either:

  • Making the default explicit in code: options = { scrollToBottom: true }, or
  • Documenting this as "the host default applies" to clarify the dependency on the underlying API.
Suggested change
- `scrollToBottom`: When `true` (default), automatically scrolls to the bottom of the conversation after posting the message. Set to `false` to prevent auto-scroll.
- `scrollToBottom`: When `true`, automatically scrolls to the bottom of the conversation after posting the message. Set to `false` to prevent auto-scroll. Defaults to the host platform's default behavior when not specified.
Prompt To Fix With AI
This is a comment left during a code review.
Path: docs/api-reference/use-send-follow-up-message.mdx
Line: 44

Comment:
**Default value documented but not enforced in code**

The docs state `scrollToBottom` defaults to `true`, but no explicit default is set in the implementation. The actual default behaviour falls through to whatever `window.openai.sendFollowUpMessage` does when `scrollToBottom` is absent from the payload. If the underlying API ever changes its default, the documented behaviour would silently diverge. Consider either:
- Making the default explicit in code: `options = { scrollToBottom: true }`, or
- Documenting this as "the host default applies" to clarify the dependency on the underlying API.

```suggestion
  - `scrollToBottom`: When `true`, automatically scrolls to the bottom of the conversation after posting the message. Set to `false` to prevent auto-scroll. Defaults to the host platform's default behavior when not specified.
```

How can I resolve this? If you propose a fix, please make it concise.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 4, 2026

Additional Comments (1)

packages/core/src/web/bridges/mcp-app/adaptor.ts
scrollToBottom option is silently ignored for MCP app hosts

The options parameter is accepted in the function signature but never used — scrollToBottom is not forwarded to the ui/message bridge request. This means any developer calling sendFollowUpMessage("...", { scrollToBottom: false }) in an MCP app host will get no effect silently, which is likely to cause confusion.

Looking at how the analogous unsupported option is handled in openExternal (line ~131 of this same file), a console.warn is emitted when redirectUrl is used on MCP. The same pattern should apply here if scrollToBottom is truly unsupported by the ui/message protocol:

  public sendFollowUpMessage = async (
    prompt: string,
    options?: { scrollToBottom?: boolean },
  ) => {
    if (options?.scrollToBottom !== undefined) {
      console.warn(
        "[skybridge] scrollToBottom option is not supported by the MCP ui/message protocol and will be ignored.",
      );
    }
    const bridge = McpAppBridge.getInstance();
    await bridge.request<McpUiMessageRequest, McpUiMessageResult>({
      method: "ui/message",
      params: {
        role: "user",
        content: [
          {
            type: "text",
            text: prompt,
          },
        ],
      },
    });
  };

If McpUiMessageRequest does support scrollToBottom, it should be forwarded instead.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/core/src/web/bridges/mcp-app/adaptor.ts
Line: 110-127

Comment:
**`scrollToBottom` option is silently ignored for MCP app hosts**

The `options` parameter is accepted in the function signature but never used — `scrollToBottom` is not forwarded to the `ui/message` bridge request. This means any developer calling `sendFollowUpMessage("...", { scrollToBottom: false })` in an MCP app host will get no effect silently, which is likely to cause confusion.

Looking at how the analogous unsupported option is handled in `openExternal` (line ~131 of this same file), a `console.warn` is emitted when `redirectUrl` is used on MCP. The same pattern should apply here if `scrollToBottom` is truly unsupported by the `ui/message` protocol:

```suggestion
  public sendFollowUpMessage = async (
    prompt: string,
    options?: { scrollToBottom?: boolean },
  ) => {
    if (options?.scrollToBottom !== undefined) {
      console.warn(
        "[skybridge] scrollToBottom option is not supported by the MCP ui/message protocol and will be ignored.",
      );
    }
    const bridge = McpAppBridge.getInstance();
    await bridge.request<McpUiMessageRequest, McpUiMessageResult>({
      method: "ui/message",
      params: {
        role: "user",
        content: [
          {
            type: "text",
            text: prompt,
          },
        ],
      },
    });
  };
```

If `McpUiMessageRequest` does support `scrollToBottom`, it should be forwarded instead.

How can I resolve this? If you propose a fix, please make it concise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sendFollowUpMessage API extension

1 participant