fix(api): compute device online status in session queries#6137
Merged
gustavosbarreto merged 1 commit intomasterfrom Apr 8, 2026
Merged
fix(api): compute device online status in session queries#6137gustavosbarreto merged 1 commit intomasterfrom
gustavosbarreto merged 1 commit intomasterfrom
Conversation
|
Claude finished @luizhf42's task in 53s —— View job Code Review CompleteReviewed 4 files across code quality, security, testing, Go/TypeScript patterns, and architecture — no issues found. The code looks good as-is. The fix correctly mirrors the existing If you push additional changes and want a new review, tag |
The Device.Online field is a computed scanonly field that defaults to false when not explicitly calculated. SessionList and SessionResolve loaded devices via Relation but never computed the online status, causing it to always return false in session responses. Compute device online status in Go after loading session entities, matching the same logic used by DeviceList and DeviceResolve. Export DeviceIsOnline and DeviceOnlineThreshold so the cloud store layer can reuse them in its own session query overrides.
7b9ee5f to
66fe044
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Device online status in session list and session resolve responses now reflects actual connectivity instead of always returning false.
Why
Device.Onlineis a computedscanonlyfield that defaults to Go's zero value (false) when not explicitly calculated.DeviceListandDeviceResolvecompute it via a SQL CASE expression, butSessionListandSessionResolveload devices through bun'sRelation("Device")which never includes that expression — so every session response reported the device as offline regardless of actual state.Changes
DeviceOnlineThresholdandDeviceIsOnline— a Go-side equivalent of the existingdeviceExprOnlineSQL expression, reusable by both core and cloud store layersSessionListandSessionResolvenow computeDevice.Onlineafter loading entities, using the same disconnected_at + last_seen logic as device queriesTesting
GET /api/sessions— verifydevice.onlineistruefor the connected devicefalse