Skip to content
TypeScript

refactor(web): remove unused runtime wrappers and exports (#10225)

Julius Marmingefdcc491e0b36
diff --git a/apps/web/src/assets/assetUrls.ts b/apps/web/src/assets/assetUrls.ts
index 84ff979e4e8..5a9738c9fbf 100644
--- a/apps/web/src/assets/assetUrls.ts
+++ b/apps/web/src/assets/assetUrls.ts
@@ -32,14 +32,6 @@ export function useAssetUrlState(
);
}
-export function useAssetUrl(
- environmentId: EnvironmentId | null,
- resource: AssetResource | null,
-): string | null {
- const result = useAssetUrlState(environmentId, resource);
- return result._tag === "Success" ? result.url : null;
-}
-
export function useAssetUrlRefresh(
environmentId: EnvironmentId | null,
resource: AssetResource | null,
diff --git a/apps/web/src/assets/projectFaviconCache.ts b/apps/web/src/assets/projectFaviconCache.ts
index e6fcc817b96..b44e919af4b 100644
--- a/apps/web/src/assets/projectFaviconCache.ts
+++ b/apps/web/src/assets/projectFaviconCache.ts
@@ -46,7 +46,7 @@ async function withStore<A>(
}
/** Rasterizes a bitmap that is too large to inline, retrying at half size. */
-export async function downscaleProjectFavicon(
+async function downscaleProjectFavicon(
image: { readonly mimeType: string; readonly bytes: Uint8Array<ArrayBuffer> },
signal: AbortSignal,
) {
diff --git a/apps/web/src/cloud/connectCliAuth.ts b/apps/web/src/cloud/connectCliAuth.ts
index 815715da249..0bc65080cf8 100644
--- a/apps/web/src/cloud/connectCliAuth.ts
+++ b/apps/web/src/cloud/connectCliAuth.ts
@@ -12,7 +12,7 @@ import { hasCloudPublicConfig, resolveCloudPublicConfig, trimNonEmpty } from "./
const CONNECT_CLI_AUTH_STATE_STORAGE_KEY = "t3code-connect-cli-auth-state";
-export function resolveConnectCliOAuthClientId(): string | null {
+function resolveConnectCliOAuthClientId(): string | null {
return trimNonEmpty(import.meta.env.VITE_CLERK_CLI_OAUTH_CLIENT_ID as string | undefined);
}
diff --git a/apps/web/src/cloud/managedRelayLayer.ts b/apps/web/src/cloud/managedRelayLayer.ts
index 52f9b6496c9..b5ce11e842f 100644
--- a/apps/web/src/cloud/managedRelayLayer.ts
+++ b/apps/web/src/cloud/managedRelayLayer.ts
@@ -13,7 +13,7 @@ import {
type BrowserDpopKey,
} from "./dpop";
-export const relayDpopSignerLayer = Layer.effect(
+const relayDpopSignerLayer = Layer.effect(
ManagedRelay.ManagedRelayDpopSigner,
Effect.gen(function* () {
const crypto = yield* Crypto.Crypto;
diff --git a/apps/web/src/cloud/managedRelayState.ts b/apps/web/src/cloud/managedRelayState.ts
index 9a56bde8851..c8f33d1d9d3 100644
--- a/apps/web/src/cloud/managedRelayState.ts
+++ b/apps/web/src/cloud/managedRelayState.ts
@@ -33,7 +33,7 @@ const managedRelayAtomRuntime = Atom.runtime(
),
);
-export const managedRelayQueryManager = createManagedRelayQueryManager(managedRelayAtomRuntime);
+const managedRelayQueryManager = createManagedRelayQueryManager(managedRelayAtomRuntime);
const managedRelayMutationScheduler = createAtomCommandScheduler();
@@ -114,10 +114,3 @@ export function useManagedRelayDevices() {
refresh,
};
}
-
-export function refreshManagedRelayEnvironments(): void {
- const session = appAtomRegistry.get(managedRelaySessionAtom);
- if (session) {
- managedRelayQueryManager.refreshEnvironments(appAtomRegistry, session.accountId);
- }
-}
diff --git a/apps/web/src/cloud/primaryCloudLinkState.ts b/apps/web/src/cloud/primaryCloudLinkState.ts
index 34fdacd214a..c5871fa65d6 100644
--- a/apps/web/src/cloud/primaryCloudLinkState.ts
+++ b/apps/web/src/cloud/primaryCloudLinkState.ts
@@ -42,7 +42,7 @@ function targetKey(target: CloudLinkTarget): string {
return JSON.stringify(target);
}
-export function refreshPrimaryCloudLinkState(target: CloudLinkTarget | null): void {
+function refreshPrimaryCloudLinkState(target: CloudLinkTarget | null): void {
if (target) {
appAtomRegistry.refresh(primaryCloudLinkStateAtom(targetKey(target)));
}
diff --git a/apps/web/src/connection/desktopLocal.ts b/apps/web/src/connection/desktopLocal.ts
index c9d8b938771..d27d20e5b31 100644
--- a/apps/web/src/connection/desktopLocal.ts
+++ b/apps/web/src/connection/desktopLocal.ts
@@ -17,7 +17,7 @@ import {
* via {@link isDesktopLocalConnectionTarget}, so the convention can never drift
* between the two.
*/
-export const DESKTOP_LOCAL_CONNECTION_ID_PREFIX = "local:";
+const DESKTOP_LOCAL_CONNECTION_ID_PREFIX = "local:";
export function desktopLocalConnectionId(backendId: string): string {
return `${DESKTOP_LOCAL_CONNECTION_ID_PREFIX}${backendId}`;
diff --git a/apps/web/src/environments/primary/auth.ts b/apps/web/src/environments/primary/auth.ts
index d76002a9329..0697fa4fe65 100644
--- a/apps/web/src/environments/primary/auth.ts
+++ b/apps/web/src/environments/primary/auth.ts
@@ -9,7 +9,6 @@ import type {
} from "@t3tools/contracts";
import { EnvironmentHttpCommonError, PRIMARY_LOCAL_ENVIRONMENT_ID } from "@t3tools/contracts";
import type { EnvironmentHttpCommonError as EnvironmentHttpCommonErrorType } from "@t3tools/contracts";
-import * as DateTime from "effect/DateTime";
import * as Effect from "effect/Effect";
import * as Schema from "effect/Schema";
import { HttpClientError } from "effect/unstable/http";
@@ -66,7 +65,7 @@ export class PrimaryEnvironmentRequestError extends Schema.TaggedErrorClass<Prim
}
}
-export const isPrimaryEnvironmentRequestError = Schema.is(PrimaryEnvironmentRequestError);
+const isPrimaryEnvironmentRequestError = Schema.is(PrimaryEnvironmentRequestError);
export class PrimaryEnvironmentPairingCredentialRejectedError extends Schema.TaggedErrorClass<PrimaryEnvironmentPairingCredentialRejectedError>()(
"PrimaryEnvironmentPairingCredentialRejectedError",
@@ -96,10 +95,6 @@ export class PrimaryEnvironmentAuthSessionTimeoutError extends Schema.TaggedErro
}
}
-export const isPrimaryEnvironmentAuthSessionTimeoutError = Schema.is(
- PrimaryEnvironmentAuthSessionTimeoutError,
-);
-
export class PrimaryEnvironmentPairingCredentialRequiredError extends Schema.TaggedErrorClass<PrimaryEnvironmentPairingCredentialRequiredError>()(
"PrimaryEnvironmentPairingCredentialRequiredError",
{
@@ -111,10 +106,6 @@ export class PrimaryEnvironmentPairingCredentialRequiredError extends Schema.Tag
}
}
-export const isPrimaryEnvironmentPairingCredentialRequiredError = Schema.is(
- PrimaryEnvironmentPairingCredentialRequiredError,
-);
-
const isEnvironmentHttpCommonError = Schema.is(EnvironmentHttpCommonError);
export interface ServerPairingLinkRecord {
@@ -386,44 +377,6 @@ export async function createServerPairingCredential(input?: {
}
}
-export async function listServerPairingLinks(): Promise<ReadonlyArray<ServerPairingLinkRecord>> {
- try {
- const pairingLinks = await runPrimaryHttp(
- PrimaryEnvironmentHttpClient.pipe(
- Effect.flatMap((client) => client.auth.pairingLinks({ headers: {} })),
- ),
- );
- return pairingLinks.map((pairingLink) => {
- const timestamps = {
- createdAt: DateTime.formatIso(pairingLink.createdAt),
- expiresAt: DateTime.formatIso(pairingLink.expiresAt),
- };
- if (pairingLink.label === undefined) {
- return {
- id: pairingLink.id,
- scopes: pairingLink.scopes,
- subject: pairingLink.subject,
- createdAt: timestamps.createdAt,
- expiresAt: timestamps.expiresAt,
- };
- }
- return {
- id: pairingLink.id,
- scopes: pairingLink.scopes,
- subject: pairingLink.subject,
- label: pairingLink.label,
- createdAt: timestamps.createdAt,
- expiresAt: timestamps.expiresAt,
- };
- });
- } catch (error) {
- throw PrimaryEnvironmentRequestError.fromCause({
- operation: "list-pairing-links",
- cause: error,
- });
- }
-}
-
export async function revokeServerPairingLink(id: string): Promise<void> {
try {
await runPrimaryHttp(
@@ -440,38 +393,6 @@ export async function revokeServerPairingLink(id: string): Promise<void> {
}
}
-export async function listServerClientSessions(): Promise<
- ReadonlyArray<ServerClientSessionRecord>
-> {
- try {
- const clientSessions = await runPrimaryHttp(
- PrimaryEnvironmentHttpClient.pipe(
- Effect.flatMap((client) => client.auth.clients({ headers: {} })),
- ),
- );
- return clientSessions.map((clientSession) => ({
- sessionId: clientSession.sessionId,
- subject: clientSession.subject,
- scopes: clientSession.scopes,
- method: clientSession.method,
- client: clientSession.client,
- issuedAt: DateTime.formatIso(clientSession.issuedAt),
- expiresAt: DateTime.formatIso(clientSession.expiresAt),
- lastConnectedAt:
- clientSession.lastConnectedAt === null
- ? null
- : DateTime.formatIso(clientSession.lastConnectedAt),
- connected: clientSession.connected,
- current: clientSession.current,
- }));
- } catch (error) {
- throw PrimaryEnvironmentRequestError.fromCause({
- operation: "list-client-sessions",
- cause: error,
- });
- }
-}
-
export async function revokeServerClientSession(sessionId: AuthSessionId): Promise<void> {
try {
await runPrimaryHttp(
@@ -531,16 +452,6 @@ export async function resolveInitialServerAuthGateState(): Promise<ServerAuthGat
});
}
-// Used by the WSL backend swap: invalidate the cached authenticated state
-// (the new backend signs sessions with a different key) and re-bootstrap
-// against the desktop bootstrap credential so the next WS reconnect doesn't
-// hit 401 and start a reauth loop in the renderer.
-export async function reauthenticatePrimaryEnvironment(): Promise<ServerAuthGateState> {
- resolvedAuthenticatedGateState = null;
- bootstrapPromise = null;
- return resolveInitialServerAuthGateState();
-}
-
export function __resetServerAuthBootstrapForTests() {
bootstrapPromise = null;
resolvedAuthenticatedGateState = null;
diff --git a/apps/web/src/environments/primary/context.ts b/apps/web/src/environments/primary/context.ts
index 48017ac29e3..4bc4cb9f668 100644
--- a/apps/web/src/environments/primary/context.ts
+++ b/apps/web/src/environments/primary/context.ts
@@ -54,7 +54,7 @@ async function fetchPrimaryEnvironmentDescriptor(): Promise<ExecutionEnvironment
});
}
-export function readPrimaryEnvironmentDescriptor(): ExecutionEnvironmentDescriptor | null {
+function readPrimaryEnvironmentDescriptor(): ExecutionEnvironmentDescriptor | null {
return primaryEnvironmentDescriptor;
}
diff --git a/apps/web/src/environments/primary/index.ts b/apps/web/src/environments/primary/index.ts
index e9b15527ea5..7f8668d20d4 100644
--- a/apps/web/src/environments/primary/index.ts
+++ b/apps/web/src/environments/primary/index.ts
@@ -1,27 +1,16 @@
export {
getPrimaryKnownEnvironment,
- readPrimaryEnvironmentDescriptor,
resetPrimaryEnvironmentDescriptorForTests,
resolveInitialPrimaryEnvironmentDescriptor,
writePrimaryEnvironmentDescriptor,
} from "./context";
-export {
- resolveInitialPrimaryEnvironmentDescriptor as ensurePrimaryEnvironmentReady,
- writePrimaryEnvironmentDescriptor as updatePrimaryEnvironmentDescriptor,
-} from "./context";
-
export {
createServerPairingCredential,
- fetchSessionState,
isPrimaryEnvironmentPairingCredentialRejectedError,
- isPrimaryEnvironmentRequestError,
- listServerClientSessions,
- listServerPairingLinks,
peekPairingTokenFromUrl,
PrimaryEnvironmentPairingCredentialRejectedError,
PrimaryEnvironmentRequestError,
- reauthenticatePrimaryEnvironment,
resolveInitialServerAuthGateState,
revokeOtherServerClientSessions,
revokeServerClientSession,
@@ -34,9 +23,7 @@ export {
__resetServerAuthBootstrapForTests,
} from "./auth";
-export { refreshPrimarySessionState, usePrimarySessionState } from "./sessionState";
-
-export { PrimaryEnvironmentHttpClient } from "./httpClient";
+export { usePrimarySessionState } from "./sessionState";
export {
DesktopEnvironmentBootstrapIncompleteError,
diff --git a/apps/web/src/environments/primary/sessionState.ts b/apps/web/src/environments/primary/sessionState.ts
index 9312646cc32..971f6811b8e 100644
--- a/apps/web/src/environments/primary/sessionState.ts
+++ b/apps/web/src/environments/primary/sessionState.ts
@@ -14,7 +14,7 @@ const primarySessionStateAtom = Atom.make(Effect.promise(fetchSessionState)).pip
Atom.withLabel("primary-environment:session"),
);
-export function refreshPrimarySessionState(): void {
+function refreshPrimarySessionState(): void {
appAtomRegistry.refresh(primarySessionStateAtom);
}
diff --git a/apps/web/src/lib/runtime.ts b/apps/web/src/lib/runtime.ts
index 3836d2a3916..754d3825bc5 100644
--- a/apps/web/src/lib/runtime.ts
+++ b/apps/web/src/lib/runtime.ts
@@ -31,8 +31,6 @@ type RuntimeLayerSource =
| typeof relayTracingLayer
| ReturnType<typeof managedRelayClientLayer>;
-export const remoteHttpRuntime = ManagedRuntime.make(httpClientLayer);
-
const primaryHttpRuntime = ManagedRuntime.make(
PrimaryEnvironmentHttpClient.layer.pipe(Layer.provide(primaryEnvironmentHttpLayer)),
);
diff --git a/apps/web/src/observability/clientTracing.ts b/apps/web/src/observability/clientTracing.ts
index 95d390b9002..81cd18e207d 100644
--- a/apps/web/src/observability/clientTracing.ts
+++ b/apps/web/src/observability/clientTracing.ts
@@ -41,15 +41,6 @@ export interface ClientTracingConfig {
readonly exportIntervalMs?: number;
}
-export const ClientTracingLive = Layer.succeed(
- Tracer.Tracer,
- Tracer.make({
- span(options) {
- return activeDelegate?.span(options) ?? new Tracer.NativeSpan(options);
- },
- }),
-);
-
export function configureClientTracing(config: ClientTracingConfig = {}): Promise<void> {
if (config.exportIntervalMs === undefined && activeConfigKey !== null) {
return pendingConfiguration;
diff --git a/apps/web/src/rpc/requestLatencyState.ts b/apps/web/src/rpc/requestLatencyState.ts
index 9015a3c40b0..2731efecfc8 100644
--- a/apps/web/src/rpc/requestLatencyState.ts
+++ b/apps/web/src/rpc/requestLatencyState.ts
@@ -112,7 +112,7 @@ export function acknowledgeRpcRequest(requestId: string): void {
setSlowRpcAckRequests(slowRequests.filter((request) => request.requestId !== requestId));
}
-export function clearAllTrackedRpcRequests(): void {
+function clearAllTrackedRpcRequests(): void {
for (const pending of pendingRpcAckRequests.values()) {
clearTimeout(pending.timeoutId);
}
diff --git a/apps/web/src/rpc/transportError.ts b/apps/web/src/rpc/transportError.ts
index 493de5f93bd..7d0e4777a3a 100644
--- a/apps/web/src/rpc/transportError.ts
+++ b/apps/web/src/rpc/transportError.ts
@@ -1,4 +1 @@
-export {
- isTransportConnectionErrorMessage,
- sanitizeThreadErrorMessage,
-} from "@t3tools/client-runtime/errors";
+export { sanitizeThreadErrorMessage } from "@t3tools/client-runtime/errors";
diff --git a/apps/web/src/state/entities.ts b/apps/web/src/state/entities.ts
index c44c5b437b6..deb4948a0f5 100644
--- a/apps/web/src/state/entities.ts
+++ b/apps/web/src/state/entities.ts
@@ -39,7 +39,7 @@ const EMPTY_THREAD_STATUS_ATOM = Atom.make<EnvironmentThreadStatus>("empty").pip
Atom.withLabel("web-thread-status:empty"),
);
-export const activeEnvironmentIdAtom = Atom.make<EnvironmentId | null>(null).pipe(
+const activeEnvironmentIdAtom = Atom.make<EnvironmentId | null>(null).pipe(
Atom.keepAlive,
Atom.withLabel("web-active-environment-id"),
);
diff --git a/apps/web/src/state/environments.ts b/apps/web/src/state/environments.ts
index 443e99b84cd..f085075fdd7 100644
--- a/apps/web/src/state/environments.ts
+++ b/apps/web/src/state/environments.ts
@@ -11,7 +11,6 @@ import { useMemo } from "react";
import { environmentCatalog } from "../connection/catalog";
import { environmentPresentations, useEnvironmentPresentation } from "./presentation";
import { primaryEnvironmentIdAtom } from "./primaryEnvironment";
-import { useEnvironmentQuery } from "./query";
import { relayEnvironmentDiscovery } from "./relay";
import { usePreparedConnection } from "./session";
@@ -85,7 +84,3 @@ export function useEnvironmentHttpBaseUrl(environmentId: EnvironmentId | null):
export function useRelayEnvironmentDiscovery(): Discovery.RelayEnvironmentDiscoveryState {
return useAtomValue(relayEnvironmentDiscovery.stateValueAtom);
}
-
-export function useEnvironmentConnectionState(environmentId: EnvironmentId) {
- return useEnvironmentQuery(environmentCatalog.stateAtom(environmentId));
-}
diff --git a/apps/web/src/state/queries.ts b/apps/web/src/state/queries.ts
index 094db94c4dc..1792c5e9e59 100644
--- a/apps/web/src/state/queries.ts
+++ b/apps/web/src/state/queries.ts
@@ -14,7 +14,6 @@ import type {
OrchestrationThread,
ProjectContentMatch,
ProjectEntryKind,
- ThreadId,
VcsListRefsResult,
VcsRef,
} from "@t3tools/contracts";
@@ -28,7 +27,6 @@ import { orchestrationEnvironment } from "./orchestration";
import { isPaginatedBranchesNextPagePending } from "./paginatedBranches";
import { projectContentSearch, projectEnvironment } from "./projects";
import { useEnvironmentQuery } from "./query";
-import { useEnvironmentThread } from "./threads";
import { vcsEnvironment } from "./vcs";
const PROJECT_PATH_SEARCH_DEBOUNCE_MS = 120;
@@ -103,35 +101,6 @@ export function useThreadSearch(
};
}
-export function useThreadDetail(
- environmentId: EnvironmentId | null,
- threadId: ThreadId | null,
-): ThreadDetailView {
- const state = useEnvironmentThread(environmentId, threadId);
- return {
- data: Option.getOrNull(state.data),
- error: Option.getOrNull(state.error),
- isPending: state.status === "synchronizing",
- isDeleted: state.status === "deleted",
- };
-}
-
-export function useBranches(target: VcsRefTarget) {
- const query = target.query?.trim() ?? "";
- return useEnvironmentQuery(
- target.environmentId !== null && target.cwd !== null
- ? vcsEnvironment.listRefs({
- environmentId: target.environmentId,
- input: {
- cwd: target.cwd,
- ...(query.length > 0 ? { query } : {}),
- limit: VCS_REF_LIST_LIMIT,
- },
- })
- : null,
- );
-}
-
export function usePaginatedBranches(target: VcsRefTarget) {
const query = target.query?.trim() ?? "";
const targetKey =
diff --git a/apps/web/src/state/server.ts b/apps/web/src/state/server.ts
index 31b9436621c..f13965e5b4d 100644
--- a/apps/web/src/state/server.ts
+++ b/apps/web/src/state/server.ts
@@ -50,7 +50,7 @@ const EMPTY_PRIMARY_SERVER_STATE: PrimaryServerState = {
welcome: null,
};
-export const primaryServerStateAtom = Atom.make((get): PrimaryServerState => {
+const primaryServerStateAtom = Atom.make((get): PrimaryServerState => {
const environmentId = get(primaryEnvironmentIdAtom);
if (environmentId === null) {
return EMPTY_PRIMARY_SERVER_STATE;
diff --git a/apps/web/src/state/shell.ts b/apps/web/src/state/shell.ts
index 1f88da2f971..b1719819da9 100644
--- a/apps/web/src/state/shell.ts
+++ b/apps/web/src/state/shell.ts
@@ -4,7 +4,6 @@ import {
} from "@t3tools/client-runtime/connection";
import {
createEnvironmentShellAtoms,
- createEnvironmentShellSummaryAtom,
createEnvironmentSnapshotAtom,
createShellEnvironmentAtoms,
type EnvironmentShellState,
@@ -21,10 +20,6 @@ import { isHostedStaticApp } from "../hostedPairing";
export const shellEnvironment = createShellEnvironmentAtoms(connectionAtomRuntime);
export const environmentShell = createEnvironmentShellAtoms(connectionAtomRuntime);
export const environmentSnapshotAtom = createEnvironmentSnapshotAtom(environmentShell.stateAtom);
-export const environmentShellSummaryAtom = createEnvironmentShellSummaryAtom({
- catalogValueAtom: environmentCatalog.catalogValueAtom,
- shellStateValueAtom: environmentShell.stateValueAtom,
-});
export const allEnvironmentShellsBootstrappedAtom = Atom.make((get) => {
const catalog = AsyncResult.value(get(environmentCatalog.catalogAtom));
diff --git a/apps/web/src/state/threads.ts b/apps/web/src/state/threads.ts
index fd936f99ff2..c7caaa6a35a 100644
--- a/apps/web/src/state/threads.ts
+++ b/apps/web/src/state/threads.ts
@@ -16,7 +16,7 @@ import { connectionAtomRuntime } from "../connection/runtime";
import { environmentSnapshotAtom } from "./shell";
export const threadEnvironment = createThreadEnvironmentAtoms(connectionAtomRuntime);
-export const environmentThreads = createEnvironmentThreadStateAtoms(connectionAtomRuntime);
+const environmentThreads = createEnvironmentThreadStateAtoms(connectionAtomRuntime);
export const environmentThreadDetails = createEnvironmentThreadDetailAtoms(
environmentThreads.stateAtom,
);