Skip to content

Commit 3dcc2d6

Browse files
committed
Refactor the Changes component to ResponseReview and implement a new feature to display and manage a history of received chat responses awaiting review
1 parent ba7c37a commit 3dcc2d6

17 files changed

Lines changed: 283 additions & 50 deletions

File tree

‎packages/ui/src/components/editor/panel/Button/Button.module.scss‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
.button {
2-
width: 100%;
32
display: flex;
43
align-items: center;
54
justify-content: center;
@@ -46,4 +45,10 @@
4645
}
4746
}
4847
}
48+
49+
&--small {
50+
min-height: 24px;
51+
font-size: var(--font-size-12px);
52+
padding: var(--padding-2px) var(--padding-8px);
53+
}
4954
}

‎packages/ui/src/components/editor/panel/Button/Button.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ type Props = {
1010
title?: string
1111
is_secondary?: boolean
1212
is_focused?: boolean
13+
is_small?: boolean
1314
}
1415

1516
export const Button: FC<Props> = (props) => {
@@ -25,7 +26,8 @@ export const Button: FC<Props> = (props) => {
2526
<button
2627
ref={button_ref}
2728
className={cn(styles.button, {
28-
[styles['button--secondary']]: props.is_secondary
29+
[styles['button--secondary']]: props.is_secondary,
30+
[styles['button--small']]: props.is_small
2931
})}
3032
onClick={props.on_click}
3133
disabled={props.disabled}

‎packages/ui/src/components/editor/panel/Changes/index.ts‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎packages/ui/src/components/editor/panel/ChatInput/ChatInput.module.scss‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,7 @@
192192
}
193193

194194
> svg {
195-
width: 12px;
196-
height: 12px;
195+
height: 11px;
197196
fill: var(--vscode-icon-foreground);
198197
}
199198
}

‎packages/ui/src/components/editor/panel/Page/Page.module.scss‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
font-weight: 600;
3333
transform: translateX(-50%);
3434
font-size: var(--font-size-14px);
35+
white-space: nowrap;
3536
}
3637

3738
&__right {

packages/ui/src/components/editor/panel/Changes/Changes.module.scss renamed to packages/ui/src/components/editor/panel/ResponseReview/ResponseReview.module.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,8 @@
130130
display: flex;
131131
gap: var(--padding-8px);
132132
padding: var(--padding-12px);
133+
134+
> button {
135+
flex: 1;
136+
}
133137
}

packages/ui/src/components/editor/panel/Changes/Changes.stories.tsx renamed to packages/ui/src/components/editor/panel/ResponseReview/ResponseReview.stories.tsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { useState } from 'react'
2-
import { Changes } from './Changes'
2+
import { ResponseReview } from './ResponseReview'
33

44
export default {
5-
component: Changes
5+
component: ResponseReview
66
}
77

88
const base_files = [
@@ -58,7 +58,7 @@ const log_action =
5858
console.log(action, ...args)
5959
}
6060

61-
const InteractiveChanges = (props: any) => {
61+
const InteractiveResponseReview = (props: any) => {
6262
const [files, set_files] = useState(
6363
props.files.map((f: any) => ({ ...f, is_checked: true }))
6464
)
@@ -83,31 +83,33 @@ const InteractiveChanges = (props: any) => {
8383
}
8484

8585
return (
86-
<Changes
86+
<ResponseReview
8787
{...props}
8888
files={files}
8989
on_toggle_file={handle_toggle_file}
90-
on_undo={log_action('on_undo')}
91-
on_keep={log_action('on_keep')}
90+
on_discard={log_action('on_undo')}
91+
on_approve={log_action('on_keep')}
9292
on_focus_file={log_action('on_focus_file')}
9393
on_go_to_file={log_action('on_go_to_file')}
9494
on_intelligent_update={log_action('on_intelligent_update')}
9595
/>
9696
)
9797
}
9898

99-
export const Default = () => <InteractiveChanges files={base_files} />
99+
export const Default = () => <InteractiveResponseReview files={base_files} />
100100

101101
export const WithSingleFile = () => (
102-
<InteractiveChanges files={[base_files[0]]} />
102+
<InteractiveResponseReview files={[base_files[0]]} />
103103
)
104104

105105
export const WithFallbacks = () => (
106-
<InteractiveChanges files={[...base_files, ...files_using_fallbacks]} />
106+
<InteractiveResponseReview
107+
files={[...base_files, ...files_using_fallbacks]}
108+
/>
107109
)
108110

109111
export const WithMultipleWorkspaces = () => (
110-
<InteractiveChanges
112+
<InteractiveResponseReview
111113
files={[
112114
{
113115
...base_files[0],

packages/ui/src/components/editor/panel/Changes/Changes.tsx renamed to packages/ui/src/components/editor/panel/ResponseReview/ResponseReview.tsx

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { FC, useState, useMemo } from 'react'
22
import { FileInReview } from '@shared/types/file-in-review'
33
import cn from 'classnames'
4-
import styles from './Changes.module.scss'
4+
import styles from './ResponseReview.module.scss'
55
import { Button } from '../Button'
66
import { Checkbox } from '../Checkbox'
77
import { IconButton } from '../IconButton/IconButton'
88

99
type Props = {
1010
files: (FileInReview & { is_checked: boolean })[]
1111
has_multiple_workspaces: boolean
12-
on_undo: () => void
13-
on_keep: (files: FileInReview[]) => void
12+
on_discard: () => void
13+
on_approve: (files: FileInReview[]) => void
1414
on_focus_file: (file: { file_path: string; workspace_name?: string }) => void
1515
on_go_to_file: (file: { file_path: string; workspace_name?: string }) => void
1616
on_intelligent_update: (file: {
@@ -25,11 +25,11 @@ type Props = {
2525
raw_instructions?: string
2626
}
2727

28-
export const Changes: FC<Props> = ({
28+
export const ResponseReview: FC<Props> = ({
2929
files,
3030
has_multiple_workspaces,
31-
on_undo,
32-
on_keep,
31+
on_discard,
32+
on_approve,
3333
on_focus_file,
3434
on_go_to_file,
3535
on_toggle_file,
@@ -38,9 +38,9 @@ export const Changes: FC<Props> = ({
3838
}) => {
3939
const [last_clicked_file_index, set_last_clicked_file_index] = useState(0)
4040

41-
const handle_keep = () => {
41+
const handle_approve = () => {
4242
const accepted_files = files.filter((f) => f.is_checked)
43-
on_keep(accepted_files)
43+
on_approve(accepted_files)
4444
}
4545

4646
const fallback_count = files.filter((f) => f.is_fallback).length
@@ -200,17 +200,16 @@ export const Changes: FC<Props> = ({
200200
})}
201201
</div>
202202
<div className={styles.footer}>
203-
<Button on_click={on_undo} is_secondary>
204-
<span className="codicon codicon-redo" />
205-
206-
{files.length > 1 ? 'Discard All' : 'Discard'}
203+
<Button on_click={on_discard} is_secondary>
204+
<span className="codicon codicon-close" />
205+
Discard
207206
</Button>
208207
<Button
209-
on_click={handle_keep}
208+
on_click={handle_approve}
210209
disabled={files.filter((f) => f.is_checked).length == 0}
211210
>
212211
<span className="codicon codicon-check" />
213-
{files.length > 1 ? 'Approve Selected' : 'Approve'}
212+
Approve
214213
</Button>
215214
</div>
216215
</div>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './ResponseReview'

‎packages/ui/src/styles/global.scss‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ button {
2121
padding: 0;
2222
font-size: var(--font-size-13px);
2323
font-family: inherit;
24+
color: inherit;
2425
}
2526

2627
button:not(:disabled) {

0 commit comments

Comments
 (0)