Skip to content

Commit d67d316

Browse files
committed
Add #ClipboardPaths symbol to reference files matching clipboard paths and internationalize hash-sign symbol error messages
- add missing translations to `apps/editor/src/i18n/translations/views/prompt/handlers/hash-sign.ts` - add new symbol "Clipboard paths" #ClipboardPaths (Description: "Files matching paths found in the clipboard"). Replacement logic: Place "# Additional files" section and reference in instructions by backticked paths. - add close button to `apps/editor/src/commands/select-clipboard-paths-command.ts` when it lists workspaces - `apps/editor/src/commands/select-files-of-commit-command.ts` misses titlebar with close button when showing workspaces - in `packages/ui/src/components/editor/common/prompts/PromptField/PromptField.tsx` add support for new symbol: "#ClipboardPaths" ├── apps │ └── editor │ └── src │ ├── commands │ │ ├── select-clipboard-paths-command.ts │ │ ├── select-definition-file-command.ts │ │ ├── select-files-of-commit-command.ts │ │ └── select-imported-files-command.ts │ ├── i18n │ │ └── translations │ │ └── views │ │ └── prompt │ │ └── handlers │ │ └── hash-sign.ts │ ├── utils │ │ ├── files-collector.ts │ │ └── git-repository-utils.ts │ └── views │ └── prompt │ └── backend │ ├── message-handlers │ │ ├── handle-autofill.ts │ │ └── handle-hash-sign-quick-pick │ │ ├── handle-hash-sign-quick-pick.ts │ │ ├── index.ts │ │ └── symbols │ │ ├── changes-symbol.ts │ │ ├── clipboard-paths-symbol.ts │ │ ├── commit-symbol.ts │ │ ├── index.ts │ │ ├── saved-context-symbol.ts │ │ ├── selection-symbol.ts │ │ └── skill-symbol.ts │ ├── prompt-view-provider.ts │ └── utils │ └── symbols │ ├── clipboard-paths │ │ └── replace-clipboard-paths-symbol.ts │ ├── fragment │ │ └── replace-fragment-symbol.ts │ ├── git │ │ └── replace-git-symbols.ts │ ├── image │ │ └── replace-image-symbol.ts │ ├── pasted-text │ │ └── replace-pasted-text-symbol.ts │ ├── replace-symbols.ts │ ├── saved-context │ │ └── replace-saved-context-symbol.ts │ ├── selection │ │ └── replace-selection-symbol.ts │ ├── skill │ │ └── replace-skill-symbol.ts │ └── website │ └── replace-website-symbol.ts └── packages └── ui └── src └── components └── editor └── common └── prompts ├── PromptField │ ├── PromptField.module.scss │ ├── PromptField.stories.tsx │ ├── PromptField.tsx │ ├── components │ │ ├── Tooltip.module.scss │ │ ├── Tooltip.tsx │ │ └── index.ts │ ├── hooks │ │ ├── use-drag-drop.ts │ │ ├── use-dropdown.ts │ │ ├── use-ghost-text.ts │ │ ├── use-handlers │ │ │ ├── handle-copy.ts │ │ │ ├── handle-cut.ts │ │ │ ├── handle-input-change.ts │ │ │ ├── handle-input-click.ts │ │ │ ├── handle-key-down.ts │ │ │ ├── handle-paste.ts │ │ │ ├── handle-submit.ts │ │ │ ├── index.ts │ │ │ ├── types.ts │ │ │ ├── use-handlers.ts │ │ │ └── utils.ts │ │ └── use-keyboard-shortcuts.ts │ └── index.ts ├── Template │ ├── Template.module.scss │ ├── Template.tsx │ └── index.ts └── shared └── symbols ├── caret.ts ├── get-highlighted-text.tsx ├── index.ts ├── position-mapping.ts ├── prompt-symbols.module.scss ├── reconstruct-raw-value.ts └── use-symbol-deletion.ts
1 parent 5136107 commit d67d316

17 files changed

Lines changed: 454 additions & 26 deletions

File tree

‎apps/editor/src/commands/select-clipboard-paths-command.ts‎

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,53 @@ export const select_clipboard_paths_command = (
110110
absolute_paths: ws.absolute_paths
111111
}))
112112

113-
const selected_workspace = await vscode.window.showQuickPick(
114-
quick_pick_items,
115-
{
116-
title: t('command.select-clipboard-paths.title'),
117-
placeHolder: 'Select workspace for clipboard paths',
118-
ignoreFocusOut: true
113+
const quick_pick = vscode.window.createQuickPick<
114+
vscode.QuickPickItem & {
115+
root: string
116+
absolute_paths: string[]
119117
}
120-
)
118+
>()
119+
quick_pick.title = 'Workspaces'
120+
quick_pick.placeholder = 'Select workspace for clipboard paths'
121+
quick_pick.items = quick_pick_items
122+
123+
const close_button = {
124+
iconPath: new vscode.ThemeIcon('close'),
125+
tooltip: t('common.close')
126+
}
127+
quick_pick.buttons = [close_button]
128+
129+
const selected_workspace = await new Promise<
130+
| (vscode.QuickPickItem & {
131+
root: string
132+
absolute_paths: string[]
133+
})
134+
| undefined
135+
>((resolve) => {
136+
let is_accepted = false
137+
138+
quick_pick.onDidTriggerButton((button) => {
139+
if (button === close_button) {
140+
resolve(undefined)
141+
quick_pick.hide()
142+
}
143+
})
144+
145+
quick_pick.onDidAccept(() => {
146+
is_accepted = true
147+
resolve(quick_pick.selectedItems[0])
148+
quick_pick.hide()
149+
})
150+
151+
quick_pick.onDidHide(() => {
152+
if (!is_accepted) {
153+
resolve(undefined)
154+
}
155+
quick_pick.dispose()
156+
})
157+
158+
quick_pick.show()
159+
})
121160

122161
if (!selected_workspace) {
123162
current_step = 'finish'

‎apps/editor/src/i18n/translations/views/prompt/handlers/hash-sign.ts‎

Lines changed: 110 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,114 @@ export const translations = {
5353
cs: 'Nebyly nalezeny žádné uložené kontexty.',
5454
hu: 'Nem találhatók mentett kontextusok.',
5555
bg: 'Няма намерени запазени контексти.'
56-
}
56+
},
57+
'views.prompt.handlers.hash-sign.commit-symbol.no-git-repo': {
58+
en: 'No Git repository found in the workspace.',
59+
pl: 'Nie znaleziono repozytorium Git w obszarze roboczym.',
60+
'zh-cn': '工作区中未找到 Git 存储库。',
61+
ja: 'ワークスペースに Git リポジトリが見つかりません。',
62+
'zh-tw': '工作區中未找到 Git 儲存庫。',
63+
de: 'Kein Git-Repository im Arbeitsbereich gefunden.',
64+
es: 'No se encontró ningún repositorio Git en el espacio de trabajo.',
65+
fr: "Aucun dépôt Git trouvé dans l'espace de travail.",
66+
'pt-br': 'Nenhum repositório Git encontrado no espaço de trabalho.',
67+
ru: 'В рабочей области не найден репозиторий Git.',
68+
ko: '작업 공간에서 Git 저장소를 찾을 수 없습니다.',
69+
it: "Nessun repository Git trovato nell'area di lavoro.",
70+
tr: 'Çalışma alanında Git deposu bulunamadı.',
71+
cs: 'V pracovním prostoru nebylo nalezeno žádné úložiště Git.',
72+
hu: 'Nem található Git tároló a munkaterületen.',
73+
bg: 'Не е намерено Git хранилище в работното пространство.'
74+
},
75+
'views.prompt.handlers.hash-sign.commit-symbol.no-commits': {
76+
en: 'No git commits found in "{0}".',
77+
pl: 'Nie znaleziono zatwierdzeń git w "{0}".',
78+
'zh-cn': '在 "{0}" 中未找到 git 提交。',
79+
ja: '"{0}" に git コミットが見つかりません。',
80+
'zh-tw': '在 "{0}" 中未找到 git 提交。',
81+
de: 'Keine Git-Commits in "{0}" gefunden.',
82+
es: 'No se encontraron confirmaciones de git en "{0}".',
83+
fr: 'Aucun commit git trouvé dans "{0}".',
84+
'pt-br': 'Nenhum commit do git encontrado em "{0}".',
85+
ru: 'В "{0}" не найдено коммитов git.',
86+
ko: '"{0}"에서 git 커밋을 찾을 수 없습니다.',
87+
it: 'Nessun commit git trovato in "{0}".',
88+
tr: '"{0}" içinde git işlemesi bulunamadı.',
89+
cs: 'V "{0}" nebyly nalezeny žádné odevzdání git.',
90+
hu: 'Nem találhatók git commitok a(z) "{0}" tárolóban.',
91+
bg: 'Не са намерени git къмити в "{0}".'
92+
},
93+
'views.prompt.handlers.hash-sign.commit-symbol.failed-to-get-commits': {
94+
en: 'Failed to get git commits. Please ensure git is installed.',
95+
pl: 'Nie udało się pobrać zatwierdzeń git. Upewnij się, że git jest zainstalowany.',
96+
'zh-cn': '获取 git 提交失败。请确保已安装 git。',
97+
ja: 'git コミットの取得に失敗しました。git がインストールされていることを確認してください。',
98+
'zh-tw': '獲取 git 提交失敗。請確保已安裝 git。',
99+
de: 'Fehler beim Abrufen der Git-Commits. Bitte stellen Sie sicher, dass Git installiert ist.',
100+
es: 'Error al obtener las confirmaciones de git. Asegúrese de que git esté instalado.',
101+
fr: "Échec de l'obtention des commits git. Veuillez vous assurer que git est installé.",
102+
'pt-br':
103+
'Falha ao obter os commits do git. Certifique-se de que o git está instalado.',
104+
ru: 'Не удалось получить коммиты git. Убедитесь, что git установлен.',
105+
ko: 'git 커밋을 가져오는 데 실패했습니다. git이 설치되어 있는지 확인하십시오.',
106+
it: 'Impossibile ottenere i commit git. Assicurati che git sia installato.',
107+
tr: "Git işlemeleri alınamadı. Lütfen git'in yüklü olduğundan emin olun.",
108+
cs: 'Nepodařilo se získat odevzdání git. Ujistěte se, že je git nainstalován.',
109+
hu: 'Nem sikerült lekérni a git commitokat. Kérjük, ellenőrizze, hogy a git telepítve van-e.',
110+
bg: 'Неуспешно получаване на git къмити. Моля, уверете се, че git е инсталиран.'
111+
},
112+
'views.prompt.handlers.hash-sign.saved-context-symbol.failed-to-load': {
113+
en: 'Failed to load saved contexts. Please check your configuration.',
114+
pl: 'Nie udało się załadować zapisanych kontekstów. Sprawdź swoją konfigurację.',
115+
'zh-cn': '加载保存的上下文失败。请检查您的配置。',
116+
ja: '保存されたコンテキストの読み込みに失敗しました。設定を確認してください。',
117+
'zh-tw': '加載儲存的上下文失敗。請檢查您的配置。',
118+
de: 'Fehler beim Laden gespeicherter Kontexte. Bitte überprüfen Sie Ihre Konfiguration.',
119+
es: 'Error al cargar los contextos guardados. Por favor verifique su configuración.',
120+
fr: 'Échec du chargement des contextes enregistrés. Veuillez vérifier votre configuration.',
121+
'pt-br': 'Falha ao carregar contextos salvos. Verifique sua configuração.',
122+
ru: 'Не удалось загрузить сохраненные контексты. Пожалуйста, проверьте вашу конфигурацию.',
123+
ko: '저장된 컨텍스트를 로드하지 못했습니다. 구성을 확인하십시오.',
124+
it: 'Impossibile caricare i contesti salvati. Controlla la tua configurazione.',
125+
tr: 'Kaydedilen bağlamlar yüklenemedi. Lütfen yapılandırmanızı kontrol edin.',
126+
cs: 'Nepodařilo se načíst uložené kontexty. Zkontrolujte prosím svou konfiguraci.',
127+
hu: 'Nem sikerült betölteni a mentett kontextusokat. Kérjük, ellenőrizze a konfigurációt.',
128+
bg: 'Неуспешно зареждане на запазените контексти. Моля, проверете конфигурацията си.'
129+
},
130+
'views.prompt.handlers.hash-sign.skill-symbol.no-agents': {
131+
en: 'No supported agents with skills detected.',
132+
pl: 'Nie wykryto obsługiwanych agentów z umiejętnościami.',
133+
'zh-cn': '未检测到支持技能的代理。',
134+
ja: 'スキルを持つサポート対象のエージェントが検出されませんでした。',
135+
'zh-tw': '未檢測到支援技能的代理。',
136+
de: 'Keine unterstützten Agenten mit Skills erkannt.',
137+
es: 'No se detectaron agentes compatibles con habilidades.',
138+
fr: 'Aucun agent pris en charge avec des compétences détecté.',
139+
'pt-br': 'Nenhum agente suportado com habilidades detectado.',
140+
ru: 'Не обнаружено поддерживаемых агентов с навыками.',
141+
ko: '스킬을 가진 지원되는 에이전트가 감지되지 않았습니다.',
142+
it: 'Nessun agente supportato con competenze rilevato.',
143+
tr: 'Yeteneklere sahip desteklenen ajan bulunamadı.',
144+
cs: 'Nebyli zjištěni žádní podporovaní agenti s dovednostmi.',
145+
hu: 'Nem találhatók támogatott ágensek képességekkel.',
146+
bg: 'Не са открити поддържани агенти с умения.'
147+
},
148+
'views.prompt.handlers.hash-sign.skill-symbol.no-skills': {
149+
en: 'No skills found for {0}.',
150+
pl: 'Nie znaleziono umiejętności dla {0}.',
151+
'zh-cn': '未找到 {0} 的技能。',
152+
ja: '{0} のスキルが見つかりません。',
153+
'zh-tw': '未找到 {0} 的技能。',
154+
de: 'Keine Skills für {0} gefunden.',
155+
es: 'No se encontraron habilidades para {0}.',
156+
fr: 'Aucune compétence trouvée pour {0}.',
157+
'pt-br': 'Nenhuma habilidade encontrada para {0}.',
158+
ru: 'Навыки для {0} не найдены.',
159+
ko: '{0}에 대한 스킬을 찾을 수 없습니다.',
160+
it: 'Nessuna competenza trovata per {0}.',
161+
tr: '{0} için yetenek bulunamadı.',
162+
cs: 'Pro {0} nebyly nalezeny žádné dovednosti.',
163+
hu: 'Nem találhatók képességek a(z) {0} számára.',
164+
bg: 'Не са намерени умения за {0}.'
165+
}
57166
} as const

‎apps/editor/src/utils/git-repository-utils.ts‎

Lines changed: 74 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,43 @@ export const get_git_repository = async (
6969
}
7070
})
7171

72-
const selected = await vscode.window.showQuickPick(picks, {
73-
placeHolder: t('command.generate-commit-message.select-repository')
72+
const quick_pick = vscode.window.createQuickPick<
73+
vscode.QuickPickItem & { repository: GitRepository }
74+
>()
75+
quick_pick.title = 'Workspaces'
76+
quick_pick.placeholder = t(
77+
'command.generate-commit-message.select-repository'
78+
)
79+
quick_pick.items = picks
80+
quick_pick.buttons = [
81+
{ iconPath: new vscode.ThemeIcon('close'), tooltip: t('common.close') }
82+
]
83+
84+
const selected = await new Promise<
85+
(vscode.QuickPickItem & { repository: GitRepository }) | undefined
86+
>((resolve) => {
87+
let is_accepted = false
88+
const disposables: vscode.Disposable[] = []
89+
90+
disposables.push(
91+
quick_pick.onDidTriggerButton(() => {
92+
resolve(undefined)
93+
quick_pick.hide()
94+
}),
95+
quick_pick.onDidAccept(() => {
96+
is_accepted = true
97+
resolve(quick_pick.selectedItems[0])
98+
quick_pick.hide()
99+
}),
100+
quick_pick.onDidHide(() => {
101+
if (!is_accepted) {
102+
resolve(undefined)
103+
}
104+
disposables.forEach((d) => d.dispose())
105+
quick_pick.dispose()
106+
})
107+
)
108+
quick_pick.show()
74109
})
75110

76111
if (!selected) {
@@ -125,8 +160,43 @@ export const get_repository_for_commit = async (
125160
}
126161
})
127162

128-
const selected = await vscode.window.showQuickPick(picks, {
129-
placeHolder: t('command.generate-commit-message.select-repository')
163+
const quick_pick = vscode.window.createQuickPick<
164+
vscode.QuickPickItem & { repository: GitRepository }
165+
>()
166+
quick_pick.title = 'Workspaces'
167+
quick_pick.placeholder = t(
168+
'command.generate-commit-message.select-repository'
169+
)
170+
quick_pick.items = picks
171+
quick_pick.buttons = [
172+
{ iconPath: new vscode.ThemeIcon('close'), tooltip: t('common.close') }
173+
]
174+
175+
const selected = await new Promise<
176+
(vscode.QuickPickItem & { repository: GitRepository }) | undefined
177+
>((resolve) => {
178+
let is_accepted = false
179+
const disposables: vscode.Disposable[] = []
180+
181+
disposables.push(
182+
quick_pick.onDidTriggerButton(() => {
183+
resolve(undefined)
184+
quick_pick.hide()
185+
}),
186+
quick_pick.onDidAccept(() => {
187+
is_accepted = true
188+
resolve(quick_pick.selectedItems[0])
189+
quick_pick.hide()
190+
}),
191+
quick_pick.onDidHide(() => {
192+
if (!is_accepted) {
193+
resolve(undefined)
194+
}
195+
disposables.forEach((d) => d.dispose())
196+
quick_pick.dispose()
197+
})
198+
)
199+
quick_pick.show()
130200
})
131201

132202
if (!selected) {

‎apps/editor/src/views/prompt/backend/message-handlers/handle-hash-sign-quick-pick/handle-hash-sign-quick-pick.ts‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@ import {
66
handle_changes_item,
77
handle_commit_item,
88
handle_saved_context_item,
9-
handle_skill_item
9+
handle_skill_item,
10+
handle_clipboard_paths_item
1011
} from './symbols'
1112

1213
const selection_label = '$(list-flat) Selection'
1314
const changes_label = '$(git-pull-request-draft) Changes'
1415
const commit_label = '$(git-commit) Commit'
1516
const saved_context_label = '$(checklist) Saved context'
1617
const skill_label = '$(thinking) Skill'
18+
const clipboard_paths_label = '$(clippy) Clipboard paths'
1719

1820
const hash_sign_quick_pick = async (params: {
1921
extension_context: vscode.ExtensionContext
@@ -38,13 +40,17 @@ const hash_sign_quick_pick = async (params: {
3840
},
3941
{
4042
label: skill_label,
41-
description: 'Reference an installed skill',
43+
description: 'Files of a selected skill',
4244
buttons: [
4345
{
4446
iconPath: new vscode.ThemeIcon('globe'),
4547
tooltip: 'Discover skills at skills.sh'
4648
}
4749
]
50+
},
51+
{
52+
label: clipboard_paths_label,
53+
description: 'Files matching paths found in the clipboard'
4854
}
4955
]
5056

@@ -126,6 +132,9 @@ const hash_sign_quick_pick = async (params: {
126132
case skill_label:
127133
result = await handle_skill_item()
128134
break
135+
case clipboard_paths_label:
136+
result = await handle_clipboard_paths_item()
137+
break
129138
default:
130139
continue
131140
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const handle_clipboard_paths_item = async (): Promise<string> => {
2+
return '#ClipboardPaths'
3+
}

‎apps/editor/src/views/prompt/backend/message-handlers/handle-hash-sign-quick-pick/symbols/commit-symbol.ts‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
LAST_SELECTED_COMMIT_REFERENCE_ACTION_STATE_KEY
77
} from '@/constants/state-keys'
88
import { GIT_LOG_SINCE_DURATION } from '@/constants/values'
9+
import { t } from '@/i18n'
910

1011
export const handle_commit_item = async (
1112
extension_context: vscode.ExtensionContext
@@ -34,7 +35,7 @@ export const handle_commit_item = async (
3435

3536
if (git_folders.length == 0) {
3637
vscode.window.showErrorMessage(
37-
'No Git repository found in the workspace.'
38+
t('views.prompt.handlers.hash-sign.commit-symbol.no-git-repo')
3839
)
3940
return undefined
4041
}
@@ -119,7 +120,10 @@ export const handle_commit_item = async (
119120

120121
if (!log_output.trim()) {
121122
vscode.window.showErrorMessage(
122-
`No git commits found in "${selected_folder.name}".`
123+
t('views.prompt.handlers.hash-sign.commit-symbol.no-commits').replace(
124+
'{0}',
125+
selected_folder.name
126+
)
123127
)
124128
if (git_folders.length > 1) {
125129
continue
@@ -269,7 +273,7 @@ export const handle_commit_item = async (
269273
}
270274
} catch (error) {
271275
vscode.window.showErrorMessage(
272-
'Failed to get git commits. Please ensure git is installed.'
276+
t('views.prompt.handlers.hash-sign.commit-symbol.failed-to-get-commits')
273277
)
274278
return 'continue'
275279
}

‎apps/editor/src/views/prompt/backend/message-handlers/handle-hash-sign-quick-pick/symbols/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ export * from './changes-symbol'
33
export * from './commit-symbol'
44
export * from './saved-context-symbol'
55
export * from './skill-symbol'
6+
export * from './clipboard-paths-symbol'

‎apps/editor/src/views/prompt/backend/message-handlers/handle-hash-sign-quick-pick/symbols/saved-context-symbol.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ export const handle_saved_context_item = async (
217217
}
218218
} catch (error) {
219219
vscode.window.showErrorMessage(
220-
'Failed to load saved contexts. Please check your configuration.'
220+
t('views.prompt.handlers.hash-sign.saved-context-symbol.failed-to-load')
221221
)
222222
return 'continue'
223223
}

0 commit comments

Comments
 (0)