-
Notifications
You must be signed in to change notification settings - Fork 4.4k
feat: Add in-app feedback collection widget to desktop GUI #7763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
jh-block
wants to merge
2
commits into
main
Choose a base branch
from
jhugo/gui-feedback-widget
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| import { useState } from 'react'; | ||
|
|
||
| interface FeedbackBannerProps { | ||
| onRate: (rating: 1 | 2 | 3 | 4) => void; | ||
| onDismiss: () => void; | ||
| } | ||
|
|
||
| const ratingOptions: Array<{ rating: 1 | 2 | 3 | 4; emoji: string; label: string }> = [ | ||
| { rating: 1, emoji: '\u{1F623}', label: 'Frustrating' }, | ||
| { rating: 2, emoji: '\u{1F615}', label: 'Poor' }, | ||
| { rating: 3, emoji: '\u{1F642}', label: 'Good' }, | ||
| { rating: 4, emoji: '\u{1F929}', label: 'Great' }, | ||
| ]; | ||
|
|
||
| const DISCORD_URL = 'https://discord.gg/goose-oss'; | ||
|
|
||
| export default function FeedbackBanner({ onRate, onDismiss }: FeedbackBannerProps) { | ||
| const [submittedRating, setSubmittedRating] = useState<1 | 2 | 3 | 4 | null>(null); | ||
|
|
||
| const handleRate = (rating: 1 | 2 | 3 | 4) => { | ||
| setSubmittedRating(rating); | ||
| if (rating > 1) { | ||
| setTimeout(() => onRate(rating), 1000); | ||
| } | ||
| }; | ||
|
|
||
| const handleDismissAfterLowRating = () => { | ||
| if (submittedRating) { | ||
| onRate(submittedRating); | ||
| } | ||
| }; | ||
|
|
||
| if (submittedRating === 1) { | ||
| return ( | ||
| <div className="flex flex-col items-center gap-1.5 py-2 animate-[fadein_300ms_ease-in_forwards]"> | ||
| <span className="text-xs text-text-secondary"> | ||
| Sorry to hear that. Let us know how we can improve: | ||
| </span> | ||
| <div className="flex items-center gap-3 text-xs"> | ||
| <a | ||
| href={DISCORD_URL} | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| onClick={handleDismissAfterLowRating} | ||
| className="text-text-secondary underline hover:text-text-primary transition-colors" | ||
| > | ||
| Chat on Discord | ||
| </a> | ||
| <button | ||
| onClick={handleDismissAfterLowRating} | ||
| className="ml-1 p-0.5 rounded text-text-secondary hover:text-text-primary hover:bg-background-secondary transition-colors cursor-pointer" | ||
| title="Dismiss" | ||
| aria-label="Dismiss" | ||
| > | ||
| <svg | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| width="14" | ||
| height="14" | ||
| viewBox="0 0 24 24" | ||
| fill="none" | ||
| stroke="currentColor" | ||
| strokeWidth="2" | ||
| strokeLinecap="round" | ||
| strokeLinejoin="round" | ||
| > | ||
| <line x1="18" y1="6" x2="6" y2="18" /> | ||
| <line x1="6" y1="6" x2="18" y2="18" /> | ||
| </svg> | ||
| </button> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| if (submittedRating) { | ||
| return ( | ||
| <div className="flex items-center justify-center py-2 text-xs text-text-secondary animate-[fadein_300ms_ease-in_forwards]"> | ||
| Thanks for the feedback! | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <div className="flex items-center justify-center gap-3 py-2 animate-[fadein_300ms_ease-in_forwards]"> | ||
| <span className="text-xs text-text-secondary">How's Goose doing?</span> | ||
| <div className="flex items-center gap-1"> | ||
| {ratingOptions.map(({ rating, emoji, label }) => ( | ||
| <button | ||
| key={rating} | ||
| onClick={() => handleRate(rating)} | ||
| className="p-1 rounded hover:bg-background-secondary transition-colors cursor-pointer" | ||
| title={label} | ||
| aria-label={label} | ||
| > | ||
| <span className="text-base">{emoji}</span> | ||
| </button> | ||
| ))} | ||
| </div> | ||
| <button | ||
| onClick={onDismiss} | ||
| className="ml-1 p-0.5 rounded text-text-secondary hover:text-text-primary hover:bg-background-secondary transition-colors cursor-pointer" | ||
| title="Dismiss" | ||
| aria-label="Dismiss feedback prompt" | ||
| > | ||
| <svg | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| width="14" | ||
| height="14" | ||
| viewBox="0 0 24 24" | ||
| fill="none" | ||
| stroke="currentColor" | ||
| strokeWidth="2" | ||
| strokeLinecap="round" | ||
| strokeLinejoin="round" | ||
| > | ||
| <line x1="18" y1="6" x2="6" y2="18" /> | ||
| <line x1="6" y1="6" x2="18" y2="18" /> | ||
| </svg> | ||
| </button> | ||
| </div> | ||
| ); | ||
| } | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| import { useCallback, useEffect, useRef, useState } from 'react'; | ||
| import { canTrack, trackFeedbackSubmitted, trackFeedbackDismissed } from '../utils/analytics'; | ||
| import { ChatState } from '../types/chatState'; | ||
|
|
||
| const EXCHANGE_INTERVAL = 5; // Show after every Nth exchange | ||
| const IN_SESSION_COOLDOWN_MS = 2 * 60 * 60 * 1000; // 2 hours | ||
| const CROSS_SESSION_COOLDOWN_MS = 24 * 60 * 60 * 1000; // 24 hours | ||
|
|
||
| interface UseFeedbackPromptOptions { | ||
| messageCount: number; | ||
| chatState: ChatState; | ||
| provider?: string | null; | ||
| model?: string | null; | ||
| } | ||
|
|
||
| export function useFeedbackPrompt({ | ||
| messageCount, | ||
| chatState, | ||
| provider, | ||
| model, | ||
| }: UseFeedbackPromptOptions) { | ||
| const [showFeedback, setShowFeedback] = useState(false); | ||
| const exchangeCountRef = useRef(0); | ||
| const lastPromptTimeRef = useRef(0); | ||
| const prevChatStateRef = useRef<ChatState>(chatState); | ||
|
|
||
| useEffect(() => { | ||
| const wasStreaming = prevChatStateRef.current !== ChatState.Idle; | ||
| const isNowIdle = chatState === ChatState.Idle; | ||
| prevChatStateRef.current = chatState; | ||
|
|
||
| // Only trigger when transitioning from streaming to idle | ||
| if (!wasStreaming || !isNowIdle) return; | ||
|
|
||
| // Check telemetry at event time (it can change during the session) | ||
| if (!canTrack()) return; | ||
|
|
||
| exchangeCountRef.current += 1; | ||
| const count = exchangeCountRef.current; | ||
|
|
||
| // Only show on every Nth exchange, never before the first interval | ||
| if (count < EXCHANGE_INTERVAL || count % EXCHANGE_INTERVAL !== 0) return; | ||
|
|
||
| // In-session cooldown | ||
| const now = Date.now(); | ||
| if (now - lastPromptTimeRef.current < IN_SESSION_COOLDOWN_MS) return; | ||
|
|
||
| // Cross-session cooldown (async check) | ||
| (async () => { | ||
| try { | ||
| const lastTimestamp = | ||
| (await window.electron.getSetting('lastFeedbackTimestamp')) as number; | ||
| if (lastTimestamp && now - lastTimestamp < CROSS_SESSION_COOLDOWN_MS) return; | ||
| } catch { | ||
| // If settings read fails, proceed anyway | ||
| } | ||
|
|
||
| lastPromptTimeRef.current = now; | ||
| setShowFeedback(true); | ||
| })(); | ||
| }, [chatState]); | ||
|
|
||
| const onRate = useCallback( | ||
| (rating: 1 | 2 | 3 | 4) => { | ||
| setShowFeedback(false); | ||
| trackFeedbackSubmitted(rating, messageCount, provider || undefined, model || undefined); | ||
| try { | ||
| window.electron.setSetting('lastFeedbackTimestamp', Date.now()); | ||
| } catch { | ||
| // Best-effort persistence | ||
| } | ||
| }, | ||
| [messageCount, provider, model] | ||
| ); | ||
|
|
||
| const onDismiss = useCallback(() => { | ||
| setShowFeedback(false); | ||
| trackFeedbackDismissed(messageCount); | ||
| try { | ||
| window.electron.setSetting('lastFeedbackTimestamp', Date.now()); | ||
| } catch { | ||
| // Best-effort persistence | ||
| } | ||
| }, [messageCount]); | ||
|
|
||
| return { showFeedback, onRate, onDismiss }; | ||
| } |
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the time out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the rating is not the worst one, it shows an acknowledgement ("Thanks for the feedback!") briefly and then removes the whole feedback banner so that it doesn't clutter the chat. Without the timeout it would disappear straight away.
If the rating is the worst one it shows "Sorry to hear that. Let us know how we can improve:" with a link to discord, and doesn't remove it automatically -- it removes it when you either click the discord link or click to dismiss the message
definitely open to any UX feedback here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have a toast mechanism for that already?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have one that's inline in the chat? it might be a bit jarring to do the top-right toast which is quite distant from where the interaction is. i'll have a play with it