Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement vote and reveal & other improvements #8

Merged
merged 23 commits into from May 16, 2024

Conversation

TiboX2021
Copy link
Collaborator

@TiboX2021 TiboX2021 commented Apr 25, 2024

  • Finished the implementation of stages of type voteForLeader and leaderReveal in order to finish the transition from local demo to backend-based webapp.

  • Updated the docker config for the webapp (documentation included in README.md)

  • Removed the hardcoded firebase configurations for deployment @ EPFL and included example configuration files (documented in README). Resolves Hide API key in a local file #7

  • Take into account remarks made in Merge back from the LSIR/llm--mediator-political repository #4's thread

Commit c838474 resolves #9

Firestore & cloud functions refactoring will be done in another PR

@TiboX2021 TiboX2021 changed the title Implement vote and reveal Implement vote and reveal & other improvements Apr 29, 2024
@TiboX2021 TiboX2021 added enhancement New feature or request dev enhancement Developer experience improvements labels Apr 30, 2024
@TiboX2021 TiboX2021 marked this pull request as ready for review May 1, 2024 09:55
@TiboX2021 TiboX2021 requested review from iislucas and cjqian May 2, 2024 09:21
Copy link
Collaborator

@iislucas iislucas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great to see the progress!

I think there's a few patterns I don't quite get (e.g. the mutation at end of stages when within the nextStep()), might need a video chat about that.

Some comments/suggestions in the meantime...

.vscode/settings.json Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
this.messages.set(extendUntilMatch(this.messages(), m.reverse(), 'uid'));

// Find if new discuss items message have arrived
const last = m.find((m) => m.messageType === MessageType.DiscussItemsMessage) as
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use the name name for a list of things as a thing in the list :) (m in this case). Use a bit more detailed variable names and it'll be easier to understand.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also worried that this will simply find the last pair of items, not tell you if there's a new pair of items to discuss...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed in 8ef5c53

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I track the current pair being discussed through the participants_ready_to_end_chat sync document, which also stores the index of the current pair being discussed in the preconfigured chat list. I should remove one of these 2 ways of computing the last pair being discussed, as they are redundant... If we want to keep the one that scans the last DIscussItemsMessage as the single source of truth, we could simply use a WritableSignal with lodash's deepEq comparison to make sure that the signal triggers on actual changes

// }
// return isReady;
// });
this.everyoneReachedThisStage = signal<boolean>(false);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a comment to say that this is signal is expected to be thrown away and replaced OnInit when the stage data is set... ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be better to simply not have this initialized... otherwise you risk creating a dependency on the signal and then having the signal value replaced, but the dependency update forgotten about... Alternatively, whenever the stage is set, you write updates from the stage's signal to this signal... (that might be better, then you have the value always defined)

this.everyoneReachedThisStage = this.participant.everyoneReachedCurrentStage(this.stage.name);
}

private queryClient = injectQueryClient();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a comment to say what this is I think.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... I suspect this is not the right design... I think you should be simply be doing a firebase groupQuery for the participants, and then when they are all at done at this stage, you move to the next...

// return sorted[0].userId;
// });
nextStep() {
this.mutationReveal.mutate({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need a comment to say what/why we are doing this...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, the idea was to structure the stage flow like so:

  1. You fill the stage data as a participant
  2. You use a mutation to send your data to the backend / firestore
  3. If the mutation was successful, you navigate to the next page

However, I realized later on that participants are not supposed to be able to edit previous stages, so we should be able to simplify this (if the stage is being worked on by the participant, mutation -> navigation. Else, just navigate).

Because the LeaderReveal stage has no data to be filled by the participant, this mutation feels especially heavy (all that work just to update workingOnStageName), I will think of lighter alternatives

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh I think I see, the point here is that you save the data to firestore at the time the person does the nextStep thing. Previously I did writes when data was edited... might be worth discussing how hard this is, and what the right abstraction is. My default would be that each stage kind has a class, and that class has functions to edit the data, and when edited, that results in a write to Firebase. So the key thing in a nextStep would be to call the corresponding stage instance's nextStep method that would simply mark this stage as complete.

@LeoLaugier
Copy link
Collaborator

@cjqian This PR is ready to be merged :)

@cjqian
Copy link
Collaborator

cjqian commented May 7, 2024

Wow, thank you!

@TiboX2021 TiboX2021 mentioned this pull request May 8, 2024
8 tasks
@TiboX2021 TiboX2021 removed the request for review from cjqian May 16, 2024 17:56
@TiboX2021 TiboX2021 merged commit 144591f into PAIR-code:main May 16, 2024
1 check passed
@cjqian cjqian added this to the Mediation Agents Playtest milestone May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev enhancement Developer experience improvements enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add script to generate fake experimenters with google.com as a provider Hide API key in a local file
4 participants