Skip to content

Commit 0f09b5f

Browse files
committed
Add isGenerating prop to ChatHistory for disabling during content generation
1 parent 4cf11f1 commit 0f09b5f

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

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

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,16 @@ interface ChatHistoryProps {
4040
onSelectConversation: (conversationId: string) => void;
4141
onNewConversation: () => void;
4242
refreshTrigger?: number; // Increment to trigger refresh
43+
isGenerating?: boolean; // True when content generation is in progress
4344
}
4445

4546
export function ChatHistory({
4647
currentConversationId,
4748
currentMessages = [],
4849
onSelectConversation,
4950
onNewConversation,
50-
refreshTrigger = 0
51+
refreshTrigger = 0,
52+
isGenerating = false
5153
}: ChatHistoryProps) {
5254
const [conversations, setConversations] = useState<ConversationSummary[]>([]);
5355
const [isLoading, setIsLoading] = useState(true);
@@ -243,6 +245,7 @@ export function ChatHistory({
243245
onDelete={handleDeleteConversation}
244246
onRename={handleRenameConversation}
245247
onRefresh={loadConversations}
248+
disabled={isGenerating}
246249
/>
247250
))}
248251
</>
@@ -264,23 +267,27 @@ export function ChatHistory({
264267
}}>
265268
{hasMore && (
266269
<Link
267-
onClick={() => setShowAll(!showAll)}
270+
onClick={isGenerating ? undefined : () => setShowAll(!showAll)}
268271
style={{
269272
fontSize: '13px',
270-
color: tokens.colorBrandForeground1,
273+
color: isGenerating ? tokens.colorNeutralForegroundDisabled : tokens.colorBrandForeground1,
274+
cursor: isGenerating ? 'not-allowed' : 'pointer',
275+
pointerEvents: isGenerating ? 'none' : 'auto',
271276
}}
272277
>
273278
{showAll ? 'Show less' : 'See all'}
274279
</Link>
275280
)}
276281
<Link
277-
onClick={onNewConversation}
282+
onClick={isGenerating ? undefined : onNewConversation}
278283
style={{
279284
display: 'flex',
280285
alignItems: 'center',
281286
gap: '8px',
282287
fontSize: '13px',
283-
color: tokens.colorNeutralForeground1,
288+
color: isGenerating ? tokens.colorNeutralForegroundDisabled : tokens.colorNeutralForeground1,
289+
cursor: isGenerating ? 'not-allowed' : 'pointer',
290+
pointerEvents: isGenerating ? 'none' : 'auto',
284291
}}
285292
>
286293
<Compose20Regular />
@@ -299,6 +306,7 @@ interface ConversationItemProps {
299306
onDelete: (conversationId: string) => void;
300307
onRename: (conversationId: string, newTitle: string) => void;
301308
onRefresh: () => void;
309+
disabled?: boolean;
302310
}
303311

304312
function ConversationItem({
@@ -308,6 +316,7 @@ function ConversationItem({
308316
onDelete,
309317
onRename,
310318
onRefresh,
319+
disabled = false,
311320
}: ConversationItemProps) {
312321
const [isMenuOpen, setIsMenuOpen] = useState(false);
313322
const [isRenameDialogOpen, setIsRenameDialogOpen] = useState(false);
@@ -350,10 +359,10 @@ function ConversationItem({
350359
return (
351360
<>
352361
<div
353-
onClick={onSelect}
362+
onClick={disabled ? undefined : onSelect}
354363
style={{
355364
padding: '8px',
356-
cursor: 'pointer',
365+
cursor: disabled ? 'not-allowed' : 'pointer',
357366
display: 'flex',
358367
alignItems: 'center',
359368
justifyContent: 'space-between',
@@ -368,6 +377,8 @@ function ConversationItem({
368377
marginLeft: '-8px',
369378
marginRight: '-8px',
370379
transition: 'background-color 0.15s, border-color 0.15s',
380+
opacity: disabled ? 0.5 : 1,
381+
pointerEvents: disabled ? 'none' : 'auto',
371382
}}
372383
>
373384
<Text

0 commit comments

Comments
 (0)