Skip to content

Commit 8ab2f15

Browse files
committed
Improve response preview focus handling by auto-focusing Accept and refocusing chat input on finish, with updated button focus outlines
- once response preview opens, 'accept' button should be focused - should set [Fragment] after 3 seconds from the response preview start - set opacity to the outline 50% - outline color should follow button's backgorund color (with exception to secondary: there follow 'color') - once response preview gets closed, prompt field should be focused ├── apps │ └── editor │ └── src │ └── views │ └── prompt │ ├── backend │ │ └── prompt-view-provider.ts │ ├── frontend │ │ ├── Main │ │ │ ├── Main.tsx │ │ │ └── MainView │ │ │ └── MainView.tsx │ │ ├── Prompt.tsx │ │ └── hooks │ │ ├── use-preview-manager.ts │ │ └── use-prompt │ │ └── use-prompt.ts │ └── types │ └── messages.ts └── packages └── ui └── src └── components └── editor ├── common │ ├── Button │ │ ├── Button.module.scss │ │ ├── Button.tsx │ │ └── index.ts │ └── prompts │ └── PromptField │ ├── PromptField.tsx │ └── hooks │ └── use-handlers │ └── use-handlers.ts └── prompt-view ├── Page │ ├── Page.tsx │ └── index.ts └── ResponsePreviewFooter ├── ResponsePreviewFooter.tsx └── index.ts
1 parent fe15edf commit 8ab2f15

3 files changed

Lines changed: 27 additions & 2 deletions

File tree

‎apps/editor/src/views/prompt/frontend/hooks/use-prompt/use-prompt.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ export const use_prompt = (vscode: any) => {
194194
set_is_modern_ui(message.is_modern_ui)
195195
} else if (message.command === 'API_CONFIGURATIONS') {
196196
set_api_configurations((message as any).configurations)
197+
} else if (message.command === 'RESPONSE_PREVIEW_FINISHED') {
198+
set_chat_input_focus_key((k) => k + 1)
197199
}
198200
}
199201
window.addEventListener('message', handle_message)

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919
text-decoration: none;
2020
}
2121

22-
&:focus-visible {
22+
&:focus {
2323
outline-offset: 2px;
24-
outline: 1px solid var(--vscode-focusBorder);
24+
outline: 1px solid
25+
color-mix(in srgb, var(--vscode-button-background) 50%, transparent);
2526
}
2627

2728
&:disabled {
@@ -37,6 +38,10 @@
3738
background-color: var(--cwc-bg-secondary);
3839
color: var(--cwc-text-color);
3940

41+
&:focus {
42+
outline-color: var(--cwc-bg-secondary);
43+
}
44+
4045
&:hover {
4146
background-color: var(--cwc-bg-primary);
4247
}
@@ -51,6 +56,14 @@
5156
&--danger {
5257
background-color: var(--vscode-inputValidation-errorBorder);
5358

59+
&:focus {
60+
outline-color: color-mix(
61+
in srgb,
62+
var(--vscode-inputValidation-errorBorder) 50%,
63+
transparent
64+
);
65+
}
66+
5467
&:hover {
5568
background-color: color-mix(
5669
in srgb,

‎packages/ui/src/components/editor/prompt-view/ResponsePreviewFooter/ResponsePreviewFooter.tsx‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useEffect, useState } from 'react'
12
import { use_compacting } from '@shared/hooks'
23
import { Button } from '../../common/Button'
34
import styles from './ResponsePreviewFooter.module.scss'
@@ -11,6 +12,14 @@ type Props = {
1112

1213
export const ResponsePreviewFooter: React.FC<Props> = (props) => {
1314
const { container_ref, compact_step } = use_compacting()
15+
const [is_accept_focused, set_is_accept_focused] = useState(false)
16+
17+
useEffect(() => {
18+
const timeout = setTimeout(() => {
19+
set_is_accept_focused(true)
20+
}, 500)
21+
return () => clearTimeout(timeout)
22+
}, [])
1423

1524
return (
1625
<div className={styles.container} ref={container_ref}>
@@ -34,6 +43,7 @@ export const ResponsePreviewFooter: React.FC<Props> = (props) => {
3443
on_click={props.on_accept}
3544
disabled={props.is_accept_disabled}
3645
title="Accept"
46+
is_focused={is_accept_focused}
3747
codicon={compact_step >= 3 ? 'check' : undefined}
3848
>
3949
{compact_step < 3 && <span>Accept</span>}

0 commit comments

Comments
 (0)