Module: Tina4::Feedback
- Defined in:
- lib/tina4/feedback.rb
Overview
── Customer feedback widget — server-side plumbing ─────────────────
Mirrors tina4_python/dev_admin/init.py lines 1436-1645. The
widget is for END USERS of a shipped Tina4 app (not developers).
Whitelisted users get a floating bubble that proxies one
conversational turn at a time to the Rust agent's intake endpoint
at
Flow:
1. Framework middleware injects <script src="/__feedback/widget.js">
into HTML responses for whitelisted users.
2. Widget POSTs to /__feedback/api/turn for each conversational turn.
3. The Ruby handler verifies whitelist + rate-limit, stamps the
user identity server-side (client cannot fake `sender`), then
forwards to the Rust agent's /feedback/intake.
4. Finalised tickets land in .tina4/chat/threads.json with
kind:"feedback". Developer sees them in the dev admin sidebar.
Constant Summary collapse
- RATE_WINDOW =
1 hour
3600- RATE_MAX =
submissions/turns per user per hour
5
Class Attribute Summary collapse
-
.rate_mutex ⇒ Object
readonly
Returns the value of attribute rate_mutex.
Class Method Summary collapse
-
.feedback_enabled? ⇒ Boolean
Hard master switch.
-
.feedback_identify_user(request) ⇒ Object
Best-effort user identity from auth headers.
-
.feedback_is_whitelisted(request) ⇒ Object
Returns [allowed, identity].
-
.feedback_rate_limit_ok(user) ⇒ Object
5 turns/hour per user.
-
.feedback_whitelist ⇒ Object
Comma-separated emails / user IDs in env.
-
.handle_request(env) ⇒ Object
Dispatcher used by RackApp — returns a Rack triple if the path matches a /__feedback route, else nil.
-
.handle_turn(env) ⇒ Object
POST /__feedback/api/turn — whitelist check + rate-limit + stamp
senderserver-side, forward to Rust agent/feedback/intake. -
.handle_widget_js(_env) ⇒ Object
GET /__feedback/widget.js — serve the bundle at lib/tina4/public/__feedback/widget.js.
-
.inject_feedback_widget(request, html) ⇒ Object
Insert the widget