Skip to content

chore: Refactor settings handling API#1148

Merged
mykola-mokhnach merged 4 commits into
masterfrom
sess-start
Jun 6, 2026
Merged

chore: Refactor settings handling API#1148
mykola-mokhnach merged 4 commits into
masterfrom
sess-start

Conversation

@mykola-mokhnach

Copy link
Copy Markdown

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the /appium/settings handling in WebDriverAgent by centralizing “get current settings” and “apply settings” logic into a dedicated FBSettingsHandler utility, reducing duplication in FBSessionCommands.

Changes:

  • Added FBSettingsHandler to provide a single source of truth for settings getters/setters and settings application/validation flow.
  • Updated FBSessionCommands settings routes to delegate to FBSettingsHandler.
  • Registered the new handler in the Xcode project; also added a new Ruby gem dependency (multi_json).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
WebDriverAgentLib/Utilities/FBSettingsHandler.m New centralized implementation of settings getters/setters and application logic.
WebDriverAgentLib/Utilities/FBSettingsHandler.h Public interface for applying settings and retrieving current settings.
WebDriverAgentLib/Commands/FBSessionCommands.m Routes now call into FBSettingsHandler instead of inline settings logic.
WebDriverAgent.xcodeproj/project.pbxproj Adds the new handler files to build phases/headers.
Gemfile Adds multi_json gem dependency.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread WebDriverAgentLib/Utilities/FBSettingsHandler.m Outdated
Comment thread Gemfile
source "https://rubygems.org"

gem "fastlane", '~> 2.229'
gem "multi_json"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

this is ok

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hm, is multi_json required outside of git managed code?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I had to add it to resolve integration tests execution, which suddenly started to fail. I would be happy to tune that if there is a better fix. Failing job example: https://github.com/appium/WebDriverAgent/actions/runs/27012566145/job/79719509941

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Comment on lines +304 to +308
FBSettingApplyBlock handler = settersMap[key];
if (nil == handler) {
continue;
}
FBCommandStatus *status = handler(session, FBNormalizedSettingValue(settings[key]));

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed

Comment on lines +241 to +243
map[FB_SETTING_ACCEPT_ALERT_BUTTON_SELECTOR] = ^id(FBSession *session) {
return FBConfiguration.acceptAlertButtonSelector;
};

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

the current behaviour is ok

Comment on lines +244 to +246
map[FB_SETTING_DISMISS_ALERT_BUTTON_SELECTOR] = ^id(FBSession *session) {
return FBConfiguration.dismissAlertButtonSelector;
};

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

the current behaviour is ok

Comment on lines +247 to +249
map[FB_SETTING_AUTO_CLICK_ALERT_SELECTOR] = ^id(FBSession *session) {
return FBConfiguration.autoClickAlertSelector;
};

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

the current behaviour is ok

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comment on lines +317 to +333
NSDictionary<NSString *, FBSettingApplyBlock> *settersMap = [self settersMap];
NSSet<NSString *> *nilClearableKeys = FBNilClearableSettingKeys();
for (NSString *key in settings) {
FBSettingApplyBlock handler = settersMap[key];
if (nil == handler) {
continue;
}
id value = FBNormalizedSettingValue(settings[key]);
if (nil == value && ![nilClearableKeys containsObject:key]) {
continue;
}
FBCommandStatus *status = handler(session, value);
if (status.hasError) {
return status;
}
}
return nil;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

no crash is going to happen, unrecognised selector would just error out the API request with an unknown error

Comment on lines +315 to +319
+ (nullable FBCommandStatus *)applySettings:(NSDictionary *)settings toSession:(FBSession *)session
{
NSDictionary<NSString *, FBSettingApplyBlock> *settersMap = [self settersMap];
NSSet<NSString *> *nilClearableKeys = FBNilClearableSettingKeys();
for (NSString *key in settings) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

this would be an overkill. I'm happy with the current state

Comment thread Gemfile
source "https://rubygems.org"

gem "fastlane", '~> 2.229'
gem "multi_json"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hm, is multi_json required outside of git managed code?

@mykola-mokhnach mykola-mokhnach merged commit ff7ac36 into master Jun 6, 2026
43 of 46 checks passed
@mykola-mokhnach mykola-mokhnach deleted the sess-start branch June 6, 2026 05:48
github-actions Bot pushed a commit that referenced this pull request Jun 6, 2026
## [13.2.1](v13.2.0...v13.2.1) (2026-06-06)

### Miscellaneous Chores

* Refactor settings handling API ([#1148](#1148)) ([ff7ac36](ff7ac36))
@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 13.2.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants