Skip to content

fix: keep BetterDiscord cold-start injection and add local pack builds#235

Open
XxUnkn0wnxX wants to merge 1 commit intoGooseMod:mainfrom
XxUnkn0wnxX:PR
Open

fix: keep BetterDiscord cold-start injection and add local pack builds#235
XxUnkn0wnxX wants to merge 1 commit intoGooseMod:mainfrom
XxUnkn0wnxX:PR

Conversation

@XxUnkn0wnxX
Copy link
Copy Markdown

Summary

This is a heavily trimmed-down follow-up to the earlier closed PR:

#233

The main goal is to fix one specific regression:

with BetterDiscord installed, OpenAsar could be missing on a normal cold launch of Discord, but then appear correctly after a soft refresh with Cmd+R / Ctrl+R.

So the real bug here is a cold-boot injection failure, not a generic "BetterDiscord support" issue.

This version intentionally keeps only the minimum changes needed to:

  • make the OpenAsar settings entry appear on normal launch, not only after a soft refresh
  • make that fix practical to test locally without the packed build immediately overwriting itself

What This PR Fixes

src/mainWindow.js

This is the actual runtime fix.

Upstream currently ties the sidebar-item injection too closely to the footer/version injection path. On cold boot, if the footer lookup misses or arrives late, the OpenAsar sidebar item can be skipped entirely. After a soft refresh, the settings DOM is more stable, so the same install can suddenly work.

This PR keeps the logic DOM-only and close to upstream, but changes the critical behavior:

  • version/footer injection is attempted independently
  • sidebar-item injection no longer depends on the footer lookup succeeding first
  • the sidebar item prefers the App Settings section when present
  • the older Advanced fallbacks are still kept
  • the item is still created by cloning a native Discord settings node

The intended outcome is simple:

  • cold launch and soft refresh should behave the same way
  • OpenAsar should show on the initial launch path instead of only after Cmd+R / Ctrl+R

Why The Build Files Are Included

The extra build changes are not unrelated cleanup.

While testing this bug, local packed builds could replace themselves with the upstream nightly release on launch. That made it hard to tell whether a cold-boot fix really worked, because the running code could stop matching the packed code almost immediately.

Because of that, this PR keeps the minimum build-time support needed for reliable local verification:

src/index.js and src/asarUpdate.js

  • allow a packed build to disable self-update
  • allow a packed build to target a different update repo when explicitly requested
  • keep the normal fallback to GooseMod/OpenAsar when nothing is stamped

scripts/pack.js

  • adds a local pack path that stamps a temporary build tree instead of editing tracked files in place
  • supports --disable-autoupdate
  • supports --update-repo owner/repo
  • supports --version and --output

These arguments are additive:

  • they do not replace the normal upstream build path
  • they do not require existing workflows to change behavior
  • they are opt-in knobs for local and fork-friendly testing

Docs In This PR

docs/build.md

Included so the local pack flow is documented and reproducible.

README.md

Only lightly updated to point to the local build docs.

.gitignore

Adds local-only ignores for:

  • tmp/
  • AGENTS.md
  • .venv/

What Was Intentionally Left Out

To keep this version reviewable, it does not include:

  • workflow changes
  • changelog / worklog files in the PR
  • the goose icon change
  • broader observer-heavy or layout-patching sidebar rewrites

Files Changed

  • .gitignore
  • README.md
  • docs/build.md
  • scripts/pack.js
  • src/asarUpdate.js
  • src/index.js
  • src/mainWindow.js

Fixes
- keep the OpenAsar settings entry injection working on BetterDiscord cold start without depending on footer injection
- prefer the `App Settings` section when it is available while staying close to upstream's DOM-only settings hook

Build
- add `scripts/pack.js` for local `app.asar` builds without editing the working tree in place
- support `--disable-autoupdate` and `--update-repo owner/repo` build stamping via `src/index.js` and `src/asarUpdate.js`
- ignore `tmp/`, `AGENTS.md`, and `.venv/` in `.gitignore`

Docs
- document local build usage in `docs/build.md`
- update `README.md` with local build references while keeping upstream workflow references

Verification
- `node -c src/mainWindow.js`
- `node -c src/index.js`
- `node -c src/asarUpdate.js`
- `node -c scripts/pack.js`
- `node scripts/pack.js --disable-autoupdate --version nightly-$(git rev-parse --short HEAD)-localtest --output tmp/app.asar`
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