Conversation
…p-back tracking, fix Tailwind utilities Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>
…onal separation from clearState Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Refactors and fixes the standalone-PWA “double back to exit” behavior and cleans up tracking UI styling, primarily addressing follow-up items from PR #582.
Changes:
- Extracts a shared
clearState()helper inuseBackToExitto dedupe toast-dismiss reset logic. - Replaces the previous
history.length-based deep/back detection approach with a hook-internal depth ref (navDepthRef) and updates tests accordingly. - Fixes non-standard Tailwind utility classes used in the tracking client UI.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/hooks/useBackToExit.ts | Refactors exit-state resets and changes deep/back detection logic for standalone PWA behavior. |
| src/hooks/tests/useBackToExit.test.ts | Updates unit tests to align with the new depth/back detection approach. |
| src/app/(protected)/tracking/TrackingClient.tsx | Replaces invalid Tailwind utilities with supported/default/arbitrary equivalents. |
| package-lock.json | Updates lockfile after dependency resolution changes during install. |
| if (!isDashboardRoute) { | ||
| // Track depth within the hook — more reliable than history.length, | ||
| // which is a session-wide counter that never decreases on back navigation. | ||
| navDepthRef.current += 1; | ||
| const now = Date.now(); |
There was a problem hiding this comment.
navDepthRef is incremented here but never read to make any decision (it only ever gets reset). That means the previous “deep history” gating was effectively removed, and the new counter currently doesn’t influence when the deep-mode exit flow should apply. Either wire navDepthRef into the deep/back detection logic (and/or replace nonDashboardBackCountRef), or remove it to avoid misleading depth-tracking semantics.
|
@copilot apply changes based on the comments in this thread |
…ve nonDashboardBackCountRef Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com>
Fixed in
|
* feat(tracking,legal): improve tracking UX and align legal policy updates - add sticky course headers on tracking page - add right-side scroll-to-bottom floating button near tracking controls - switch accept-terms success navigation to router.replace to prevent back nav to terms - update legal policy text (Turnstile clarity, AWS ap-south-1 disclosure, Kochi jurisdiction) - bump terms version to 2.5 and align legal effective date docs/env examples - enhance legal page external link visibility and secure external link behavior - update related tests and mocks (tracking + save-token terms version) * fix(tracking,pwa): refine pinned course header and reset deep back-exit state - use header-based scroll detection for pinned course title timing - adjust scroll-to-end FAB margins slightly on mobile and md breakpoints - reset non-dashboard back counter when exit state/toast is cleared - add regression test for deep-mode threshold expiry re-arming behavior * fix(pwa,tracking): extract clearState helper, consolidate depth counter into navDepthRef, fix Tailwind utilities (#583) * Initial plan * fix(pwa,tracking): extract clearState helper, use navDepthRef for deep-back tracking, fix Tailwind utilities Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com> * refine(pwa): clarify navDepthRef semantics and add comment on intentional separation from clearState Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com> * fix(pwa): merge navDepthRef into single qualifying-back counter, remove nonDashboardBackCountRef Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com> * fix(pwa,tracking): toast race condition, scroll setState deduplication, activeCourseMeta lookup trim consistency (#584) * Initial plan * fix(tracking,pwa): guard toast callbacks, deduplicate scroll setState, fix activeCourseMeta lookups Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com> * fix(tracking): remove unused cardVariants and improve toast dismissal logic in useBackToExit * fix(legal): normalize legal effective date format and improve handling * Update src/app/config/legal.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Devanarayanan <fusion@devakesu.com> * fix(tracking,hooks): aria-hidden decorative icons + accurate stale comments (#585) * Initial plan * fix(tracking,hooks): add aria-hidden to decorative BookOpen icons and update stale comments Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: devakesu <61821107+devakesu@users.noreply.github.com> --------- Signed-off-by: Devanarayanan <fusion@devakesu.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Pull Request
Description
Addresses unresolved review comments from PR #582. Fixes unreliable
history.length-based deep-back detection inuseBackToExit, eliminates duplicated ref-reset logic across toast callbacks, and corrects two non-standard Tailwind utility classes inTrackingClient.useBackToExit.ts—clearState()helperonDismiss/onAutoClosepreviously inlined the same 5-ref reset already inresetExitState(). ExtractedclearState()— resets exit-state refs without callingtoast.dismiss()(avoids re-entrant dismissals).resetExitState()now callstoast.dismiss()+clearState(); the toast callbacks referenceclearStatedirectly.useBackToExit.ts—navDepthRefreplaces bothhistory.lengthandnonDashboardBackCountRefhistory.lengthis a session-wide counter that never decreases on back navigation, causing misclassification of shallow positions as "deep". Replaced withnavDepthRef— a hook-internal counter that serves as the single source of truth for qualifying non-dashboard back presses. The separatenonDashboardBackCountRefhas been removed;navDepthRefnow drives both depth tracking and the>= 2deep-mode toast gate.Key semantics:
resetExitState()branches so each new sequence starts at 1clearState()so toast expiry/dismiss resets the count, requiring a fresh 2-press sequenceTrackingClient.tsx— Tailwind utility fixesbackdrop-blur-xs→backdrop-blur-sm(noxsblur in Tailwind's default scale)top-22→top-[88px](no22in Tailwind's default spacing scale)Type of Change
Related Issues
Relates to #582
Changes Made
clearState()helper insideuseEffect;onDismiss/onAutoClosenow reference it instead of duplicating inline reset blocksnonDashboardBackCountRef; consolidated intonavDepthRefas the single qualifying-back-press counternavDepthRefadded toclearState()so toast expiry resets the count; incremented afterresetExitState()branches so sequences always start at 1navDepthRef.current >= 2gates the deep-mode exit toast (replacesnonDashboardBackCountRef.current >= 2)backdrop-blur-xs→backdrop-blur-smandtop-22→top-[88px]inTrackingClient.tsxhistory.pushStatesetups from tests that only existed to inflatehistory.length; updated affected test descriptionVersion Bump
node scripts/bump-version.js(fork PRs)Testing
Test Environment
Tests Performed
npm run test)npm run test:e2e)npm run lint)Test Coverage
All 20
useBackToExitunit tests pass. Tests updated to reflect that depth tracking no longer depends onhistory.lengthand that the singlenavDepthRefcounter drives the deep-mode gate.Documentation
Checklist
Screenshots (if applicable)
N/A
Additional Notes
navDepthRefis now the single counter for both "how deep has the user navigated?" and "how many qualifying back presses have occurred in this sequence?". It resets inclearState()on toast expiry/dismiss so the user must press back twice again for a fresh deep-mode trigger, and resets to 0 at sentinel/dashboard/close so deep-mode counting always restarts cleanly from a root or shallow position.For maintainers:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.