Skip to content
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

Clear entries from LevelDB #5404

Merged
merged 28 commits into from
Jan 7, 2025
Merged

Conversation

joshliebe
Copy link
Contributor

@joshliebe joshliebe commented Dec 18, 2024

Task/Issue URL: https://app.asana.com/0/488551667048375/1208996865644937/f

Description

Selectively clears entries from the WebView’s LevelDB.

Steps to test this PR

Point at the JSON blob linked in the task

  • Open AI Chat
  • Type a prompt
  • Go to cnn.com
  • Use the fire button
  • Verify that you see:
WebLocalStorageManager: Allowed domains: [duckduckgo.com]
WebLocalStorageManager: Matching regex: [^_https://([a-zA-Z0-9.-]+\.)?{domain}\u0000\u0001.+$, ^META:https://([a-zA-Z0-9.-]+\.)?{domain}$, ^METAACCESS:https://([a-zA-Z0-9.-]+\.)?{domain}$]
  • Verify that the cnn.com entries are deleted (And any other sites you may have visited), e.g.
WebLocalStorageManager: Deleted key: _https://edition.cnn.com??xyz
  • Go back to AI Chat
  • Verify that the recent chats are retained

Copy link
Contributor Author

joshliebe commented Dec 18, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

@joshliebe joshliebe force-pushed the feature/aitor/webview/localStorage branch from 9562bfd to af0cf12 Compare December 18, 2024 14:28
@joshliebe joshliebe force-pushed the feature/josh/clear-from-level-db branch from 37a55d2 to 8bfc686 Compare December 18, 2024 14:28
@joshliebe joshliebe force-pushed the feature/josh/clear-from-level-db branch from 5fde4bd to e610184 Compare December 18, 2024 18:21
@joshliebe joshliebe changed the base branch from feature/aitor/webview/localStorage to develop December 18, 2024 18:21
@joshliebe joshliebe force-pushed the feature/josh/clear-from-level-db branch from 7590db5 to 627a8e3 Compare December 19, 2024 20:44
@joshliebe joshliebe marked this pull request as ready for review December 20, 2024 17:12
Copy link
Collaborator

@aitorvs aitorvs left a comment

Choose a reason for hiding this comment

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

left some comments but LGTM and tested as expected

Comment on lines 58 to 59
Timber.d("LocalStorageManager: Allowed domains: $domains")
Timber.d("LocalStorageManager: Matching regex: $matchingRegex")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Mental note, we need to migrate all logs to logcat. String interpolation will be executed in production even if logs are disabled. Which is wasteful and in hot paths perf can even be noticeable if the strings are big

No need to do anything here

private val jsonAdapter by lazy { buildJsonAdapter() }

private fun buildJsonAdapter(): JsonAdapter<SettingsJson> {
val moshi = Moshi.Builder().add(KotlinJsonAdapterFactory()).build()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Note: I wonder if we should directly add the KotlinJsonAdapterFactory to the moshi instance that it's in DI.
I see we're creating new instances of moshi everywhere just because the DI instance doens't have that adapter

Also no need to do it in this PR

@joshliebe
Copy link
Contributor Author

@aitorvs I’ve renamed all instances of local storage to web local storage, thanks for the review! 🙏

@joshliebe joshliebe merged commit 450055d into develop Jan 7, 2025
6 checks passed
@joshliebe joshliebe deleted the feature/josh/clear-from-level-db branch January 7, 2025 12:26
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