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

[iOS] - Add ability to set custom command-line switches #24384

Merged
merged 3 commits into from
Jun 26, 2024

Conversation

Brandon-T
Copy link
Contributor

@Brandon-T Brandon-T commented Jun 26, 2024

Summary

  • Add ability to set custom command-line switches/flags for Brave-Core

Resolves brave/brave-browser#39384

Submitter Checklist:

  • I confirm that no security/privacy review is needed and no other type of reviews are needed, or that I have requested them
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally:
    • npm run test -- brave_browser_tests, npm run test -- brave_unit_tests wiki
    • npm run presubmit wiki, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

  1. Enable the Debug menu in Settings
  2. Scroll down to Brave Core Switches
  3. Scroll down to "Add Custom Switch"
  4. Enter Key: "env-ai-chat.bsg" and Value: "dev"
  5. Save
  6. Notice new switch added at the bottom of the screen with --env-ai-chat.bsg=dev as the sub-text.
  7. Restart the app
  8. Visit: brave://version and verify the command-line switch was added.
  9. Swipe to delete the switch you added.
  10. Verify that it was deleted in the UI.
  11. Visit: brave://version and verify the command-line switch was removed.

Screenshots

image
image
image
image

@Brandon-T Brandon-T added CI/skip-android Do not run CI builds for Android CI/skip-macos-x64 Do not run CI builds for macOS x64 CI/skip-windows-x64 Do not run CI builds for Windows x64 unused-CI/skip-linux-x64 Do not run CI builds for Linux x64 CI/skip-macos-arm64 Do not run CI builds for macOS arm64 labels Jun 26, 2024
@Brandon-T Brandon-T self-assigned this Jun 26, 2024
@Brandon-T Brandon-T requested a review from a team as a code owner June 26, 2024 12:37
private struct CustomSwitchInputView: View {
@ObservedObject private var customSwitches = Preferences.BraveCore.customSwitches
@ObservedObject private var switchValues = Preferences.BraveCore.switchValues
@Environment(\.presentationMode) @Binding private var presentationMode
Copy link
Collaborator

Choose a reason for hiding this comment

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

Prefer @Environment(\.dismiss) private var dismiss instead

@ObservedObject private var switchValues = Preferences.BraveCore.switchValues
@Environment(\.presentationMode) @Binding private var presentationMode

@State var key: String = ""
Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably shouldn't initialize State like this, best to pass in a regular var and onAppear set the State with that. If you're fine with the key passed in being ignored on subsequent body evaluations you can also make a explicit init method that sets the state like _key = State(initialValue: key) instead

let keys = $0.map { Preferences.BraveCore.customSwitches.value[$0] }

withAnimation(.default) {
keys.forEach { key in
Copy link
Collaborator

Choose a reason for hiding this comment

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

Prefer regular for loops

@Brandon-T Brandon-T merged commit b821b18 into master Jun 26, 2024
19 checks passed
@Brandon-T Brandon-T deleted the feature/Skus-Env-iOS branch June 26, 2024 16:20
@github-actions github-actions bot added this to the 1.69.x - Nightly milestone Jun 26, 2024
@stephendonner
Copy link
Contributor

stephendonner commented Jun 26, 2024

Verification PASSED using

Brave version 1.69 (57)
iOS 17.5.1 (21F90)
iPad Pro (12.9-inch) (2nd generation)

Steps:

  1. installed 1.69 (57) via TestFlight
  2. launched Brave
  3. enabled the Debug menu in Settings
  4. swiped down to BraveCore Switches
  5. swiped down further to Add Custom Switch
  6. tapped on it
  7. input env-ai-chat.bsg for the key field
  8. input dev for the value field
  9. repeated for keys: env-leo and env-ai-chat-premium.bsg
  10. did my usual purchase from account.bravesoftware.com of Leo Premium, using `issue39384@mailinator.com
  11. restarted Brave
  12. loaded an article on vox.com
  13. tapped on Summarize this page
  14. tapped on I understand

Confirmed it summarized correctly using Leo Premium credentials and Claude 3 Sonnet

example example example example example
image image image image image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/skip-android Do not run CI builds for Android CI/skip-macos-arm64 Do not run CI builds for macOS arm64 CI/skip-macos-x64 Do not run CI builds for macOS x64 CI/skip-windows-x64 Do not run CI builds for Windows x64 unused-CI/skip-linux-x64 Do not run CI builds for Linux x64
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[iOS] - Add ability to set custom command-line switches for Brave-Core
4 participants