@@ -36,7 +36,23 @@ async function handleMessage(
3636 console . log ( `${ Date . now ( ) } Beginning handleMessage: ${ message . type } ` ) ;
3737 switch ( message . type ) {
3838 case MessageTypeNames . ExtensionPing :
39- sendToFrontend ( panel , Messages . ExtensionPong ( null ) ) ;
39+ let state = context . globalState . get ( "token" ) ?? null ;
40+
41+ const token = state ? JSON . stringify ( state ) : null ;
42+
43+ console . log ( `WebviewStarted: Obtain token from VSC: ${ token } ` ) ;
44+
45+ // if (token !== null && Object.keys(token).length === 0) {
46+ // token = null
47+ // }
48+ // if (token !== null) {
49+ // token = JSON.stringify(token);
50+ // }
51+
52+ panel ! . webview . postMessage ( Messages . ExtensionPong ( token ) ) ;
53+ if ( token ) {
54+ context . globalState . update ( "token" , undefined ) ;
55+ }
4056 break ;
4157 case MessageTypeNames . NewEditor :
4258 activeEditor = await Editor . create (
@@ -56,8 +72,10 @@ async function handleMessage(
5672 }
5773 if ( editor !== activeEditor ) {
5874 console . log (
59- `EXTENSION: Editor ${ editor . assessmentName } _${ editor . questionId } is no longer active, skipping onChange` ,
75+ `EXTENSION: Editor is no longer active, skipping onChange` ,
76+ `User edited ${ editor . assessmentName } _${ editor . questionId } , active is ${ activeEditor ?. assessmentName } _${ activeEditor ?. questionId } ` ,
6077 ) ;
78+ return ;
6179 }
6280 const message = Messages . Text ( workspaceLocation , code ) ;
6381 console . log ( `Sending message: ${ JSON . stringify ( message ) } ` ) ;
@@ -78,7 +96,8 @@ async function handleMessage(
7896 handling = false ;
7997}
8098
81- export async function showPanel ( context : vscode . ExtensionContext ) {
99+ export async function showPanel ( context : vscode . ExtensionContext , url : string ) {
100+ vscode . window . showInformationMessage ( `showPanel caleld with ${ url } ` ) ;
82101 let language : string | undefined = context . workspaceState . get ( "language" ) ;
83102 if ( ! language ) {
84103 language = LANGUAGES . SOURCE_1 ;
@@ -117,7 +136,8 @@ export async function showPanel(context: vscode.ExtensionContext) {
117136 >
118137 < iframe
119138 id = { FRONTEND_ELEMENT_ID }
120- src = { frontendUrl }
139+ src = { url || frontendUrl }
140+ // src={"vscode://source-academy.source-academy/sso"}
121141 width = "100%"
122142 height = "100%"
123143 // @ts -ignore
0 commit comments