Skip to content

Commit

Permalink
Fixing agent desync on RemoteProcedure tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
JackUrb authored and meta-paul committed Mar 6, 2024
1 parent 0629103 commit 12b3bda
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/mephisto-task/src/RemoteTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const useMephistoRemoteProcedureTask = function (props) {
// mapping of request ID to the callback object
const requestCallbacks = {};
const [disconnectIssueText, setDisconnectIssueText] = React.useState();
const [connectedAgentId, setConnectedAgentId] = React.useState();

// We register a ref so that the liveUpdate handler has access
// to the current set of callbacks
Expand Down Expand Up @@ -68,9 +69,9 @@ const useMephistoRemoteProcedureTask = function (props) {
connect,
destroy,
sendLiveUpdate,
agentId,
...otherMephistoProps
} = mephistoProps;
let { agentId } = mephistoProps;

// They're still exposed in a separate manner though
const _fullSocketProps = {
Expand All @@ -83,6 +84,7 @@ const useMephistoRemoteProcedureTask = function (props) {
if (agentId) {
console.log("connecting...");
connect(agentId);
setConnectedAgentId(agentId);
}
}, [agentId]);

Expand Down Expand Up @@ -131,6 +133,7 @@ const useMephistoRemoteProcedureTask = function (props) {

return {
...otherMephistoProps,
agentId: connectedAgentId, // only show connected agent Ids
remoteProcedure,
disconnectIssueText,
_fullSocketProps,
Expand Down

0 comments on commit 12b3bda

Please sign in to comment.