Skip to content

Conversation

@benceruleanlu
Copy link
Member

@benceruleanlu benceruleanlu commented Dec 30, 2025

Enable Windows AMD GPU support in hardware validation and installs.

What changed

  • Detect AMD GPUs on Windows via vendor IDs and WMI fallbacks, updating the Windows validation error message and GPU type plumbing.
  • Install AMD ROCm SDK and PyTorch wheels when selectedDevice is amd, with new compiled requirements and override assets.
  • Update README download label and compiled requirements guidance to reflect NVIDIA/AMD support.

Why

  • Windows users with AMD GPUs were blocked by NVIDIA-only validation and install flows.
  • Using vendor IDs + WMI provides a more reliable vendor detection path than string matching alone; explicit ROCm wheel URLs avoid pulling CUDA/CPU builds.
  • Tradeoffs: AMD support is Windows-only and depends on Radeon-hosted ROCm packages; detection may still miss unusual device identifiers.

@coderabbitai
Copy link

coderabbitai bot commented Dec 30, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

This change introduces AMD ROCm support for Windows systems. It adds GPU detection logic for AMD hardware, new AMD-specific package dependencies and overrides, type definitions to support AMD as a GPU option, and installation workflows for AMD ROCm SDK and PyTorch wheels. Documentation is updated to reference compiled requirements headers.

Changes

Cohort / File(s) Summary
Documentation & Configuration
README.md, assets/override_amd.txt
README simplified to reference compiled requirements headers instead of detailed commands. New AMD override file maps torch packages to AMD ROCm repository URLs for Windows.
AMD ROCm Dependencies
assets/requirements/amd_requirements.txt, assets/requirements/windows_amd.compiled
New AMD requirements file adds ROCm SDK packages (rocm-sdk-core, rocm-sdk-devel, rocm-sdk-libraries-custom, rocm) with Windows wheel/tarball URLs. Compiled requirements file lists all transitive dependencies with AMD ROCm wheels for torch, torchaudio, torchvision, and related packages.
Type System & Constants
src/constants.ts, src/preload.ts
New exports in constants: AMD_VENDOR_ID, NVIDIA_VENDOR_ID, AMD_ROCM_SDK_PACKAGES, AMD_TORCH_PACKAGES. GpuType type expanded from 'nvidia' | 'mps' | 'unsupported' to include 'amd'.
GPU Detection & Validation
src/utils.ts
Windows GPU detection significantly extended with WMI-based probes, PNPDeviceID parsing, vendor ID normalization, and multi-path detection (CIM data → vendor ID matching → nvidia-smi fallback). Supports detecting AMD (vendor ID 1002) and NVIDIA GPUs; error messaging updated to reflect AMD Windows support.
Virtual Environment & Installation
src/virtualEnvironment.ts
Device mapping for Windows expanded to support 'cpu' → windows_cpu, 'amd' → windows_amd, and nvidia fallback. New private methods installAmdRocmSdk and installAmdTorch execute AMD-specific pip install commands. Both createEnvironment and installPytorch flows gate AMD installation on device selection and platform checks.
Test Suite
tests/unit/utils.test.ts
Windows GPU tests refactored with explicit node:child_process mocking helpers. AMD GPU path now returns gpu type 'amd' (vendor ID 1002). New test added for unsupported GPU rejection (Intel Iris Xe) with error message validation.
Build Tooling
scripts/downloadFrontend.js
Frontend build invocation replaced with nx-based build in source-branch with NODE_OPTIONS memory increase. Error handling improved to extract and log stdout/stderr from execSync via new logExecErrorOutput helper.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant App as Application
    participant GPU as GPU Detection
    participant Env as Virtual Environment
    participant Install as Installation

    User->>App: Initialize environment / setup
    App->>GPU: validateHardware()
    
    rect rgb(220, 240, 255)
    Note over GPU: Windows GPU Detection
    GPU->>GPU: Query Windows CIM data
    GPU->>GPU: Parse vendor ID from PNPDeviceID
    alt AMD Detected (1002)
        GPU-->>App: detected: 'amd'
    else NVIDIA Detected (10DE)
        GPU-->>App: detected: 'nvidia'
    else Fallback
        GPU->>GPU: Execute nvidia-smi
        GPU-->>App: detected GPU or error
    end
    end
    
    App->>Env: selectDevice(detected)
    alt Device is 'amd'
        rect rgb(240, 220, 255)
        Note over Env: AMD ROCm Setup
        Env->>Install: installAmdRocmSdk()
        Install->>Install: Build pip install command
        Install->>Install: Execute via uv (AMD SDK packages)
        Install-->>Env: SDK installed
        
        Env->>Install: installAmdTorch()
        Install->>Install: Build pip install command
        Install->>Install: Execute via uv (AMD PyTorch wheels)
        Install-->>Env: PyTorch installed
        end
    else Device is 'nvidia'
        Env->>Install: installPytorch() [standard NVIDIA path]
        Install-->>Env: PyTorch installed
    else Device is 'cpu'
        Env->>Install: installPytorch() [CPU only]
        Install-->>Env: PyTorch installed
    end
    
    Env-->>App: Environment ready
    App-->>User: Setup complete
Loading
✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5b957d9 and ad5940c.

📒 Files selected for processing (2)
  • README.md
  • tests/unit/utils.test.ts
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{ts,mts,cts}

📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)

**/*.{ts,mts,cts}: Use features available in TypeScript 5.x
Use ESM only (type: module). Avoid CommonJS (require, module.exports)
Target ESNext runtime APIs and syntax. Prefer top-level await only when it improves clarity
Code must compile with strict mode and noImplicitAny enabled, with zero implicit any
Use unknown instead of any. Narrow with type guards. any is allowed only when interfacing with untyped code and must be localized and justified
Use interface for public object shapes intended for extension/implementation
Use type for unions, mapped/conditional types, function types, and when composition is needed
Model domain variants with a discriminant field (e.g., kind: 'X' | 'Y'). Use exhaustive switch statements
Prefer as const objects and string/number literal unions over enum
Prefer readonly properties and ReadonlyArray<T> where appropriate. Do not mutate function parameters
Prefer T[] over Array<T> for readability
Prefer Record<Key, T> for simple maps; use Map/Set when iteration semantics or key types require it
Avoid non-null assertions (!). Use optional chaining, nullish coalescing, and explicit guards
Use satisfies to enforce object literal conformance without widening values
Prefer named exports. Default exports are allowed only when a module clearly has a single primary export
Use import type { X } from '…' for type-only imports. Keep value and type imports separated when helpful for clarity and bundling
Exported functions, classes, and public APIs must have explicit parameter and return types. Internal locals can rely on inference
Prefer arrow functions for local functions and callbacks. Use function declarations when hoisting or this binding is required
Modules should be pure. Avoid executing logic at import time unless necessary (e.g., polyfills)
Prefer async/await over raw then/catch chains. Keep linear flow and use try/catch for failures
Either await promises or deliberately mark them...

Files:

  • tests/unit/utils.test.ts
tests/**/*.{ts,mts,cts}

📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)

Test code may relax some strictness to maximize ergonomics. Keep type escapes localized

Files:

  • tests/unit/utils.test.ts
tests/unit/**/*.test.{js,ts}

📄 CodeRabbit inference engine (.cursor/rules/vitest.mdc)

tests/unit/**/*.test.{js,ts}: Use vitest for unit testing
Do not build custom testing infrastructure; use Vitest and existing helpers
Store tests in the tests/unit/ directory with directory structure matching that of the tested file in src/
Tests should be cross-platform compatible; ensure proper use of path.normalize, path.join, and path.sep for Windows, macOS, and Linux compatibility
Mocks should be cleanly written, easy to understand, and reusable where possible
Prefer the use of test.extend over loose variables in Vitest tests
Use test instead of it for defining tests

Files:

  • tests/unit/utils.test.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: TypeScript: Do not use the any type; use unknown when the type is genuinely unknown
Use JSDoc format for method documentation with common tags @param and @return (omit @return for void return type); use {@link } to reference symbols

Files:

  • tests/unit/utils.test.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use ESLint and Prettier for code formatting; run yarn lint and yarn format before committing

Files:

  • tests/unit/utils.test.ts
tests/unit/**/*.{test,spec}.ts

📄 CodeRabbit inference engine (AGENTS.md)

Use Vitest for creating unit tests; do not attempt to create custom testing infrastructure

Files:

  • tests/unit/utils.test.ts
🧠 Learnings (14)
📚 Learning: 2025-11-25T20:49:40.925Z
Learnt from: CR
Repo: Comfy-Org/desktop PR: 0
File: .cursor/rules/integration-testing.mdc:0-0
Timestamp: 2025-11-25T20:49:40.925Z
Learning: Applies to tests/integration/**/*.spec.ts : Mock native dialogs when needed using app.app.evaluate() with electron.dialog overrides

Applied to files:

  • tests/unit/utils.test.ts
📚 Learning: 2025-11-25T20:49:40.925Z
Learnt from: CR
Repo: Comfy-Org/desktop PR: 0
File: .cursor/rules/integration-testing.mdc:0-0
Timestamp: 2025-11-25T20:49:40.925Z
Learning: Applies to tests/integration/**/*.spec.ts : Use Playwright + TypeScript for Electron testing in integration tests

Applied to files:

  • tests/unit/utils.test.ts
📚 Learning: 2025-11-25T20:50:25.371Z
Learnt from: CR
Repo: Comfy-Org/desktop PR: 0
File: .cursor/rules/vitest.mdc:0-0
Timestamp: 2025-11-25T20:50:25.371Z
Learning: Applies to tests/unit/**/*.test.{js,ts} : Tests should be cross-platform compatible; ensure proper use of `path.normalize`, `path.join`, and `path.sep` for Windows, macOS, and Linux compatibility

Applied to files:

  • tests/unit/utils.test.ts
📚 Learning: 2025-12-18T19:46:11.878Z
Learnt from: CR
Repo: Comfy-Org/desktop PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-18T19:46:11.878Z
Learning: Applies to tests/integration/**/*.{test,spec}.ts : Use Playwright for E2E testing; configure tests in `tests/integration/` with subdirectories for `install/`, `post-install/`, and `shared/`

Applied to files:

  • tests/unit/utils.test.ts
📚 Learning: 2025-11-25T20:49:50.649Z
Learnt from: CR
Repo: Comfy-Org/desktop PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-25T20:49:50.649Z
Learning: Applies to tests/integration/**/*.{ts,js} : Use `path.join()` and `path.sep` to ensure file path handling works consistently across Windows, macOS, and Linux platforms

Applied to files:

  • tests/unit/utils.test.ts
📚 Learning: 2025-11-25T20:49:40.925Z
Learnt from: CR
Repo: Comfy-Org/desktop PR: 0
File: .cursor/rules/integration-testing.mdc:0-0
Timestamp: 2025-11-25T20:49:40.925Z
Learning: Applies to tests/integration/**/*.spec.ts : Leverage TestEnvironment for state manipulation and error simulation instead of manual setup

Applied to files:

  • tests/unit/utils.test.ts
📚 Learning: 2025-11-25T20:49:40.925Z
Learnt from: CR
Repo: Comfy-Org/desktop PR: 0
File: .cursor/rules/integration-testing.mdc:0-0
Timestamp: 2025-11-25T20:49:40.925Z
Learning: Applies to tests/integration/**/*.spec.ts : Import fixtures from testExtensions.ts, not raw Playwright

Applied to files:

  • tests/unit/utils.test.ts
📚 Learning: 2025-11-25T20:50:25.371Z
Learnt from: CR
Repo: Comfy-Org/desktop PR: 0
File: .cursor/rules/vitest.mdc:0-0
Timestamp: 2025-11-25T20:50:25.371Z
Learning: Applies to tests/unit/**/*.test.{js,ts} : Mocks should be cleanly written, easy to understand, and reusable where possible

Applied to files:

  • tests/unit/utils.test.ts
📚 Learning: 2025-11-25T20:49:40.925Z
Learnt from: CR
Repo: Comfy-Org/desktop PR: 0
File: .cursor/rules/integration-testing.mdc:0-0
Timestamp: 2025-11-25T20:49:40.925Z
Learning: Applies to tests/integration/**/*.spec.ts : Check CI behavior with process.env.CI in integration tests

Applied to files:

  • tests/unit/utils.test.ts
📚 Learning: 2025-11-25T20:49:50.649Z
Learnt from: CR
Repo: Comfy-Org/desktop PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-25T20:49:50.649Z
Learning: Applies to tests/integration/**/*.spec.ts : Prefer imports from `testExtensions.ts` over Playwright defaults in spec files

Applied to files:

  • tests/unit/utils.test.ts
📚 Learning: 2025-11-25T20:50:25.371Z
Learnt from: CR
Repo: Comfy-Org/desktop PR: 0
File: .cursor/rules/vitest.mdc:0-0
Timestamp: 2025-11-25T20:50:25.371Z
Learning: Applies to tests/unit/**/*.test.{js,ts} : Use `vitest` for unit testing

Applied to files:

  • tests/unit/utils.test.ts
📚 Learning: 2025-11-25T20:50:25.371Z
Learnt from: CR
Repo: Comfy-Org/desktop PR: 0
File: .cursor/rules/vitest.mdc:0-0
Timestamp: 2025-11-25T20:50:25.371Z
Learning: Applies to tests/unit/**/*.test.{js,ts} : Do not build custom testing infrastructure; use Vitest and existing helpers

Applied to files:

  • tests/unit/utils.test.ts
📚 Learning: 2025-12-18T19:46:11.878Z
Learnt from: CR
Repo: Comfy-Org/desktop PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-18T19:46:11.878Z
Learning: Applies to tests/unit/**/*.{test,spec}.ts : Use Vitest for creating unit tests; do not attempt to create custom testing infrastructure

Applied to files:

  • tests/unit/utils.test.ts
📚 Learning: 2025-11-25T20:49:50.649Z
Learnt from: CR
Repo: Comfy-Org/desktop PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-25T20:49:50.649Z
Learning: Tests should be cross-platform compatible and work on Windows, macOS, and Linux

Applied to files:

  • tests/unit/utils.test.ts
🧬 Code graph analysis (1)
tests/unit/utils.test.ts (1)
src/utils.ts (1)
  • validateHardware (240-295)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: build-and-test-e2e-windows / integration-windows-test
  • GitHub Check: lint-and-format (windows-latest)
  • GitHub Check: build-apple-debug-all / build-macos-debug
  • GitHub Check: lint-and-format (macos-latest)
🔇 Additional comments (4)
tests/unit/utils.test.ts (3)

1-42: Excellent test infrastructure improvements!

The refactored mocking approach is much cleaner and more maintainable:

  • Explicit vi.mock('node:child_process') is more readable than inline mocking
  • withExecResponses helper provides flexible pattern-based command mocking
  • createChildProcess helper centralizes mock creation
  • beforeEach/afterEach hooks properly reset mocks and clean up global stubs

The type assertions on lines 20 and 33 are acceptable for test code per the coding guidelines, which explicitly allow relaxed strictness in tests.


74-82: LGTM! AMD GPU test correctly updated.

The test now properly validates AMD GPU detection with vendor ID '1002' (AMD's PCI vendor ID) and expects gpu: 'amd' in the result. This aligns with the PR's goal of adding vendor-ID based AMD detection.


84-100: Excellent test coverage for unsupported GPU scenario!

This test properly validates that Windows systems with unsupported GPUs (Intel in this case) are rejected with an appropriate error message. The mock setup is comprehensive:

  • Intel Iris Xe GPU via systeminformation
  • nvidia-smi failure simulation
  • WMI query returning Intel vendor ID VEN_8086 (correct for Intel)
  • Error message validation for "NVIDIA or AMD"

This ensures users get clear feedback when their GPU is not supported.

README.md (1)

192-192: Excellent documentation improvement!

Moving the source of truth to the header comments in the .compiled files themselves is a smart maintainability improvement. This prevents documentation drift and addresses the past review comments about missing flags (--python-platform, --python-version) by ensuring developers look at the actual commands used to generate those files.

This change aligns well with the PR's goal of updating compiled requirements guidance for both NVIDIA and AMD support.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

@benceruleanlu benceruleanlu marked this pull request as ready for review December 30, 2025 02:11
@benceruleanlu benceruleanlu requested review from a team as code owners December 30, 2025 02:11
Copilot AI review requested due to automatic review settings December 30, 2025 02:11
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. enhancement New feature or request labels Dec 30, 2025
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: 2

📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bb0f3e6 and 6b6b95e.

📒 Files selected for processing (9)
  • README.md
  • assets/override_amd.txt
  • assets/requirements/amd_requirements.txt
  • assets/requirements/windows_amd.compiled
  • src/constants.ts
  • src/preload.ts
  • src/utils.ts
  • src/virtualEnvironment.ts
  • tests/unit/utils.test.ts
🧰 Additional context used
📓 Path-based instructions (9)
**/*.{ts,mts,cts}

📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)

**/*.{ts,mts,cts}: Use features available in TypeScript 5.x
Use ESM only (type: module). Avoid CommonJS (require, module.exports)
Target ESNext runtime APIs and syntax. Prefer top-level await only when it improves clarity
Code must compile with strict mode and noImplicitAny enabled, with zero implicit any
Use unknown instead of any. Narrow with type guards. any is allowed only when interfacing with untyped code and must be localized and justified
Use interface for public object shapes intended for extension/implementation
Use type for unions, mapped/conditional types, function types, and when composition is needed
Model domain variants with a discriminant field (e.g., kind: 'X' | 'Y'). Use exhaustive switch statements
Prefer as const objects and string/number literal unions over enum
Prefer readonly properties and ReadonlyArray<T> where appropriate. Do not mutate function parameters
Prefer T[] over Array<T> for readability
Prefer Record<Key, T> for simple maps; use Map/Set when iteration semantics or key types require it
Avoid non-null assertions (!). Use optional chaining, nullish coalescing, and explicit guards
Use satisfies to enforce object literal conformance without widening values
Prefer named exports. Default exports are allowed only when a module clearly has a single primary export
Use import type { X } from '…' for type-only imports. Keep value and type imports separated when helpful for clarity and bundling
Exported functions, classes, and public APIs must have explicit parameter and return types. Internal locals can rely on inference
Prefer arrow functions for local functions and callbacks. Use function declarations when hoisting or this binding is required
Modules should be pure. Avoid executing logic at import time unless necessary (e.g., polyfills)
Prefer async/await over raw then/catch chains. Keep linear flow and use try/catch for failures
Either await promises or deliberately mark them...

Files:

  • src/preload.ts
  • src/constants.ts
  • tests/unit/utils.test.ts
  • src/virtualEnvironment.ts
  • src/utils.ts
src/**/*.{ts,mts,cts}

📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)

Centralize reusable domain types in src/** where discoverable. Avoid ad-hoc inline types for shared structures

Files:

  • src/preload.ts
  • src/constants.ts
  • src/virtualEnvironment.ts
  • src/utils.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: TypeScript: Do not use the any type; use unknown when the type is genuinely unknown
Use JSDoc format for method documentation with common tags @param and @return (omit @return for void return type); use {@link } to reference symbols

Files:

  • src/preload.ts
  • src/constants.ts
  • tests/unit/utils.test.ts
  • src/virtualEnvironment.ts
  • src/utils.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use ESLint and Prettier for code formatting; run yarn lint and yarn format before committing

Files:

  • src/preload.ts
  • src/constants.ts
  • tests/unit/utils.test.ts
  • src/virtualEnvironment.ts
  • src/utils.ts
{src/main.ts,src/preload.ts,src/main-process/**/*.ts}

📄 CodeRabbit inference engine (AGENTS.md)

Main process code must maintain clean separation between main process, renderer, and preload scripts; follow Electron security best practices

Files:

  • src/preload.ts
src/preload.ts

📄 CodeRabbit inference engine (AGENTS.md)

For preload script at src/preload.ts, implement secure IPC bridge between main and renderer processes without exposing sensitive APIs

Files:

  • src/preload.ts
tests/**/*.{ts,mts,cts}

📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)

Test code may relax some strictness to maximize ergonomics. Keep type escapes localized

Files:

  • tests/unit/utils.test.ts
tests/unit/**/*.test.{js,ts}

📄 CodeRabbit inference engine (.cursor/rules/vitest.mdc)

tests/unit/**/*.test.{js,ts}: Use vitest for unit testing
Do not build custom testing infrastructure; use Vitest and existing helpers
Store tests in the tests/unit/ directory with directory structure matching that of the tested file in src/
Tests should be cross-platform compatible; ensure proper use of path.normalize, path.join, and path.sep for Windows, macOS, and Linux compatibility
Mocks should be cleanly written, easy to understand, and reusable where possible
Prefer the use of test.extend over loose variables in Vitest tests
Use test instead of it for defining tests

Files:

  • tests/unit/utils.test.ts
tests/unit/**/*.{test,spec}.ts

📄 CodeRabbit inference engine (AGENTS.md)

Use Vitest for creating unit tests; do not attempt to create custom testing infrastructure

Files:

  • tests/unit/utils.test.ts
🧠 Learnings (13)
📚 Learning: 2025-11-25T20:50:25.371Z
Learnt from: CR
Repo: Comfy-Org/desktop PR: 0
File: .cursor/rules/vitest.mdc:0-0
Timestamp: 2025-11-25T20:50:25.371Z
Learning: Applies to tests/unit/**/*.test.{js,ts} : Tests should be cross-platform compatible; ensure proper use of `path.normalize`, `path.join`, and `path.sep` for Windows, macOS, and Linux compatibility

Applied to files:

  • tests/unit/utils.test.ts
📚 Learning: 2025-11-25T20:49:40.925Z
Learnt from: CR
Repo: Comfy-Org/desktop PR: 0
File: .cursor/rules/integration-testing.mdc:0-0
Timestamp: 2025-11-25T20:49:40.925Z
Learning: Applies to tests/integration/**/*.spec.ts : Mock native dialogs when needed using app.app.evaluate() with electron.dialog overrides

Applied to files:

  • tests/unit/utils.test.ts
📚 Learning: 2025-11-25T20:49:50.649Z
Learnt from: CR
Repo: Comfy-Org/desktop PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-25T20:49:50.649Z
Learning: Applies to tests/integration/**/*.{ts,js} : Use `path.join()` and `path.sep` to ensure file path handling works consistently across Windows, macOS, and Linux platforms

Applied to files:

  • tests/unit/utils.test.ts
📚 Learning: 2025-11-25T20:49:40.925Z
Learnt from: CR
Repo: Comfy-Org/desktop PR: 0
File: .cursor/rules/integration-testing.mdc:0-0
Timestamp: 2025-11-25T20:49:40.925Z
Learning: Applies to tests/integration/**/*.spec.ts : Leverage TestEnvironment for state manipulation and error simulation instead of manual setup

Applied to files:

  • tests/unit/utils.test.ts
📚 Learning: 2025-11-25T20:49:40.925Z
Learnt from: CR
Repo: Comfy-Org/desktop PR: 0
File: .cursor/rules/integration-testing.mdc:0-0
Timestamp: 2025-11-25T20:49:40.925Z
Learning: Applies to tests/integration/**/*.spec.ts : Add screenshots for visual regression testing in integration tests

Applied to files:

  • tests/unit/utils.test.ts
📚 Learning: 2025-11-25T20:49:40.925Z
Learnt from: CR
Repo: Comfy-Org/desktop PR: 0
File: .cursor/rules/integration-testing.mdc:0-0
Timestamp: 2025-11-25T20:49:40.925Z
Learning: Applies to tests/integration/**/*.spec.ts : Check CI behavior with process.env.CI in integration tests

Applied to files:

  • tests/unit/utils.test.ts
📚 Learning: 2025-11-25T20:50:25.371Z
Learnt from: CR
Repo: Comfy-Org/desktop PR: 0
File: .cursor/rules/vitest.mdc:0-0
Timestamp: 2025-11-25T20:50:25.371Z
Learning: Applies to tests/unit/**/*.test.{js,ts} : Mocks should be cleanly written, easy to understand, and reusable where possible

Applied to files:

  • tests/unit/utils.test.ts
📚 Learning: 2025-11-25T20:49:40.925Z
Learnt from: CR
Repo: Comfy-Org/desktop PR: 0
File: .cursor/rules/integration-testing.mdc:0-0
Timestamp: 2025-11-25T20:49:40.925Z
Learning: Applies to tests/integration/**/*.spec.ts : Use Playwright + TypeScript for Electron testing in integration tests

Applied to files:

  • tests/unit/utils.test.ts
📚 Learning: 2025-11-25T20:49:40.925Z
Learnt from: CR
Repo: Comfy-Org/desktop PR: 0
File: .cursor/rules/integration-testing.mdc:0-0
Timestamp: 2025-11-25T20:49:40.925Z
Learning: Applies to tests/integration/**/*.spec.ts : Import fixtures from testExtensions.ts, not raw Playwright

Applied to files:

  • tests/unit/utils.test.ts
📚 Learning: 2025-11-25T20:50:25.371Z
Learnt from: CR
Repo: Comfy-Org/desktop PR: 0
File: .cursor/rules/vitest.mdc:0-0
Timestamp: 2025-11-25T20:50:25.371Z
Learning: Applies to tests/unit/**/*.test.{js,ts} : Use `vitest` for unit testing

Applied to files:

  • tests/unit/utils.test.ts
📚 Learning: 2025-11-25T20:50:25.371Z
Learnt from: CR
Repo: Comfy-Org/desktop PR: 0
File: .cursor/rules/vitest.mdc:0-0
Timestamp: 2025-11-25T20:50:25.371Z
Learning: Applies to tests/unit/**/*.test.{js,ts} : Do not build custom testing infrastructure; use Vitest and existing helpers

Applied to files:

  • tests/unit/utils.test.ts
📚 Learning: 2025-12-18T19:46:11.878Z
Learnt from: CR
Repo: Comfy-Org/desktop PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-18T19:46:11.878Z
Learning: Applies to tests/unit/**/*.{test,spec}.ts : Use Vitest for creating unit tests; do not attempt to create custom testing infrastructure

Applied to files:

  • tests/unit/utils.test.ts
📚 Learning: 2025-11-25T20:49:50.649Z
Learnt from: CR
Repo: Comfy-Org/desktop PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-25T20:49:50.649Z
Learning: Tests should be cross-platform compatible and work on Windows, macOS, and Linux

Applied to files:

  • tests/unit/utils.test.ts
🧬 Code graph analysis (4)
src/preload.ts (1)
src/main_types.ts (1)
  • GpuType (8-8)
tests/unit/utils.test.ts (1)
src/utils.ts (1)
  • validateHardware (240-295)
src/virtualEnvironment.ts (1)
src/constants.ts (2)
  • AMD_ROCM_SDK_PACKAGES (191-196)
  • AMD_TORCH_PACKAGES (198-202)
src/utils.ts (2)
src/preload.ts (1)
  • GpuType (21-21)
src/constants.ts (2)
  • NVIDIA_VENDOR_ID (123-123)
  • AMD_VENDOR_ID (122-122)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: build-windows-debug
  • GitHub Check: Agent
  • GitHub Check: build-apple-debug-all / build-macos-debug
  • GitHub Check: build-and-test-e2e-windows / integration-windows-test
  • GitHub Check: lint-and-format (windows-latest)
🔇 Additional comments (24)
src/preload.ts (1)

21-22: LGTM - Type union correctly expanded to include AMD GPU support.

The GpuType union now properly includes 'amd', and TorchDeviceType automatically inherits this addition.

README.md (1)

199-206: LGTM - Documentation correctly updated for AMD ROCm support.

The README now includes the AMD ROCm requirements compilation command with proper inputs (amd_requirements.txt, override_amd.txt) and output (windows_amd.compiled).

src/constants.ts (2)

191-202: AMD package arrays correctly defined.

The AMD_ROCM_SDK_PACKAGES and AMD_TORCH_PACKAGES arrays contain the correct URLs matching the requirements and override files.


122-123: Vendor ID constants correctly defined with case-insensitive comparison.

The PCI vendor IDs are accurate: 1002 for AMD and 10DE for NVIDIA. Vendor ID comparisons in src/utils.ts are properly case-insensitive: the hasPciVendorId() function explicitly normalizes both sides to uppercase before comparison (line 145), and normalizeVendorId() ensures all vendor IDs are normalized to uppercase prior to comparison with the constants (line 151).

tests/unit/utils.test.ts (3)

1-24: Test setup is well-structured and follows Vitest patterns.

The mock setup for node:child_process and systeminformation is clean and reusable. The createChildProcess helper appropriately creates a minimal mock object.


56-64: AMD GPU detection test correctly validates the new AMD path.

The test properly mocks an AMD GPU with vendorId: '1002' and verifies that validateHardware returns { isValid: true, gpu: 'amd' }.


66-94: Unsupported GPU test provides good coverage for rejection path.

The test correctly simulates:

  1. An Intel GPU via systeminformation
  2. Failed nvidia-smi execution
  3. WMI query returning Intel vendor ID (VEN_8086)

The error message assertion (expect.stringContaining('NVIDIA or AMD')) aligns with the updated error messaging in src/utils.ts.

src/virtualEnvironment.ts (3)

10-10: Import correctly adds AMD package constants.


236-238: Compiled requirements selection correctly handles AMD device.

The logic properly returns the appropriate compiled requirements file based on the selected device:

  • 'cpu''windows_cpu'
  • 'amd''windows_amd'
  • default (nvidia) → 'windows_nvidia'

609-613: AMD PyTorch installation path correctly short-circuits the standard flow.

When the device is 'amd', the method properly delegates to the AMD-specific installation methods and returns early, avoiding the standard CUDA/CPU torch installation path.

assets/requirements/windows_amd.compiled (2)

1-4: Auto-generated compiled requirements file is correctly structured.

The file header properly documents the uv pip compile command used for generation, matching the documentation in README.md.


230-243: ROCm and torch packages correctly pinned from AMD's repository.

The compiled file properly includes:

  • ROCm SDK packages from repo.radeon.com
  • torch, torchaudio, torchvision wheels with override annotations pointing to the AMD ROCm wheels

Also applies to: 286-306

assets/requirements/amd_requirements.txt (1)

1-5: AMD ROCm SDK package entries are correctly defined.

The requirements file properly lists the four ROCm SDK packages (rocm-sdk-core, rocm-sdk-devel, rocm-sdk-libraries-custom, and rocm) with consistent versioning (ROCm 7.1.1, version 0.1.dev0). URLs match those referenced in src/constants.ts and integrate properly with the build pipeline documented in README.md.

assets/override_amd.txt (1)

1-4: LGTM - AMD ROCm PyTorch wheel overrides are correctly configured and verified.

All three wheel URLs are accessible and the versions are compatible with ComfyUI requirements. The compiled requirements output confirms torch 2.9.0, torchaudio 2.9.0, and torchvision 0.24.0 from the AMD ROCm repository resolve cleanly with all dependencies (numpy, pillow, etc.) for Python 3.12 on Windows x64.

src/utils.ts (10)

10-13: LGTM!

The imports are correctly structured with type-only imports separated and properly using import type as per the coding guidelines.


131-135: LGTM!

The PowerShell command is well-constructed with appropriate flags (-NoProfile, -NonInteractive), explicit UTF-8 encoding, and JSON output for reliable parsing. The regex patterns and type alias are correctly defined.


137-146: LGTM!

The function correctly extracts and compares PCI vendor IDs with case-insensitive matching and safe optional chaining.


148-152: LGTM!

The normalization function properly handles edge cases and ensures consistent uppercase hex format for vendor ID comparison.


154-167: LGTM!

The function implements a sensible two-tier detection strategy: first attempting reliable vendor ID matching, then falling back to string-based heuristics for edge cases. The fallback keywords cover common AMD identifiers including 'radeon'.


169-175: LGTM!

The function correctly iterates through controllers and returns the first detected supported GPU type, which works well for multi-GPU systems where integrated GPUs (Intel) are skipped.


190-212: LGTM - well-structured WMI detection with robust JSON parsing.

The function correctly handles PowerShell's JSON output variations (single string vs array) with proper type narrowing. The as unknown pattern followed by type guards is the correct approach per coding guidelines.


214-228: LGTM!

Clean helper functions that provide a readable abstraction over the generic hasGpuViaWmi function.


259-282: LGTM - comprehensive multi-path GPU detection.

The cascading detection strategy (systeminformation → WMI NVIDIA → nvidia-smi → WMI AMD) provides thorough coverage with appropriate fallbacks. The prioritization of NVIDIA detection before AMD is reasonable given the ecosystem.


284-287: LGTM!

The error message correctly reflects the expanded GPU support (NVIDIA or AMD on Windows).

Comment on lines +177 to +188
/**
* Detects NVIDIA GPUs on Windows using nvidia-smi.
* @return `true` if nvidia-smi executes successfully.
*/
async function hasNvidiaGpuViaSmi(): Promise<boolean> {
try {
await execAsync('nvidia-smi');
return true;
} catch {
return false;
}
}
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Consider adding a timeout for robustness.

The function works correctly, but unlike canExecuteShellCommand, it doesn't have a timeout. While nvidia-smi typically returns quickly, a hung process could delay GPU detection. Consider using a timeout pattern similar to canExecuteShellCommand above.

🔎 Suggested improvement with timeout
 async function hasNvidiaGpuViaSmi(): Promise<boolean> {
   try {
-    await execAsync('nvidia-smi');
+    await execAsync('nvidia-smi', { timeout: 5000 });
     return true;
   } catch {
     return false;
   }
 }
📝 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
/**
* Detects NVIDIA GPUs on Windows using nvidia-smi.
* @return `true` if nvidia-smi executes successfully.
*/
async function hasNvidiaGpuViaSmi(): Promise<boolean> {
try {
await execAsync('nvidia-smi');
return true;
} catch {
return false;
}
}
/**
* Detects NVIDIA GPUs on Windows using nvidia-smi.
* @return `true` if nvidia-smi executes successfully.
*/
async function hasNvidiaGpuViaSmi(): Promise<boolean> {
try {
await execAsync('nvidia-smi', { timeout: 5000 });
return true;
} catch {
return false;
}
}
🤖 Prompt for AI Agents
In src/utils.ts around lines 177 to 188, hasNvidiaGpuViaSmi currently awaits
execAsync('nvidia-smi') with no timeout; modify it to use the same timeout
pattern as canExecuteShellCommand by racing the execAsync call against a timeout
Promise (e.g., reject after configurable milliseconds), and return false on
timeout or error; ensure the timeout path cleans up/kills the spawned process if
possible and preserves the original boolean return semantics (true only on
successful exec before timeout, false otherwise).

Comment on lines +632 to +670
/**
* Installs AMD ROCm SDK packages on Windows.
* @param callbacks The callbacks to use for the command.
*/
private async installAmdRocmSdk(callbacks?: ProcessCallbacks): Promise<void> {
if (process.platform !== 'win32') {
throw new Error('AMD ROCm packages are currently supported only on Windows.');
}

const installArgs = getPipInstallArgs({
packages: AMD_ROCM_SDK_PACKAGES,
});

log.info('Installing AMD ROCm SDK packages.');
const { exitCode } = await this.runUvCommandAsync(installArgs, callbacks);
if (exitCode !== 0) {
throw new Error(`Failed to install AMD ROCm SDK packages: exit code ${exitCode}`);
}
}

/**
* Installs AMD ROCm PyTorch wheels on Windows.
* @param callbacks The callbacks to use for the command.
*/
private async installAmdTorch(callbacks?: ProcessCallbacks): Promise<void> {
if (process.platform !== 'win32') {
throw new Error('AMD ROCm packages are currently supported only on Windows.');
}

const installArgs = getPipInstallArgs({
packages: AMD_TORCH_PACKAGES,
});

log.info('Installing AMD ROCm PyTorch packages.');
const { exitCode } = await this.runUvCommandAsync(installArgs, callbacks);
if (exitCode !== 0) {
throw new Error(`Failed to install AMD ROCm PyTorch packages: exit code ${exitCode}`);
}
}
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

AMD ROCm installation methods are well-implemented with proper platform guards.

Both installAmdRocmSdk and installAmdTorch:

  1. Validate Windows platform with clear error messages
  2. Use the shared getPipInstallArgs helper
  3. Log installation progress
  4. Throw descriptive errors on failure

Consider adding JSDoc documentation to these private methods for consistency with other methods in the class:

🔎 Suggested documentation

The methods already have minimal JSDoc - this is sufficient for private methods.

🤖 Prompt for AI Agents
In src/virtualEnvironment.ts around lines 632 to 670 the reviewer noted the two
private methods already have minimal JSDoc and no functional changes are
required; if you want consistency with the rest of the class, add fuller JSDoc
for each method by expanding the existing comment to include @param callbacks -
ProcessCallbacks | undefined and @returns Promise<void>, keeping the same brief
description, and ensure wording matches other private method comments in this
file.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds AMD GPU support for Windows, enabling ComfyUI Desktop to run on AMD Radeon GPUs using ROCm. Previously, only NVIDIA GPUs and Apple Silicon were supported on Windows and macOS respectively.

  • Added AMD GPU detection logic using vendor IDs and WMI queries
  • Implemented AMD-specific PyTorch installation using ROCm SDK and custom wheels
  • Updated hardware validation to accept AMD GPUs alongside NVIDIA GPUs on Windows

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/preload.ts Added 'amd' to the GpuType union type
src/constants.ts Added AMD and NVIDIA vendor ID constants, and AMD ROCm package URLs
src/utils.ts Enhanced Windows GPU detection to identify AMD GPUs via vendor IDs and WMI, updated validation logic and error messages
src/virtualEnvironment.ts Added AMD device handling in compiled requirements selection, implemented AMD ROCm SDK and PyTorch installation methods
tests/unit/utils.test.ts Updated tests to verify AMD GPU detection and adjusted unsupported GPU test to reflect new error message
assets/requirements/windows_amd.compiled Added compiled requirements file for AMD ROCm on Windows
assets/requirements/amd_requirements.txt Added AMD ROCm SDK package requirements
assets/override_amd.txt Added AMD-specific PyTorch wheel overrides
README.md Added documentation for generating AMD ROCm requirements

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

import path from 'node:path';

import { InstallStage, TorchMirrorUrl } from './constants';
import { AMD_ROCM_SDK_PACKAGES, AMD_TORCH_PACKAGES, InstallStage, TorchMirrorUrl } from './constants';
Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

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

The fixDeviceMirrorMismatch function at lines 96-102 doesn't handle the 'amd' device type. When an AMD device is selected and the mirror is set to TorchMirrorUrl.Default, the function doesn't remap it to an appropriate mirror. Since AMD installations use custom PyTorch wheels from AMD's ROCm repository, this function should either handle the 'amd' case explicitly or document why it's not needed. Consider adding: else if (device === 'amd') return undefined; or returning TorchMirrorUrl.Default, depending on the expected behavior.

Copilot uses AI. Check for mistakes.
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: 1

📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6b6b95e and 36d3e75.

📒 Files selected for processing (2)
  • README.md
  • package.json
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-12-18T19:46:11.878Z
Learnt from: CR
Repo: Comfy-Org/desktop PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-18T19:46:11.878Z
Learning: Configuration files like `package.json` and `todesktop.json` must be kept in sync with version numbers and build settings

Applied to files:

  • package.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: build-windows-debug
  • GitHub Check: build-and-test-e2e-windows / integration-windows-test
  • GitHub Check: build-apple-debug-all / build-macos-debug
  • GitHub Check: lint-and-format (windows-latest)
🔇 Additional comments (2)
README.md (2)

11-11: Label correctly reflects AMD support scope.

The Windows download label has been updated to accurately reflect the addition of AMD GPU support alongside NVIDIA.


190-192: Header comments in .compiled files contain required platform and version flags.

Both assets/requirements/windows_amd.compiled and assets/requirements/windows_nvidia.compiled include the required --python-platform x86_64-pc-windows-msvc and --python-version 3.12 flags in their header comments, along with all other necessary compilation options.

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: 1

📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 36d3e75 and 49bba09.

📒 Files selected for processing (1)
  • scripts/downloadFrontend.js
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use ESLint and Prettier for code formatting; run yarn lint and yarn format before committing

Files:

  • scripts/downloadFrontend.js
🧬 Code graph analysis (1)
scripts/downloadFrontend.js (2)
scripts/makeComfy.js (1)
  • output (39-39)
scripts/todesktop/beforeInstall.cjs (1)
  • output (38-38)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: build-windows-debug
  • GitHub Check: lint-and-format (macos-latest)
  • GitHub Check: lint-and-format (windows-latest)
  • GitHub Check: build-and-test-e2e-windows / integration-windows-test
  • GitHub Check: build-apple-debug-all / build-macos-debug
🔇 Additional comments (2)
scripts/downloadFrontend.js (2)

47-60: LGTM: Resilient command execution wrapper.

The execAndLog function properly wraps execSync with error handling, logs both success and failure output, and improves debuggability by capturing the failed command context before rethrowing.


62-84: LGTM: Safe extraction of exec error output.

The logExecErrorOutput helper uses appropriate type checking and optional chaining to safely extract and log stdout/stderr from execSync errors. The defensive checks prevent crashes when properties are unavailable.

await fs.rm(frontendDir, { recursive: true });
} catch (error) {
console.error('Error building frontend:', error.message);
console.error('Error building frontend:', error instanceof Error ? error.message : String(error));
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Improved error handling with type-safe check.

The use of error instanceof Error ? error.message : String(error) is a robust pattern that handles both Error objects and other thrown values.

For consistency, consider applying this same pattern to lines 118 and 136, which currently access error.message directly.

Optional: Apply consistent error handling pattern
-    console.error('Error downloading frontend:', error.message);
+    console.error('Error downloading frontend:', error instanceof Error ? error.message : String(error));

And similarly for line 136:

-  console.error('Error copying desktop-ui:', error.message);
+  console.error('Error copying desktop-ui:', error instanceof Error ? error.message : String(error));

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In scripts/downloadFrontend.js around lines 118 and 136, direct access to
error.message is used which can throw if a non-Error is thrown; update both
locations to use the same type-safe pattern used at line 37: replace occurrences
like error.message with error instanceof Error ? error.message : String(error)
(or store that expression in a local variable and reuse it) so the logged/output
error text is safe and consistent.

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: 1

♻️ Duplicate comments (1)
scripts/downloadFrontend.js (1)

41-43: Good type-safe error handling.

The error instanceof Error ? error.message : String(error) pattern correctly handles unknown error types. Based on learnings, this is the recommended approach.

Note: Lines 123 and 141 still use direct error.message access without type narrowing—this was flagged in a previous review.

📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 49bba09 and 5b957d9.

📒 Files selected for processing (1)
  • scripts/downloadFrontend.js
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use ESLint and Prettier for code formatting; run yarn lint and yarn format before committing

Files:

  • scripts/downloadFrontend.js
🧠 Learnings (4)
📚 Learning: 2025-11-25T20:50:17.635Z
Learnt from: CR
Repo: Comfy-Org/desktop PR: 0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-11-25T20:50:17.635Z
Learning: Applies to **/*.{ts,mts,cts} : Treat caught errors as `unknown` and narrow with `instanceof Error` (or custom guards) before access

Applied to files:

  • scripts/downloadFrontend.js
📚 Learning: 2025-11-25T20:50:17.635Z
Learnt from: CR
Repo: Comfy-Org/desktop PR: 0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-11-25T20:50:17.635Z
Learning: Applies to **/*.{ts,mts,cts} : Avoid non-null assertions (`!`). Use optional chaining, nullish coalescing, and explicit guards

Applied to files:

  • scripts/downloadFrontend.js
📚 Learning: 2025-11-25T20:50:17.635Z
Learnt from: CR
Repo: Comfy-Org/desktop PR: 0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-11-25T20:50:17.635Z
Learning: Applies to **/*.{ts,mts,cts} : Throw `Error` (or subclasses) with actionable messages. Avoid throwing strings

Applied to files:

  • scripts/downloadFrontend.js
📚 Learning: 2025-11-25T20:50:17.635Z
Learnt from: CR
Repo: Comfy-Org/desktop PR: 0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2025-11-25T20:50:17.635Z
Learning: Applies to **/*.{ts,mts,cts} : Do not use non-null assertions or `ts-ignore`. Use `ts-expect-error` with an explanation when unavoidable

Applied to files:

  • scripts/downloadFrontend.js
🧬 Code graph analysis (1)
scripts/downloadFrontend.js (2)
scripts/todesktop/beforeInstall.cjs (2)
  • path (2-2)
  • output (38-38)
scripts/makeComfy.js (1)
  • output (39-39)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: build-windows-debug
  • GitHub Check: build-and-test-e2e-windows / integration-windows-test
  • GitHub Check: build-apple-debug-all / build-macos-debug
  • GitHub Check: lint-and-format (windows-latest)
  • GitHub Check: lint-and-format (macos-latest)
🔇 Additional comments (2)
scripts/downloadFrontend.js (2)

32-37: LGTM!

The direct nx build approach with explanatory comment is clear. The 8GB heap allocation via NODE_OPTIONS is reasonable for large frontend builds, and the environment variable handling is correct.


67-89: LGTM!

The helper correctly handles unknown error types with proper guards. The optional chaining on stdout?.toString?.() and stderr?.toString?.() safely extracts output when available, consistent with the pattern in scripts/todesktop/beforeInstall.cjs. Based on learnings, this approach properly avoids non-null assertions.

Comment on lines 52 to +65
function execAndLog(command, cwd, env = {}) {
const output = execSync(command, {
cwd,
encoding: 'utf8',
env: { ...process.env, ...env },
});
console.log(output);
try {
const output = execSync(command, {
cwd,
encoding: 'utf8',
env: { ...process.env, ...env },
});
console.log(output);
} catch (error) {
console.error(`Command failed: ${command}`);
logExecErrorOutput(error);
throw error;
}
}
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Solid error handling with proper logging and rethrow.

The try/catch wrapper correctly captures output on success and delegates to logExecErrorOutput on failure before rethrowing. The encoding: 'utf8' usage is consistent with other scripts.

Minor style note: the function is declared after its first use (lines 30-31). While hoisting makes this valid, consider moving the helper functions before the try block for improved readability.

🤖 Prompt for AI Agents
In scripts/downloadFrontend.js around lines 52 to 65, execAndLog is defined
after it's first invoked (used at lines 30-31); move this helper (and any
related helpers like logExecErrorOutput) above their first use so the function
declaration appears before the try block that calls it, keeping the same
implementation and behavior but improving readability.

@socket-security
Copy link

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn High
Obfuscated code: npm entities is 91.0% likely obfuscated

Confidence: 0.91

Location: Package overview

From: ?npm/entities@4.5.0

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/entities@4.5.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
Obfuscated code: npm entities is 91.0% likely obfuscated

Confidence: 0.91

Location: Package overview

From: ?npm/entities@4.5.0

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/entities@4.5.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

@benceruleanlu benceruleanlu merged commit aa394bd into main Dec 30, 2025
6 of 7 checks passed
@benceruleanlu benceruleanlu deleted the bl-amd-support branch December 30, 2025 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants