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

Print version when run from CLI with --version or -v #1559

Closed
wants to merge 4 commits into from

Conversation

esimkowitz
Copy link
Member

@esimkowitz esimkowitz commented Dec 18, 2024

Summary by CodeRabbit

  • New Features
    • Added command-line arguments to check and display the application version.
    • Introduced a configuration option to dismiss architecture warnings at startup.
    • Added a new section detailing platform requirements for the Wave Terminal.
  • Bug Fixes
    • Improved error handling to ignore specific errors related to the QUIC protocol during the updater process.
  • Documentation
    • Updated FAQ to include information on ARM64 translation warnings and compatibility.
    • Enhanced configuration documentation with new keys and descriptions.

Copy link

coderabbitai bot commented Dec 18, 2024

Walkthrough

The pull request introduces a command-line argument for version checking in the application's appMain function, allowing users to retrieve version information via --version or -v without launching the full application. Additionally, a new function checkIfRunningUnderARM64Translation is added to assess the runtime environment. The error handling for the uncaughtException event listener is refined to ignore QUIC protocol errors, enhancing the application's robustness.

Changes

File Change Summary
emain/emain.ts Added version flag handling in appMain function for --version and -v arguments; added checkIfRunningUnderARM64Translation function; updated uncaughtException listener to ignore QUIC protocol-related errors.
Taskfile.yml Modified package task to append {{.CLI_ARGS}} to the electron-builder command.
docs/docs/config.mdx Added new configuration key app:dismissarchitecturewarning for disabling architecture warnings.
docs/docs/faq.mdx Updated FAQ with new entry on ARM64 translation warnings and performance recommendations.
docs/docs/gettingstarted.mdx Introduced "Platform requirements" section detailing supported platforms and requirements.
emain/platform.ts Implemented user interaction for dismissing ARM64 translation warnings with checkIfRunningUnderARM64Translation.
frontend/types/gotypes.d.ts Added optional property app:dismissarchitecturewarning to SettingsType interface.
pkg/wconfig/metaconsts.go Introduced constant ConfigKey_AppDismissArchitectureWarning for the new configuration key.
pkg/wconfig/settingsconfig.go Added field AppDismissArchitectureWarning to SettingsType struct; reformatted existing fields for consistency.

Possibly related PRs

  • Add FAQ for WSH outside of Wave #1558: The changes in the main PR introduce command-line argument handling, which is relevant to the FAQ update regarding the command-line interface for Wave Shell (WSH) outside of the application.

Poem

🐰 A Rabbit's Ode to Version Checks 🔍
With flags so neat, version's a treat,
QUIC errors now soft and discreet,
CLI magic, simple and bright,
Helping users get info just right!
hop hop 🚀

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


🪧 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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

@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: 0

🧹 Nitpick comments (2)
emain/emain.ts (2)

568-576: Consider using a CLI argument parser for more robust flag handling.

While the current implementation works, it has limitations:

  1. Only checks argv[1], missing flags if they appear later
  2. No error handling for getWaveVersion()

Consider using a CLI argument parsing library like yargs or commander for:

  • More flexible argument position handling
  • Built-in help text generation
  • Consistent error handling

Example implementation:

- const args = process.argv;
- if (args?.length > 1 && (args[1] === "--version" || args[1] === "-v")) {
-     const versionInfo = getWaveVersion();
-     console.log(`Wave Terminal v${versionInfo.version} (build ${versionInfo.buildTime})`);
-     electronApp.quit();
-     return;
- }
+ const yargs = require('yargs/yargs');
+ const argv = yargs(process.argv.slice(1))
+     .version(false)  // Disable default version
+     .option('version', {
+         alias: 'v',
+         describe: 'Show version information',
+         type: 'boolean'
+     })
+     .parse();
+ 
+ if (argv.version) {
+     try {
+         const versionInfo = getWaveVersion();
+         console.log(`Wave Terminal v${versionInfo.version} (build ${versionInfo.buildTime})`);
+     } catch (error) {
+         console.error('Error retrieving version information:', error);
+     }
+     electronApp.quit();
+     return;
+ }

Line range hint 1-575: Document the rationale for ignoring QUIC protocol errors.

The error handling for QUIC protocol errors lacks documentation explaining why these errors can be safely ignored.

Add a comment explaining the context:

 process.on("uncaughtException", (error) => {
     if (caughtException) {
         return;
     }
 
+    // QUIC protocol errors can occur during auto-updates when the updater
+    // attempts to establish a connection. These errors are non-fatal and
+    // can be safely ignored as they don't affect the core functionality
+    // of the application.
     if (error?.message?.includes("net::ERR_QUIC_PROTOCOL_ERROR")) {
         console.log("Ignoring QUIC protocol error:", error.message);
         console.log("Stack Trace:", error.stack);
         return;
     }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cc6da28 and 370c53d.

📒 Files selected for processing (1)
  • emain/emain.ts (1 hunks)
🔇 Additional comments (1)
emain/emain.ts (1)

Line range hint 1-575: Consider more robust QUIC error detection.

The current string-based error detection might be fragile if error messages change.

Consider checking error types or codes instead:

- if (error?.message?.includes("net::ERR_QUIC_PROTOCOL_ERROR")) {
+ // Check for specific error types/codes that indicate QUIC protocol errors
+ if (error?.code === 'ERR_QUIC_PROTOCOL_ERROR' || 
+     (error instanceof Error && error.name === 'QuicError')) {

Let's verify if there are other QUIC-related error patterns we should handle:

Copy link

@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: 0

🧹 Nitpick comments (5)
docs/docs/faq.mdx (2)

36-36: Improve phrase clarity

The phrase "outside of" is redundant.

-`wsh` is an internal CLI for extending control over Wave to the command line, you can learn more about it [here](./wsh). To prevent misuse by other applications, `wsh` requires an access token provided by Wave to work and will not function outside of the app.
+`wsh` is an internal CLI for extending control over Wave to the command line, you can learn more about it [here](./wsh). To prevent misuse by other applications, `wsh` requires an access token provided by Wave to work and will not function outside Wave.
🧰 Tools
🪛 LanguageTool

[style] ~36-~36: This phrase is redundant. Consider using “outside”.
Context: ...d by Wave to work and will not function outside of the app. ## Why does Wave warn me abou...

(OUTSIDE_OF)


40-40: Fix grammatical and hyphenation issues

There are two minor issues in this paragraph:

  1. The word "however" should be properly separated from the sentence
  2. The hyphen in "natively-compiled" is redundant
-macOS and Windows both have compatibility layers that allow x64 applications to run on ARM computers. This helps more apps run on these systems while developers work to add native ARM support to their applications, however it comes with significant performance tradeoffs. To get the best experience using Wave, it is recommended to install the version of Wave that is natively-compiled for your computer.
+macOS and Windows both have compatibility layers that allow x64 applications to run on ARM computers. This helps more apps run on these systems while developers work to add native ARM support to their applications. However, it comes with significant performance tradeoffs. To get the best experience using Wave, it is recommended to install the version of Wave that is natively compiled for your computer.
🧰 Tools
🪛 LanguageTool

[typographical] ~40-~40: The word “however” is an adverb that can’t be used like a conjunction, and therefore needs to be separated from the sentence.
Context: ...native ARM support to their applications, however it comes with significant performance t...

(HOWEVER_SENTENCE)


[uncategorized] ~40-~40: The hyphen in natively-compiled is redundant.
Context: ... to install the version of Wave that is natively-compiled for your computer. You can find the rig...

(ADVERB_LY_HYPHEN_FIX)

emain/platform.ts (1)

44-63: Consider enhancing the architecture warning implementation

The implementation is functional but could be improved for maintainability.

Consider these improvements:

+const ARCH_WARNING_DIALOG_OPTIONS = {
+    type: "warning",
+    buttons: ["See documentation", "Dismiss"],
+    title: "Wave has detected a performance issue",
+};
+
+const ARCH_WARNING_DOCS_URL = "https://docs.waveterm.dev";
+
 export function checkIfRunningUnderARM64Translation(fullConfig: FullConfigType) {
     if (!fullConfig.settings["app:dismissarchitecturewarning"] && app.runningUnderARM64Translation) {
         console.log("Running under ARM64 translation, alerting user");
-        const dialogOpts: Electron.MessageBoxOptions = {
-            type: "warning",
-            buttons: ["See documentation", "Dismiss"],
-            title: "Wave has detected a performance issue",
-            message: `Wave has detected that it is running in ARM64 translation mode.\n\nThis may cause performance issues.\n\nPlease download the native version of Wave for your architecture (${unameArch})`,
-        };
+        const dialogOpts: Electron.MessageBoxOptions = {
+            ...ARCH_WARNING_DIALOG_OPTIONS,
+            message: `Wave has detected that it is running in ARM64 translation mode.\n\nThis may cause performance issues.\n\nPlease download the native version of Wave for your architecture (${unameArch})`,
+        };

         const choice = dialog.showMessageBoxSync(null, dialogOpts);
         if (choice === 0) {
             // Open the documentation URL
             console.log("Opening documentation URL");
-            fireAndForget(() => shell.openExternal("https://docs.waveterm.dev"));
+            fireAndForget(() => shell.openExternal(ARCH_WARNING_DOCS_URL));
         } else {
             console.log("User dismissed the dialog");
         }
     }
 }
emain/emain.ts (2)

622-629: LGTM! Consider adding error handling for package.json reading.

The version flag implementation follows standard CLI patterns. However, consider adding try-catch for the require statement to handle potential file reading errors gracefully.

 const args = process.argv;
 if (args?.length > 1 && (args.includes("--version") || args.includes("-v"))) {
+    try {
         const pkg = require("../package.json");
         console.log(`Wave Terminal v${pkg.version}`);
+    } catch (e) {
+        console.error("Error reading version information:", e);
+    }
     electronApp.quit();
 }

592-592: Consider adding error handling for architecture check.

While the placement is correct, consider wrapping the architecture check in a try-catch to ensure any failures don't prevent the application from starting.

-    checkIfRunningUnderARM64Translation(fullConfig);
+    try {
+        checkIfRunningUnderARM64Translation(fullConfig);
+    } catch (e) {
+        console.error("Error checking architecture:", e);
+    }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 370c53d and d843a3c.

📒 Files selected for processing (9)
  • Taskfile.yml (1 hunks)
  • docs/docs/config.mdx (1 hunks)
  • docs/docs/faq.mdx (1 hunks)
  • docs/docs/gettingstarted.mdx (1 hunks)
  • emain/emain.ts (3 hunks)
  • emain/platform.ts (2 hunks)
  • frontend/types/gotypes.d.ts (1 hunks)
  • pkg/wconfig/metaconsts.go (1 hunks)
  • pkg/wconfig/settingsconfig.go (1 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/docs/faq.mdx

[style] ~36-~36: This phrase is redundant. Consider using “outside”.
Context: ...d by Wave to work and will not function outside of the app. ## Why does Wave warn me abou...

(OUTSIDE_OF)


[typographical] ~40-~40: The word “however” is an adverb that can’t be used like a conjunction, and therefore needs to be separated from the sentence.
Context: ...native ARM support to their applications, however it comes with significant performance t...

(HOWEVER_SENTENCE)


[uncategorized] ~40-~40: The hyphen in natively-compiled is redundant.
Context: ... to install the version of Wave that is natively-compiled for your computer. You can find the rig...

(ADVERB_LY_HYPHEN_FIX)

🔇 Additional comments (8)
pkg/wconfig/metaconsts.go (1)

11-11: LGTM! The new config key follows conventions

The new configuration key follows the established naming pattern and is correctly placed in the App-related configuration section.

docs/docs/gettingstarted.mdx (1)

17-45: LGTM! Well-structured platform requirements section

The new platform requirements section is well-organized and provides clear information about supported architectures and OS versions for each platform.

Let's verify the cross-references and issue link:

✅ Verification successful

Issue #928 link and ARM64 support information is accurate

The documentation correctly reflects the current state of Windows ARM64 support:

  • Issue Windows ARM support #928 exists and is correctly referenced
  • The issue is open and actively tracked
  • The blocker is accurately described (waiting for upstream dependencies)
  • Linux and macOS ARM64 support is already available, as confirmed by build configurations and README
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the Windows ARM support issue link and related documentation

# Check if the Windows ARM support issue exists and is referenced correctly
gh issue view 928

# Check for any other related issues or PRs
gh search issues "ARM64 support" --repo wavetermdev/waveterm --state all

Length of output: 3265


Script:

#!/bin/bash
# Let's verify Windows ARM support related information with correct flags

# Check for open issues related to ARM64 support
gh search issues "ARM64 support in:title,body repo:wavetermdev/waveterm state:open"

# Check for closed issues related to ARM64 support
gh search issues "ARM64 support in:title,body repo:wavetermdev/waveterm state:closed"

# Let's also check the codebase for any ARM64-related build configurations or discussions
rg -i "arm64|aarch64" --type md --type mdx -C 2

Length of output: 5573


Script:

#!/bin/bash
# Let's try a different approach to verify ARM-related content

# Check for ARM-related content in markdown files
rg -i "arm64|aarch64" -t md -C 2

# Check the specific issue #928 mentioned in the docs
gh issue view 928 --json title,state,body,comments

# Look for any build or platform configuration files that might contain ARM-related settings
rg -i "arm64|aarch64" -g "*.{json,yaml,yml,toml}" -C 2

Length of output: 4815

emain/platform.ts (1)

4-5: LGTM: Clean import additions

The new imports are properly organized and necessary for the dialog and shell functionality.

Taskfile.yml (1)

99-99: LGTM: Clean addition of CLI args support

The addition of {{.CLI_ARGS}} properly enables passing version flag and other arguments to electron-builder.

pkg/wconfig/settingsconfig.go (2)

36-37: LGTM: Improved field alignment

The realignment of existing fields enhances code readability while maintaining functionality.


38-38: LGTM: Well-structured settings addition

The new AppDismissArchitectureWarning field follows the established patterns and properly implements the architecture warning dismissal functionality.

docs/docs/config.mdx (1)

29-29: LGTM! Documentation is clear and well-structured.

The new configuration key is well-documented, follows the existing format, and includes helpful references to additional information.

frontend/types/gotypes.d.ts (1)

621-621: LGTM! Type definition is correct and consistent.

The new property is properly typed as an optional boolean and follows the existing pattern in the SettingsType interface.

@esimkowitz esimkowitz closed this Dec 18, 2024
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.

1 participant