Skip to content

Commit 19f84b7

Browse files
committed
Remove temporary apply button disabling logic
- don't timeout-dim 'apply from...' button in prompt view's footer └── apps └── editor └── src └── views └── prompt ├── backend │ └── prompt-view-provider.ts ├── frontend │ ├── Prompt.tsx │ ├── components │ │ └── Layout │ │ ├── Footer │ │ │ ├── Footer.module.scss │ │ │ ├── Footer.tsx │ │ │ └── index.ts │ │ ├── Layout.module.scss │ │ └── Layout.tsx │ ├── contexts │ │ └── LayoutContext.tsx │ ├── hooks │ │ └── use-prompt │ │ └── use-prompt.ts │ └── i18n │ └── translations │ └── footer.ts └── types └── messages.ts
1 parent 51533f4 commit 19f84b7

6 files changed

Lines changed: 4 additions & 54 deletions

File tree

‎apps/editor/src/views/prompt/backend/prompt-view-provider.ts‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -292,16 +292,6 @@ export class PromptViewProvider implements vscode.WebviewViewProvider {
292292
'edit'
293293
)
294294

295-
this.extension_context.subscriptions.push(
296-
vscode.window.onDidChangeWindowState(async (e) => {
297-
if (e.focused) {
298-
this.send_message({
299-
command: 'RESET_APPLY_BUTTON_TEMPORARY_DISABLED_STATE'
300-
})
301-
}
302-
})
303-
)
304-
305295
const tasks_file_path = TasksStorage.get_file_path(this.extension_context)
306296
const tasks_watcher = vscode.workspace.createFileSystemWatcher(
307297
new vscode.RelativePattern(

‎apps/editor/src/views/prompt/frontend/Prompt.tsx‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ export const Prompt = () => {
4242
main_view_scroll_reset_key,
4343
set_main_view_scroll_reset_key,
4444
version,
45-
apply_button_enabling_trigger_count,
4645
is_connected,
4746
ask_about_context_instructions,
4847
edit_files_instructions,
@@ -263,8 +262,7 @@ export const Prompt = () => {
263262
const layout_context_value = {
264263
can_undo,
265264
on_apply_click: handle_apply_click,
266-
on_undo_click: handle_undo_click,
267-
apply_button_enabling_trigger_count
265+
on_undo_click: handle_undo_click
268266
}
269267

270268
const current_state = get_current_instructions_state()

‎apps/editor/src/views/prompt/frontend/components/Layout/Footer/Footer.tsx‎

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState, useEffect, useContext } from 'react'
1+
import { useContext } from 'react'
22
import styles from './Footer.module.scss'
33
import { use_compacting } from '@shared/hooks'
44
import { LayoutContext } from '../../../contexts/LayoutContext'
@@ -10,39 +10,18 @@ type Props = {
1010
}
1111

1212
export const Footer: React.FC<Props> = (props) => {
13-
const {
14-
can_undo,
15-
on_apply_click,
16-
on_undo_click,
17-
apply_button_enabling_trigger_count
18-
} = useContext(LayoutContext)
13+
const { can_undo, on_apply_click, on_undo_click } = useContext(LayoutContext)
1914

2015
const { t } = use_translation()
2116

2217
const history_label = t('footer.action.history')
2318
const undo_label = t('footer.action.undo')
2419
const apply_label = t('footer.action.apply-from')
2520

26-
const [is_apply_disabled_temporarily, set_is_apply_disabled_temporarily] =
27-
useState(false)
28-
2921
const { container_ref, compact_step } = use_compacting()
3022

31-
useEffect(() => {
32-
set_is_apply_disabled_temporarily(false)
33-
}, [apply_button_enabling_trigger_count])
34-
35-
useEffect(() => {
36-
// Timeout prevents jitter of non disabled state caused by order of updates.
37-
setTimeout(() => {
38-
set_is_apply_disabled_temporarily(false)
39-
}, 500)
40-
}, [can_undo])
41-
4223
const handle_apply_click = () => {
43-
set_is_apply_disabled_temporarily(true)
4424
on_apply_click()
45-
setTimeout(() => set_is_apply_disabled_temporarily(false), 3000)
4625
}
4726

4827
return (
@@ -70,7 +49,6 @@ export const Footer: React.FC<Props> = (props) => {
7049
className={styles['apply-button']}
7150
onClick={handle_apply_click}
7251
title={t('footer.apply-title')}
73-
disabled={is_apply_disabled_temporarily}
7452
>
7553
{apply_label}
7654
</button>

‎apps/editor/src/views/prompt/frontend/contexts/LayoutContext.tsx‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ type LayoutContextType = {
44
can_undo: boolean
55
on_apply_click: () => void
66
on_undo_click: () => void
7-
apply_button_enabling_trigger_count: number
87
}
98

109
export const LayoutContext = createContext<LayoutContextType>({
1110
can_undo: false,
1211
on_apply_click: () => {},
13-
on_undo_click: () => {},
14-
apply_button_enabling_trigger_count: 0
12+
on_undo_click: () => {}
1513
})

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ export const use_prompt = (vscode: any) => {
2020
const [main_view_scroll_reset_key, set_main_view_scroll_reset_key] =
2121
useState(0)
2222
const [version, set_version] = useState<string>('')
23-
const [
24-
apply_button_enabling_trigger_count,
25-
set_apply_button_enabling_trigger_count
26-
] = useState(0)
2723
const [is_connected, set_is_connected] = useState<boolean>()
2824
const [target, set_target] = useState<Target>()
2925
const [web_prompt_type, set_web_mode] = useState<WebPromptType>()
@@ -186,10 +182,6 @@ export const use_prompt = (vscode: any) => {
186182
set_send_with_shift_enter(message.enabled)
187183
} else if (message.command === 'FOCUS_PROMPT_FIELD') {
188184
set_chat_input_focus_key((k) => k + 1)
189-
} else if (
190-
message.command === 'RESET_APPLY_BUTTON_TEMPORARY_DISABLED_STATE'
191-
) {
192-
set_apply_button_enabling_trigger_count((c) => c + 1)
193185
} else if (message.command === 'CAN_UNDO_CHANGED') {
194186
set_can_undo(message.can_undo)
195187
} else if (message.command === 'RECORDING_STATE') {
@@ -327,7 +319,6 @@ export const use_prompt = (vscode: any) => {
327319
main_view_scroll_reset_key,
328320
set_main_view_scroll_reset_key,
329321
version,
330-
apply_button_enabling_trigger_count,
331322
is_connected,
332323
ask_about_context_instructions,
333324
edit_files_instructions,

‎apps/editor/src/views/prompt/types/messages.ts‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -957,10 +957,6 @@ export interface CanUndoChangedMessage extends BaseMessage {
957957
can_undo: boolean
958958
}
959959

960-
export interface ResetApplyButtonTemporaryDisabledStateMessage extends BaseMessage {
961-
command: 'RESET_APPLY_BUTTON_TEMPORARY_DISABLED_STATE'
962-
}
963-
964960
export interface SendWithShiftEnterMessage extends BaseMessage {
965961
command: 'SEND_WITH_SHIFT_ENTER'
966962
enabled: boolean
@@ -1114,7 +1110,6 @@ export type BackendMessage =
11141110
| VersionMessage
11151111
| SendWithShiftEnterMessage
11161112
| CanUndoChangedMessage
1117-
| ResetApplyButtonTemporaryDisabledStateMessage
11181113
| ResponsePreviewStartedMessage
11191114
| ResponsePreviewFinishedMessage
11201115
| WorkspaceStateMessage

0 commit comments

Comments
 (0)