Skip to content

Next release#1708

Merged
jokob-sk merged 4 commits into
mainfrom
next_release
Jul 9, 2026
Merged

Next release#1708
jokob-sk merged 4 commits into
mainfrom
next_release

Conversation

@jokob-sk

@jokob-sk jokob-sk commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Email notifications now include a preheader preview token for better inbox display, generated from the first few table rows.
  • Bug Fixes

    • Adjusted dashboard/device page spacing and help/icon alignment for a cleaner layout.
    • Updated loading skeleton spacing and margins to better match the final rendered UI.
  • Internal

    • Reduced logging verbosity and updated notification template tests to reflect the enhanced notification generation output.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: de1380df-8ab9-48a3-9b56-b569876a42b1

📥 Commits

Reviewing files that changed from the base of the PR and between 88ab7db and 11b27b1.

📒 Files selected for processing (1)
  • front/report_templates/report_template.html

📝 Walkthrough

Walkthrough

This PR adds notification email preheader generation, updates notification tests and template wiring, lowers several log levels across workflow/reporting code, removes device-history debug output, and adjusts device page and loading skeleton CSS spacing.

Changes

Notification Preheader Preview

Layer / File(s) Summary
PREHEADER placeholder in template
front/report_templates/report_template.html
Adds a hidden PREHEADER placeholder token to the email template.
build_preheader helper and return value
server/models/notification_instance.py
Adds build_preheader(tableTitle, jsn, headers) and returns preheader_preview as a third value from construct_notifications(), including the empty-section path.
NotificationInstance.create wiring
server/models/notification_instance.py
Collects per-section preheaders and replaces PREHEADER in mail_html with the joined preview string.
Test updates for three-value return
test/backend/test_notification_templates.py
Updates construct_notifications() call sites to unpack the third return value and adds an empty-string assertion for the empty-section case.

Log Level Downgrades

Layer / File(s) Summary
Workflow engine logging levels
server/workflows/conditions.py, server/workflows/manager.py, server/workflows/triggers.py
Changes condition, workflow, action-target, and trigger/query diagnostic logs to trace level without changing control flow.
Reporting, history, and plugin logging levels
server/messaging/reporting.py, server/models/device_history_instance.py, front/plugins/unifi_api_import/unifi_api_import.py
Lowers notification SQL logging to trace, removes verbose history debug logs, and changes UniFi API response logs to trace with indented JSON.

Device Page and Skeleton Styling

Layer / File(s) Summary
Help icons and device panel padding
front/css/app.css
Adjusts calendar and plugins help icon offsets, adds padding for device panels, and updates change-log/history/tab-content styling.
Loading skeleton spacing
front/css/app.css
Removes negative margins from skeleton panes and session/event/presence tabs while keeping padding-based layout.

Sequence Diagram(s)

sequenceDiagram
  participant NotificationInstance
  participant NotificationsBuilder
  participant EmailTemplate
  NotificationInstance->>NotificationsBuilder: build preheader preview text
  NotificationsBuilder->>NotificationInstance: return html, text, preheader_preview
  NotificationInstance->>EmailTemplate: replace PREHEADER placeholder
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 32.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is too generic and does not describe the actual changes in this pull request. Use a specific title that summarizes the main change, such as adding email preheaders and adjusting logging levels.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch next_release

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.

@coderabbitai coderabbitai Bot left a comment

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.

🧹 Nitpick comments (2)
test/backend/test_notification_templates.py (2)

97-97: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Unused preheader_preview variable triggers Ruff RUF059.

preheader_preview is unpacked but never used in this test. Use _ to suppress the warning and match the pattern used by other tests.

♻️ Proposed fix
-        html, text, preheader_preview = construct_notifications(json_data, "new_devices")
+        html, text, _ = construct_notifications(json_data, "new_devices")
🤖 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 `@test/backend/test_notification_templates.py` at line 97, The unpacking in the
test that calls construct_notifications for "new_devices" binds
preheader_preview but never uses it, triggering Ruff RUF059. Update the
assignment to ignore that value with a placeholder like _ so the test matches
the existing unpacking style used elsewhere and removes the unused variable
warning.

Source: Linters/SAST tools


97-97: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

No test asserts on preheader_preview content for non-empty sections.

All tests that unpack the third return value either ignore it (_) or only assert it's empty. Consider adding a test that verifies build_preheader produces the expected preview string (e.g., title prefix, first-three-rows/cols, (+N more) suffix).

♻️ Suggested test addition
`@patch`("models.notification_instance.get_setting_value")
def test_preheader_preview_content(self, mock_setting):
    from models.notification_instance import construct_notifications

    mock_setting.side_effect = self._setting_factory({
        "NTFPRCS_TEXT_SECTION_HEADERS": True,
        "NTFPRCS_TEXT_TEMPLATE_new_devices": "",
    })
    json_data = _make_json(
        "new_devices", SAMPLE_NEW_DEVICES, NEW_DEVICE_COLUMNS, "🆕 New devices"
    )
    _, _, preheader_preview = construct_notifications(json_data, "new_devices")

    self.assertIn("🆕 New devices:", preheader_preview)
    self.assertIn("MyPhone", preheader_preview)
    self.assertIn("Laptop", preheader_preview)
🤖 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 `@test/backend/test_notification_templates.py` at line 97, Add a test that
exercises the third return value from construct_notifications for a non-empty
section, since current coverage only checks empty or ignored previews. Use the
construct_notifications and build_preheader flow in
test_notification_templates.py to assert the preheader_preview contains the
expected title prefix and sample content (for example, the first visible
rows/columns and any (+N more) suffix when applicable). Make the new test
similar to the existing notification template tests and verify the generated
preview string directly instead of unpacking it as _.
🤖 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.

Nitpick comments:
In `@test/backend/test_notification_templates.py`:
- Line 97: The unpacking in the test that calls construct_notifications for
"new_devices" binds preheader_preview but never uses it, triggering Ruff RUF059.
Update the assignment to ignore that value with a placeholder like _ so the test
matches the existing unpacking style used elsewhere and removes the unused
variable warning.
- Line 97: Add a test that exercises the third return value from
construct_notifications for a non-empty section, since current coverage only
checks empty or ignored previews. Use the construct_notifications and
build_preheader flow in test_notification_templates.py to assert the
preheader_preview contains the expected title prefix and sample content (for
example, the first visible rows/columns and any (+N more) suffix when
applicable). Make the new test similar to the existing notification template
tests and verify the generated preview string directly instead of unpacking it
as _.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 54848eae-db39-4216-81ea-7742bfa49a74

📥 Commits

Reviewing files that changed from the base of the PR and between d2cc992 and 88ab7db.

📒 Files selected for processing (10)
  • front/css/app.css
  • front/plugins/unifi_api_import/unifi_api_import.py
  • front/report_templates/report_template.html
  • server/messaging/reporting.py
  • server/models/device_history_instance.py
  • server/models/notification_instance.py
  • server/workflows/conditions.py
  • server/workflows/manager.py
  • server/workflows/triggers.py
  • test/backend/test_notification_templates.py
💤 Files with no reviewable changes (1)
  • server/models/device_history_instance.py

@jokob-sk jokob-sk merged commit cc8788c into main Jul 9, 2026
7 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Jul 10, 2026
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