SDKS-4927 Implement AgreementCollector for DaVinci forms to support Terms of Service and agreement displays#182
Conversation
|
Warning Rate limit exceeded
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 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughThe changes introduce a new Changes
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (8)
davinci/README.mddavinci/src/main/kotlin/com/pingidentity/davinci/CollectorRegistry.ktdavinci/src/main/kotlin/com/pingidentity/davinci/collector/AgreementCollector.ktdavinci/src/test/kotlin/com/pingidentity/davinci/AgreementCollectorTest.ktsamples/app/src/main/java/com/pingidentity/samples/app/davinci/collector/Agreement.ktsamples/app/src/main/java/com/pingidentity/samples/app/davinci/collector/ContinueNode.ktsamples/pingsampleapp/src/main/java/com/pingidentity/samples/pingsampleapp/davinci/collector/Agreement.ktsamples/pingsampleapp/src/main/java/com/pingidentity/samples/pingsampleapp/davinci/collector/DaVinciContinueNode.kt
| input[AGREEMENT]?.jsonObject?.let { agreement -> | ||
| agreementId = agreement[ID]?.jsonPrimitive?.content ?: "" | ||
| useDynamicAgreement = agreement[USE_DYNAMIC_AGREEMENT]?.jsonPrimitive?.boolean ?: false | ||
| } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Since this is an AgreementCollector the purpose is to receive the agreement.
There was a problem hiding this comment.
@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 Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| input[AGREEMENT]?.jsonObject?.let { agreement -> | ||
| agreementId = agreement[ID]?.jsonPrimitive?.content ?: "" | ||
| useDynamicAgreement = agreement[USE_DYNAMIC_AGREEMENT]?.jsonPrimitive?.boolean ?: false | ||
| } |
There was a problem hiding this comment.
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.
JIRA Ticket
SDKS-4927
Description
SDKS-4927 Implement
AgreementCollectorfor DaVinci forms to support Terms of Service and agreement displaysKey changes:
AgreementCollectorto handleAGREEMENTtype form fields, supporting properties likecontent,title, andagreementId.AgreementCollectorinCollectorRegistryusing theREAD_ONLY_TEXTfactory key.AgreementCompose UI component to both sample applications for rendering agreement text.ContinueNodein sample apps to includeAgreementCollectorin the collector dispatch logic.AgreementCollectorTest.ktto verify JSON initialization and default values.davinci/README.mdto includeAgreementCollectorin the list of available collectors.Summary by CodeRabbit
New Features
Tests
Documentation