Skip to content

refactor(tauri): split lib.rs into commands/ submodule (Phase 4)#52

Merged
jamesbrink merged 1 commit intomainfrom
james-brink/split-tauri-commands
May 4, 2026
Merged

refactor(tauri): split lib.rs into commands/ submodule (Phase 4)#52
jamesbrink merged 1 commit intomainfrom
james-brink/split-tauri-commands

Conversation

@jamesbrink
Copy link
Copy Markdown
Member

Summary

  • Carves the 2,438-line src-tauri/src/lib.rs into a commands/ submodule grouped by concern, mirroring the shell/ submodule split from refactor(tauri): split shell.rs into shell/ submodule (Phase 5) #49 (Phase 5). lib.rs shrinks to 755 lines (-69%) and now holds only the agent supervisor, agent IPC, paste persistence, tracing init, and run().
  • All IPC command names preserved — frontend invoke() callers don't need to change.
  • Tray idempotency tests travel with their code; lib.rs keeps a smaller test pinning the invoke_handler wiring contract.

Closes #41.

New layout

File Lines Concern
lib.rs 755 agent supervisor, agent IPC (start_agent, send_message, agent_command, force_restart_agent, dispatch_a2ui_event), save_paste_image, logging, run()
commands/config.rs 336 read_state, write_state, read_config, write_config, aethon_home_dir, aethon_state_path
commands/session.rs 345 search_sessions, delete_session, export_chat_markdown + snippet helpers
commands/extensions.rs 895 ExtensionMenuItem/Store, set_extension_menu_items, install_app_menu/install_tray/TRAY_ID, AgentWatcher, watch/unwatch_project_extensions, install_aethon_extension
commands/git.rs 152 git_status, pick_project_directory
commands/window.rs 79 toggle_fullscreen, toggle_devtools, updater_available + pubkey gate
commands/mod.rs 23 submodule declarations

Notes

  • sanitize_filename_segment moved to helpers.rs since both save_paste_image (lib.rs) and export_chat_markdown (session.rs) need it.
  • install_app_menu / install_tray / TRAY_ID bundled into extensions.rs rather than left in lib.rs — the menu rebuild is driven by extension menu deltas, so cohesion lives there. Keeping them in lib.rs would have forced a pub(crate) purely for set_extension_menu_items to reach them.
  • Visibility widened on AgentProcess, AgentReloadFlag, agent_reload_in_progress, project_root, resolved_login_path (now pub(crate)) so the watcher debounce worker and install_aethon_extension can reach them from the new module.
  • Spec listed search_sessions_by_keyword for the session command; kept the existing IPC name search_sessions to avoid breaking src/skills/default-layout/search-panel.tsx:178 and src/App.tsx:3663.

Test plan

  • cargo clippy --all-targets -- -D warnings — clean
  • cargo test --lib — 74 passed (3 in the relocated commands::extensions::tests)
  • bunx vitest run — 305 passed across 30 files
  • bunx tsc -b --noEmit + bunx eslint . — clean
  • Full devshell check gate end-to-end — passes
  • Smoke test the dev build: send a chat, search sessions, export a chat, install an extension, watch a project's .aethon/extensions/, toggle fullscreen/devtools — all IPC paths resolve from the frontend.

Carve the 2,438-line lib.rs into a commands/ submodule grouped by
concern, mirroring the shell/ submodule split that landed in #49.
lib.rs shrinks to 755 lines and now holds only what the agent
process supervisor + tauri::Builder actually need: agent IPC
commands, paste persistence, tracing init, run().

- commands/config.rs    — read/write_state, read/write_config,
                          aethon_home_dir, aethon_state_path
- commands/session.rs   — search_sessions, delete_session,
                          export_chat_markdown + snippet helpers
- commands/extensions.rs — ExtensionMenuItem/Store, native menu
                          + tray rebuild, AgentWatcher,
                          watch/unwatch_project_extensions,
                          install_aethon_extension
- commands/git.rs       — git_status, pick_project_directory
- commands/window.rs    — toggle_fullscreen, toggle_devtools,
                          updater_available + pubkey gate

sanitize_filename_segment moves to helpers.rs since both
save_paste_image (lib.rs) and export_chat_markdown (session.rs)
need it. Tray idempotency tests travel with their code into
commands/extensions.rs; lib.rs keeps a smaller test pinning the
invoke_handler wiring contract.

All IPC command names preserved — search_sessions stays as-is so
the frontend invoke surface (search-panel.tsx, App.tsx) keeps
resolving. Visibility for AgentProcess / AgentReloadFlag /
agent_reload_in_progress / project_root / resolved_login_path
widened to pub(crate) so the watcher debounce worker and
install_aethon_extension can reach them from the new module.

Closes #41
@jamesbrink jamesbrink enabled auto-merge (squash) May 4, 2026 14:34
@jamesbrink jamesbrink merged commit 22206ef into main May 4, 2026
4 checks passed
@jamesbrink jamesbrink deleted the james-brink/split-tauri-commands branch May 4, 2026 14:34
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.

refactor(tauri): split src-tauri/src/lib.rs (2438 lines) into commands/ submodules

1 participant