Skip to content

Commit 945fd2c

Browse files
committed
Save and restore completed tasks with checkpoints
- history entries (checkpoints) doesn't preserve/restore completed tasks └── apps └── editor └── src ├── commands │ └── history-command │ ├── actions │ │ └── restore-checkpoint.ts │ └── history-command.ts ├── constants │ └── state-keys.ts ├── features │ └── checkpoints │ ├── actions │ │ └── create-checkpoint.ts │ └── types │ └── checkpoint.ts └── views └── prompt ├── backend │ ├── message-handlers │ │ └── handle-save-completed-tasks.ts │ └── prompt-view-provider.ts └── frontend └── Main └── Main.tsx
1 parent 5b8d859 commit 945fd2c

3 files changed

Lines changed: 31 additions & 3 deletions

File tree

‎apps/editor/src/commands/history-command/actions/restore-checkpoint.ts‎

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import * as vscode from 'vscode'
55
import {
66
TEMPORARY_CHECKPOINT_STATE_KEY,
77
CHECKPOINT_OPERATION_IN_PROGRESS_STATE_KEY,
8-
CONTEXT_SELECTED_PATHS_STATE_KEY
8+
CONTEXT_SELECTED_PATHS_STATE_KEY,
9+
COMPLETED_TASKS_STATE_KEY
910
} from '@/constants/state-keys'
1011
import { WorkspaceProvider } from '@/context/providers/workspace/workspace-provider'
1112
import type { Checkpoint } from '@/features/checkpoints/types'
@@ -457,6 +458,29 @@ export const restore_checkpoint = async (params: {
457458
})
458459
}
459460

461+
if (params.checkpoint.completed_tasks) {
462+
params.prompt_view_provider.completed_tasks =
463+
params.checkpoint.completed_tasks
464+
await params.extension_context.workspaceState.update(
465+
COMPLETED_TASKS_STATE_KEY,
466+
params.checkpoint.completed_tasks
467+
)
468+
params.prompt_view_provider.send_message({
469+
command: 'COMPLETED_TASKS',
470+
completed_tasks: params.checkpoint.completed_tasks
471+
})
472+
} else {
473+
params.prompt_view_provider.completed_tasks = []
474+
await params.extension_context.workspaceState.update(
475+
COMPLETED_TASKS_STATE_KEY,
476+
[]
477+
)
478+
params.prompt_view_provider.send_message({
479+
command: 'COMPLETED_TASKS',
480+
completed_tasks: []
481+
})
482+
}
483+
460484
const active_file = open_files.find((f) => f.isActive)
461485

462486
for (const file of open_files) {
@@ -494,6 +518,8 @@ export const restore_checkpoint = async (params: {
494518
params.workspace_provider.load_selected_files_state()
495519
}
496520

521+
params.prompt_view_provider.send_token_count()
522+
497523
await params.extension_context.workspaceState.update(
498524
CHECKPOINT_OPERATION_IN_PROGRESS_STATE_KEY,
499525
undefined

‎apps/editor/src/features/checkpoints/actions/create-checkpoint.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ export const create_checkpoint = async (params: {
208208
uses_git,
209209
git_data: Object.keys(git_data).length > 0 ? git_data : undefined,
210210
selected_files: params.workspace_provider.get_all_selected_paths(),
211-
active_tabs
211+
active_tabs,
212+
completed_tasks: [...params.prompt_view_provider.completed_tasks]
212213
}
213214

214215
if (trigger == 'manual' && !response_preview_promise_resolve) {

‎apps/editor/src/features/checkpoints/types/checkpoint.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ export interface Checkpoint {
2626
trigger: CheckpointTrigger
2727
description?: string
2828
is_pinned?: boolean
29-
git_data?: Record<string, GitCheckpointData> // folder name -> git data
29+
git_data?: Record<string, GitCheckpointData>
3030
uses_git?: boolean
3131
response_history?: ResponseHistoryItem[]
3232
response_preview_item_created_at?: number
3333
selected_files?: string[]
3434
active_tabs?: CheckpointTab[]
35+
completed_tasks?: string[]
3536
}

0 commit comments

Comments
 (0)