1- import { handleDerivableNodeClick , handleDerivationResetClick } from "./views/derivation-nodes" ;
2- import { renderCorrect } from "./views/correct" ;
1+ import { handleDerivableNodeClick , handleDerivationResetClick } from "./views/verification/derivation-nodes" ;
32import { renderLoading } from "./views/loading" ;
4- import { renderErrors } from "./views/errors" ;
5- import { renderWarnings } from "./views/warnings" ;
63import { renderStateMachineView } from "./views/diagram" ;
74import { createMermaidDiagram , renderMermaidDiagram } from "./mermaid" ;
8- import type { LJError , LJWarning , LJDiagnostic } from "../types/diagnostics" ;
5+ import type { LJDiagnostic } from "../types/diagnostics" ;
96import type { StateMachine } from "../types/fsm" ;
7+ import type { NavTab } from "./views/sections" ;
8+ import { renderVerificationView } from "./views/verification/verification" ;
109
1110/**
1211 * Initializes the webview script
@@ -16,12 +15,12 @@ import type { StateMachine } from "../types/fsm";
1615 */
1716export function getScript ( vscode : any , document : any , window : any ) {
1817 const root = document . getElementById ( 'root' ) ;
19- let fileErrors : LJError [ ] = [ ] ;
20- let fileWarnings : LJWarning [ ] = [ ] ;
18+ let diagnostics : LJDiagnostic [ ] = [ ] ;
2119 let showAllDiagnostics = false ;
2220 let currentFile : string | undefined ;
2321 let expandedErrors = new Set < number > ( ) ;
24- let stateMachineView = '' ;
22+ let stateMachine : StateMachine | undefined ;
23+ let selectedTab : NavTab = 'verification' ;
2524
2625 // initial state
2726 root . innerHTML = renderLoading ( ) ;
@@ -91,31 +90,34 @@ export function getScript(vscode: any, document: any, window: any) {
9190 }
9291 return ;
9392 }
93+
94+ // nav tab click
95+ if ( target . classList . contains ( 'nav-tab' ) ) {
96+ e . stopPropagation ( ) ;
97+ const tab = target . getAttribute ( 'data-tab' ) as NavTab ;
98+ if ( tab && tab !== selectedTab ) {
99+ selectedTab = tab ;
100+ updateView ( ) ;
101+ }
102+ return ;
103+ }
94104 } ) ;
95105
96106 window . addEventListener ( 'message' , event => {
97107 const msg = event . data ;
98108 if ( msg . type === 'diagnostics' ) {
99- const diagnostics = msg . diagnostics as LJDiagnostic [ ] ;
100- const errors = diagnostics . filter ( ( d : LJDiagnostic ) => d . category === 'error' ) as LJError [ ] ;
101- const warnings = diagnostics . filter ( ( d : LJDiagnostic ) => d . category === 'warning' ) as LJWarning [ ] ;
102-
103- fileErrors = errors ;
104- fileWarnings = warnings ;
105-
109+ diagnostics = msg . diagnostics as LJDiagnostic [ ] ;
106110 updateView ( ) ;
107111 } else if ( msg . type === 'file' ) {
108112 currentFile = msg . file ;
109113 if ( ! showAllDiagnostics ) updateView ( ) ;
110114 } else if ( msg . type === 'fsm' ) {
111115 if ( ! msg . sm ) {
112- stateMachineView = '' ;
116+ stateMachine = undefined ;
113117 updateView ( ) ;
114118 return ;
115119 }
116- const sm = msg . sm as StateMachine ;
117- const diagram = createMermaidDiagram ( sm ) ;
118- stateMachineView = renderStateMachineView ( sm , diagram ) ;
120+ stateMachine = msg . sm as StateMachine ;
119121 updateView ( ) ;
120122 }
121123 } ) ;
@@ -124,12 +126,12 @@ export function getScript(vscode: any, document: any, window: any) {
124126 * Updates the webview content based on the current state
125127 */
126128 function updateView ( ) {
127- let mainView = fileErrors . length > 0 ? renderErrors ( fileErrors , showAllDiagnostics , currentFile , expandedErrors ) : renderCorrect ( showAllDiagnostics ) ;
128- let warningsView = fileWarnings . length > 0 ? renderWarnings ( fileWarnings , showAllDiagnostics , currentFile ) : '' ;
129- root . innerHTML = mainView + warningsView + stateMachineView ;
130-
131- // re-render mermaid diagram after DOM update
132- if ( stateMachineView ) renderMermaidDiagram ( document , window ) ;
129+ if ( selectedTab === 'verification' ) {
130+ root . innerHTML = renderVerificationView ( diagnostics , showAllDiagnostics , currentFile , expandedErrors , selectedTab )
131+ } else {
132+ const diagram = createMermaidDiagram ( stateMachine ) ;
133+ root . innerHTML = renderStateMachineView ( stateMachine , diagram , selectedTab ) ;
134+ if ( stateMachine ) renderMermaidDiagram ( document , window ) ;
135+ }
133136 }
134137}
135-
0 commit comments