Skip to content

Commit 7eeef98

Browse files
committed
Migrate automatic checkpoint disabling to a VS Code setting, update all handlers to use the configuration instead of workspace state, remove the legacy state key, and reorganize the General settings UI accordingly
1 parent ef142ac commit 7eeef98

7 files changed

Lines changed: 35 additions & 37 deletions

File tree

‎packages/vscode/package.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,11 @@
551551
"default": 48,
552552
"minimum": 1
553553
},
554+
"codeWebChat.areAutomaticCheckpointsDisabled": {
555+
"type": "boolean",
556+
"scope": "resource",
557+
"default": false
558+
},
554559
"codeWebChat.clearChecksInWorkspaceBehavior": {
555560
"type": "string",
556561
"enum": [

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import * as vscode from 'vscode'
22
import {
33
CHECKPOINTS_STATE_KEY,
44
TEMPORARY_CHECKPOINT_STATE_KEY,
5-
CHECKPOINT_OPERATION_IN_PROGRESS_STATE_KEY,
6-
ARE_AUTOMATIC_CHECKPOINTS_DISABLED_STATE_KEY
5+
CHECKPOINT_OPERATION_IN_PROGRESS_STATE_KEY
76
} from '../../../constants/state-keys'
87
import { WorkspaceProvider } from '../../../context/providers/workspace-provider'
98
import type { Checkpoint, CheckpointTab } from '../types'
@@ -35,11 +34,9 @@ export const create_checkpoint = async (
3534
description?: string
3635
): Promise<Checkpoint | undefined> => {
3736
try {
38-
const are_automatic_checkpoints_disabled =
39-
context.workspaceState.get<boolean>(
40-
ARE_AUTOMATIC_CHECKPOINTS_DISABLED_STATE_KEY
41-
) ?? false
42-
37+
const are_automatic_checkpoints_disabled = vscode.workspace
38+
.getConfiguration('codeWebChat')
39+
.get<boolean>('areAutomaticCheckpointsDisabled', false)
4340
const is_automatic_checkpoint = title !== 'Created by user'
4441

4542
if (are_automatic_checkpoints_disabled && is_automatic_checkpoint) {

‎packages/vscode/src/constants/state-keys.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ export const CHECKPOINTS_STATE_KEY = 'checkpoints'
3131
export const TEMPORARY_CHECKPOINT_STATE_KEY = 'temporary-checkpoint'
3232
export const CHECKPOINT_OPERATION_IN_PROGRESS_STATE_KEY =
3333
'checkpoint-operation-in-progress'
34-
export const ARE_AUTOMATIC_CHECKPOINTS_DISABLED_STATE_KEY =
35-
'are_automatic_checkpoints_disabled'
3634

3735
export const DUPLICATE_WORKSPACE_CONTEXT_STATE_KEY =
3836
'duplicate-workspace-context'

‎packages/vscode/src/views/settings/backend/message-handlers/handle-get-are-automatic-checkpoints-disabled.ts‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { SettingsProvider } from '../settings-provider'
2-
import { ARE_AUTOMATIC_CHECKPOINTS_DISABLED_STATE_KEY } from '@/constants/state-keys'
2+
import * as vscode from 'vscode'
33

44
export async function handle_get_are_automatic_checkpoints_disabled(
55
settings_provider: SettingsProvider
66
) {
7-
const disabled =
8-
settings_provider.context.workspaceState.get<boolean>(
9-
ARE_AUTOMATIC_CHECKPOINTS_DISABLED_STATE_KEY
10-
) ?? false
7+
const disabled = vscode.workspace
8+
.getConfiguration('codeWebChat')
9+
.get<boolean>('areAutomaticCheckpointsDisabled', false)
1110

1211
settings_provider.postMessage({
1312
command: 'ARE_AUTOMATIC_CHECKPOINTS_DISABLED',
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import * as vscode from 'vscode'
22
import { UpdateAreAutomaticCheckpointsDisabledMessage } from '@/views/settings/types/messages'
3-
import { ARE_AUTOMATIC_CHECKPOINTS_DISABLED_STATE_KEY } from '@/constants/state-keys'
43

54
export async function handle_update_are_automatic_checkpoints_disabled(
6-
message: UpdateAreAutomaticCheckpointsDisabledMessage,
7-
context: vscode.ExtensionContext
5+
message: UpdateAreAutomaticCheckpointsDisabledMessage
86
) {
9-
await context.workspaceState.update(
10-
ARE_AUTOMATIC_CHECKPOINTS_DISABLED_STATE_KEY,
11-
message.disabled
12-
)
7+
await vscode.workspace
8+
.getConfiguration('codeWebChat')
9+
.update(
10+
'areAutomaticCheckpointsDisabled',
11+
message.disabled || undefined,
12+
vscode.ConfigurationTarget.Global
13+
)
1314
}

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,7 @@ export class SettingsProvider {
226226
} else if (
227227
message.command == 'UPDATE_ARE_AUTOMATIC_CHECKPOINTS_DISABLED'
228228
) {
229-
await handle_update_are_automatic_checkpoints_disabled(
230-
message,
231-
this.context
232-
)
233-
await handle_get_are_automatic_checkpoints_disabled(this)
229+
await handle_update_are_automatic_checkpoints_disabled(message)
234230
} else if (message.command == 'UPDATE_CHECKPOINT_LIFESPAN') {
235231
await vscode.workspace
236232
.getConfiguration('codeWebChat')

‎packages/vscode/src/views/settings/frontend/Home/sections/GeneralSection.tsx‎

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,19 @@ export const GeneralSection = forwardRef<HTMLDivElement, Props>(
110110
/>
111111
}
112112
/>
113+
<Item
114+
title="Clear Checks in Workspace Behavior"
115+
description="Behavior of the 'Clear Checks' button in the Workspace view."
116+
slot={
117+
<Dropdown
118+
options={CLEAR_CHECKS_OPTIONS}
119+
value={props.clear_checks_in_workspace_behavior}
120+
onChange={props.on_clear_checks_in_workspace_behavior_change}
121+
/>
122+
}
123+
/>
124+
</Group>
125+
<Group title="Checkpoints">
113126
<Item
114127
title="Automatic Checkpoints"
115128
description="A checkpoint will be created whenever a response is accepted or changes commited."
@@ -136,17 +149,6 @@ export const GeneralSection = forwardRef<HTMLDivElement, Props>(
136149
/>
137150
}
138151
/>
139-
<Item
140-
title="Clear Checks in Workspace Behavior"
141-
description="Behavior of the 'Clear Checks' button in the Workspace view."
142-
slot={
143-
<Dropdown
144-
options={CLEAR_CHECKS_OPTIONS}
145-
value={props.clear_checks_in_workspace_behavior}
146-
onChange={props.on_clear_checks_in_workspace_behavior_change}
147-
/>
148-
}
149-
/>
150152
</Group>
151153
<Group title="Edit Format Instructions">
152154
<Item

0 commit comments

Comments
 (0)