fixed suggestions bug#66
Conversation
KDwevedi
left a comment
There was a problem hiding this comment.
Core change is good — fetchSuggestionsWithRetry (backoff 300/700/1200/2000ms, early-exit on non-empty) is clean and correctly pairs with backend PR amul-oan-api#64. Two things to fix before merge, both unrelated to the suggestions fix:
🔴 Remove the committed build artifact
tsconfig.tsbuildinfo is a generated TypeScript incremental-build cache, not source. Committing it causes perpetual spurious diffs and merge conflicts. Note PR #65 adds a .gitignore rule for *.tsbuildinfo while this PR commits the file — contradictory. Please gitignore it and drop it from this PR.
🟡 Split out the JWT public-key rotation
public/jwt_public_key.pem is rotated here (2048-bit → ~4096-bit RSA). That's a security-sensitive change that must deploy in lockstep with the backend's signing private key or token verification breaks for all users. It should not ride along in a suggestions bugfix — please move it to its own PR with explicit backend-deploy coordination. (This file is also churning in PR #65; worth reconciling.)
🟢 Non-blocking
Backend GET waits ≤8s and the FE retries 5× on top — worst case a stuck session stalls ~40s. Usually resolves on attempt 1; flagging for later tuning.
Once the artifact and the key rotation are out, the suggestions logic itself is good to merge.
fetchSuggestionsWithRetry could run its full ~4.2s backoff ladder (plus a final call) even after the user moved on, and could overwrite a newer turn's suggestions with stale results. Pass an isStale() predicate (session changed or assistant typing again) checked before each attempt and before applying the result, so the retry tail is bounded to the current turn. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Small Promise delay helper for retries to get suggestions from cache.