Skip to content

Commit ed7b3de

Browse files
committed
Rename the component to and add Storybook stories for settings
1 parent ca441e6 commit ed7b3de

9 files changed

Lines changed: 365 additions & 18 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Once the response is ready, suggested multi-file changes can be integrated with
3232

3333
⭐️ **Non-agentic nature**
3434

35-
CWC works solely on hand-picked context. This design choice was dictated by the fact LLMs cannot truly reason—they only match patters seen in training data, therefore they can't reliably make informed decisions (especially those less pronounced in training data). Although agentic coding shows plausible results to some, it is characterized by extensive token demand, slowness of operation and more prominent hallucinations.
35+
CWC works solely on hand-picked context. This design choice was dictated by the fact LLMs cannot truly reason—they only match patters seen in training data, therefore they can't reliably make informed decisions (especially those less pronounced in training data). Although agentic coding show plausible results, it is characterized by slowness of operation and extensive token demand.
3636

3737
## <span style="background-color: #fbb100; color: black; padding: 0.2em 0.6em; border-radius: 999px">Chatbot initialization</span>
3838

‎packages/ui/src/components/editor/settings/ApiProviders/index.ts‎

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
import { useState } from 'react'
2+
import { ConfigurationsList } from './ConfigurationsList'
3+
4+
export default {
5+
component: ConfigurationsList
6+
}
7+
8+
const initial_configurations: ConfigurationsList.Configuration[] = [
9+
{
10+
id: '1',
11+
model: 'gpt-4o',
12+
description: 'OpenAI - 1.0 temp',
13+
is_default: true
14+
},
15+
{
16+
id: '2',
17+
model: 'claude-3-haiku-20240307',
18+
description: 'Anthropic - 0.7 temp'
19+
},
20+
{
21+
id: '3',
22+
model: 'gemini-1.5-flash',
23+
description: 'Google - cache on'
24+
}
25+
]
26+
27+
const log_action =
28+
(action: string) =>
29+
(...args: any[]) => {
30+
console.log(action, ...args)
31+
}
32+
33+
export const Default = () => {
34+
const [configurations, set_configurations] = useState(initial_configurations)
35+
36+
const handle_set_default = (id: string) => {
37+
set_configurations(
38+
configurations.map((c) => ({
39+
...c,
40+
is_default: c.id == id
41+
}))
42+
)
43+
log_action('on_set_default')(id)
44+
}
45+
46+
const handle_unset_default = () => {
47+
set_configurations(
48+
configurations.map((c) => ({
49+
...c,
50+
is_default: false
51+
}))
52+
)
53+
log_action('on_unset_default')()
54+
}
55+
56+
return (
57+
<div
58+
style={{
59+
padding: '1rem',
60+
backgroundColor: 'var(--vscode-sideBar-background)'
61+
}}
62+
>
63+
<ConfigurationsList
64+
configurations={configurations}
65+
on_reorder={(reordered) => {
66+
set_configurations(reordered)
67+
log_action('on_reorder')(reordered)
68+
}}
69+
on_edit={log_action('on_edit')}
70+
on_delete={log_action('on_delete')}
71+
on_add={log_action('on_add')}
72+
on_set_default={handle_set_default}
73+
on_unset_default={handle_unset_default}
74+
/>
75+
</div>
76+
)
77+
}
78+
79+
export const NoDefaultOption = () => {
80+
const [configurations, set_configurations] = useState(
81+
initial_configurations.map(({ is_default, ...c }) => c)
82+
)
83+
84+
return (
85+
<div
86+
style={{
87+
padding: '1rem',
88+
backgroundColor: 'var(--vscode-sideBar-background)'
89+
}}
90+
>
91+
<ConfigurationsList
92+
configurations={configurations}
93+
on_reorder={(reordered) => {
94+
set_configurations(reordered)
95+
log_action('on_reorder')(reordered)
96+
}}
97+
on_edit={log_action('on_edit')}
98+
on_delete={log_action('on_delete')}
99+
on_add={log_action('on_add')}
100+
/>
101+
</div>
102+
)
103+
}
104+
105+
export const Empty = () => {
106+
return (
107+
<div
108+
style={{
109+
padding: '1rem',
110+
backgroundColor: 'var(--vscode-sideBar-background)'
111+
}}
112+
>
113+
<ConfigurationsList
114+
configurations={[]}
115+
on_reorder={log_action('on_reorder')}
116+
on_edit={log_action('on_edit')}
117+
on_delete={log_action('on_delete')}
118+
on_add={log_action('on_add')}
119+
on_set_default={log_action('on_set_default')}
120+
on_unset_default={log_action('on_unset_default')}
121+
/>
122+
</div>
123+
)
124+
}

packages/ui/src/components/editor/settings/ApiProviders/ApiProviders.module.scss renamed to packages/ui/src/components/editor/settings/ModelProviders/ModelProviders.module.scss

File renamed without changes.

packages/ui/src/components/editor/settings/ApiProviders/ApiProviders.stories.tsx renamed to packages/ui/src/components/editor/settings/ModelProviders/ModelProviders.stories.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import { ApiProviders } from './ApiProviders'
1+
import { ModelProviders } from './ModelProviders'
22
import { useState } from 'react'
33

44
export default {
5-
component: ApiProviders,
6-
title: 'Editor/Settings/ApiProviders'
5+
component: ModelProviders
76
}
87

9-
const initialProviders: ApiProviders.Provider[] = [
8+
const initial_providers: ModelProviders.Provider[] = [
109
{
1110
name: 'OpenAI',
1211
type: 'built-in',
@@ -28,19 +27,19 @@ const initialProviders: ApiProviders.Provider[] = [
2827
]
2928

3029
export const Default = () => {
31-
const [providers, setProviders] = useState(initialProviders)
30+
const [providers, set_providers] = useState(initial_providers)
3231
return (
3332
<div
3433
style={{
3534
padding: '1rem',
3635
backgroundColor: 'var(--vscode-sideBar-background)'
3736
}}
3837
>
39-
<ApiProviders
38+
<ModelProviders
4039
providers={providers}
4140
on_reorder={(reordered) => {
4241
console.log('reordered', reordered)
43-
setProviders(reordered)
42+
set_providers(reordered)
4443
}}
4544
on_add_provider={() => console.log('Add provider clicked')}
4645
on_delete_provider={(name) => console.log('Delete provider', name)}
@@ -59,7 +58,7 @@ export const Empty = () => {
5958
backgroundColor: 'var(--vscode-sideBar-background)'
6059
}}
6160
>
62-
<ApiProviders
61+
<ModelProviders
6362
providers={[]}
6463
on_reorder={(reordered) => console.log('reordered', reordered)}
6564
on_add_provider={() => console.log('Add provider clicked')}

packages/ui/src/components/editor/settings/ApiProviders/ApiProviders.tsx renamed to packages/ui/src/components/editor/settings/ModelProviders/ModelProviders.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import styles from './ApiProviders.module.scss'
1+
import styles from './ModelProviders.module.scss'
22
import { ReactSortable } from 'react-sortablejs'
33
import { IconButton } from '../../IconButton'
44

5-
export namespace ApiProviders {
5+
export namespace ModelProviders {
66
export type Provider = {
77
name: string
88
type: 'built-in' | 'custom'
@@ -21,15 +21,15 @@ export namespace ApiProviders {
2121
}
2222

2323
const with_ids = (
24-
providers: ApiProviders.Provider[]
25-
): (ApiProviders.Provider & { id: string })[] => {
24+
providers: ModelProviders.Provider[]
25+
): (ModelProviders.Provider & { id: string })[] => {
2626
return providers.map((provider) => ({
2727
...provider,
2828
id: provider.name
2929
}))
3030
}
3131

32-
export const ApiProviders: React.FC<ApiProviders.Props> = ({
32+
export const ModelProviders: React.FC<ModelProviders.Props> = ({
3333
providers,
3434
on_reorder,
3535
on_add_provider,
@@ -103,7 +103,7 @@ export const ApiProviders: React.FC<ApiProviders.Props> = ({
103103
) : (
104104
<div className={styles.row}>
105105
<div className={styles['empty-message']}>
106-
No API providers configured.
106+
No model providers configured.
107107
</div>
108108
</div>
109109
)}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { ModelProviders } from './ModelProviders'

0 commit comments

Comments
 (0)