Skip to content

Commit 2e5f239

Browse files
committed
Add back button navigation to all context selection flows in apply context command
1 parent 92d3963 commit 2e5f239

8 files changed

Lines changed: 1121 additions & 885 deletions

File tree

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
Code Web Chat is a free and open-source AI coding toolkit. You can use CWC in **VS Code** family of editors (Cursor, Antigravity, VSCodium etc.) for a **much faster and cost efficient\*** development experience.
1616

17-
<sup>\* Compared to coding agents.</sub>
17+
<sup>\* Compared to coding agents, thanks to its a single request/response design.</sub>
1818

1919
✍️ **Construct coding prompts for...**
2020

@@ -32,7 +32,7 @@ Code Web Chat is a free and open-source AI coding toolkit. You can use CWC in **
3232

3333
## Introduction
3434

35-
With its focus on context engineering, CWC proposes a non-agentic workflow, where all the necessary for the task files, includnig useful examples, are picked with engineer's intent. Such guided model works well with simple prompts and as accurate as it can get. The tool is a perfect companion for all kinds of coding tasks; from mass renamings to complex features.
35+
With its focus on context engineering, CWC proposes **a non-agentic workflow**, where all the necessary for the task files, includnig useful examples, are **picked with engineer's intent**. Such guided model works well with simple prompts and is as accurate as it can get. The tool is a **perfect companion for all kinds of coding tasks**; from laborious refactors to complex features.
3636

3737
> [!TIP]
3838
> Feeling lost in the codebase? Just pick a broad context, set _Prune context_, type what you're about to do and AI will help narrow it down to a reasonable size.

‎apps/editor/src/commands/apply-context-command/apply-context-command.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,13 @@ export const apply_context_command = (
243243
show_main_menu = true
244244
}
245245
} else if (main_selection.value == 'unstaged') {
246-
await handle_unstaged_files_source(workspace_provider)
247-
return
246+
const result = await handle_unstaged_files_source(
247+
workspace_provider,
248+
extension_context
249+
)
250+
if (result == 'back') {
251+
show_main_menu = true
252+
}
248253
} else if (main_selection.value == 'commit_files') {
249254
const result = await handle_commit_files_source(
250255
workspace_provider,

‎apps/editor/src/commands/apply-context-command/helpers/applying/apply-saved-context.ts‎

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const apply_saved_context = async (
1010
workspace_root: string,
1111
workspace_provider: WorkspaceProvider,
1212
extension_context: vscode.ExtensionContext
13-
): Promise<void> => {
13+
): Promise<'back' | void> => {
1414
const resolved_paths = await resolve_context_paths(
1515
context,
1616
workspace_root,
@@ -55,6 +55,8 @@ export const apply_saved_context = async (
5555
const quick_pick = vscode.window.createQuickPick()
5656
quick_pick.items = quick_pick_options
5757
quick_pick.placeholder = `How would you like to apply "${context.name}"?`
58+
quick_pick.buttons = [vscode.QuickInputButtons.Back]
59+
5860
if (last_choice_label) {
5961
const active_item = quick_pick_options.find(
6062
(opt) => opt.label === last_choice_label
@@ -64,23 +66,33 @@ export const apply_saved_context = async (
6466
}
6567
}
6668

67-
const choice = await new Promise<vscode.QuickPickItem | undefined>(
68-
(resolve) => {
69-
let is_accepted = false
70-
quick_pick.onDidAccept(() => {
71-
is_accepted = true
72-
resolve(quick_pick.selectedItems[0])
69+
const choice = await new Promise<
70+
vscode.QuickPickItem | 'back' | undefined
71+
>((resolve) => {
72+
let is_accepted = false
73+
quick_pick.onDidTriggerButton((button) => {
74+
if (button === vscode.QuickInputButtons.Back) {
75+
resolve('back')
7376
quick_pick.hide()
74-
})
75-
quick_pick.onDidHide(() => {
76-
if (!is_accepted) {
77-
resolve(undefined)
78-
}
79-
quick_pick.dispose()
80-
})
81-
quick_pick.show()
82-
}
83-
)
77+
}
78+
})
79+
quick_pick.onDidAccept(() => {
80+
is_accepted = true
81+
resolve(quick_pick.selectedItems[0])
82+
quick_pick.hide()
83+
})
84+
quick_pick.onDidHide(() => {
85+
if (!is_accepted) {
86+
resolve('back')
87+
}
88+
quick_pick.dispose()
89+
})
90+
quick_pick.show()
91+
})
92+
93+
if (choice === 'back') {
94+
return 'back'
95+
}
8496

8597
if (!choice) {
8698
return

0 commit comments

Comments
 (0)