Skip to content

feat(recruitment): make applicant switching reliable - #81

Merged
IanCou merged 4 commits into
candiedoperation:masterfrom
urjitc:codex/recruitment-review-navigation
Nov 13, 2026
Merged

IanCou merged 4 commits into
candiedoperation:masterfrom
urjitc:codex/recruitment-review-navigation

Conversation

@urjitc

@urjitc urjitc commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Switching applicants currently clears and reloads their information, briefly shows misleading empty states, and can let a late response display the previous applicant’s data.

This uses the existing React Router and TanStack Query setup so the URL owns selection and each applicant’s requests stay separate. Back/Forward, refresh, and direct links work, recently viewed data is reused, and saves stay attached to the application they started on.

Loading, empty, and error states are separated. Resume links refresh automatically before expiry, with an “Open resume” fallback and retry on errors. Dragging proposes a stage change without modifying saved data before confirmation; cards stay in their saved position until the update succeeds.

No new dependencies or backend changes.

All 31 UI tests pass, including two focused checks for navigation/caching and stale responses. Also tested the real UI in Chrome with synthetic responses, delayed requests, retries, and a delayed rating save. Production authentication and resume performance remain unverified. Typecheck still reports 18 pre-existing errors outside this change.

Closes #72

Use URL selection and identity-keyed queries for applicant reviews. Keep late responses and saves attached to their original application, and separate proposed stage changes from cached server data.

@ktirumal2006 ktirumal2006 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All 31 existing tests passed locally. An additional focused hook test reproduced a stale-list race after saving a rating: the refreshed details contain the saved value, but the selected applicant data reverts when the older initial list response arrives. Please address the inline finding and add regression coverage before merging.


async function refreshApplication(applicationId: string) {
// An initial detail read may predate the save; do not reuse its response.
await client.cancelQueries({ queryKey: keys.details(teamId, applicationId) });

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Could we also cancel the pending applications-list query before invalidating it?

I reproduced a race on commit 41fed7c with a focused hook test using controlled fetch responses: applicant details load while the initial list remains pending, a rating update successfully saves 5 stars, and the refreshed details return 5. When the initial list then resolves with the old value of 0, selected.stars becomes 0 because the list entry takes precedence over the details.

Invalidating the initially pending list reuses that request rather than fetching fresh data. Please ensure the older list response cannot replace the successfully saved value, and add a regression test covering this sequence.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Youre right, i found that invalidating a query that has no data yet reuses the request already in flight (TanStack/query#8530), so the pre-save list request overwrote the saved rating. Stage changes had the same race.

Fixed in 9e9af4c by cancelling the list query before invalidating it, matching details. Added a regression test for this: it fails on 41fed7c and passes now. Also verified it in the real UI.

urjitc and others added 2 commits October 26, 2026 15:59
Invalidating a query only restarts its request when the query already
has data, so a save during the initial board load reused the pre-save
list request and its stale result overwrote the saved value. Cancel the
list read before invalidating it, as already done for details.

Also drop the cache clear on unmount: each reviewer/team session owns a
discarded client, and the cleanup emptied the cache in StrictMode.
@IanCou
IanCou merged commit c0a462c into candiedoperation:master Nov 13, 2026
4 checks passed
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.

[FEATURE] Slow applicant switching and unreliable loading states in recruitment

3 participants