Talent-Catalog / talentcatalog

https://tctalent.org
GNU Affero General Public License v3.0
9 stars 4 forks source link

Create CandidateProspect chats functionality for source partners and bug fixes #1095

Open samschlicht opened 2 weeks ago

samschlicht commented 2 weeks ago

The evolution of this issue can be understood from the comments below.

John and I identified a bug whereby source partners create a CandidateProspect chat automatically by viewing any full-screen candidate profile (including anonymised profiles of candidates they don't manage), but the tab is not visible to any source partner except TBB (irrespective of whether they manage the candidate) — until the candidate has an opportunity at CV Review stage or later, when it is visible to TBB and the managing source partner.

UPDATE: I've also found that the candidate viewing their own profile also auto-creates a CandidateProspect chat, and that they will see the chat from the point when they are added to a submission list (due to the automated message telling them they're a prospect).

The solution to this bug is also an enhancement:

As a source partner I want to be able to create and view CandidateProspect chats So that I can correspond with promising candidates before they're associated with an opportunity at CV Review stage or later

As John suggests, I've created a separate issue for blocking these CandidateProspect chats.

samschlicht commented 2 weeks ago

John and I discussed this one and didn't get entirely clear on exactly where the line between bug and desired behaviour is, but agreed there's at least something of the former.

So here's a summary of what's happening:

In my view the bug is one of these (and not the other):

I'll note an extra detail, which is that once the candidate is associated with a job at CV review stage, this error appears when I load their profile as a source partner admin: 2024-06-11 18:16:05.916 ERROR 79341 --- [io-8080-exec-12] o.tctalent.server.util.dto.ErrorHandler : Processing ServiceException: org.tctalent.server.exception.InvalidRequestException: Missing candidate

Finally, source_partner_id is not being saved for any of these chats, which seems like a bug and is potentially a problem for #693:

Screenshot 2024-06-12 at 9.24.40 AM.png

There's nothing catastrophic happening here, probably just a little tightening up needed!

samschlicht commented 2 weeks ago

Just confirming that we're getting the same error in prod (when a partner opens the full profile of a candidate with an opportunity at or past CV review stage).

Screenshot 2024-06-12 at 8.43.08 AM.png Screenshot 2024-06-12 at 9.06.24 AM.png
samschlicht commented 2 weeks ago

Source partner ID should probably be set here (view-candidate-component.ts in the left split):

Screenshot 2024-06-12 at 9.30.02 AM.png

I may be wrong, but this property seems like an important aspect of gathering a source partner's chat, per #693.

FYI @camerojo

camerojo commented 1 week ago

Thanks for this analysis.

There is definitely a bug here.

The intention was that a source partner should have the option to create a chat with a candidate even if they have not been associated with a job. (A candidate prospect chat is automatically created for candidates who have a candidate job opp).

This allows source to communicate with promising candidates even before they are considered for a job.

I think one bug is that adding the Chat tab to the candidate display auto creates a chat. A solution to that bug could be to add an Open Chat button to the candidate display. A candidate tab is only displayed if that button has been pressed.

Once the button has been pressed and the tab displayed (and therefore the chat auto created if necessary), the button could change to Block Chat. Block Chat could be used to block input from the candidate if needed. Maybe that Block Candidate functionality should be added in a separate issue.

camerojo commented 1 week ago

I am not sure that source partner id should be send on a Candidate Prospect chat. The source partner would be redundant data. It will always be the source partner associated with the candidate (which can change).

The source partner id on chats is present to define chats between that source partner and other partners- eg destination partners.

camerojo commented 1 week ago

Note also that the CandidateProspect chat is intended to be shared across all opportunities for that Candidate as well as being used for chats between source and candidate unassisted with any job.

In other words there is only one CandidateProspect chat per candidate - irrespective of how many jobs they go for (including zero jobs).

samschlicht commented 3 days ago

Thanks for that, @camerojo! In that case I'll take this issue forward as a solution and enhancement relating to the creation of CandidateProspect chats. I'll adjust the title and description accordingly.

Totally take your point the source_partner_id would be redundant.

samschlicht commented 3 days ago

The behaviour we ideally want is

These are the code steps we'll need:

samschlicht commented 3 days ago

I've found the source of the bug with the method that checks if the admin belongs to a managing partner: while ngOnInit first fires the method to fetch the candidate, it is subscribed to — Angular moves on to using the candidate object in subsequent ngOnInit methods before it has arrived!

samschlicht commented 2 days ago

Currently a source-partner chat is also created when a candidate views their own profile (not desired behaviour)

But it's only viewable to the candidate if it has posts (desired behaviour, except that it means the chat will be visible when candidate is a prospect for a job, because that triggers an automated notification, rather than at CV review stage or later, which I understood was the intention).

samschlicht commented 2 days ago

I need to choose between the clickable tab or button. My preference is for the latter, but I'll run it by the team.

Screenshot 2024-06-27 at 9.48.11 AM.png Screenshot 2024-06-27 at 9.47.22 AM.png
samschlicht commented 1 day ago

Team strongly preferred the button option, so I've removed the clickable tab code.

This is ready for PR but I'm going to discuss w JC first.