@@ -45,7 +45,10 @@ export class SandboxTreeItem extends vscode.TreeItem {
4545 super ( label , vscode . TreeItemCollapsibleState . None ) ;
4646
4747 const state = ( sandbox . state ?? 'unknown' ) . toLowerCase ( ) ;
48- this . description = state ;
48+ const eolDate = sandbox . eol
49+ ? new Date ( sandbox . eol ) . toLocaleDateString ( undefined , { year : 'numeric' , month : 'short' , day : 'numeric' } )
50+ : undefined ;
51+ this . description = eolDate ? `${ state } · expires ${ eolDate } ` : state ;
4952 this . iconPath = STATE_ICONS [ state ] ?? DEFAULT_ICON ;
5053 this . contextValue = `sandbox-${ state } ` ;
5154
@@ -55,6 +58,12 @@ export class SandboxTreeItem extends vscode.TreeItem {
5558 if ( sandbox . createdAt ) lines . push ( `Created: ${ sandbox . createdAt } ` ) ;
5659 if ( sandbox . eol ) lines . push ( `EOL: ${ sandbox . eol } ` ) ;
5760 this . tooltip = new vscode . MarkdownString ( lines . join ( '\n\n' ) ) ;
61+
62+ this . command = {
63+ command : 'b2c-dx.sandbox.viewDetails' ,
64+ title : 'View Details' ,
65+ arguments : [ this ] ,
66+ } ;
5867 }
5968}
6069
@@ -66,6 +75,18 @@ function getPollIntervalMs(): number {
6675 return seconds * 1000 ;
6776}
6877
78+ function getSandboxDisplayName ( sandbox : SandboxInfo ) : string {
79+ return sandbox . instance ? `${ sandbox . realm ?? '' } ${ sandbox . realm ? '-' : '' } ${ sandbox . instance } ` : sandbox . id ;
80+ }
81+
82+ function sortSandboxesByName ( sandboxes : SandboxInfo [ ] ) : SandboxInfo [ ] {
83+ return [ ...sandboxes ] . sort ( ( a , b ) => {
84+ const nameA = getSandboxDisplayName ( a ) . toLowerCase ( ) ;
85+ const nameB = getSandboxDisplayName ( b ) . toLowerCase ( ) ;
86+ return nameA . localeCompare ( nameB ) ;
87+ } ) ;
88+ }
89+
6990export class SandboxTreeDataProvider implements vscode . TreeDataProvider < SandboxTreeNode > {
7091 private _onDidChangeTreeData = new vscode . EventEmitter < SandboxTreeNode | undefined | void > ( ) ;
7192 readonly onDidChangeTreeData = this . _onDidChangeTreeData . event ;
@@ -167,7 +188,7 @@ export class SandboxTreeDataProvider implements vscode.TreeDataProvider<SandboxT
167188 private async getRealmChildren ( element : RealmTreeItem ) : Promise < SandboxTreeItem [ ] > {
168189 const cached = this . configProvider . getCachedSandboxes ( element . realm ) ;
169190 if ( cached ) {
170- return cached . map ( ( s ) => new SandboxTreeItem ( s , element . realm ) ) ;
191+ return sortSandboxesByName ( cached ) . map ( ( s ) => new SandboxTreeItem ( s , element . realm ) ) ;
171192 }
172193
173194 const configProvider = this . configProvider . getConfigProvider ( ) ;
@@ -198,7 +219,7 @@ export class SandboxTreeDataProvider implements vscode.TreeDataProvider<SandboxT
198219 } ,
199220 ) ;
200221 this . configProvider . setCachedSandboxes ( element . realm , sandboxes ) ;
201- return sandboxes . map ( ( s ) => new SandboxTreeItem ( s , element . realm ) ) ;
222+ return sortSandboxesByName ( sandboxes ) . map ( ( s ) => new SandboxTreeItem ( s , element . realm ) ) ;
202223 } catch ( err ) {
203224 const message = err instanceof Error ? err . message : String ( err ) ;
204225 vscode . window . showErrorMessage ( `Sandboxes (${ element . realm } ): ${ message } ` ) ;
0 commit comments