Skip to content

SDKS-4927 Implement AgreementCollector for DaVinci forms to support Terms of Service and agreement displays#182

Merged
spetrov merged 1 commit intodevelopfrom
SDKS-4927
May 4, 2026
Merged

SDKS-4927 Implement AgreementCollector for DaVinci forms to support Terms of Service and agreement displays#182
spetrov merged 1 commit intodevelopfrom
SDKS-4927

Conversation

@witrisna
Copy link
Copy Markdown
Contributor

@witrisna witrisna commented Apr 14, 2026

JIRA Ticket

SDKS-4927

Description

SDKS-4927 Implement AgreementCollector for DaVinci forms to support Terms of Service and agreement displays

Key changes:

  • Created AgreementCollector to handle AGREEMENT type form fields, supporting properties like content, title, and agreementId.
  • Registered AgreementCollector in CollectorRegistry using the READ_ONLY_TEXT factory key.
  • Added a scrollable Agreement Compose UI component to both sample applications for rendering agreement text.
  • Updated ContinueNode in sample apps to include AgreementCollector in the collector dispatch logic.
  • Added comprehensive unit tests in AgreementCollectorTest.kt to verify JSON initialization and default values.
  • Updated documentation in davinci/README.md to include AgreementCollector in the list of available collectors.

Summary by CodeRabbit

  • New Features

    • Added an agreement collector type to display user agreements in forms.
    • Sample apps now render agreement cards with optional titles and scrollable agreement text.
  • Tests

    • Added tests validating agreement collector initialization and defaults.
  • Documentation

    • README updated to list the agreement collector among available collectors.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 59c92776-4df1-40c8-ba5b-8769e02aa2ba

📥 Commits

Reviewing files that changed from the base of the PR and between 5e653df and 39e6d86.

📒 Files selected for processing (8)
  • davinci/README.md
  • davinci/src/main/kotlin/com/pingidentity/davinci/CollectorRegistry.kt
  • davinci/src/main/kotlin/com/pingidentity/davinci/collector/AgreementCollector.kt
  • davinci/src/test/kotlin/com/pingidentity/davinci/AgreementCollectorTest.kt
  • samples/app/src/main/java/com/pingidentity/samples/app/davinci/collector/Agreement.kt
  • samples/app/src/main/java/com/pingidentity/samples/app/davinci/collector/ContinueNode.kt
  • samples/pingsampleapp/src/main/java/com/pingidentity/samples/pingsampleapp/davinci/collector/Agreement.kt
  • samples/pingsampleapp/src/main/java/com/pingidentity/samples/pingsampleapp/davinci/collector/DaVinciContinueNode.kt
✅ Files skipped from review due to trivial changes (3)
  • davinci/README.md
  • samples/pingsampleapp/src/main/java/com/pingidentity/samples/pingsampleapp/davinci/collector/Agreement.kt
  • samples/app/src/main/java/com/pingidentity/samples/app/davinci/collector/Agreement.kt
🚧 Files skipped from review as they are similar to previous changes (3)
  • samples/pingsampleapp/src/main/java/com/pingidentity/samples/pingsampleapp/davinci/collector/DaVinciContinueNode.kt
  • davinci/src/main/kotlin/com/pingidentity/davinci/CollectorRegistry.kt
  • davinci/src/test/kotlin/com/pingidentity/davinci/AgreementCollectorTest.kt

📝 Walkthrough

Walkthrough

Adds a new AgreementCollector type (implementation, factory registration, and tests) and integrates its UI rendering into two sample apps; documentation updated to list the new collector.

Changes

Cohort / File(s) Summary
Core Collector
davinci/src/main/kotlin/com/pingidentity/davinci/collector/AgreementCollector.kt
New AgreementCollector class implementing Collector<Nothing> with read-only properties parsed from JSON and id() override.
Factory & Docs
davinci/src/main/kotlin/com/pingidentity/davinci/CollectorRegistry.kt, davinci/README.md
Registered AgreementCollector in the collector factory (key: "READ_ONLY_TEXT") and updated README to list AgreementCollector.
Tests
davinci/src/test/kotlin/com/pingidentity/davinci/AgreementCollectorTest.kt
Added tests verifying full and empty JSON initialization, property values, defaults, and id() behavior.
Sample UI — App
samples/app/src/main/java/com/pingidentity/samples/app/davinci/collector/Agreement.kt, samples/app/src/main/java/com/pingidentity/samples/app/davinci/collector/ContinueNode.kt
Added Agreement composable and integrated rendering for AgreementCollector in ContinueNode.
Sample UI — PingSampleApp
samples/pingsampleapp/src/main/java/com/pingidentity/samples/pingsampleapp/davinci/collector/Agreement.kt, samples/pingsampleapp/src/main/java/com/pingidentity/samples/pingsampleapp/davinci/collector/DaVinciContinueNode.kt
Added Agreement composable and integrated rendering for AgreementCollector in DaVinciContinueNode.

Sequence Diagram(s)

sequenceDiagram
    participant ContinueNode as ContinueNode
    participant Collector as AgreementCollector
    participant UI as Agreement Composable
    participant User

    ContinueNode->>Collector: Receive collector instance
    ContinueNode->>ContinueNode: Check type (AgreementCollector?)
    alt AgreementCollector
        ContinueNode->>UI: Call Agreement(collector)
        UI->>UI: Read properties (titleEnabled, title, content, etc.)
        alt titleEnabled && title != ""
            UI->>User: Render title
        end
        UI->>User: Render scrollable agreement content
    else Other collector
        ContinueNode->>User: Render other collector UI
    end
    User->>UI: View content
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • spetrov
  • george-bafaloukas-forgerock
  • vahancouver
  • rodrigoareis

Poem

🐰 I hopped a patch and found a new friend to show,
An Agreement that scrolls where the text will flow,
From registry to samples it gleefully springs,
Titles and content and tiny checkbox things—
Hop on, review, let the UI glow! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: implementing AgreementCollector for DaVinci forms with clear purpose (Terms of Service and agreement displays).
Description check ✅ Passed The description includes the required JIRA ticket link and a comprehensive overview of all key changes made, with sufficient detail for reviewers.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch SDKS-4927

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@davinci/README.md`:
- Around line 108-109: The markdown line listing collectors has an unclosed
inline code span around AgreementCollector which breaks rendering; edit the
sentence containing `LabelCollector`, `MultiSelectCollector`,
`SingleSelectCollector`, `AgreementCollector` and close the backtick after
AgreementCollector so each collector name is wrapped in matching backticks
(e.g., `AgreementCollector`) and the rest of the sentence reads normally to
restore proper inline code formatting.

In
`@davinci/src/main/kotlin/com/pingidentity/davinci/collector/AgreementCollector.kt`:
- Around line 109-112: The fields agreementId and useDynamicAgreement retain
stale values when input lacks AGREEMENT because they are only set inside the
agreement let-block; before parsing the nested agreement in the init()/parsing
routine, explicitly reset agreementId to "" and useDynamicAgreement to false (or
their intended defaults) so missing agreement clears previous values; update the
logic in AgreementCollector (the block referencing input[AGREEMENT]?.jsonObject
and the properties agreementId and useDynamicAgreement) to assign defaults
first, then parse and override when agreement exists.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 11691ca5-8eb6-4ac5-9606-3cfb187efcca

📥 Commits

Reviewing files that changed from the base of the PR and between 6bc1efa and 5e653df.

📒 Files selected for processing (8)
  • davinci/README.md
  • davinci/src/main/kotlin/com/pingidentity/davinci/CollectorRegistry.kt
  • davinci/src/main/kotlin/com/pingidentity/davinci/collector/AgreementCollector.kt
  • davinci/src/test/kotlin/com/pingidentity/davinci/AgreementCollectorTest.kt
  • samples/app/src/main/java/com/pingidentity/samples/app/davinci/collector/Agreement.kt
  • samples/app/src/main/java/com/pingidentity/samples/app/davinci/collector/ContinueNode.kt
  • samples/pingsampleapp/src/main/java/com/pingidentity/samples/pingsampleapp/davinci/collector/Agreement.kt
  • samples/pingsampleapp/src/main/java/com/pingidentity/samples/pingsampleapp/davinci/collector/DaVinciContinueNode.kt

Comment thread davinci/README.md Outdated
Comment on lines +109 to +112
input[AGREEMENT]?.jsonObject?.let { agreement ->
agreementId = agreement[ID]?.jsonPrimitive?.content ?: ""
useDynamicAgreement = agreement[USE_DYNAMIC_AGREEMENT]?.jsonPrimitive?.boolean ?: false
}
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot Apr 14, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Reset nested agreement defaults before conditional parse.

agreementId and useDynamicAgreement are only assigned when agreement exists. On repeated init() calls, missing agreement can retain stale prior values.

Proposed fix
+        agreementId = ""
+        useDynamicAgreement = false
         input[AGREEMENT]?.jsonObject?.let { agreement ->
             agreementId = agreement[ID]?.jsonPrimitive?.content ?: ""
             useDynamicAgreement = agreement[USE_DYNAMIC_AGREEMENT]?.jsonPrimitive?.boolean ?: false
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@davinci/src/main/kotlin/com/pingidentity/davinci/collector/AgreementCollector.kt`
around lines 109 - 112, The fields agreementId and useDynamicAgreement retain
stale values when input lacks AGREEMENT because they are only set inside the
agreement let-block; before parsing the nested agreement in the init()/parsing
routine, explicitly reset agreementId to "" and useDynamicAgreement to false (or
their intended defaults) so missing agreement clears previous values; update the
logic in AgreementCollector (the block referencing input[AGREEMENT]?.jsonObject
and the properties agreementId and useDynamicAgreement) to assign defaults
first, then parse and override when agreement exists.

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.

Since this is an AgreementCollector the purpose is to receive the agreement.

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.

@vibhorgoswami, that's a fair point — if AgreementCollector is always initialized with a JSON payload that includes the agreement field (which is part of its expected contract), then the stale-value concern on repeated init() calls doesn't apply in practice. I'll defer to your design intent here.

🐰 hops away quietly

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 14, 2026

Codecov Report

❌ Patch coverage is 57.14286% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 44.06%. Comparing base (4351962) to head (39e6d86).
⚠️ Report is 3 commits behind head on develop.

Files with missing lines Patch % Lines
...ngidentity/davinci/collector/AgreementCollector.kt 55.00% 0 Missing and 9 partials ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop     #182      +/-   ##
=============================================
+ Coverage      44.03%   44.06%   +0.02%     
- Complexity      1233     1250      +17     
=============================================
  Files            306      307       +1     
  Lines           9250     9271      +21     
  Branches        1321     1329       +8     
=============================================
+ Hits            4073     4085      +12     
  Misses          4638     4638              
- Partials         539      548       +9     
Flag Coverage Δ
integration-tests 28.50% <4.76%> (-0.07%) ⬇️
unit-tests 25.12% <57.14%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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 on lines +109 to +112
input[AGREEMENT]?.jsonObject?.let { agreement ->
agreementId = agreement[ID]?.jsonPrimitive?.content ?: ""
useDynamicAgreement = agreement[USE_DYNAMIC_AGREEMENT]?.jsonPrimitive?.boolean ?: false
}
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.

Since this is an AgreementCollector the purpose is to receive the agreement.

… Terms of Service and agreement displays

Key changes:
- Created `AgreementCollector` to handle `AGREEMENT` type form fields, supporting properties like `content`, `title`, and `agreementId`.
- Registered `AgreementCollector` in `CollectorRegistry` using the `READ_ONLY_TEXT` factory key.
- Added a scrollable `Agreement` Compose UI component to both sample applications for rendering agreement text.
- Updated `ContinueNode` in sample apps to include `AgreementCollector` in the collector dispatch logic.
- Added comprehensive unit tests in `AgreementCollectorTest.kt` to verify JSON initialization and default values.
- Updated documentation in `davinci/README.md` to include `AgreementCollector` in the list of available collectors.
Copy link
Copy Markdown
Contributor

@spetrov spetrov left a comment

Choose a reason for hiding this comment

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

LGTM! 👍🏻

Copy link
Copy Markdown
Contributor

@spetrov spetrov left a comment

Choose a reason for hiding this comment

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

LGTM! 👍🏻

@spetrov spetrov merged commit 19ae5fa into develop May 4, 2026
34 of 36 checks passed
@spetrov spetrov deleted the SDKS-4927 branch May 4, 2026 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants