@@ -122,7 +122,9 @@ export class Remote {
122122
123123const disposables :vscode . Disposable [ ] = [ ]
124124// Register before connection so the label still displays!
125- disposables . push ( this . registerLabelFormatter ( `${ this . storage . workspace . owner_name } /${ this . storage . workspace . name } ` ) )
125+ disposables . push (
126+ this . registerLabelFormatter ( remoteAuthority , this . storage . workspace . owner_name , this . storage . workspace . name ) ,
127+ )
126128
127129let buildComplete :undefined | ( ( ) => void )
128130if ( this . storage . workspace . latest_build . status === "stopped" ) {
@@ -420,14 +422,11 @@ export class Remote {
420422} )
421423
422424// Register the label formatter again because SSH overrides it!
423- let label = `${ this . storage . workspace . owner_name } /${ this . storage . workspace . name } `
424- if ( agents . length > 1 ) {
425- label += `/${ agent . name } `
426- }
427-
425+ const workspace = this . storage . workspace
426+ const agentName = agents . length > 1 ?agent . name :undefined
428427disposables . push (
429428vscode . extensions . onDidChange ( ( ) => {
430- disposables . push ( this . registerLabelFormatter ( label ) )
429+ disposables . push ( this . registerLabelFormatter ( remoteAuthority , workspace . owner_name , workspace . name , agentName ) )
431430} ) ,
432431)
433432
@@ -679,14 +678,34 @@ export class Remote {
679678await vscode . commands . executeCommand ( "workbench.action.reloadWindow" )
680679}
681680
682- private registerLabelFormatter ( suffix :string ) :vscode . Disposable {
681+ private registerLabelFormatter (
682+ remoteAuthority :string ,
683+ owner :string ,
684+ workspace :string ,
685+ agent ?:string ,
686+ ) :vscode . Disposable {
687+ // VS Code splits based on the separator when displaying the label
688+ // in a recently opened dialog. If the workspace suffix contains /,
689+ // then it'll visually display weird:
690+ // "/home/kyle [Coder: kyle/workspace]" displays as "workspace] /home/kyle [Coder: kyle"
691+ // For this reason, we use a different / that visually appears the
692+ // same on non-monospace fonts "∕".
693+ let suffix = `Coder:${ owner } ∕${ workspace } `
694+ if ( agent ) {
695+ suffix += `∕${ agent } `
696+ }
697+ // VS Code caches resource label formatters in it's global storage SQLite database
698+ // under the key "memento/cachedResourceLabelFormatters2".
683699return this . vscodeProposed . workspace . registerResourceLabelFormatter ( {
684700scheme :"vscode-remote" ,
701+ // authority is optional but VS Code prefers formatters that most
702+ // accurately match the requested authority, so we include it.
703+ authority :remoteAuthority ,
685704formatting :{
686705label :"${path}" ,
687706separator :"/" ,
688707tildify :true ,
689- workspaceSuffix :`Coder: ${ suffix } ` ,
708+ workspaceSuffix :suffix ,
690709} ,
691710} )
692711}