Skip to content

fix(app): make per-instance launch hooks clearable #3757

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

Merged
merged 2 commits into from
Jun 13, 2025

Conversation

AlexTMjugador
Copy link
Member

@AlexTMjugador AlexTMjugador commented Jun 8, 2025

This PR fixes the cleanup of per-instance launch hook overrides by bundling together several related, though technically distinct, smaller fixes:

  • The HookSettings frontend page previously couldn't clear per-instance launch hooks because it failed to instruct the backend to clear the stored hook strings when no hooks were explicitly overridden. The frontend now correctly instructs the backend to clear the hooks in such cases.
  • The backend incorrectly treated a Some("") launch hook as valid for launching Minecraft, even though it clearly isn't. It now correctly interprets Some(""), which may be read from the app state database for instances affected by issue I/O error: program path has no file name #3730, as equivalent to None.
  • During (de)serialization of launch hook structs to the frontend, the backend also mishandled Some(""), treating it as distinct from None. This led to the storage of empty instance hook strings in the database, which triggered the issue described above.

I chose not to modify the app database schema to enforce a non-empty hook command string constraint in the profiles table because SQLite's ALTER TABLE does not support adding constraints to existing columns, and implementing such a change would require an overly complex migration for an issue that can be much simply resolved in the application layer. That said, I would definitely add such a constraint in a new schema design.

Additionally, I removed the wrap_ref_builder macro, which was only used in two places, made the code that used it harder to read, and didn't result in a reduction in lines of code.

As a result of these changes, removing per-instance launch hooks now works reliably and intuitively in the test scenario described in this issue comment.

@AlexTMjugador AlexTMjugador added bug Something isn't working app Relates to Modrinth App labels Jun 8, 2025
@AlexTMjugador AlexTMjugador linked an issue Jun 8, 2025 that may be closed by this pull request
3 tasks
@AlexTMjugador AlexTMjugador requested a review from Copilot June 8, 2025 13:16
Copy link
Contributor

@Copilot 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 resolves issues with per-instance launch hook cleanup by ensuring that empty hook strings are treated as cleared hooks in both the frontend and backend, and removes an unused macro to simplify the code.

  • Frontend now instructs the backend to clear hook overrides when not provided.
  • Backend consistently filters out empty strings for hook commands via updated (de)serialization and processing logic.
  • The unused wrap_ref_builder macro has been removed to improve code clarity.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/app-lib/src/util/mod.rs Removed the unused wrap_ref_builder macro.
packages/app-lib/src/state/settings.rs Added serde attributes to ensure empty strings are serialized as None.
packages/app-lib/src/launcher/mod.rs Replaced macro usage with explicit mutable blocks for clarity.
packages/app-lib/src/api/profile/mod.rs Updated hook processing to filter out empty strings for all hook types.
packages/app-lib/Cargo.toml Added serde_with dependency for proper serialization handling.
apps/app-frontend/src/components/ui/instance_settings/HooksSettings.vue Adjusted hook assignment to clear hooks when not overridden.
Comments suppressed due to low confidence (1)

packages/app-lib/src/api/profile/mod.rs:665

  • [nitpick] Consider extracting a helper function to encapsulate retrieving a valid hook command (including filtering empty strings) since the same pattern is repeated for pre_launch, wrapper, and post_exit hooks. This would reduce duplication and improve maintainability.
.or(settings.hooks.pre_launch.as_ref()).filter(|hook_command| !hook_command.is_empty());

@IMB11 IMB11 removed their request for review June 11, 2025 22:25
@AlexTMjugador AlexTMjugador added this pull request to the merge queue Jun 13, 2025
Merged via the queue into main with commit 8a26011 Jun 13, 2025
1 check passed
@AlexTMjugador AlexTMjugador deleted the alex/fix-instance-hooks branch June 13, 2025 21:13
Prospector added a commit that referenced this pull request Jun 14, 2025
* Show up to 15 projects in chart tooltips (#3739)

* fix(frontend): remove fixed height from ManySelect (#2898)

* fix(frontend): remove fixed height from ManySelect

Frontend development is not my passion, there might be a better fix.

I've tested my changes in all places that I found using the chganed components (ManySelect, ScrollablePanel):

- Changelog filters
- Version filters
- Download dialog
- Search filters

Fixes #2334

* Revert incorrect merge

* fix merge conflict

* fix: reset reset-icon state value correctly in edit world modal (#3748)

* Fix random_projects route not returning the requested number of projects (#3758)

* Fix random_projects route not returning the requested number of projects

* fix(labrinth): further improve random project route SQL query

* chore: fix typo in comment

* tweak(labrinth): more apparent and fast randomness for `random_projects_get`

* tweak(labrinth): even better random projects query

* chore: address formatting review

---------

Co-authored-by: Alejandro González <me@alegon.dev>

* Make get_user_from_headers and check_is_moderator_from_headers take in a bitflag of Scopes rather than a slice of Scopes (#3765)

* Update a bunch of dependencies (#3766)

* Add handling for new loaders, fix max height being applied when scrolling is disabled from #2898 (#3761)

* perf(labrinth/random_projects_get): speed up through spatial queries according to profiling results (#3762)

* fix: hydration issues caused by duplicate components on servers panel (#3753)

* fix: server stats icons

* fix: fix chart jumping

* refactor: iconComponent -> icon

* fix: panel hydration issues

* fix: apply requested changes

* fix: MOD-292 repair button showing during installation (#3734)

* fix: MOD-292 repair button showing during installation

* fix: lint

* Update apps/app-frontend/src/pages/instance/Index.vue

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: IMB11 <hendersoncal117@gmail.com>

* fix: lint issues

---------

Signed-off-by: IMB11 <hendersoncal117@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* feat(labrinth): ignore email case differences in password recovery flow (#3771)

* feat(labrinth): ignore email case differences in password recovery flow

* chore(labrinth): run `sqlx prepare`

* Add segmentation to reports list to fix it (#3772)

* feat(frontend): Organisations are now sorted alphabetically in dashboard and on user pages (#3755)

* feat: Organisations are now sorted alphabetically in dashboard and on user pages

* Use computed ref

---------

Co-authored-by: Prospector <prospectordev@gmail.com>
Co-authored-by: Prospector <6166773+Prospector@users.noreply.github.com>

* fix: undefined instance path by using emitted event instead when opening world folder (#3746)

* fix: undefined instance path by using emitted event instead

* fix: linting

* refactor: Huge pyro servers composable cleanup (#3745)

* refactor: start refactor of pyro servers module-based class

* refactor: finish modules

* refactor: start on type checking + matching api

* refactor: finish pyro servers composable refactor

* refactor: pyro -> modrinth

* fix: import not refactored

* fix: broken power action enums

* fix: remove pyro mentions

* fix: lint

* refactor: fix option pages

* fix: error renames

* remove empty pyro-servers.ts file

---------

Signed-off-by: IMB11 <hendersoncal117@gmail.com>
Co-authored-by: Prospector <prospectordev@gmail.com>

* frontend: Improve file too large error (#3774)

* Improve file too large error

Signed-off-by: IThundxr <me@ithundxr.dev>

* MB -> MiB

Signed-off-by: Prospector <6166773+Prospector@users.noreply.github.com>

---------

Signed-off-by: IThundxr <me@ithundxr.dev>
Signed-off-by: Prospector <6166773+Prospector@users.noreply.github.com>
Co-authored-by: Prospector <6166773+Prospector@users.noreply.github.com>

* enh(ci): optimize Turbo CI check workflow, track Rust and Node toolchain versions in well-known files (#3776)

* enh(ci): optimize Turbo CI check workflow, track Rust and Node toolchain versions in well-known files

* fix(ci): build `sqlx-cli` with `rustls` to fix Postgres TLS failures

* fix(app): make instances with non-UTF8 text file encodings launcheable and importable (#3721)

Previous to these changes, the app always assumed that Minecraft and
other launchers always use UTF-8, which is not necessarily always true.

* fix(app): make per-instance launch hooks clearable (#3757)

* fix(app): make per-instance launch hooks clearable

* chore(apps/app-frontend): fix Prettier lints

* Update Rust and Turbo versions (#3781)

* chore: bump Rust version from 1.86 to 1.87

* chore: update Turbo

* chore(.cargo/config.toml): minor comment tweak

* Small CI flakiness fix and performance tweak (#3780)

* perf(ci): use Turbo to schedule both `lint` and `test` tasks at once

* fix(ci): wait until service containers are initialized for tests

This is achieved by adding a health check to the containers, and
instructing the CI workflow to wait until the containers are healthy.
Not doing this wait risks spurious CI failures due to DB migrations
being applied before the DB even starts.

* chore(turbo): use locally installed schema in new Turbo override file

On the latest versions of Turbo, this ensures that the used schema is
always in sync with what's available in the installed Turbo version,
which is something that has already caused confusion to me before.

* refactor: inherit Clippy lint config and Rust edition from workspace (#3782)

* refactor: inherit Clippy lint config and Rust edition from workspace

This also ensures developers running `clippy lint` locally get the same
lints as during CI, especially when the Rust toolchain version is fixed
through a `rust-toolchain.toml` file.

* chore(clippy.toml): bump MSRV to 1.87

* chore(clippy): enable and fix many stricter lints (#3783)

* chore(clippy): enable and fix many stricter lints

These ensure that the codebase uses more idiomatic, performant, and
concise language constructions.

* chore: make non-Clippy compiler warnings also deny by default

* Fix lint

* Update changelog

---------

Signed-off-by: IMB11 <hendersoncal117@gmail.com>
Signed-off-by: IThundxr <me@ithundxr.dev>
Signed-off-by: Prospector <6166773+Prospector@users.noreply.github.com>
Co-authored-by: Erb3 <49862976+Erb3@users.noreply.github.com>
Co-authored-by: Magnus Jensen <magnushjensen.mail@gmail.com>
Co-authored-by: Emma Alexia <emma@modrinth.com>
Co-authored-by: Alejandro González <me@alegon.dev>
Co-authored-by: Josiah Glosson <soujournme@gmail.com>
Co-authored-by: Alejandro González <7822554+AlexTMjugador@users.noreply.github.com>
Co-authored-by: IMB11 <hendersoncal117@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: worldwidepixel <58098422+worldwidepixel@users.noreply.github.com>
Co-authored-by: IThundxr <me@ithundxr.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app Relates to Modrinth App bug Something isn't working
Development

Successfully merging this pull request may close these issues.

I/O error: program path has no file name
2 participants