diff --git a/.vscode/launch.json b/.vscode/launch.json index df4e6540..760b7607 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -165,6 +165,27 @@ }, "console": "integratedTerminal", "internalConsoleOptions": "openOnSessionStart" + }, + { + "name": "Open Storybook", + "type": "node", + "request": "launch", + "runtimeExecutable": "npm", + "runtimeArgs": [ + "run", + "storybook" + ], + "cwd": "${workspaceFolder}/webview-ui", + "console": "integratedTerminal", + "internalConsoleOptions": "neverOpen", + "serverReadyAction": { + "pattern": "Local:.*http://localhost:([0-9]+)", + "uriFormat": "http://localhost:%s", + "action": "openExternally" + }, + "env": { + "IS_DEV": "true" + } } ] } diff --git a/.vscode/tasks.json b/.vscode/tasks.json index d6fddc52..e9254187 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -263,6 +263,26 @@ "watch" ], "command": "rm -rf ${workspaceFolder}/dist/tmp/user && mkdir -p ${workspaceFolder}/dist/tmp/user" + }, + { + "type": "npm", + "script": "storybook", + "group": "build", + "problemMatcher": [], + "isBackground": false, + "label": "npm: storybook", + "dependsOn": [ + "npm: protos", + "npm: build:webview" + ], + "presentation": { + "reveal": "always" + }, + "options": { + "env": { + "IS_DEV": "true" + } + } } ], "inputs": [ diff --git a/package.json b/package.json index f2c562fe..7e3fd369 100644 --- a/package.json +++ b/package.json @@ -359,7 +359,8 @@ "docs": "cd docs && npm run dev", "docs:check-links": "cd docs && npm run check", "docs:rename-file": "cd docs && npm run rename", - "report-issue": "node scripts/report-issue.js" + "report-issue": "node scripts/report-issue.js", + "storybook": "cd webview-ui && npm run storybook" }, "lint-staged": { "*": [ diff --git a/webview-ui/.storybook/themes.ts b/webview-ui/.storybook/themes.ts index b205a47a..55263aec 100644 --- a/webview-ui/.storybook/themes.ts +++ b/webview-ui/.storybook/themes.ts @@ -2,12 +2,19 @@ const mockVSCodeDarkTheme = { "--vscode-editor-background": "#1E1E1E", "--vscode-editor-foreground": "#D4D4D4", "--vscode-sideBar-background": "#252526", + "--vscode-sideBar-foreground": "#CCCCCC", "--vscode-editorGroup-border": "#454545", "--vscode-descriptionForeground": "#CCCCCC99", + "--vscode-foreground": "#D4D4D4", "--vscode-button-background": "#007ACC", "--vscode-button-foreground": "#FFFFFF", + "--vscode-button-hoverBackground": "#005A9E", + "--vscode-button-separator": "#FFFFFF4D", "--vscode-button-secondaryBackground": "#383B3D", + "--vscode-button-secondaryForeground": "#CCCCCC", + "--vscode-button-secondaryHoverBackground": "#454545", "--vscode-textLink-foreground": "#6fc3df", + "--vscode-textLink-activeForeground": "#9CCBFF", "--vscode-errorForeground": "#f48771", "--vscode-editorWidget-border": "#303031", "--vscode-editorError-foreground": "#f14c4c", @@ -20,6 +27,8 @@ const mockVSCodeDarkTheme = { "--vscode-focusBorder": "#007ACC", "--vscode-input-border": "#6B6B6B", "--vscode-banner-background": "#007ACC", + "--vscode-banner-foreground": "#FFFFFF", + "--vscode-banner-iconForeground": "#FFFFFF", "--vscode-titleBar-inactiveForeground": "#BBBBBB", "--vscode-input-foreground": "#D4D4D4", "--vscode-input-background": "#383B3D", @@ -34,24 +43,42 @@ const mockVSCodeDarkTheme = { "--vscode-menu-background": "#252526", "--vscode-menu-border": "#454545", "--vscode-menu-foreground": "#CCCCCC", + "--vscode-menu-shadow": "#00000050", "--vscode-menu-selectionBackground": "#062F4A", "--vscode-menu-selectionForeground": "#FFFFFF", "--vscode-inputValidation-errorBackground": "#eb1424", "--vscode-inputValidation-errorForeground": "#fcd1c1", "--vscode-editor-foldBackground": "#252526", "--vscode-editor-foldPlaceholderForeground": "#454545", + "--vscode-list-activeSelectionBackground": "#094771", + "--vscode-list-activeSelectionForeground": "#FFFFFF", + "--vscode-list-hoverBackground": "#2D2D30", + "--vscode-editor-border": "#454545", + "--vscode-textCodeBlock-background": "#3E3E42", + "--vscode-toolbar-background": "#252526", + "--vscode-toolbar-hoverBackground": "#3E3E42", + "--vscode-widget-shadow": "#00000050", + "--vscode-panel-border": "#454545", + "--vscode-icon-foreground": "#CCCCCC", } const mockVSCodeLightTheme = { "--vscode-editor-background": "#FFFFFF", "--vscode-editor-foreground": "#000000", "--vscode-sideBar-background": "#F3F3F3", + "--vscode-sideBar-foreground": "#3E3E42", "--vscode-editorGroup-border": "#D4D4D4", "--vscode-descriptionForeground": "#6F6F6F", + "--vscode-foreground": "#000000", "--vscode-button-background": "#007ACC", "--vscode-button-foreground": "#FFFFFF", + "--vscode-button-hoverBackground": "#005A9E", + "--vscode-button-separator": "#0000001F", "--vscode-button-secondaryBackground": "#E8E8E8", + "--vscode-button-secondaryForeground": "#3E3E42", + "--vscode-button-secondaryHoverBackground": "#D5D5D5", "--vscode-textLink-foreground": "#6fc3df", + "--vscode-textLink-activeForeground": "#0078D4", "--vscode-errorForeground": "#c72e0f", "--vscode-editorWidget-border": "#D4D4D4", "--vscode-editorError-foreground": "#c72e0f", @@ -64,6 +91,8 @@ const mockVSCodeLightTheme = { "--vscode-focusBorder": "#007ACC", "--vscode-input-border": "#CECECE", "--vscode-banner-background": "#007ACC", + "--vscode-banner-foreground": "#FFFFFF", + "--vscode-banner-iconForeground": "#FFFFFF", "--vscode-titleBar-inactiveForeground": "#919191", "--vscode-input-foreground": "#000000", "--vscode-input-background": "#FFFFFF", @@ -77,10 +106,21 @@ const mockVSCodeLightTheme = { "--vscode-menu-background": "#F3F3F3", "--vscode-menu-border": "#D4D4D4", "--vscode-menu-foreground": "#6F6F6F", + "--vscode-menu-shadow": "#00000029", "--vscode-menu-selectionBackground": "#007ACC", "--vscode-menu-selectionForeground": "#FFFFFF", "--vscode-inputValidation-errorBackground": "#f48771", "--vscode-inputValidation-errorForeground": "#c72e0f", + "--vscode-list-activeSelectionBackground": "#094771", + "--vscode-list-activeSelectionForeground": "#FFFFFF", + "--vscode-list-hoverBackground": "#F0F0F0", + "--vscode-editor-border": "#D4D4D4", + "--vscode-textCodeBlock-background": "#F5F5F5", + "--vscode-toolbar-background": "#F3F3F3", + "--vscode-toolbar-hoverBackground": "#E8E8E8", + "--vscode-widget-shadow": "#00000033", + "--vscode-panel-border": "#D4D4D4", + "--vscode-icon-foreground": "#3E3E42", } // Mock VSCode theme variables for Storybook diff --git a/webview-ui/src/App.stories.tsx b/webview-ui/src/App.stories.tsx index 7699a7ff..bd9de4a5 100644 --- a/webview-ui/src/App.stories.tsx +++ b/webview-ui/src/App.stories.tsx @@ -1,6 +1,7 @@ import { HeroUIProvider } from "@heroui/react" import { DEFAULT_AUTO_APPROVAL_SETTINGS } from "@shared/AutoApprovalSettings" -import type { ApiConfiguration } from "@shared/api" +import { type ApiConfiguration, bedrockModels } from "@shared/api" +import { CLINE_ONBOARDING_MODELS } from "@shared/cline/onboarding" import type { ClineMessage } from "@shared/ExtensionMessage" import type { HistoryItem } from "@shared/HistoryItem" import type { Meta, StoryObj } from "@storybook/react-vite" @@ -8,16 +9,21 @@ import { useMemo } from "react" import { expect, userEvent, within } from "storybook/test" import { ExtensionStateContext, useExtensionState } from "@/context/ExtensionStateContext" import ChatView from "./components/chat/ChatView" +import OnboardingView from "./components/onboarding/OnboardingView" import WelcomeView from "./components/welcome/WelcomeView" // Mock component that mimics App behavior but works in Storybook const MockApp = () => { - const { showWelcome } = useExtensionState() + const { showWelcome, onboardingModels } = useExtensionState() return ( {showWelcome ? ( - + onboardingModels ? ( + + ) : ( + + ) ) : ( {}} isHidden={false} showAnnouncement={false} showHistoryView={() => {}} /> )} @@ -220,6 +226,8 @@ const createMockState = (overrides: any = {}) => ({ clineMessages: mockActiveMessages, taskHistory: mockTaskHistory, apiConfiguration: mockApiConfiguration, + onboardingModels: undefined, + openRouterModels: bedrockModels, ...overrides, }) @@ -238,7 +246,7 @@ const createStoryDecorator = ) } -export const WelcomeScreen: Story = { +export const Welcome: Story = { decorators: [createStoryDecorator({ welcomeViewCompleted: false, showWelcome: true, clineMessages: [] })], parameters: { docs: { @@ -262,6 +270,96 @@ export const WelcomeScreen: Story = { }, } +export const Onboarding: Story = { + decorators: [ + createStoryDecorator({ + welcomeViewCompleted: false, + showWelcome: true, + clineMessages: [], + onboardingModels: { models: CLINE_ONBOARDING_MODELS }, + }), + ], + parameters: { + docs: { + description: { + story: "The onboarding flow shown to new users, allowing them to select their preferred AI models and configure initial settings.", + }, + }, + }, + args: { + onboardingModels: { models: CLINE_ONBOARDING_MODELS }, + }, + argTypes: { + onboardingModels: { + control: { type: "object" }, + }, + }, + // More on component testing: https://storybook.js.org/docs/writing-tests/interaction-testing + play: async ({ canvasElement }) => { + const canvas = within(canvasElement) + + // Step 0: User type selection should be visible + const title = canvas.getByText("How will you use Cline?") + await expect(title).toBeInTheDocument() + const freeUserOption = canvas.getByText("Absolutely Free") + const powerUserOption = canvas.getByText("Frontier Model") + await expect(freeUserOption).toBeInTheDocument() + await expect(powerUserOption).toBeInTheDocument() + + // Select "Free User" option + await userEvent.click(freeUserOption) + + // Verify the next button appears + const nextButton = canvas.getByText("Continue") + await expect(nextButton).toBeInTheDocument() + + // Click next to go to model selection + await userEvent.click(nextButton) + + // Step 1: Model selection should be visible + // Check for model group headers + const otherOptionsHeader = canvas.getByText("Select a free model") + + // At least one should be visible + await expect(otherOptionsHeader).toBeInTheDocument() + + // Test search functionality + const searchInput = canvas.getByPlaceholderText("Search model...") + await expect(searchInput).toBeInTheDocument() + + // Type in search box + await userEvent.type(searchInput, "claude") + + // Verify search term is in the input + await expect(searchInput).toHaveValue("claude") + + // Clear search + await userEvent.clear(searchInput) + + // Verify sign in button appears after model selection + const signInButton = canvas.getByText("Create my Account") + await expect(signInButton).toBeInTheDocument() + + // Test back navigation + const backButton = canvas.getByText("Back") + await expect(backButton).toBeInTheDocument() + await userEvent.click(backButton) + + // Should be back to user type selection + await expect(canvas.getByText("How will you use Cline?")).toBeInTheDocument() + + // Test power user flow + await userEvent.click(powerUserOption) + + const continueButton = canvas.getByText("Continue") + await userEvent.click(continueButton) + + // Should see model selection again + await expect(canvas.getByPlaceholderText("Search model...")).toBeInTheDocument() + await userEvent.click(canvas.getByText("Back")) + }, +} + export const ActiveConversation: Story = { decorators: [createStoryDecorator({ task: mockTaskHistory[0], currentTaskItem: mockTaskHistory[0] })], parameters: {