Skip to content

refactor: modularize architecture and harden runtime behavior - #4

Merged
ChouChiu merged 16 commits into
mainfrom
opt
Jul 18, 2026
Merged

refactor: modularize architecture and harden runtime behavior#4
ChouChiu merged 16 commits into
mainfrom
opt

Conversation

@ChouChiu

@ChouChiu ChouChiu commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary

Architecture and runtime boundaries

  • split i18n catalogues, lyrics parsing, romanization, search, ranking, provider adapters, and SQLite cache code into focused facade-backed modules
  • separate configuration validation, persistence, and recovery while preserving the existing configuration model
  • replace broad shared controller state with owned state, a narrow runtime configuration, generation-checked async results, and a read-only playback projection
  • move SQLite access and configuration writes behind serialized workers so blocking persistence stays off the GTK update path
  • reject obsolete fetch, cache, preview, apply, save, and romanization completions after the relevant track, query, configuration, or generation changes

Configuration recovery

  • recover incompatible persisted TOML field by field, preserving valid preferences while defaulting only invalid, unknown, or incompatible values
  • back up the original bytes beside the config as .incompatible (with collision-safe numeric suffixes) before rewriting the recovered configuration in the current format
  • retain fatal handling for real filesystem I/O failures and cover malformed TOML, non-UTF-8 input, type changes, invalid ranges, unknown fields, and backup collisions

Frontend behavior

  • separate manual-search session, state, and view responsibilities, and make preview/apply completions generation-aware
  • split settings pages, font selection, About license data, overlay layout, positioning, styling, and the WebKit command bridge into focused modules
  • reuse the font picker window and keep selection logic independent from GTK callbacks
  • drive AMLL with the complete lyrics document so its native line transitions handle playback, hide passed lines, isolate lyric groups, and keep interlude indicators centered
  • remove the inappropriate boxed-list styling from manual-search candidates so the split-pane candidate column and rows remain square

CI and release automation

  • replace the broad Build workflow with a focused CI workflow for pull requests, main pushes, and manual dispatches
  • remove package construction and artifact uploads from ordinary CI while adding documentation validation
  • keep release automation focused on tag validation, optimized binary construction, Linux packaging, and publishing
  • pin packaging tools, emit .deb and .rpm files into an isolated dist directory, and transfer them as one artifact
  • remove obsolete and duplicated workflow steps while keeping release publication idempotent

Why

Several application and domain modules had accumulated unrelated responsibilities. GTK presentation code, asynchronous lyrics work, cache access, persisted configuration, and mutable playback state were coupled closely enough to make changes difficult to test and stale results harder to reject safely.

The workflows also repeated expensive checks and packaging work across branch pushes, pull requests, and releases. This change establishes clearer dependency boundaries, keeps blocking persistence away from the UI thread, preserves usable preferences when configuration formats drift, restores AMLL's intended transition behavior, and gives CI and release workflows distinct responsibilities.

Impact and compatibility

  • improves responsiveness around cache and configuration writes
  • preserves provider order, manual-selection precedence, the SQLite schema, localization catalogues, dependency versions, CLI flags, and packaging metadata
  • preserves the public lower-crate facades while reducing internal coupling
  • keeps strict normal deserialization, but deliberately recovers incompatible configuration files after creating a byte-for-byte backup
  • changes CI triggering so ordinary feature-branch pushes are validated through their pull request instead of a duplicate push workflow
  • keeps release publication idempotent by replacing existing assets when a release already exists

Validation

Latest-head GitHub Actions passed the Frontend and Rust quality job, covering:

  • bun install --frozen-lockfile
  • bun run check
  • bun run typecheck
  • bun test
  • dependency-license freshness
  • cargo fmt --all -- --check
  • cargo clippy --locked --all-targets --all-features -- -D warnings
  • cargo test --locked --all-targets --all-features
  • cargo docs
  • cargo build --locked --release

Additional validation recorded during the change:

  • bun run build:lyrics
  • actionlint .github/workflows/*.yml
  • isolated .deb and .rpm generation with exactly two release assets
  • git diff --check

The final UI was not manually exercised in a real layer-shell Wayland session.

@ChouChiu ChouChiu changed the title refactor: modularize architecture and isolate runtime services refactor: modularize architecture and harden runtime behavior Jul 18, 2026
@ChouChiu
ChouChiu marked this pull request as ready for review July 18, 2026 13:18
@ChouChiu
ChouChiu merged commit 3da42cb into main Jul 18, 2026
1 check passed
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