Skip to content

Commit 795e149

Browse files
committed
Add settings shortcuts to template and snippet quick picks and make prompt template and snippet settings sections collapsible
- in settings: 'templates' and 'snippets' should be collapsed - in top right corner of templates quick pick add gear icon that opens settings on templates management - on 'snippet' quick pick action of the hash symbol, add 'gear' icon, opening settings at prompt management just like [Changes] ├── apps │ └── editor │ └── src │ ├── i18n │ │ └── translations │ │ ├── common.ts │ │ └── views │ │ └── shared │ │ └── utils │ │ └── hash-sign-quick-pick.ts │ └── views │ ├── prompt │ │ └── backend │ │ └── message-handlers │ │ └── handle-template-quick-pick.ts │ ├── settings │ │ ├── frontend │ │ │ ├── Home │ │ │ │ ├── Home.tsx │ │ │ │ └── sections │ │ │ │ └── GeneralSection.tsx │ │ │ └── forms │ │ │ ├── SnippetsForm │ │ │ │ └── SnippetsForm.tsx │ │ │ └── TemplatesForm │ │ │ ├── TemplatesForm.tsx │ │ │ └── index.ts │ │ └── helpers │ │ └── open-settings.ts │ └── shared │ └── utils │ └── hash-sign-quick-pick │ ├── hash-sign-quick-pick.ts │ └── symbols │ └── snippet-symbol.ts └── packages └── ui └── src └── components └── editor └── settings-view └── Item ├── Item.module.scss └── Item.tsx
1 parent 48c00a6 commit 795e149

3 files changed

Lines changed: 37 additions & 5 deletions

File tree

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,16 @@ export const handle_template_quick_pick = async (
5454
>()
5555
templates_quick_pick.title = 'Templates'
5656
templates_quick_pick.placeholder = 'Select a template'
57-
templates_quick_pick.buttons = [
58-
{ iconPath: new vscode.ThemeIcon('close'), tooltip: t('common.close') }
59-
]
57+
58+
const settings_button = {
59+
iconPath: new vscode.ThemeIcon('settings-gear'),
60+
tooltip: t('common.open-settings')
61+
}
62+
const close_button = {
63+
iconPath: new vscode.ThemeIcon('close'),
64+
tooltip: t('common.close')
65+
}
66+
templates_quick_pick.buttons = [settings_button, close_button]
6067

6168
const get_template_id = (t: Template) => t.name || t.template
6269
const recents_key = get_last_used_template_key(prompt_type)
@@ -103,7 +110,10 @@ export const handle_template_quick_pick = async (
103110
let is_entering_variables = false
104111

105112
disposables.push(
106-
templates_quick_pick.onDidTriggerButton((_button) => {
113+
templates_quick_pick.onDidTriggerButton((button) => {
114+
if (button === settings_button) {
115+
open_settings.general.prompt()
116+
}
107117
templates_quick_pick.hide()
108118
}),
109119
templates_quick_pick.onDidAccept(async () => {

‎apps/editor/src/views/settings/frontend/Home/sections/GeneralSection.tsx‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,11 @@ export const GeneralSection = forwardRef<HTMLDivElement, Props>(
242242
<UiItem
243243
title={t('general.prompt.templates.title')}
244244
description={t('general.prompt.templates.description')}
245+
is_toggleable
246+
translations={{
247+
expand: t('common.expand'),
248+
collapse: t('common.collapse')
249+
}}
245250
>
246251
<TemplatesForm
247252
prompt_instructions={props.prompt_instructions}
@@ -254,6 +259,11 @@ export const GeneralSection = forwardRef<HTMLDivElement, Props>(
254259
<UiItem
255260
title={t('general.prompt.snippets.title')}
256261
description={t('general.prompt.snippets.description')}
262+
is_toggleable
263+
translations={{
264+
expand: t('common.expand'),
265+
collapse: t('common.collapse')
266+
}}
257267
>
258268
<SnippetsForm
259269
prompt_instructions={props.prompt_instructions}

‎apps/editor/src/views/shared/utils/hash-sign-quick-pick/symbols/snippet-symbol.ts‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import { open_settings } from '@/views/settings/helpers/open-settings'
55
export const handle_snippet_item = async (
66
prompt_type?: 'ask' | 'edit'
77
): Promise<string | 'continue' | undefined> => {
8+
const settings_button = {
9+
iconPath: new vscode.ThemeIcon('settings-gear'),
10+
tooltip: t('common.open-settings')
11+
}
812
const close_button = {
913
iconPath: new vscode.ThemeIcon('close'),
1014
tooltip: t('common.close')
@@ -49,7 +53,11 @@ export const handle_snippet_item = async (
4953
quick_pick.title = t(
5054
'views.shared.utils.hash-sign-quick-pick.snippet-symbol.title'
5155
)
52-
quick_pick.buttons = [vscode.QuickInputButtons.Back, close_button]
56+
quick_pick.buttons = [
57+
vscode.QuickInputButtons.Back,
58+
settings_button,
59+
close_button
60+
]
5361

5462
return new Promise((resolve) => {
5563
let is_accepted = false
@@ -60,6 +68,10 @@ export const handle_snippet_item = async (
6068
did_trigger_back = true
6169
quick_pick.hide()
6270
resolve('continue')
71+
} else if (button === settings_button) {
72+
open_settings.general.prompt()
73+
quick_pick.hide()
74+
resolve(undefined)
6375
} else if (button === close_button) {
6476
quick_pick.hide()
6577
resolve(undefined)

0 commit comments

Comments
 (0)