Phase 2: Refactor Prompts cluster to MCP SDK types
Replace ad hoc local types with MCP SDK schema types across the Prompts group components and PromptsScreen, per the v2 UX interfaces plan. - PromptListItem: accept `prompt: Prompt` instead of flat `name`/`description`; render `title ?? name` as primary label - PromptControls: accept `Prompt[]` + `selectedName` instead of `PromptItem[]`; no-op on clicking already-selected prompt; search includes title field - PromptArgumentsForm: accept `prompt: Prompt` instead of flat props; read `prompt.arguments` directly; display `title ?? name` as heading - PromptMessagesDisplay: narrow type from `(PromptMessage | SamplingMessage)[]` to `PromptMessage[]` per spec - PromptsScreen: accept `Prompt[]` + `selectedPromptName` + `GetPromptState`; derive selected prompt via `prompts.find()`; own `argumentValues` state locally; reset arguments on tool switch - Delete local `PromptItem`, `SelectedPrompt`, `PromptArgument` types - Update all stories with real SDK `Prompt` fixtures - Update ConnectedView PromptsActive story Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
12c41cbed7
commit
de40b3720e
2 changed files with 230 additions and 226 deletions
|
|
@ -15,23 +15,40 @@ type Story = StoryObj<typeof PromptListItem>;
|
|||
|
||||
export const Default: Story = {
|
||||
args: {
|
||||
name: "summarize",
|
||||
description: "Summarize the given text into key points",
|
||||
prompt: {
|
||||
name: "summarize",
|
||||
description: "Summarize the given text into key points",
|
||||
},
|
||||
selected: false,
|
||||
},
|
||||
};
|
||||
|
||||
export const Selected: Story = {
|
||||
args: {
|
||||
name: "translate",
|
||||
description: "Translate text from one language to another",
|
||||
prompt: {
|
||||
name: "translate",
|
||||
description: "Translate text from one language to another",
|
||||
},
|
||||
selected: true,
|
||||
},
|
||||
};
|
||||
|
||||
export const WithTitle: Story = {
|
||||
args: {
|
||||
prompt: {
|
||||
name: "code-review",
|
||||
title: "Code Review",
|
||||
description: "Review code for issues and best practices",
|
||||
},
|
||||
selected: false,
|
||||
},
|
||||
};
|
||||
|
||||
export const NoDescription: Story = {
|
||||
args: {
|
||||
name: "code-review",
|
||||
prompt: {
|
||||
name: "code-review",
|
||||
},
|
||||
selected: false,
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { Stack, Text, UnstyledButton } from "@mantine/core";
|
||||
import type { Prompt } from "@modelcontextprotocol/sdk/types.js";
|
||||
|
||||
export interface PromptListItemProps {
|
||||
name: string;
|
||||
description?: string;
|
||||
prompt: Prompt;
|
||||
selected: boolean;
|
||||
onClick: () => void;
|
||||
}
|
||||
|
|
@ -18,11 +18,11 @@ const DescriptionText = Text.withProps({
|
|||
});
|
||||
|
||||
export function PromptListItem({
|
||||
name,
|
||||
description,
|
||||
prompt,
|
||||
selected,
|
||||
onClick,
|
||||
}: PromptListItemProps) {
|
||||
const { name, title, description } = prompt;
|
||||
return (
|
||||
<UnstyledButton
|
||||
w="100%"
|
||||
|
|
@ -32,7 +32,7 @@ export function PromptListItem({
|
|||
onClick={onClick}
|
||||
>
|
||||
<Stack gap={2}>
|
||||
<NameText>{name}</NameText>
|
||||
<NameText>{title ?? name}</NameText>
|
||||
{description && <DescriptionText>{description}</DescriptionText>}
|
||||
</Stack>
|
||||
</UnstyledButton>
|
||||
|
|
|
|||
Loading…
Reference in a new issue