Skip to content

Commit d889143

Browse files
committed
Refactor the response history display in the main view to show items in chronological order and update the logic for handling new responses and ongoing reviews
1 parent dff629d commit d889143

10 files changed

Lines changed: 45 additions & 45 deletions

File tree

‎packages/shared/src/constants/dictionary.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ export const dictionary = {
4444
},
4545

4646
warning_message: {
47-
REVIEW_ONGOING_DISCARD:
48-
'A review is currently ongoing. Would you like to discard it?',
47+
REVIEW_ONGOING:
48+
'Another response review is currently ongoing. Would you like to switch to the new one?',
4949
SKIPPING_INVALID_PATH: (file_path: string) =>
5050
`Skipping applying change to invalid path: ${file_path}`,
5151
NO_VALID_CODE_BLOCKS_IN_CLIPBOARD:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.container {
2-
--padding: var(--padding-5px) var(--padding-20px) var(--padding-5px)
2+
--padding: var(--padding-4px) var(--padding-20px) var(--padding-4px)
33
var(--padding-7px);
44
position: relative;
55

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,6 @@
44
height: 100%;
55
background-color: var(--vscode-sideBar-background);
66
position: relative;
7-
8-
&--has-outline::after {
9-
content: '';
10-
position: absolute;
11-
z-index: 1;
12-
width: 100%;
13-
height: 100%;
14-
outline: 1px solid var(--vscode-focusBorder);
15-
outline-offset: -1px;
16-
pointer-events: none;
17-
}
187
}
198

209
.header {

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import cn from 'classnames'
21
import styles from './Page.module.scss'
32
import { Scrollable } from '../Scrollable'
43
import { IconButton } from '../IconButton'
@@ -9,16 +8,11 @@ type Props = {
98
on_close_click?: () => void
109
header_slot?: React.ReactNode
1110
children: React.ReactNode
12-
has_outline?: boolean
1311
}
1412

1513
export const Page: React.FC<Props> = (props) => {
1614
return (
17-
<div
18-
className={cn(styles.container, {
19-
[styles['container--has-outline']]: props.has_outline
20-
})}
21-
>
15+
<div className={styles.container}>
2216
<div className={styles.header}>
2317
{props.title && (
2418
<div className={styles.header__title}>{props.title}</div>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
}
66

77
.info {
8-
padding: var(--padding-5px) var(--padding-7px);
8+
padding: var(--padding-4px) var(--padding-7px);
99
color: var(--vscode-descriptionForeground);
1010
font-size: var(--padding-12px);
1111
border: 1px solid var(--vscode-sideBarSectionHeader-border);
@@ -21,7 +21,7 @@
2121

2222
.instructions {
2323
position: relative;
24-
padding: var(--padding-5px) var(--padding-20px) var(--padding-5px)
24+
padding: var(--padding-4px) var(--padding-20px) var(--padding-4px)
2525
var(--padding-7px);
2626
color: var(--vscode-descriptionForeground);
2727
border: 1px solid var(--vscode-sideBarSectionHeader-border);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ button {
2222
font-size: var(--font-size-13px);
2323
font-family: inherit;
2424
color: inherit;
25+
line-height: inherit;
2526
}
2627

2728
button:not(:disabled) {

‎packages/vscode/src/commands/apply-chat-response-command/apply-chat-response-command.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,12 +411,12 @@ export const apply_chat_response_command = (
411411

412412
if (code_review_promise_resolve) {
413413
const choice = await vscode.window.showWarningMessage(
414-
dictionary.warning_message.REVIEW_ONGOING_DISCARD,
414+
dictionary.warning_message.REVIEW_ONGOING,
415415
{ modal: true },
416-
'Apply Another Chat Response'
416+
'Switch'
417417
)
418418

419-
if (choice == 'Apply Another Chat Response') {
419+
if (choice == 'Switch') {
420420
code_review_promise_resolve({ accepted_files: [] })
421421
if (ongoing_review_cleanup_promise) {
422422
await ongoing_review_cleanup_promise

‎packages/vscode/src/views/panel/frontend/Main/MainView/MainView.module.scss‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
.responses {
2020
padding: 0 var(--padding-12px);
2121
display: flex;
22-
flex-direction: column-reverse;
22+
flex-direction: column;
2323

24-
&__list-item {
24+
&__item {
2525
display: flex;
2626
align-items: center;
2727
justify-content: space-between;
2828
gap: var(--padding-8px);
29-
padding: var(--padding-5px) var(--padding-7px);
29+
padding: var(--padding-5px) var(--padding-8px);
3030
border-radius: var(--border-radius-4px);
3131
width: 100%;
3232
text-align: left;

‎packages/vscode/src/views/panel/frontend/Main/MainView/MainView.tsx‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,8 @@ export const MainView: React.FC<Props> = (props) => {
316316
{props.response_history.map((item) => (
317317
<button
318318
key={item.created_at}
319-
className={cn(styles['responses__list-item'], {
320-
[styles['responses__list-item--selected']]:
319+
className={cn(styles['responses__item'], {
320+
[styles['responses__item--selected']]:
321321
props.selected_history_item_created_at ==
322322
item.created_at
323323
})}
@@ -327,12 +327,10 @@ export const MainView: React.FC<Props> = (props) => {
327327
props.on_selected_history_item_change(item.created_at)
328328
}}
329329
>
330-
<span
331-
className={styles['responses__list-item__instruction']}
332-
>
330+
<span className={styles['responses__item__instruction']}>
333331
{item.raw_instructions || 'Response without instructions'}
334332
</span>
335-
<span className={styles['responses__list-item__date']}>
333+
<span className={styles['responses__item__date']}>
336334
{dayjs(item.created_at).fromNow()}
337335
</span>
338336
</button>

‎packages/vscode/src/views/panel/frontend/Panel.tsx‎

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -173,22 +173,41 @@ export const Panel = () => {
173173
set_commit_button_enabling_trigger_count((k) => k + 1)
174174
} else if (message.command == 'NEW_RESPONSE_RECEIVED') {
175175
const now = Date.now()
176-
if (response_history.length == 0) {
176+
177+
if (!response_history.length) {
177178
set_selected_history_item_created_at(now)
179+
set_response_history([
180+
{
181+
response: message.response,
182+
raw_instructions: message.raw_instructions,
183+
created_at: now
184+
}
185+
])
178186
}
179-
set_response_history((prev_history) => {
187+
const is_duplicate = response_history.some(
188+
(item) =>
189+
item.response == message.response &&
190+
item.raw_instructions == message.raw_instructions
191+
)
192+
if (!is_duplicate) {
180193
const new_item = {
181194
response: message.response,
182195
raw_instructions: message.raw_instructions,
183196
created_at: now
184197
}
185-
const is_duplicate = prev_history.some(
186-
(item) =>
187-
item.response == new_item.response &&
188-
item.raw_instructions == new_item.raw_instructions
198+
set_response_history([...response_history, new_item])
199+
if (!files_to_review) {
200+
set_selected_history_item_created_at(now)
201+
}
202+
} else {
203+
set_selected_history_item_created_at(
204+
response_history.find(
205+
(item) =>
206+
item.response == message.response &&
207+
item.raw_instructions == message.raw_instructions
208+
)?.created_at
189209
)
190-
return is_duplicate ? prev_history : [new_item, ...prev_history]
191-
})
210+
}
192211
}
193212
}
194213
window.addEventListener('message', handle_message)
@@ -208,7 +227,7 @@ export const Panel = () => {
208227
initial_messages.forEach((message) => post_message(vscode, message))
209228

210229
return () => window.removeEventListener('message', handle_message)
211-
}, [response_history])
230+
}, [response_history, files_to_review])
212231

213232
const edit_preset_back_click_handler = () => {
214233
post_message(vscode, {
@@ -449,7 +468,6 @@ export const Panel = () => {
449468
<div className={styles.slot}>
450469
<UiPage
451470
title="Response Review"
452-
has_outline={true}
453471
on_back_click={() => {
454472
post_message(vscode, { command: 'EDITS_REVIEW', files: [] })
455473
}}

0 commit comments

Comments
 (0)