Skip to content

Commit 24f644b

Browse files
committed
Fix command palette visibility with proper "when" clause placement
Move "when" clauses from command definitions to menus.commandPalette section. This fixes commands like Logout and Create Workspace appearing in the palette before the user is authenticated.
1 parent 99d1fab commit 24f644b

File tree

3 files changed

+58
-22
lines changed

3 files changed

+58
-22
lines changed

‎package.json‎

Lines changed: 53 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -192,67 +192,67 @@
192192
"commands": [
193193
{
194194
"command": "coder.login",
195-
"title": "Coder: Login"
195+
"title": "Login",
196+
"category": "Coder",
197+
"icon": "$(sign-in)"
196198
},
197199
{
198200
"command": "coder.logout",
199-
"title": "Coder: Logout",
200-
"when": "coder.authenticated",
201+
"title": "Logout",
202+
"category": "Coder",
201203
"icon": "$(sign-out)"
202204
},
203205
{
204206
"command": "coder.open",
205207
"title": "Open Workspace",
206-
"icon": "$(play)",
207-
"category": "Coder"
208+
"category": "Coder",
209+
"icon": "$(play)"
208210
},
209211
{
210212
"command": "coder.openFromSidebar",
211-
"title": "Coder: Open Workspace",
213+
"title": "Open Workspace",
214+
"category": "Coder",
212215
"icon": "$(play)"
213216
},
214217
{
215218
"command": "coder.createWorkspace",
216219
"title": "Create Workspace",
217220
"category": "Coder",
218-
"when": "coder.authenticated",
219221
"icon": "$(add)"
220222
},
221223
{
222224
"command": "coder.navigateToWorkspace",
223225
"title": "Navigate to Workspace Page",
224-
"when": "coder.authenticated",
226+
"category": "Coder",
225227
"icon": "$(link-external)"
226228
},
227229
{
228230
"command": "coder.navigateToWorkspaceSettings",
229231
"title": "Edit Workspace Settings",
230-
"when": "coder.authenticated",
232+
"category": "Coder",
231233
"icon": "$(settings-gear)"
232234
},
233235
{
234236
"command": "coder.workspace.update",
235-
"title": "Coder: Update Workspace",
236-
"when": "coder.workspace.updatable"
237+
"title": "Update Workspace",
238+
"category": "Coder"
237239
},
238240
{
239241
"command": "coder.refreshWorkspaces",
240242
"title": "Refresh Workspace",
241243
"category": "Coder",
242-
"icon": "$(refresh)",
243-
"when": "coder.authenticated"
244+
"icon": "$(refresh)"
244245
},
245246
{
246247
"command": "coder.viewLogs",
247248
"title": "Coder: View Logs",
248-
"icon": "$(list-unordered)",
249-
"when": "coder.authenticated"
249+
"icon": "$(list-unordered)"
250250
},
251251
{
252252
"command": "coder.openAppStatus",
253-
"title": "Coder: Open App Status",
254-
"icon": "$(robot)",
255-
"when": "coder.authenticated"
253+
"title": "Open App Status",
254+
"category": "Coder",
255+
"icon": "$(robot)"
256256
},
257257
{
258258
"command": "coder.searchMyWorkspaces",
@@ -274,6 +274,41 @@
274274
],
275275
"menus":{
276276
"commandPalette": [
277+
{
278+
"command": "coder.login",
279+
"when": "!coder.authenticated"
280+
},
281+
{
282+
"command": "coder.logout",
283+
"when": "coder.authenticated"
284+
},
285+
{
286+
"command": "coder.createWorkspace",
287+
"when": "coder.authenticated"
288+
},
289+
{
290+
"command": "coder.navigateToWorkspace",
291+
"when": "coder.authenticated"
292+
},
293+
{
294+
"command": "coder.navigateToWorkspaceSettings",
295+
"when": "coder.authenticated"
296+
},
297+
{
298+
"command": "coder.workspace.update",
299+
"when": "coder.workspace.updatable"
300+
},
301+
{
302+
"command": "coder.refreshWorkspaces",
303+
"when": "coder.authenticated"
304+
},
305+
{
306+
"command": "coder.viewLogs"
307+
},
308+
{
309+
"command": "coder.openAppStatus",
310+
"when": "coder.authenticated"
311+
},
277312
{
278313
"command": "coder.debug.listDeployments",
279314
"when": "coder.devMode"

‎src/api/utils.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
importfsfrom"fs/promises";
1+
importfsfrom"node:fs/promises";
22
import{ProxyAgent}from"proxy-agent";
33
import{typeWorkspaceConfiguration}from"vscode";
44

‎src/remote/sshProcess.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,9 @@ export class SshProcessMonitor implements vscode.Disposable{
256256
consttargetPid=this.currentPid;
257257
while(!this.disposed&&this.currentPid===targetPid){
258258
try{
259-
constlogFiles=awaitfs.readdir(logDir);
260-
logFiles.sort().reverse();
259+
constlogFiles=(awaitfs.readdir(logDir))
260+
.sort((a,b)=>a.localeCompare(b))
261+
.reverse();
261262
constlogFileName=logFiles.find(
262263
(file)=>
263264
file===`${targetPid}.log`||file.endsWith(`-${targetPid}.log`),
@@ -420,7 +421,7 @@ async function findRemoteSshLogPath(
420421
constdirs=awaitfs.readdir(logsParentDir);
421422
constoutputDirs=dirs
422423
.filter((d)=>d.startsWith("output_logging_"))
423-
.sort()
424+
.sort((a,b)=>a.localeCompare(b))
424425
.reverse();
425426

426427
if(outputDirs.length>0){

0 commit comments

Comments
(0)