Skip to content

Commit fdf5cc4

Browse files
committed
Add fallback handling for unavailable apply targets and update CompactableActionButton disabled state
- disabled compactable buttons should still register clicks and in their handler emit info notifications like: 'Nothing to undo.', 'Nothing to commit', 'Applying is not available here.' (use appropriate translations) ├── apps │ └── editor │ └── src │ ├── commands │ │ └── generate-commit-message-commands │ │ ├── actions │ │ │ └── run-generate-action.ts │ │ └── generate-commit-message-commands.ts │ ├── i18n │ │ └── translations │ │ ├── utils │ │ │ ├── git-repository-utils.ts │ │ │ └── index.ts │ │ └── views │ │ └── prompt │ │ └── handlers │ │ ├── handle-apply.ts │ │ ├── handle-undo.ts │ │ └── index.ts │ ├── utils │ │ └── git-repository-utils.ts │ └── views │ └── prompt │ ├── backend │ │ ├── message-handlers │ │ │ ├── handle-apply.ts │ │ │ ├── handle-get-workspace-state.ts │ │ │ ├── handle-request-can-undo.ts │ │ │ └── handle-undo.ts │ │ └── prompt-view-provider.ts │ ├── frontend │ │ ├── Prompt.tsx │ │ ├── components │ │ │ └── Layout │ │ │ └── Footer │ │ │ └── Footer.tsx │ │ ├── contexts │ │ │ └── LayoutContext.tsx │ │ └── hooks │ │ ├── use-editor-sync.ts │ │ └── use-prompt │ │ └── use-prompt.ts │ └── types │ └── messages.ts └── packages └── ui └── src └── components └── editor └── prompt-view └── CompactableActionButton ├── CompactableActionButton.module.scss └── CompactableActionButton.tsx
1 parent 4002dbc commit fdf5cc4

5 files changed

Lines changed: 32 additions & 4 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
export const translations = {
2+
'views.prompt.handlers.handle-apply.applying-is-not-available-here': {
3+
en: 'Applying is not available here.',
4+
pl: 'Aplikowanie nie jest tutaj dostępne.',
5+
'zh-cn': '此处不可应用。',
6+
ja: 'ここでは適用できません。',
7+
'zh-tw': '此處不可應用。',
8+
de: 'Anwenden ist hier nicht verfügbar.',
9+
es: 'Aplicar no está disponible aquí.',
10+
fr: "L'application n'est pas disponible ici.",
11+
'pt-br': 'Aplicar não está disponível aqui.',
12+
ru: 'Применение здесь недоступно.',
13+
ko: '여기에서는 적용할 수 없습니다.',
14+
it: "L'applicazione non è disponibile qui.",
15+
tr: 'Uygulama burada mevcut değil.',
16+
cs: 'Použití zde není dostupné.',
17+
hu: 'Az alkalmazás itt nem érhető el.',
18+
bg: 'Прилагането не е достъпно тук.'
19+
}
20+
} as const

‎apps/editor/src/i18n/translations/views/prompt/handlers/index.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import { translations as handle_save_completed_tasks } from './handle-save-compl
1313
import { translations as handle_clear_completed_tasks } from './handle-clear-completed-tasks'
1414
import { translations as handle_show_accuracy_boost_info } from './handle-show-accuracy-boost-info'
1515
import { translations as handle_select_terminal_interactivity } from './handle-select-terminal-interactivity'
16+
import { translations as handle_apply } from './handle-apply'
17+
1618
export const translations = {
1719
...handle_delete_task,
1820
...handle_make_api_call,
@@ -28,5 +30,6 @@ export const translations = {
2830
...handle_save_completed_tasks,
2931
...handle_clear_completed_tasks,
3032
...handle_show_accuracy_boost_info,
31-
...handle_select_terminal_interactivity
33+
...handle_select_terminal_interactivity,
34+
...handle_apply
3235
}

‎apps/editor/src/views/prompt/backend/message-handlers/handle-apply.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as vscode from 'vscode'
2+
import { t } from '@/i18n'
23
import { PromptViewProvider } from '@/views/prompt/backend/prompt-view-provider'
34
import { ApplyMessage } from '@/views/prompt/types/messages'
45

@@ -12,5 +13,9 @@ export const handle_apply = async (
1213
await vscode.commands.executeCommand('codeWebChat.applyFromClipboard')
1314
} else if (target === 'CLI') {
1415
await vscode.commands.executeCommand('codeWebChat.applyFromTerminal')
16+
} else {
17+
vscode.window.showInformationMessage(
18+
t('views.prompt.handlers.handle-apply.applying-is-not-available-here')
19+
)
1520
}
1621
}

‎packages/ui/src/components/editor/prompt-view/CompactableActionButton/CompactableActionButton.module.scss‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
border: 1px solid var(--cwc-border-color-dimmed);
1111
color: inherit;
1212

13-
&:hover:not(:disabled) {
13+
&:hover:not([data-disabled='true']) {
1414
background-color: var(--vscode-toolbar-hoverBackground);
1515
border-color: var(--cwc-border-color);
1616
text-decoration: none;
1717
}
1818

19-
&:disabled {
19+
&[data-disabled='true'] {
2020
opacity: var(--disabled-opacity);
2121
cursor: default;
2222
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const CompactableActionButton: React.FC<CompactableActionButtonProps> = (
4949
className={className}
5050
onClick={props.on_click}
5151
title={props.title}
52-
disabled={props.disabled}
52+
data-disabled={props.disabled ? 'true' : undefined}
5353
>
5454
{content}
5555
</button>

0 commit comments

Comments
 (0)