This repository was archived by the owner on Aug 1, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 488
Expand file tree
/
Copy pathChat.story.tsx
More file actions
88 lines (79 loc) · 2.96 KB
/
Copy pathChat.story.tsx
File metadata and controls
88 lines (79 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import { type DefaultContext, FIXTURE_MODELS } from '@sourcegraph/cody-shared'
import { ExtensionAPIProviderForTestsOnly, MOCK_API } from '@sourcegraph/prompt-editor'
import type { Meta, StoryObj } from '@storybook/react'
import { Observable } from 'observable-fns'
import { Chat } from './Chat'
import { FIXTURE_TRANSCRIPT } from './chat/fixtures'
import { FIXTURE_COMMANDS, makePromptsAPIWithData } from './components/promptList/fixtures'
import { VSCodeWebview } from './storybook/VSCodeStoryDecorator'
import { MockNoGuardrails } from './utils/guardrails'
const meta: Meta<typeof Chat> = {
title: 'cody/Chat',
component: Chat,
argTypes: {
transcript: {
name: 'Transcript fixture',
options: Object.keys(FIXTURE_TRANSCRIPT),
mapping: FIXTURE_TRANSCRIPT,
control: { type: 'select' },
models: FIXTURE_MODELS,
},
},
args: {
transcript: FIXTURE_TRANSCRIPT.simple2,
messageInProgress: null,
chatEnabled: true,
vscodeAPI: {
postMessage: () => {},
onMessage: () => () => {},
},
models: FIXTURE_MODELS,
guardrails: new MockNoGuardrails(),
} satisfies React.ComponentProps<typeof Chat>,
decorators: [VSCodeWebview],
}
export default meta
export const Default: StoryObj<typeof meta> = {}
export const Empty: StoryObj<typeof meta> = { args: { transcript: [] } }
export const EmptyWithPromptLibraryUnsupported: StoryObj<typeof meta> = {
args: { transcript: [] },
render: args => (
<ExtensionAPIProviderForTestsOnly
value={{
...MOCK_API,
userHistory: () => Observable.of(null),
defaultContext: () =>
Observable.of<DefaultContext>({ initialContext: [], corpusContext: [] }),
prompts: makePromptsAPIWithData({
arePromptsSupported: false,
prompts: [],
commands: FIXTURE_COMMANDS,
}),
evaluatedFeatureFlag: _flag => Observable.of(true),
}}
>
<Chat {...args} />
</ExtensionAPIProviderForTestsOnly>
),
}
export const EmptyWithNoPrompts: StoryObj<typeof meta> = {
args: { transcript: [] },
render: args => (
<ExtensionAPIProviderForTestsOnly
value={{
...MOCK_API,
userHistory: () => Observable.of(null),
defaultContext: () =>
Observable.of<DefaultContext>({ initialContext: [], corpusContext: [] }),
prompts: makePromptsAPIWithData({
prompts: [],
commands: FIXTURE_COMMANDS,
}),
evaluatedFeatureFlag: _flag => Observable.of(true),
}}
>
<Chat {...args} />
</ExtensionAPIProviderForTestsOnly>
),
}
export const Disabled: StoryObj<typeof meta> = { args: { chatEnabled: false } }