Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import useRobotsWithStatus from '../../hooks/useRobotsWithStatus';
import { useMethod } from '../../util/meteorUtils';
import FleetStatusComponent from './FleetStatusComponent';
import { UI_AGG_STATUS } from '../fleetFilteringUtil';
import { AGG_STATUSES_KEY } from '../../../../shared/constants';
import { AGG_STATUSES_KEY, HACK_GHOST_UPDATE_STAMP_VALUE } from '../../../../shared/constants';
import { useWidgetData } from '../../contexts/WidgetDataContext';

const FleetStatusWidgetContainer = ({
Expand Down Expand Up @@ -91,7 +91,7 @@ const FleetStatusWidgetContainer = ({
const st = status?.[attributeId];
if (st?.message) {
let { message } = st;
if (st.ts) {
if (st.ts && st.ts !== HACK_GHOST_UPDATE_STAMP_VALUE) { // ghosts: no age, see lib/status.js
message += ` (Last reported ${moment(st.ts).fromNow()})`;
}
return message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { Table, TableHead, TableSortLabel } from '@mui/material';
import { makeStyles } from 'tss-react/mui';
import { AttributeValueFormatter } from '../../../../../shared/attributes';
import { UNDEFINED_VALUE } from '../../../../../lib/util';
import { HACK_GHOST_UPDATE_STAMP_VALUE } from '../../../../../shared/constants';
import {
StyledTableBody,
StyledTableCell,
Expand Down Expand Up @@ -92,8 +93,9 @@ const KeyValueComponent = ({ customData, staleIndicator = true, now }) => {
let { ts } = kv;
const value = kv.value !== undefined ? formatter(kv.value) : UNDEFINED_VALUE;
// HACK: Timestamps may come a few secs/mins in the future due to clock differences.
if (ts > now) ts = now;
const isStale = staleIndicator && now - kv.ts > MAX_DATA_AGE;
// Ghost robots carry the sentinel timestamp, which must read as current (see lib/status.js).
if (ts > now || ts === HACK_GHOST_UPDATE_STAMP_VALUE) ts = now;
const isStale = staleIndicator && now - ts > MAX_DATA_AGE;
return (
<StyledTableRow
data-test="mc-keyvalue-widget-tablerow"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { Navigation2, Settings } from 'lucide-react';
import { useTracker } from 'meteor/react-meteor-data';
import moment from 'moment';
// ORO modules
import { ID_TYPE_ROBOT } from '../../../../shared/constants';
import { ID_TYPE_ROBOT, HACK_GHOST_UPDATE_STAMP_VALUE } from '../../../../shared/constants';
import {
ACTION_TYPES,
createInternalActionId
Expand Down Expand Up @@ -123,7 +123,9 @@ const RobotInfoButtons = (props) => {
* Returns a string indicating the elapsed time since the robot's
* last connection.
*/
const getLastSeenInterval = () => 'Last seen ' + moment(updateStamp).fromNow();
const getLastSeenInterval = () => (updateStamp === HACK_GHOST_UPDATE_STAMP_VALUE
? 'Last seen just now' // HACK: ghost robots, see lib/status.js
: 'Last seen ' + moment(updateStamp).fromNow());

/**
* Returns a string indicating the last seen time for a robot in
Expand Down
Loading