Skip to content

Commit 01bde87

Browse files
committed
Refactor checkpoint commands to consistently pass the websites_provider parameter
1 parent 715a90f commit 01bde87

6 files changed

Lines changed: 51 additions & 47 deletions

File tree

‎packages/vscode/src/commands/apply-chat-response-command/apply-chat-response-command.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ export const apply_chat_response_command = (
9898
workspace_provider,
9999
context,
100100
panel_provider,
101+
panel_provider.websites_provider,
101102
'Before response previewed',
102103
args?.raw_instructions
103104
)

‎packages/vscode/src/commands/checkpoints-command/actions/restore-checkpoint.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,9 @@ export const restore_checkpoint = async (params: {
391391
checkpoint: temp_checkpoint,
392392
workspace_provider: params.workspace_provider,
393393
context: params.context,
394-
options: { skip_confirmation: true },
395394
panel_provider: params.panel_provider,
396-
websites_provider: params.websites_provider
395+
websites_provider: params.websites_provider,
396+
options: { skip_confirmation: true }
397397
})
398398
await delete_checkpoint({
399399
context: params.context,

‎packages/vscode/src/commands/checkpoints-command/checkpoints-command.ts‎

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ dayjs.extend(relativeTime)
2222

2323
export type { Checkpoint } from './types'
2424

25-
export const checkpoints_command = (
26-
workspace_provider: WorkspaceProvider,
27-
context: vscode.ExtensionContext,
28-
panel_provider: PanelProvider,
25+
export const checkpoints_command = (params: {
26+
context: vscode.ExtensionContext
27+
workspace_provider: WorkspaceProvider
2928
websites_provider: WebsitesProvider
30-
): vscode.Disposable[] => {
29+
panel_provider: PanelProvider
30+
}): vscode.Disposable[] => {
3131
let activeDeleteOperation: {
3232
finalize: () => Promise<void>
3333
timestamp: number
@@ -46,10 +46,10 @@ export const checkpoints_command = (
4646
return
4747
}
4848
const checkpoint = await create_checkpoint(
49-
workspace_provider,
50-
context,
51-
panel_provider,
52-
websites_provider
49+
params.workspace_provider,
50+
params.context,
51+
params.panel_provider,
52+
params.websites_provider
5353
)
5454
if (checkpoint) {
5555
vscode.window.showInformationMessage('Checkpoint created successfully.')
@@ -89,9 +89,9 @@ export const checkpoints_command = (
8989

9090
const refresh_items = async () => {
9191
quick_pick.busy = true
92-
checkpoints = await get_checkpoints(context)
92+
checkpoints = await get_checkpoints(params.context)
9393

94-
const temp_checkpoint = context.workspaceState.get<Checkpoint>(
94+
const temp_checkpoint = params.context.workspaceState.get<Checkpoint>(
9595
TEMPORARY_CHECKPOINT_STATE_KEY
9696
)
9797
let revert_item:
@@ -113,7 +113,7 @@ export const checkpoints_command = (
113113
}
114114
} catch {
115115
// file doesn't exist, so we can't revert. Clean up state.
116-
await context.workspaceState.update(
116+
await params.context.workspaceState.update(
117117
TEMPORARY_CHECKPOINT_STATE_KEY,
118118
undefined
119119
)
@@ -189,17 +189,18 @@ export const checkpoints_command = (
189189
if (selected.id == 'add-new') {
190190
quick_pick.hide()
191191
await create_checkpoint(
192-
workspace_provider,
193-
context,
194-
panel_provider,
195-
websites_provider
192+
params.workspace_provider,
193+
params.context,
194+
params.panel_provider,
195+
params.websites_provider
196196
)
197197
await show_quick_pick()
198198
} else if (selected.id == 'revert-last') {
199199
quick_pick.hide()
200-
const temp_checkpoint = context.workspaceState.get<Checkpoint>(
201-
TEMPORARY_CHECKPOINT_STATE_KEY
202-
)
200+
const temp_checkpoint =
201+
params.context.workspaceState.get<Checkpoint>(
202+
TEMPORARY_CHECKPOINT_STATE_KEY
203+
)
203204
if (!temp_checkpoint) {
204205
vscode.window.showErrorMessage(
205206
'Could not find temporary checkpoint to revert.'
@@ -209,30 +210,30 @@ export const checkpoints_command = (
209210

210211
await restore_checkpoint({
211212
checkpoint: temp_checkpoint,
212-
workspace_provider,
213-
context,
213+
workspace_provider: params.workspace_provider,
214+
context: params.context,
214215
options: { skip_confirmation: true },
215-
panel_provider,
216-
websites_provider
216+
panel_provider: params.panel_provider,
217+
websites_provider: params.websites_provider
217218
})
218219
// After reverting, delete the temp checkpoint and clear state.
219220
await delete_checkpoint({
220-
context,
221+
context: params.context,
221222
checkpoint_to_delete: temp_checkpoint,
222-
panel_provider
223+
panel_provider: params.panel_provider
223224
})
224-
await context.workspaceState.update(
225+
await params.context.workspaceState.update(
225226
TEMPORARY_CHECKPOINT_STATE_KEY,
226227
undefined
227228
)
228229
} else if (selected.checkpoint) {
229230
quick_pick.hide()
230231
await restore_checkpoint({
231232
checkpoint: selected.checkpoint,
232-
workspace_provider,
233-
context,
234-
panel_provider,
235-
websites_provider
233+
workspace_provider: params.workspace_provider,
234+
context: params.context,
235+
panel_provider: params.panel_provider,
236+
websites_provider: params.websites_provider
236237
})
237238
}
238239
})
@@ -247,12 +248,12 @@ export const checkpoints_command = (
247248
)
248249

249250
if (confirmation == 'Clear All') {
250-
await clear_all_checkpoints(context, panel_provider)
251+
await clear_all_checkpoints(params.context, params.panel_provider)
251252
vscode.window.showInformationMessage(
252253
'All checkpoints have been cleared.'
253254
)
254255
}
255-
await context.workspaceState.update(
256+
await params.context.workspaceState.update(
256257
TEMPORARY_CHECKPOINT_STATE_KEY,
257258
undefined
258259
)
@@ -273,11 +274,11 @@ export const checkpoints_command = (
273274
)
274275
if (checkpoint_to_update) {
275276
checkpoint_to_update.is_starred = !checkpoint_to_update.is_starred
276-
await context.workspaceState.update(
277+
await params.context.workspaceState.update(
277278
CHECKPOINTS_STATE_KEY,
278279
checkpoints
279280
)
280-
panel_provider.send_checkpoints()
281+
params.panel_provider.send_checkpoints()
281282
}
282283
await refresh_items()
283284
const active_item = quick_pick.items.find(
@@ -306,11 +307,11 @@ export const checkpoints_command = (
306307
)
307308
if (checkpoint_to_update) {
308309
checkpoint_to_update.description = new_description
309-
await context.workspaceState.update(
310+
await params.context.workspaceState.update(
310311
CHECKPOINTS_STATE_KEY,
311312
checkpoints
312313
)
313-
panel_provider.send_checkpoints()
314+
params.panel_provider.send_checkpoints()
314315
}
315316
}
316317
await refresh_items()
@@ -346,11 +347,11 @@ export const checkpoints_command = (
346347
const updated_checkpoints = checkpoints.filter(
347348
(c) => c.timestamp !== deleted_checkpoint.timestamp
348349
)
349-
await context.workspaceState.update(
350+
await params.context.workspaceState.update(
350351
CHECKPOINTS_STATE_KEY,
351352
updated_checkpoints
352353
)
353-
panel_provider.send_checkpoints()
354+
params.panel_provider.send_checkpoints()
354355
checkpoints = updated_checkpoints
355356
await refresh_items()
356357

@@ -394,11 +395,11 @@ export const checkpoints_command = (
394395
0,
395396
original_checkpoint_from_state
396397
)
397-
await context.workspaceState.update(
398+
await params.context.workspaceState.update(
398399
CHECKPOINTS_STATE_KEY,
399400
checkpoints
400401
)
401-
panel_provider.send_checkpoints()
402+
params.panel_provider.send_checkpoints()
402403
notification_count++
403404
vscode.window
404405
.showInformationMessage('Checkpoint restored.')

‎packages/vscode/src/extension.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ export async function activate(context: vscode.ExtensionContext) {
7979
context,
8080
panel_provider
8181
),
82-
...checkpoints_command(
83-
workspace_provider,
82+
...checkpoints_command({
8483
context,
84+
workspace_provider,
85+
websites_provider,
8586
panel_provider,
86-
websites_provider
87-
)
87+
})
8888
)
8989
}
9090

‎packages/vscode/src/views/panel/backend/message-handlers/handle-accept-commit-message.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export const handle_accept_commit_message = async (
3333
panel_provider.workspace_provider,
3434
panel_provider.context,
3535
panel_provider,
36+
panel_provider.websites_provider,
3637
title,
3738
description
3839
)

‎packages/vscode/src/views/panel/backend/panel-provider.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,8 @@ export class PanelProvider implements vscode.WebviewViewProvider {
428428
checkpoint: checkpoint_to_restore,
429429
workspace_provider: this.workspace_provider,
430430
context: this.context,
431-
panel_provider: this
431+
panel_provider: this,
432+
websites_provider: this.websites_provider
432433
})
433434
}
434435
} else if (message.command == 'GET_HISTORY') {

0 commit comments

Comments
 (0)