feat: add feedback insights view, closing the write-only gap in #823#845
Open
Rudra-clrscr wants to merge 2 commits into
Open
feat: add feedback insights view, closing the write-only gap in #823#845Rudra-clrscr wants to merge 2 commits into
Rudra-clrscr wants to merge 2 commits into
Conversation
…nknown84#823 Issue Userunknown84#823 asked for a feedback loop (thumbs up/down UI, /feedback endpoint, persistence, retraining docs) - all of which already existed on main (FeedbackWidget.jsx, /feedback in both api.py and predictionRoutes.js, feedback_store.csv, retrain.py, and a README section documenting all of it). Verified this directly: checked out a clean branch off upstream/main and ran the existing test_feedback.py (6/6 passing) before starting this work. The one real gap: feedback was completely write-only. Nothing read feedback_store.csv back out except retrain.py (as a training corpus) - there was no way to see what had been collected, how often the model's predictions were being corrected, or what they were corrected to, without opening the CSV by hand. - api.py: new GET /feedback/stats route (same validate_request/validate_internal_request gate as POST /feedback) that reads feedback_store.csv and returns total/corrections/ correction_rate, a per-predicted-label breakdown of confirmations vs. corrections (and what each label gets corrected to), and the 20 most recent submissions (text truncated to 100 chars, matching the privacy posture already used elsewhere in this file for Sentry payloads). - predictionRoutes.js: matching GET /feedback/stats proxy, same pattern as the existing /spam-insights proxy. - frontend/src/components/FeedbackInsights.jsx: new component rendering this data (stat cards, a by-label breakdown table, a recent-submissions table), mounted inside SpamInsightsDashboard.jsx (the existing "Insights" tab) below the existing spam-pattern insights. - backend/tests/test_feedback.py: 4 new tests covering the empty case, correction/confirmation aggregation, the 20-item/most-recent-first cap, and text_preview truncation. - README: documents the new endpoint's response shape under the existing "User Feedback Loop" section. Verified live end-to-end against the real Flask API (submitted feedback, confirmed /feedback/stats aggregated it correctly against the actual production feedback_store.csv, then removed the test rows to leave that file exactly as it was - it's gitignored runtime data, not something to commit test pollution into). App.jsx and ManipulationIndex.jsx again carry the same parse-error fixes from the pending frontend-eslint-errors PR, needed here for the same reason as the other issues worked this session (this branch also forks from upstream/main before that fix lands, and SpamInsightsDashboard is only reachable through App.jsx).
|
Someone is attempting to deploy a commit to the Aditya Sharma's projects Team on Vercel. A member of the Team first needs to authorize it. |
The container's Flask process defaults to FLASK_HOST=127.0.0.1 (a deliberate secure default for bare-metal runs), so inside the CI container it never listens on an interface reachable through the -p 5000:5000 port mapping, and the smoke test's curl always times out. docker-compose.yml already sets FLASK_HOST=0.0.0.0 for the same reason; the CI workflow's docker run step needs the same override.
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.
Summary
Related to #823.
Issue #823 asked for a feedback loop (thumbs up/down UI, /feedback endpoint,
persistence, retraining docs) — all of which already existed on
main(
FeedbackWidget.jsx,/feedbackin bothapi.pyandpredictionRoutes.js,feedback_store.csv,retrain.py, and a READMEsection documenting all of it). Verified this directly before starting:
checked out a clean branch off
upstream/mainand ran the existingtest_feedback.py(6/6 passing).The one real gap: feedback was completely write-only. Nothing read
feedback_store.csvback out exceptretrain.py(as a training corpus) —there was no way to see what had been collected, how often the model's
predictions were being corrected, or what they were corrected to, without
opening the CSV by hand.
Changes
api.py: newGET /feedback/statsroute (samevalidate_request/validate_internal_requestgate asPOST /feedback)that reads
feedback_store.csvand returns total/corrections/correction_rate, a per-predicted-label breakdown of confirmations vs.
corrections (and what each label gets corrected to), and the 20 most
recent submissions (text truncated to 100 chars, matching the privacy
posture already used elsewhere in this file for Sentry payloads).
predictionRoutes.js: matchingGET /feedback/statsproxy, samepattern as the existing
/spam-insightsproxy.frontend/src/components/FeedbackInsights.jsx: new componentrendering this data (stat cards, a by-label breakdown table, a
recent-submissions table), mounted inside
SpamInsightsDashboard.jsx(the existing "Insights" tab) below the existing spam-pattern insights.
backend/tests/test_feedback.py: 4 new tests covering the emptycase, correction/confirmation aggregation, the 20-item/most-recent-first
cap, and text_preview truncation.
existing "User Feedback Loop" section.
Note:
App.jsxandManipulationIndex.jsxagain carry the sameparse-error fixes from the pending
fix/frontend-eslint-errorsPR —needed here for the same reason as prior issues this session (this branch
also forks from
upstream/mainbefore that fix lands, andSpamInsightsDashboardis only reachable throughApp.jsx). Will needreconciling with whichever PR merges first.
Test plan
cd backend && pytest tests/test_feedback.py -q— 10/10 passconfirmed
/feedback/statsaggregated it correctly against the actualproduction
feedback_store.csv, then removed the test rows to leavethat file exactly as it was (gitignored runtime data, not something to
commit test pollution into)
cd backend && pytest tests/ -q(excluding two unrelated pre-existingcollection errors already tracked separately) — 107 passed, same 5
known pre-existing failures, no new regressions
cd frontend && npx vite build— succeedsnpx eslinton new/touched frontend files — clean (aside from onepre-existing, unrelated
exhaustive-depswarning)