Skip to content

Next release#1675

Merged
jokob-sk merged 5 commits into
mainfrom
next_release
Jun 17, 2026
Merged

Next release#1675
jokob-sk merged 5 commits into
mainfrom
next_release

Conversation

@jokob-sk

@jokob-sk jokob-sk commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features
    • Workflows now support cross-device targeting via selectable strategies and configurable target conditions.
    • Action values can reference {{trigger.*}} tokens with validation during workflow loading.
  • Bug Fixes
    • Prevents cascaded re-processing when actions mutate targeted devices in the same run.
    • Safer handling for missing targets, MAC conflicts (automatic conflict archiving), and boolean field casting.
  • Documentation
    • Updated workflow UI text and examples, including a new cross-device targeting example.
  • Tests
    • Added coverage for targeting, token interpolation/validation, condition querying, boolean casting, MAC conflict behavior, and cascade prevention.
  • Chores
    • Updated repository ignore rules and expanded internal workflow documentation.

jokob-sk added 2 commits June 16, 2026 11:40
…d conflict resolution

- Added `queryByConditions` method to `DeviceInstance` for flexible device querying based on dynamic conditions.
- Introduced `interpolate_tokens` function to replace placeholders in action values with actual device data.
- Updated `UpdateFieldAction` to handle cross-device updates and archive conflicting MAC addresses.
- Implemented cascade prevention in `WorkflowManager` to avoid processing events for devices modified in the same batch.
- Added unit tests for new functionalities, including token interpolation, condition querying, and action execution.
- Created constants for device column validation to enhance security and maintainability.
- Established a structured research skill specification to guide development practices.
@coderabbitai

coderabbitai Bot commented Jun 16, 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: a7ae9ad2-970c-4944-91ff-78ce28507a6a

📥 Commits

Reviewing files that changed from the base of the PR and between 7311ed8 and 5ee3a04.

📒 Files selected for processing (1)
  • docs/WORKFLOW_EXAMPLES.md
✅ Files skipped from review due to trivial changes (1)
  • docs/WORKFLOW_EXAMPLES.md

📝 Walkthrough

Walkthrough

The PR introduces cross-device action targeting to the workflow engine. A new constants.py defines whitelisted device columns, boolean columns, and token regex. DeviceInstance gains device query helpers. actions.py adds token interpolation and extends actions to support cross-device targeting with MAC-conflict handling. WorkflowManager implements cascade prevention, token validation, and target resolution. The frontend adds UI for configuring target strategies and conditions with corresponding i18n and CSS. Tests cover all new behaviors, and examples documentation is updated.

Changes

Cross-device workflow targeting

Layer / File(s) Summary
Shared workflow constants
server/workflows/constants.py
Introduces VALID_DEVICE_COLUMNS, BOOLEAN_COLUMNS, and TOKEN_RE as the shared foundation for token validation and query safety across the workflow engine.
Device model query helpers
server/models/device_instance.py
Adds getByMac and queryByConditions to DeviceInstance, enabling MAC-based lookup and dynamic parameterized queries with field whitelisting, operator validation, and MAC normalization.
Token interpolation and cross-device action execution
server/workflows/actions.py
Adds interpolate_tokens and updates UpdateFieldAction (target device, boolean casting, MAC conflict archiving via _archive_conflicting_mac), DeleteObjectAction (target device, early exit), and RunPluginAction (db parameter).
AppEvents shared helpers
server/workflows/app_events.py
Extracts get_unprocessed and mark_processed as module-level helpers, replacing inline SQL in the manager with shared, testable functions.
WorkflowManager cascade prevention, token validation, and target resolution
server/workflows/manager.py
Adds _mutated_guids cascade-prevention state, _validate_workflow_tokens to reject invalid workflows at load time, _resolve_target_devices for triggering-device and query strategies, and reworks execute_actions, process_event, and execute_workflow to wire all new behaviors together.
Frontend target strategy UI, condition rows, and styling
front/workflowsCore.php, front/css/app.css, front/php/templates/language/en_us.json
Adds target-strategy dropdown and collapsible target-conditions sub-form for update_field/delete_device actions, createTargetConditionRow helper, add/remove condition event handlers, spinner in saveWorkflows, CSS rules for condition styling and icon sizing, and three i18n strings.
Unit tests for targeting, token handling, and cascade prevention
test/backend/test_workflows.py, test/db_test_helpers.py
Adds seven test classes covering interpolate_tokens, _validate_workflow_tokens, load_workflows rejection, queryByConditions, UpdateFieldAction boolean casting and MAC guard, and cascade prevention; adds insert_device_from_dict test helper.
Workflow examples documentation
docs/WORKFLOW_EXAMPLES.md
Updates examples with formatting adjustments and a new Example 4 demonstrating cross-device targeting with conditions and MAC conflict archiving.

AI Tooling Configuration

Layer / File(s) Summary
Gemini research skill spec and gitignore
.gemini/skills/initiative-start/reasearch-skill.md, .gitignore
Adds the NAX Research Skill workflow specification and ignores .gemini/internal-docs/PRDs/* from version control.

Sequence Diagram(s)

sequenceDiagram
  rect rgba(70, 130, 180, 0.5)
    Note over WorkflowManager: Batch start
    WorkflowManager->>WorkflowManager: get_new_app_events() — clears _mutated_guids
    WorkflowManager->>AppEvents: get_unprocessed(db)
    AppEvents-->>WorkflowManager: [event1, event2, ...]
  end

  rect rgba(60, 179, 113, 0.5)
    Note over WorkflowManager: Per-event processing
    WorkflowManager->>WorkflowManager: process_event(event)
    WorkflowManager->>WorkflowManager: skip if objectGuid in _mutated_guids
    WorkflowManager->>WorkflowManager: execute_actions(trigger_device, actions)
    WorkflowManager->>WorkflowManager: _resolve_target_devices(action, trigger_device)
    WorkflowManager->>DeviceInstance: queryByConditions(interpolated_conditions)
    DeviceInstance-->>WorkflowManager: [target_device, ...]
    WorkflowManager->>UpdateFieldAction: execute(target_device)
    UpdateFieldAction->>interpolate_tokens: resolve {{trigger.*}} in value
    interpolate_tokens-->>UpdateFieldAction: interpolated value
    UpdateFieldAction->>DeviceInstance: getByMac (MAC conflict check)
    UpdateFieldAction->>DB: UPDATE Devices SET field=value
    UpdateFieldAction-->>WorkflowManager: done
    WorkflowManager->>WorkflowManager: record devGUID in _mutated_guids
    WorkflowManager->>AppEvents: mark_processed(db, event_index)
  end
Loading

Poem

🐇 A workflow once ran on the device that triggered it,
Now it hops across the network—conditions permit!
Tokens expand, MAC conflicts retreat,
Cascade loops are stopped—quite a feat!
The rabbit stamps "CONFIRMED" and lets changes commit. ✅

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.37% 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 'Next release' is vague and does not clearly describe the specific changes in the pull request, which include cross-device workflow targeting, token interpolation, new database query helpers, and UI improvements. Replace with a more descriptive title that captures the main technical change, such as 'Add cross-device targeting and token interpolation to workflows' or 'Implement cross-device workflow actions with conditional targeting'.
✅ 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.

✏️ 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 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 and usage tips.

@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.

Actionable comments posted: 3

🤖 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 `@front/workflowsCore.php`:
- Around line 1228-1238: The saveWorkflows() function shows a spinner but only
hides it in the success callback of the $.post() call. If the POST request to
query_replace_config.php fails (network error, server error, timeout, etc.), the
hideSpinner() call on line 1236 never executes, leaving the spinner visible and
blocking user interaction. Add an error handler to the $.post() call (using
.fail() or .error()) that also calls hideSpinner() to ensure the spinner is
cleared regardless of whether the request succeeds or fails.
- Around line 328-329: The token hint is being set using the .text() method
which escapes HTML content, causing the <code> tags in the
getString("WF_Action_token_hint") translation to display as literal text rather
than formatted HTML elements. Replace the .text() method with .html() on the
$tokenHint element to properly render the HTML markup from the translation
string.

In `@test/db_test_helpers.py`:
- Around line 390-397: Add a guard check after the cols list comprehension to
handle the case where device has no keys matching db_columns. If cols is empty,
skip the cursor execute call entirely since constructing an INSERT statement
with no columns results in invalid SQL. Check the length of cols immediately
after it is populated from the device keys intersection with db_columns, and
only proceed with building and executing the INSERT statement if cols contains
at least one element.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 98a44311-cf43-44f1-b7e2-369e011f07fa

📥 Commits

Reviewing files that changed from the base of the PR and between 3e08505 and 07f566b.

📒 Files selected for processing (12)
  • .gemini/skills/initiative-start/reasearch-skill.md
  • .gitignore
  • front/css/app.css
  • front/php/templates/language/en_us.json
  • front/workflowsCore.php
  • server/models/device_instance.py
  • server/workflows/actions.py
  • server/workflows/app_events.py
  • server/workflows/constants.py
  • server/workflows/manager.py
  • test/backend/test_workflows.py
  • test/db_test_helpers.py

Comment thread front/workflowsCore.php Outdated
Comment thread front/workflowsCore.php Outdated
Comment thread test/db_test_helpers.py
@jokob-sk jokob-sk merged commit 4075aa4 into main Jun 17, 2026
6 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Jun 17, 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