Skip to content

Commit f90a553

Browse files
committed
Merge branch 'dev'
2 parents b19b6c0 + ea6e395 commit f90a553

6 files changed

Lines changed: 68 additions & 28 deletions

File tree

‎packages/vscode/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "gemini-coder",
33
"displayName": "Code Web Chat",
44
"description": "Unlimited AI coding in free chatbots (CWC)",
5-
"version": "1.477.0",
5+
"version": "1.478.0",
66
"scripts": {
77
"build": "npx vsce package --no-dependencies",
88
"vscode:prepublish": "rimraf out && npm run compile",

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

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { WorkspaceProvider } from '../../../context/providers/workspace-provider
44
import type { Checkpoint } from '../types'
55
import { copy_workspace_to_dir } from './copy-workspace-to-dir'
66
import { get_checkpoints } from './get-checkpoints'
7-
import { get_checkpoint_path } from '../utils'
7+
import { get_checkpoint_path, get_incremented_description } from '../utils'
88

99
export const create_checkpoint = async (
1010
workspace_provider: WorkspaceProvider,
@@ -29,37 +29,20 @@ export const create_checkpoint = async (
2929
await copy_workspace_to_dir(checkpoint_dir_uri, workspace_provider)
3030

3131
const checkpoints = await get_checkpoints(context)
32-
let final_description = description
33-
if (title == 'Created by user' && description === undefined) {
34-
const user_checkpoints = checkpoints.filter(
35-
(c) => c.title == 'Created by user'
36-
)
37-
const first_custom_index = user_checkpoints.findIndex(
38-
(c) => !c.description?.match(/^\(\d+\)$/)
39-
)
4032

41-
const relevant_checkpoints =
42-
first_custom_index === -1
43-
? user_checkpoints
44-
: user_checkpoints.slice(0, first_custom_index)
45-
46-
const user_checkpoint_numbers = relevant_checkpoints.map((c) =>
47-
parseInt(c.description!.match(/^\((\d+)\)$/)![1], 10)
48-
)
33+
const final_description = get_incremented_description(
34+
title,
35+
description,
36+
checkpoints
37+
)
4938

50-
const max_num =
51-
user_checkpoint_numbers.length > 0
52-
? Math.max(...user_checkpoint_numbers)
53-
: 0
54-
final_description = `(${max_num + 1})`
55-
}
5639
const new_checkpoint: Checkpoint = {
5740
title,
5841
timestamp,
5942
description: final_description
6043
}
6144

62-
checkpoints.push(new_checkpoint)
45+
checkpoints.unshift(new_checkpoint)
6346
await context.workspaceState.update(CHECKPOINTS_STATE_KEY, checkpoints)
6447
}
6548
)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ export const get_checkpoints = async (
2727
)
2828
}
2929

30-
return valid_checkpoints.sort((a, b) => b.timestamp - a.timestamp)
30+
return valid_checkpoints
3131
}

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as vscode from 'vscode'
22
import { CHECKPOINTS_STATE_KEY } from '../../../constants/state-keys'
33
import type { Checkpoint } from '../types'
4+
import { get_incremented_description } from '../utils'
45

56
export const promote_temporary_checkpoint = async (params: {
67
context: vscode.ExtensionContext
@@ -13,11 +14,20 @@ export const promote_temporary_checkpoint = async (params: {
1314
CHECKPOINTS_STATE_KEY,
1415
[]
1516
) ?? []
16-
checkpoints.push({
17+
18+
checkpoints.sort((a, b) => b.timestamp - a.timestamp)
19+
20+
const final_description = get_incremented_description(
21+
params.title,
22+
params.description,
23+
checkpoints
24+
)
25+
26+
checkpoints.unshift({
1727
...params.temp_checkpoint,
1828
is_temporary: false,
1929
title: params.title,
20-
description: params.description
30+
description: final_description
2131
})
2232
await params.context.workspaceState.update(CHECKPOINTS_STATE_KEY, checkpoints)
2333
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import type { Checkpoint } from '../types'
2+
3+
export const get_incremented_description = (
4+
title: string,
5+
description: string | undefined,
6+
checkpoints: Checkpoint[]
7+
): string | undefined => {
8+
if (checkpoints.length == 0) {
9+
return description
10+
}
11+
12+
const most_recent = checkpoints[0]
13+
14+
if (most_recent.title != title) {
15+
return description
16+
}
17+
18+
const most_recent_desc = most_recent.description || ''
19+
const normalized_desc = description || ''
20+
21+
const counter_pattern = /^(.*?)\s*\((\d+)\)$/
22+
const match = most_recent_desc.match(counter_pattern)
23+
24+
let base_desc: string
25+
let counter: number
26+
27+
if (match) {
28+
base_desc = match[1].trim()
29+
counter = parseInt(match[2], 10)
30+
} else {
31+
base_desc = most_recent_desc
32+
counter = 0
33+
}
34+
35+
const current_matches = normalized_desc === base_desc
36+
37+
if (current_matches) {
38+
const next_counter = counter + 1
39+
if (normalized_desc == '') {
40+
return `(${next_counter})`
41+
}
42+
return `(${next_counter}) ${normalized_desc}`
43+
}
44+
45+
return description
46+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from './clean-directory'
22
export * from './copy-optimised-recursively'
33
export * from './get-checkpoint-path'
4+
export * from './get-incremented-description'
45
export * from './sync-directory'

0 commit comments

Comments
 (0)