Skip to content

refactor: split lib.rs Tauri commands into commands modules - #295

Merged
pountzas merged 4 commits into
devfrom
refactor/split-lib-commands-242
Oct 18, 2026
Merged

pountzas merged 4 commits into
devfrom
refactor/split-lib-commands-242

Conversation

@pountzas

Copy link
Copy Markdown
Owner

Summary

  • Move ~75 #[tauri::command] handlers from src-tauri/src/lib.rs into src-tauri/src/commands/<area>.rs (keyboard, mouse, window, profiles, files, teaching_pdf, library, dictation, system, prediction, input_preview).
  • Move window layout/animation helpers to window/layout.rs; keep lib.rs as mods, AppState, run(), and generate_handler! (~171 lines).
  • Shared pick_file replaces the four near-identical pickers; CommandResult / ok / err live in commands/mod.rs; typed TeachingPdfEntry for list/save (on-disk JSON unchanged). Command fn names and invoke strings unchanged.

Commit message

refactor: split lib.rs Tauri commands into commands modules

Related issue

Fixes #242
Part of #244

Accessibility impact

N/A — backend module split only; no user-facing behavior change.

Test plan

  • cargo check --locked (src-tauri)
  • cargo test --locked (152 passed)
  • npm test (559 passed)
  • Sorted generate_handler! cmd list matches pre-split baseline (68 commands)
  • Smoke: typing, trackpad, Focus mode animation, profile switch, background/music/PDF pickers, Teaching PDF open/save/export, dictation

Screenshots (if UI changed)

N/A

Made with Cursor

dependabot Bot and others added 2 commits October 15, 2026 23:39
…with 5 updates

Bumps the cargo-minor-and-patch group with 5 updates in the /src-tauri directory:

| Package | From | To |
| --- | --- | --- |
| [tauri](https://github.com/tauri-apps/tauri) | `2.12.1` | `2.12.2` |
| [serde_json](https://github.com/serde-rs/json) | `1.0.151` | `1.0.154` |
| [uuid](https://github.com/uuid-rs/uuid) | `1.26.1` | `1.28.0` |
| [tokio](https://github.com/tokio-rs/tokio) | `1.53.1` | `1.53.2` |
| [tauri-build](https://github.com/tauri-apps/tauri) | `2.7.1` | `2.7.2` |



Updates `tauri` from 2.12.1 to 2.12.2
- [Release notes](https://github.com/tauri-apps/tauri/releases)
- [Commits](tauri-apps/tauri@tauri-v2.12.1...tauri-v2.12.2)

Updates `serde_json` from 1.0.151 to 1.0.154
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](serde-rs/json@v1.0.151...v1.0.154)

Updates `uuid` from 1.26.1 to 1.28.0
- [Release notes](https://github.com/uuid-rs/uuid/releases)
- [Commits](uuid-rs/uuid@v1.26.1...v1.28.0)

Updates `tokio` from 1.53.1 to 1.53.2
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](tokio-rs/tokio@tokio-1.53.1...tokio-1.53.2)

Updates `tauri-build` from 2.7.1 to 2.7.2
- [Release notes](https://github.com/tauri-apps/tauri/releases)
- [Commits](tauri-apps/tauri@tauri-build-v2.7.1...tauri-build-v2.7.2)

---
updated-dependencies:
- dependency-name: serde_json
  dependency-version: 1.0.152
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-minor-and-patch
- dependency-name: tauri
  dependency-version: 2.12.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-minor-and-patch
- dependency-name: tauri-build
  dependency-version: 2.7.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-minor-and-patch
- dependency-name: tokio
  dependency-version: 1.53.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-minor-and-patch
- dependency-name: uuid
  dependency-version: 1.28.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo-minor-and-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Move IPC handlers out of the god-file so feature PRs stop conflicting, with shared pick_file and typed TeachingPdfEntry. Closes #242.

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6f6a9a71-c00a-48ea-98db-c0039725430f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@pountzas pountzas left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Review: refactor split of lib.rs (#242)

The split itself is clean. I compared every function, struct and const from the old lib.rs against its new home with whitespace and visibility normalized: all ~75 commands, CommandResult/ok/err, MusicFilePayload, ALLOWED_MS_SETTINGS_PAGES, RestoreAlwaysOnTop and the window-layout helpers are byte-for-byte moves apart from path prefixes (crate::, super::) and pub visibility. The sorted generate_handler! list is identical (75 entries incl. the 7 companion commands), parameter names are unchanged (so invoke args still match), run() only changed formatting, and teaching_pdf.rs (#291 validation) is untouched. pick_file keeps the same filters, parent, save-name and always-on-top restore; there were no dialog titles before, so none are lost.

Acceptance criteria: lib.rs size/contents ✅, module layout per table ✅, fn names + handler list ✅, single CommandResult ✅, shared pick_file ✅, typed TeachingPdfEntry ✅ (with one regression below), #291 moved unchanged ✅. Still open: CI check was in progress when reviewed (build-windows skipped), and the manual smoke list is unchecked.

Required changes (priority order)

  1. src-tauri/src/commands/teaching_pdf.rs cmd_list_teaching_pdfs: don't fail the whole library when one stored entry doesn't match TeachingPdfEntry; skip invalid entries (and default title/lastOpenedAt) so loading stays as tolerant as before.
  2. src-tauri/src/commands/teaching_pdf.rs: add unit tests that pin the on-disk camelCase JSON round-trip and the skip-invalid behavior.
  3. Before merge: confirm CI check is green and run the Windows smoke list from the PR test plan (pickers, Teaching PDF open/save/export, Focus mode animation, dictation).

Optional: #242 asked for move-only commits first, then pick_file, then TeachingPdfEntry. This is one squashed commit. I verified the moves mechanically, so it isn't blocking.

Comment thread src-tauri/src/commands/teaching_pdf.rs Outdated
Comment thread src-tauri/src/commands/teaching_pdf.rs
Comment thread src-tauri/src/commands/teaching_pdf.rs
pountzas and others added 2 commits October 18, 2026 18:43
Skip invalid stored entries and default missing title/lastOpenedAt so typed TeachingPdfEntry does not regress the old frontend filter.

Co-authored-by: Cursor <cursoragent@cursor.com>
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