Skip to content

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

Open
witrisna wants to merge 1 commit intodevelopfrom
SDKS-4927
Open

SDKS-4927 Implement AgreementCollector for DaVinci forms to support Terms of Service and agreement displays#182
witrisna wants to merge 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 a new agreement collector type for displaying user agreements in forms.
    • Implemented UI components to render agreement content with customizable titles and scrollable text areas in sample applications.
  • Tests

    • Added comprehensive test coverage for the agreement collector.
  • Documentation

    • Updated README to include the agreement collector in the list of available collectors.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 14, 2026

Warning

Rate limit exceeded

@witrisna has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 11 minutes and 36 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 11 minutes and 36 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3803a647-e565-44d5-b453-2289aaf102eb

📥 Commits

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

📒 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
📝 Walkthrough

Walkthrough

The changes introduce a new AgreementCollector type to the DaVinci framework. This includes the core collector implementation, factory registration, comprehensive test coverage, and UI rendering components integrated into two sample applications.

Changes

Cohort / File(s) Summary
Core Collector Implementation
davinci/src/main/kotlin/com/pingidentity/davinci/collector/AgreementCollector.kt
Added new AgreementCollector class implementing Collector<Nothing> with read-only properties (key, type, content, title, titleEnabled, enabled, agreementId, useDynamicAgreement) initialized from JSON input with sensible defaults.
Registry & Configuration
davinci/src/main/kotlin/com/pingidentity/davinci/CollectorRegistry.kt, davinci/README.md
Registered AgreementCollector in CollectorFactory under key "READ_ONLY_TEXT". Updated documentation to list AgreementCollector among available collectors. Updated copyright year to 2026.
Test Suite
davinci/src/test/kotlin/com/pingidentity/davinci/AgreementCollectorTest.kt
Added comprehensive test coverage validating AgreementCollector.init() with full and empty JSON payloads, confirming property population and default value handling.
UI Components — Sample 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 rendering an outlined card with optional title and scrollable content body. Integrated AgreementCollector rendering into ContinueNode via new when branch.
UI Components — 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 with identical structure for Material3 theming. Integrated AgreementCollector rendering into DaVinciContinueNode via new when branch.

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 instanceof AgreementCollector
    alt Is AgreementCollector
        ContinueNode->>UI: Call Agreement(collector)
        UI->>UI: Extract properties (title, content, etc.)
        alt titleEnabled && title.isNotEmpty()
            UI->>User: Render title
        end
        UI->>User: Render scrollable content box
    else Other collector types
        ContinueNode->>User: Render default collector UI
    end
    User->>UI: View agreement content
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A new agreement collector hops into the fray,
With scrollable content displayed in grand array,
Twin sample apps now show the field so fair,
From factory registry to UI everywhere—
DaVinci's collectors grow, what a marvelous day! 📜✨

🚥 Pre-merge checks | ✅ 2 | ❌ 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 (2 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and clearly summarizes the main change: implementing AgreementCollector for DaVinci forms to support agreement displays.
Description check ✅ Passed The description includes the required JIRA ticket link and a comprehensive description of all key changes, providing clear context for the PR.

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

✨ Finishing Touches
🧪 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

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.00%. Comparing base (a8272e6) to head (ef9936e).

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      43.98%   44.00%   +0.01%     
- Complexity      1231     1248      +17     
=============================================
  Files            306      307       +1     
  Lines           9255     9276      +21     
  Branches        1326     1334       +8     
=============================================
+ Hits            4071     4082      +11     
  Misses          4638     4638              
- Partials         546      556      +10     
Flag Coverage Δ
integration-tests 28.48% <4.76%> (-0.07%) ⬇️
unit-tests 25.09% <57.14%> (+0.06%) ⬆️

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants