Skip to content

Commit 0bc6a24

Browse files
committed
chore(web): keep unrelated endpoint status edits local
1 parent 619ded9 commit 0bc6a24

1 file changed

Lines changed: 7 additions & 16 deletions

File tree

‎apps/web/src/components/settings/TelemetryExportSettings.tsx‎

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,8 @@ const SIGNALS = [
2020

2121
type SignalKey = (typeof SIGNALS)[number]["key"];
2222

23-
/**
24-
* The latest check for a signal; it describes the field only while `url` is still its value.
25-
* `null` is in flight. "unavailable" means the server could not run it, such as an older server.
26-
*/
27-
type EndpointCheck = {
28-
readonly url: string;
29-
readonly result: OtlpEndpointCheckResult | "unavailable" | null;
30-
};
23+
/** The latest check for a signal; it describes the field only while `url` is still its value. */
24+
type EndpointCheck = { readonly url: string; readonly result: OtlpEndpointCheckResult | null };
3125

3226
const isHttpUrl = (url: string) => /^https?:\/\/./.test(url);
3327

@@ -36,7 +30,6 @@ function endpointStatus(url: string, check: EndpointCheck | undefined) {
3630
if (check?.url !== url) return { label: "Not checked", dot: "bg-muted-foreground/40" };
3731
const { result } = check;
3832
if (result === null) return { label: "Checking…", dot: "bg-warning" };
39-
if (result === "unavailable") return { label: "Couldn't check", dot: "bg-muted-foreground/40" };
4033
switch (result._tag) {
4134
case "Accepted":
4235
return { label: `Connected · ${Math.round(result.latencyMs)} ms`, dot: "bg-success" };
@@ -66,11 +59,7 @@ export function TelemetryExportSettings() {
6659
),
6760
);
6861
const updateSettings = useAtomCommand(serverEnvironment.updateSettings, { reportFailure: true });
69-
// Failures show in the status instead of a toast per field.
70-
const checkOtlpEndpoint = useAtomCommand(serverEnvironment.checkOtlpEndpoint, {
71-
reportFailure: false,
72-
reportDefect: false,
73-
});
62+
const checkOtlpEndpoint = useAtomCommand(serverEnvironment.checkOtlpEndpoint);
7463
const values = { ...saved, ...draft };
7564
const changedSignals = SIGNALS.filter(({ key }) => values[key].trim() !== saved[key]);
7665
const changed = changedSignals.length > 0;
@@ -82,8 +71,10 @@ export function TelemetryExportSettings() {
8271
// A newer check for the same field replaces this one.
8372
setChecks((previous) => {
8473
if (previous[key]?.url !== url || previous[key].result !== null) return previous;
85-
const result = response._tag === "Success" ? response.value : "unavailable";
86-
return { ...previous, [key]: { url, result } };
74+
const next = { ...previous };
75+
if (response._tag === "Success") next[key] = { url, result: response.value };
76+
else delete next[key];
77+
return next;
8778
});
8879
};
8980

0 commit comments

Comments
 (0)