@agent-relay/dashboard 2.0.81 → 2.0.82

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (244) hide show
  1. package/out/404.html +1 -1
  2. package/out/_next/static/chunks/{118-4c8241b0218335de.js → 118-ae2b650136a5a5fc.js} +1 -1
  3. package/out/_next/static/chunks/407-0c82986cf79c8ecb.js +1 -0
  4. package/out/_next/static/chunks/app/app/[[...slug]]/{page-1e81c047cff17212.js → page-f7eca1b66fb4249b.js} +1 -1
  5. package/out/_next/static/chunks/app/{page-6892fe2dd07fb48b.js → page-0ee604f7070d14c0.js} +1 -1
  6. package/out/_next/static/css/8968d98ed4c4d33f.css +1 -0
  7. package/out/about.html +2 -2
  8. package/out/about.txt +1 -1
  9. package/out/app/onboarding.html +1 -1
  10. package/out/app/onboarding.txt +1 -1
  11. package/out/app.html +1 -1
  12. package/out/app.txt +2 -2
  13. package/out/blog/go-to-bed-wake-up-to-a-finished-product.html +2 -2
  14. package/out/blog/go-to-bed-wake-up-to-a-finished-product.txt +1 -1
  15. package/out/blog/let-them-cook-multi-agent-orchestration.html +2 -2
  16. package/out/blog/let-them-cook-multi-agent-orchestration.txt +2 -2
  17. package/out/blog.html +2 -2
  18. package/out/blog.txt +1 -1
  19. package/out/careers.html +2 -2
  20. package/out/careers.txt +1 -1
  21. package/out/changelog.html +2 -2
  22. package/out/changelog.txt +1 -1
  23. package/out/cloud/link.html +1 -1
  24. package/out/cloud/link.txt +2 -2
  25. package/out/complete-profile.html +2 -2
  26. package/out/complete-profile.txt +1 -1
  27. package/out/connect-repos.html +1 -1
  28. package/out/connect-repos.txt +1 -1
  29. package/out/contact.html +2 -2
  30. package/out/contact.txt +1 -1
  31. package/out/docs.html +2 -2
  32. package/out/docs.txt +1 -1
  33. package/out/history.html +1 -1
  34. package/out/history.txt +2 -2
  35. package/out/index.html +1 -1
  36. package/out/index.txt +2 -2
  37. package/out/login.html +2 -2
  38. package/out/login.txt +1 -1
  39. package/out/metrics.html +1 -1
  40. package/out/metrics.txt +2 -2
  41. package/out/pricing.html +2 -2
  42. package/out/pricing.txt +1 -1
  43. package/out/privacy.html +2 -2
  44. package/out/privacy.txt +1 -1
  45. package/out/providers/setup/claude.html +1 -1
  46. package/out/providers/setup/claude.txt +1 -1
  47. package/out/providers/setup/codex.html +1 -1
  48. package/out/providers/setup/codex.txt +1 -1
  49. package/out/providers/setup/cursor.html +1 -1
  50. package/out/providers/setup/cursor.txt +1 -1
  51. package/out/providers.html +1 -1
  52. package/out/providers.txt +1 -1
  53. package/out/security.html +2 -2
  54. package/out/security.txt +1 -1
  55. package/out/signup.html +2 -2
  56. package/out/signup.txt +1 -1
  57. package/out/terms.html +2 -2
  58. package/out/terms.txt +1 -1
  59. package/package.json +7 -1
  60. package/src/app/about/page.tsx +7 -0
  61. package/src/app/app/[[...slug]]/DashboardPageClient.tsx +853 -0
  62. package/src/app/app/[[...slug]]/page.tsx +23 -0
  63. package/src/app/app/onboarding/page.tsx +394 -0
  64. package/src/app/apple-icon.png +0 -0
  65. package/src/app/blog/go-to-bed-wake-up-to-a-finished-product/page.tsx +88 -0
  66. package/src/app/blog/let-them-cook-multi-agent-orchestration/page.tsx +93 -0
  67. package/src/app/blog/page.tsx +15 -0
  68. package/src/app/careers/page.tsx +7 -0
  69. package/src/app/changelog/page.tsx +7 -0
  70. package/src/app/cloud/link/page.tsx +464 -0
  71. package/src/app/complete-profile/page.tsx +204 -0
  72. package/src/app/connect-repos/page.tsx +410 -0
  73. package/src/app/contact/page.tsx +7 -0
  74. package/src/app/docs/page.tsx +7 -0
  75. package/src/app/favicon.png +0 -0
  76. package/src/app/globals.css +200 -0
  77. package/src/app/history/page.tsx +658 -0
  78. package/src/app/layout.tsx +25 -0
  79. package/src/app/login/page.tsx +424 -0
  80. package/src/app/metrics/page.tsx +781 -0
  81. package/src/app/page.tsx +59 -0
  82. package/src/app/pricing/page.tsx +7 -0
  83. package/src/app/privacy/page.tsx +7 -0
  84. package/src/app/providers/page.tsx +193 -0
  85. package/src/app/providers/setup/[provider]/ProviderSetupClient.tsx +197 -0
  86. package/src/app/providers/setup/[provider]/constants.ts +35 -0
  87. package/src/app/providers/setup/[provider]/page.tsx +42 -0
  88. package/src/app/security/page.tsx +7 -0
  89. package/src/app/signup/page.tsx +533 -0
  90. package/src/app/terms/page.tsx +7 -0
  91. package/src/components/ActivityFeed.tsx +216 -0
  92. package/src/components/AddWorkspaceModal.tsx +170 -0
  93. package/src/components/AgentCard.test.tsx +134 -0
  94. package/src/components/AgentCard.tsx +585 -0
  95. package/src/components/AgentList.test.tsx +147 -0
  96. package/src/components/AgentList.tsx +419 -0
  97. package/src/components/AgentLogPreview.tsx +173 -0
  98. package/src/components/AgentProfilePanel.tsx +569 -0
  99. package/src/components/App.tsx +3424 -0
  100. package/src/components/BillingPanel.tsx +922 -0
  101. package/src/components/BillingResult.tsx +447 -0
  102. package/src/components/BroadcastComposer.tsx +690 -0
  103. package/src/components/ChannelAdminPanel.tsx +773 -0
  104. package/src/components/ChannelBrowser.tsx +385 -0
  105. package/src/components/ChannelChat.tsx +261 -0
  106. package/src/components/ChannelSidebar.tsx +399 -0
  107. package/src/components/CloudSessionProvider.tsx +130 -0
  108. package/src/components/CommandPalette.tsx +815 -0
  109. package/src/components/ConfirmationDialog.tsx +133 -0
  110. package/src/components/ConversationHistory.tsx +518 -0
  111. package/src/components/CoordinatorPanel.tsx +956 -0
  112. package/src/components/DecisionQueue.tsx +717 -0
  113. package/src/components/DirectMessageView.tsx +164 -0
  114. package/src/components/FileAutocomplete.tsx +368 -0
  115. package/src/components/FleetOverview.tsx +278 -0
  116. package/src/components/LogViewer.tsx +310 -0
  117. package/src/components/LogViewerPanel.tsx +482 -0
  118. package/src/components/Logo.tsx +284 -0
  119. package/src/components/MentionAutocomplete.tsx +384 -0
  120. package/src/components/MessageComposer.tsx +473 -0
  121. package/src/components/MessageList.tsx +725 -0
  122. package/src/components/MessageSenderName.tsx +91 -0
  123. package/src/components/MessageStatusIndicator.tsx +142 -0
  124. package/src/components/NewConversationModal.tsx +400 -0
  125. package/src/components/NotificationToast.tsx +488 -0
  126. package/src/components/OnlineUsersIndicator.tsx +164 -0
  127. package/src/components/Pagination.tsx +124 -0
  128. package/src/components/PricingPlans.tsx +386 -0
  129. package/src/components/ProjectList.tsx +711 -0
  130. package/src/components/ProviderAuthFlow.tsx +343 -0
  131. package/src/components/ProviderConnectionList.tsx +375 -0
  132. package/src/components/ProvisioningProgress.tsx +730 -0
  133. package/src/components/ReactionChips.tsx +70 -0
  134. package/src/components/ReactionPicker.tsx +121 -0
  135. package/src/components/RepoAccessPanel.tsx +787 -0
  136. package/src/components/RepositoriesPanel.tsx +901 -0
  137. package/src/components/ServerCard.tsx +202 -0
  138. package/src/components/SessionExpiredModal.tsx +128 -0
  139. package/src/components/SpawnModal.test.tsx +190 -0
  140. package/src/components/SpawnModal.tsx +1001 -0
  141. package/src/components/TaskAssignmentUI.tsx +375 -0
  142. package/src/components/TerminalProviderSetup.tsx +517 -0
  143. package/src/components/ThemeProvider.tsx +159 -0
  144. package/src/components/ThinkingIndicator.tsx +231 -0
  145. package/src/components/ThreadList.tsx +198 -0
  146. package/src/components/ThreadPanel.tsx +405 -0
  147. package/src/components/TrajectoryViewer.tsx +698 -0
  148. package/src/components/TypingIndicator.tsx +69 -0
  149. package/src/components/UsageBanner.tsx +231 -0
  150. package/src/components/UserProfilePanel.tsx +233 -0
  151. package/src/components/WorkspaceContext.tsx +95 -0
  152. package/src/components/WorkspaceSelector.tsx +234 -0
  153. package/src/components/WorkspaceStatusIndicator.tsx +396 -0
  154. package/src/components/XTermInteractive.tsx +516 -0
  155. package/src/components/XTermLogViewer.tsx +719 -0
  156. package/src/components/channels/ChannelDialogs.tsx +1411 -0
  157. package/src/components/channels/ChannelHeader.tsx +317 -0
  158. package/src/components/channels/ChannelMessageList.tsx +463 -0
  159. package/src/components/channels/ChannelViewV1.tsx +146 -0
  160. package/src/components/channels/MessageInput.tsx +302 -0
  161. package/src/components/channels/SearchInput.tsx +172 -0
  162. package/src/components/channels/SearchResults.tsx +336 -0
  163. package/src/components/channels/api.test.ts +1527 -0
  164. package/src/components/channels/api.ts +703 -0
  165. package/src/components/channels/index.ts +76 -0
  166. package/src/components/channels/mockApi.ts +344 -0
  167. package/src/components/channels/types.ts +566 -0
  168. package/src/components/hooks/index.ts +58 -0
  169. package/src/components/hooks/useAgentLogs.ts +504 -0
  170. package/src/components/hooks/useAgents.ts +127 -0
  171. package/src/components/hooks/useBroadcastDedup.test.ts +371 -0
  172. package/src/components/hooks/useBroadcastDedup.ts +86 -0
  173. package/src/components/hooks/useChannelAdmin.ts +329 -0
  174. package/src/components/hooks/useChannelBrowser.ts +239 -0
  175. package/src/components/hooks/useChannelCommands.ts +138 -0
  176. package/src/components/hooks/useChannels.ts +367 -0
  177. package/src/components/hooks/useDebounce.ts +29 -0
  178. package/src/components/hooks/useDirectMessage.test.ts +952 -0
  179. package/src/components/hooks/useDirectMessage.ts +141 -0
  180. package/src/components/hooks/useMessages.ts +310 -0
  181. package/src/components/hooks/useOrchestrator.test.ts +165 -0
  182. package/src/components/hooks/useOrchestrator.ts +424 -0
  183. package/src/components/hooks/usePinnedAgents.test.ts +356 -0
  184. package/src/components/hooks/usePinnedAgents.ts +140 -0
  185. package/src/components/hooks/usePresence.test.ts +245 -0
  186. package/src/components/hooks/usePresence.ts +377 -0
  187. package/src/components/hooks/useRecentRepos.ts +130 -0
  188. package/src/components/hooks/useSession.ts +209 -0
  189. package/src/components/hooks/useThread.ts +138 -0
  190. package/src/components/hooks/useTrajectory.ts +265 -0
  191. package/src/components/hooks/useWebSocket.ts +290 -0
  192. package/src/components/hooks/useWorkspaceMembers.ts +132 -0
  193. package/src/components/hooks/useWorkspaceRepos.ts +73 -0
  194. package/src/components/hooks/useWorkspaceStatus.ts +237 -0
  195. package/src/components/index.ts +81 -0
  196. package/src/components/layout/Header.tsx +311 -0
  197. package/src/components/layout/RepoContextHeader.tsx +361 -0
  198. package/src/components/layout/Sidebar.archive.test.tsx +126 -0
  199. package/src/components/layout/Sidebar.test.tsx +691 -0
  200. package/src/components/layout/Sidebar.tsx +900 -0
  201. package/src/components/layout/index.ts +7 -0
  202. package/src/components/settings/BillingSettingsPanel.tsx +564 -0
  203. package/src/components/settings/SettingsPage.tsx +683 -0
  204. package/src/components/settings/TeamSettingsPanel.tsx +560 -0
  205. package/src/components/settings/WorkspaceSettingsPanel.tsx +1368 -0
  206. package/src/components/settings/index.ts +11 -0
  207. package/src/components/settings/types.ts +79 -0
  208. package/src/components/utils/messageFormatting.test.tsx +331 -0
  209. package/src/components/utils/messageFormatting.tsx +597 -0
  210. package/src/index.ts +63 -0
  211. package/src/landing/AboutPage.tsx +77 -0
  212. package/src/landing/BlogContent.tsx +187 -0
  213. package/src/landing/BlogPage.tsx +47 -0
  214. package/src/landing/CareersPage.tsx +53 -0
  215. package/src/landing/ChangelogPage.tsx +33 -0
  216. package/src/landing/ContactPage.tsx +41 -0
  217. package/src/landing/DocsPage.tsx +43 -0
  218. package/src/landing/LandingPage.tsx +702 -0
  219. package/src/landing/PricingPage.tsx +549 -0
  220. package/src/landing/PrivacyPage.tsx +117 -0
  221. package/src/landing/SecurityPage.tsx +42 -0
  222. package/src/landing/StaticPage.tsx +165 -0
  223. package/src/landing/TermsPage.tsx +125 -0
  224. package/src/landing/blogData.ts +312 -0
  225. package/src/landing/index.ts +18 -0
  226. package/src/landing/styles.css +3673 -0
  227. package/src/lib/agent-merge.test.ts +43 -0
  228. package/src/lib/agent-merge.ts +35 -0
  229. package/src/lib/api.ts +1294 -0
  230. package/src/lib/cloudApi.ts +893 -0
  231. package/src/lib/colors.test.ts +175 -0
  232. package/src/lib/colors.ts +218 -0
  233. package/src/lib/config.ts +109 -0
  234. package/src/lib/hierarchy.ts +242 -0
  235. package/src/lib/stuckDetection.ts +142 -0
  236. package/src/lib/useUrlRouting.ts +190 -0
  237. package/src/types/index.ts +317 -0
  238. package/src/types/threading.ts +7 -0
  239. package/out/_next/static/chunks/285-dc644487a8d6500d.js +0 -1
  240. package/out/_next/static/css/4c58d9cf493aa626.css +0 -1
  241. /package/out/_next/static/{dYlczDQI12PIQ3tqq3N4Y → IxfA6RZu4trcsEMYlkQra}/_buildManifest.js +0 -0
  242. /package/out/_next/static/{dYlczDQI12PIQ3tqq3N4Y → IxfA6RZu4trcsEMYlkQra}/_ssgManifest.js +0 -0
  243. /package/out/_next/static/chunks/{528-d375bc8b46912d2c.js → 528-f5f676996d613c25.js} +0 -0
  244. /package/out/_next/static/chunks/app/blog/let-them-cook-multi-agent-orchestration/{page-a58308f43557b908.js → page-b194f207fbd91862.js} +0 -0
@@ -0,0 +1,91 @@
1
+ /**
2
+ * MessageSenderName Component
3
+ *
4
+ * Clickable sender name for chat messages.
5
+ * Opens agent profile panel for agents, user profile panel for humans.
6
+ * Maintains existing color styling while adding hover feedback.
7
+ */
8
+
9
+ import React, { useCallback } from 'react';
10
+ import type { Agent } from '../types';
11
+ import type { UserPresence } from './hooks/usePresence';
12
+
13
+ export interface MessageSenderNameProps {
14
+ /** Display name to show */
15
+ displayName: string;
16
+ /** Color for the name text */
17
+ color: string;
18
+ /** Whether this sender is the current user */
19
+ isCurrentUser?: boolean;
20
+ /** Agent object if sender is an agent */
21
+ agent?: Agent;
22
+ /** User presence object if sender is a human user */
23
+ userPresence?: UserPresence;
24
+ /** Callback when an agent name is clicked */
25
+ onAgentClick?: (agent: Agent) => void;
26
+ /** Callback when a human user name is clicked */
27
+ onUserClick?: (user: UserPresence) => void;
28
+ /** Additional CSS classes */
29
+ className?: string;
30
+ }
31
+
32
+ /**
33
+ * Clickable sender name component for chat messages.
34
+ * Provides visual feedback on hover and opens the appropriate profile panel on click.
35
+ */
36
+ export function MessageSenderName({
37
+ displayName,
38
+ color,
39
+ isCurrentUser = false,
40
+ agent,
41
+ userPresence,
42
+ onAgentClick,
43
+ onUserClick,
44
+ className = '',
45
+ }: MessageSenderNameProps) {
46
+ const handleClick = useCallback(() => {
47
+ if (agent && onAgentClick) {
48
+ onAgentClick(agent);
49
+ } else if (userPresence && onUserClick) {
50
+ onUserClick(userPresence);
51
+ }
52
+ }, [agent, userPresence, onAgentClick, onUserClick]);
53
+
54
+ // Determine if the name should be clickable
55
+ const isClickable = (agent && onAgentClick) || (userPresence && onUserClick);
56
+
57
+ // If not clickable, render as plain text
58
+ if (!isClickable) {
59
+ return (
60
+ <span
61
+ className={`font-display font-semibold text-sm ${className}`}
62
+ style={{ color }}
63
+ >
64
+ {displayName}
65
+ </span>
66
+ );
67
+ }
68
+
69
+ // Render as interactive button
70
+ return (
71
+ <button
72
+ type="button"
73
+ onClick={handleClick}
74
+ className={`
75
+ font-display font-semibold text-sm
76
+ bg-transparent border-none p-0 m-0
77
+ cursor-pointer
78
+ transition-all duration-150
79
+ hover:underline hover:decoration-current hover:decoration-1 hover:underline-offset-2
80
+ focus:outline-none focus:ring-2 focus:ring-offset-1 focus:ring-accent-cyan/50 focus:rounded-sm
81
+ ${className}
82
+ `}
83
+ style={{ color }}
84
+ title={`View ${agent ? 'agent' : 'user'} profile: ${displayName}`}
85
+ >
86
+ {displayName}
87
+ </button>
88
+ );
89
+ }
90
+
91
+ export default MessageSenderName;
@@ -0,0 +1,142 @@
1
+ /**
2
+ * MessageStatusIndicator Component
3
+ *
4
+ * Shows the delivery status of a message:
5
+ * - Sending/Unread: Animated clock/pending icon
6
+ * - Acked/Read: Checkmark icon (success)
7
+ * - Failed: Exclamation icon (error - NACK or timeout)
8
+ *
9
+ * Used to indicate when a message was received by an agent
10
+ * before they start responding (fills the gap before ThinkingIndicator).
11
+ */
12
+
13
+ import React from 'react';
14
+ import type { MessageStatus } from '../types';
15
+
16
+ export interface MessageStatusIndicatorProps {
17
+ /** Message delivery status */
18
+ status?: MessageStatus;
19
+ /** Size variant */
20
+ size?: 'small' | 'medium';
21
+ }
22
+
23
+ export function MessageStatusIndicator({
24
+ status,
25
+ size = 'small',
26
+ }: MessageStatusIndicatorProps) {
27
+ // Don't show anything if no status
28
+ if (!status) return null;
29
+
30
+ const sizeClasses = {
31
+ small: 'w-3.5 h-3.5',
32
+ medium: 'w-4 h-4',
33
+ };
34
+
35
+ const sizeClass = sizeClasses[size];
36
+
37
+ // Sending/Unread - show pending indicator
38
+ if (status === 'sending' || status === 'unread') {
39
+ return (
40
+ <span
41
+ className={`inline-flex items-center justify-center ${sizeClass} text-text-muted`}
42
+ title="Sending..."
43
+ >
44
+ <SendingIcon className={sizeClass} />
45
+ </span>
46
+ );
47
+ }
48
+
49
+ // Acked/Read - show checkmark
50
+ if (status === 'acked' || status === 'read') {
51
+ return (
52
+ <span
53
+ className={`inline-flex items-center justify-center ${sizeClass} text-success`}
54
+ title="Delivered"
55
+ >
56
+ <CheckIcon className={sizeClass} />
57
+ </span>
58
+ );
59
+ }
60
+
61
+ // Failed - show error indicator
62
+ if (status === 'failed') {
63
+ return (
64
+ <span
65
+ className={`inline-flex items-center justify-center ${sizeClass} text-error`}
66
+ title="Delivery failed"
67
+ >
68
+ <FailedIcon className={sizeClass} />
69
+ </span>
70
+ );
71
+ }
72
+
73
+ return null;
74
+ }
75
+
76
+ function SendingIcon({ className }: { className?: string }) {
77
+ return (
78
+ <svg
79
+ className={`animate-pulse ${className}`}
80
+ viewBox="0 0 16 16"
81
+ fill="none"
82
+ stroke="currentColor"
83
+ strokeWidth="1.5"
84
+ >
85
+ {/* Clock/pending icon */}
86
+ <circle cx="8" cy="8" r="6" />
87
+ <path d="M8 5v3l2 1" strokeLinecap="round" strokeLinejoin="round" />
88
+ </svg>
89
+ );
90
+ }
91
+
92
+ function CheckIcon({ className }: { className?: string }) {
93
+ return (
94
+ <svg
95
+ className={className}
96
+ viewBox="0 0 16 16"
97
+ fill="none"
98
+ stroke="currentColor"
99
+ strokeWidth="2"
100
+ >
101
+ {/* Single checkmark for delivered */}
102
+ <path d="M3 8l3 3 7-7" strokeLinecap="round" strokeLinejoin="round" />
103
+ </svg>
104
+ );
105
+ }
106
+
107
+ function FailedIcon({ className }: { className?: string }) {
108
+ return (
109
+ <svg
110
+ className={className}
111
+ viewBox="0 0 16 16"
112
+ fill="none"
113
+ stroke="currentColor"
114
+ strokeWidth="2"
115
+ >
116
+ {/* Exclamation mark in circle for failed delivery */}
117
+ <circle cx="8" cy="8" r="6" />
118
+ <line x1="8" y1="5" x2="8" y2="8" strokeLinecap="round" />
119
+ <circle cx="8" cy="11" r="0.5" fill="currentColor" stroke="none" />
120
+ </svg>
121
+ );
122
+ }
123
+
124
+ /**
125
+ * Double checkmark variant for when message has been read
126
+ * (not currently used, but available for future enhancement)
127
+ */
128
+ export function DoubleCheckIcon({ className }: { className?: string }) {
129
+ return (
130
+ <svg
131
+ className={className}
132
+ viewBox="0 0 20 16"
133
+ fill="none"
134
+ stroke="currentColor"
135
+ strokeWidth="2"
136
+ >
137
+ {/* Double checkmark for read */}
138
+ <path d="M1 8l3 3 7-7" strokeLinecap="round" strokeLinejoin="round" />
139
+ <path d="M7 8l3 3 7-7" strokeLinecap="round" strokeLinejoin="round" />
140
+ </svg>
141
+ );
142
+ }
@@ -0,0 +1,400 @@
1
+ /**
2
+ * NewConversationModal Component
3
+ *
4
+ * Modal for starting a new conversation with an agent.
5
+ * Allows selecting a target agent and composing an initial message.
6
+ */
7
+
8
+ import React, { useState, useRef, useEffect, useCallback, useMemo } from 'react';
9
+ import type { Agent } from '../types';
10
+ import { getAgentColor, getAgentInitials } from '../lib/colors';
11
+
12
+ export interface NewConversationModalProps {
13
+ isOpen: boolean;
14
+ onClose: () => void;
15
+ onSend: (to: string, content: string) => Promise<boolean>;
16
+ agents: Agent[];
17
+ isSending?: boolean;
18
+ error?: string | null;
19
+ /** Optional: Pre-select an agent */
20
+ preselectedAgent?: string;
21
+ }
22
+
23
+ export function NewConversationModal({
24
+ isOpen,
25
+ onClose,
26
+ onSend,
27
+ agents,
28
+ isSending = false,
29
+ error,
30
+ preselectedAgent,
31
+ }: NewConversationModalProps) {
32
+ const [selectedAgent, setSelectedAgent] = useState<string>('');
33
+ const [message, setMessage] = useState('');
34
+ const [searchQuery, setSearchQuery] = useState('');
35
+ const [localError, setLocalError] = useState<string | null>(null);
36
+ const messageInputRef = useRef<HTMLTextAreaElement>(null);
37
+ const searchInputRef = useRef<HTMLInputElement>(null);
38
+
39
+ // Filter agents based on search query
40
+ const filteredAgents = useMemo(() => {
41
+ if (!searchQuery.trim()) return agents;
42
+ const query = searchQuery.toLowerCase();
43
+ return agents.filter(
44
+ (agent) =>
45
+ agent.name.toLowerCase().includes(query) ||
46
+ agent.role?.toLowerCase().includes(query) ||
47
+ agent.team?.toLowerCase().includes(query)
48
+ );
49
+ }, [agents, searchQuery]);
50
+
51
+ // Reset state when modal opens
52
+ useEffect(() => {
53
+ if (isOpen) {
54
+ setSelectedAgent(preselectedAgent || '');
55
+ setMessage('');
56
+ setSearchQuery('');
57
+ setLocalError(null);
58
+ setTimeout(() => {
59
+ if (preselectedAgent) {
60
+ messageInputRef.current?.focus();
61
+ } else {
62
+ searchInputRef.current?.focus();
63
+ }
64
+ }, 100);
65
+ }
66
+ }, [isOpen, preselectedAgent]);
67
+
68
+ const handleSubmit = async (e: React.FormEvent) => {
69
+ e.preventDefault();
70
+
71
+ if (!selectedAgent) {
72
+ setLocalError('Please select an agent');
73
+ return;
74
+ }
75
+
76
+ if (!message.trim()) {
77
+ setLocalError('Please enter a message');
78
+ return;
79
+ }
80
+
81
+ setLocalError(null);
82
+ const success = await onSend(selectedAgent, message.trim());
83
+
84
+ if (success) {
85
+ onClose();
86
+ }
87
+ };
88
+
89
+ const handleKeyDown = (e: React.KeyboardEvent) => {
90
+ if (e.key === 'Escape') {
91
+ e.preventDefault();
92
+ onClose();
93
+ }
94
+ };
95
+
96
+ const handleAgentSelect = useCallback((agentName: string) => {
97
+ setSelectedAgent(agentName);
98
+ setLocalError(null);
99
+ setTimeout(() => messageInputRef.current?.focus(), 50);
100
+ }, []);
101
+
102
+ if (!isOpen) return null;
103
+
104
+ const displayError = error || localError;
105
+ const selectedAgentData = agents.find((a) => a.name === selectedAgent);
106
+ const selectedColors = selectedAgentData ? getAgentColor(selectedAgentData.name) : null;
107
+
108
+ return (
109
+ <div
110
+ className="fixed inset-0 bg-black/50 flex items-center justify-center z-[1000] animate-fade-in"
111
+ onClick={onClose}
112
+ >
113
+ <div
114
+ className="bg-bg-primary border border-border rounded-xl w-[520px] max-w-[90vw] max-h-[85vh] overflow-hidden shadow-modal animate-slide-up flex flex-col"
115
+ onClick={(e) => e.stopPropagation()}
116
+ onKeyDown={handleKeyDown}
117
+ >
118
+ {/* Header */}
119
+ <div className="flex items-center justify-between p-5 border-b border-border shrink-0">
120
+ <div className="flex items-center gap-3">
121
+ <div className="w-9 h-9 rounded-lg bg-accent/10 flex items-center justify-center">
122
+ <MessageIcon />
123
+ </div>
124
+ <div>
125
+ <h2 className="m-0 text-lg font-semibold text-text-primary">New Conversation</h2>
126
+ <p className="m-0 text-xs text-text-muted">Start a direct message with an agent</p>
127
+ </div>
128
+ </div>
129
+ <button
130
+ className="flex items-center justify-center w-8 h-8 bg-transparent border-none rounded-md text-text-muted cursor-pointer transition-all duration-150 hover:bg-bg-hover hover:text-text-primary"
131
+ onClick={onClose}
132
+ aria-label="Close"
133
+ >
134
+ <CloseIcon />
135
+ </button>
136
+ </div>
137
+
138
+ <form onSubmit={handleSubmit} className="flex flex-col flex-1 overflow-hidden">
139
+ {/* Agent Selection */}
140
+ <div className="p-5 border-b border-border">
141
+ <label className="block text-sm font-semibold text-text-primary mb-2">
142
+ To
143
+ </label>
144
+
145
+ {selectedAgent ? (
146
+ <div className="flex items-center gap-3 p-3 bg-bg-hover rounded-lg">
147
+ <div
148
+ className="shrink-0 w-10 h-10 rounded-lg flex items-center justify-center text-sm font-semibold"
149
+ style={{ backgroundColor: selectedColors?.primary, color: selectedColors?.text }}
150
+ >
151
+ {getAgentInitials(selectedAgent)}
152
+ </div>
153
+ <div className="flex-1 min-w-0">
154
+ <div className="font-semibold text-text-primary">{selectedAgent}</div>
155
+ {selectedAgentData?.role && (
156
+ <div className="text-xs text-text-muted truncate">{selectedAgentData.role}</div>
157
+ )}
158
+ </div>
159
+ <button
160
+ type="button"
161
+ className="flex items-center justify-center w-8 h-8 bg-bg-active border-none rounded-md text-text-muted cursor-pointer transition-all duration-150 hover:bg-bg-tertiary hover:text-text-primary"
162
+ onClick={() => {
163
+ setSelectedAgent('');
164
+ setTimeout(() => searchInputRef.current?.focus(), 50);
165
+ }}
166
+ aria-label="Change agent"
167
+ >
168
+ <ChangeIcon />
169
+ </button>
170
+ </div>
171
+ ) : (
172
+ <>
173
+ {/* Search Input */}
174
+ <div className="relative mb-3">
175
+ <div className="absolute left-3 top-1/2 -translate-y-1/2 text-text-muted">
176
+ <SearchIcon />
177
+ </div>
178
+ <input
179
+ ref={searchInputRef}
180
+ type="text"
181
+ className="w-full py-2.5 pl-10 pr-3.5 border border-border rounded-md text-sm font-sans outline-none bg-transparent text-text-primary transition-colors duration-150 focus:border-accent placeholder:text-text-muted"
182
+ placeholder="Search agents..."
183
+ value={searchQuery}
184
+ onChange={(e) => setSearchQuery(e.target.value)}
185
+ />
186
+ </div>
187
+
188
+ {/* Agent List */}
189
+ <div className="max-h-[200px] overflow-y-auto border border-border rounded-lg">
190
+ {filteredAgents.length === 0 ? (
191
+ <div className="p-4 text-center text-text-muted text-sm">
192
+ {searchQuery ? 'No agents found' : 'No agents available'}
193
+ </div>
194
+ ) : (
195
+ <div className="divide-y divide-border">
196
+ {/* Broadcast option */}
197
+ <button
198
+ type="button"
199
+ className="w-full flex items-center gap-3 p-3 bg-transparent border-none cursor-pointer transition-colors duration-150 hover:bg-bg-hover text-left"
200
+ onClick={() => handleAgentSelect('*')}
201
+ >
202
+ <div className="shrink-0 w-9 h-9 rounded-lg bg-warning/20 flex items-center justify-center">
203
+ <BroadcastIcon />
204
+ </div>
205
+ <div className="flex-1 min-w-0">
206
+ <div className="font-semibold text-text-primary">Everyone</div>
207
+ <div className="text-xs text-text-muted">Broadcast to all agents</div>
208
+ </div>
209
+ </button>
210
+
211
+ {/* Agent options */}
212
+ {filteredAgents.map((agent) => {
213
+ const colors = getAgentColor(agent.name);
214
+ return (
215
+ <button
216
+ key={agent.name}
217
+ type="button"
218
+ className="w-full flex items-center gap-3 p-3 bg-transparent border-none cursor-pointer transition-colors duration-150 hover:bg-bg-hover text-left"
219
+ onClick={() => handleAgentSelect(agent.name)}
220
+ >
221
+ <div
222
+ className="shrink-0 w-9 h-9 rounded-lg flex items-center justify-center text-xs font-semibold"
223
+ style={{ backgroundColor: colors.primary, color: colors.text }}
224
+ >
225
+ {getAgentInitials(agent.name)}
226
+ </div>
227
+ <div className="flex-1 min-w-0">
228
+ <div className="flex items-center gap-2">
229
+ <span className="font-semibold text-text-primary">{agent.name}</span>
230
+ <span
231
+ className={`w-2 h-2 rounded-full ${
232
+ agent.status === 'online' ? 'bg-success' : 'bg-text-muted'
233
+ }`}
234
+ />
235
+ </div>
236
+ {(agent.role || agent.team) && (
237
+ <div className="text-xs text-text-muted truncate">
238
+ {agent.role}
239
+ {agent.role && agent.team && ' - '}
240
+ {agent.team}
241
+ </div>
242
+ )}
243
+ </div>
244
+ </button>
245
+ );
246
+ })}
247
+ </div>
248
+ )}
249
+ </div>
250
+ </>
251
+ )}
252
+ </div>
253
+
254
+ {/* Message Input */}
255
+ <div className="p-5 flex-1 overflow-hidden flex flex-col">
256
+ <label className="block text-sm font-semibold text-text-primary mb-2" htmlFor="message">
257
+ Message
258
+ </label>
259
+ <textarea
260
+ ref={messageInputRef}
261
+ id="message"
262
+ className="flex-1 min-h-[120px] w-full py-3 px-3.5 border border-border rounded-md text-sm font-sans outline-none bg-transparent text-text-primary transition-colors duration-150 focus:border-accent resize-none placeholder:text-text-muted"
263
+ placeholder={
264
+ selectedAgent === '*'
265
+ ? 'Write a message to all agents...'
266
+ : selectedAgent
267
+ ? `Write a message to ${selectedAgent}...`
268
+ : 'Select an agent first...'
269
+ }
270
+ value={message}
271
+ onChange={(e) => {
272
+ setMessage(e.target.value);
273
+ setLocalError(null);
274
+ }}
275
+ disabled={isSending || !selectedAgent}
276
+ />
277
+ </div>
278
+
279
+ {/* Error Display */}
280
+ {displayError && (
281
+ <div className="flex items-center gap-2 mx-5 mb-4 p-3 bg-error/10 border border-error/30 rounded-md text-error text-sm">
282
+ <ErrorIcon />
283
+ <span>{displayError}</span>
284
+ </div>
285
+ )}
286
+
287
+ {/* Actions */}
288
+ <div className="flex justify-end gap-2 p-5 pt-0 border-t border-border">
289
+ <button
290
+ type="button"
291
+ className="flex items-center gap-1.5 py-2.5 px-4 border-none rounded-md text-sm font-medium cursor-pointer font-sans transition-all duration-150 bg-bg-hover text-text-secondary hover:bg-bg-active hover:text-text-primary disabled:opacity-50 disabled:cursor-not-allowed"
292
+ onClick={onClose}
293
+ disabled={isSending}
294
+ >
295
+ Cancel
296
+ </button>
297
+ <button
298
+ type="submit"
299
+ className="flex items-center gap-1.5 py-2.5 px-4 border-none rounded-md text-sm font-medium cursor-pointer font-sans transition-all duration-150 bg-accent text-white hover:bg-accent-hover disabled:opacity-50 disabled:cursor-not-allowed"
300
+ disabled={isSending || !selectedAgent || !message.trim()}
301
+ >
302
+ {isSending ? (
303
+ <>
304
+ <Spinner />
305
+ Sending...
306
+ </>
307
+ ) : (
308
+ <>
309
+ <SendIcon />
310
+ Send Message
311
+ </>
312
+ )}
313
+ </button>
314
+ </div>
315
+ </form>
316
+ </div>
317
+ </div>
318
+ );
319
+ }
320
+
321
+ function MessageIcon() {
322
+ return (
323
+ <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" className="text-accent">
324
+ <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" />
325
+ <line x1="9" y1="10" x2="15" y2="10" />
326
+ </svg>
327
+ );
328
+ }
329
+
330
+ function CloseIcon() {
331
+ return (
332
+ <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
333
+ <line x1="18" y1="6" x2="6" y2="18" />
334
+ <line x1="6" y1="6" x2="18" y2="18" />
335
+ </svg>
336
+ );
337
+ }
338
+
339
+ function SearchIcon() {
340
+ return (
341
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
342
+ <circle cx="11" cy="11" r="8" />
343
+ <line x1="21" y1="21" x2="16.65" y2="16.65" />
344
+ </svg>
345
+ );
346
+ }
347
+
348
+ function ChangeIcon() {
349
+ return (
350
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
351
+ <polyline points="1 4 1 10 7 10" />
352
+ <path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10" />
353
+ </svg>
354
+ );
355
+ }
356
+
357
+ function BroadcastIcon() {
358
+ return (
359
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" className="text-warning">
360
+ <circle cx="12" cy="12" r="2" />
361
+ <path d="M16.24 7.76a6 6 0 0 1 0 8.49m-8.48-.01a6 6 0 0 1 0-8.49m11.31-2.82a10 10 0 0 1 0 14.14m-14.14 0a10 10 0 0 1 0-14.14" />
362
+ </svg>
363
+ );
364
+ }
365
+
366
+ function SendIcon() {
367
+ return (
368
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
369
+ <line x1="22" y1="2" x2="11" y2="13" />
370
+ <polygon points="22 2 15 22 11 13 2 9 22 2" />
371
+ </svg>
372
+ );
373
+ }
374
+
375
+ function ErrorIcon() {
376
+ return (
377
+ <svg className="shrink-0" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
378
+ <circle cx="12" cy="12" r="10" />
379
+ <line x1="12" y1="8" x2="12" y2="12" />
380
+ <line x1="12" y1="16" x2="12.01" y2="16" />
381
+ </svg>
382
+ );
383
+ }
384
+
385
+ function Spinner() {
386
+ return (
387
+ <svg className="animate-spin" width="16" height="16" viewBox="0 0 24 24">
388
+ <circle
389
+ cx="12"
390
+ cy="12"
391
+ r="10"
392
+ stroke="currentColor"
393
+ strokeWidth="2"
394
+ fill="none"
395
+ strokeDasharray="32"
396
+ strokeLinecap="round"
397
+ />
398
+ </svg>
399
+ );
400
+ }