Skip to content

Introduce status field to Device model for better representation of state#7828

Merged
Steve-Mcl merged 1 commit into
mainfrom
7862-device-status
Jul 15, 2026
Merged

Introduce status field to Device model for better representation of state#7828
Steve-Mcl merged 1 commit into
mainfrom
7862-device-status

Conversation

@Steve-Mcl

Copy link
Copy Markdown
Contributor

Description

This pull request adds a new virtual status field to the Device model and introduces comprehensive unit tests to verify its behavior. The main goal is to provide a simple way to determine if a device is "online", "offline", or "not-seen" based on the lastSeenAt timestamp.

Device model enhancements:

  • Added a virtual status field to the Device model, which returns "not-seen" if the device has never been seen, "online" if seen within the last 30 minutes, and "offline" otherwise.

Testing improvements:

  • Added unit tests for the new status virtual field in Device_spec.js, covering all possible status values ("not-seen", "online", "offline") based on different lastSeenAt values.

Related Issue(s)

closes #7826

Checklist

  • I have read the contribution guidelines
  • Suitable unit/system level tests have been added and they pass
  • Documentation has been updated
    • Upgrade instructions
    • Configuration details
    • Concepts
  • Changes flowforge.yml?
    • Issue/PR raised on FlowFuse/helm to update ConfigMap Template
    • Issue/PR raised on FlowFuse/CloudProject to update values for Staging/Production
  • Link to Changelog Entry PR, or note why one is not needed.

Labels

  • Includes a DB migration? -> add the area:migration label

@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.10%. Comparing base (a7b9f86) to head (5cc2cee).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7828   +/-   ##
=======================================
  Coverage   75.09%   75.10%           
=======================================
  Files         430      430           
  Lines       22838    22844    +6     
  Branches     6052     6054    +2     
=======================================
+ Hits        17151    17157    +6     
  Misses       5687     5687           
Flag Coverage Δ
backend 75.10% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Steve-Mcl

Copy link
Copy Markdown
Contributor Author

odd - unrelated UI test error

  1) FlowFuse platform admin users
       can view applications and instances from teams they're not a member of:
     AssertionError: Timed out retrying after 4000ms: expected 'http://localhost:3001/team/bteam/overview' to include '/applications'
      at Context.eval (webpack:///../test/e2e/frontend/cypress/tests/admin.spec.js:78:17)

Re-running

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

Looks good to me. Good job on the new test

@knolleary

Copy link
Copy Markdown
Member

I was expecting this to include updates to the Device Views to include this new field - I assumed the MCP stuff would be accessing things via the external platform API.

If that isn't going to get covered here, please add a note to the UI issue you raised to point out the UI doesn't yet have visibility of the new field.

@Steve-Mcl

Steve-Mcl commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

I was expecting this to include updates to the Device Views to include this new field - I assumed the MCP stuff would be accessing things via the external platform API.

If that isn't going to get covered here, please add a note to the UI issue you raised to point out the UI doesn't yet have visibility of the new field.

For MCP stuff, no FE (or views) are required so no, not done in this one. I'll tip a wink to the requirement for views in the 2nd sub-task (which is small enough to be a single PR or broken down further into FE and BE tasks)

@Steve-Mcl
Steve-Mcl merged commit 00b8d9c into main Jul 15, 2026
36 of 38 checks passed
@Steve-Mcl
Steve-Mcl deleted the 7862-device-status branch July 15, 2026 14:32
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.

Computed property for device online/offline status

3 participants