-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Problem
Lines 191 to 1466 in src/providers/chartViewProvider.ts
contain approximately 1,275 lines of hard-coded HTML, CSS, and JavaScript embedded directly in a TypeScript string literal within the _getHtmlForWebview()
method.
This approach creates several maintenance and development challenges:
- Difficult to maintain: Any UI changes require editing a massive string literal with escaped characters
- Hard to test: The embedded webview logic cannot be easily unit tested or verified
- Poor readability: Syntax highlighting and IDE support is limited within string literals
- Error-prone: Easy to introduce syntax errors or miss closing tags in the embedded code
- Hard to review: Code reviews of UI changes are challenging due to the string literal format
Suggested Refactoring
- Extract HTML/CSS to separate template files - Move the webview HTML structure to dedicated
.html
and.css
files in amedia/
ortemplates/
directory - Extract JavaScript logic - Move the embedded JavaScript to a separate
.js
file that can be loaded as a webview resource - Use proper templating - Consider using a simple template system to inject dynamic values (configuration, URIs, nonces) into the HTML
- Modularize webview scripts - Break down the monolithic inline script into smaller, testable modules
- Add tests - Once extracted, add unit tests for the webview logic and integration tests for the chart rendering
Benefits
- Significantly improved code maintainability and readability
- Easier to extend with new chart features
- Better IDE support and syntax checking
- Ability to test webview logic independently
- Simpler code reviews and collaboration
Copilot
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request