Compare commits

...

5 Commits

Author SHA1 Message Date
abeatrix 773f8518ce Refactor tmp user directory for dev launch config
This commit refactors the temporary user directory used in the development launch configuration.

- Updates `.vscode/launch.json` to use `${workspaceFolder}/dist/tmp/user` for the `--user-data-dir` argument, ensuring the temporary profile is located within the workspace.
- Adds `TEMP_PROFILE: "true"` to the environment variables in `.vscode/launch.json` to enable in-memory storage for temporary profiles.
- Renames the `clean-sandbox` task in `.vscode/tasks.json` to `clean-tmp-user` and modifies its command to remove and recreate the `${workspaceFolder}/dist/tmp/user` directory. This ensures a clean environment for each launch.
2025-07-08 11:59:40 -07:00
abeatrix 187eb9dec4 Implement in-memory storage for temporary profiles
Adds in-memory storage for global state, workspace state, and secrets when running in a temporary profile. This is determined by the `TEMP_PROFILE` environment variable being set to "true". When active, the `updateGlobalState`, `getGlobalState`, `updateGlobalStateBatch`, `updateSecretsBatch`, `storeSecret`, `getSecret`, `updateWorkspaceState`, and `getWorkspaceState` functions will use `Map` objects to store and retrieve data instead of VS Code's `globalState`, `secrets`, and `workspaceState` APIs. This ensures that no data is persisted to disk when using a temporary profile, providing a clean environment for testing and development.
2025-07-08 11:58:17 -07:00
abeatrix c0d8a985c2 tmp dir 2025-07-08 10:47:34 -07:00
abeatrix ce33d1d825 update name 2025-07-08 10:42:37 -07:00
abeatrix 8871057f8b Fix fresh install mode launch config
Updates the launch configuration in `.vscode/launch.json` to include a temporary profile and user data directory. This fixes the issue where the launch config does not start in fresh install mode for extension development. This change prevents  interference from existing settings and extensions. The `--user-data-dir=/tmp/cline/user` argument specifies a temporary directory for user data, while `--profile-temp` ensures a clean profile is used for each launch. Also, `--sync=off` is added to disable settings sync.
2025-07-08 10:35:27 -07:00
3 changed files with 54 additions and 5 deletions
+4 -3
View File
@@ -23,19 +23,20 @@
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--user-data-dir=${workspaceFolder}/dist/tmp/user",
"--profile-temp",
"--sync",
"off",
"--sync=off",
"--disable-extensions",
"--extensionDevelopmentPath=${workspaceFolder}",
"${workspaceFolder}"
],
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
"preLaunchTask": "clean-sandbox",
"preLaunchTask": "clean-tmp-user",
"internalConsoleOptions": "openOnSessionStart",
"postDebugTask": "stop",
"env": {
"IS_DEV": "true",
"TEMP_PROFILE": "true",
"DEV_WORKSPACE_FOLDER": "${workspaceFolder}"
}
},
+2 -2
View File
@@ -233,10 +233,10 @@
"type": "shell"
},
{
"label": "clean-sandbox",
"label": "clean-tmp-user",
"type": "shell",
"dependsOn": ["watch"],
"command": "rm -rf .vscode-dev"
"command": "rm -rf ${workspaceFolder}/dist/tmp/user && mkdir -p ${workspaceFolder}/dist/tmp/user"
}
],
"inputs": [
+48
View File
@@ -18,23 +18,53 @@ import { migrateEnableCheckpointsSetting, migrateMcpMarketplaceEnableSetting } f
https://www.eliostruyf.com/devhack-code-extension-storage-options/
*/
const isTemporaryProfile = process.env.TEMP_PROFILE === "true"
// In-memory storage for temporary profiles
const inMemoryGlobalState = new Map<string, any>()
const inMemoryWorkspaceState = new Map<string, any>()
const inMemorySecrets = new Map<string, string>()
// global
export async function updateGlobalState(context: vscode.ExtensionContext, key: GlobalStateKey, value: any) {
if (isTemporaryProfile) {
inMemoryGlobalState.set(key, value)
return
}
await context.globalState.update(key, value)
}
export async function getGlobalState(context: vscode.ExtensionContext, key: GlobalStateKey) {
if (isTemporaryProfile) {
return inMemoryGlobalState.get(key)
}
return await context.globalState.get(key)
}
// Batched operations for performance optimization
export async function updateGlobalStateBatch(context: vscode.ExtensionContext, updates: Record<string, any>) {
if (isTemporaryProfile) {
Object.entries(updates).forEach(([key, value]) => {
inMemoryGlobalState.set(key, value)
})
return
}
// Use Promise.all to batch the updates
await Promise.all(Object.entries(updates).map(([key, value]) => context.globalState.update(key as GlobalStateKey, value)))
}
export async function updateSecretsBatch(context: vscode.ExtensionContext, updates: Record<string, string | undefined>) {
if (isTemporaryProfile) {
Object.entries(updates).forEach(([key, value]) => {
if (value) {
inMemorySecrets.set(key, value)
} else {
inMemorySecrets.delete(key)
}
})
return
}
// Use Promise.all to batch the secret updates
await Promise.all(Object.entries(updates).map(([key, value]) => storeSecret(context, key as SecretKey, value)))
}
@@ -42,6 +72,14 @@ export async function updateSecretsBatch(context: vscode.ExtensionContext, updat
// secrets
export async function storeSecret(context: vscode.ExtensionContext, key: SecretKey, value?: string) {
if (isTemporaryProfile) {
if (value) {
inMemorySecrets.set(key, value)
} else {
inMemorySecrets.delete(key)
}
return
}
if (value) {
await context.secrets.store(key, value)
} else {
@@ -50,16 +88,26 @@ export async function storeSecret(context: vscode.ExtensionContext, key: SecretK
}
export async function getSecret(context: vscode.ExtensionContext, key: SecretKey) {
if (isTemporaryProfile) {
return inMemorySecrets.get(key)
}
return await context.secrets.get(key)
}
// workspace
export async function updateWorkspaceState(context: vscode.ExtensionContext, key: LocalStateKey, value: any) {
if (isTemporaryProfile) {
inMemoryWorkspaceState.set(key, value)
return
}
await context.workspaceState.update(key, value)
}
export async function getWorkspaceState(context: vscode.ExtensionContext, key: LocalStateKey) {
if (isTemporaryProfile) {
return inMemoryWorkspaceState.get(key)
}
return await context.workspaceState.get(key)
}