Skip to content

Commit 7e104bc

Browse files
perf(web): the remote open hook compiles without manual memoization
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent a702563 commit 7e104bc

1 file changed

Lines changed: 19 additions & 20 deletions

File tree

‎apps/web/src/remoteOpen.ts‎

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
} from "@t3tools/contracts";
88
import * as Option from "effect/Option";
99
import * as Schema from "effect/Schema";
10-
import { useEffect, useMemo, useState } from "react";
10+
import { useEffect, useState } from "react";
1111

1212
import { isDesktopLocalConnectionTarget } from "~/connection/desktopLocal";
1313
import { isLoopbackHostname } from "~/environments/primary/target";
@@ -82,28 +82,27 @@ export function resolveRemoteOpenState(input: {
8282

8383
export function useRemoteOpenResolution(environmentId: EnvironmentId | null): RemoteOpenResolution {
8484
const { presentation } = useEnvironmentPresentation(environmentId);
85-
// The presentation changes with every server config push. Memoize on the
86-
// pieces read here so callers keep a stable result across provider updates.
85+
// The presentation changes with every server config push. Read only the pieces
86+
// used here so the compiler keys the result on them and callers keep a stable
87+
// result across provider updates.
8788
const entry = presentation?.entry ?? null;
8889
const remoteOpenTargets = presentation?.serverConfig?.remoteOpenTargets;
8990

90-
return useMemo(() => {
91-
if (entry === null) {
92-
return UNRESOLVED_REMOTE_OPEN;
93-
}
94-
const profile = Option.getOrNull(entry.profile);
95-
const sshAlias =
96-
profile !== null && profile._tag === "SshConnectionProfile" ? profile.target.alias : null;
97-
return {
98-
state: resolveRemoteOpenState({
99-
target: entry.target,
100-
sshAlias,
101-
remoteOpenTargets,
102-
isDesktopRenderer: window.desktopBridge !== undefined,
103-
}),
104-
isResolved: true,
105-
};
106-
}, [entry, remoteOpenTargets]);
91+
if (entry === null) {
92+
return UNRESOLVED_REMOTE_OPEN;
93+
}
94+
const profile = Option.getOrNull(entry.profile);
95+
const sshAlias =
96+
profile !== null && profile._tag === "SshConnectionProfile" ? profile.target.alias : null;
97+
return {
98+
state: resolveRemoteOpenState({
99+
target: entry.target,
100+
sshAlias,
101+
remoteOpenTargets,
102+
isDesktopRenderer: window.desktopBridge !== undefined,
103+
}),
104+
isResolved: true,
105+
};
107106
}
108107

109108
export function useRemoteOpenState(environmentId: EnvironmentId | null): RemoteOpenState {

0 commit comments

Comments
 (0)