11import * as vscode from 'vscode' ;
22
3+ type WalkthroughElement =
4+ | string // Markdown content
5+ | { comment : any } // Simplified for now
6+ | { gitdiff : any } // Simplified for now
7+ | { action : { button : string ; description ?: string ; tell_agent ?: string } } ;
8+
9+ interface WalkthroughData {
10+ introduction ?: WalkthroughElement [ ] ;
11+ highlights ?: WalkthroughElement [ ] ;
12+ changes ?: WalkthroughElement [ ] ;
13+ actions ?: WalkthroughElement [ ] ;
14+ }
15+
316export class WalkthroughWebviewProvider implements vscode . WebviewViewProvider {
417 public static readonly viewType = 'dialectic.walkthrough' ;
518
@@ -12,23 +25,31 @@ export class WalkthroughWebviewProvider implements vscode.WebviewViewProvider {
1225 context : vscode . WebviewViewResolveContext ,
1326 _token : vscode . CancellationToken ,
1427 ) {
28+ console . log ( 'WalkthroughWebviewProvider.resolveWebviewView called' ) ;
1529 this . _view = webviewView ;
1630
1731 webviewView . webview . options = {
1832 enableScripts : true ,
1933 localResourceRoots : [ this . _extensionUri ]
2034 } ;
2135
36+ console . log ( 'Setting webview HTML' ) ;
2237 webviewView . webview . html = this . _getHtmlForWebview ( webviewView . webview ) ;
38+ console . log ( 'Webview HTML set, webview should be ready' ) ;
2339 }
2440
25- public showWalkthrough ( walkthrough : any ) {
41+ public showWalkthrough ( walkthrough : WalkthroughData ) {
42+ console . log ( 'WalkthroughWebviewProvider.showWalkthrough called with:' , walkthrough ) ;
2643 if ( this . _view ) {
44+ console . log ( 'Webview exists, showing and posting message' ) ;
2745 this . _view . show ?.( true ) ;
2846 this . _view . webview . postMessage ( {
2947 type : 'walkthrough' ,
3048 data : walkthrough
3149 } ) ;
50+ console . log ( 'Message posted to webview' ) ;
51+ } else {
52+ console . log ( 'ERROR: No webview available' ) ;
3253 }
3354 }
3455
@@ -108,18 +129,12 @@ export class WalkthroughWebviewProvider implements vscode.WebviewViewProvider {
108129 <div class="empty-state">No walkthrough loaded</div>
109130 </div>
110131 <script>
132+ console.log('Walkthrough webview JavaScript loaded');
111133 const vscode = acquireVsCodeApi();
134+ console.log('VSCode API acquired');
112135
113136 function renderMarkdown(text) {
114- return text
115- .replace(/^# (.*$)/gm, '<h1>$1</h1>')
116- .replace(/^## (.*$)/gm, '<h2>$1</h2>')
117- .replace(/^### (.*$)/gm, '<h3>$1</h3>')
118- .replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>')
119- .replace(/\*(.*?)\*/g, '<em>$1</em>')
120- .replace(/\`(.*?)\`/g, '<code>$1</code>')
121- .replace(/^- (.*$)/gm, '<li>$1</li>')
122- .replace(/(<li>.*<\/li>)/s, '<ul>$1</ul>');
137+ return text; // Just return plain text for now
123138 }
124139
125140 function renderSection(title, items) {
@@ -133,8 +148,8 @@ export class WalkthroughWebviewProvider implements vscode.WebviewViewProvider {
133148 html += '<div class="content-item">' + renderMarkdown(item) + '</div>';
134149 } else if (item.action) {
135150 html += '<div class="content-item">';
136- html += '<button class="action-button" onclick="handleAction(\' ' +
137- (item.action.tell_agent || '') + '\ ')">' +
151+ html += '<button class="action-button" onclick="handleAction(' +
152+ JSON.stringify (item.action.tell_agent || '') + ')">' +
138153 item.action.button + '</button>';
139154 if (item.action.description) {
140155 html += '<div class="action-description">' + item.action.description + '</div>';
@@ -157,8 +172,10 @@ export class WalkthroughWebviewProvider implements vscode.WebviewViewProvider {
157172 }
158173
159174 window.addEventListener('message', event => {
175+ console.log('Webview received message:', event.data);
160176 const message = event.data;
161177 if (message.type === 'walkthrough') {
178+ console.log('Processing walkthrough message with data:', message.data);
162179 const data = message.data;
163180 let html = '';
164181
@@ -167,7 +184,13 @@ export class WalkthroughWebviewProvider implements vscode.WebviewViewProvider {
167184 html += renderSection('Changes', data.changes);
168185 html += renderSection('Actions', data.actions);
169186
170- document.getElementById('content').innerHTML = html || '<div class="empty-state">Empty walkthrough</div>';
187+ console.log('Generated HTML:', html);
188+ const finalHtml = html || '<div class="empty-state">Empty walkthrough</div>';
189+ console.log('Setting innerHTML to:', finalHtml);
190+ document.getElementById('content').innerHTML = finalHtml;
191+ console.log('Content updated');
192+ } else {
193+ console.log('Ignoring message type:', message.type);
171194 }
172195 });
173196 </script>
0 commit comments