Skip to content

Conversation

@0nko
Copy link
Member

@0nko 0nko commented Dec 14, 2025

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

  • Perform manual fire action
  • 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

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.

Written by Cursor Bugbot for commit ea6128c. This will update automatically on new commits. Configure here.

@0nko 0nko mentioned this pull request Dec 14, 2025
1 task
Copy link
Member Author

0nko commented Dec 14, 2025

@cursor
Copy link

cursor bot commented Dec 14, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@0nko 0nko force-pushed the feature/ondrej/fire-dialog-data-clearing-interface branch 3 times, most recently from 626c9b6 to c0a512b Compare December 14, 2025 14:58
@0nko 0nko requested a review from CDRussell December 15, 2025 22:30
@0nko 0nko force-pushed the feature/ondrej/fire-dialog-data-clearing-interface branch from c0a512b to d1c9628 Compare December 15, 2025 22:59
@0nko 0nko force-pushed the feature/ondrej/fire-dialog-new-clear-actions branch from adf4505 to 7c5f868 Compare December 15, 2025 22:59
@0nko 0nko mentioned this pull request Dec 15, 2025
51 tasks
@0nko 0nko changed the title Fire Dialog: New DataClearing interface Fire Dialog: New data clearing component Dec 15, 2025
@CDRussell CDRussell self-assigned this Dec 16, 2025
Comment on lines +176 to +177
if (androidBrowserConfigFeature.moreGranularDataClearingOptions().isEnabled()) {
val clearWhenOption = fireDataStore.getAutomaticallyClearWhenOption()
val clearOptions = fireDataStore.getAutomaticClearOptions()
Copy link
Member

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.

  1. you already have the "old" config to auto clear
  2. you update, and get this new logic
  3. does it automatically migrate from the old config's data store to the new fireDataStore ?

Copy link
Member Author

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.

Copy link
Member

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()) {
Copy link
Member

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.

Copy link
Member Author

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.

@0nko 0nko force-pushed the feature/ondrej/fire-dialog-new-clear-actions branch from 7c5f868 to f26080c Compare December 16, 2025 12:31
@0nko 0nko force-pushed the feature/ondrej/fire-dialog-data-clearing-interface branch from 9a4ca65 to 920fef0 Compare December 16, 2025 12:31
@0nko 0nko force-pushed the feature/ondrej/fire-dialog-new-clear-actions branch from f26080c to dff2a53 Compare December 17, 2025 15:15
@0nko 0nko force-pushed the feature/ondrej/fire-dialog-data-clearing-interface branch 2 times, most recently from 86ce114 to 1a61594 Compare December 17, 2025 18:34
@0nko 0nko force-pushed the feature/ondrej/fire-dialog-new-clear-actions branch from dff2a53 to 454a295 Compare December 17, 2025 18:34
@0nko 0nko mentioned this pull request Dec 17, 2025
1 task
Base automatically changed from feature/ondrej/fire-dialog-new-clear-actions to develop December 18, 2025 12:20
@0nko 0nko force-pushed the feature/ondrej/fire-dialog-data-clearing-interface branch from 1a61594 to ea6128c Compare December 18, 2025 12:22
@0nko 0nko merged commit 1774ce1 into develop Dec 18, 2025
10 checks passed
@0nko 0nko deleted the feature/ondrej/fire-dialog-data-clearing-interface branch December 18, 2025 13:00
cursor bot pushed a commit that referenced this pull request Dec 19, 2025
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 -->
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