Skip to content

Conversation

@5hank6
Copy link

@5hank6 5hank6 commented Jan 3, 2026

PR Description

This PR adds an optional save confirmation dialog when closing the app.

Users can control this behavior via Settings → “Show Save Alert on App Close”.
When enabled and there are unsaved changes, the app prompts the user to either
save or discard changes before exiting.

This avoids unnecessary prompts when no changes exist and improves the overall
closing experience.

Related Issues

Closes #993

Checklist

  • I have gone through the contributing guide
  • My branch is up to date with main
  • I have run the app and verified the behavior manually
  • Existing tests pass

Added/updated tests?

  • Yes
  • No — behavior verified manually via UI interaction

OS tested on

  • Windows
  • macOS
  • Linux

@5hank6 5hank6 mentioned this pull request Jan 3, 2026
@ShashwatXD
Copy link

ShashwatXD commented Jan 5, 2026

Hi @5hank6 , have you tested this, as i can see in your code that you havent used the provider you created in ui_providers.dart, also there is no saveData() called on automatic close.

@5hank6
Copy link
Author

5hank6 commented Jan 5, 2026

Hi @ShashwatXD, thanks for the careful review 🙌

Yes, I’ve manually tested the flow on macOS:

  • When “Show Save Alert on App Close” is enabled and there are unsaved changes, the dialog appears
  • On “Save”, saveData() is called before closing
  • On “No”, the app closes immediately

That said, you’re right — the provider added in ui_providers.dart is currently redundant and not wired in.
I’ll clean this up and push a follow-up commit to either:

  • properly use the provider, or
  • remove it if it’s unnecessary.

Thanks for pointing this out — updating shortly.

@5hank6
Copy link
Author

5hank6 commented Jan 5, 2026

Thanks for checking this 👍

I’ve verified the behavior end-to-end on macOS:

  • The close handler now checks promptBeforeClosing from settingsProvider
  • The dialog is shown only when there are unsaved changes
  • On “Save”, saveData() is explicitly called before closing
  • On “No”, the app closes without persisting changes
  • When the setting is disabled, the app closes immediately

I’ve manually tested all flows (save / discard / no changes), and they work as expected.
Happy to adjust if you’d prefer a different integration point.

@5hank6
Copy link
Author

5hank6 commented Jan 5, 2026

Update:
Addressed the feedback and fixed the save-on-close flow.

Verified:

  • Prompt appears only when there are unsaved changes
  • “Save” persists workspace correctly
  • “No” discards changes as expected

Tested on macOS. All existing tests pass.

@ShashwatXD
Copy link

@5hank6 the feature to be added was adding a auto-save flow, you have added too much complexity with the pre-existiing features only.

@5hank6
Copy link
Author

5hank6 commented Jan 5, 2026

@ShashwatXD
I interpreted the issue as adding user control via settings, so I reused the existing “Save Alert on App Close” flow.
If the intended behavior is always autosave on close (without user prompt), I can simplify the logic and update the PR accordingly.
Please let me know which direction you prefer.

@ShashwatXD
Copy link

I have asked the maintainers for the exact flow, we can discuss those in the related issue.

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.

An autosave on close?

2 participants