mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-07-05 12:31:47 +02:00
b1f1363502
Show a one-time toast asking how a feature is working after its third successful use, with an optional comment sent anonymously to the Yaak API (feature key, text, app version, and OS only — nothing identifying, and nothing is sent unless the user clicks Send). - New cmd_send_feedback Tauri command posts fire-and-forget via the shared API client (localhost in dev) - Feature keys registry (cookie-editor, response-history, sse-summary, git-sync) with per-feature use counting in the key-value store - "Never ask for feedback" setting to disable prompts entirely - Toast gains dynamicHeight and hideDismiss props for richer content - Fix missing vertical padding on xs/2xs multiline inputs - Fix unused-import and dead-code warnings in yaak-system-appearance on non-Linux builds Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
66 lines
1.9 KiB
TypeScript
66 lines
1.9 KiB
TypeScript
import { HStack, VStack } from "@yaakapp-internal/ui";
|
|
import { useState } from "react";
|
|
import type { FeedbackFeature } from "../lib/featureFeedback";
|
|
import { FEEDBACK_FEATURES } from "../lib/featureFeedback";
|
|
import { invokeCmd } from "../lib/tauri";
|
|
import { hideToastById, showToast } from "../lib/toast";
|
|
import { Button } from "./core/Button";
|
|
import { Input } from "./core/Input";
|
|
|
|
interface Props {
|
|
feature: FeedbackFeature;
|
|
}
|
|
|
|
export function FeedbackToast({ feature }: Props) {
|
|
const [text, setText] = useState<string>("");
|
|
|
|
const handleDismiss = () => {
|
|
hideToastById(`feature-feedback-${feature}`);
|
|
};
|
|
|
|
const handleSend = () => {
|
|
// Fire-and-forget; failures are intentionally ignored
|
|
invokeCmd("cmd_send_feedback", { feature, text: text.trim() }).catch(() => {});
|
|
showToast({
|
|
id: `feature-feedback-${feature}`,
|
|
timeout: 3000,
|
|
color: "success",
|
|
message: "Thanks for the feedback!",
|
|
});
|
|
};
|
|
|
|
return (
|
|
<VStack space={2}>
|
|
<p className="text-sm font-semibold">{FEEDBACK_FEATURES[feature]}</p>
|
|
<div className="h-20">
|
|
<Input
|
|
size="xs"
|
|
// The editor forces its mono font on the scroller, so the override
|
|
// has to target it directly
|
|
className="[&_.cm-scroller]:font-sans! [&_.cm-scroller]:text-sm!"
|
|
label="Feedback"
|
|
hideLabel
|
|
stateKey={null}
|
|
multiLine
|
|
fullHeight
|
|
placeholder="Your thoughts..."
|
|
onChange={setText}
|
|
/>
|
|
</div>
|
|
<HStack space={1.5} justifyContent="end">
|
|
<Button size="xs" color="secondary" variant="border" onClick={handleDismiss}>
|
|
Dismiss
|
|
</Button>
|
|
<Button
|
|
size="xs"
|
|
color="primary"
|
|
disabled={text.trim().length === 0}
|
|
onClick={handleSend}
|
|
>
|
|
Send
|
|
</Button>
|
|
</HStack>
|
|
</VStack>
|
|
);
|
|
}
|