Skip to content

Commit 5276ad6

Browse files
committed
Simplify checkpoint quick pick item details presentation and correct context utilization tooltip wording
1 parent d251fdf commit 5276ad6

3 files changed

Lines changed: 28 additions & 27 deletions

File tree

‎packages/ui/src/components/editor/panel/ContextUtilisation/ContextUtilisation.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const ContextUtilisation: React.FC<Props> = (props) => {
4040
const remaining_tokens =
4141
props.context_size_warning_threshold - props.current_context_size
4242
const formatted_remaining_tokens = format_tokens(remaining_tokens)
43-
title_text = `${formatted_remaining_tokens} tokens remaining until threshold`
43+
title_text = `${formatted_remaining_tokens} tokens remaining until threshold warning`
4444
} else {
4545
title_text = `Context size (${formatted_current_size}) exceeds threshold (${formatted_threshold})`
4646
}

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

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,37 @@ export const create_checkpoint = async (
2828

2929
await copy_workspace_to_dir(checkpoint_dir_uri, workspace_provider)
3030

31+
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+
)
40+
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+
)
49+
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+
}
3156
const new_checkpoint: Checkpoint = {
3257
title,
3358
timestamp,
34-
description
59+
description: final_description
3560
}
3661

37-
const checkpoints = await get_checkpoints(context)
3862
checkpoints.push(new_checkpoint)
3963
await context.workspaceState.update(CHECKPOINTS_STATE_KEY, checkpoints)
4064
}

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

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -100,18 +100,6 @@ export const checkpoints_command = (
100100
}
101101

102102
const visible_checkpoints = checkpoints.filter((c) => !c.is_temporary)
103-
const detail_counts = new Map<string, number>()
104-
for (const c of visible_checkpoints) {
105-
if (c.description) {
106-
detail_counts.set(
107-
c.description,
108-
(detail_counts.get(c.description) || 0) + 1
109-
)
110-
}
111-
}
112-
113-
const current_detail_counts = new Map(detail_counts)
114-
115103
quick_pick.items = [
116104
{
117105
id: 'add-new',
@@ -128,22 +116,11 @@ export const checkpoints_command = (
128116
]
129117
: []),
130118
...visible_checkpoints.map((c, index) => {
131-
let detail = c.description
132-
if (
133-
c.description &&
134-
(detail_counts.get(c.description) ?? 0) > 1
135-
) {
136-
const current_count = current_detail_counts.get(c.description)!
137-
current_detail_counts.set(c.description, current_count - 1)
138-
if (current_count > 1) {
139-
detail = `(${current_count - 1}) ${c.description}`
140-
}
141-
}
142119
return {
143120
id: c.timestamp.toString(),
144121
label: c.title,
145122
description: dayjs(c.timestamp).fromNow(),
146-
detail,
123+
detail: c.description,
147124
checkpoint: c,
148125
index,
149126
buttons:

0 commit comments

Comments
 (0)