Skip to content

Add FXiOS-15127 [AI Kill Switch] Delete models when translation is toggled off#32995

Open
Cramsden wants to merge 5 commits intomainfrom
cr/FXIOS-15127_delete-models
Open

Add FXiOS-15127 [AI Kill Switch] Delete models when translation is toggled off#32995
Cramsden wants to merge 5 commits intomainfrom
cr/FXIOS-15127_delete-models

Conversation

@Cramsden
Copy link
Copy Markdown
Contributor

@Cramsden Cramsden commented Apr 8, 2026

📜 Tickets

Jira ticket
Github issue

💡 Description

  • Delete models via resetStorage when toggling off translations either via kill switch or via the toggle setting

🎥 Demos

Before After
Demo

📝 Checklist

  • I filled in the ticket numbers and a description of my work
  • I updated the PR name to follow our PR naming guidelines
  • I ensured unit tests pass and wrote tests for new code
  • If working on UI, I checked and implemented accessibility (Dynamic Text and VoiceOver)
  • If adding telemetry, I read the data stewardship requirements and will request a data review
  • If adding or modifying strings, I read the guidelines and will request a string review from l10n
  • If needed, I updated documentation and added comments to complex code

@Cramsden Cramsden requested a review from a team as a code owner April 8, 2026 17:21
@Cramsden Cramsden requested review from razvanlitianu and removed request for razvanlitianu April 8, 2026 17:21
@mobiletest-ci-bot
Copy link
Copy Markdown

mobiletest-ci-bot commented Apr 14, 2026

Messages
📖 Project coverage: 41.17%

💪 Quality guardian

5 tests files modified. You're a champion of test coverage! 🚀

🥇 Perfect PR size

Smaller PRs are easier to review. Thanks for making life easy for reviewers! ✨

🧑‍💻 New Task {} detected

New Task {} added in file firefox-ios/Client/Frontend/Settings/Translation/TranslationSettingsMiddleware.swift at line 75.
Please add a concurrency reviewer on your PR: @Cramsden @ih-codes @lmarceau

✅ New file code coverage

No new file detected so code coverage gate wasn't ran.

Client.app: Coverage: 39.43

File Coverage
TranslationSettingsMiddleware.swift 88.46%
TranslationSettingsAction.swift 100.0%
AIControlsSettingsView.swift 0.0% ⚠️
ASTranslationModelsFetcher.swift 70.98%
AIControlsModel.swift 100.0%
SettingsCoordinator.swift 82.32%

Generated by 🚫 Danger Swift against ea5b6f8

prefs.setBool(false, forKey: PrefsKeys.Settings.translationsFeature)
prefs.setBool(false, forKey: PrefsKeys.Summarizer.summarizeContentFeature)
}
store.dispatch(TranslationSettingsViewAction(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we might have an edge case that breaks: user manually turns translations off (pref = false) → then turns kill switch ON → middleware reads pref (false) → sets to true. The pref ends up opposite to what the kill switch intended. In TranslationSettingsViewActionType.toggleTranslationsEnabled action let newValue = !current just flips whatever is currently in prefs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yep you are right. I found this logic a bit strange but was just trying to follow the existing pattern. I think it makes more sense to just pass in the bool value we expect to set it to. What do you think?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yes. That makes sense.

/// Resets any local storage of models.
func resetStorage() async {
do {
try modelsClient?.resetStorage()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If modelsClient is nil, the reset is silently skipped, no log, no error. Is it worth at least a logger.log at warning level for the nil case so it's observable if it ever happens in the field?

@Cramsden Cramsden requested a review from a team April 14, 2026 15:53
Copy link
Copy Markdown
Contributor

@adudenamedruby adudenamedruby left a comment

Choose a reason for hiding this comment

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

aside from @razvanlitianu 's comments, this is ok with me for the most part. I'll approve pending the resolution to those comments.

isEditing: false,
pendingLanguages: nil,
preferredLanguages: [],
supportedLanguages: ["en", "fr", "de"]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not familliar with translations, but, I feel like...... should this be hardcoded somewhere central that we can easily keep track of, and we get it from one place so further updates don't get missed out on? Or is this the one place?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I guess I am still not sure where we land on test data.. I have always been in the camp that test data should be hard coded therefore if the code changes the test will catch it. This is not actually needed here so I can just remove it. I copied this from the middleware tests, but generally it is a discussion I would be interested in discussing.

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.

4 participants