Skip to content

Conversation

@rprtr258
Copy link

@rprtr258 rprtr258 commented Oct 25, 2025

Description

Fixes enum random ordering in generated typescript sources.

Fixes # (issue)

Type of change

Please select the option that is relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration using wails doctor.

  • Windows
  • macOS
  • Linux
Linux 6.16.12+deb14-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.16.12-1 (2025-10-13) x86_64 GNU/Linux

Test Configuration

$ wails doctor


          Wails Doctor



# Wails
Version         | v2.10.2
Package Manager | apt


# System
WARNING: failed to read int from file: open /sys/devices/system/cpu/cpu0/online: no such file or directory
┌────────────────────────────────────────────────────────────────────────────────┐
| OS           | Debian GNU/Linux                                                |
| Version      | Unknown                                                         |
| ID           | debian                                                          |
| Branding     |                                                                 |
| Go Version   | go1.23.4                                                        |
| Platform     | linux                                                           |
| Architecture | amd64                                                           |
| CPU          | 13th Gen Intel(R) Core(TM) i7-13620H                            |
| GPU          | Raptor Lake-P [UHD Graphics] (Intel Corporation) - Driver: i915 |
| Memory       | 15GB                                                            |
└────────────────────────────────────────────────────────────────────────────────┘

# Dependencies
┌───────────────────────────────────────────────────────────────────┐
| Dependency | Package Name          | Status    | Version          |
| *docker    | docker.io             | Installed | 29.0.0-rc.1      |
| gcc        | build-essential       | Installed | 15.2.0           |
| libgtk-3   | libgtk-3-dev          | Installed | 3.24.51-1        |
| libwebkit  | libwebkit2gtk-4.0-dev | Installed | 2.48.5-1~deb12u1 |
| npm        | npm                   | Available | 9.2.0~ds1-3      |
| *nsis      | nsis                  | Available | 3.11-1           |
| pkg-config | pkg-config            | Installed | 1.8.1-4          |
|                                                                   |
└───────────────────── * - Optional Dependency ─────────────────────┘

# Diagnosis
Required package(s) installation details:
  - npm: sudo apt install npm

Optional package(s) installation details:
  - nsis: sudo apt install nsis

 WARNING  Your system has missing dependencies!

 ♥   If Wails is useful to you or your company, please consider sponsoring the project:
https://github.com/sponsors/leaanthony

Checklist:

  • I have updated website/src/pages/changelog.mdx with details of this PR
  • My code follows the general coding style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Summary by CodeRabbit

  • Bug Fixes

    • Fixed inconsistent ordering of generated enums so outputs are deterministic across runs.
  • Chores

    • Deterministic ordering of package lists in generated artifacts.
    • Reduced allocations by pre-sizing internal collections used during generation.
    • Minor refinements to generation error handling for cleaner output.
  • Documentation

    • Updated changelog noting the enum ordering fix.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 25, 2025

Walkthrough

Deterministic ordering added for enum and package generation by collecting and sorting names; TypeScript emitter sorts enum elements and removes a redundant error check; changelog updated to note fixed enum ordering.

Changes

Cohort / File(s) Summary
Binding: deterministic package & enum ordering
v2/internal/binding/binding.go
Collects enum names and package names into slices, sorts them, iterates in sorted order; initializes package-name slice with capacity hint for deterministic output.
TypeScript emitter: deterministic enum elements & imports
v2/internal/typescriptify/typescriptify.go
Adds cmp and slices imports; collects enum elements then sorts by TypeScript name in AddEnum; removes a redundant error check after writing in ConvertToFile.
Changelog update
website/src/pages/changelog.mdx
Adds "Fixed generated enums ordering" entry under Unreleased.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Generator
    participant Collector
    participant Sorter
    participant Emitter

    Generator->>Collector: collect enum names & package names
    Collector->>Sorter: provide collected lists
    Sorter->>Sorter: sort names deterministically
    Sorter-->>Emitter: return sorted lists
    Emitter->>Emitter: emit enums/packages in sorted order
    Note over Emitter: Deterministic output across runs
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Pay attention to sorting correctness (stable/comparison logic) and handling of empty/nil maps.
  • Verify the removed error check in ConvertToFile does not suppress a real write or fs error.

Poem

🐇 I hopped through keys and ordered them right,
I nudged the enums into tidy light.
No more scramble, no more race—
Now every build finds its place. 🥕

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fix generated enums ordering' directly and clearly summarizes the main change: fixing deterministic ordering of generated enums in TypeScript sources.
Description check ✅ Passed The PR description covers key requirements: identifies the issue (enum random ordering), confirms changelog update, marks Linux testing completed with system details, includes wails doctor output, and completes all checklist items.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bc0a9c7 and 7a29c78.

📒 Files selected for processing (1)
  • website/src/pages/changelog.mdx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • website/src/pages/changelog.mdx

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.

@rprtr258 rprtr258 changed the title enumsort: enumsort Fix generated enums ordering Oct 25, 2025
@leaanthony
Copy link
Member

Thanks 🙏 Please could you add an entry to the changelog located at website/src/pages/changelog.mdx?

@rprtr258
Copy link
Author

rprtr258 commented Nov 1, 2025

done

@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 3, 2025

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.

2 participants