Thread cacheMode through managed list refresh via SDK cache-aware verbs (#1721) (#1723)
Some checks failed
Run install, format, lint, build, and test on every push / build (push) Has been cancelled
Run install, format, lint, build, and test on every push / publish (push) Has been cancelled
Run install, format, lint, build, and test on every push / publish-github-container-registry (push) Has been cancelled

* Thread cacheMode through managed list refresh via SDK cache-aware verbs (#1721)

Manual/auto refresh of tools/resources/prompts now forces a cache-bypassing
round trip on modern servers, delivering the raw-request cacheMode control
deferred from #1628.

The InspectorClient list/read path uses the SDK's single-page `client.request`
verbs (for pagination debugging), which never consult the SDK response cache —
so `cacheMode` was inert there. This adds a separate aggregate path that routes
through the SDK's cache-aware high-level verbs, where `cacheMode` is honored:

- InspectorClient: new `listAllTools/Prompts/Resources/ResourceTemplates(
  { cacheMode, metadata })` that call `client.listTools()` etc. (all-page
  aggregate + SEP-2243 x-mcp-header exclusion + cache consult/write). A shared
  `getCacheableRequestOptions` / `aggregateListParams` back all four.
- InspectorClientProtocol: the four `listAll*` methods added.
- ManagedListState: delegates page walking to the SDK verb (config `fetchPage`
  loop → `fetchAll`); `refresh(metadata?, cacheMode?)` threads cacheMode. A
  `list_changed` auto-refresh bypasses the cache (`cacheMode: "refresh"`).
- Managed hooks: user-initiated `refresh()` passes `cacheMode: "refresh"`, so
  the existing per-tab Refresh buttons become genuinely cache-bypassing — no
  App wiring change. Connect-time load stays default (`'use'`).

The single-page `listTools(cursor)` primitive is unchanged; the paged hooks
still surface per-page `nextCursor`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5

* Single-page list pagination: sidebar toggle + server setting (#1721)

Delivers the deferred single-page fetch UI: Tools/Resources/Prompts can be
loaded one page at a time instead of auto-aggregating every page — a defensive
option for servers with very large lists.

- New `singlePageLists` server setting (persisted, server-wide), plumbed through
  ServerConfig/InspectorServerSettings, serverList convert/default, the node +
  remote settings paths, and the Server Settings form ("Fetch Lists One Page at
  a Time").
- New `ListPaginationControls` element (a "Single page" switch + "Load next
  page" button + "N pages loaded" status) rendered in each list sidebar; the
  toggle edits the setting live (optimistic) and persists it.
- The paged state stores (PagedTools/Prompts/ResourcesState) now own loading:
  they auto-load page 1 on connect in single-page mode and track nextCursor +
  page count as observable state; the managed stores skip their all-page walk
  in single-page mode (so nothing is over-fetched) while still lighting the
  list-changed indicator. `usePaginatedList` selects the display source and
  pagination controls per mode — pure, no data-loading in React effects.
- Refresh is mode-aware: reload page 1 in single-page mode, refetch the whole
  aggregate otherwise. Sidebars widened 340→360 so the controls don't crowd
  list entries.
- Test server: `test-servers/configs/pagination-http.json` (12 tools/resources/
  prompts, page size 4 → 3 pages each) exercises the flow end to end.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5

* Add pr-screenshots proving single-page pagination (#1721)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5

* Address @claude review: template load, double-click guard, auth recovery (#1721)

- Fix: resource templates never loaded on connect in single-page mode. The
  connect-time all-page skip now applies only to lists with a paged counterpart
  (new `deferInSinglePage` flag on ManagedListConfig; false for resource
  templates), so templates still aggregate on connect regardless of the setting.
- Guard `PagedTools/Prompts/ResourcesState.loadPage` against a concurrent load
  (fast double-click on "Load next page") so the same page can't be appended
  twice; the in-flight load owns the cursor and the second call is a no-op.
- Thread ambient auth recovery through the single-page refresh, Load-next-page,
  and mode-switch loads (they previously bypassed it) — usePaginatedList's
  onRefresh/onLoadMore now return their promises so App can wrap them.
- Drop the misleading "aggregated list" wording from the paged-store docs.

Tests added for each; npm run coverage green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5

* Review round 2: revert optimistic toggle when persisting the setting fails (#1721)

Non-blocking review follow-up. If updateServerSettings rejects, the optimistic
`singlePageListsOverride` is now cleared and the live client setting rolled back
(the effect only clears the override when the persisted value changes, which
doesn't happen on failure), so the UI and client reflect what's on disk rather
than the failed edit. Added an App test for the revert path.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5

* Fix single-page Refresh not clearing list-changed indicator + UI polish (#1721)

Round-3 review fix (blocking): in single-page mode a `list_changed` lights the
list-changed indicator, but the single-page Refresh reloads page 1 of the paged
store and bypassed `useManaged*.refresh()`, so the indicator was never cleared.
Expose `clearListChanged` from useManagedTools/Prompts/Resources and call it in
the single-page branch of onRefreshTools/Prompts/Resources. Tests added.

UI polish (user feedback on the sidebar control):
- Rename the switch label "Single page" → "Paginated".
- Put "Load next page" on the same row as the switch, space-between (switch
  fully left, button fully right).
- Move the "N pages loaded" status to its own line below the row, centered.
- Hide the whole control once the list is known to be a single page
  (single-page mode, page 1 loaded, no nextCursor) — nothing to paginate.

pr-screenshots refreshed to the new layout.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5

* Rename the singlePageLists setting to paginatedLists for clarity (#1721)

`singlePageLists` read backwards from the "Paginated" switch label (it sounds
like paginated=false). Rename the server setting to `paginatedLists` with the
same value meaning — true = paginated/one-page-at-a-time, false = aggregate-all
— and follow through on the related identifiers for consistency:

- Setting field `paginatedLists` across ServerConfig / InspectorServerSettings,
  serverList convert/default, node + remote settings paths, and the form/modal
  callbacks (onPaginatedListsChange).
- `usePaginatedList` / `ListPaginationControls` prop `singlePage` → `paginated`,
  `onSinglePageChange` → `onPaginatedChange`.
- `ManagedListConfig.deferInSinglePage` → `deferWhenPaginated`.
- App state (paginatedListsOverride, onTogglePaginatedLists, …) and all
  tests/fixtures + mode-referring comments.

"single-page" wording that denotes the SDK's one-page `client.request` verb
(inspectorClient) is intentionally left as-is. Purely a rename — no behavior
change; unit + integration + cli + tui + coverage all green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5

* Format App.test.tsx (prettier) after the paginatedLists rename (#1721)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cliff Hall 2026-07-19 01:06:31 -04:00 • committed by GitHub
commit b3b04c6939
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
28 changed files with 2494 additions and 247 deletions

View file

@ -0,0 +1,47 @@
import type { Meta, StoryObj } from "@storybook/react-vite";
import { fn } from "storybook/test";
import { ListPaginationControls } from "./ListPaginationControls";
const meta: Meta<typeof ListPaginationControls> = {
title: "Elements/ListPaginationControls",
component: ListPaginationControls,
args: {
onPaginatedChange: fn(),
onLoadMore: fn(),
},
};
export default meta;
type Story = StoryObj<typeof ListPaginationControls>;
export const AllPages: Story = {
args: {
paginated: false,
canLoadMore: false,
loadedPages: 0,
},
};
export const SinglePageWithMore: Story = {
args: {
paginated: true,
canLoadMore: true,
loadedPages: 2,
},
};
export const SinglePageAtEnd: Story = {
args: {
paginated: true,
canLoadMore: false,
loadedPages: 3,
},
};
export const SinglePageFirstPage: Story = {
args: {
paginated: true,
canLoadMore: true,
loadedPages: 1,
},
};

View file

@ -0,0 +1,125 @@
import { describe, it, expect, vi } from "vitest";
import { renderWithMantine, screen } from "../../../test/renderWithMantine";
import userEvent from "@testing-library/user-event";
import { ListPaginationControls } from "./ListPaginationControls";
const baseProps = {
paginated: false,
onPaginatedChange: () => {},
canLoadMore: false,
loadedPages: 0,
onLoadMore: () => {},
};
describe("ListPaginationControls", () => {
it("renders only the 'Paginated' switch in all-pages mode (no load-more)", () => {
renderWithMantine(<ListPaginationControls {...baseProps} />);
const toggle = screen.getByRole("switch");
expect(toggle).not.toBeChecked();
expect(screen.getByText("Paginated")).toBeInTheDocument();
expect(
screen.queryByRole("button", { name: "Load next page" }),
).not.toBeInTheDocument();
});
it("toggles paginated mode via the switch", async () => {
const user = userEvent.setup();
const onPaginatedChange = vi.fn();
renderWithMantine(
<ListPaginationControls
{...baseProps}
onPaginatedChange={onPaginatedChange}
/>,
);
await user.click(screen.getByRole("switch"));
expect(onPaginatedChange).toHaveBeenCalledWith(true);
});
it("shows the load-more button and page count in paginated mode", () => {
renderWithMantine(
<ListPaginationControls
{...baseProps}
paginated
canLoadMore
loadedPages={2}
/>,
);
expect(screen.getByRole("switch")).toBeChecked();
expect(
screen.getByRole("button", { name: "Load next page" }),
).toBeEnabled();
expect(screen.getByText("2 pages loaded")).toBeInTheDocument();
});
it("uses the singular label for one page (while more remain)", () => {
renderWithMantine(
<ListPaginationControls
{...baseProps}
paginated
canLoadMore
loadedPages={1}
/>,
);
expect(screen.getByText("1 page loaded")).toBeInTheDocument();
});
it("hides the whole control when the list is a single page", () => {
// Paginated mode, page 1 loaded, no next cursor → nothing to paginate.
renderWithMantine(
<ListPaginationControls
{...baseProps}
paginated
canLoadMore={false}
loadedPages={1}
/>,
);
expect(screen.queryByRole("switch")).not.toBeInTheDocument();
expect(
screen.queryByRole("button", { name: "Load next page" }),
).not.toBeInTheDocument();
});
it("still shows the switch while a paginated load is pending (0 pages)", () => {
// loadedPages 0 (page 1 not yet loaded) must not trip the paginated hide.
renderWithMantine(
<ListPaginationControls
{...baseProps}
paginated
canLoadMore={false}
loadedPages={0}
/>,
);
expect(screen.getByRole("switch")).toBeInTheDocument();
});
it("marks the end when there are multiple pages and no more to load", () => {
renderWithMantine(
<ListPaginationControls
{...baseProps}
paginated
canLoadMore={false}
loadedPages={3}
/>,
);
expect(
screen.getByRole("button", { name: "Load next page" }),
).toBeDisabled();
expect(screen.getByText("3 pages loaded · end")).toBeInTheDocument();
});
it("invokes onLoadMore when the button is clicked", async () => {
const user = userEvent.setup();
const onLoadMore = vi.fn();
renderWithMantine(
<ListPaginationControls
{...baseProps}
paginated
canLoadMore
loadedPages={1}
onLoadMore={onLoadMore}
/>,
);
await user.click(screen.getByRole("button", { name: "Load next page" }));
expect(onLoadMore).toHaveBeenCalledTimes(1);
});
});

View file

@ -0,0 +1,86 @@
import { Button, Group, Stack, Switch, Text } from "@mantine/core";
export interface ListPaginationControlsProps {
/**
* True when the list is fetched one page at a time (backed by the server's
* `paginatedLists` setting). False = auto-aggregate every page on load.
*/
paginated: boolean;
/** Toggle paginated mode. Wired to write the `paginatedLists` setting. */
onPaginatedChange: (paginated: boolean) => void;
/** Paginated mode only: the server returned a `nextCursor` to load. */
canLoadMore: boolean;
/** Paginated mode only: number of pages loaded so far (status label). */
loadedPages: number;
/** Paginated mode only: fetch the next page. */
onLoadMore: () => void;
}
// Switch fully left, "Load next page" fully right; the page-count sits on its
// own line under the row.
const ControlsRow = Group.withProps({
gap: "sm",
align: "center",
justify: "space-between",
wrap: "nowrap",
});
const ModeSwitch = Switch.withProps({
size: "sm",
"aria-label": "Fetch lists one page at a time",
});
const LoadMoreButton = Button.withProps({
size: "compact-sm",
variant: "light",
});
const StatusText = Text.withProps({
size: "xs",
ta: "center",
c: "var(--inspector-text-secondary)",
});
/**
* Sidebar control for a paginated list (Tools/Resources/Prompts). A "Paginated"
* switch toggles between auto-aggregating every page and fetching one page at a
* time; in paginated mode a "Load next page" button (to the right of the
* switch) surfaces the server's `nextCursor` and a status shows how many pages
* are loaded. Hidden entirely once the list is known to be a single page, since
* there's nothing to paginate.
*/
export function ListPaginationControls({
paginated,
onPaginatedChange,
canLoadMore,
loadedPages,
onLoadMore,
}: ListPaginationControlsProps) {
// The list turned out to be a single page (loaded page 1, no `nextCursor`):
// pagination is moot, so hide the whole control rather than show a useless
// toggle + disabled button (#1721).
if (paginated && !canLoadMore && loadedPages === 1) return null;
return (
<Stack gap={4}>
<ControlsRow>
<ModeSwitch
label="Paginated"
checked={paginated}
onChange={(e) => onPaginatedChange(e.currentTarget.checked)}
/>
{paginated ? (
<LoadMoreButton disabled={!canLoadMore} onClick={onLoadMore}>
Load next page
</LoadMoreButton>
) : null}
</ControlsRow>
{paginated ? (
<StatusText>
{loadedPages} {loadedPages === 1 ? "page" : "pages"} loaded
{canLoadMore ? "" : " · end"}
</StatusText>
) : null}
</Stack>
);
}

View file

@ -1,4 +1,5 @@
import type { Meta, StoryObj } from "@storybook/react-vite";
import { noopPagination } from "../../../test/fixtures/pagination";
import type { Prompt } from "@modelcontextprotocol/client";
import { fn } from "storybook/test";
import { PromptControls } from "./PromptControls";
@ -7,6 +8,7 @@ const meta: Meta<typeof PromptControls> = {
title: "Groups/PromptControls",
component: PromptControls,
args: {
pagination: noopPagination,
onRefreshList: fn(),
onSelectPrompt: fn(),
onSearchChange: fn(),

View file

@ -4,6 +4,7 @@ import userEvent from "@testing-library/user-event";
import type { Prompt } from "@modelcontextprotocol/client";
import { renderWithMantine, screen } from "../../../test/renderWithMantine";
import { PromptControls, type PromptControlsProps } from "./PromptControls";
import { noopPagination } from "../../../test/fixtures/pagination";
const samplePrompts: Prompt[] = [
{
@ -25,6 +26,7 @@ const baseProps = {
onRefreshList: vi.fn(),
onSelectPrompt: vi.fn(),
onSearchChange: vi.fn(),
pagination: noopPagination,
};
// The search box is controlled: typing fires onSearchChange but does not

View file

@ -2,6 +2,10 @@ import { Group, ScrollArea, Stack, TextInput, Title } from "@mantine/core";
import { ClearButton } from "../../elements/ClearButton/ClearButton";
import type { Prompt } from "@modelcontextprotocol/client";
import { ListChangedIndicator } from "../../elements/ListChangedIndicator/ListChangedIndicator";
import {
ListPaginationControls,
type ListPaginationControlsProps,
} from "../../elements/ListPaginationControls/ListPaginationControls";
import { PromptListItem } from "../PromptListItem/PromptListItem";
import { useScrollMemory } from "../../../hooks/useScrollMemory";
@ -13,6 +17,8 @@ export interface PromptControlsProps {
searchText?: string;
listChanged: boolean;
onRefreshList: () => void;
/** Pagination controls (#1721). */
pagination: ListPaginationControlsProps;
onSearchChange: (value: string) => void;
onSelectPrompt: (name: string) => void;
}
@ -23,6 +29,7 @@ export function PromptControls({
searchText = "",
listChanged,
onRefreshList,
pagination,
onSearchChange,
onSelectPrompt,
}: PromptControlsProps) {
@ -53,6 +60,7 @@ export function PromptControls({
searchText ? <ClearButton onClick={() => onSearchChange("")} /> : null
}
/>
<ListPaginationControls {...pagination} />
<ScrollArea viewportRef={viewportRef} flex={1} mih={0}>
<Stack gap="xs">
{filteredPrompts.map((prompt) => (

View file

@ -1,4 +1,5 @@
import type { Meta, StoryObj } from "@storybook/react-vite";
import { noopPagination } from "../../../test/fixtures/pagination";
import type {
Resource,
ResourceTemplateType as ResourceTemplate,
@ -26,6 +27,7 @@ const meta: Meta<typeof ResourceControls> = {
title: "Groups/ResourceControls",
component: ResourceControls,
args: {
pagination: noopPagination,
onRefreshList: fn(),
onSelectUri: fn(),
onSelectTemplate: fn(),

View file

@ -11,6 +11,7 @@ import {
ResourceControls,
type ResourceControlsProps,
} from "./ResourceControls";
import { noopPagination } from "../../../test/fixtures/pagination";
const sampleResources: Resource[] = [
{ name: "config.json", uri: "file:///config.json" },
@ -41,6 +42,7 @@ const baseProps = {
onUnsubscribeResource: vi.fn(),
compact: false,
onCompactChange: vi.fn(),
pagination: noopPagination,
};
// ResourceControls is controlled: search text + accordion open-sections live in

View file

@ -7,6 +7,10 @@ import type {
} from "@modelcontextprotocol/client";
import type { InspectorResourceSubscription } from "../../../../../../core/mcp/types.js";
import { ListChangedIndicator } from "../../elements/ListChangedIndicator/ListChangedIndicator";
import {
ListPaginationControls,
type ListPaginationControlsProps,
} from "../../elements/ListPaginationControls/ListPaginationControls";
import { ListToggle } from "../../elements/ListToggle/ListToggle";
import { ResourceListItem } from "../ResourceListItem/ResourceListItem";
import { ResourceSubscribedItem } from "../ResourceSubscribedItem/ResourceSubscribedItem";
@ -32,6 +36,8 @@ export interface ResourceControlsProps {
openSections?: string[];
listChanged: boolean;
onRefreshList: () => void;
/** Pagination controls for the Resources list (#1721). */
pagination: ListPaginationControlsProps;
onSearchChange: (value: string) => void;
onOpenSectionsChange: (value: string[]) => void;
onSelectUri: (uri: string) => void;
@ -71,6 +77,7 @@ export function ResourceControls({
openSections: controlledOpenSections,
listChanged,
onRefreshList,
pagination,
onSearchChange,
onOpenSectionsChange,
onSelectUri,
@ -186,6 +193,7 @@ export function ResourceControls({
/>
<ListToggle compact={!allExpanded} onToggle={handleToggleList} />
</Group>
<ListPaginationControls {...pagination} />
<Accordion
multiple
variant="disclosure"

View file

@ -131,6 +131,12 @@ function InteractiveRender(args: ServerSettingsFormProps) {
settings: { ...args.settings, autoRefreshOnListChanged: value },
});
}}
onPaginatedListsChange={(value) => {
args.onPaginatedListsChange(value);
updateArgs({
settings: { ...args.settings, paginatedLists: value },
});
}}
onMaxFetchRequestsChange={(value) => {
args.onMaxFetchRequestsChange(value);
updateArgs({
@ -178,6 +184,7 @@ const meta: Meta<typeof ServerSettingsForm> = {
onMetadataChange: fn(),
onTimeoutChange: fn(),
onAutoRefreshChange: fn(),
onPaginatedListsChange: fn(),
onMaxFetchRequestsChange: fn(),
onProtocolEraChange: fn(),
onOAuthChange: fn(),

View file

@ -65,6 +65,7 @@ const baseHandlers = {
onMetadataChange: vi.fn(),
onTimeoutChange: vi.fn(),
onAutoRefreshChange: vi.fn(),
onPaginatedListsChange: vi.fn(),
onMaxFetchRequestsChange: vi.fn(),
onProtocolEraChange: vi.fn(),
onOAuthChange: vi.fn(),

View file

@ -58,6 +58,7 @@ export interface ServerSettingsFormProps {
value: number,
) => void;
onAutoRefreshChange: (value: boolean) => void;
onPaginatedListsChange: (value: boolean) => void;
onMaxFetchRequestsChange: (value: number) => void;
onProtocolEraChange: (value: ServerProtocolEra) => void;
onOAuthChange: (oauth: OAuthSettings) => void;
@ -239,6 +240,7 @@ export function ServerSettingsForm({
onMetadataChange,
onTimeoutChange,
onAutoRefreshChange,
onPaginatedListsChange,
onMaxFetchRequestsChange,
onProtocolEraChange,
onOAuthChange,
@ -314,6 +316,12 @@ export function ServerSettingsForm({
checked={settings.autoRefreshOnListChanged ?? false}
onChange={(e) => onAutoRefreshChange(e.currentTarget.checked)}
/>
<Checkbox
label="Fetch Lists One Page at a Time"
description="When checked, the Tools, Resources, and Prompts lists load a single page and reveal a “Load next page” control instead of auto-loading every page. Useful defensively for servers with very large lists. The per-list sidebar toggle sets this too."
checked={settings.paginatedLists ?? false}
onChange={(e) => onPaginatedListsChange(e.currentTarget.checked)}
/>
<NumberInput
label="Network Log Size"
description="Maximum number of HTTP requests kept in the Network log for this server. Older entries rotate out past this limit; a response body that arrives after its entry rotated out is dropped. Use 0 for unlimited (not recommended). Applies immediately to the active connection."

View file

@ -162,6 +162,10 @@ export function ServerSettingsModal({
onSettingsChange({ ...settings, autoRefreshOnListChanged: value });
}
function handlePaginatedListsChange(value: boolean) {
onSettingsChange({ ...settings, paginatedLists: value });
}
function handleMaxFetchRequestsChange(value: number) {
onSettingsChange({ ...settings, maxFetchRequests: value });
}
@ -232,6 +236,7 @@ export function ServerSettingsModal({
onMetadataChange={handleMetadataChange}
onTimeoutChange={handleTimeoutChange}
onAutoRefreshChange={handleAutoRefreshChange}
onPaginatedListsChange={handlePaginatedListsChange}
onMaxFetchRequestsChange={handleMaxFetchRequestsChange}
onProtocolEraChange={handleProtocolEraChange}
onOAuthChange={handleOAuthChange}

View file

@ -1,4 +1,5 @@
import { useState } from "react";
import { noopPagination } from "../../../test/fixtures/pagination";
import type { ComponentProps } from "react";
import type { Meta, StoryObj } from "@storybook/react-vite";
import { fn, userEvent, within } from "storybook/test";
@ -23,6 +24,7 @@ const meta: Meta<typeof ToolControls> = {
title: "Groups/ToolControls",
component: ToolControls,
args: {
pagination: noopPagination,
onRefreshList: fn(),
onSelectTool: fn(),
onSearchChange: fn(),

View file

@ -4,6 +4,7 @@ import userEvent from "@testing-library/user-event";
import type { Tool } from "@modelcontextprotocol/client";
import { renderWithMantine, screen } from "../../../test/renderWithMantine";
import { ToolControls, type ToolControlsProps } from "./ToolControls";
import { noopPagination } from "../../../test/fixtures/pagination";
const sampleTools: Tool[] = [
{ name: "list_files", title: "List Files", inputSchema: { type: "object" } },
@ -22,6 +23,7 @@ const baseProps = {
onRefreshList: vi.fn(),
onSelectTool: vi.fn(),
onSearchChange: vi.fn(),
pagination: noopPagination,
};
// The search box is controlled: typing fires onSearchChange but does not

View file

@ -2,6 +2,10 @@ import { Group, ScrollArea, Stack, TextInput, Title } from "@mantine/core";
import { ClearButton } from "../../elements/ClearButton/ClearButton";
import type { Tool } from "@modelcontextprotocol/client";
import { ListChangedIndicator } from "../../elements/ListChangedIndicator/ListChangedIndicator";
import {
ListPaginationControls,
type ListPaginationControlsProps,
} from "../../elements/ListPaginationControls/ListPaginationControls";
import { ToolListItem } from "../ToolListItem/ToolListItem";
import { useScrollMemory } from "../../../hooks/useScrollMemory";
@ -13,6 +17,8 @@ export interface ToolControlsProps {
searchText?: string;
listChanged: boolean;
onRefreshList: () => void;
/** Pagination controls (#1721). */
pagination: ListPaginationControlsProps;
onSearchChange: (value: string) => void;
onSelectTool: (name: string) => void;
}
@ -23,6 +29,7 @@ export function ToolControls({
searchText = "",
listChanged,
onRefreshList,
pagination,
onSearchChange,
onSelectTool,
}: ToolControlsProps) {
@ -61,6 +68,7 @@ export function ToolControls({
searchText ? <ClearButton onClick={() => onSearchChange("")} /> : null
}
/>
<ListPaginationControls {...pagination} />
<ScrollArea viewportRef={viewportRef} flex={1} mih={0}>
<Stack gap="xs">
{filteredTools.map((tool) => (

View file

@ -1,4 +1,5 @@
import { useState } from "react";
import { noopPagination } from "../../../test/fixtures/pagination";
import type { ComponentProps } from "react";
import type { Meta, StoryObj } from "@storybook/react-vite";
import type { Prompt } from "@modelcontextprotocol/client";
@ -21,6 +22,7 @@ const meta: Meta<typeof PromptsScreen> = {
component: PromptsScreen,
parameters: { layout: "fullscreen" },
args: {
pagination: noopPagination,
ui: EMPTY_PROMPTS_UI,
onUiChange: fn(),
onRefreshList: fn(),

View file

@ -3,6 +3,7 @@ import { describe, it, expect, vi } from "vitest";
import userEvent from "@testing-library/user-event";
import type { Prompt } from "@modelcontextprotocol/client";
import { renderWithMantine, screen } from "../../../test/renderWithMantine";
import { noopPagination } from "../../../test/fixtures/pagination";
import {
PromptsScreen,
type PromptsScreenProps,
@ -34,6 +35,7 @@ const baseProps = {
ui: EMPTY_PROMPTS_UI,
onUiChange: vi.fn(),
onRefreshList: vi.fn(),
pagination: noopPagination,
onGetPrompt: vi.fn(),
};

View file

@ -10,6 +10,7 @@ import {
} from "@mantine/core";
import type { GetPromptResult, Prompt } from "@modelcontextprotocol/client";
import { PromptControls } from "../../groups/PromptControls/PromptControls";
import type { ListPaginationControlsProps } from "../../elements/ListPaginationControls/ListPaginationControls";
import { PromptArgumentsForm } from "../../groups/PromptArgumentsForm/PromptArgumentsForm";
import { PromptMessagesDisplay } from "../../groups/PromptMessagesDisplay/PromptMessagesDisplay";
@ -32,6 +33,8 @@ export interface PromptsScreenProps {
completionsSupported?: boolean;
onUiChange: (next: PromptsUiState) => void;
onRefreshList: () => void;
/** Pagination controls rendered in the sidebar (#1721). */
pagination: ListPaginationControlsProps;
onGetPrompt: (name: string, args: Record<string, string>) => void;
onCopyMessages?: () => void;
onCompleteArgument?: (
@ -62,7 +65,9 @@ const ScreenLayout = Flex.withProps({
});
const Sidebar = Stack.withProps({
w: 340,
// Widened from 340 to comfortably fit the pagination controls
// (Load-next-page button + status) without cramping list entries (#1721).
w: 360,
flex: "0 0 auto",
});
@ -119,6 +124,7 @@ export function PromptsScreen({
completionsSupported,
onUiChange,
onRefreshList,
pagination,
onGetPrompt,
onCopyMessages,
onCompleteArgument,
@ -255,6 +261,7 @@ export function PromptsScreen({
searchText={search}
listChanged={listChanged}
onRefreshList={onRefreshList}
pagination={pagination}
onSearchChange={(value) => onUiChange({ ...ui, search: value })}
onSelectPrompt={handleSelectPrompt}
/>

View file

@ -1,4 +1,5 @@
import { useState } from "react";
import { noopPagination } from "../../../test/fixtures/pagination";
import type { ComponentProps } from "react";
import type { Meta, StoryObj } from "@storybook/react-vite";
import type {
@ -26,6 +27,7 @@ const meta: Meta<typeof ResourcesScreen> = {
component: ResourcesScreen,
parameters: { layout: "fullscreen" },
args: {
pagination: noopPagination,
ui: EMPTY_RESOURCES_UI,
onUiChange: fn(),
onRefreshList: fn(),

Some files were not shown because too many files have changed in this diff Show more