Skip to content

Refactor#14

Open
ravinagabhyru wants to merge 7 commits intosevos:mainfrom
ravinagabhyru:refactor
Open

Refactor#14
ravinagabhyru wants to merge 7 commits intosevos:mainfrom
ravinagabhyru:refactor

Conversation

@ravinagabhyru
Copy link

This pull request refactors the waystt codebase to introduce a library-first architecture, separating the CLI/binary from core logic and making the application more modular and testable. It introduces new modules for configuration, CLI options, signal handling, and the audio processing pipeline, and updates how transcription providers are selected and instantiated. The binary entrypoint is moved, and configuration/environment handling is improved for flexibility and clarity.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Performance improvement
  • Code refactoring

Changes Made

Library/Architecture Refactor:

  • Introduced a new lib.rs as the main library entrypoint, exposing a public async run function that coordinates configuration, provider creation, and running the app, enabling a library-first API with a thin binary wrapper. (src/lib.rs)
  • Moved the binary entrypoint from src/main.rs to src/bin/waystt.rs to decouple the binary from the core library. (Cargo.toml)

Configuration and CLI Improvements:

  • Added RunOptions struct in cli.rs to decouple CLI-facing options from parsing, and provided helpers for default env file paths. (src/cli.rs)
  • Improved configuration loading and validation with a new bootstrap function, supporting optional envfile loading and clear error handling. (src/config.rs)

Audio and Signal Handling:

  • Added a new AudioPipeline struct to encapsulate audio processing, WAV encoding, and transcription logic, improving separation of concerns. (src/pipeline.rs)
  • Added a signals module for signal constants and async signal stream utilities, simplifying signal handling. (src/signals.rs)
  • Updated AudioProcessor to use a stricter silence check, allowing very quiet audio to pass to further processing. (src/audio_processing.rs)

Transcription Provider Refactor:

  • Refactored provider selection to use a strongly-typed ProviderKind enum instead of string matching, and updated the TranscriptionFactory to accept explicit config injection, improving type safety and testability. (src/transcription/mod.rs)
  • Updated tests to use the new provider instantiation API. (src/transcription/mod.rs) [1] [2] [3] [4]

Application Logic:

  • Added a new App struct to encapsulate application state and logic, including signal-driven control flow and user feedback, making the main loop more maintainable and testable. (src/app.rs)

These changes lay the foundation for a more maintainable, testable, and reusable codebase, with clear separation between the CLI, core logic, and provider-specific implementations.

Testing

  • Tests pass locally with cargo test
  • Code follows the project's style guidelines (cargo fmt and cargo clippy)
  • Self-review of the code has been performed
  • Code has been tested manually (if applicable)

Test Environment

  • OS: Arch Linux
  • Wayland Compositor: Hyprland
  • Audio System: PipeWire

Audio Feedback Testing (if applicable)

  • Recording start beep plays correctly
  • Recording stop beep plays correctly
  • Success beep plays after operations
  • Error beep plays on failures
  • Volume controls work as expected

Signal Testing (if applicable)

  • SIGUSR1 (direct typing) works correctly
  • SIGUSR2 (clipboard copy) works correctly
  • Error handling works properly

Breaking Changes

If this PR contains breaking changes, please describe:

  • There should not breaking changes

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@sevos
Copy link
Owner

sevos commented Oct 6, 2025

Thanks! let's integrate after 0.3.1

@sevos
Copy link
Owner

sevos commented Oct 6, 2025

@claude review pls

@ravinagabhyru
Copy link
Author

@claude review the PR

@ravinagabhyru
Copy link
Author

Fixed merge issues

@sevos
Copy link
Owner

sevos commented Nov 11, 2025

@ravinagabhyru thanks for this. I intend to merge this next. Could you resolve the conflict for the last time please?

@ravinagabhyru
Copy link
Author

There should not be any conflicts anymore. main.rs has been moved to bin/waystt.rs.

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.

2 participants