fix(cc): review comments and cleanup state machine#2
Conversation
0b9598a to
53ebb39
Compare
53ebb39 to
c63d7d7
Compare
| // Backend may send hold success without a preceding HOLD_INITIATED (e.g. remote hold) | ||
| // Backend may send hold success without a preceding HOLD_INITIATED (e.g. remote hold) for consult cases | ||
| // TODO: check if we need this state as we already have consulting and intermediate state | ||
| [TaskEvent.HOLD_SUCCESS]: { |
There was a problem hiding this comment.
remove this , we have intermediate state for consult and conference
| data: WebSocketPayload; | ||
| }; | ||
|
|
||
| type TaskWithStateMachine = ITask & { |
There was a problem hiding this comment.
Move this to types file and this is applicable for any other similar occurrences of defining tyopes and interfaces in the same file
There was a problem hiding this comment.
its not. needed moved to task class
There was a problem hiding this comment.
I believe this comment is remaining to be discussed as I still feel we don't need to handle RONA, Failed, END and WRAPUP events here as state machine already has these transitions addressed. I even checked the handlers for these events and I see that apart from logging we are not doing much there
There was a problem hiding this comment.
can you elaborate more on this ,
we just do when we get OUTBOUND on OFFERED state , and do the following
[TaskEvent.OUTBOUND_FAILED]: {
target: TaskState.TERMINATED,
actions: ['updateTaskData', 'markEnded', 'emitTaskReject'],
},
| const payload = JSON.parse(event) as WebSocketMessage; | ||
|
|
||
| // Filter out keepalive messages | ||
| if (payload?.keepalive === 'true' || payload?.keepalive === true) { |
There was a problem hiding this comment.
There was a previous comment on this line that why do we need to check for string and boolean value here ?
There was a problem hiding this comment.
i have seen it coming up as a string , for secruity if they end of changing to boolan both gets handled
|
|
||
| // Some consult/conference events can arrive on a child interactionId while the task we track | ||
| // is keyed by the main/parent interactionId. Resolve to an existing task when possible. | ||
| const interactionId = message.data.interactionId; |
There was a problem hiding this comment.
What is the difference between the 3 interaction IDs here and task object ? I believe one would be the current task/interaction and other would be the associated task for consult or conference flows so why do we have 3 interactions/task being fetched here
|
|
||
| // ============================================ | ||
| // Recording Guards | ||
| recordingActive: ({context}: GuardParams): boolean => { |
There was a problem hiding this comment.
I don't see these guards being used in state machine but in the methods: pauseRecording and resumeRecording. We can directly us context itself in those method in the conditions instead of creating new guards
| * This prevents all agents in a conference from becoming consultInitiator when one agent | ||
| * starts a new consult. | ||
| */ | ||
| setConsultInitiator: assign(({event}: TaskActionArgs) => { |
There was a problem hiding this comment.
If we already have consultInitiator being set in context, why do we need these actions: setConsultInitiator and determineConsultInitiator?
There was a problem hiding this comment.
this is what sets the values in the context ,
determineConsultInitiator is a helper becuase when a task update happend then also we need to check if there is initator or not that happens in deriveTaskDataUpdates
There was a problem hiding this comment.
Are these getting used ? We can remove them if not needed
There was a problem hiding this comment.
Won't this change now that we don't have OFFERED_CONSULT state
| context; | ||
| const {recordingControlsAvailable, recordingInProgress} = context; | ||
|
|
||
| const isHeld = serverHold ?? state === TaskState.HELD; |
There was a problem hiding this comment.
Same question here, why can't we use context to identify task states ? Do we really need to create so many conditions in this file ?
There was a problem hiding this comment.
serverHold is from the context object .
state === TaskState.HELD is just a backup when conext is not set
adhmenon
left a comment
There was a problem hiding this comment.
Tested changes locally and it works.
Approving.
| EventObject | ||
| >; | ||
|
|
||
| type RecordingStateUpdate = Partial< |
| }), | ||
|
|
||
| setHoldInitiated: assign({}), | ||
| handleTransferInit: assign({}), |
There was a problem hiding this comment.
We are still keeping these even when not used
|
|
||
| // State categories for cleaner logic | ||
| const isOffered = state === TaskState.OFFERED || state === TaskState.OFFERED_CONSULT; | ||
| const isOffered = state === TaskState.OFFERED; |
There was a problem hiding this comment.
Why do we even need this variable, just use the state
| return; | ||
| } | ||
|
|
||
| const eventTaskData = Task.extractTaskDataFromEvent(event) as any; |
| return; | ||
| } | ||
|
|
||
| const isAutoAnsweringFromEvent = eventTaskData?.isAutoAnswering; |
a5f23da to
f877286
Compare
|
@Kesari3008 have update the PR with the review comments addredded , unit test are passing as well |
COMPLETES #< INSERT LINK TO ISSUE >
This pull request addresses
< DESCRIBE THE CONTEXT OF THE ISSUE >
by making the following changes
< DESCRIBE YOUR CHANGES >
Change Type
The following scenarios where tested
< ENUMERATE TESTS PERFORMED, WHETHER MANUAL OR AUTOMATED >
I certified that
I have read and followed contributing guidelines
I discussed changes with code owners prior to submitting this pull request
I have not skipped any automated checks
All existing and new tests passed
I have updated the documentation accordingly
Make sure to have followed the contributing guidelines before submitting.