SDKS-4927 Implement AgreementCollector for DaVinci forms to support Terms of Service and agreement displays#182
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
✅ Files skipped from review due to trivial changes (3)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughAdds 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
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.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 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
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