Skip to content

[PM-38442] feat: Add Fill-Assist endpoint and models#2760

Open
andrebispo5 wants to merge 19 commits into
mainfrom
pm-38442/add-fill-assist-endpoint-and-models
Open

[PM-38442] feat: Add Fill-Assist endpoint and models#2760
andrebispo5 wants to merge 19 commits into
mainfrom
pm-38442/add-fill-assist-endpoint-and-models

Conversation

@andrebispo5

@andrebispo5 andrebispo5 commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-38442

📔 Objective

Adds the networking layer and data models needed to fetch Fill-Assist targeting rules from the map-the-web repository.

API & Models

  • FillAssistAPIService — fetches forms.v0.json via a dedicated mapTheWebService HTTP service
  • FormsMapResponseModel and supporting types (FormsMapHostEntry, FormsMapPathnameEntry, FormsMapContent, FormsMapSelector) — decode the forms map JSON, including a custom init(from:) that silently excludes null-valued host entries

Environment URL plumbing

  • fillAssistRules: String? added to EnvironmentServerConfigResponseModel and EnvironmentServerConfig so the server can provide a custom rules URL
  • fillAssistRulesUrl: URL? added to EnvironmentURLData (persisted per account) with a with(fillAssistRulesUrl:) copy helper
  • fillAssistRulesURL: URL added to EnvironmentURLs, EnvironmentService protocol, and both DefaultEnvironmentService implementations (PM and Authenticator), defaulting to the GitHub releases URL
  • DefaultStateService.setServerConfig stamps the server-provided fillAssistRules URL into the active account's EnvironmentURLData so it is available the next time loadURLsForActiveAccount() runs

@github-actions github-actions Bot added app:password-manager Bitwarden Password Manager app context app:authenticator Bitwarden Authenticator app context t:feature labels Jun 5, 2026
@andrebispo5 andrebispo5 added the ai-review Request a Claude code review label Jun 5, 2026
@github-actions github-actions Bot removed the ai-review Request a Claude code review label Jun 5, 2026
Comment thread BitwardenKit/Core/Platform/Models/Domain/EnvironmentURLs.swift Outdated
Comment thread BitwardenShared/Core/Autofill/Models/FormsMapResponseModel.swift
@andrebispo5 andrebispo5 marked this pull request as ready for review June 17, 2026 15:40
@andrebispo5 andrebispo5 requested review from a team and matt-livefront as code owners June 17, 2026 15:40
Copilot AI review requested due to automatic review settings June 17, 2026 15:40
@andrebispo5 andrebispo5 added the ai-review Request a Claude code review label Jun 17, 2026
@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

🤖 Bitwarden Claude Code Review

Overall Assessment: APPROVE

Reviewed the Fill-Assist networking layer and supporting models: the new FillAssistAPIService / FormsMapRequest / FormsMapResponseModel types, the fillAssistRulesUrl plumbing through EnvironmentURLData, EnvironmentURLs, EnvironmentService, and ServerConfig, and the DefaultStateService.setServerConfig change that stamps the server-provided URL onto the active account. Verified URL composition (baseURL.appendingPathComponent(path)), the region-switch preservation logic in EnvironmentURLs.init(environmentURLData:), and that the new required fillAssistRulesURL init parameter does not break existing call sites (only the memberwise initializer in tests is affected; production code uses init(environmentURLData:)). The change follows established patterns (HTTPService builder, Has* DI protocols, AutoMockable) and has thorough unit-test coverage. Prior reviewer feedback (service naming, var mutability, server-config override preservation, direct decode tests) has been addressed in recent commits.

Code Review Details

No findings at or above the confidence threshold.

Notes considered and dropped during validation:

  • setServerConfig writes environmentUrls?.fillAssistRulesUrl via optional chaining, which is a no-op if environmentUrls is nil at config time. This is consistent with the documented "available next time loadURLsForActiveAccount() runs" flow and the developer's stated design; not a bug.
  • FormsMapResponseModel is decode-oriented (JSONResponse) with a custom init(from:) that drops null host entries — covered by FormsMapResponseModelTests and intentional.

Copilot AI left a comment

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.

Pull request overview

Adds “Fill-Assist” support to the iOS codebase by introducing a dedicated API surface for fetching map-the-web targeting rules, wiring a configurable base URL through environment configuration, and updating environment URL models/services accordingly.

Changes:

  • Added FillAssistAPIService + FormsMap* request/response models and tests to fetch forms.v0.json from the map-the-web release endpoint.
  • Extended server/environment configuration (EnvironmentServerConfigResponseModel / EnvironmentURL*) to include an optional Fill-Assist rules base URL override, and exposed it via EnvironmentService.
  • Updated state/config handling to persist the Fill-Assist rules URL from server config into per-account environment URL data.

Reviewed changes

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

Show a summary per file
File Description
BitwardenShared/Core/Platform/Services/Stores/AppSettingsStoreTests.swift Updates test fixtures to include the new fillAssistRules config field.
BitwardenShared/Core/Platform/Services/StateServiceTests.swift Adds coverage ensuring server config updates fillAssistRulesUrl in environment URL data.
BitwardenShared/Core/Platform/Services/StateService.swift Persists Fill-Assist rules URL from server config into account environment URL state.
BitwardenShared/Core/Platform/Services/Services.swift Adds HasFillAssistAPIService to the shared services composition.
BitwardenShared/Core/Platform/Services/ServiceContainer.swift Exposes fillAssistAPIService from the shared container via apiService.
BitwardenShared/Core/Platform/Services/ServerCommunicationConfigClientSingletonTests.swift Updates test config models to include fillAssistRules.
BitwardenShared/Core/Platform/Services/EnvironmentService.swift Exposes fillAssistRulesURL from EnvironmentURLs.
BitwardenShared/Core/Platform/Services/API/APIServiceTests.swift Validates mapTheWebService base URL + token provider configuration.
BitwardenShared/Core/Platform/Services/API/APIService.swift Adds mapTheWebService HTTP service bound to environmentService.fillAssistRulesURL.
BitwardenShared/Core/Autofill/Services/API/Requests/FormsMapRequestTests.swift Adds tests for FormsMapRequest path/method.
BitwardenShared/Core/Autofill/Services/API/Requests/FormsMapRequest.swift Introduces request for forms.v0.json.
BitwardenShared/Core/Autofill/Services/API/Fixtures/APITestData+FillAssist.swift Adds fixture JSON for Forms Map responses.
BitwardenShared/Core/Autofill/Services/API/FillAssistAPIServiceTests.swift Adds request-building test for getFormsMap().
BitwardenShared/Core/Autofill/Services/API/FillAssistAPIService.swift Introduces FillAssistAPIService protocol and APIService conformance.
BitwardenShared/Core/Autofill/Models/FormsMapResponseModel.swift Adds decoding models for the Forms Map schema (hosts/pathnames/forms/selectors).
BitwardenKit/Core/Platform/Services/Mocks/MockEnvironmentService.swift Adds fillAssistRulesURL to the mock environment service.
BitwardenKit/Core/Platform/Services/EnvironmentService.swift Extends the EnvironmentService protocol with fillAssistRulesURL.
BitwardenKit/Core/Platform/Services/AppInfoServiceTests.swift Updates test fixtures to include fillAssistRules.
BitwardenKit/Core/Platform/Services/API/Response/ConfigResponseModel.swift Adds fillAssistRules to the environment server config response model.
BitwardenKit/Core/Platform/Models/Domain/ServerConfig.swift Propagates fillAssistRules into the domain environment server config model.
BitwardenKit/Core/Platform/Models/Domain/EnvironmentURLsTests.swift Updates expected EnvironmentURLs to include default fillAssistRulesURL.
BitwardenKit/Core/Platform/Models/Domain/EnvironmentURLs.swift Adds fillAssistRulesURL with default GitHub release download base and override support.
BitwardenKit/Core/Platform/Models/Domain/EnvironmentURLData.swift Adds per-account fillAssistRulesUrl storage and helper to update it.
Comments suppressed due to low confidence (1)

BitwardenKit/Core/Platform/Models/Domain/EnvironmentURLData.swift:96

  • isEmpty is documented as "true if none of the URLs are set", but it doesn't account for the newly added fillAssistRulesUrl. If fillAssistRulesUrl is set via server config, isEmpty will still return true, which can cause callers to treat the environment as having no overrides.
    /// Whether all of the environment URLs are not set.
    var isEmpty: Bool {
        api == nil
            && base == nil
            && events == nil

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

Comment thread BitwardenKit/Core/Platform/Models/Domain/EnvironmentURLData.swift
Comment thread BitwardenKit/Core/Platform/Services/EnvironmentService.swift
Comment thread BitwardenShared/Core/Autofill/Models/FormsMapResponseModel.swift
Comment thread BitwardenKit/Core/Platform/Models/Domain/EnvironmentURLs.swift Outdated
@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.86207% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.55%. Comparing base (3467801) to head (f90dc54).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
...d/Core/Autofill/Models/FormsMapResponseModel.swift 60.86% 9 Missing ⚠️
...ed/Core/Platform/Services/EnvironmentService.swift 0.00% 3 Missing ⚠️
...ared/Core/Platform/Services/ServiceContainer.swift 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2760      +/-   ##
==========================================
- Coverage   80.82%   78.55%   -2.28%     
==========================================
  Files        1019     1144     +125     
  Lines       64856    72254    +7398     
==========================================
+ Hits        52418    56756    +4338     
- Misses      12438    15498    +3060     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread BitwardenShared/Core/Platform/Services/API/APIService.swift Outdated
Comment thread BitwardenKit/Core/Platform/Models/Domain/EnvironmentURLData.swift Outdated
Comment thread BitwardenShared/Core/Autofill/Services/API/FillAssistAPIServiceTests.swift Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Request a Claude code review app:authenticator Bitwarden Authenticator app context app:password-manager Bitwarden Password Manager app context t:feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants