Skip to content

[codex] Add subjective check-in calendar SLA#187

Merged
dzarlax merged 2 commits into
mainfrom
codex/checkin-calendar-sla
Jun 18, 2026
Merged

[codex] Add subjective check-in calendar SLA#187
dzarlax merged 2 commits into
mainfrom
codex/checkin-calendar-sla

Conversation

@dzarlax

@dzarlax dzarlax commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add tenant-scoped subjective_checkin_enabled_since for morning subjective check-in coverage.
  • Extend the admin check-in coverage API with calendar SLA rows while preserving the existing latest prompt history fields.
  • Update the admin UI to save the enabled-since date and render separate Calendar SLA and Latest prompt history sections.

Why

The previous admin view intentionally showed only actual check-in rows so early rollout days would not appear as false missing failures. Now that the flow is live, operators need an explicit enabled-since date so missing expected prompt days can indicate scheduler, webhook, or prompt delivery failures.

Details

  • GET /api/admin/checkin-coverage keeps summary and rows as actual history and adds enabled_since, sla_active, sla_summary, and sla_rows.
  • POST /api/admin/checkin-coverage saves enabled_since for the active tenant through the existing settings table.
  • Calendar SLA synthesizes missing for absent rows after enabled-since and uses pending for today when no row exists yet, avoiding premature same-day failures.
  • The implementation plan was added at docs/ai-plans/2026-06-18-checkin-calendar-sla.html and updated with implementation notes.

Validation

  • go test ./internal/storage -run "Test.*Checkin|Test.*CheckinCoverage" -count=1
  • go test ./internal/ui -run TestAdminCheckinCoverage -count=1
  • go test ./internal/ui -run "TestAdmin(CheckinCoverage|Template|Page)" -count=1
  • git diff --check

Related

Summary by CodeRabbit

  • New Features

    • Added calendar-based SLA view for check-in coverage displaying a date range of expected daily entries
    • Added admin control to configure the "enabled since" date for coverage SLA calculations
    • New "pending" status for current day when check-in is not yet answered
    • Synthesizes and displays missing check-in days in calendar view
    • Multi-language support for new UI controls
  • Tests

    • Added comprehensive test coverage for SLA synthesis and validation

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@dzarlax, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 2 minutes and 26 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5d5ccd36-4e80-4e60-92e0-95f136a40620

📥 Commits

Reviewing files that changed from the base of the PR and between 21d0747 and a875de0.

📒 Files selected for processing (7)
  • internal/storage/subjective_checkin.go
  • internal/ui/admin_checkin_coverage_test.go
  • internal/ui/handler.go
  • internal/ui/i18n_en.go
  • internal/ui/i18n_ru.go
  • internal/ui/i18n_sr.go
  • internal/ui/templates/pages/admin.html
📝 Walkthrough

Walkthrough

Adds a per-tenant subjective_checkin_enabled_since setting to the check-in storage layer, which triggers calendar-day SLA synthesis in GetCheckinCoverage. The admin API handler gains POST support to persist this setting. The admin UI is extended with an "enabled since" date control, a dual SLA/history display, new i18n strings for three locales, and CSS for the pending status pill.

Changes

Check-in Calendar SLA Feature

Layer / File(s) Summary
Storage types, constants, and DB methods for enabled-since/SLA
internal/storage/subjective_checkin.go
Adds SettingSubjectiveCheckinEnabledSince, CheckinStatusPending, extends CheckinCoverage with EnabledSince/SLAActive/SLASummary/SLARows, adds Pending to CheckinCoverageSummary, and introduces ValidateCheckinEnabledSince, GetCheckinEnabledSince, and SaveCheckinEnabledSince.
SLA calendar synthesis logic
internal/storage/subjective_checkin.go
GetCheckinCoverage reads and validates enabledSince, fetches rows for the computed calendar window, and delegates to buildCheckinCoverageWithSLA; helpers calendarCoverageStart and checkinCoverageRow synthesize day-by-day missing/pending rows and recompute SLA summary metrics.
Storage unit tests
internal/storage/subjective_checkin_test.go
Tests for buildCheckinCoverageWithSLA row synthesis/status sequencing, calendarCoverageStart clamping to enabledSince, and ValidateCheckinEnabledSince input validation.
Admin handler POST + integration tests
internal/ui/handler.go, internal/ui/admin_checkin_coverage_test.go
Handler method guard widened to GET/POST; POST branch decodes enabled_since JSON and persists it, returning 400 on errors. Integration tests cover SLA GET calendar rows/summary, valid POST persistence, and invalid POST rejection.
Admin UI template, i18n, and CSS
internal/ui/templates/pages/admin.html, internal/ui/style.go, internal/ui/i18n_en.go, internal/ui/i18n_ru.go, internal/ui/i18n_sr.go
Adds enabled-since date input + Save button, saveCheckinEnabledSince() POST function, refactored renderCheckinCoverage with dual SLA/history renderBlock sections, pending/missing status labels and CSS pill, and updated strings in all three locale files.
AI implementation plan document
docs/ai-plans/2026-06-18-checkin-calendar-sla.html
Full HTML plan documenting current/desired behavior, implementation steps, test plan, risks, rollback strategy, and the recorded implemented result.

Sequence Diagram(s)

sequenceDiagram
  participant AdminUI as Admin Browser
  participant Handler as adminCheckinCoverage
  participant DB as Storage DB
  participant SLA as buildCheckinCoverageWithSLA

  rect rgba(100, 150, 255, 0.5)
    note over AdminUI,DB: Save enabled-since (POST)
    AdminUI->>Handler: POST /api/admin/checkin-coverage {enabled_since}
    Handler->>DB: SaveCheckinEnabledSince(date)
    DB-->>Handler: ok / error
  end

  rect rgba(100, 200, 150, 0.5)
    note over AdminUI,SLA: Fetch SLA coverage (GET or after POST)
    Handler->>DB: GetCheckinEnabledSince()
    DB-->>Handler: enabledSince
    Handler->>DB: GetCheckinCoverage(today, days)
    DB->>SLA: buildCheckinCoverageWithSLA(rows, from, today)
    SLA-->>DB: SLARows + SLASummary (pending/missing synthesized)
    DB-->>Handler: CheckinCoverage {sla_active, sla_rows, sla_summary, rows, summary}
    Handler-->>AdminUI: JSON response
    AdminUI->>AdminUI: renderCheckinCoverage(d) — dual SLA/history blocks
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

  • Dzarlax-AI/health_dashboard#125: Introduced the original GetCheckinCoverage, CheckinCoverage model, and adminCheckinCoverage handler that this PR directly extends with SLA synthesis fields and POST support.
  • Dzarlax-AI/health_dashboard#126: Modified the same adminCheckinCoverage handler in internal/ui/handler.go to add tenant scope resolution, which this PR further modifies to add POST support.

Poem

🐇 Hop, hop, the calendar grows,
Each missing day now clearly shows.
enabled_since plants the start,
pending and missing — a whole new art.
The SLA view, both sharp and neat,
Makes every skipped prompt bittersweet! 🗓️

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

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.
Description check ❓ Inconclusive The PR description covers Summary, Details, Validation, and Related sections. However, it lacks explicit Privacy/Data Impact checkboxes and Evidence Boundary section required by the template. Add Privacy/Data Impact checkboxes and Evidence Boundary section to match the repository description template.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title '[codex] Add subjective check-in calendar SLA' clearly and concisely summarizes the main change: adding a calendar-day SLA view for subjective check-in prompts.
Linked Issues check ✅ Passed The PR implements all major objectives from #186: tenant-scoped enabled-since setting, calendar SLA synthesis with missing/pending rows, preserved latest history, validation, and comprehensive tests.
Out of Scope Changes check ✅ Passed All changes align with #186 requirements: storage layer adds enabled-since setting and SLA synthesis, API/UI layers support calendar view and enabled-since configuration, i18n/styling support new UI elements, and an implementation plan document was added.

✏️ 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 codex/checkin-calendar-sla

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.

@dzarlax dzarlax marked this pull request as ready for review June 18, 2026 15:18

@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: 2

🧹 Nitpick comments (2)
internal/storage/subjective_checkin.go (2)

617-638: 💤 Low value

Consider using checkinCoverageRow in buildCheckinCoverage as well.

This helper extracts the row conversion logic nicely. The same logic is duplicated inline in buildCheckinCoverage (lines 479-517). Using this helper in both places would improve consistency and reduce maintenance burden.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/storage/subjective_checkin.go` around lines 617 - 638, The
checkinCoverageRow helper function has been created to encapsulate the
conversion logic from CheckinRow to CheckinCoverageRow, but the same conversion
logic is still duplicated inline in the buildCheckinCoverage function (around
lines 479-517). Replace the duplicated row conversion logic in
buildCheckinCoverage with calls to the checkinCoverageRow helper function to
eliminate the duplication, improve consistency, and reduce maintenance burden
when this logic needs to be updated in the future.

411-445: 💤 Low value

Consider extracting the row scanning logic to reduce duplication.

The row scanning loop here (lines 424-443) is nearly identical to the one in GetCheckinCoverage (lines 371-390). Consider extracting a helper like scanCheckinRows(rows pgx.Rows) ([]CheckinRow, error) to consolidate this pattern.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/storage/subjective_checkin.go` around lines 411 - 445, Extract the
duplicate row scanning logic that appears in the getCheckinRowsBetween method
(the loop iterating through rows.Next() and populating CheckinRow fields
including handling nullable pointer fields like answer, msgID, and answeredAt)
into a separate helper function called scanCheckinRows that accepts pgx.Rows as
a parameter and returns []CheckinRow and error. Then replace the scanning loop
in both getCheckinRowsBetween and the GetCheckinCoverage method with calls to
this new helper function to eliminate the duplication.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/ui/handler.go`:
- Around line 2890-2893: The JSON decoding in the
json.NewDecoder(r.Body).Decode(&req) call lacks both request body size limiting
and strict parsing enforcement. Wrap r.Body with http.MaxBytesReader to impose a
reasonable size limit on incoming payloads, preventing memory exhaustion from
oversized requests. Additionally, enable strict JSON parsing by setting the
DisallowUnknownFields flag on the decoder instance before calling Decode to
reject partial or ambiguous JSON bodies that contain unknown fields.

In `@internal/ui/templates/pages/admin.html`:
- Around line 888-896: Replace the hardcoded English strings in the admin.html
check-in coverage fetch handler with localized strings. Specifically, replace
the progress message '...' on line 888 (the msg.textContent assignment) and the
error message 'Failed to save check-in SLA date' on line 895 with calls to
retrieve localized text using keys admin_saving and admin_checkin_save_failed
respectively. Additionally, add these two new localization keys (admin_saving
and admin_checkin_save_failed) to all three i18n files: i18n_en.go, i18n_ru.go,
and i18n_sr.go with appropriate English, Russian, and Serbian translations.

---

Nitpick comments:
In `@internal/storage/subjective_checkin.go`:
- Around line 617-638: The checkinCoverageRow helper function has been created
to encapsulate the conversion logic from CheckinRow to CheckinCoverageRow, but
the same conversion logic is still duplicated inline in the buildCheckinCoverage
function (around lines 479-517). Replace the duplicated row conversion logic in
buildCheckinCoverage with calls to the checkinCoverageRow helper function to
eliminate the duplication, improve consistency, and reduce maintenance burden
when this logic needs to be updated in the future.
- Around line 411-445: Extract the duplicate row scanning logic that appears in
the getCheckinRowsBetween method (the loop iterating through rows.Next() and
populating CheckinRow fields including handling nullable pointer fields like
answer, msgID, and answeredAt) into a separate helper function called
scanCheckinRows that accepts pgx.Rows as a parameter and returns []CheckinRow
and error. Then replace the scanning loop in both getCheckinRowsBetween and the
GetCheckinCoverage method with calls to this new helper function to eliminate
the duplication.
🪄 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 Plus

Run ID: a1028116-641f-461c-8104-bfda54e66aaf

📥 Commits

Reviewing files that changed from the base of the PR and between 566c1dc and 21d0747.

📒 Files selected for processing (10)
  • docs/ai-plans/2026-06-18-checkin-calendar-sla.html
  • internal/storage/subjective_checkin.go
  • internal/storage/subjective_checkin_test.go
  • internal/ui/admin_checkin_coverage_test.go
  • internal/ui/handler.go
  • internal/ui/i18n_en.go
  • internal/ui/i18n_ru.go
  • internal/ui/i18n_sr.go
  • internal/ui/style.go
  • internal/ui/templates/pages/admin.html

Comment thread internal/ui/handler.go Outdated
Comment thread internal/ui/templates/pages/admin.html Outdated
@dzarlax dzarlax merged commit 0b46d1e into main Jun 18, 2026
5 checks passed
@dzarlax dzarlax deleted the codex/checkin-calendar-sla branch June 18, 2026 17:14
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.

Add calendar-day SLA for subjective check-in prompts

1 participant