Frontend Enhancements: - Complete React TypeScript frontend with modern UI components - Distributed workflows management interface with real-time updates - Socket.IO integration for live agent status monitoring - Agent management dashboard with cluster visualization - Project management interface with metrics and task tracking - Responsive design with proper error handling and loading states Backend Infrastructure: - Distributed coordinator for multi-agent workflow orchestration - Cluster management API with comprehensive agent operations - Enhanced database models for agents and projects - Project service for filesystem-based project discovery - Performance monitoring and metrics collection - Comprehensive API documentation and error handling Documentation: - Complete distributed development guide (README_DISTRIBUTED.md) - Comprehensive development report with architecture insights - System configuration templates and deployment guides The platform now provides a complete web interface for managing the distributed AI cluster with real-time monitoring, workflow orchestration, and agent coordination capabilities. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
104 lines
4.0 KiB
JavaScript
104 lines
4.0 KiB
JavaScript
"use client";
|
|
|
|
// src/useBaseQuery.ts
|
|
import * as React from "react";
|
|
import { isServer, noop, notifyManager } from "@tanstack/query-core";
|
|
import { useQueryClient } from "./QueryClientProvider.js";
|
|
import { useQueryErrorResetBoundary } from "./QueryErrorResetBoundary.js";
|
|
import {
|
|
ensurePreventErrorBoundaryRetry,
|
|
getHasError,
|
|
useClearResetErrorBoundary
|
|
} from "./errorBoundaryUtils.js";
|
|
import { useIsRestoring } from "./IsRestoringProvider.js";
|
|
import {
|
|
ensureSuspenseTimers,
|
|
fetchOptimistic,
|
|
shouldSuspend,
|
|
willFetch
|
|
} from "./suspense.js";
|
|
function useBaseQuery(options, Observer, queryClient) {
|
|
if (process.env.NODE_ENV !== "production") {
|
|
if (typeof options !== "object" || Array.isArray(options)) {
|
|
throw new Error(
|
|
'Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object'
|
|
);
|
|
}
|
|
}
|
|
const isRestoring = useIsRestoring();
|
|
const errorResetBoundary = useQueryErrorResetBoundary();
|
|
const client = useQueryClient(queryClient);
|
|
const defaultedOptions = client.defaultQueryOptions(options);
|
|
client.getDefaultOptions().queries?._experimental_beforeQuery?.(
|
|
defaultedOptions
|
|
);
|
|
if (process.env.NODE_ENV !== "production") {
|
|
if (!defaultedOptions.queryFn) {
|
|
console.error(
|
|
`[${defaultedOptions.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`
|
|
);
|
|
}
|
|
}
|
|
defaultedOptions._optimisticResults = isRestoring ? "isRestoring" : "optimistic";
|
|
ensureSuspenseTimers(defaultedOptions);
|
|
ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary);
|
|
useClearResetErrorBoundary(errorResetBoundary);
|
|
const isNewCacheEntry = !client.getQueryCache().get(defaultedOptions.queryHash);
|
|
const [observer] = React.useState(
|
|
() => new Observer(
|
|
client,
|
|
defaultedOptions
|
|
)
|
|
);
|
|
const result = observer.getOptimisticResult(defaultedOptions);
|
|
const shouldSubscribe = !isRestoring && options.subscribed !== false;
|
|
React.useSyncExternalStore(
|
|
React.useCallback(
|
|
(onStoreChange) => {
|
|
const unsubscribe = shouldSubscribe ? observer.subscribe(notifyManager.batchCalls(onStoreChange)) : noop;
|
|
observer.updateResult();
|
|
return unsubscribe;
|
|
},
|
|
[observer, shouldSubscribe]
|
|
),
|
|
() => observer.getCurrentResult(),
|
|
() => observer.getCurrentResult()
|
|
);
|
|
React.useEffect(() => {
|
|
observer.setOptions(defaultedOptions);
|
|
}, [defaultedOptions, observer]);
|
|
if (shouldSuspend(defaultedOptions, result)) {
|
|
throw fetchOptimistic(defaultedOptions, observer, errorResetBoundary);
|
|
}
|
|
if (getHasError({
|
|
result,
|
|
errorResetBoundary,
|
|
throwOnError: defaultedOptions.throwOnError,
|
|
query: client.getQueryCache().get(defaultedOptions.queryHash),
|
|
suspense: defaultedOptions.suspense
|
|
})) {
|
|
throw result.error;
|
|
}
|
|
;
|
|
client.getDefaultOptions().queries?._experimental_afterQuery?.(
|
|
defaultedOptions,
|
|
result
|
|
);
|
|
if (defaultedOptions.experimental_prefetchInRender && !isServer && willFetch(result, isRestoring)) {
|
|
const promise = isNewCacheEntry ? (
|
|
// Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted
|
|
fetchOptimistic(defaultedOptions, observer, errorResetBoundary)
|
|
) : (
|
|
// subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in
|
|
client.getQueryCache().get(defaultedOptions.queryHash)?.promise
|
|
);
|
|
promise?.catch(noop).finally(() => {
|
|
observer.updateResult();
|
|
});
|
|
}
|
|
return !defaultedOptions.notifyOnChangeProps ? observer.trackResult(result) : result;
|
|
}
|
|
export {
|
|
useBaseQuery
|
|
};
|
|
//# sourceMappingURL=useBaseQuery.js.map
|