MCPcopy
hub / github.com/codeaashu/claude-code / useMemorySurvey

Function useMemorySurvey

src/components/FeedbackSurvey/useMemorySurvey.tsx:47–212  ·  view source on GitHub ↗
(messages: Message[], isLoading: boolean, hasActivePrompt = false, {
  enabled = true
}: {
  enabled?: boolean;
} = {})

Source from the content-addressed store, hash-verified

45 return false;
46}
47export function useMemorySurvey(messages: Message[], isLoading: boolean, hasActivePrompt = false, {
48 enabled = true
49}: {
50 enabled?: boolean;
51} = {}): {
52 state: 'closed' | 'open' | 'thanks' | 'transcript_prompt' | 'submitting' | 'submitted';
53 lastResponse: FeedbackSurveyResponse | null;
54 handleSelect: (selected: FeedbackSurveyResponse) => void;
55 handleTranscriptSelect: (selected: TranscriptShareResponse) => void;
56} {
57 // Track assistant message UUIDs that were already evaluated so we don't
58 // re-roll probability on re-renders or re-scan messages for the same turn.
59 const seenAssistantUuids = useRef<Set<string>>(new Set());
60 // Once a memory file read is observed it stays true for the session —
61 // skip the O(n) scan on subsequent turns.
62 const memoryReadSeen = useRef(false);
63 const messagesRef = useRef(messages);
64 messagesRef.current = messages;
65 const onOpen = useCallback((appearanceId: string) => {
66 logEvent(MEMORY_SURVEY_EVENT, {
67 event_type: 'appeared' as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
68 appearance_id: appearanceId as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS
69 });
70 void logOTelEvent('feedback_survey', {
71 event_type: 'appeared',
72 appearance_id: appearanceId,
73 survey_type: 'memory'
74 });
75 }, []);
76 const onSelect = useCallback((appearanceId_0: string, selected: FeedbackSurveyResponse) => {
77 logEvent(MEMORY_SURVEY_EVENT, {
78 event_type: 'responded' as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
79 appearance_id: appearanceId_0 as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
80 response: selected as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS
81 });
82 void logOTelEvent('feedback_survey', {
83 event_type: 'responded',
84 appearance_id: appearanceId_0,
85 response: selected,
86 survey_type: 'memory'
87 });
88 }, []);
89 const shouldShowTranscriptPrompt = useCallback((selected_0: FeedbackSurveyResponse) => {
90 if ("external" !== 'ant') {
91 return false;
92 }
93 if (selected_0 !== 'bad' && selected_0 !== 'good') {
94 return false;
95 }
96 if (getGlobalConfig().transcriptShareDismissed) {
97 return false;
98 }
99 if (!isPolicyAllowed('allow_product_feedback')) {
100 return false;
101 }
102 return true;
103 }, []);
104 const onTranscriptPromptShown = useCallback((appearanceId_1: string) => {

Callers 1

REPLFunction · 0.85

Calls 15

logEventFunction · 0.85
logOTelEventFunction · 0.85
getGlobalConfigFunction · 0.85
isPolicyAllowedFunction · 0.85
saveGlobalConfigFunction · 0.85
submitTranscriptShareFunction · 0.85
useSurveyStateFunction · 0.85
getLastAssistantMessageFunction · 0.85
isAutoMemoryEnabledFunction · 0.85
isFeedbackSurveyDisabledFunction · 0.85
isEnvTruthyFunction · 0.85

Tested by

no test coverage detected