@@ -52,9 +52,17 @@ export class EmpathyDashboardProvider implements vscode.WebviewViewProvider {
5252 switch ( message . type ) {
5353 case 'runCommand' :
5454 try {
55- // Special handling for run-tests (runs pytest directly)
56- if ( message . command === 'run-tests' ) {
57- await this . _runTests ( ) ;
55+ // Quick Actions that should open in webview instead of terminal
56+ const webviewCommands : Record < string , { cmd : string ; title : string } > = {
57+ 'morning' : { cmd : 'morning' , title : 'Morning Briefing' } ,
58+ 'ship' : { cmd : 'ship' , title : 'Pre-Ship Check' } ,
59+ 'learn' : { cmd : 'learn --analyze 20' , title : 'Learn Patterns' } ,
60+ 'run-tests' : { cmd : 'ship --tests-only' , title : 'Test Results' }
61+ } ;
62+
63+ if ( webviewCommands [ message . command ] ) {
64+ const { cmd, title } = webviewCommands [ message . command ] ;
65+ await this . _runQuickAction ( cmd , title ) ;
5866 } else if ( message . command === 'initialize' ) {
5967 // Launch the Initialize Wizard (force open, bypass "already initialized" check)
6068 await vscode . commands . executeCommand ( 'empathy.initializeProject' , { force : true } ) ;
@@ -766,20 +774,53 @@ export class EmpathyDashboardProvider implements vscode.WebviewViewProvider {
766774 return this . _workflowHistory . get ( workflowId ) ;
767775 }
768776
769- private async _runTests ( ) {
777+ /**
778+ * Run a Quick Action command and display output in webview report panel.
779+ * Replaces terminal output with rich webview display.
780+ */
781+ private async _runQuickAction ( command : string , title : string ) : Promise < void > {
770782 const workspaceFolder = vscode . workspace . workspaceFolders ?. [ 0 ] ?. uri . fsPath ;
771783 if ( ! workspaceFolder ) {
772784 vscode . window . showErrorMessage ( 'No workspace folder open' ) ;
773785 return ;
774786 }
775787
776- // Create terminal for test output
777- const terminal = vscode . window . createTerminal ( {
778- name : 'Empathy Tests' ,
779- cwd : workspaceFolder
780- } ) ;
781- terminal . show ( ) ;
782- terminal . sendText ( 'python -m pytest tests/ --no-cov -v' ) ;
788+ // Get configured python path
789+ const config = vscode . workspace . getConfiguration ( 'empathy' ) ;
790+ const pythonPath = config . get < string > ( 'pythonPath' , 'python' ) ;
791+
792+ // Build arguments as array for safe execution
793+ const args = [ '-m' , 'empathy_os.cli' , ...command . split ( / \s + / ) ] ;
794+
795+ // Show progress notification
796+ vscode . window . withProgress (
797+ {
798+ location : vscode . ProgressLocation . Notification ,
799+ title : `Empathy: Running ${ title } ...` ,
800+ cancellable : false
801+ } ,
802+ async ( ) => {
803+ return new Promise < void > ( ( resolve ) => {
804+ cp . execFile ( pythonPath , args , { cwd : workspaceFolder , maxBuffer : 1024 * 1024 * 5 } , async ( error , stdout , stderr ) => {
805+ const output = stdout || stderr || ( error ? error . message : 'No output' ) ;
806+
807+ // Open in webview report panel
808+ try {
809+ await vscode . commands . executeCommand ( 'empathy.openReportInEditor' , {
810+ workflowName : command . split ( / \s + / ) [ 0 ] , // Use first word as workflow name
811+ output,
812+ input : title
813+ } ) ;
814+ vscode . window . showInformationMessage ( `${ title } report opened` ) ;
815+ } catch ( openErr ) {
816+ vscode . window . showErrorMessage ( `Failed to open report: ${ openErr } ` ) ;
817+ }
818+
819+ resolve ( ) ;
820+ } ) ;
821+ } ) ;
822+ }
823+ ) ;
783824 }
784825
785826 private async _runWorkflow ( workflowName : string , input ?: string ) {
0 commit comments