Skip to content

Commit f336f3b

Browse files
refactor: extract AI_DISCLAIMER constant, remove dead selector and trivial useMemo
1 parent bfce2ef commit f336f3b

10 files changed

Lines changed: 21 additions & 30 deletions

File tree

content-gen/src/app/frontend/src/components/BriefReview.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
tokens,
66
} from '@fluentui/react-components';
77
import type { CreativeBrief } from '../types';
8-
import { BRIEF_FIELD_LABELS, BRIEF_DISPLAY_ORDER, BRIEF_FIELD_KEYS } from '../utils';
8+
import { BRIEF_FIELD_LABELS, BRIEF_DISPLAY_ORDER, BRIEF_FIELD_KEYS, AI_DISCLAIMER } from '../utils';
99

1010
interface BriefReviewProps {
1111
brief: CreativeBrief;
@@ -154,7 +154,7 @@ export const BriefReview = memo(function BriefReview({
154154
paddingTop: '8px',
155155
}}>
156156
<Text size={100} style={{ color: tokens.colorNeutralForeground4 }}>
157-
AI-generated content may be incorrect
157+
{AI_DISCLAIMER}
158158
</Text>
159159
</div>
160160
</div>

content-gen/src/app/frontend/src/components/ChatHistory.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,7 @@ export const ChatHistory = memo(function ChatHistory({
142142
() => showAll ? displayConversations : displayConversations.slice(0, INITIAL_COUNT),
143143
[showAll, displayConversations],
144144
);
145-
const hasMore = useMemo(
146-
() => displayConversations.length > INITIAL_COUNT,
147-
[displayConversations.length],
148-
);
145+
const hasMore = displayConversations.length > INITIAL_COUNT;
149146

150147
const handleRefreshConversations = useCallback(() => {
151148
dispatch(fetchConversations());

content-gen/src/app/frontend/src/components/ChatInput.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
Tooltip,
66
tokens,
77
} from '@fluentui/react-components';
8+
import { AI_DISCLAIMER } from '../utils';
89
import {
910
Send20Regular,
1011
Add20Regular,
@@ -140,7 +141,7 @@ export const ChatInput = memo(function ChatInput({
140141
fontSize: '12px',
141142
}}
142143
>
143-
AI generated content may be incorrect
144+
{AI_DISCLAIMER}
144145
</Text>
145146
</div>
146147
);

content-gen/src/app/frontend/src/components/ChatPanel.tsx

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState, useMemo, useCallback, memo } from 'react';
1+
import { useState, useCallback, memo } from 'react';
22
import type { Product } from '../types';
33
import { BriefReview } from './BriefReview';
44
import { ConfirmedBriefView } from './ConfirmedBriefView';
@@ -62,22 +62,10 @@ export const ChatPanel = memo(function ChatPanel({
6262
]);
6363

6464
// Determine if we should show inline components
65-
const showBriefReview = useMemo(
66-
() => !!(pendingBrief && onBriefConfirm && onBriefCancel),
67-
[pendingBrief, onBriefConfirm, onBriefCancel],
68-
);
69-
const showProductReview = useMemo(
70-
() => !!(confirmedBrief && !generatedContent && onGenerateContent),
71-
[confirmedBrief, generatedContent, onGenerateContent],
72-
);
73-
const showContentPreview = useMemo(
74-
() => !!(generatedContent && onRegenerateContent),
75-
[generatedContent, onRegenerateContent],
76-
);
77-
const showWelcome = useMemo(
78-
() => messages.length === 0 && !showBriefReview && !showProductReview && !showContentPreview,
79-
[messages.length, showBriefReview, showProductReview, showContentPreview],
80-
);
65+
const showBriefReview = !!(pendingBrief && onBriefConfirm && onBriefCancel);
66+
const showProductReview = !!(confirmedBrief && !generatedContent && onGenerateContent);
67+
const showContentPreview = !!(generatedContent && onRegenerateContent);
68+
const showWelcome = messages.length === 0 && !showBriefReview && !showProductReview && !showContentPreview;
8169

8270
// Handle suggestion click from welcome card
8371
const handleSuggestionClick = useCallback((prompt: string) => {

content-gen/src/app/frontend/src/components/ComplianceSection.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { memo } from 'react';
2+
import { AI_DISCLAIMER } from '../utils';
23
import {
34
Text,
45
Badge,
@@ -145,7 +146,7 @@ export const ComplianceSection = memo(function ComplianceSection({
145146
marginTop: '8px',
146147
}}
147148
>
148-
AI-generated content may be incorrect
149+
{AI_DISCLAIMER}
149150
</Text>
150151

151152
{/* Collapsible Compliance Accordion */}

content-gen/src/app/frontend/src/components/MessageBubble.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { Copy20Regular } from '@fluentui/react-icons';
1010
import ReactMarkdown from 'react-markdown';
1111
import type { ChatMessage } from '../types';
1212
import { useCopyToClipboard } from '../hooks';
13+
import { AI_DISCLAIMER } from '../utils';
1314

1415
export interface MessageBubbleProps {
1516
message: ChatMessage;
@@ -91,7 +92,7 @@ export const MessageBubble = memo(function MessageBubble({ message }: MessageBub
9192
fontSize: '11px',
9293
}}
9394
>
94-
AI-generated content may be incorrect
95+
{AI_DISCLAIMER}
9596
</Text>
9697

9798
<div className="assistant-actions" style={{ display: 'flex', gap: '4px' }}>

content-gen/src/app/frontend/src/components/ProductCard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { memo, useMemo } from 'react';
1+
import { memo } from 'react';
22
import {
33
Text,
44
tokens,
@@ -30,7 +30,7 @@ export const ProductCard = memo(function ProductCard({
3030
}: ProductCardProps) {
3131
const isCompact = size === 'compact';
3232
const imgSize = isCompact ? 56 : 80;
33-
const isInteractive = useMemo(() => !!onClick && !disabled, [onClick, disabled]);
33+
const isInteractive = !!onClick && !disabled;
3434

3535
return (
3636
<div

content-gen/src/app/frontend/src/components/ProductReview.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
Sparkle20Regular,
99
} from '@fluentui/react-icons';
1010
import type { Product } from '../types';
11+
import { AI_DISCLAIMER } from '../utils';
1112
import { ProductCard } from './ProductCard';
1213

1314
interface ProductReviewProps {
@@ -126,7 +127,7 @@ export const ProductReview = memo(function ProductReview({
126127
paddingTop: '8px',
127128
}}>
128129
<Text size={100} style={{ color: tokens.colorNeutralForeground4 }}>
129-
AI-generated content may be incorrect
130+
{AI_DISCLAIMER}
130131
</Text>
131132
</div>
132133
</div>

content-gen/src/app/frontend/src/store/selectors.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import type { RootState } from './store';
99
export const selectUserId = (state: RootState) => state.app.userId;
1010
export const selectUserName = (state: RootState) => state.app.userName;
1111
export const selectIsLoading = (state: RootState) => state.app.isLoading;
12-
export const selectGenerationStatus = (state: RootState) => state.app.generationStatus;
1312
export const selectGenerationStatusLabel = (state: RootState) => state.app.generationStatusLabel;
1413
export const selectImageGenerationEnabled = (state: RootState) => state.app.imageGenerationEnabled;
1514
export const selectShowChatHistory = (state: RootState) => state.app.showChatHistory;

content-gen/src/app/frontend/src/utils/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@ export { isContentFilterError, getErrorMessage } from './contentErrors';
2727

2828
// Image download
2929
export { downloadImage } from './downloadImage';
30+
31+
// Shared UI constants
32+
export const AI_DISCLAIMER = 'AI-generated content may be incorrect';

0 commit comments

Comments
 (0)