Skip to content

Feat/tos grace dialog - #1099

Open
jona159 wants to merge 8 commits into
devfrom
feat/tos-grace-dialog
Open

Feat/tos grace dialog#1099
jona159 wants to merge 8 commits into
devfrom
feat/tos-grace-dialog

Conversation

@jona159

@jona159 jona159 commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Type of Change

  • Dependency upgrade
  • Bug fix (non-breaking change)
  • Breaking change
    • e.g. a fixed bug or new feature that may break something else
  • New feature
  • Code quality improvements
    • e.g. refactoring, documentation, tests, tooling, ...

Implementation

Add dismissible Terms of Service dialog for logged-in users during the grace period. Users can review and accept the current terms immediately or postpone acceptance until their next login, while the existing mandatory flow remains active after the deadline. Dismissal is stored per ToS version in the authenticated session, and acceptance is handled through a server-side resource route. Thenow uses version 2026-09, effective from September 10, 2026, with an acceptance deadline of January 01 2027 (these parameters can be passed to the script as input arguments, so they can be adjusted).

Checklist

  • I gave this pull request a meaningful title
  • My pull request is targeting the dev branch
  • I have added documentation to my code
  • I have deleted code that I have commented out

Additional Information

  • This PR closes #

@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 37d15670-53b2-4ab7-95c4-1d5baf6a4639

📝 Summary

Summary by CodeRabbit

  • New Features
    • Added a Terms of Service update prompt during the grace period.
    • Users can review and accept updated terms or choose to be reminded later.
    • The prompt displays the acceptance deadline and prevents submission until agreement is confirmed.
    • Prompts are suppressed on relevant terms, account deletion, and logout pages.
  • Bug Fixes
    • Added clear error messaging when accepting or dismissing updated terms fails.
  • Localization
    • Added English and German translations for the new prompt and actions.

Walkthrough

Adds a grace-period Terms of Service prompt. The root loader detects pending updates, the dialog submits accept or dismiss actions, session state records dismissals, and localized copy and seed data support the flow.

Changes

Terms grace-period consent

Layer / File(s) Summary
Eligibility and dismissal state
app/root.tsx, app/services/session-service.server.ts
The root loader computes pending grace-period Terms data. Session helpers read, store, and clear dismissed version IDs.
Prompt and consent actions
app/components/tos-grace-dialog.tsx, app/routes/resources.tos-grace.ts, app/root.tsx
The application renders the localized prompt and submits validated accept or dismiss intents. The action authenticates users, checks the current Terms version, records acceptance, and sets dismissal cookies.
Localized copy and seed data
public/locales/*/tos.json, scripts/db/seed-tos.ts
Locale files add grace-period descriptions, errors, and action labels. Seed data updates the default Terms dates and version.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant TosGraceDialog
  participant TosGraceAction
  participant SessionService
  User->>TosGraceDialog: choose accept or dismiss
  TosGraceDialog->>TosGraceAction: submit intent and Terms version
  TosGraceAction->>SessionService: save acceptance or dismissal
  SessionService-->>TosGraceAction: return result or Set-Cookie
  TosGraceAction-->>TosGraceDialog: return success or error
Loading

Merge Risk: 🔵 Low · up to 2c67a

The dialog can display a grace-period deadline one calendar day earlier for some users, creating confusion about when acceptance is required. The impact is limited to deadline presentation and should be fixed or explicitly accepted.

🚥 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%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 5 files. (2 skipped: 2… 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 identifies the main change: adding a Terms of Service grace dialog.
Description check ✅ Passed The description clearly explains the dismissible Terms of Service dialog, session-based dismissal, acceptance flow, and grace-period behavior.
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 5 files. (2 skipped: 2 unsupported.)

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/tos-grace-dialog

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.

@github-actions

github-actions Bot commented Sep 10, 2026

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 65.95% 2247 / 3407
🔵 Statements 64.43% 2319 / 3599
🔵 Functions 63.26% 434 / 686
🔵 Branches 50.65% 1078 / 2128
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
scripts/db/seed-tos.ts 35.71% 60% 33.33% 35.71% 299-311, 316-318
Generated in workflow #3020 for commit 1f10c37 by the Vitest Coverage Report Action

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: ed2f5467-7506-4a1f-a503-1edbcba08c1c

📥 Commits

Reviewing files that changed from the base of the PR and between 28e2ed0 and 2c67ac7.

📒 Files selected for processing (7)
  • app/components/tos-grace-dialog.tsx
  • app/root.tsx
  • app/routes/resources.tos-grace.ts
  • app/services/session-service.server.ts
  • public/locales/de/tos.json
  • public/locales/en/tos.json
  • scripts/db/seed-tos.ts

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.

Comment thread app/root.tsx
dismissedGraceTosVersionId !== tosRequirement.tos.id
? {
id: tosRequirement.tos.id,
acceptBy: tosRequirement.acceptBy?.toISOString() ?? '',

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the configured deadline representation.
rg -n -C 4 'acceptBy|2027-01-01|2026-09' \
  scripts/db/seed-tos.ts app/db/models/tos.server.ts

# A midnight-UTC deadline renders as the prior local calendar date in US timezones.
TZ=America/New_York node - <<'NODE'
console.log(
  new Date('2027-01-01T00:00:00.000Z').toLocaleDateString('en-US', {
    dateStyle: 'long',
  }),
)
NODE

Repository: openSenseMap/frontend

Length of output: 2928


🤖 get_repo_knowledge executed:

get_repo_knowledge openSenseMap/frontend /tmp/coderabbit-repo-knowledge/opensensemap-frontend-df8e5696/architecture

Length of output: 12483


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- app/root.tsx ---'
sed -n '70,120p' app/root.tsx

printf '%s\n' '--- app/components/tos-grace-dialog.tsx ---'
sed -n '1,90p' app/components/tos-grace-dialog.tsx

printf '%s\n' '--- ToS model and schema references ---'
rg -n -C 5 'acceptBy|mustBlock|inGrace|effectiveFrom|tosVersion' app/db app routes scripts/db --glob '*.ts' --glob '*.tsx' | head -n 260

Repository: openSenseMap/frontend

Length of output: 18077


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- deadline wording and seed entrypoint ---'
rg -n -C 5 'grace_description|acceptBy|seedTos|accept by|deadline|January|Januar' \
  app scripts package.json README.md --glob '*.ts' --glob '*.tsx' --glob '*.json' --glob '*.md' \
  | head -n 260

printf '%s\n' '--- enforcement branches ---'
sed -n '1,90p' app/routes/resources.tos-grace.ts
sed -n '1,85p' app/db/models/tos.server.ts

Repository: openSenseMap/frontend

Length of output: 11411


Format the deadline in the enforcement timezone.

acceptBy is a timezone-aware instant. Enforcement compares it with now, while app/components/tos-grace-dialog.tsx formats it in the browser timezone. The default 2027-01-01T00:00:00.000Z deadline can therefore display as December 31, 2026 for users west of UTC. Format the instant in UTC, or return a date-only value when acceptBy represents a calendar date.

📍 Affects 2 files
  • app/root.tsx#L103-L103 (this comment)
  • app/components/tos-grace-dialog.tsx#L46-L48

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant