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 committed Apr 27, 2022
1 parent 339b1c7 commit aa88b34
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 @@ -29,6 +29,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 @@ -70,9 +71,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 @@ -85,6 +86,7 @@ const useMephistoRemoteProcedureTask = function (props) {
if (agentId) {
console.log("connecting...");
connect(agentId);
setConnectedAgentId(agentId);
}
}, [agentId]);

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

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

0 comments on commit aa88b34

Please sign in to comment.