Skip to content
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

feat: lineage refactor #1212

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open

feat: lineage refactor #1212

wants to merge 45 commits into from

Conversation

saravmajestic
Copy link
Collaborator

@saravmajestic saravmajestic commented Jun 13, 2024

Overview

Problem

Extract lineage component for better maintainability

Solution

  • Created separate components for lineage

Screenshot/Demo

A picture is worth a thousand words. Please highlight the changes if applicable.

How to test

  • enable feature flag: dbt.enableLineageV2 as true in settings.json
  • verify lineage panel, sql visualizer
  • all functionalities should as existing

Checklist

  • I have run this code and it appears to resolve the stated issue
  • README.md updated and added information about my change

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced the NewLineagePanel with improved functionality through integration with additional services.
    • Introduced a new class CLL for managing cancellation and progress tracking.
    • Added new interfaces and updated existing component prop types for better data handling.
    • Added new commands for retrieving configuration settings in the SQLLineagePanel.
  • Improvements

    • Streamlined the rendering logic of the webview for improved responsiveness.
    • Expanded the CodeBlock component to support new theme options.
  • Chores

    • Updated the build script in package.json to increase Node.js memory allocation during the build process.
  • Bug Fixes

    • Resolved issues related to command response tracking for improved accuracy.

@saravmajestic saravmajestic self-assigned this Jun 13, 2024
@@ -173,14 +173,6 @@ export class LineagePanel implements WebviewViewProvider, Disposable {
return;
}

if (command === "openURL") {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is handled via altimateWebviewProvider

window.addEventListener(
"message",
(
event: MessageEvent<{ command: string; args: Record<string, unknown> }>,

Check warning

Code scanning / CodeQL

Missing origin verification in `postMessage` handler Medium

Postmessage handler has no origin check.

Copilot Autofix AI 18 days ago

To fix the problem, we need to ensure that the postMessage handler verifies the origin of incoming messages against a list of trusted origins. This involves:

  1. Defining a list of trusted origins.
  2. Modifying the postMessage handler to check if the event's origin is in the list of trusted origins.
  3. Logging and ignoring messages from untrusted origins.
Suggested changeset 1
webview_panels/src/modules/lineage/LineageView.tsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/webview_panels/src/modules/lineage/LineageView.tsx b/webview_panels/src/modules/lineage/LineageView.tsx
--- a/webview_panels/src/modules/lineage/LineageView.tsx
+++ b/webview_panels/src/modules/lineage/LineageView.tsx
@@ -92,2 +92,4 @@
 
+    const trustedOrigins = ["vscode-webview://"];
+
     window.addEventListener(
@@ -97,3 +99,3 @@
       ) => {
-        if (!event.origin.startsWith("vscode-webview://")) {
+        if (!trustedOrigins.includes(event.origin)) {
           panelLogger.debug("invalid message ", event);
EOF
@@ -92,2 +92,4 @@

const trustedOrigins = ["vscode-webview://"];

window.addEventListener(
@@ -97,3 +99,3 @@
) => {
if (!event.origin.startsWith("vscode-webview://")) {
if (!trustedOrigins.includes(event.origin)) {
panelLogger.debug("invalid message ", event);
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
@@ -188,17 +188,6 @@ export class QueryResultPanel extends AltimateWebviewProvider {
);
}

private async checkIfWebviewReady() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved to altimateWebviewProvider

@saravmajestic saravmajestic marked this pull request as ready for review July 9, 2024 07:55
@saravmajestic saravmajestic changed the title feat: lineage v2 feat: lineage refactor Jul 9, 2024
Copy link
Collaborator

@AdiGajbhiye AdiGajbhiye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Contributor

coderabbitai bot commented Sep 23, 2024

Walkthrough

The changes involve a substantial refactor of the NewLineagePanel and SQLLineagePanel classes, enhancing their functionality by integrating additional services and updating their constructors. The webview rendering methods have been streamlined, with new methods introduced for better management of webview content. Additionally, several new interfaces and components have been added to the altimate-components.d.ts file, and the package.json has been updated to modify the build script for improved Node.js memory management.

Changes

Files Change Summary
src/webview_provider/newLineagePanel.ts Refactored NewLineagePanel to extend AltimateWebviewProvider, updated constructor to include new services, streamlined webview rendering logic into renderWebviewView, removed _panel property, and modified handleCommand method to accept syncRequestId.
src/webview_provider/sqlLineagePanel.ts Refactored SQLLineagePanel to extend AltimateWebviewProvider, updated constructor to include new services, renamed resolveWebviewView to renderSqlVisualizer, and refactored message handling with new commands.
webview_panels/src/lib/altimate/altimate-components.d.ts Added new class CLL with static methods for cancellation and progress tracking, introduced multiple new interfaces, and updated existing component props.
webview_panels/src/lib/altimate/altimate-components.js Reorganized exports, added new exports for CLL, CllEvents, and Lineage, and repositioned existing exports.
webview_panels/package.json Updated build script to include NODE_OPTIONS=--max-old-space-size=16384 before executing the TypeScript compiler.

Possibly related PRs

  • Support model versions #1436: The changes in the SQLLineagePanel and NewLineagePanel classes both involve replacing nodeMetaMap.get() with lookupByBaseName() and lookupByUniqueId(), indicating a shared focus on improving how node metadata is accessed, which is relevant to the refactoring in the main PR.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 21

Outside diff range and nitpick comments (22)
webview_panels/src/lib/altimate/altimate-components.js (1)

2-11: LGTM: Export declarations updated correctly with a minor suggestion

The export declarations have been appropriately updated to include the new components (CLL, CllEvents, Lineage) and reorganize existing exports. These changes align well with the PR objectives of enhancing the lineage component and improving maintainability.

For consistency and improved readability, consider sorting the exports alphabetically. Here's a suggested order:

export {
  a as ApiHelper,
  e as CLL,
  r as CllEvents,
  n as CodeBlock,
  i as ConversationGroupProvider,
  t as ConversationInputForm,
  C as ConversationSources,
  l as DbtDocs,
  p as Lineage
};
webview_panels/src/modules/lineage/components/help/HelpButton.tsx (2)

5-19: LGTM: Well-structured component with good UX considerations.

The HelpButton component is well-implemented, using the Drawer component effectively to display help content. The button styling and content are appropriate for its purpose.

Consider adding an aria-label to the button for improved accessibility. You can modify the buttonProps like this:

 buttonProps={{
   outline: true,
+  'aria-label': 'Open help drawer',
 }}

1-21: Summary: Well-implemented component aligning with PR objectives.

The HelpButton component is a well-structured and focused addition that aligns with the PR's goal of enhancing maintainability through separate lineage components. Its clean implementation should facilitate easier updates and modifications in the future.

To fully meet the PR objectives:

  1. Ensure this component is properly integrated into the lineage panel.
  2. Verify that it works correctly when the dbt.enableLineageV2 feature flag is enabled.
  3. Consider updating the README.md to include information about this new help feature in the lineage component.
webview_panels/src/modules/lineage/Demo.tsx (1)

11-22: Consider extracting the URL to a constant or configuration file.

The documentation button implementation is good, using the executeRequestInAsync function to open the URL. However, it might be beneficial to extract the hardcoded URL "https://docs.myaltimate.com" to a constant or configuration file for easier maintenance and potential reuse.

Consider applying this change:

+ const DOCUMENTATION_URL = "https://docs.myaltimate.com";

  // ... (in the onClick handler)
  executeRequestInAsync("openURL", {
-   url: "https://docs.myaltimate.com",
+   url: DOCUMENTATION_URL,
  });
webview_panels/src/modules/lineage/MissingLineageMessage.tsx (1)

10-12: LGTM: Well-defined helper function.

The openProblemsTab function is concise and uses the existing executeRequestInAsync utility effectively. Its purpose is clear from the name.

Consider adding a brief comment explaining the purpose of this function and what the "Problems" tab represents in the context of the application. This would enhance code readability for future maintainers.

webview_panels/src/AppConstants.tsx (1)

Line range hint 1-31: Consider creating an issue for future lazy loading optimization

There's a TODO comment at the beginning of the file regarding lazy loading. To ensure this optimization task isn't forgotten, consider creating a GitHub issue to track it.

Here's a suggested issue description:

Title: Implement lazy loading for route components

Description:
Currently, all route components are imported eagerly. Implementing lazy loading could improve initial load time and overall performance. However, there's a known issue with Vite's dynamic loading when CSS is involved.

Tasks:

  1. Research how to fix the CSS loading issue with Vite's dynamic imports
  2. Implement lazy loading for route components
  3. Test thoroughly to ensure no regression in functionality
  4. Update documentation if necessary

Please create this issue if you agree it's worth tracking.

webview_panels/src/modules/lineage/lineage.module.scss (3)

1-19: LGTM! Good use of CSS custom properties for theming.

The root and body styles are well-structured, with appropriate use of CSS custom properties for theming. The dark theme implementation aligns well with VSCode's theming approach.

Consider reviewing the necessity of !important declarations on lines 4 and 5. While they might be required to override VSCode styles, it's generally a good practice to minimize their use when possible.


31-40: LGTM! Consistent use of CSS custom properties for theming.

The menu_card styles maintain consistency with the overall theming approach, which is good for maintainability.

Consider reviewing the necessity of the !important declaration on line 32. While it might be required to override other styles, it's generally a good practice to minimize their use when possible.


1-79: Overall, excellent styling that aligns well with PR objectives.

This new SCSS file for the lineage component contributes significantly to the PR's goal of improving maintainability. The use of CSS custom properties for theming, consistent styling patterns, and support for both light and dark themes are all positive aspects that align with best practices for VSCode extension development.

The separation of lineage-specific styles into this module supports the PR's objective of creating separate components for lineage, which should facilitate easier updates and modifications in the future.

To further enhance maintainability, consider extracting common theme variables (like colors and spacing) into a separate SCSS file that can be imported across different components. This would centralize theme management and make it easier to maintain a consistent look and feel across the entire extension.

webview_panels/src/modules/lineage/components/help/HelpContent.tsx (1)

23-50: LGTM: Clear and informative content structure.

The help content is well-structured and provides clear information about the lineage feature. The use of paragraphs and an unordered list improves readability.

Consider adding a brief explanation or link to instructions on how to add the API key in the extension settings. This could be helpful for users who want to access the column level lineage. For example:

 You need to add API key in the extension settings to
-view column level lineage. You can view model level lineage without an
-API key.
+view column level lineage. (See our <a href="#" className="text-blue">documentation</a> for instructions
+on adding the API key.) You can view model level lineage without an API key.
webview_panels/src/uiCore/theme.scss (1)

179-181: LGTM! Consider adding a comment for clarity.

The addition of the .modal-content class is consistent with the existing styling patterns and correctly uses a CSS variable for theming. This change aligns well with the PR's objective of refactoring the lineage component.

For improved readability and consistency with other sections, consider adding a brief comment above the new class definition. For example:

// Modal styles
.modal-content {
  background-color: var(--background--04);
}
src/webview_provider/lineagePanel.ts (1)

Issues Found with Removal of openURL Command Handling

The removal of the openURL command handling in src/webview_provider/lineagePanel.ts may impact multiple parts of the codebase where openURL is still in use:

  • src/webview_provider/altimateWebviewProvider.ts
  • webview_panels/src/modules/lineage/Demo.tsx
  • webview_panels/src/modules/lineage/components/help/HelpContent.tsx
  • webview_panels/src/modules/commonActionButtons/FeedbackButton.tsx
  • new_lineage_panel/src/service_utils.ts
  • new_lineage_panel/src/StaticLineage.tsx
  • new_lineage_panel/src/Demo.tsx
  • new_lineage_panel/src/ActionWidget.tsx

Please ensure that removing openURL does not disrupt functionality in these areas. Consider refactoring or properly deprecating openURL across the codebase to maintain application stability.

Analysis chain

Line range hint 142-148: Approve change with suggestions for verification

The update to extract url from args.params?.url is a good improvement:

  1. It allows for a more nested structure in args.
  2. The use of optional chaining (?.) is a safer way to access nested properties.

However, there are a couple of points to consider:

  1. Please verify that this change doesn't break existing functionality. Any code that previously relied on args.url directly might need to be updated.

  2. The removal of the openURL command handling is notable. Was this intentional? If so, please ensure that this functionality is not needed elsewhere in the codebase.

To verify the impact of these changes, you can run the following script:

This will help identify any potential areas that might need updating due to these changes.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining usage of args.url or the openURL command
rg --type typescript 'args\.url|openURL'

Length of output: 77


Script:

#!/bin/bash
# Search for any remaining usage of args.url or the openURL command in TypeScript files
rg 'args\.url|openURL' --glob '*.ts' --glob '*.tsx'

Length of output: 1258

webview_panels/src/assets/icons/index.tsx (1)

Line range hint 1-140: Summary: Changes align with PR objectives, but consider some refinements.

The changes in this file contribute to the PR's objective of refactoring the lineage component. The new LineageDemo component provides a way to display a lineage demonstration, which aligns with the goal of creating separate components for lineage.

However, to further improve maintainability:

  1. Consider addressing the TypeScript error without suppression, as suggested in the previous comment.
  2. Ensure that the window.lineageGif global variable is properly managed and documented, as it's crucial for the component's functionality.
  3. Update the README.md file to include information about this new lineage demonstration feature and how to use it, as mentioned in the PR checklist.

To enhance modularity and reduce dependencies:

  1. Consider moving the lineage-specific components (like LineageDemo) to a separate file within a lineage folder. This would align with the PR's goal of creating separate components for lineage.
  2. If window.lineageGif is specific to lineage functionality, consider encapsulating it within a lineage-specific context or configuration, rather than relying on a global variable.

These changes would further support the PR's objective of improving the maintainability of the lineage component.

src/webview_provider/altimateWebviewProvider.ts (3)

570-580: LGTM: New LineageGif constant

The addition of the LineageGif constant follows the existing pattern for asset URIs in this file, which is good for consistency. This suggests that a new visual asset (lineage.gif) is being introduced to the webview.

For even better consistency, consider using the same naming convention as other constants in this method. For example, you could rename it to LineageGifUrl to match SpinnerUrl.


610-617: LGTM: HTML template modifications

The changes to the HTML template are consistent with the earlier addition of the LineageGif constant and suggest the introduction of new modal functionality. The modifications look good and follow the existing structure of the template.

For consistency with other variable names in the script section, consider using camelCase for the lineageGif variable name. For example:

var lineageGifUrl = "${LineageGif}"

This would match the naming convention of spinnerUrl.


Line range hint 496-617: Summary of changes: Lineage visualization and webview improvements

The changes in this file introduce new functionality for lineage visualization and improve the webview readiness checking mechanism. Here's a summary of the key changes:

  1. A new checkIfWebviewReady method has been added to asynchronously wait for the webview to be ready.
  2. A new LineageGif constant has been introduced, suggesting the addition of a visual asset for lineage representation.
  3. The HTML template has been modified to include a new modal div and make the lineage GIF available to the webview's JavaScript.

These changes appear to be part of a larger feature implementation related to lineage visualization in the DBT Power User extension. The modifications are generally well-implemented and consistent with the existing codebase. Some minor optimizations and consistency improvements have been suggested in the individual review comments.

As this seems to be part of a larger feature implementation, ensure that:

  1. The lineage functionality is properly integrated with other parts of the extension.
  2. Appropriate error handling is in place for cases where the lineage GIF might fail to load.
  3. The new modal functionality is accessible and follows VSCode's UI guidelines.
  4. Performance impact of the new lineage visualization is monitored, especially if it involves loading large GIFs or complex visualizations.
src/commands/index.ts (1)

Line range hint 696-704: Consider reusing existing webview panels

The current implementation creates a new webview panel each time the sqlLineage command is executed. To improve user experience and reduce clutter, consider reusing existing panels if they're already open.

Here's a suggested approach:

let sqlVisualizerPanel: vscode.WebviewPanel | undefined;

// In the sqlLineage command handler:
if (sqlVisualizerPanel) {
  sqlVisualizerPanel.reveal(vscode.ViewColumn.Two);
} else {
  sqlVisualizerPanel = vscode.window.createWebviewPanel(
    SQLLineagePanel.viewType,
    `${modelName} - visualization`,
    vscode.ViewColumn.Two,
    { retainContextWhenHidden: true, enableScripts: true }
  );
  
  sqlVisualizerPanel.onDidDispose(() => {
    sqlVisualizerPanel = undefined;
  });
}

this.sqlLineagePanel.renderSqlVisualizer(sqlVisualizerPanel, lineage);

This approach will reuse the existing panel if it's open, or create a new one if it's not, providing a more consistent user experience.

webview_panels/src/modules/lineage/LineageView.tsx (2)

36-36: Address the TODO regarding TypeScript generics

There's a TODO comment to add a type generic for executeRequestInSync. Ensuring proper TypeScript typings will enhance type safety and code maintainability.

Would you like assistance in defining the generic types for executeRequestInSync? I can help update the function to include appropriate type parameters.


106-113: Handle unknown commands gracefully

Currently, unrecognized commands received in the message handler are ignored silently. For improved debugging and user experience, consider logging a warning or handling them explicitly.

Apply this diff to enhance command handling:

            if (command in commandMap) {
              (
                commandMap[command as keyof typeof commandMap] as (
                  args: Record<string, unknown>,
                ) => void
              )(args);
+           } else {
+             panelLogger.warn(`Received unknown command: ${command}`);
            }
webview_panels/src/lib/altimate/altimate-components.d.ts (1)

301-303: Specify the event detail type for selectionend

When extending the HTMLElementEventMap interface with a custom event selectionend, it's good practice to specify the type of the event detail for better type safety. If selectionend carries additional data, consider parameterizing CustomEvent with the appropriate type.

For example:

 interface HTMLElementEventMap {
-    selectionend: CustomEvent;
+    selectionend: CustomEvent<SelectionEndDetail>;
 }

Replace SelectionEndDetail with the correct type of the event's detail property.

src/webview_provider/newLineagePanel.ts (2)

394-395: Clarify Usage of event.event for Readability

The pattern event = this.queryManifestService.getEventByCurrentProject(); followed by if (!event?.event) { return; } can be confusing due to the repetition of event. Consider renaming variables or destructuring to enhance clarity. For example:

const projectEvent = this.queryManifestService.getEventByCurrentProject();
if (!projectEvent?.event) {
  return;
}

This makes the code more readable and reduces potential confusion.

Also applies to: 428-429, 558-559, 775-776


Line range hint 914-920: Handle Potential Errors in getMissingLineageMessage

The try-catch block in getMissingLineageMessage captures errors from throwDiagnosticsErrorIfAvailable(). Ensure that all exceptions are properly handled, and consider logging the errors or providing additional context to aid in debugging.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 841bf7f and f685076.

Files ignored due to path filters (1)
  • webview_panels/src/assets/icons/lineage.gif is excluded by !**/*.gif
Files selected for processing (24)
  • new_lineage_panel/src/service_utils.ts (1 hunks)
  • src/altimate.ts (3 hunks)
  • src/commands/index.ts (1 hunks)
  • src/webview_provider/altimateWebviewProvider.ts (3 hunks)
  • src/webview_provider/lineagePanel.ts (1 hunks)
  • src/webview_provider/newLineagePanel.ts (23 hunks)
  • src/webview_provider/queryResultPanel.ts (0 hunks)
  • src/webview_provider/sqlLineagePanel.ts (6 hunks)
  • webview_panels/src/AppConstants.tsx (2 hunks)
  • webview_panels/src/assets/icons/index.tsx (2 hunks)
  • webview_panels/src/lib/altimate/altimate-components.d.ts (1 hunks)
  • webview_panels/src/lib/altimate/altimate-components.js (1 hunks)
  • webview_panels/src/modules/lineage/ActionWidget.tsx (1 hunks)
  • webview_panels/src/modules/lineage/Demo.tsx (1 hunks)
  • webview_panels/src/modules/lineage/LineageView.tsx (1 hunks)
  • webview_panels/src/modules/lineage/MissingLineageMessage.tsx (1 hunks)
  • webview_panels/src/modules/lineage/components/demo/DemoButton.tsx (1 hunks)
  • webview_panels/src/modules/lineage/components/help/HelpButton.tsx (1 hunks)
  • webview_panels/src/modules/lineage/components/help/HelpContent.tsx (1 hunks)
  • webview_panels/src/modules/lineage/lineage.module.scss (1 hunks)
  • webview_panels/src/modules/lineage/types.ts (1 hunks)
  • webview_panels/src/uiCore/components/codeblock/index.tsx (1 hunks)
  • webview_panels/src/uiCore/index.ts (1 hunks)
  • webview_panels/src/uiCore/theme.scss (1 hunks)
Files not reviewed due to no reviewable changes (1)
  • src/webview_provider/queryResultPanel.ts
Additional context used
Biome
src/webview_provider/sqlLineagePanel.ts

[error] 220-220: Unnecessary continue statement

Unsafe fix: Delete the unnecessary continue statement

(lint/correctness/noUnnecessaryContinue)


[error] 281-281: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

The declaration is defined in this switch clause:

Unsafe fix: Wrap the declaration in a block.

(lint/correctness/noSwitchDeclarations)


[error] 291-291: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

The declaration is defined in this switch clause:

Unsafe fix: Wrap the declaration in a block.

(lint/correctness/noSwitchDeclarations)


[error] 299-299: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

The declaration is defined in this switch clause:

Unsafe fix: Wrap the declaration in a block.

(lint/correctness/noSwitchDeclarations)

webview_panels/src/lib/altimate/altimate-components.d.ts

[error] 9-19: Avoid classes that contain only static members.

Prefer using simple functions instead of classes with only static members.

(lint/complexity/noStaticOnlyClass)


[error] 297-298: This empty export is useless because there's another export or import.

This import makes useless the empty export.

Safe fix: Remove this useless empty export.

(lint/complexity/noUselessEmptyExport)

GitHub Check: CodeQL
webview_panels/src/modules/lineage/LineageView.tsx

[warning] 96-96: Missing origin verification in postMessage handler
Postmessage handler has no origin check.

Additional comments not posted (44)
webview_panels/src/lib/altimate/altimate-components.js (1)

1-1: LGTM: Import statement updated correctly

The import statement has been appropriately updated to include the new identifiers that are being exported. This change aligns well with the modifications in the export declarations.

webview_panels/src/modules/lineage/types.ts (2)

1-1: LGTM: Import statement is correct and necessary.

The import of CollectColumn and Details from "@lib" is appropriate for the interfaces defined in this file.


3-6: LGTM: MissingLineageMessage interface is well-defined.

The interface provides a clear structure for lineage-related messages, with appropriate types for each property. The use of a union type for the 'type' property is a good practice.

webview_panels/src/modules/lineage/components/help/HelpButton.tsx (2)

1-3: LGTM: Imports are appropriate and well-organized.

The import statements are concise and relevant to the component's functionality. The use of both relative and absolute imports is consistent with best practices.


21-21: LGTM: Appropriate export statement.

The default export of the HelpButton component is correct and follows common practices for React components.

webview_panels/src/modules/lineage/Demo.tsx (4)

1-3: LGTM: Import statements are appropriate and concise.

The import statements are relevant to the component's functionality, using aliased paths for better organization. No unused imports are present.


5-29: LGTM: Well-structured component with clear layout.

The Demo component is well-organized, using appropriate CSS classes for layout and flexbox. The structure is clear and easy to understand, with a header section and a main content area.


31-31: LGTM: Proper named export of the Demo component.

The export statement correctly uses a named export for the Demo component, following best practices and allowing for easy import in other files.


1-31: Overall assessment: Well-implemented new component for lineage demo.

This new Demo component aligns well with the PR objectives of enhancing the maintainability of the lineage component. It contributes to the modular approach mentioned in the PR summary by creating a separate, focused component for the lineage demo. The implementation is clean, well-structured, and follows React best practices.

A minor suggestion was made to improve maintainability by extracting the hardcoded URL to a constant or configuration file. Otherwise, the component looks good and ready for integration.

webview_panels/src/uiCore/components/codeblock/index.tsx (2)

31-32: LGTM, pending theme impact verification

The changes to the theme-related props appear to be intentional and aimed at providing more granular control over the theming of the CodeblockLib component. The rest of the component's logic and structure remain unchanged, which is good.

Please ensure to test the component with different theme settings to confirm that the visual output matches the expected behavior with these new prop assignments.


31-32: Verify the impact of theme changes on the CodeblockLib component

The changes to the theme props passed to the CodeblockLib component might affect its rendering:

  1. The theme prop now directly uses the app's theme instead of the derived codeBlockTheme.
  2. A new editorTheme prop has been introduced, using the value previously assigned to theme.

These changes suggest a more granular control over theming, but it's important to ensure they don't unintentionally alter the component's appearance or functionality.

To verify the impact of these changes, please run the following script:

This script will help identify any other usages of CodeblockLib that might need similar updates, and verify the prop definitions in the CodeblockLib component to ensure they align with these changes.

webview_panels/src/modules/lineage/MissingLineageMessage.tsx (4)

1-3: LGTM: Imports are well-organized and appropriate.

The imports are concise and relevant to the component's functionality. Good job on separating the type definitions into a separate file.


5-9: LGTM: Well-defined component with proper TypeScript usage.

The component is correctly defined as a functional component with proper TypeScript typing for its prop. The optional prop and explicit return type enhance the component's flexibility and type safety.


39-39: LGTM: Appropriate export of the component.

The default export of the component is correct and follows common React practices.


1-39: Overall assessment: Well-implemented component with minor improvement opportunities.

The MissingLineageMessageComponent is a well-structured and typed React component that aligns with the PR objectives of enhancing the maintainability of the lineage component. It provides a modular approach to handling missing lineage messages, which should improve the overall maintainability of the codebase.

The component demonstrates good practices such as:

  • Proper use of TypeScript for type safety
  • Conditional rendering based on prop values
  • Use of existing UI components and utility functions

To further enhance the component, consider implementing the suggested refactoring improvements mentioned in the previous comments. These changes will improve code readability and maintainability without affecting the component's functionality.

To ensure that this component is properly integrated and used within the project, run the following verification script:

This script will help verify that the new component is properly imported and used within the project, and that the required type definition exists.

webview_panels/src/modules/lineage/components/demo/DemoButton.tsx (5)

1-5: LGTM: Imports are well-organized and use appropriate aliases.

The imports are logically structured, using aliases for better maintainability. All necessary components and hooks are imported.


7-9: LGTM: Component definition and state management are well-implemented.

The DemoButton component is correctly defined as a functional component. The use of useState hooks for managing the visibility of the demo button and modal is appropriate and follows React best practices.


18-46: LGTM: Render method is well-implemented with appropriate conditional rendering and event handling.

The render method effectively uses conditional rendering for the demo button and properly implements the modal with a close functionality. The use of stopPropagation in the button's onClick handler is a good practice to prevent unintended event bubbling.


48-48: LGTM: Component export is correct.

The DemoButton component is correctly exported as the default export, following common React practices.


1-48: Overall, the DemoButton component is well-implemented and aligns with the PR objectives.

The DemoButton component effectively implements a temporary demo button that opens a modal with a demo of the lineage functionality. This aligns well with the PR objectives of enhancing the lineage component and improving maintainability. The code is clean, efficient, and follows React best practices.

Key points:

  1. Good use of React hooks for state management and side effects.
  2. Appropriate conditional rendering and event handling.
  3. Well-structured code with clear separation of concerns.

The only suggested improvement is to clear the timeout when the component unmounts to prevent potential memory leaks.

This new component contributes to the modular approach mentioned in the PR objectives, which should facilitate easier updates and modifications in the future.

webview_panels/src/AppConstants.tsx (2)

8-8: LGTM: Import statement for LineageView

The import statement for LineageView is correctly formatted and consistent with other imports in the file.


29-29: LGTM: New route for LineageView added

The new route for LineageView is correctly added to the AvailableRoutes object and is consistent with other route definitions.

To ensure the new route is properly integrated, please run the following verification script:

This script will verify:

  1. The correct import of LineageView
  2. The proper addition of the lineage route to AvailableRoutes
  3. The existence of the LineageView component file
Verification successful

Verification Failed: LineageView import not found in AppConstants.tsx

The initial verification script encountered an issue recognizing the TypeScript file type, preventing accurate checks. To address this, please run the following updated verification script:

This updated script uses grep to avoid issues with file type recognition and will verify:

  1. The correct import of LineageView
  2. The proper addition of the /lineage route to AvailableRoutes
  3. The existence of the LineageView.tsx component file

Please execute this script and provide the results for further analysis.


Verification Successful: LineageView route correctly implemented

The verification scripts confirmed that the LineageView component is properly imported, the /lineage route is correctly added to the AvailableRoutes object, and the LineageView.tsx component file exists in the expected location.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the LineageView component is correctly imported and used

# Test 1: Check if LineageView is imported
if ! rg --type typescript "import LineageView from \"@modules/lineage/LineageView\"" webview_panels/src/AppConstants.tsx; then
    echo "Error: LineageView import not found in AppConstants.tsx"
    exit 1
fi

# Test 2: Check if the lineage route is correctly added to AvailableRoutes
if ! rg --type typescript "^\s*\"/lineage\":\s*{\s*component:\s*<LineageView\s*/>\s*}," webview_panels/src/AppConstants.tsx; then
    echo "Error: Lineage route not found or incorrectly formatted in AvailableRoutes"
    exit 1
fi

# Test 3: Verify LineageView component exists
if ! fd --type f "LineageView.tsx" webview_panels/src/modules/lineage; then
    echo "Warning: LineageView.tsx not found in expected location. Please verify the file exists."
fi

echo "All checks passed successfully."

Length of output: 280


Script:

#!/bin/bash
# Description: Re-verify the presence of the LineageView import and route without relying on file type

# Test 1: Check if LineageView is imported
if ! grep -q 'import LineageView from "@modules/lineage/LineageView"' webview_panels/src/AppConstants.tsx; then
    echo "Error: LineageView import not found in AppConstants.tsx"
    exit 1
fi

# Test 2: Check if the lineage route is correctly added to AvailableRoutes
if ! grep -q '"/lineage": { component: <LineageView \/> },' webview_panels/src/AppConstants.tsx; then
    echo "Error: Lineage route not found or incorrectly formatted in AvailableRoutes"
    exit 1
fi

# Test 3: Verify LineageView component exists
if ! fd --type f "LineageView.tsx" webview_panels/src/modules/lineage; then
    echo "Warning: LineageView.tsx not found in expected location. Please verify the file exists."
fi

echo "All checks passed successfully."

Length of output: 384

webview_panels/src/uiCore/index.ts (1)

31-31: LGTM! Please clarify the intended usage of the Modal component.

The addition of the Modal component from reactstrap is consistent with the existing export pattern and expands the available UI components for use in the application. This change could potentially support the lineage refactoring mentioned in the PR objectives.

Could you provide more context on how the Modal component will be used in relation to the lineage refactoring? This information would help in understanding the full scope of the changes and ensure that it aligns with the PR objectives.

webview_panels/src/modules/lineage/ActionWidget.tsx (2)

1-18: LGTM: Well-structured imports and component declaration

The imports are appropriate for the component's functionality, and the ActionWidget component is well-defined with properly typed props. This approach enhances code maintainability and type safety.


56-56: LGTM: Correct component export

The component is properly exported as the default export, which is the standard practice for React components.

webview_panels/src/modules/lineage/lineage.module.scss (2)

20-30: LGTM! Effective use of flexbox for layout.

The lineageView styles create a full-viewport layout with a flexible inner wrap. This approach provides a good foundation for responsive design.


42-55: LGTM! Well-structured action widget styles.

The action-widget styles effectively position the widget and its buttons. The use of flexbox for button layout and z-index for layering is appropriate.

webview_panels/src/modules/lineage/components/help/HelpContent.tsx (3)

1-4: LGTM: Imports and component declaration are well-structured.

The imports are appropriate for the component's functionality, and the component is correctly declared as a functional component returning JSX.Element.


66-66: LGTM: Component export is correct.

The component is correctly exported as the default export, following React best practices.


1-66: Overall, well-implemented help component with minor suggestions for improvement.

The HelpContent component is well-structured and provides clear, informative content about the lineage feature. The use of styled elements and links enhances readability and user experience.

Main strengths:

  1. Clear explanation of lineage types and requirements.
  2. Well-organized content structure with paragraphs and lists.
  3. Provision of additional resources for users.

Suggestions for improvement:

  1. Consider using configuration or environment variables for URLs to enhance maintainability.
  2. Add a brief explanation or link to instructions for adding the API key.

These changes would further improve the component's maintainability and user-friendliness without significantly altering its current functionality.

new_lineage_panel/src/service_utils.ts (1)

41-41: Approve simplification, but verify extension compatibility and consider consistency

The simplification of the message structure in the openURL function is a good improvement that aligns with the PR's maintainability goals.

Please ensure that the VS Code extension side can handle this new message structure. Run the following script to check for any inconsistencies in handling openURL messages:

Consider applying similar simplifications to other functions in this file (e.g., openFile) for consistency. This would further improve the overall maintainability of the codebase.

Verification successful

Verified extension compatibility and code consistency

The openURL message structure change has been successfully verified. The VS Code extension correctly handles the openURL command, ensuring compatibility with the updated message format.

  • Handler found in ./src/webview_provider/altimateWebviewProvider.ts:340
  • openURL is properly exported and used in ./new_lineage_panel/src/service_utils.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for inconsistencies in handling 'openURL' messages

# Search for 'openURL' handler in the extension code
rg --type typescript -A 10 "case 'openURL':" 

Length of output: 87


Script:

#!/bin/bash
# Description: Check for inconsistencies in handling 'openURL' messages by searching for 'openURL' handlers in .ts files

# Find all .ts files and search for 'case 'openURL':' within them
fd --extension ts --type file --exec grep -H -A 10 "case 'openURL':" {} \;

Length of output: 85


Script:

#!/bin/bash
# Description: Broadly search for 'openURL' usage in .ts and .js files to locate any handlers

# Search for 'openURL' in all .ts and .js files
fd --extension ts --extension js --type file --exec grep -H -n "openURL" {} \;

Length of output: 463

webview_panels/src/assets/icons/index.tsx (1)

27-27: LGTM: New import statement is correctly placed.

The import for LineageGif is appropriately added with other imports at the top of the file, maintaining good code organization.

src/altimate.ts (1)

934-937: LGTM! Verify usage of the new type across the codebase.

The renaming of StaticLineageResponse to SqlLineageResponse improves consistency and clarity. This change aligns well with the PR objectives of enhancing maintainability.

To ensure this change doesn't introduce any issues, please verify that all occurrences of StaticLineageResponse have been updated accordingly throughout the codebase. Run the following script to check for any remaining instances:

If the script returns any results, those occurrences should be updated to use SqlLineageResponse.

src/commands/index.ts (1)

703-703: Verify consistency with SQLLineagePanel class

While the method name change improves clarity, it's important to ensure that this change is consistent with the SQLLineagePanel class implementation.

Let's verify the SQLLineagePanel class implementation:

If the renderSqlVisualizer method is not found in the SQLLineagePanel class, consider updating the class to include this method or correcting the method name in this file.

Verification successful

SQLLineagePanel class includes renderSqlVisualizer method

The SQLLineagePanel class in src/webview_provider/sqlLineagePanel.ts includes the renderSqlVisualizer method, ensuring consistency with its usage in src/commands/index.ts.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for the SQLLineagePanel class definition
ast-grep --lang typescript --pattern 'class SQLLineagePanel {
  $$$
  renderSqlVisualizer($$$) {
    $$$
  }
  $$$
}'

# If the above doesn't yield results, search for any method named renderSqlVisualizer in the SQLLineagePanel file
rg --type typescript 'renderSqlVisualizer' src/webview_provider/sqlLineagePanel.ts

Length of output: 237


Script:

#!/bin/bash
# Search for the SQLLineagePanel class definition without specifying file type
ast-grep --lang typescript --pattern 'class SQLLineagePanel {
  $$$
  renderSqlVisualizer($$$) {
    $$$
  }
  $$$
}'

# Search for any occurrence of 'renderSqlVisualizer' in the SQLLineagePanel file without specifying file type
rg 'renderSqlVisualizer' src/webview_provider/sqlLineagePanel.ts

# List the contents of the src/webview_provider directory to verify the presence of sqlLineagePanel.ts
ls src/webview_provider/

Length of output: 459

webview_panels/src/modules/lineage/LineageView.tsx (2)

137-137: Confirm the inclusion of DemoButton

The DemoButton component is rendered in the lineage view. Ensure that this is intended for production and not left over from testing or debugging.

Run the following script to check if DemoButton is appropriately used across the codebase:

#!/bin/bash
# Description: Verify the usage of DemoButton in the project.

# Test: Search for all occurrences of 'DemoButton'.
rg --type ts --type tsx $'DemoButton'

# Review the contexts where 'DemoButton' is used.
# Expectation: 'DemoButton' should only appear where it's intended in the production code.

96-101: Confirm the sufficiency of the origin check in the message event listener

You have implemented an origin check using event.origin.startsWith("vscode-webview://"). While this is a good practice, it's important to ensure that this check adequately secures the message handling against potential security risks.

Run the following script to verify that the origin check correctly filters messages and that no unintended messages are processed:

Verification successful

Origin Check in Message Event Listener is Sufficient

The origin check using event.origin.startsWith("vscode-webview://") in LineageView.tsx effectively secures message handling. No other message event listeners without adequate origin checks were found in the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the origin check in the message event listener.

# Test: Search for 'event.origin' usages to confirm proper origin checking.
rg --type ts --type tsx -A 5 -B 2 $'event.origin'

# Verify that all message event listeners include adequate origin checks.
# Expect: All listeners should validate 'event.origin' before processing messages.

Length of output: 197


Script:

#!/bin/bash
# Description: Verify the origin check in the message event listener.

# Test: Search for 'event.origin' usages to confirm proper origin checking.
rg event.origin --glob "*.ts" --glob "*.tsx" -A 5 -B 2

# Verify that all message event listeners include adequate origin checks.
# Expect: All listeners should validate 'event.origin' before processing messages.

Length of output: 780

Tools
GitHub Check: CodeQL

[warning] 96-96: Missing origin verification in postMessage handler
Postmessage handler has no origin check.

src/webview_provider/sqlLineagePanel.ts (1)

47-63: Verify superclass constructor parameters

Ensure that the parameters passed to super() in the constructor match the expected order and types defined in AltimateWebviewProvider. Any mismatch could lead to runtime errors or unexpected behavior.

src/webview_provider/newLineagePanel.ts (7)

74-77: Ensure Correct Inheritance and Implementation

The NewLineagePanel class now extends AltimateWebviewProvider and implements LineagePanelView. Verify that all necessary methods from AltimateWebviewProvider are properly utilized, and that the implementation satisfies the LineagePanelView interface requirements.


85-102: Validate Constructor Initialization

Additional services have been injected into the constructor (eventEmitterService, queryManifestService, usersService). Ensure that these services are correctly initialized and utilized within the class. Also, confirm that the super call passes all required arguments to the parent class.


103-116: Configuration Change Listener Added

A listener for configuration changes has been added to re-render the webview when dbt.enableLineagePanelV2 is modified. This ensures that the webview stays up-to-date with user settings.


165-171: Consistent Message Handling with syncRequestId

The handleCommand method now includes an optional syncRequestId in the message structure, enhancing asynchronous communication handling. Ensure that all command handling logic correctly utilizes syncRequestId to maintain message synchronization.


Line range hint 181-252: Include syncRequestId in Responses

In response messages, syncRequestId is now included within the args. This improves response tracking between the webview and the extension. Confirm that all relevant responses consistently include syncRequestId to ensure reliable communication.


327-327: Unhandled Commands Delegated to Superclass

The call to super.handleCommand(message); allows unhandled commands to be processed by the superclass. Verify that the superclass AltimateWebviewProvider can handle these commands appropriately, and that this delegation does not introduce unexpected behavior.


981-989: Conditional Webview Rendering Based on Feature Flag

The renderWebviewView method now conditionally renders the webview content based on the enableLineagePanelV2 configuration setting. This allows for feature toggling between different versions of the lineage panel. Verify that both rendering paths function correctly and that the feature flag behaves as expected.

Comment on lines +8 to +14
export interface StaticLineageProps {
selectedColumn?: { table: string; name: string };
collectColumns?: Record<string, CollectColumn[]>;
columnEdges?: [string, string][];
tableEdges: [string, string][];
details: Details;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a suggestion: StaticLineageProps interface is well-structured.

The interface provides a clear structure for static lineage properties, with appropriate use of optional properties and types. However, there's a potential improvement for the 'collectColumns' property:

Consider using a more specific type for the 'collectColumns' property. Instead of Record<string, CollectColumn[]>, you could define a type alias for better readability and type safety:

type TableColumns = Record<string, CollectColumn[]>;

export interface StaticLineageProps {
  // ... other properties
  collectColumns?: TableColumns;
  // ... remaining properties
}

This change would make the code more self-documenting and easier to understand at a glance.

Comment on lines +14 to +37
if (!missingLineageMessage) {
return null;
}
return (
<Alert color="warning" className="p-2 mb-0">
{missingLineageMessage.message}
{missingLineageMessage.type === "error" ? (
<>
<Button
color="link"
className={"pt-0 pb-0"}
style={{ marginTop: -5 }}
onClick={openProblemsTab}
>
Click here
</Button>{" "}
to view Problems tab
</>
) : (
""
)}
</Alert>
);
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM: Component logic is sound and well-structured.

The component's logic is well-organized, with appropriate handling of the optional prop and good use of conditional rendering. The use of the Alert component for displaying the message is fitting.

Consider the following improvements:

  1. Extract the button rendering logic into a separate component or function to improve readability.
  2. Replace inline styles with CSS classes for better maintainability. For example:
-          <Button
-            color="link"
-            className={"pt-0 pb-0"}
-            style={{ marginTop: -5 }}
-            onClick={openProblemsTab}
-          >
+          <Button
+            color="link"
+            className="pt-0 pb-0 mt-n1"
+            onClick={openProblemsTab}
+          >
  1. Consider using template literals for string interpolation instead of concatenation:
-        <>
-          <Button
-            color="link"
-            className="pt-0 pb-0 mt-n1"
-            onClick={openProblemsTab}
-          >
-            Click here
-          </Button>{" "}
-          to view Problems tab
-        </>
+        <span>
+          <Button
+            color="link"
+            className="pt-0 pb-0 mt-n1"
+            onClick={openProblemsTab}
+          >
+            Click here
+          </Button>
+          {` to view Problems tab`}
+        </span>

These changes will enhance the component's maintainability and readability.

Committable suggestion was skipped due to low confidence.

Comment on lines +11 to +16
useEffect(() => {
// hide demo button after 10s
setTimeout(() => {
setShowDemoButton(false);
}, 10000);
}, []);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider clearing the timeout to prevent potential memory leaks.

While the useEffect hook is used correctly to hide the demo button after 10 seconds, it's important to clear the timeout when the component unmounts to prevent potential memory leaks.

Consider modifying the useEffect hook as follows:

useEffect(() => {
  // hide demo button after 10s
  const timer = setTimeout(() => {
    setShowDemoButton(false);
  }, 10000);

  // Clear the timeout when the component unmounts
  return () => clearTimeout(timer);
}, []);

This change ensures that the timeout is properly cleared if the component unmounts before the 10 seconds have elapsed.

Comment on lines +19 to +25
if (lineageType === "sql") {
return (
<div className={styles.actionWidget}>
<FeedbackButton url="https://app.myaltimate.com/contactus" />
</div>
);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using a configuration for the feedback URL

The feedback URL is currently hardcoded. To improve maintainability and flexibility, consider moving this URL to a configuration file or environment variable.

You could refactor this part as follows:

import { FEEDBACK_URLS } from '@config/urls';

// ...

return (
  <div className={styles.actionWidget}>
    <FeedbackButton url={FEEDBACK_URLS.sql} />
  </div>
);

This approach would make it easier to update the URL in the future and maintain consistency across the application.

Comment on lines +36 to +39
onClick={() => {
executeRequestInAsync("setLegacyLineageView", {});
CLL.cancel();
}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add error handling for async function call

The async function call to set the legacy lineage view lacks error handling. Consider wrapping it in a try-catch block to handle potential errors gracefully.

You could refactor this part as follows:

onClick={async () => {
  try {
    await executeRequestInAsync("setLegacyLineageView", {});
    CLL.cancel();
  } catch (error) {
    console.error("Failed to set legacy lineage view:", error);
    // Optionally, show an error message to the user
  }
}}

This approach ensures that any errors during the async operation are caught and logged, improving the robustness of the application.

nodeType: _node.resource_type,
nodeId: modelId,
};
nodeMapping[key] = { nodeId: modelId, type: _node.resource_type };
break;
}
}
continue;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unnecessary continue statement

The continue statement at line 220 is unnecessary because it's at the end of the loop block. Removing it will simplify the code without affecting functionality.

Apply this diff to remove the unnecessary continue:

      }
-     continue;
    }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
continue;
}
Tools
Biome

[error] 220-220: Unnecessary continue statement

Unsafe fix: Delete the unnecessary continue statement

(lint/correctness/noUnnecessaryContinue)

});
break;
case "getColumns":
const body = await this.getColumns(params);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrap variable declaration in a block within switch case

Similar to the previous case, the variable body should be scoped within a block to prevent unintended access by other cases.

Apply this diff:

     case "getColumns":
+      {
       const body = await this.getColumns(params);
       this._panel?.webview.postMessage({
         command: "response",
         args: { id, syncRequestId, body, status: true },
       });
       break;
+      }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const body = await this.getColumns(params);
case "getColumns":
{
const body = await this.getColumns(params);
this._panel?.webview.postMessage({
command: "response",
args: { id, syncRequestId, body, status: true },
});
break;
}
Tools
Biome

[error] 291-291: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

The declaration is defined in this switch clause:

Unsafe fix: Wrap the declaration in a block.

(lint/correctness/noSwitchDeclarations)

}
switch (command) {
case "openFile":
const { url } = args;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrap variable declaration in a block within switch case

Declaring variables directly inside a switch case can lead to unexpected behavior due to variable hoisting. Wrap the case "openFile": block in braces to localize the scope of the url variable.

Apply this diff to wrap the case in a block:

     case "openFile":
+      {
       const { url } = args;
       if (!url) {
         return;
       }
       await commands.executeCommand("vscode.open", Uri.file(url), {
         preview: false,
         preserveFocus: true,
       });
       break;
+      }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const { url } = args;
case "openFile":
{
const { url } = args;
if (!url) {
return;
}
await commands.executeCommand("vscode.open", Uri.file(url), {
preview: false,
preserveFocus: true,
});
break;
}
Tools
Biome

[error] 281-281: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

The declaration is defined in this switch clause:

Unsafe fix: Wrap the declaration in a block.

(lint/correctness/noSwitchDeclarations)

});
return;
case "getLineageSettings":
const config = workspace.getConfiguration("dbt.lineage");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrap variable declaration in a block within switch case

To avoid potential variable hoisting issues, wrap the case "getLineageSettings": block in braces. This confines the config variable's scope to this case only.

Apply this diff:

     case "getLineageSettings":
+      {
       const config = workspace.getConfiguration("dbt.lineage");
       this._panel?.webview.postMessage({
         command: "response",
         args: {
           id,
           syncRequestId,
           status: true,
           body: {
             showSelectEdges: config.get("showSelectEdges", true),
             showNonSelectEdges: config.get("showNonSelectEdges", true),
             defaultExpansion: config.get("defaultExpansion", 1),
             useSchemaForQueryVisualizer: config.get(
               "useSchemaForQueryVisualizer",
               false,
             ),
           },
         },
       });
       break;
+      }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const config = workspace.getConfiguration("dbt.lineage");
case "getLineageSettings":
{
const config = workspace.getConfiguration("dbt.lineage");
this._panel?.webview.postMessage({
command: "response",
args: {
id,
syncRequestId,
status: true,
body: {
showSelectEdges: config.get("showSelectEdges", true),
showNonSelectEdges: config.get("showNonSelectEdges", true),
defaultExpansion: config.get("defaultExpansion", 1),
useSchemaForQueryVisualizer: config.get(
"useSchemaForQueryVisualizer",
false,
),
},
},
});
break;
}
Tools
Biome

[error] 299-299: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

The declaration is defined in this switch clause:

Unsafe fix: Wrap the declaration in a block.

(lint/correctness/noSwitchDeclarations)

Comment on lines +914 to +916
this.queryManifestService
.getProject()
?.throwDiagnosticsErrorIfAvailable();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add Null Checks to Prevent Potential Runtime Errors

In getMissingLineageMessage, the call to this.queryManifestService.getProject()?.throwDiagnosticsErrorIfAvailable(); may result in a runtime error if getProject() returns undefined. Add a null check to ensure safety.

Apply this diff to add a null check:

 try {
-  this.queryManifestService
-    .getProject()!
-    .throwDiagnosticsErrorIfAvailable();
+  this.queryManifestService.getProject()?.throwDiagnosticsErrorIfAvailable();
 } catch (err) {
   return { message: (err as Error).message, type: "error" };
 }

Committable suggestion was skipped due to low confidence.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Outside diff range and nitpick comments (6)
webview_panels/src/lib/altimate/altimate-components.d.ts (1)

297-298: Remove unnecessary empty export

The empty export statement is unnecessary as there are other exports in the file. It can be safely removed to clean up the code.

Apply this diff to remove the empty export:

 declare type ViewsTypes = keyof typeof VIEWS_TYPE_COLOR;
-export { }
Tools
Biome

[error] 297-298: This empty export is useless because there's another export or import.

This import makes useless the empty export.

Safe fix: Remove this useless empty export.

(lint/complexity/noUselessEmptyExport)

src/webview_provider/newLineagePanel.ts (5)

74-117: LGTM: Class refactor improves modularity and dependency injection.

The NewLineagePanel class has been refactored to extend AltimateWebviewProvider and implement LineagePanelView. This change improves the class's modularity and allows for better separation of concerns. The constructor now uses dependency injection for various services, which is a good practice for maintainability and testability.

A few minor suggestions:

  1. Consider using TypeScript's parameter properties to reduce boilerplate in the constructor.
  2. The _disposables property is not visible in this snippet. Ensure it's properly initialized.

Consider refactoring the constructor to use parameter properties:

constructor(
  protected readonly dbtProjectContainer: DBTProjectContainer,
  private readonly altimate: AltimateRequest,
  protected readonly telemetry: TelemetryService,
  private readonly terminal: DBTTerminal,
  private readonly eventEmitterService: SharedStateService,
  protected readonly queryManifestService: QueryManifestService,
  protected readonly usersService: UsersService,
) {
  super(
    dbtProjectContainer,
    altimate,
    telemetry,
    eventEmitterService,
    terminal,
    queryManifestService,
    usersService,
  );

  // ... rest of the constructor code
}

Line range hint 165-327: Consider refactoring handleCommand for improved maintainability.

The handleCommand method has grown quite large and handles multiple responsibilities. While it's organized by command type, its length makes it harder to maintain and understand at a glance.

Suggestions for improvement:

  1. Consider splitting this method into smaller, more focused methods for each command type.
  2. Implement a command pattern or use a map of command handlers to reduce the number of if-else statements.
  3. Use early returns to reduce nesting and improve readability.

Here's a high-level example of how you might refactor this method:

private commandHandlers = {
  openProblemsTab: () => commands.executeCommand("workbench.action.problems.focus"),
  upstreamTables: async (args) => {
    const body = await this.getUpstreamTables(args.params);
    return { body, status: true };
  },
  // ... other command handlers
};

async handleCommand(message: { command: string; args: any; syncRequestId?: string }): Promise<void> {
  const { command, args = {}, syncRequestId } = message;
  const { id = syncRequestId, params } = args;

  const handler = this.commandHandlers[command];
  if (handler) {
    const result = await handler(args);
    this._panel?.webview.postMessage({
      command: "response",
      args: { id, syncRequestId, ...result },
    });
    return;
  }

  this.terminal.debug("newLineagePanel:handleCommand", "Unsupported command", message);
  super.handleCommand(message);
}

This refactoring would make the handleCommand method more concise and easier to maintain, as each command's logic would be encapsulated in its own function.


Line range hint 541-757: Refactor getConnectedColumns for improved readability and maintainability.

The getConnectedColumns method is complex and handles multiple responsibilities. While it seems to work as intended, its length and complexity make it difficult to understand and maintain.

Suggestions for improvement:

  1. Break down the method into smaller, more focused helper methods.
  2. Consider moving some of the logic (e.g., model fetching, SQL compilation) into separate services.
  3. Use more descriptive variable names to improve readability.
  4. Add more inline comments explaining the purpose of each section.

Here's a high-level example of how you might start refactoring this method:

private async getConnectedColumns(params: ConnectedColumnsParams) {
  const { event, project } = await this.validateAndGetEventAndProject();
  if (!event || !project) return;

  const modelInfos = await this.prepareModelInfos(params, event, project);
  if (this.cancellationTokenSource?.token.isCancellationRequested) {
    return { column_lineage: [] };
  }

  const request = this.buildColumnLevelLineageRequest(params, modelInfos, project);
  const result = await this.fetchColumnLevelLineage(request);

  return this.processColumnLevelLineageResult(result);
}

private async validateAndGetEventAndProject() {
  // ... implementation
}

private async prepareModelInfos(params: ConnectedColumnsParams, event: Event, project: Project) {
  // ... implementation
}

private buildColumnLevelLineageRequest(params: ConnectedColumnsParams, modelInfos: ModelInfo[], project: Project) {
  // ... implementation
}

private async fetchColumnLevelLineage(request: ColumnLevelLineageRequest) {
  // ... implementation
}

private processColumnLevelLineageResult(result: ColumnLevelLineageResult) {
  // ... implementation
}

This refactoring breaks down the large method into smaller, more focused methods, improving readability and maintainability.


Line range hint 981-994: LGTM: Good approach for gradual feature rollout.

The renderWebviewView method has been updated to support a new version of the lineage panel. This is a good approach for gradually rolling out new features while maintaining backward compatibility.

A minor suggestion for improvement:
Consider extracting the version check into a separate method for better readability and reusability.

Here's a suggested refactor:

private isV2Enabled = () =>
  workspace
    .getConfiguration("dbt")
    .get<boolean>("enableLineagePanelV2", false);

protected renderWebviewView(webview: Webview) {
  if (this.isV2Enabled()) {
    this.renderV2WebviewView(webview);
  } else {
    this.renderV1WebviewView(webview);
  }
}

private renderV2WebviewView(webview: Webview) {
  this._panel!.webview.html = super.getHtml(
    webview,
    this.dbtProjectContainer.extensionUri,
  );
}

private renderV1WebviewView(webview: Webview) {
  this._panel!.webview.options = <WebviewOptions>{ enableScripts: true };
  this._panel!.webview.html = getHtml(
    webview,
    this.dbtProjectContainer.extensionUri,
  );
}

This refactoring improves readability and makes it easier to maintain different versions of the webview rendering logic.


Line range hint 1-1048: Consider further refactoring for improved modularity and consistency.

While the individual methods have been improved, the overall file structure could benefit from further refactoring:

  1. The file is quite large. Consider splitting it into smaller, more focused modules.
  2. There's a mix of async/await and Promise-based code. Standardize on async/await for consistency.
  3. Remove or address TODO comments and commented-out code sections.
  4. Consider creating separate services for some of the complex logic (e.g., lineage calculation, webview rendering).

Here are some high-level suggestions for improving the overall architecture:

  1. Create a LineageService to handle the complex lineage calculation logic.
  2. Move webview-related code to a separate LineageWebviewProvider class.
  3. Use dependency injection consistently throughout the codebase.
  4. Create interfaces for the main classes to improve testability and maintainability.

Example structure:

// lineageService.ts
export class LineageService {
  // ... lineage calculation methods
}

// lineageWebviewProvider.ts
export class LineageWebviewProvider extends AltimateWebviewProvider {
  // ... webview-related methods
}

// newLineagePanel.ts
export class NewLineagePanel implements LineagePanelView {
  constructor(
    private lineageService: LineageService,
    private webviewProvider: LineageWebviewProvider,
    // ... other dependencies
  ) {}

  // ... simplified methods using the new services
}

This structure would improve modularity, testability, and maintainability of the codebase.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f685076 and 67fd4f8.

Files selected for processing (3)
  • src/webview_provider/newLineagePanel.ts (24 hunks)
  • webview_panels/src/lib/altimate/altimate-components.d.ts (1 hunks)
  • webview_panels/src/lib/altimate/altimate-components.js (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • webview_panels/src/lib/altimate/altimate-components.js
Additional context used
Biome
webview_panels/src/lib/altimate/altimate-components.d.ts

[error] 9-19: Avoid classes that contain only static members.

Prefer using simple functions instead of classes with only static members.

(lint/complexity/noStaticOnlyClass)


[error] 297-298: This empty export is useless because there's another export or import.

This import makes useless the empty export.

Safe fix: Remove this useless empty export.

(lint/complexity/noUselessEmptyExport)

Additional comments not posted (7)
webview_panels/src/lib/altimate/altimate-components.d.ts (6)

21-25: LGTM: CllEvents enum declaration

The CllEvents enum is well-structured and follows TypeScript conventions. It appropriately defines the events related to the CLL lifecycle (CANCEL, END, START).


27-27: LGTM: CodeBlock component props enhancement

The CodeBlock component has been updated with additional props (editorTheme and className) and refined type definitions. These changes improve the component's flexibility and customization options, aligning with modern React component patterns.

Also applies to: 177-186


29-293: LGTM: Comprehensive type definitions with new interfaces

The addition of numerous new interfaces (e.g., CollectColumn, Column, ColumnLineage, Columns, Confidence, Conversation, ConversationGroup, ExposureMetaData, LineageProviderProps, ModalArgs, OpNodeArgs, SelectedColumn, SqlLineage, StaticLineage, StaticLineageDetails) significantly enhances the type safety and readability of the codebase. These well-structured interfaces follow TypeScript best practices and provide clear type definitions for various data structures used in the application.


279-286: LGTM: VIEWS_TYPE_COLOR constant declaration

The VIEWS_TYPE_COLOR constant provides a centralized definition for view type colors, which can improve consistency across the application. The naming convention follows TypeScript standards for constants.


306-321: LGTM: Identifiers namespace declaration

The Identifiers namespace is a well-structured grouping of related constants. This approach effectively organizes and encapsulates values related to various aspects of the application, including themes, debugging, and remote URIs. It follows good TypeScript practices for constant management.


300-303: Verify usage of custom 'selectionend' event

The global HTMLElementEventMap has been extended to include a custom 'selectionend' event. This is a valid approach to declare custom events. However, it's important to ensure that this custom event is actually used and dispatched in the application.

To verify the usage of this custom event, you can run the following script:

This will help confirm that the custom event is being utilized in the application.

Verification successful

To address the issue with the previous search, please run the following script to verify the usage of the custom 'selectionend' event:


'selectionend' event usage verified

The custom selectionend event is actively used within the application as seen in the following file:

  • webview_panels/src/lib/altimate/DbtDocsRenderer.js
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usage of 'selectionend' event in the codebase
rg --type typescript --type javascript "selectionend" -C 3

Length of output: 93


Script:

# Searching for 'selectionend' event usage in .ts and .js files
rg -e 'selectionend' --glob '*.ts' --glob '*.js' -C 3

Length of output: 1882

src/webview_provider/newLineagePanel.ts (1)

Line range hint 1-1048: Summary: Significant improvements with opportunities for further refinement.

The NewLineagePanel class has undergone substantial refactoring, resulting in improved modularity and functionality. Key improvements include:

  1. Extension of AltimateWebviewProvider and implementation of LineagePanelView.
  2. Improved dependency injection in the constructor.
  3. Support for a new version of the lineage panel.

While these changes are positive, there are opportunities for further improvement:

  1. Further break down large methods like handleCommand and getConnectedColumns.
  2. Standardize on async/await throughout the file.
  3. Consider splitting the file into smaller, more focused modules.
  4. Implement a more robust error handling strategy.

Overall, the changes represent a significant step forward in the codebase's evolution. Addressing the suggested improvements will further enhance the maintainability and scalability of the lineage functionality.

Comment on lines +9 to +19
export declare class CLL {
static isCancelled: boolean;
static inProgress: boolean;
static linkCount: number;
static onCancel(): void;
static cancel(): void;
static start(): void;
static end(): void;
static addLinks(n: number): void;
static showCllInProgressMsg(): void;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider refactoring the CLL class to a namespace or module

The CLL class contains only static members and methods, which is generally discouraged in TypeScript. To improve maintainability and adhere to best practices, consider refactoring this into a namespace or module with exported functions and variables.

Here's a suggested refactor:

export namespace CLL {
    export let isCancelled: boolean;
    export let inProgress: boolean;
    export let linkCount: number;
    export function onCancel(): void;
    export function cancel(): void;
    export function start(): void;
    export function end(): void;
    export function addLinks(n: number): void;
    export function showCllInProgressMsg(): void;
}

This approach maintains the same functionality while aligning with TypeScript best practices.

Tools
Biome

[error] 9-19: Avoid classes that contain only static members.

Prefer using simple functions instead of classes with only static members.

(lint/complexity/noStaticOnlyClass)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Outside diff range and nitpick comments (2)
src/webview_provider/sqlLineagePanel.ts (1)

202-202: Use Consistent Node Type Strings

In assigning the type property for the node mapping, ensure that the string values match expected resource types. For example, "source" should match the resource type used elsewhere in the application to avoid inconsistencies.

src/webview_provider/newLineagePanel.ts (1)

165-171: Standardize the use of 'id' and 'syncRequestId'

In the handleCommand method, both id and syncRequestId are being used interchangeably. This can lead to confusion and potential bugs. Consider standardizing on a single identifier for request correlation.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ce8762d and d27a9b8.

📒 Files selected for processing (3)
  • src/commands/index.ts (1 hunks)
  • src/webview_provider/newLineagePanel.ts (23 hunks)
  • src/webview_provider/sqlLineagePanel.ts (6 hunks)
🧰 Additional context used
🪛 Biome
src/webview_provider/sqlLineagePanel.ts

[error] 220-220: Unnecessary continue statement

Unsafe fix: Delete the unnecessary continue statement

(lint/correctness/noUnnecessaryContinue)


[error] 281-281: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

The declaration is defined in this switch clause:

Unsafe fix: Wrap the declaration in a block.

(lint/correctness/noSwitchDeclarations)


[error] 291-291: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

The declaration is defined in this switch clause:

Unsafe fix: Wrap the declaration in a block.

(lint/correctness/noSwitchDeclarations)


[error] 299-299: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

The declaration is defined in this switch clause:

Unsafe fix: Wrap the declaration in a block.

(lint/correctness/noSwitchDeclarations)

🔇 Additional comments (11)
src/webview_provider/sqlLineagePanel.ts (9)

38-40: Extending AltimateWebviewProvider Enhances Code Reusability

By extending AltimateWebviewProvider, the SQLLineagePanel class now inherits shared functionalities, promoting code reuse and improving maintainability as per the PR objectives.


47-63: Constructor Properly Injects Dependencies

The constructor correctly injects all necessary services and passes them to the superclass, ensuring that both the SQLLineagePanel and its superclass are properly initialized with required dependencies.


250-261: Refactored renderSqlVisualizer Method Improves Clarity

The renderSqlVisualizer method has been refactored for better clarity and efficiency. It streamlines the rendering process by directly posting messages to the webview after ensuring it's ready.


267-272: Enhanced Command Handling in handleCommand Method

The handleCommand method now uses a switch statement for cleaner and more maintainable command handling. The inclusion of syncRequestId supports synchronous communication when necessary.


Line range hint 193-225: Efficient Mapping of Nodes in nodeMapping

The updates to nodeMapping correctly associate node IDs and types, improving the accuracy of the lineage visualization by ensuring that nodes are properly identified and rendered.

🧰 Tools
🪛 Biome

[error] 220-220: Unnecessary continue statement

Unsafe fix: Delete the unnecessary continue statement

(lint/correctness/noUnnecessaryContinue)


31-31: Updated Type Definition for details

The details property in the SQLLineage type has been updated to SqlLineageDetails, ensuring type correctness and better alignment with the data being handled.


15-15: Importing Necessary Types from ../altimate

The import statement now includes SqlLineageDetails, which is necessary for the updated details type, ensuring that all required types are available.


25-27: New Imports for Expanded Functionality

The added imports of AltimateWebviewProvider, SharedStateService, and UsersService indicate an expansion of functionality and integration with additional services, enhancing the capabilities of the SQLLineagePanel.


225-225: Consistent Use of Node Resource Types

Ensure that currNode.resource_type returns a string consistent with the expected values for node types. This consistency is crucial for correct rendering and interaction in the lineage visualization.

src/webview_provider/newLineagePanel.ts (2)

913-915: Good job addressing the previous null check issue

You've successfully added a null check before calling throwDiagnosticsErrorIfAvailable(), preventing potential runtime errors when getProject() returns undefined.


594-594: ⚠️ Potential issue

Ensure 'cancellationTokenSource' is initialized before use

In getConnectedColumns, this.cancellationTokenSource is used without checking if it's initialized. If this.cancellationTokenSource is undefined, accessing its token property will lead to a runtime error. Please ensure that this.cancellationTokenSource is properly initialized before accessing its token.

Apply this diff to add a null check:

-        this.cancellationTokenSource!.token,
+        this.cancellationTokenSource?.token || CancellationToken.None,

Likely invalid or redundant comment.

@@ -700,7 +700,7 @@ export class VSCodeCommands implements Disposable {
ViewColumn.Two,
{ retainContextWhenHidden: true, enableScripts: true },
);
this.sqlLineagePanel.resolveWebviewView(panel, lineage);
this.sqlLineagePanel.renderSqlVisualizer(panel, lineage);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Incomplete method renaming detected.

The method resolveWebviewView still exists in multiple files, indicating that the renaming to renderSqlVisualizer was not fully propagated. To maintain code consistency and prevent potential issues, please ensure that all instances of resolveWebviewView are updated accordingly.

Affected files:

  • src/webview_provider/lineagePanel.ts
  • src/webview_provider/altimateWebviewProvider.ts
  • src/webview_provider/sqlLineagePanel.ts
  • src/webview_provider/queryResultPanel.ts
  • src/webview_provider/newDocsGenPanel.ts
  • src/webview_provider/docsEditPanel.ts
  • src/webview_provider/modelGraphViewPanel.ts
🔗 Analysis chain

Improved method naming for better clarity.

The renaming of resolveWebviewView to renderSqlVisualizer enhances code readability by more accurately describing the method's purpose. This change is a step in the right direction for maintaining clear and self-documenting code.

To ensure consistency across the codebase, let's verify if this method has been renamed in all relevant files:


Correction needed for file type specification in search scripts.

The initial shell scripts failed because rg does not recognize typescript as a valid file type. To resolve this, we'll use the correct file type identifier ts for TypeScript files.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining instances of 'resolveWebviewView' in TypeScript files
echo "Searching for 'resolveWebviewView':"
rg --type typescript 'resolveWebviewView'

# Search for occurrences of 'renderSqlVisualizer' to ensure consistent usage
echo "Searching for 'renderSqlVisualizer':"
rg --type typescript 'renderSqlVisualizer'

Length of output: 330


Script:

#!/bin/bash
# Search for any remaining instances of 'resolveWebviewView' in TypeScript files
echo "Searching for 'resolveWebviewView':"
rg --type ts 'resolveWebviewView'

# Search for occurrences of 'renderSqlVisualizer' to ensure consistent usage
echo "Searching for 'renderSqlVisualizer':"
rg --type ts 'renderSqlVisualizer'

Length of output: 1138

Comment on lines +394 to +395
const event = this.queryManifestService.getEventByCurrentProject();
if (!event?.event) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Refactor repeated event retrieval and null checks

The pattern of retrieving the event and checking for its existence is repeated multiple times. Consider refactoring this into a helper method to reduce code duplication and improve readability.

You could create a helper method:

private getCurrentEvent(): ManifestCacheProjectAddedEvent['event'] | undefined {
  const eventWrapper = this.queryManifestService.getEventByCurrentProject();
  return eventWrapper?.event;
}

Then, replace occurrences like:

const event = this.queryManifestService.getEventByCurrentProject();
if (!event?.event) {
  return;
}

With:

const event = this.getCurrentEvent();
if (!event) {
  return;
}

Also applies to: 428-429, 557-558, 774-775, 931-932

Comment on lines +980 to +987
protected renderWebviewView(webview: Webview) {
if (this.isV2Enabled()) {
this._panel!.webview.html = super.getHtml(
webview,
this.dbtProjectContainer.extensionUri,
);
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Set 'webview.options' consistently

In the renderWebviewView method, this._panel!.webview.options is only set when isV2Enabled() is false. For consistency and to avoid potential issues, consider setting webview.options regardless of the feature flag.

Apply this diff to set webview.options in both cases:

protected renderWebviewView(webview: Webview) {
+  this._panel!.webview.options = { enableScripts: true };
   if (this.isV2Enabled()) {
     this._panel!.webview.html = super.getHtml(
       webview,
       this.dbtProjectContainer.extensionUri,
     );
     return;
   }
-  this._panel!.webview.options = { enableScripts: true };
   this._panel!.webview.html = getHtml(
     webview,
     this.dbtProjectContainer.extensionUri,
   );
}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
protected renderWebviewView(webview: Webview) {
if (this.isV2Enabled()) {
this._panel!.webview.html = super.getHtml(
webview,
this.dbtProjectContainer.extensionUri,
);
return;
}
protected renderWebviewView(webview: Webview) {
this._panel!.webview.options = { enableScripts: true };
if (this.isV2Enabled()) {
this._panel!.webview.html = super.getHtml(
webview,
this.dbtProjectContainer.extensionUri,
);
return;
}
this._panel!.webview.html = getHtml(
webview,
this.dbtProjectContainer.extensionUri,
);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants