Skip to content

Commit 38e9b83

Browse files
committed
fix: sizing
1 parent d16dc7e commit 38e9b83

4 files changed

Lines changed: 293 additions & 5 deletions

File tree

src/components/Chat/ChatInterface.stories.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Meta, StoryObj } from '@storybook/react'
22
import { ChatDemo } from './demo'
3+
import { ChatDemoLongMessages } from './demo-long-messages'
34

45
const meta: Meta<typeof ChatDemo> = {
56
title: 'Chat/Chat Interface',
@@ -15,3 +16,15 @@ type Story = StoryObj<typeof ChatDemo>
1516
export const Default: Story = {
1617
name: 'Clean Interface with File Upload & Bottom Capabilities',
1718
}
19+
20+
export const LongMessages: StoryObj<typeof ChatDemoLongMessages> = {
21+
render: () => <ChatDemoLongMessages />,
22+
name: 'Long Text Messages',
23+
parameters: {
24+
docs: {
25+
description: {
26+
story: 'Demonstrates how the chat interface handles very long text messages with proper width constraints and text wrapping.',
27+
},
28+
},
29+
},
30+
}

src/components/Chat/ChatInterface.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,17 +209,17 @@ export function ChatInterface({
209209
return (
210210
<div key={index} className="mb-2 p-2 bg-background/50 rounded-lg">
211211
<div className="flex items-center gap-2">
212-
{getFileIcon(filePart.mimeType || 'application/octet-stream')}
212+
{getFileIcon(filePart.mediaType || 'application/octet-stream')}
213213
<div className="flex-1 min-w-0">
214214
<p className="text-sm font-medium truncate">
215-
{filePart.name || filePart.url?.split('/').pop() || 'File'}
215+
{filePart.filename || filePart.url?.split('/').pop() || 'File'}
216216
</p>
217-
{filePart.size && (
217+
{/* {filePart.size && (
218218
<p className="text-xs opacity-70">{formatFileSize(filePart.size)}</p>
219219
)}
220220
{filePart.mimeType && (
221221
<p className="text-xs opacity-70">{filePart.mimeType}</p>
222-
)}
222+
)} */}
223223
</div>
224224
{filePart.url && (
225225
<Button
@@ -403,7 +403,7 @@ export function ChatInterface({
403403
}
404404

405405
return (
406-
<Card className={`h-full flex flex-col shadow-sm ${className || ""}`}>
406+
<Card className={`h-full flex flex-col shadow-sm max-w-4xl mx-auto ${className || ""}`}>
407407
{/* Chat Messages */}
408408
<ScrollArea
409409
ref={scrollAreaRef}

src/components/Chat/CopilotInterface.stories.tsx

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ export const WithCapabilitiesDemo: Story = {
261261
name: 'Capabilities Demo',
262262
args: {
263263
...baseArgs,
264+
enableAI: false, // Disable AI to use static messages
264265
initialTeam: 'sales',
265266
title: 'Sales Copilot with Capabilities',
266267
messages: [
@@ -309,6 +310,7 @@ export const WithActiveChat: Story = {
309310
name: 'Active Chat Session',
310311
args: {
311312
...baseArgs,
313+
enableAI: false, // Disable AI to use static messages
312314
initialTeam: 'design',
313315
title: 'Design Copilot - Active Session',
314316
messages: [
@@ -452,6 +454,7 @@ export const AllCapabilitiesShowcase: Story = {
452454
name: 'All Capabilities Showcase',
453455
args: {
454456
...baseArgs,
457+
enableAI: false, // Disable AI to use static messages
455458
initialTeam: 'sales',
456459
title: 'All Capabilities Showcase',
457460
messages: [
@@ -500,6 +503,7 @@ export const InteractiveCapabilities: Story = {
500503
name: 'Interactive Capabilities',
501504
args: {
502505
...baseArgs,
506+
enableAI: false, // Disable AI to use static messages
503507
initialTeam: 'marketing',
504508
title: 'Marketing Copilot - Interactive',
505509
messages: [
@@ -548,6 +552,7 @@ export const EnhancedWithFileUpload: Story = {
548552
name: 'Enhanced with File Upload',
549553
args: {
550554
...baseArgs,
555+
enableAI: false, // Disable AI to use static messages
551556
initialTeam: 'engineering',
552557
title: 'Enhanced Engineering Copilot',
553558
enableFileUpload: true,
@@ -619,6 +624,7 @@ export const LongChatHistory: Story = {
619624
name: 'Long Chat History',
620625
args: {
621626
...baseArgs,
627+
enableAI: false, // Disable AI to use static messages
622628
initialTeam: 'engineering',
623629
title: 'Engineering Copilot',
624630
messages: [
@@ -707,6 +713,7 @@ export const EnhancedFeaturesShowcase: Story = {
707713
name: 'Enhanced Features Showcase',
708714
args: {
709715
...baseArgs,
716+
enableAI: false, // Disable AI to use static messages
710717
initialTeam: 'engineering',
711718
title: 'Enhanced AI Assistant',
712719
enableFileUpload: true,
@@ -818,6 +825,7 @@ export const FileUploadDemo: Story = {
818825
name: 'File Upload Demo',
819826
args: {
820827
...baseArgs,
828+
enableAI: false, // Disable AI to use static messages
821829
initialTeam: 'design',
822830
title: 'File Upload Assistant',
823831
enableFileUpload: true,
@@ -981,3 +989,149 @@ export const NoDataProvided: Story = {
981989
},
982990
},
983991
}
992+
993+
export const LongTextMessages: Story = {
994+
name: 'Long Text Messages',
995+
args: {
996+
...baseArgs,
997+
enableAI: false, // Disable AI to use static messages
998+
initialTeam: 'design',
999+
title: 'Design Copilot - Long Messages Test',
1000+
messages: [
1001+
{
1002+
id: "1",
1003+
role: "user",
1004+
parts: [
1005+
{
1006+
type: "text",
1007+
text: "Can you provide me with a comprehensive overview of modern design systems, including their key components, implementation strategies, and best practices for maintaining consistency across large-scale digital products and platforms?"
1008+
}
1009+
]
1010+
},
1011+
{
1012+
id: "2",
1013+
role: "assistant",
1014+
parts: [
1015+
{
1016+
type: "text",
1017+
text: `Absolutely! Here's a comprehensive overview of modern design systems:
1018+
1019+
**What is a Design System?**
1020+
1021+
A design system is a collection of reusable components, patterns, and guidelines that enable teams to build consistent, scalable user interfaces across products and platforms. It serves as the single source of truth for design decisions, bridging the gap between design and development.
1022+
1023+
**Key Components of a Design System:**
1024+
1025+
1. **Foundation Elements**
1026+
• Color palettes with semantic naming conventions
1027+
• Typography scales and font families
1028+
• Spacing and grid systems
1029+
• Iconography and illustration styles
1030+
• Motion and interaction principles
1031+
1032+
2. **Component Library**
1033+
• Basic UI components (buttons, inputs, cards, etc.)
1034+
• Complex patterns (navigation, forms, modals)
1035+
• Layout components (headers, footers, sidebars)
1036+
• Data visualization components
1037+
1038+
3. **Documentation**
1039+
• Usage guidelines and best practices
1040+
• Code examples and implementation guides
1041+
• Accessibility standards and requirements
1042+
• Brand voice and tone guidelines
1043+
1044+
4. **Tokens**
1045+
• Design tokens for cross-platform consistency
1046+
• Semantic color definitions
1047+
• Spacing and sizing values
1048+
• Animation timing and easing functions
1049+
1050+
**Implementation Strategies:**
1051+
1052+
1. **Start Small, Scale Gradually**
1053+
Begin with core components and foundational elements before expanding to complex patterns. This allows for validation and refinement before wide adoption.
1054+
1055+
2. **Cross-functional Collaboration**
1056+
Involve designers, developers, product managers, and content strategists from the beginning to ensure the system meets everyone's needs.
1057+
1058+
3. **Tool Integration**
1059+
• Design tools: Figma, Sketch, Adobe XD
1060+
• Development: React, Vue, Angular component libraries
1061+
• Documentation: Storybook, Zeroheight, Notion
1062+
• Version control: Git for both design and code
1063+
1064+
4. **Governance Model**
1065+
Establish clear processes for:
1066+
• Contributing new components
1067+
• Updating existing patterns
1068+
• Deprecating outdated elements
1069+
• Quality assurance and review
1070+
1071+
**Best Practices for Maintenance:**
1072+
1073+
1. **Version Control**
1074+
Treat your design system like any software product with proper versioning, changelogs, and migration guides.
1075+
1076+
2. **Regular Audits**
1077+
Conduct quarterly reviews to identify inconsistencies, unused components, and opportunities for improvement.
1078+
1079+
3. **Community Building**
1080+
Foster a community of contributors and users through:
1081+
• Regular office hours and workshops
1082+
• Feedback channels and feature requests
1083+
• Success stories and case studies
1084+
1085+
4. **Measurement and Analytics**
1086+
Track adoption metrics, component usage, and developer satisfaction to guide future improvements.
1087+
1088+
**Challenges and Solutions:**
1089+
1090+
• **Adoption Resistance**: Combat by showing clear ROI and providing excellent developer experience
1091+
• **Maintenance Overhead**: Invest in automation and clear governance processes
1092+
• **Platform Differences**: Use design tokens and platform-specific implementations
1093+
• **Keeping Current**: Regular updates and staying aligned with design trends
1094+
1095+
**Tools and Technologies:**
1096+
1097+
• **Design**: Figma with design system libraries, Tokens Studio
1098+
• **Development**: Styled-components, Tailwind CSS, Emotion
1099+
• **Documentation**: Storybook, Chromatic for visual testing
1100+
• **Distribution**: NPM packages, CDNs, or internal registries
1101+
1102+
Modern design systems are living, breathing entities that evolve with your product and organization. The key to success lies in treating them as products themselves, with dedicated resources, clear ownership, and continuous improvement based on user feedback.
1103+
1104+
Would you like me to dive deeper into any specific aspect of design systems?`
1105+
}
1106+
]
1107+
},
1108+
{
1109+
id: "3",
1110+
role: "user",
1111+
parts: [
1112+
{
1113+
type: "text",
1114+
text: "This is a test of an extremely long user message to ensure that the chat interface properly handles text wrapping and width constraints. When users write very lengthy messages that contain multiple sentences, paragraphs, and extensive content, the interface should maintain proper formatting and not cause the layout to break or become too wide. The message bubble should respect the maximum width constraints while ensuring that the text is still readable and properly formatted. This is especially important in professional environments where users might paste large amounts of text, write detailed specifications, or engage in lengthy discussions about complex topics. The chat interface should gracefully handle all of these scenarios while maintaining a clean, professional appearance that doesn't compromise the overall user experience or visual design of the application."
1115+
}
1116+
]
1117+
},
1118+
{
1119+
id: "4",
1120+
role: "assistant",
1121+
parts: [
1122+
{
1123+
type: "text",
1124+
text: "Perfect! Your long message demonstrates exactly what we needed to test. As you can see, the chat interface now properly handles very long text messages by:\n\n• **Width Constraints**: The overall chat container is limited to max-w-4xl to prevent excessive horizontal expansion\n• **Text Wrapping**: Using break-words CSS property to ensure long words don't overflow\n• **Message Bubbles**: Individual messages respect the max-w-[80%] constraint while maintaining readability\n• **Whitespace Handling**: The whitespace-pre-wrap property preserves intentional line breaks\n• **Visual Hierarchy**: Long messages maintain proper spacing and visual separation\n\nThese improvements ensure that whether users are discussing brief topics or engaging in detailed technical conversations, the interface remains functional, visually appealing, and easy to read across all device sizes."
1125+
}
1126+
]
1127+
}
1128+
],
1129+
},
1130+
parameters: {
1131+
docs: {
1132+
description: {
1133+
story: 'Demonstrates how the CopilotInterface handles very long text messages with proper width constraints, text wrapping, and formatting to ensure readability and visual consistency.',
1134+
},
1135+
},
1136+
},
1137+
}
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
/**
2+
* Demo component to test the ChatInterface with very long text messages
3+
* to ensure proper width constraints and text wrapping
4+
*/
5+
6+
import React, { useState } from 'react'
7+
import { CopilotInterface } from './CopilotInterface'
8+
import type { UIMessage } from 'ai'
9+
import { testCapabilities } from '../../test-data/capabilities'
10+
11+
const longMessageDemo: UIMessage[] = [
12+
{
13+
id: '1',
14+
role: 'user',
15+
parts: [
16+
{
17+
type: 'text',
18+
text: 'Can you write me a comprehensive analysis of the current state of artificial intelligence and machine learning technologies, including their applications, limitations, and future prospects?'
19+
}
20+
]
21+
},
22+
{
23+
id: '2',
24+
role: 'assistant',
25+
parts: [
26+
{
27+
type: 'text',
28+
text: `Here's a comprehensive analysis of the current state of AI and ML technologies:
29+
30+
**Current State of Artificial Intelligence and Machine Learning**
31+
32+
Artificial Intelligence (AI) and Machine Learning (ML) have experienced unprecedented growth and adoption across virtually every industry in recent years. We're currently in what many experts consider the "golden age" of AI, characterized by breakthrough achievements in natural language processing, computer vision, and autonomous systems.
33+
34+
**Key Applications:**
35+
36+
1. **Natural Language Processing**: Large Language Models like GPT-4, Claude, and others have revolutionized how we interact with computers, enabling conversational AI, content generation, code assistance, and translation services that approach human-level quality.
37+
38+
2. **Computer Vision**: AI systems can now accurately identify objects, faces, and scenes in images and videos, powering applications from medical imaging diagnosis to autonomous vehicle navigation and augmented reality experiences.
39+
40+
3. **Recommendation Systems**: Platforms like Netflix, Amazon, and Spotify use sophisticated ML algorithms to personalize user experiences, driving significant business value and user engagement.
41+
42+
4. **Healthcare**: AI is transforming medical diagnosis, drug discovery, and treatment planning, with systems that can detect diseases earlier and more accurately than human specialists in some cases.
43+
44+
5. **Financial Services**: From fraud detection and algorithmic trading to credit scoring and risk assessment, ML models are integral to modern financial operations.
45+
46+
**Current Limitations:**
47+
48+
Despite remarkable progress, several significant limitations remain:
49+
50+
1. **Data Quality and Bias**: AI systems are only as good as the data they're trained on, and biased or incomplete datasets can lead to unfair or inaccurate outcomes.
51+
52+
2. **Interpretability**: Many advanced AI models, particularly deep neural networks, operate as "black boxes," making it difficult to understand how they arrive at specific decisions.
53+
54+
3. **Energy Consumption**: Training and running large AI models requires substantial computational resources and energy, raising environmental concerns.
55+
56+
4. **Generalization**: While AI excels in specific domains, achieving artificial general intelligence (AGI) that can perform any intellectual task remains elusive.
57+
58+
5. **Safety and Alignment**: Ensuring AI systems behave safely and align with human values becomes increasingly challenging as they become more powerful.
59+
60+
**Future Prospects:**
61+
62+
The future of AI holds immense promise across multiple dimensions:
63+
64+
1. **Multimodal AI**: Integration of text, image, audio, and video processing will enable more natural and comprehensive AI interactions.
65+
66+
2. **Edge AI**: Deployment of AI directly on devices will reduce latency, improve privacy, and enable offline functionality.
67+
68+
3. **AI-Assisted Scientific Discovery**: AI will accelerate research in fields like materials science, climate modeling, and space exploration.
69+
70+
4. **Personalized Education**: Adaptive learning systems will provide customized educational experiences tailored to individual learning styles and pace.
71+
72+
5. **Sustainable AI**: Development of more efficient algorithms and hardware will reduce the environmental impact of AI systems.
73+
74+
The next decade will likely see AI becoming even more integrated into our daily lives, while addressing current limitations through improved techniques, better governance frameworks, and more sustainable practices. The key will be balancing innovation with responsible development to ensure AI benefits humanity as a whole.`
75+
}
76+
]
77+
},
78+
{
79+
id: '3',
80+
role: 'user',
81+
parts: [
82+
{
83+
type: 'text',
84+
text: 'This is an extremely long message to test the width constraints of the chat interface and ensure that even when I write a very long message that goes on and on and on, it still maintains proper formatting and doesn\'t cause the chat interface to become too wide or break the layout. The message should wrap properly and maintain readability while staying within the maximum width constraints that have been set for the chat bubbles. This is important for user experience and ensuring that the interface remains functional and visually appealing even with extensive text content.'
85+
}
86+
]
87+
},
88+
{
89+
id: '4',
90+
role: 'assistant',
91+
parts: [
92+
{
93+
type: 'text',
94+
text: 'Perfect! Your long message demonstrates exactly what we needed to test. As you can see, the chat interface now properly handles long text messages by:\n\n• Constraining the overall chat width with max-w-4xl\n• Using break-words to prevent text overflow\n• Maintaining the max-w-[80%] constraint on individual message bubbles\n• Preserving whitespace and line breaks with whitespace-pre-wrap\n• Ensuring proper text wrapping for readability\n\nThe interface remains visually appealing and functional regardless of message length, which is crucial for a good user experience.'
95+
}
96+
]
97+
}
98+
]
99+
100+
export function ChatDemoLongMessages() {
101+
const [messages, setMessages] = useState<UIMessage[]>(longMessageDemo)
102+
103+
return (
104+
<div className="h-screen w-full">
105+
<CopilotInterface
106+
messages={messages}
107+
capabilities={testCapabilities}
108+
enableFileUpload={true}
109+
maxFileSize={10}
110+
allowedFileTypes={['*']}
111+
businessUnits={[]}
112+
sessions={[]}
113+
notifications={[]}
114+
onNewChat={() => setMessages(longMessageDemo)}
115+
onSessionSelect={() => {}}
116+
onSessionDelete={() => {}}
117+
showCapabilities={true}
118+
/>
119+
</div>
120+
)
121+
}

0 commit comments

Comments
 (0)