The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 23, 06:45 UTC
perf(web): resource telemetry diagnostics compile without manual memoization (#20625)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 16, 2026 at 21:59 UTC
145b15416a71b1370bf8f6ec1fe4005bcb524877
1 file changed
+80
-86
apps/web/src/components/settings/ResourceTelemetryDiagnostics.tsx
+80
-86
@@ -28,7 +28,7 @@ import type {
28
} from "@t3tools/contracts";
29
import * as DateTime from "effect/DateTime";
30
import * as Option from "effect/Option";
31
-import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from "react";
31
+import { useEffect, useRef, useState, type ReactNode } from "react";
32
import {
33
isAtomCommandInterrupted,
34
squashAtomCommandFailure,
@@ -544,11 +544,8 @@ function ProcessTable({
544
onSignal: (process: ResourceTelemetryProcess, signal: ServerProcessSignal) => void;
545
}) {
546
const [collapsed, setCollapsed] = useState<ReadonlySet<string>>(() => new Set());
547
- const visible = useMemo(
548
- () => visibleResourceTelemetryProcesses(processes, collapsed),
549
- [collapsed, processes],
550
- );
551
- const toggle = useCallback((process: ResourceTelemetryProcess) => {
547
+ const visible = visibleResourceTelemetryProcesses(processes, collapsed);
548
+ const toggle = (process: ResourceTelemetryProcess) => {
549
const identityKey = processIdentityKey(process);
550
setCollapsed((current) => {
551
const next = new Set(current);
@@ -559,7 +556,7 @@ function ProcessTable({
556
}
557
return next;
558
});
562
- }, []);
559
+ };
560
561
return (
562
<div className="border-t border-border/60">
@@ -845,92 +842,89 @@ export function ResourceTelemetryDiagnostics({
842
const snapshot = telemetry.data;
843
const allT3 = snapshot?.groups.allT3;
844
848
- const signalProcess = useCallback(
849
- async (process: ResourceTelemetryProcess, signal: ServerProcessSignal) => {
850
- const targetEnvironmentId = environmentIdRef.current;
851
- if (
852
- targetEnvironmentId === null ||
853
- !readEnvironmentScope(targetEnvironmentId, AuthEnvironmentMaintainScope)
854
- )
855
- return;
856
- const identityKey = processIdentityKey(process);
857
- if (signalingKeysRef.current.has(identityKey)) return;
858
- const nextSignalingKeys = new Set(signalingKeysRef.current).add(identityKey);
859
- signalingKeysRef.current = nextSignalingKeys;
860
- setSignalingKeys(nextSignalingKeys);
861
- const clearSignaling = () => {
862
- const next = new Set(signalingKeysRef.current);
863
- next.delete(identityKey);
864
- signalingKeysRef.current = next;
865
- setSignalingKeys(next);
866
- };
845
+ const signalProcess = async (process: ResourceTelemetryProcess, signal: ServerProcessSignal) => {
846
+ const targetEnvironmentId = environmentIdRef.current;
847
+ if (
848
+ targetEnvironmentId === null ||
849
+ !readEnvironmentScope(targetEnvironmentId, AuthEnvironmentMaintainScope)
850
+ )
851
+ return;
852
+ const identityKey = processIdentityKey(process);
853
+ if (signalingKeysRef.current.has(identityKey)) return;
854
+ const nextSignalingKeys = new Set(signalingKeysRef.current).add(identityKey);
855
+ signalingKeysRef.current = nextSignalingKeys;
856
+ setSignalingKeys(nextSignalingKeys);
857
+ const clearSignaling = () => {
858
+ const next = new Set(signalingKeysRef.current);
859
+ next.delete(identityKey);
860
+ signalingKeysRef.current = next;
861
+ setSignalingKeys(next);
862
+ };
863
868
- if (signal === "SIGKILL") {
869
- let confirmed = false;
870
- try {
871
- confirmed = await ensureLocalApi().dialogs.confirm(
872
- `Send SIGKILL to process ${process.identity.pid}? This cannot be handled by the process.`,
873
- { variant: "destructive" },
874
- );
875
- } catch (error) {
876
- clearSignaling();
877
- toastManager.add({
878
- type: "error",
879
- title: "Could not confirm signal",
880
- description: error instanceof Error ? error.message : `Failed to send ${signal}.`,
881
- });
882
- return;
883
- }
884
- if (!confirmed) {
885
- clearSignaling();
886
- return;
887
- }
864
+ if (signal === "SIGKILL") {
865
+ let confirmed = false;
866
+ try {
867
+ confirmed = await ensureLocalApi().dialogs.confirm(
868
+ `Send SIGKILL to process ${process.identity.pid}? This cannot be handled by the process.`,
869
+ { variant: "destructive" },
870
+ );
871
+ } catch (error) {
872
+ clearSignaling();
873
+ toastManager.add({
874
+ type: "error",
875
+ title: "Could not confirm signal",
876
+ description: error instanceof Error ? error.message : `Failed to send ${signal}.`,
877
+ });
878
+ return;
879
}
889
- if (
890
- environmentIdRef.current !== targetEnvironmentId ||
891
- !readEnvironmentScope(targetEnvironmentId, AuthEnvironmentMaintainScope)
892
- ) {
880
+ if (!confirmed) {
881
clearSignaling();
882
return;
883
}
896
- void signalServerProcess({
897
- environmentId: targetEnvironmentId,
898
- input: {
899
- pid: process.identity.pid,
900
- startTimeMs: process.identity.startTimeMs,
901
- signal,
902
- },
884
+ }
885
+ if (
886
+ environmentIdRef.current !== targetEnvironmentId ||
887
+ !readEnvironmentScope(targetEnvironmentId, AuthEnvironmentMaintainScope)
888
+ ) {
889
+ clearSignaling();
890
+ return;
891
+ }
892
+ void signalServerProcess({
893
+ environmentId: targetEnvironmentId,
894
+ input: {
895
+ pid: process.identity.pid,
896
+ startTimeMs: process.identity.startTimeMs,
897
+ signal,
898
+ },
899
+ })
900
+ .then((result) => {
901
+ if (result._tag === "Failure") {
902
+ if (isAtomCommandInterrupted(result)) return;
903
+ throw squashAtomCommandFailure(result);
904
+ }
905
+ if (result.value.signaled) return;
906
+ toastManager.add({
907
+ type: "error",
908
+ title: `Could not send ${signal}`,
909
+ description: Option.getOrElse(
910
+ result.value.message,
911
+ () => `Failed to send ${signal} to process ${process.identity.pid}.`,
912
+ ),
913
+ });
914
})
904
- .then((result) => {
905
- if (result._tag === "Failure") {
906
- if (isAtomCommandInterrupted(result)) return;
907
- throw squashAtomCommandFailure(result);
908
- }
909
- if (result.value.signaled) return;
910
- toastManager.add({
911
- type: "error",
912
- title: `Could not send ${signal}`,
913
- description: Option.getOrElse(
914
- result.value.message,
915
- () => `Failed to send ${signal} to process ${process.identity.pid}.`,
916
- ),
917
- });
918
- })
919
- .catch((error: unknown) => {
920
- toastManager.add({
921
- type: "error",
922
- title: `Could not send ${signal}`,
923
- description: error instanceof Error ? error.message : `Failed to send ${signal}.`,
924
- });
925
- })
926
- .finally(() => {
927
- clearSignaling();
915
+ .catch((error: unknown) => {
916
+ toastManager.add({
917
+ type: "error",
918
+ title: `Could not send ${signal}`,
919
+ description: error instanceof Error ? error.message : `Failed to send ${signal}.`,
920
});
929
- },
930
- [signalServerProcess],
931
- );
921
+ })
922
+ .finally(() => {
923
+ clearSignaling();
924
+ });
925
+ };
926
933
- const retryCollector = useCallback(() => {
927
+ const retryCollector = () => {
928
const environmentId = environmentIdRef.current;
929
if (
930
environmentId === null ||
@@ -950,7 +944,7 @@ export function ResourceTelemetryDiagnostics({
944
.finally(() => {
945
setIsRetrying(false);
946
});
953
- }, [retryTelemetry]);
947
+ };
948
949
const speedLimit = snapshot ? Option.getOrNull(snapshot.speedLimitPercent) : null;
950
const collectorNeedsRetry = shouldShowResourceMonitorRetry({