Skip to content

feat: Orbit banner warning for stale data#523

Open
rycollins wants to merge 29 commits into
mainfrom
rjc-warning-for-stale-data
Open

feat: Orbit banner warning for stale data#523
rycollins wants to merge 29 commits into
mainfrom
rjc-warning-for-stale-data

Conversation

@rycollins

Copy link
Copy Markdown
Contributor

Asana Task: 🪐 📐 Orbit banner warning for stale data

image

Add warning banner to top of page if data is stale (>3 minutes since there's been a position update).

Includes significant changes to header/sidebar alignment; changed from fixed and updated flex properties to accommodate that removal. The fixed header and sidebar created issues when content was dynamically added above it.

Checklist

  • Appearance:
    • (N/A) Light & dark mode
    • (X) Desktop & mobile sizes
  • Browsers:
    • (X) Chromium
    • ( ) Firefox
    • ( ) Safari
  • Privacy:
    • (X) Commits free of internal data
    • (X) PR description free of internal data
    • (X) Logging free of internal data
  • Tests:
    • (X) Has tests
    • ( ) Doesn't need tests
    • ( ) Tests deferred (with justification)
  • Product/Design sign off:
    • ( ) Okayed the plan for the feature (e.g. the design files, or the Asana task)
    • ( ) Reviewed the feature as implemented (e.g. on dev-green, or saw screenshots)
    • ( ) No review needed

rycollins added 24 commits June 22, 2026 15:03
… re-render shouldn't be based on all the variables within the effect
@rycollins rycollins marked this pull request as ready for review June 30, 2026 13:46
@rycollins rycollins requested a review from a team as a code owner June 30, 2026 13:46

@andrewdolce andrewdolce left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of questions, but overall looks solid!

Comment thread js/components/ladderPage/ladderPage.tsx Outdated
"flex overflow-auto transition-all duration-300 ease-in-out w-full",
sideBarSelection && "ml-80 min-[1485px]:ml-0",
"flex transition-all duration-300 ease-in-out overflow-x-auto w-full",
sideBarSelection && "min-[1485px]:ml-30",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue/suggestion: I realized in testing around that ml-30 actually isn't a value supported by tailwind by default, so this actually gets ignored. As spacing gets larger, at a certain point, it only pre-defines classes in certain increments. So either we should pick ml-32 here, or use a custom value in rem or px.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good callout. This conditional styling is actually no longer necessary since the sidebar is no longer out of the document flow; flex box should handle the re-sizing/spacing. Removed.

Comment thread js/hooks/useChannel.ts Outdated
);
}
}, [topic, event, channel, parser, RawData]);
}, [topic, event, parser, channel, RawData]);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Is there a reason this changed? It's fine either way but if this wasn't intentional maybe drop it from the PR so it doesn't pollute git blame.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, the order swapping was unintentional. Updated

Comment on lines +19 to +34
const addWarning: (warning: DataWarning) => void = (warning: DataWarning) => {
setWarnings((warnings) => {
const newSet = new Set(warnings);
newSet.add(warning);
return newSet;
});
};
const removeWarning: (warning: DataWarning) => void = (
warning: DataWarning,
) => {
setWarnings((warnings) => {
const newSet = new Set(warnings);
newSet.delete(warning);
return newSet;
});
};

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: I like that you broke this out rather than just copying the basic setter that Glides has. Seems nice that each caller doesn't need to do its own Set diff.

Comment thread js/hooks/useVehicles.ts
Comment on lines +44 to +46
// Disabling this because it's due to outdated react-hooks lint rules
// Remove when that library is updated
// eslint-disable-next-line react-hooks/exhaustive-deps

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Interesting. So this is something that is different in later versions of eslint? I see that it otherwise complains that checkForStaleData should be declared as a dependency of this useEffect. Maybe related to the use of useEffectEvent, but can you provide any context on why it shouldn't be a dependency?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has to do with useEffectEvents not being "stable" (i.e. they change on every render) so including it in the dependency array would cause it to re-fire on every render. Apparently this is an intended way of preventing an incorrect use of useEffectEvent. Newer version of ESLint will actually warn if you include it in the dependency array.

There's an explanation of the reasoning behind this here: https://react.dev/reference/react/useEffectEvent#why-are-effect-events-not-stable.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After reading through this, I think I understand and agree with the use of the effect here. From perusing eslint-plugin-react-hooks I think some of their later releases (possibly 7.1.0) address this? Unclear. In any case I'm happy with this for now until we update.

Comment thread js/hooks/useVehicles.ts
RawData: VehicleDataMessage,
defaultResult: null,
});
const checkForStaleData = useEffectEvent(() => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: I haven't personally delved into useEffectEvent, and I don't think we have examples of it being used elsewhere. Which doesn't mean that you can't/shouldn't use it here, but could you maybe explain the benefits as opposed to just putting this code directly inside the useEffect call?

@rycollins rycollins Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useEffectEvent is new in React 19 so this is also my first time using it.

As I understand it from reading the doc (https://react.dev/reference/react/useEffectEvent), useEffectEvent is for handling firing events from Effects where the functions related to that firing aren't related to the re-rendering logic of the useEffect. In this case addWarnings and setWarnings aren't related to when this useEffect should be re-triggered but would have to be wrapped in a useCallback and included in the dependency array anyway if they weren't separated out into a useEffectEvent.

Although in typing the above and thinking through this again, mostRecentTimestamp should be included in the dependency array so that we don't run into a situation where the stale data banner lingers after data starts flowing again because we're only checking every 1 minute. Will cause more renders which I was trying to avoid but it's probably the correct logic and not including it is kind of an anti-pattern that the useEffectEvent docs advises against. Will update that.

@rycollins rycollins requested a review from andrewdolce July 2, 2026 13:08
Comment thread js/hooks/useVehicles.ts
Comment on lines +44 to +46
// Disabling this because it's due to outdated react-hooks lint rules
// Remove when that library is updated
// eslint-disable-next-line react-hooks/exhaustive-deps

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After reading through this, I think I understand and agree with the use of the effect here. From perusing eslint-plugin-react-hooks I think some of their later releases (possibly 7.1.0) address this? Unclear. In any case I'm happy with this for now until we update.

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.

2 participants