-
Notifications
You must be signed in to change notification settings - Fork 16
feat: integrate HTML config dialog from Language Server [IDE-1458] #426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Introduces BaseSnykUserControl to eliminate duplicate settings synchronization code across all WinForms settings pages. When settings change in the HTML modal window, the base class automatically reloads from disk and updates all WinForms controls. Key changes: - Add BaseSnykUserControl base class with SettingsChanged event handling - Extend Language Server initialization options with new settings (BaseUrl, RiskScoreThreshold, FilterSeverity, AdditionalEnv) - Remove InternalAutoScan flag and auto-scan trigger logic from Language Client - Add severity filter properties (FilterCritical/High/Medium/Low) to options - Implement GetAdditionalEnvAsync/SaveAdditionalEnvAsync in SnykOptionsManager - Update all UserControls to inherit from BaseSnykUserControl - Add logging and error handling to HTML settings window - Extend ScanCommandConfig with pre/post scan command properties
| /// <returns>HTML string for configuration UI, or null if unavailable</returns> | ||
| public static async Task<string> GetConfigHtmlAsync(IJsonRpc rpc, CancellationToken cancellationToken = default) | ||
| { | ||
| if (rpc == null) return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth adding a log here? Not sure how common this will be.
| } | ||
|
|
||
| // Fallback: try priorityScore first, then riskScore | ||
| return AdditionalData.PriorityScore > 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need a fallback? Would Product not always be set?
Snyk.VisualStudio.Extension.2022/Settings/HtmlSettingsWindow.xaml.cs
Outdated
Show resolved
Hide resolved
Snyk.VisualStudio.Extension.2022/Settings/SnykSolutionOptionsUserControl.cs
Show resolved
Hide resolved
Snyk.VisualStudio.Extension.2022/UI/Html/ConfigScriptingBridge.cs
Outdated
Show resolved
Hide resolved
3ef86fd to
2fb042e
Compare
- Migrate to regex-based CSS variable replacement (inspired by IntelliJ plugin) - Replace var(--vscode-*, fallback) patterns with actual VS theme colors - Fix scrollbar theming to adapt properly to dark/light themes - Use proper VS tool window colors for consistent theming across all elements - Add browser feature control keys for better WebBrowser rendering - Adjust modal window dimensions for better content display - Fix ScanCommandConfig property name: Command -> PreScanCommand
2fb042e to
90a8c80
Compare
| { | ||
| ThreadHelper.JoinableTaskFactory.Run(async () => | ||
| { | ||
| await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
| InjectIdeBridgeFunctions(); | ||
|
|
||
| // Hide loading label | ||
| DebugLabel.Visibility = Visibility.Collapsed; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is DebugLabel ?
| private async Task<string> GetHtmlContentAsync() | ||
| { | ||
| // Try to get HTML from Language Server (with retries) | ||
| for (int i = 0; i < 3; i++) | ||
| { | ||
| try | ||
| { | ||
| var lsHtml = await LanguageServerCommands.GetConfigHtmlAsync( | ||
| languageServerRpc, | ||
| System.Threading.CancellationToken.None); | ||
| if (!string.IsNullOrEmpty(lsHtml)) | ||
| { | ||
| Logger.Information("Successfully loaded settings HTML from Language Server"); | ||
| return lsHtml; | ||
| } | ||
| Logger.Warning("Language Server returned empty HTML on attempt {Attempt}", i + 1); | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| Logger.Warning(ex, "Failed to get HTML from Language Server on attempt {Attempt} of 3", i + 1); | ||
| } | ||
|
|
||
| if (i < 2) | ||
| await Task.Delay(1000); | ||
| } | ||
|
|
||
| // Fall back to embedded HTML | ||
| Logger.Warning("Falling back to embedded HTML after 3 failed Language Server attempts"); | ||
| return HtmlResourceLoader.LoadFallbackHtml(options); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not just check if LangaugeServer is initialized ? If not load fallback
| /// Must be ComVisible for IE11 WebBrowser control's ObjectForScripting. | ||
| /// </summary> | ||
| [ComVisible(true)] | ||
| public class ConfigScriptingBridge |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this only used for the new Html Settings? If yes, please rename it for clarity since the name is too generic
ShawkyZ
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please check my comments, happy to pair and go through these changes together.
| SetBrowserFeatureControlKey("FEATURE_BROWSER_EMULATION", appName, 11001); // IE11 mode | ||
| SetBrowserFeatureControlKey("FEATURE_DISABLE_NAVIGATION_SOUNDS", appName, 1); | ||
| SetBrowserFeatureControlKey("FEATURE_SCRIPTURL_MITIGATION", appName, 1); | ||
| SetBrowserFeatureControlKey("FEATURE_96DPI_PIXEL", appName, 1); // Force 96 DPI pixel scaling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check for other solutions
| } | ||
| } | ||
|
|
||
| private void SetBrowserFeatureControlKey(string feature, string appName, int value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we must not manipulate the Windows registry
The new page can be enabled (shown on startup) by setting `AutoOpenOnStartup` to `true` and specifying a path for `DEBUG_HTML_FILE_PATH`.
The new settings page is not DPI aware, so I am disabling the flag which falsely says we are. This fixes issues with dropdowns being rendered incorrectly. Also made the debug HTML page actually not supress errors like it says.

Description
Provide description of this PR and changes, if linked Jira ticket doesn't cover it in full.
Checklist
Screenshots / GIFs
Visuals that may help the reviewer. Please add screenshots for any UI change. GIFs are most welcome!