Skip to content

fix(StudentWebSocketService): Late-joining teams' posts show no name - #2394

Open
Isaries wants to merge 2 commits into
WISE-Community:developfrom
Isaries:fix/late-joiner-classmate-names
Open

Isaries wants to merge 2 commits into
WISE-Community:developfrom
Isaries:fix/late-joiner-classmate-names

Conversation

@Isaries

@Isaries Isaries commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Discussion posts by a team that joined the run after a student opened it show no author name on that student's screen until the student reloads. When a workgroup joins, the classroom topic sends newWorkgroupJoinedRun and StudentWebSocketService calls ConfigService.retrieveConfig() to refresh the roster, but retrieveConfig() returns a cold HTTP observable and nothing subscribes to it, so the request is never made. Posts are named from classmateUserInfos when they arrive, and that roster stays as it was at page load.

This is the normal way a class starts: students join with the access code over the first minutes, and whoever opened the unit first sees an increasing share of their classmates' posts and "reply" notifications without names.

Changes

  • The join message feeds a subject that requests the student run config with auditTime, at most once per window per tab. auditTime rather than debounceTime, so the roster keeps refreshing while a class is still joining. The window is 2 to 5 seconds, chosen per tab, so a whole class does not request the config at the same instant. Each request is mapped with concatMap and runs to completion, so a server slower than the window still answers during a burst instead of having every request cancelled by the next. A failed request is swallowed so later joins still refresh, and initialize() replaces any earlier pipeline.
  • DiscussionStudent re-applies names to the posts it already shows when a new config is retrieved, unless responses are anonymized.
  • Anonymous names come from each workgroup's index in the period's roster, sorted by username. Once the roster refreshes mid-session, a newcomer sorted in ahead of a classmate, or a team leaving, would shift those indexes and give later posts another classmate's pseudonym, and every author missing from the roster shared the last slot. DiscussionService now keeps the order it first read for each run and period and appends authors it has not seen to the end, so within a session each team keeps the pseudonym it was first shown under and newcomers get distinct ones. Pseudonyms already differ between viewers today; that is reported separately in Discussion anonymous names refer to different students for different viewers #2393 and not changed here.

Test

  • New studentWebSocketService.spec.ts: the config is requested, once for a burst of joins, repeatedly while joins keep arriving one second apart, again after a failed request, and through one pipeline after a second initialize(). Against the current develop, the request cases fail with Expected 0 to equal 1.
  • New case in discussion-student.component.spec.ts: a post by a team missing from the roster gets its name once the config is retrieved again.
  • New cases in discussionService.spec.ts: a classmate keeps its pseudonym after a newcomer joins and after a team leaves, and authors missing from the roster neither take a classmate's pseudonym nor share one. Against the current develop, these fail with messages such as Expected 'Anonymous Fox' to equal 'Anonymous Lion'.
  • should finish slow config requests while joins keep arriving: with a request slower than the window, requests still complete while joins continue. With switchMap it fails with Expected 0 to be greater than or equal 2.
  • Removing any one part (the audit window, the error handling, the pipeline replacement, the renaming, the pseudonym order) makes its own cases fail.

When a new workgroup joins the run, the classroom topic sends a
newWorkgroupJoinedRun message and the student side calls
ConfigService.retrieveConfig() to refresh its roster. retrieveConfig()
returns a cold HTTP observable and nothing subscribed to it, so the
request was never made and classmateUserInfos kept the roster from page
load. Discussion posts get their author names from that roster when they
arrive, so posts by late joiners showed a user id fallback or nothing
until the student reloaded.

The message now feeds a subject that requests the config at most once
per audit window, so a whole class joining produces one request per tab
while joins keep arriving, and a random per-tab window keeps the class
from requesting at the same instant. A failed request is swallowed so
later joins still refresh, and initialize() replaces any earlier
pipeline instead of adding a second one.

DiscussionStudent re-applies names to the posts it already shows when a
new config is retrieved, unless responses are anonymized.

Anonymous names come from each workgroup's index in the period's
alphabetically sorted roster. Once the roster refreshes mid-session, a
newcomer sorted in ahead of a classmate or a team leaving would shift
those indexes and give later posts another classmate's pseudonym, and
every author missing from the roster shared the last slot.
DiscussionService now keeps the workgroup order it first read for each
run and period and appends authors it has not seen to the end of it, so
for the rest of the session in that tab each team keeps the pseudonym it
was first shown under and newcomers get distinct ones.
The roster refresh audits newWorkgroupJoinedRun messages and maps each
audit tick to a config request with switchMap. While a class keeps
joining, the audit window closes again every few seconds and switchMap
cancels the request still in flight. If the config endpoint takes
longer than the window to answer, no request completes until the joins
stop.

Use concatMap instead so each request runs to completion and the
request for the latest joins still runs after the one before it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant