Skip to content

Commit e15d463

Browse files
committed
Move checkpoint logic to a feature directory and add automatic checkpoint creation on git commits
- move checkpoint handling related logic to `apps/editor/src/features/checkpoints` - move `apps/editor/src/features/checkpoints/handlers` to `apps/editor/src/views/panel/backend/message-handlers/checkpionts/handle-...` - fix checkpoint-related imports in `apps/editor/src/views/panel/backend/panel-provider.ts` - create a special checkpoint once commited - in `apps/editor/src/views/panel/frontend/Home/Home.tsx` handle trigger 'commit' ("Commited") - add missing translations to [Fragment]
1 parent 0d7d155 commit e15d463

35 files changed

Lines changed: 92 additions & 286 deletions

‎apps/editor/src/commands/apply-chat-response-command/apply-chat-response-command.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@ import {
2424
CwcPreviewProvider
2525
} from './utils/preview/virtual-document-provider'
2626
import { parse_response } from './utils/clipboard-parser'
27-
import { Checkpoint } from '@/views/panel/backend/message-handlers/checkpoints/types'
28-
import { create_checkpoint, delete_checkpoint } from '@/views/panel/backend/message-handlers/checkpoints/actions'
29-
import { get_checkpoint_path } from '@/views/panel/backend/message-handlers/checkpoints/utils'
27+
import { Checkpoint } from '@/features/checkpoints/types'
28+
import {
29+
create_checkpoint,
30+
delete_checkpoint
31+
} from '@/features/checkpoints/actions'
32+
import { get_checkpoint_path } from '@/features/checkpoints/utils'
3033

3134
let in_progress = false
3235

‎apps/editor/src/commands/generate-commit-message-command/generate-commit-message-command.ts‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,19 @@ import axios from 'axios'
1414
import { PromptsForCommitMessagesUtils } from '../../utils/prompts-for-commit-messages-utils'
1515
import { simplify_prompt_symbols } from '@shared/utils/simplify-prompt-symbols'
1616
import { MAX_PROMPT_CHARS_IN_COMMIT_MESSAGE } from '@/constants/values'
17+
import { PanelProvider } from '@/views/panel/backend/panel-provider'
18+
import { WorkspaceProvider } from '@/context/providers/workspace/workspace-provider'
19+
import { create_checkpoint } from '@/features/checkpoints/actions'
1720

1821
const truncate_prompt = (text: string): string => {
1922
if (text.length <= MAX_PROMPT_CHARS_IN_COMMIT_MESSAGE) return text
2023
return text.substring(0, MAX_PROMPT_CHARS_IN_COMMIT_MESSAGE) + '...'
2124
}
2225

2326
export const generate_commit_message_command = (
24-
context: vscode.ExtensionContext
27+
context: vscode.ExtensionContext,
28+
panel_provider: PanelProvider,
29+
workspace_provider: WorkspaceProvider
2530
) => {
2631
const get_prompt_data = async (params: {
2732
repository: GitRepository
@@ -258,14 +263,25 @@ export const generate_commit_message_command = (
258263
.join('\n')
259264
: ''
260265

261-
repository.inputBox.value = edited_message + selected_prompts_text
266+
const commit_message_value = edited_message + selected_prompts_text
267+
repository.inputBox.value = commit_message_value
262268
await vscode.commands.executeCommand('git.commit', repository)
263269
PromptsForCommitMessagesUtils.remove_committed_files({
264270
context,
265271
workspace_root,
266272
prompts: relevant_prompts.map((p) => p.prompt),
267273
committed_files: staged_files
268274
})
275+
276+
const subject_line = commit_message_value.split('\n')[0].trim()
277+
create_checkpoint({
278+
workspace_provider,
279+
context,
280+
panel_provider,
281+
trigger: 'commit',
282+
description: subject_line,
283+
silent: true
284+
}).catch(() => {})
269285
} else if (was_empty_stage) {
270286
await vscode.commands.executeCommand('git.unstageAll')
271287
}

‎apps/editor/src/extension.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,11 @@ export const activate = async (context: vscode.ExtensionContext) => {
170170
settings_provider.createOrShow(section)
171171
}
172172
),
173-
generate_commit_message_command(context),
173+
generate_commit_message_command(
174+
context,
175+
panel_provider,
176+
workspace_provider
177+
),
174178
vscode.commands.registerCommand(
175179
'codeWebChat.openWebsitePreviewUrl',
176180
async () => {

apps/editor/src/views/panel/backend/message-handlers/checkpoints/actions/clear-all-checkpoints.ts renamed to apps/editor/src/features/checkpoints/actions/clear-all-checkpoints.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
import { get_checkpoint_path } from '../utils'
77
import { get_checkpoints } from './get-checkpoints'
88
import { Logger } from '@shared/utils/logger'
9-
import { PanelProvider } from '../../../panel-provider'
9+
import { PanelProvider } from '@/views/panel/backend/panel-provider'
1010
import type { Checkpoint } from '../types'
1111

1212
export const clear_all_checkpoints = async (

apps/editor/src/views/panel/backend/message-handlers/checkpoints/actions/create-checkpoint.ts renamed to apps/editor/src/features/checkpoints/actions/create-checkpoint.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
} from '../utils/git-utils'
2020
import * as path from 'path'
2121
import { Logger } from '@shared/utils/logger'
22-
import { PanelProvider } from '../../../panel-provider'
22+
import { PanelProvider } from '@/views/panel/backend/panel-provider'
2323
import { dictionary } from '@shared/constants/dictionary'
2424
import { response_preview_promise_resolve } from '@/commands/apply-chat-response-command/utils/preview'
2525

apps/editor/src/views/panel/backend/message-handlers/checkpoints/actions/create-temporary-checkpoint.ts renamed to apps/editor/src/features/checkpoints/actions/create-temporary-checkpoint.ts

File renamed without changes.

apps/editor/src/views/panel/backend/message-handlers/checkpoints/actions/delete-checkpoint.ts renamed to apps/editor/src/features/checkpoints/actions/delete-checkpoint.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { CHECKPOINTS_STATE_KEY } from '@/constants/state-keys'
33
import type { Checkpoint } from '../types'
44
import { get_checkpoint_path } from '../utils'
55
import { Logger } from '@shared/utils/logger'
6-
import { PanelProvider } from '../../../panel-provider'
6+
import { PanelProvider } from '@/views/panel/backend/panel-provider'
77
import { dictionary } from '@shared/constants/dictionary'
88

99
export const delete_checkpoint = async (params: {

apps/editor/src/views/panel/backend/message-handlers/checkpoints/actions/get-checkpoints.ts renamed to apps/editor/src/features/checkpoints/actions/get-checkpoints.ts

File renamed without changes.

apps/editor/src/views/panel/backend/message-handlers/checkpoints/actions/index.ts renamed to apps/editor/src/features/checkpoints/actions/index.ts

File renamed without changes.

apps/editor/src/views/panel/backend/message-handlers/checkpoints/actions/restore-checkpoint.ts renamed to apps/editor/src/features/checkpoints/actions/restore-checkpoint.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { get_checkpoints } from './get-checkpoints'
1616
import { sync_workspace_from_dir } from './sync-workspace-from-dir'
1717
import { get_checkpoint_path, sync_directory } from '../utils'
1818
import { Logger } from '@shared/utils/logger'
19-
import { PanelProvider } from '../../../panel-provider'
19+
import { PanelProvider } from '@/views/panel/backend/panel-provider'
2020
import { response_preview_promise_resolve } from '@/commands/apply-chat-response-command/utils/preview'
2121
import { ongoing_preview_cleanup_promise } from '@/commands/apply-chat-response-command/utils/preview-handler'
2222
import { dictionary } from '@shared/constants/dictionary'

0 commit comments

Comments
 (0)