@@ -126,6 +126,7 @@ export class RepositoryCommandModule {
126126 [ WebviewCmd . StartPractice ] : this . handleStartPractice ,
127127 [ WebviewCmd . StartExercise ] : this . handleStartExercise ,
128128 [ WebviewCmd . OpenRepository ] : this . handleOpenRepository ,
129+ [ WebviewCmd . OpenClonedRepository ] : this . handleOpenClonedRepository ,
129130 [ WebviewCmd . ViewBuildLog ] : this . handleViewBuildLog ,
130131 [ WebviewCmd . GoToSource ] : this . handleGoToSource ,
131132 } ;
@@ -338,7 +339,8 @@ export class RepositoryCommandModule {
338339
339340 this . context . sendMessage ( {
340341 type : ExtensionMsg . ShowClonedRepoNotice ,
341- exerciseTitle : exerciseTitle
342+ exerciseTitle : exerciseTitle ,
343+ participationId,
342344 } ) ;
343345
344346 const openAction = await vscode . window . showInformationMessage (
@@ -752,6 +754,44 @@ export class RepositoryCommandModule {
752754 }
753755 } ;
754756
757+ private handleOpenClonedRepository = async ( message : WebviewToExtensionMessage ) : Promise < void > => {
758+ try {
759+ const { participationId } = getPayload < WebCmd < 'openClonedRepository' > > ( message ) ;
760+ const repoInfo = this . clonedRepositories . get ( participationId ) ;
761+
762+ if ( ! repoInfo ) {
763+ vscode . window . showWarningMessage ( 'Cloned repository not found. It may have been moved or deleted.' ) ;
764+ return ;
765+ }
766+
767+ try {
768+ const stats = fs . statSync ( repoInfo . path ) ;
769+ if ( ! stats . isDirectory ( ) ) {
770+ this . clonedRepositories . delete ( participationId ) ;
771+ vscode . window . showWarningMessage ( 'Cloned repository path is not a directory.' ) ;
772+ return ;
773+ }
774+ } catch {
775+ this . clonedRepositories . delete ( participationId ) ;
776+ vscode . window . showWarningMessage ( 'Cloned repository not found. It may have been moved or deleted.' ) ;
777+ return ;
778+ }
779+
780+ const repoUri = vscode . Uri . file ( repoInfo . path ) ;
781+
782+ const currentFolder = vscode . workspace . workspaceFolders ?. [ 0 ] ;
783+ if ( currentFolder && currentFolder . uri . fsPath === repoInfo . path ) {
784+ await vscode . commands . executeCommand ( 'workbench.view.explorer' ) ;
785+ return ;
786+ }
787+
788+ await vscode . commands . executeCommand ( 'vscode.openFolder' , repoUri , true ) ;
789+ } catch ( error : unknown ) {
790+ logger . error ( 'Open cloned repository error:' , LogCategory . SUBMISSION , error ) ;
791+ vscode . window . showErrorMessage ( 'Failed to open cloned repository.' ) ;
792+ }
793+ } ;
794+
755795 private handleOpenRepository = async ( message : WebviewToExtensionMessage ) : Promise < void > => {
756796 try {
757797 const repositoryUri = getOptionalPayload < WebCmd < 'openRepository' > > ( message ) ?. repositoryUri ;
0 commit comments