Fetch the watchlist window the URL actually asked for - #24
Merged
Conversation
A shared link like /watchlist?range=1Y lit up the 1Y button and then showed 3M numbers underneath it. The table was wrong and said nothing about being wrong, which is worse than failing. Two faults, one behind the other. The state was restored too late. `restoreWatchlistPrefs()` ran inside boot(), which reaches it only after awaiting /health and /api/stats — but the session resolving fires `advis0r:auth-changed` -> openWatchlistTab() well before that. So the first overview request went out on the default 3M window, before the URL had been read at all. It is restored at module scope now: nothing may read wlView before it reflects the URL. Then the correction was dropped. When boot() caught up and asked for 1Y, `loadWatchlistOverview` returned early because a request was already in flight, so the right window was never fetched and the 3M payload rendered under the 1Y label. Requests are coalesced now rather than discarded: the fetch loop re-runs while the selected range differs from the one just fetched, and the last write wins. The same guard swallowed a range clicked while a request was outstanding, and a reprice requested mid-flight by adding a ticker — which left the new row permanently unpriced. Both are covered by the loop and the pending flag respectively, and both now have a test that fails without the fix. This is why `test/dashboard-watchlist.test.ts` has been red since #22: the deep-link case was asserted and never passed. The suite is green at 590. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WQQYeLjnzqv5n39KLu3gdK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A shared link like
/watchlist?range=1Ylit up the 1Y button and then showed 3M numbers underneath it. The table was wrong and said nothing about being wrong.This is also why
typecheck + bun testhas been failing:dashboard-watchlist.test.tsasserted the deep-link case in #22 and it has never passed. The suite is green at 590 with this.Two faults, one behind the other
The state was restored too late.
restoreWatchlistPrefs()ran insideboot(), which reaches it only after awaiting/healthand/api/stats— but the session resolving firesadvis0r:auth-changed→openWatchlistTab()well before that. The first overview request therefore went out on the default 3M window, before the URL had been read at all. It is restored at module scope now, so nothing can readwlViewbefore it reflects the URL.Then the correction was dropped. When
boot()caught up and asked for 1Y,loadWatchlistOverviewreturned early because a request was already in flight — so the right window was never fetched, and the 3M payload rendered under the 1Y label. Requests are coalesced now instead of discarded: the fetch loop re-runs while the selected range differs from the one just fetched, and the last write wins.Two more paths through the same guard
The first is covered by the range check in the loop, the second by a pending flag. Both have a test that I verified fails without the fix (I reverted each half in turn and watched the corresponding test go red).
Verified
bun install --frozen-lockfile,bun run typecheckclean,bun test590 pass / 0 fail — the same stepstest.ymlruns.🤖 Generated with Claude Code
https://claude.ai/code/session_01WQQYeLjnzqv5n39KLu3gdK