Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added:

- Agent Skill: [Dev Proxy](https://github.com/dotnet/dev-proxy/tree/main/skills/dev-proxy)
- Command: Switch Version (Stable/Beta) to toggle between stable and beta releases

### Changed:

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Control Dev Proxy directly from VS Code via the Command Palette (`Cmd+Shift+P` /
| Add to Workspace Recommendations | Always |
| Reset State | Always |
| Upgrade config files | Dev Proxy installed |
| Switch Version (Stable/Beta) | Always |

### Snippets

Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@
"title": "Upgrade config files",
"category": "Dev Proxy Toolkit",
"enablement": "isDevProxyInstalled"
},
{
"command": "dev-proxy-toolkit.switch-version",
"title": "Switch Version (Stable/Beta)",
"category": "Dev Proxy Toolkit"
}
],
"mcpServerDefinitionProviders": [
Expand Down
23 changes: 23 additions & 0 deletions src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { registerDocCommands } from './docs';
import { Commands } from '../constants';
import { addExtensionToRecommendations } from '../utils';
import { registerUpgradeConfigCommands } from './upgrade-config';
import { VersionPreference } from '../enums';
import * as logger from '../logger';

/**
* Register all commands for the extension.
Expand Down Expand Up @@ -60,6 +62,27 @@ export function registerCommands(
})
);

context.subscriptions.push(
vscode.commands.registerCommand(Commands.switchVersion, async () => {
const currentVersion = (configuration.get<string>('version') as VersionPreference) || VersionPreference.Stable;
const newVersion = currentVersion === VersionPreference.Stable
? VersionPreference.Beta
: VersionPreference.Stable;

logger.info('Switching Dev Proxy version', { from: currentVersion, to: newVersion });

await vscode.workspace.getConfiguration('dev-proxy-toolkit').update('version', newVersion, vscode.ConfigurationTarget.Global);

const result = await vscode.window.showInformationMessage(
`Switched to Dev Proxy ${newVersion}. Reload the window to apply changes.`,
'Reload'
);
if (result === 'Reload') {
await vscode.commands.executeCommand('workbench.action.reloadWindow');
}
})
);

registerUpgradeConfigCommands(context);
}

Expand Down
3 changes: 3 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ export const Commands = {
// Language model commands
addLanguageModelConfig: 'dev-proxy-toolkit.addLanguageModelConfig',

// Version commands
switchVersion: 'dev-proxy-toolkit.switch-version',

// Workspace commands
addToRecommendations: 'dev-proxy-toolkit.add-to-recommendations',
resetState: 'dev-proxy-toolkit.reset-state',
Expand Down
7 changes: 7 additions & 0 deletions src/test/commands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ suite('Command Registration', () => {
);
});

test('switch-version command should be registered', () => {
assert.ok(
registeredCommands.includes(Commands.switchVersion),
`Command ${Commands.switchVersion} should be registered`
);
});

test('all Commands constants should be registered', () => {
const allCommandIds = Object.values(Commands) as string[];
const missingCommands = allCommandIds.filter(id => !registeredCommands.includes(id));
Expand Down
Loading