@@ -176,6 +176,10 @@ export class WalkthroughWebviewProvider implements vscode.WebviewViewProvider {
176176
177177 private async handleWebviewMessage ( message : any ) : Promise < void > {
178178 switch ( message . command || message . type ) {
179+ case 'clearWalkthrough' :
180+ console . log ( 'Walkthrough: clearWalkthrough command received' ) ;
181+ await this . clearWalkthrough ( ) ;
182+ break ;
179183 case 'openFile' :
180184 console . log ( 'Walkthrough: openFile command received:' , message . dialecticUrl ) ;
181185 await openDialecticUrl ( message . dialecticUrl , this . outputChannel , this . baseUri , this . placementMemory ) ;
@@ -207,6 +211,36 @@ export class WalkthroughWebviewProvider implements vscode.WebviewViewProvider {
207211 }
208212 }
209213
214+ /**
215+ * Clear the walkthrough and dismiss any active comments
216+ */
217+ private async clearWalkthrough ( ) : Promise < void > {
218+ console . log ( '[WALKTHROUGH] Clearing walkthrough and comments' ) ;
219+
220+ // Clear any active comment threads
221+ if ( this . commentController ) {
222+ // Dispose all comment threads
223+ this . commentController . dispose ( ) ;
224+
225+ // Recreate the comment controller for future use
226+ this . commentController = vscode . comments . createCommentController (
227+ 'dialectic-walkthrough' ,
228+ 'Dialectic Walkthrough'
229+ ) ;
230+
231+ // Set options to enable submit button
232+ this . commentController . options = {
233+ prompt : 'Ask Socratic Shell...' ,
234+ placeHolder : 'Type your question or comment here...'
235+ } ;
236+ }
237+
238+ // Clear placement memory
239+ this . placementMemory . clear ( ) ;
240+
241+ this . outputChannel . appendLine ( 'Walkthrough cleared' ) ;
242+ }
243+
210244 /**
211245 * Show comment using VSCode CommentController with context-aware file opening
212246 */
@@ -939,6 +973,31 @@ export class WalkthroughWebviewProvider implements vscode.WebviewViewProvider {
939973 padding: 16px;
940974 line-height: 1.5;
941975 }
976+ .walkthrough-header {
977+ display: flex;
978+ justify-content: space-between;
979+ align-items: center;
980+ margin-bottom: 20px;
981+ padding-bottom: 12px;
982+ border-bottom: 1px solid var(--vscode-panel-border);
983+ }
984+ .walkthrough-title {
985+ font-size: 1.2em;
986+ font-weight: 600;
987+ color: var(--vscode-textLink-foreground);
988+ }
989+ .clear-button {
990+ background-color: var(--vscode-button-secondaryBackground);
991+ color: var(--vscode-button-secondaryForeground);
992+ border: none;
993+ padding: 6px 12px;
994+ border-radius: 3px;
995+ cursor: pointer;
996+ font-size: 0.9em;
997+ }
998+ .clear-button:hover {
999+ background-color: var(--vscode-button-secondaryHoverBackground);
1000+ }
9421001 .section {
9431002 margin-bottom: 24px;
9441003 }
@@ -1092,6 +1151,10 @@ export class WalkthroughWebviewProvider implements vscode.WebviewViewProvider {
10921151 </style>
10931152 </head>
10941153 <body>
1154+ <div class="walkthrough-header">
1155+ <div class="walkthrough-title">Code Walkthrough</div>
1156+ <button class="clear-button" id="clear-walkthrough">Clear</button>
1157+ </div>
10951158 <div id="content">
10961159 <div class="empty-state">No walkthrough loaded</div>
10971160 </div>
@@ -1335,7 +1398,13 @@ export class WalkthroughWebviewProvider implements vscode.WebviewViewProvider {
13351398
13361399 // Add event listener for action button clicks (CSP-compliant)
13371400 document.addEventListener('click', (event) => {
1338- if (event.target.tagName === 'BUTTON' &&
1401+ if (event.target.id === 'clear-walkthrough') {
1402+ // Clear walkthrough and dismiss comments
1403+ document.getElementById('content').innerHTML = '<div class="empty-state">No walkthrough loaded</div>';
1404+ vscode.postMessage({
1405+ type: 'clearWalkthrough'
1406+ });
1407+ } else if (event.target.tagName === 'BUTTON' &&
13391408 event.target.classList.contains('action-button') &&
13401409 event.target.dataset.tellAgent) {
13411410 handleAction(event.target.dataset.tellAgent);
0 commit comments