Skip to content

Conversation

@hllshiro
Copy link
Collaborator

@hllshiro hllshiro commented Aug 19, 2025

Pull Request Description (中文)

你的功能请求是否与某个问题有关?请描述一下。
请对问题进行清晰扼要的描述。
完善 #752 的nsis脚本,下载vsdist时根据当前架构拼接url,而不总是x64

Summary by CodeRabbit

  • New Features

    • Windows installer now validates system and app architecture, preventing incompatible installs and providing guidance.
    • Automatically checks for the required Microsoft Visual C++ Redistributable; offers to download and install it if missing, then continues setup on success.
    • Clearer user prompts and safer abort behavior when prerequisites aren’t met.
  • Chores

    • Integrated a custom NSIS script into the Windows installer build to support the above installer enhancements.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 19, 2025

Walkthrough

Adds an NSIS script (build/nsis-installer.nsh) implementing architecture compatibility checks and Visual C++ Redistributable detection/installation, and includes it via electron-builder.yml. The script defines checkVCRedist, checkArchitectureCompatibility, and a customInit macro for pre-install validation, download, and installation of VC++ redist when needed, excluding uninstaller builds.

Changes

Cohort / File(s) Summary
NSIS installer logic
build/nsis-installer.nsh
New script with functions: checkVCRedist(arch), checkArchitectureCompatibility; and macro: customInit ($0..$6). Performs system/app arch detection, compatibility gating, VC++ redist presence check, optional download/install via inets::get, and re-check. Skips inclusion for uninstallers. Shows user messages and opens guidance URL on mismatch.
Packaging config
electron-builder.yml
Adds nsis.include: build/nsis-installer.nsh to incorporate the new installer logic during Windows packaging.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User
  participant I as NSIS Installer
  participant R as System Registry
  participant D as Microsoft Download Server
  participant V as VC++ Installer

  U->>I: Start installer
  I->>I: checkArchitectureCompatibility()
  I->>R: Read system arch keys
  R-->>I: System arch (x64/arm64/x86)
  I->>I: Infer app arch (universal/x64/arm64)
  alt Incompatible
    I-->>U: Show incompatibility message and open URL
    I-->>U: Abort
  else Compatible
    I->>I: Determine target redist arch
    alt x86 redist not required
      I-->>U: Continue installation
    else Redist required
      I->>R: checkVCRedist(target)
      R-->>I: Present? (yes/no)
      alt Present
        I-->>U: Continue installation
      else Missing
        I-->>U: Prompt to download and install
        opt User accepts
          I->>D: Download vc_redist.<arch>.exe
          D-->>I: File in TEMP
          I->>V: Run with /install /norestart
          V-->>I: Complete (exit code ignored)
          I->>R: Re-check presence
          R-->>I: Present? (yes/no)
          alt Installed
            I-->>U: Continue installation
          else Failed
            I-->>U: Abort
          end
        end
        opt User declines
          I-->>U: Abort
        end
      end
    end
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • zerob13

Poem

A nibble of logic, a hop through checks,
I sniff the arch, then peek the regs.
If VC’s missing, I fetch with glee—
inets::get, a treat for me!
Ears up, installer, thump-thump—proceed!
The Warren builds, fulfilled indeed. 🐇💾

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch optimize/vsredist-check-nsh

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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: 4

🧹 Nitpick comments (2)
build/nsis-installer.nsh (2)

18-22: Consider checking both x64 and x86 redistributables for x64 architecture

When checking for x64 architecture, the code only checks the x64 runtime registry key. However, x64 applications might also require the x86 redistributable for compatibility with 32-bit components.

Consider checking both redistributables for x64 systems:

 ${If} $1 == "arm64"
   ReadRegDWORD $0 HKLM "SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\arm64" "Installed"
 ${Else}
   ReadRegDWORD $0 HKLM "SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64" "Installed"
+  ; Optionally check x86 runtime for 32-bit components on x64 systems
+  ; ReadRegDWORD $2 HKLM "SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x86" "Installed"
 ${EndIf}

108-111: Add logging for x86 skip scenario

The code silently skips the VC++ redistributable check for x86 systems. Consider adding a log message or comment explaining why x86 is skipped.

 ; Don't check for x86 systems as we don't ship redist for it
 ${If} $2 == "x86"
+  ; DetailPrint "Skipping VC++ Redistributable check for x86 architecture"
   Goto ContinueInstall
 ${EndIf}
📜 Review details

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

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 3d18325 and 5c23c2d.

📒 Files selected for processing (2)
  • build/nsis-installer.nsh (1 hunks)
  • electron-builder.yml (1 hunks)
🔇 Additional comments (2)
build/nsis-installer.nsh (1)

1-159: Well-structured NSIS installer script

The overall implementation is well-organized with clear separation of concerns:

  • Architecture detection logic is comprehensive
  • User-friendly error messages with actionable guidance
  • Proper fallback handling for universal packages
  • Good use of NSIS macros and conditionals
electron-builder.yml (1)

61-61: LGTM! Proper integration of NSIS installer script

The inclusion of the custom NSIS script is correctly placed within the nsis configuration section, which will enhance the Windows installer with architecture checks and VC++ redistributable handling.

@zerob13 zerob13 merged commit 5284000 into dev Aug 19, 2025
2 checks passed
@zerob13 zerob13 mentioned this pull request Aug 26, 2025
@zerob13 zerob13 deleted the optimize/vsredist-check-nsh branch January 6, 2026 12:16
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