-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fire Dialog: New data clearing component #7351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fire Dialog: New data clearing component #7351
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
Cursor Agent can help with this pull request. Just |
626c9b6 to
c0a512b
Compare
c0a512b to
d1c9628
Compare
adf4505 to
7c5f868
Compare
| if (androidBrowserConfigFeature.moreGranularDataClearingOptions().isEnabled()) { | ||
| val clearWhenOption = fireDataStore.getAutomaticallyClearWhenOption() | ||
| val clearOptions = fireDataStore.getAutomaticClearOptions() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how does migration work here? e.g.
- you already have the "old" config to auto clear
- you update, and get this new logic
- does it automatically migrate from the old config's data store to the new
fireDataStore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CDRussell It does. When the new options are accessed for the first time and there is no value stored, the old options are used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! thanks for clarifying
| // the app does not have any activity in CREATED state we kill the process | ||
| if (settingsDataStore.automaticallyClearWhatOption != ClearWhatOption.CLEAR_NONE) { | ||
| clearDataAction.killProcess() | ||
| runBlocking(dispatchers.io()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contrary to cursor's suggestion, I think we should launch a coroutine here instead of runBlocking.
Worst case, our coroutine is prematurely cancelled because Android is killing our app. But that's ok, because the point of the coroutine was to kill the process anyway, so risk there is low.
On the other hand, there's potential to create an ANR with runBlocking. It's unlikely to be user-visible if it happens, but still, doesn't seem worth it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CDRussell OK, thanks! I was trying to be cautious about changing the existing flow but that makes sense. I'll change it back.
7c5f868 to
f26080c
Compare
9a4ca65 to
920fef0
Compare
f26080c to
dff2a53
Compare
86ce114 to
1a61594
Compare
dff2a53 to
454a295
Compare
1a61594 to
ea6128c
Compare
Task/Issue URL: https://app.asana.com/1/137249556945/project/1207418217763355/task/1212373034728504?focus=true ### Description This PR adds a new `AutomaticDataClearing` and `ManualDataClearing` interface, which encapsulate the manual and automatic data-clearing functionality and the necessary side-effects. ### Steps to test this PR _Unit tests_ - [ ] Make sure all unit tests pass _Exisitng manual fire functionality_ - [x] Perform manual fire action - [x] Verify that tabs and data are cleared, as expected _Exisitng automatic fire functionality_ - [ ] Schedule automatic data-clearing (tabs only) set for app launch - [ ] Restart the app and check that tabs are cleared, as expected - [ ] Schedule automatic data-clearing (tabs and data) set for app launch - [ ] Verify that tabs and data are cleared, as expected _Duck.ai chats fire functionality_ - [ ] Go to Settings -> Data Clearing -> Enable Clear Duck.ai chats - [ ] Perform manual fire action for Data, tabs and chats - [ ] Verify that tabs, data and chats are cleared, as expected <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Introduces granular manual/automatic data-clearing (tabs, data, Duck.ai chats) behind a feature flag, refactors clear APIs, and wires the new flow into the Fire dialog, automatic clearer, worker, and notifications with comprehensive tests. > > - **Core (granular clearing)**: > - Add `ManualDataClearing` and `AutomaticDataClearing` interfaces and `DataClearing` implementation using `FireDataStore` options (`TABS`, `DATA`, `DUCKAI_CHATS`). > - Legacy/Granular selection gated by `AndroidBrowserConfigFeature.moreGranularDataClearingOptions()`. > - **Automatic clearing**: > - Refactor `AutomaticDataClearer` to delegate to granular flow when enabled; otherwise use legacy `ClearWhatOption`/`ClearWhenOption`. > - Update restart logic when clearing in foreground and background timer scheduling via `WorkManager` using new options. > - Update `DataClearingWorker` to use granular flow (kills process when needed) or legacy path. > - **Clear action API**: > - Rename `clearTabsOnly(appInForeground)` to `clearTabsAsync(appInForeground)`; add new `clearTabsOnly()` (no side effects). > - Add granular helpers: `clearBrowserDataOnly(...)`, `clearDuckAiChatsOnly()`. > - **UI integration**: > - `BrowserActivity` and `FireDialog` use `ManualDataClearing` when feature flag enabled; otherwise keep legacy full-clear flow and restart behavior. > - **Notifications / DI**: > - `ClearDataNotification` `canShow()` checks new automatic options when flag enabled. > - Wire dependencies in `NotificationModule` for new components. > - **Tests**: > - Add `DataClearingTest` unit tests and expand instrumentation tests (`AutomaticDataClearerTest`, `ClearPersonalDataActionTest`, `ClearDataNotificationTest`) to cover granular vs legacy flows, timers, and restart behavior. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit ea6128c. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->

Task/Issue URL: https://app.asana.com/1/137249556945/project/1207418217763355/task/1212373034728504?focus=true
Description
This PR adds a new
AutomaticDataClearingandManualDataClearinginterface, which encapsulate the manual and automatic data-clearing functionality and the necessary side-effects.Steps to test this PR
Unit tests
Exisitng manual fire functionality
Exisitng automatic fire functionality
Duck.ai chats fire functionality
Note
Introduces granular manual/automatic data-clearing (tabs, data, Duck.ai chats) behind a feature flag, refactors clear APIs, and wires the new flow into the Fire dialog, automatic clearer, worker, and notifications with comprehensive tests.
ManualDataClearingandAutomaticDataClearinginterfaces andDataClearingimplementation usingFireDataStoreoptions (TABS,DATA,DUCKAI_CHATS).AndroidBrowserConfigFeature.moreGranularDataClearingOptions().AutomaticDataClearerto delegate to granular flow when enabled; otherwise use legacyClearWhatOption/ClearWhenOption.WorkManagerusing new options.DataClearingWorkerto use granular flow (kills process when needed) or legacy path.clearTabsOnly(appInForeground)toclearTabsAsync(appInForeground); add newclearTabsOnly()(no side effects).clearBrowserDataOnly(...),clearDuckAiChatsOnly().BrowserActivityandFireDialoguseManualDataClearingwhen feature flag enabled; otherwise keep legacy full-clear flow and restart behavior.ClearDataNotificationcanShow()checks new automatic options when flag enabled.NotificationModulefor new components.DataClearingTestunit tests and expand instrumentation tests (AutomaticDataClearerTest,ClearPersonalDataActionTest,ClearDataNotificationTest) to cover granular vs legacy flows, timers, and restart behavior.Written by Cursor Bugbot for commit ea6128c. This will update automatically on new commits. Configure here.