fix(atlas): source tag in the telemetry footer, in place of Not polled

This commit is contained in:
MrAlders0n committed 2026-11-29 22:09:47 -05:00
1 parent cd24562821
commit 4900f5ec90
3 files changed
+47 -13

No files matched your search

+12 -6
View File
@@ -34,7 +34,7 @@ import { AccuracyChip } from "../nodes/AccuracyChip";
import { useAtlasObserver } from "./useAtlasObserver";
import type { CardHandleProps } from "./useCardDrag";
import { ViewTabs } from "./ViewTabs";
import { TelemetrySourceTag } from "../nodes/ForeignObserver";
import { TelemetrySourceTag, telemetrySourceInfo } from "../nodes/ForeignObserver";
import { allLocal } from "../nodes/poller-seats";
import { PollerClaimTags } from "../nodes/NodePollerSection";
@@ -489,6 +489,10 @@ export function AtlasCard({
const lastReading = tab.polling?.latestReadingAt ?? telSample.latestAt;
const pollerName = tab.polling?.poller?.name;
const pollState = !tab.polling ? null : polledNow ? (pollerName ? t("atlas.telemetry.polledBy", { name: pollerName }) : t("atlas.telemetry.polled")) : t("atlas.telemetry.notPolled");
// Readings from an observer this server does not manage are tagged in the footer. With nobody here polling,
// the tag stands in for "Not polled": the repeater is polled, only not by this server.
const outsideSource = tel.foreign === "all" || tel.foreign === "some";
const localSource = allLocal(tab.polling?.foreign);
const windowLabel = obs.sample.partial ? t("atlas.observerPartialCoverage") : t(`atlas.ranges.${range}`);
const observerTile = (id: ObserverTile, slot: number) => {
const sample = obs.sample;
@@ -666,15 +670,17 @@ export function AtlasCard({
)}
{view === "telemetry" && node && (
<div ref={body} className="flex flex-1 flex-col gap-3">
{(tel.foreign === "all" || tel.foreign === "some") && <div data-telemetry-source className="flex"><TelemetrySourceTag foreign={tel.foreign} local={allLocal(tab.polling?.foreign)} /></div>}
<div className="grid flex-1 grid-cols-2 gap-3">{telemetryTiles.map((id, slot) => <Fragment key={id}>{telemetryTile(id, slot)}</Fragment>)}</div>
{footer(
tab.polling
? lead(polledNow, t(polledNow ? "atlas.telemetry.polledShort" : "atlas.telemetry.notPolledShort"), polledNow ? lastReading : null)
: lastReading != null && lead(null, t("atlas.telemetry.lastReading"), lastReading),
<>
{tab.polling
? (polledNow || !outsideSource) && lead(polledNow, t(polledNow ? "atlas.telemetry.polledShort" : "atlas.telemetry.notPolledShort"), polledNow ? lastReading : null)
: lastReading != null && lead(null, t("atlas.telemetry.lastReading"), lastReading)}
{outsideSource && <span data-telemetry-source className="flex shrink-0"><TelemetrySourceTag bare foreign={tel.foreign} local={localSource} /></span>}
</>,
polledNow && pollerName ? t("atlas.telemetry.byPoller", { name: pollerName }) : "",
tel,
[pollState, lastReading != null && `${t("atlas.telemetry.lastReading")} ${formatAbsolute(lastReading)}`, t("atlas.telemetry.help")],
[(polledNow || !outsideSource) && pollState, outsideSource && t(telemetrySourceInfo(localSource)), lastReading != null && `${t("atlas.telemetry.lastReading")} ${formatAbsolute(lastReading)}`, t("atlas.telemetry.help")],
)}
</div>
)}
+11 -6
View File
@@ -10,12 +10,14 @@ import type { NodePollingForeign, TelemetryForeign } from "./types";
const TAG = "inline-flex shrink-0 items-center rounded-sm border px-1.5 py-px font-mono text-[10px] font-semibold tracking-wider uppercase";
const OUTSIDE = `${TAG} border-dashed border-text-muted/60 text-text-normal`;
// info overrides the foreign note, for a local-mode observer.
function OutsideTag({ label, info, chip = "foreign-observer" }: { label: string; info?: string; chip?: "foreign-observer" | "local-observer" }) {
// info overrides the foreign note, for a local-mode observer. bare leaves the note to a tip the row already has.
function OutsideTag({ label, info, chip = "foreign-observer", bare = false }: { label: string; info?: string; chip?: "foreign-observer" | "local-observer"; bare?: boolean }) {
const { t } = useTranslation();
const tag = <span data-chip={chip} className={OUTSIDE}>{label}</span>;
if (bare) return tag;
return (
<span className="inline-flex shrink-0 items-center gap-1">
<span data-chip={chip} className={OUTSIDE}>{label}</span>
{tag}
<InfoTip text={info ?? t("nodeDetail.foreignObserver.info")} />
</span>
);
@@ -33,13 +35,16 @@ export function LocalObserverTag({ source = false }: { source?: boolean }) {
}
// One tag for a telemetry panel, from the server's count of foreign readings behind it.
export function TelemetrySourceTag({ foreign, local = false }: { foreign: TelemetryForeign | undefined; local?: boolean }) {
export function TelemetrySourceTag({ foreign, local = false, bare = false }: { foreign: TelemetryForeign | undefined; local?: boolean; bare?: boolean }) {
const { t } = useTranslation();
if (foreign !== "all" && foreign !== "some") return null;
if (local) return <OutsideTag chip="local-observer" label={t(foreign === "all" ? "nodeDetail.foreignObserver.localSourceAll" : "nodeDetail.foreignObserver.localSourceSome")} info={t("nodeDetail.foreignObserver.localSourceInfo")} />;
return <OutsideTag label={t(foreign === "all" ? "nodeDetail.foreignObserver.sourceAll" : "nodeDetail.foreignObserver.sourceSome")} />;
if (local) return <OutsideTag bare={bare} chip="local-observer" label={t(foreign === "all" ? "nodeDetail.foreignObserver.localSourceAll" : "nodeDetail.foreignObserver.localSourceSome")} info={t("nodeDetail.foreignObserver.localSourceInfo")} />;
return <OutsideTag bare={bare} label={t(foreign === "all" ? "nodeDetail.foreignObserver.sourceAll" : "nodeDetail.foreignObserver.sourceSome")} />;
}
// What a bare source tag's row says about it in its own tip.
export const telemetrySourceInfo = (local: boolean): string => (local ? "nodeDetail.foreignObserver.localSourceInfo" : "nodeDetail.foreignObserver.info");
export function AlsoCheckedTag() {
const { t } = useTranslation();
return <span data-also-checked className={`${OUTSIDE} normal-case tracking-normal`}>{t("nodeDetail.foreignObserver.alsoChecked")}</span>;
+24 -1
View File
@@ -717,8 +717,31 @@ describe("AtlasCard", () => {
client.clear();
vi.mocked(api.getNodeTelemetry).mockResolvedValue({ ...week, foreign: "all" } as never);
mount({ view: "telemetry" });
expect(await screen.findByText("Foreign source")).toBeInTheDocument();
const tag = await screen.findByText("Foreign source");
expect(screen.getByText("4.23V")).toBeInTheDocument();
// It sits in the bottom row with the polling line, under the tiles, and that row has one info tip.
const row = tag.closest("[data-card-footer]") as HTMLElement;
expect(row).not.toBeNull();
expect(within(row).getAllByRole("button")).toHaveLength(1);
expect(within(row).getByRole("button")).toHaveTextContent(/observer this site doesn't manage/);
// Nobody here polls it, and the tag says who does: the row does not also call it not polled.
expect(within(row).queryByText("Not polled")).toBeNull();
expect(within(row).getByRole("button")).not.toHaveTextContent(/Not being polled/);
});
it("lets the source tag stand in for Not polled when nobody here polls the repeater", async () => {
vi.mocked(api.getNodePolling).mockResolvedValue(polling({ poller: null }));
const { unmount } = mount({ view: "telemetry" });
await screen.findByText("4.23V");
expect(screen.getByText("Not polled")).toBeInTheDocument();
unmount();
client.clear();
vi.mocked(api.getNodeTelemetry).mockResolvedValue({ ...week, foreign: "all" } as never);
mount({ view: "telemetry" });
const row = (await screen.findByText("Foreign source")).closest("[data-card-footer]") as HTMLElement;
expect(within(row).queryByText("Not polled")).toBeNull();
expect(within(row).getByRole("button")).not.toHaveTextContent(/Not being polled/);
expect(within(row).getByRole("button")).toHaveTextContent(/observer this site doesn't manage/);
});
it("draws two readings as dots, not a line", async () => {