Skip to content

Commit

Permalink
chore(weave): Fix call query on the Playground (#3275)
Browse files Browse the repository at this point in the history
* Fix call query on the Playground

* move costs field

* pr comments/cleanup
  • Loading branch information
jwlee64 authored Dec 17, 2024
1 parent b978a7f commit b28adb0
Showing 1 changed file with 25 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,20 @@ export const PlaygroundPageInner = (props: PlaygroundPageProps) => {

const {useCall, useCalls} = useWFHooks();
const [settingsTab, setSettingsTab] = useState<number | null>(0);
const callKey = useMemo(() => {
return props.callId
? {
entity: props.entity,
project: props.project,
callId: props.callId,
}
: null;
}, [props.entity, props.project, props.callId]);

const call = useCall(
useMemo(() => {
return props.callId
? {
entity: props.entity,
project: props.project,
callId: props.callId,
}
: null;
}, [props.entity, props.project, props.callId]),
{
includeCosts: true,
}
);
const call = useCall(callKey);
const callWithCosts = useCall(callKey, {
includeCosts: true,
});

const {result: calls} = useCalls(
props.entity,
Expand Down Expand Up @@ -103,6 +102,18 @@ export const PlaygroundPageInner = (props: PlaygroundPageProps) => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [call.loading]);

useEffect(() => {
if (!callWithCosts.loading && callWithCosts.result) {
if (callWithCosts.result.traceCall?.inputs) {
setPlaygroundStateFromTraceCall(callWithCosts.result.traceCall);
}
}
}, [
callWithCosts.loading,
setPlaygroundStateFromTraceCall,
callWithCosts.result,
]);

useEffect(() => {
setPlaygroundStates(prev => {
const newStates = [...prev];
Expand Down

0 comments on commit b28adb0

Please sign in to comment.