Skip to content

Commit fa41c1c

Browse files
committed
feat: move Coder Chat to secondary sidebar with agents experiment gate
- Move the coderChat view container from the bottom panel to the secondarySidebar contribution point (requires VS Code >= 1.106). - Add coder.agentsEnabled context key, set by fetching /api/v2/experiments after login. The chat view is only visible when the agents experiment is enabled on the deployment. - Bump engines.vscode from ^1.95.0 to ^1.106.0.
1 parent 7f147ab commit fa41c1c

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@
193193
"icon": "media/tasks-logo.svg"
194194
}
195195
],
196-
"panel": [
196+
"secondarySidebar": [
197197
{
198198
"id": "coderChat",
199199
"title": "Coder Chat (Experimental)",
@@ -237,7 +237,8 @@
237237
"type": "webview",
238238
"id": "coder.chatPanel",
239239
"name": "Coder Chat (Experimental)",
240-
"icon": "media/shorthand-logo.svg"
240+
"icon": "media/shorthand-logo.svg",
241+
"when": "coder.agentsEnabled"
241242
}
242243
]
243244
},
@@ -574,7 +575,7 @@
574575
],
575576
"packageManager": "pnpm@10.32.1",
576577
"engines": {
577-
"vscode": "^1.95.0",
578+
"vscode": "^1.106.0",
578579
"node": ">= 20"
579580
},
580581
"icon": "media/logo.png",

src/core/contextManager.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const CONTEXT_DEFAULTS = {
44
"coder.authenticated": false,
55
"coder.isOwner": false,
66
"coder.loaded": false,
7+
"coder.agentsEnabled": false,
78
"coder.workspace.connected": false,
89
"coder.workspace.updatable": false,
910
} as const;

src/deployment/deploymentManager.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ export class DeploymentManager implements vscode.Disposable {
137137
this.registerAuthListener();
138138
// Contexts must be set before refresh (providers check isAuthenticated)
139139
this.updateAuthContexts(deployment.user);
140+
this.updateExperimentContexts();
140141
this.refreshWorkspaces();
141142

142143
const deploymentWithoutAuth: Deployment =
@@ -166,6 +167,7 @@ export class DeploymentManager implements vscode.Disposable {
166167
this.oauthSessionManager.clearDeployment();
167168
this.client.setCredentials(undefined, undefined);
168169
this.updateAuthContexts(undefined);
170+
this.contextManager.set("coder.agentsEnabled", false);
169171
this.clearWorkspaces();
170172
}
171173

@@ -251,6 +253,26 @@ export class DeploymentManager implements vscode.Disposable {
251253
this.contextManager.set("coder.isOwner", isOwner);
252254
}
253255

256+
/**
257+
* Fetch enabled experiments and update context keys.
258+
* Runs in the background so it does not block login.
259+
*/
260+
private updateExperimentContexts(): void {
261+
this.client.getAxiosInstance().get("/api/v2/experiments")
262+
.then((resp) => {
263+
const experiments: string[] = resp.data ?? [];
264+
this.contextManager.set(
265+
"coder.agentsEnabled",
266+
experiments.includes("agents"),
267+
);
268+
})
269+
.catch((err) => {
270+
this.logger.warn("Failed to fetch experiments", err);
271+
// Default to hidden when we cannot determine.
272+
this.contextManager.set("coder.agentsEnabled", false);
273+
});
274+
}
275+
254276
/**
255277
* Refresh all workspace providers asynchronously.
256278
*/

test/mocks/testHelpers.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ export class MockCoderApi implements Pick<
504504
| "getHost"
505505
| "getAuthenticatedUser"
506506
| "dispose"
507+
| "getAxiosInstance"
507508
> {
508509
private _host: string | undefined;
509510
private _token: string | undefined;
@@ -541,6 +542,11 @@ export class MockCoderApi implements Pick<
541542
this._disposed = true;
542543
});
543544

545+
// Minimal axios-like stub for getAxiosInstance().
546+
readonly getAxiosInstance = vi.fn(() => ({
547+
get: vi.fn().mockResolvedValue({ data: [] }),
548+
}));
549+
544550
/**
545551
* Get current host (for assertions)
546552
*/

0 commit comments

Comments
 (0)