fix(web): only show auto balance errors after failed checks (#10407)
This commit is contained in:
1 parent
e15ffb9c0f
commit
2d6a379997
3 files changed
+16
-9
No files matched your search
@@ -3331,7 +3331,9 @@ export default function ChatView(props: ChatViewProps) {
|
||||
? "Auto balance"
|
||||
: loadBalancing.pending
|
||||
? "Checking machines…"
|
||||
: "Auto balance unavailable"
|
||||
: loadBalancing.failed
|
||||
? "Auto balance unavailable"
|
||||
: "Auto balance"
|
||||
: undefined;
|
||||
|
||||
// Handle environment change for draft threads. When the user picks a
|
||||
|
||||
@@ -30,21 +30,25 @@ export function useLoadBalancedEnvironment(
|
||||
resources: result._tag === "Success" ? result.value : null,
|
||||
receivedAt: result._tag === "Success" ? result.timestamp : 0,
|
||||
pending: result._tag === "Initial" || result.waiting,
|
||||
failed: result._tag === "Failure",
|
||||
};
|
||||
}),
|
||||
),
|
||||
[environmentIds],
|
||||
);
|
||||
const resources = useAtomValue(resourcesAtom);
|
||||
const pending = resources.some((resource) => resource.pending);
|
||||
const environmentId = chooseLoadBalancedEnvironment(
|
||||
resources.map((resource) => ({
|
||||
...resource,
|
||||
weight: weights[resource.environmentId] ?? 50,
|
||||
})),
|
||||
Date.now(),
|
||||
) as EnvironmentId | null;
|
||||
return {
|
||||
refresh,
|
||||
pending: resources.some((resource) => resource.pending),
|
||||
environmentId: chooseLoadBalancedEnvironment(
|
||||
resources.map((resource) => ({
|
||||
...resource,
|
||||
weight: weights[resource.environmentId] ?? 50,
|
||||
})),
|
||||
Date.now(),
|
||||
) as EnvironmentId | null,
|
||||
pending,
|
||||
environmentId,
|
||||
failed: !pending && environmentId === null && resources.some((resource) => resource.failed),
|
||||
};
|
||||
}
|
||||
@@ -1021,6 +1021,7 @@ export function createServerEnvironmentAtoms<R, E>(
|
||||
}),
|
||||
hostResources: createEnvironmentQueryAtomFamily(runtime, {
|
||||
label: "environment-data:server:host-resources",
|
||||
idleTtlMs: 0,
|
||||
staleTimeMs: 5_000,
|
||||
execute: (input: EnvironmentRpcInput<typeof WS_METHODS.serverGetHostResources>) =>
|
||||
request(WS_METHODS.serverGetHostResources, input).pipe(Effect.timeout("5 seconds")),
|
||||
|
||||
Reference in new issue
Block a user