Skip to content

feat: add user preferences management and settings UI#3

Draft
rchandu wants to merge 1 commit into
mainfrom
feat/preferences
Draft

feat: add user preferences management and settings UI#3
rchandu wants to merge 1 commit into
mainfrom
feat/preferences

Conversation

@rchandu
Copy link
Copy Markdown
Owner

@rchandu rchandu commented May 27, 2025

  • Implemented user preferences structure and loading/saving functionality in TimerManager.
  • Added settings modal for adjusting timer durations and auto-start options.
  • Integrated settings button in the main app interface to open the settings modal.
  • Updated styles for the settings modal and buttons for better user experience.
  • Enhanced timer functionality to reflect user preferences for work and break durations.
  • Added reset to defaults functionality in settings.

- Implemented user preferences structure and loading/saving functionality in TimerManager.
- Added settings modal for adjusting timer durations and auto-start options.
- Integrated settings button in the main app interface to open the settings modal.
- Updated styles for the settings modal and buttons for better user experience.
- Enhanced timer functionality to reflect user preferences for work and break durations.
- Added reset to defaults functionality in settings.
@rchandu rchandu requested a review from Copilot May 27, 2025 05:40
Copy link
Copy Markdown

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 adds persistent user preferences management in the backend and a new Settings modal in the UI so users can customize and save timer durations and auto-start options.

  • Introduces UserPreferences storage/load/save in TimerManager (Rust).
  • Adds a Settings component with a modal UI for editing preferences.
  • Integrates a settings button in App.tsx and updates timer buttons to reflect user-configured durations.

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/Settings.tsx New Settings React component; load, update, reset, save
src/Settings.css Styles for the Settings modal and its controls
src/App.tsx Added preferences state, settings button, and modal hook
src/App.css Header and settings button styling
src-tauri/src/lib.rs TimerManager extended with preferences load/save API
src-tauri/Cargo.toml Added dirs crate for config directory resolution
eslint.config.js Added globals configuration for ESLint
package.json Added globals dependency
Comments suppressed due to low confidence (1)

src-tauri/src/lib.rs:112

  • [nitpick] There are no unit tests covering get_preferences and update_preferences. Consider adding tests for loading, updating, and persisting UserPreferences to prevent regressions.
    pub fn update_preferences(&self, new_preferences: UserPreferences) -> Result<(), String> {

Comment thread src/Settings.tsx
Comment on lines +72 to +89
onMount(() => {
if (props.isOpen) {
loadPreferences();
}
});

// Load preferences when modal opens
const handleModalOpen = () => {
if (props.isOpen) {
loadPreferences();
}
};

// Watch for isOpen changes
onMount(() => {
handleModalOpen();
});

Copy link

Copilot AI May 27, 2025

Choose a reason for hiding this comment

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

Using onMount twice with a separate handleModalOpen won’t reload preferences each time the modal opens. Replace both onMount blocks with a createEffect that watches props.isOpen to call loadPreferences whenever the modal opens.

Suggested change
onMount(() => {
if (props.isOpen) {
loadPreferences();
}
});
// Load preferences when modal opens
const handleModalOpen = () => {
if (props.isOpen) {
loadPreferences();
}
};
// Watch for isOpen changes
onMount(() => {
handleModalOpen();
});
// Watch for isOpen changes and load preferences when modal opens
createEffect(() => {
if (props.isOpen) {
loadPreferences();
}
});

Copilot uses AI. Check for mistakes.
Comment thread src-tauri/src/lib.rs

fn get_preferences_path() -> Result<PathBuf, Box<dyn std::error::Error>> {
let mut path = dirs::config_dir()
.ok_or("Could not get config directory")?;
Copy link

Copilot AI May 27, 2025

Choose a reason for hiding this comment

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

Using ok_or("…")? with an &str won’t compile because &str doesn’t implement std::error::Error. Consider returning a concrete error (e.g., io::Error) or converting to a boxed error type.

Suggested change
.ok_or("Could not get config directory")?;
.ok_or_else(|| "Could not get config directory".into())?;

Copilot uses AI. Check for mistakes.
Repository owner deleted a comment from Copilot AI May 27, 2025
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