Skip to content

Fix task ordering in replay when participants use previous buttons #1240

Description

@jaykim1213

In Participant View replay timelines, task ordering can become incorrect when a participant navigates backward using the previous button.

The startTime / endTime values can affect the replay timeline ordering and make tasks appear out of sequence. They should always show up in the their sequence order


Specification

Added after specification review.

Summary

Participant View replay timelines should render tasks in study sequence order even when a participant used Previous and the saved startTime / endTime values are no longer monotonic. This should be a replay rendering fix, not a stored-data migration.

Decisions

  • Sort replay task entries by parsed trialOrder, using sequence step first, dynamic funcIndex second, and task identifier as a stable tie-breaker.
  • Keep startTime / endTime as the source for timeline scale, task bar position, bar width, duration, and browsed-away overlays.
  • Include incomplete answers with startTime === 0 in the same sequence-order sort rather than appending them after completed tasks.
  • Sort dynamic block trials such as 3_0, 3_1, and 3_2 by parent step and then funcIndex; if both a non-dynamic 3 and dynamic children exist, the non-dynamic step sorts before its dynamic children.
  • Do not modify saved participant answer data.
  • Do not change analytics summaries or exported data ordering unless they share the same visible Participant View replay timeline bug.

Acceptance Criteria

  • Participant View replay timeline renders task labels/tasks in study sequence order when saved answers have non-monotonic startTime values caused by Previous navigation.
  • Dynamic/repeated task answers sort by trialOrder step and funcIndex.
  • Incomplete answers do not get appended out of sequence solely because startTime === 0.
  • Timestamp-based bar scale, bar widths, and browsed-away overlays continue to use recorded startTime / endTime.
  • Clicking a task in the replay timeline still opens the correct trial using that task's trialOrder.
  • Focused unit coverage is added for the ordering helper or AllTasksTimeline behavior using out-of-order timestamps.

Out of Scope

  • Rewriting participant answer persistence.
  • Changing how startTime / endTime are collected.
  • Changing exported analytics semantics.
  • Adding new libraries.

Implementation Notes

  • The likely control point is src/analysis/individualStudy/replay/AllTasksTimeline.tsx, which currently sorts completed tasks by startTime while incomplete tasks use trialOrder.
  • Prefer reusing the existing parseTrialOrder utility instead of adding ad-hoc parsing logic.
  • Existing think-aloud replay code already orders answers by parsed trialOrder with an identifier tie-breaker; use that as the behavioral reference.

Testing Notes

  • Add a focused Vitest test for out-of-order timestamps where trialOrder is still ordered, including at least one dynamic trialOrder case.
  • Confirm timestamp-driven visual metrics still use startTime / endTime after the ordering change.

Metadata

Metadata

Assignees

Labels

SpecifiedIssue has enough detail to implementbugSomething isn't working

Type

No type

Fields

No fields configured for issues without a type.

Projects

Status
In progress

Relationships

None yet

Development

No branches or pull requests

Issue actions