Harden and polish the feedback endpoint

- Honeypot field ("website", hidden via CSS + tabIndex -1): any
  non-empty value silently short-circuits to a fake success response
  without logging or filing anything, at near-zero cost to real users.
- Tag created GitHub issues with the feedback category (bug/idea/
  other) alongside the existing "feedback" label, for easier triage -
  GitHub auto-creates labels that don't exist yet.
- Rotate feedback.log once it crosses 5MB (move to feedback.log.1) so
  a busy instance doesn't grow the file unbounded.
- Push the nudge bubble's cooldown out from the moment someone
  actually submits feedback, so it doesn't ask again shortly after
  they just did.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
MoepchiandClaude Sonnet 5 committed 2026-09-10 09:15:05 +02:00
1 parent 5b5f4caf79
commit 7776a71e84
3 files changed
+67 -3

No files matched your search

+9
View File
@@ -3457,6 +3457,15 @@
max-width: 90vw;
}
.ts-feedback-honeypot {
position: absolute;
left: -5000px;
width: 1px;
height: 1px;
opacity: 0;
pointer-events: none;
}
.ts-update-toast {
position: fixed;
left: 50%;
+24
View File
@@ -1678,6 +1678,10 @@ function FeedbackDialog({ onClose }: { onClose: () => void }) {
const [message, setMessage] = useState("");
const [email, setEmail] = useState("");
const [publishAsIssue, setPublishAsIssue] = useState(false);
// Honeypot: real users never see or fill this (hidden via CSS, no label,
// excluded from tab order); bots that blindly fill every field do. Kept
// in sync with the gateway's "website" field name.
const [website, setWebsite] = useState("");
const [status, setStatus] = useState<"idle" | "sending" | "sent" | "error">("idle");
const [issueUrl, setIssueUrl] = useState<string | undefined>(undefined);
@@ -1694,12 +1698,22 @@ function FeedbackDialog({ onClose }: { onClose: () => void }) {
message: trimmed,
email: email.trim() || undefined,
publishAsIssue,
website,
}),
});
if (!res.ok) throw new Error(String(res.status));
const json = (await res.json()) as { ok?: boolean; githubIssueUrl?: string };
setIssueUrl(json.githubIssueUrl);
setStatus("sent");
// Someone who just sent feedback doesn't need the nudge bubble asking
// them to do exactly that again for a while - push its cooldown out
// from this moment rather than leaving it on whatever schedule it was
// already on.
try {
localStorage.setItem(FEEDBACK_BUBBLE_STORAGE_KEY, String(Date.now()));
} catch {
// ignore
}
} catch {
setStatus("error");
}
@@ -1731,6 +1745,16 @@ function FeedbackDialog({ onClose }: { onClose: () => void }) {
) : (
<>
<p className="ts-feedback-intro">{t("feedback.dialog.intro")}</p>
<input
type="text"
name="website"
value={website}
onChange={(e) => setWebsite(e.target.value)}
className="ts-feedback-honeypot"
tabIndex={-1}
autoComplete="off"
aria-hidden="true"
/>
<label className="ts-dialog-field">
{t("feedback.dialog.category")}
<select value={category} onChange={(e) => setCategory(e.target.value as FeedbackCategory)}>