@autobe/ui 0.30.3 → 0.30.4-dev.20260324

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 (65) hide show
  1. package/LICENSE +661 -661
  2. package/README.md +261 -0
  3. package/lib/components/AutoBeChatMain.d.ts +6 -0
  4. package/lib/components/AutoBeChatMain.js +46 -37
  5. package/lib/components/AutoBeChatMain.js.map +1 -1
  6. package/lib/components/AutoBeConfigModal.js +9 -9
  7. package/lib/components/upload/AutoBeChatUploadBox.d.ts +1 -0
  8. package/lib/components/upload/AutoBeChatUploadBox.js +11 -16
  9. package/lib/components/upload/AutoBeChatUploadBox.js.map +1 -1
  10. package/lib/context/AutoBeAgentContext.js +78 -30
  11. package/lib/context/AutoBeAgentContext.js.map +1 -1
  12. package/lib/context/SearchParamsContext.js +1 -1
  13. package/lib/context/SearchParamsContext.js.map +1 -1
  14. package/lib/structure/AutoBeListener.d.ts +1 -0
  15. package/lib/structure/AutoBeListener.js +9 -1
  16. package/lib/structure/AutoBeListener.js.map +1 -1
  17. package/package.json +2 -2
  18. package/src/components/AutoBeAssistantMessageMovie.tsx +22 -22
  19. package/src/components/AutoBeChatMain.tsx +394 -376
  20. package/src/components/AutoBeChatSidebar.tsx +414 -414
  21. package/src/components/AutoBeConfigButton.tsx +83 -83
  22. package/src/components/AutoBeConfigModal.tsx +443 -443
  23. package/src/components/AutoBeStatusButton.tsx +75 -75
  24. package/src/components/AutoBeStatusModal.tsx +486 -486
  25. package/src/components/AutoBeUserMessageMovie.tsx +27 -27
  26. package/src/components/common/ActionButton.tsx +205 -205
  27. package/src/components/common/ActionButtonGroup.tsx +80 -80
  28. package/src/components/common/AutoBeConfigInput.tsx +185 -185
  29. package/src/components/common/ChatBubble.tsx +119 -119
  30. package/src/components/common/Collapsible.tsx +95 -95
  31. package/src/components/common/CompactSessionIndicator.tsx +73 -73
  32. package/src/components/common/CompactSessionList.tsx +82 -82
  33. package/src/components/common/openai/OpenAIContent.tsx +53 -53
  34. package/src/components/common/openai/OpenAIUserAudioContent.tsx +70 -70
  35. package/src/components/common/openai/OpenAIUserFileContent.tsx +76 -76
  36. package/src/components/common/openai/OpenAIUserImageContent.tsx +34 -34
  37. package/src/components/common/openai/OpenAIUserTextContent.tsx +15 -15
  38. package/src/components/events/AutoBeCompleteEventMovie.tsx +402 -402
  39. package/src/components/events/AutoBeCorrectEventMovie.tsx +354 -354
  40. package/src/components/events/AutoBeEventGroupMovie.tsx +18 -18
  41. package/src/components/events/AutoBeEventMovie.tsx +154 -154
  42. package/src/components/events/AutoBeProgressEventMovie.tsx +207 -207
  43. package/src/components/events/AutoBeScenarioEventMovie.tsx +135 -135
  44. package/src/components/events/AutoBeStartEventMovie.tsx +82 -82
  45. package/src/components/events/AutoBeValidateEventMovie.tsx +249 -249
  46. package/src/components/events/README.md +300 -300
  47. package/src/components/events/common/CollapsibleEventGroup.tsx +211 -211
  48. package/src/components/events/common/EventCard.tsx +61 -61
  49. package/src/components/events/common/EventContent.tsx +31 -31
  50. package/src/components/events/common/EventHeader.tsx +85 -85
  51. package/src/components/events/common/EventIcon.tsx +82 -82
  52. package/src/components/events/common/ProgressBar.tsx +64 -64
  53. package/src/components/events/groups/CorrectEventGroup.tsx +183 -183
  54. package/src/components/events/groups/ValidateEventGroup.tsx +143 -143
  55. package/src/components/events/utils/eventGrouper.tsx +116 -116
  56. package/src/components/upload/AutoBeChatUploadBox.tsx +433 -425
  57. package/src/components/upload/AutoBeChatUploadSendButton.tsx +66 -66
  58. package/src/components/upload/AutoBeFileUploadBox.tsx +123 -123
  59. package/src/components/upload/AutoBeVoiceRecoderButton.tsx +100 -100
  60. package/src/context/AutoBeAgentContext.tsx +301 -245
  61. package/src/context/AutoBeAgentSessionList.tsx +58 -58
  62. package/src/context/SearchParamsContext.tsx +49 -49
  63. package/src/icons/Receipt.tsx +74 -74
  64. package/src/structure/AutoBeListener.ts +368 -363
  65. package/tsconfig.json +9 -9
@@ -1,486 +1,486 @@
1
- import { IAutoBeTokenUsageJson } from "@autobe/interface";
2
- import React from "react";
3
-
4
- import { useAutoBeAgent } from "../context/AutoBeAgentContext";
5
- import { useEscapeKey } from "../hooks";
6
- import { AutoBeListenerState } from "../structure";
7
- import { toCompactNumberFormat } from "../utils";
8
-
9
- // Types
10
- interface IAutoBeStatusModalProps {
11
- isOpen: boolean;
12
- onClose: () => void;
13
- }
14
-
15
- // Style constants
16
- const MODAL_STYLES = {
17
- overlay: {
18
- position: "fixed" as const,
19
- top: 0,
20
- left: 0,
21
- right: 0,
22
- bottom: 0,
23
- background: "rgba(0, 0, 0, 0.6)",
24
- backdropFilter: "blur(8px)",
25
- display: "flex",
26
- alignItems: "center",
27
- justifyContent: "center",
28
- zIndex: 1001,
29
- padding: "1rem",
30
- },
31
- container: {
32
- background: "#ffffff",
33
- borderRadius: "16px",
34
- boxShadow:
35
- "0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.05)",
36
- maxWidth: "700px",
37
- maxHeight: "85vh",
38
- width: "100%",
39
- overflowY: "auto" as const,
40
- position: "relative" as const,
41
- },
42
- closeButton: {
43
- position: "absolute" as const,
44
- top: "1rem",
45
- right: "1rem",
46
- background: "rgba(107, 114, 128, 0.1)",
47
- border: "none",
48
- borderRadius: "50%",
49
- width: "2rem",
50
- height: "2rem",
51
- display: "flex",
52
- alignItems: "center",
53
- justifyContent: "center",
54
- cursor: "pointer",
55
- color: "#6b7280",
56
- fontSize: "1.2rem",
57
- zIndex: 10,
58
- },
59
- content: {
60
- padding: "1.25rem",
61
- },
62
- section: {
63
- display: "flex",
64
- flexDirection: "column" as const,
65
- gap: "1.5rem",
66
- },
67
- } as const;
68
-
69
- const CARD_STYLES = {
70
- base: {
71
- background: "linear-gradient(145deg, #ffffff, #f8fafc)",
72
- borderRadius: "8px",
73
- padding: "0.7rem",
74
- marginBottom: "0.4rem",
75
- border: "1px solid rgba(148, 163, 184, 0.15)",
76
- boxShadow: "0 1px 3px 0 rgba(0, 0, 0, 0.1)",
77
- },
78
- header: {
79
- margin: "0 0 0.5rem 0",
80
- fontSize: "0.8rem",
81
- fontWeight: "700",
82
- color: "#374151",
83
- textTransform: "capitalize" as const,
84
- letterSpacing: "0.025em",
85
- },
86
- sectionTitle: {
87
- margin: 0,
88
- color: "#1e293b",
89
- fontSize: "0.9rem",
90
- fontWeight: "600",
91
- letterSpacing: "-0.01em",
92
- },
93
- } as const;
94
-
95
- const PROGRESS_STYLES = {
96
- card: {
97
- borderRadius: "10px",
98
- padding: "0.75rem",
99
- position: "relative" as const,
100
- overflow: "hidden",
101
- },
102
- completed: {
103
- background: "linear-gradient(135deg, #10b981, #059669)",
104
- border: "1px solid rgba(16, 185, 129, 0.2)",
105
- color: "white",
106
- boxShadow: "0 2px 8px rgba(16, 185, 129, 0.25)",
107
- },
108
- pending: {
109
- background: "linear-gradient(145deg, #ffffff, #f8fafc)",
110
- border: "1px solid rgba(148, 163, 184, 0.15)",
111
- color: "#6b7280",
112
- boxShadow: "0 2px 4px -1px rgba(0, 0, 0, 0.05)",
113
- },
114
- } as const;
115
-
116
- // Step configuration
117
- const PROGRESS_STEPS = [
118
- {
119
- name: "analyze",
120
- title: "Requirements Analysis",
121
- getResults: (state: AutoBeListenerState) => {
122
- if (!state.analyze) return null;
123
- const fileCount = Object.keys(state.analyze.files).length;
124
- const roleCount = state.analyze.actors.length;
125
- return `${fileCount} analysis files, ${roleCount} actors`;
126
- },
127
- },
128
- {
129
- name: "database",
130
- title: "Database Design",
131
- getResults: (state: AutoBeListenerState) => {
132
- if (!state.database) return null;
133
- const schemaCount = Object.keys(state.database.schemas).length;
134
- return `${schemaCount} schema files`;
135
- },
136
- },
137
- {
138
- name: "interface",
139
- title: "API Interface",
140
- getResults: (state: AutoBeListenerState) => {
141
- if (!state.interface) return null;
142
- const operationCount = state.interface.document.operations.length;
143
- const authCount = state.interface.authorizations.length;
144
- return `${operationCount} API endpoints, ${authCount} auth`;
145
- },
146
- },
147
- {
148
- name: "test",
149
- title: "Test Code",
150
- getResults: (state: AutoBeListenerState) => {
151
- if (!state.test) return null;
152
- const testCount = state.test.functions.filter(
153
- (f) => f.type === "operation",
154
- ).length;
155
- return `${testCount} test files`;
156
- },
157
- },
158
- {
159
- name: "realize",
160
- title: "Implementation Complete",
161
- getResults: (state: AutoBeListenerState) => {
162
- if (!state.realize) return null;
163
- const functionCount = state.realize.functions.length;
164
- const authCount = state.realize.authorizations.length;
165
- return `${functionCount} implementation functions, ${authCount} auth decorators`;
166
- },
167
- },
168
- ] as const;
169
-
170
- // Helper components
171
- const SectionTitle = ({ children }: { children: React.ReactNode }) => (
172
- <div style={{ marginBottom: "1rem" }}>
173
- <h3 style={CARD_STYLES.sectionTitle}>{children}</h3>
174
- </div>
175
- );
176
-
177
- // const ConnectionInfo = ({
178
- // header,
179
- // }: {
180
- // header: IAutoBePlaygroundHeader<ILlmSchema.Model> | null;
181
- // }) => (
182
- // <div>
183
- // <SectionTitle>Connection Info</SectionTitle>
184
- // <div
185
- // style={{
186
- // background: "linear-gradient(145deg, #ffffff, #f8fafc)",
187
- // borderRadius: "10px",
188
- // padding: "1rem",
189
- // border: "1px solid rgba(148, 163, 184, 0.15)",
190
- // boxShadow: "0 2px 4px -1px rgba(0, 0, 0, 0.05)",
191
- // }}
192
- // >
193
- // <p
194
- // style={{
195
- // margin: 0,
196
- // fontSize: "0.8rem",
197
- // color: "#374151",
198
- // lineHeight: 1.5,
199
- // }}
200
- // >
201
- // <strong>Model:</strong> {header?.model || "N/A"} |{" "}
202
- // <strong>Vendor:</strong> {header?.vendor.model || "N/A"} |{" "}
203
- // <strong>Locale:</strong> {header?.locale || "N/A"} |{" "}
204
- // <strong>Timezone:</strong> {header?.timezone || "N/A"}
205
- // </p>
206
- // </div>
207
- // </div>
208
- // );
209
-
210
- const HighlightNumbers = ({
211
- text,
212
- isCompleted,
213
- }: {
214
- text: string;
215
- isCompleted: boolean;
216
- }) => {
217
- const parts = text.split(/(\d+)/);
218
- return (
219
- <>
220
- {parts.map((part, index) => {
221
- const isNumber = /^\d+$/.test(part);
222
- if (isNumber) {
223
- return (
224
- <span
225
- key={index}
226
- style={{
227
- fontWeight: "700",
228
- fontSize: "0.8rem",
229
- color: isCompleted ? "#ffffff" : "#3b82f6",
230
- }}
231
- >
232
- {part}
233
- </span>
234
- );
235
- }
236
- return part;
237
- })}
238
- </>
239
- );
240
- };
241
-
242
- const ProgressCard = ({
243
- step,
244
- isCompleted,
245
- results,
246
- }: {
247
- step: (typeof PROGRESS_STEPS)[number];
248
- isCompleted: boolean;
249
- results: string | null;
250
- }) => (
251
- <div
252
- style={{
253
- ...PROGRESS_STYLES.card,
254
- ...(isCompleted ? PROGRESS_STYLES.completed : PROGRESS_STYLES.pending),
255
- }}
256
- >
257
- <div
258
- style={{
259
- display: "flex",
260
- justifyContent: "space-between",
261
- alignItems: "center",
262
- }}
263
- >
264
- <div style={{ flex: 1 }}>
265
- <div style={{ display: "flex", flexDirection: "row", gap: "0.2rem" }}>
266
- <span
267
- style={{
268
- fontSize: "0.85rem",
269
- fontWeight: "700",
270
- marginBottom: "0.2rem",
271
- textTransform: "uppercase",
272
- letterSpacing: "0.02em",
273
- }}
274
- >
275
- {step.name}
276
- </span>
277
- <span
278
- style={{
279
- fontSize: "0.75rem",
280
- opacity: 0.9,
281
- marginBottom: "0.2rem",
282
- }}
283
- >
284
- ({step.title})
285
- </span>
286
- </div>
287
-
288
- {results && (
289
- <div
290
- style={{
291
- fontSize: "0.7rem",
292
- opacity: 0.8,
293
- fontWeight: "500",
294
- }}
295
- >
296
- <HighlightNumbers text={results} isCompleted={isCompleted} />
297
- </div>
298
- )}
299
- </div>
300
- <div
301
- style={{
302
- fontSize: "0.7rem",
303
- fontWeight: "600",
304
- padding: "0.3rem 0.6rem",
305
- borderRadius: "10px",
306
- background: isCompleted
307
- ? "rgba(255, 255, 255, 0.2)"
308
- : "rgba(107, 114, 128, 0.1)",
309
- }}
310
- >
311
- {isCompleted ? "Completed" : "Pending"}
312
- </div>
313
- </div>
314
- </div>
315
- );
316
-
317
- const ProgressStatus = ({ state }: { state: AutoBeListenerState | null }) =>
318
- state && (
319
- <div>
320
- <SectionTitle>Progress Status</SectionTitle>
321
- <div
322
- style={{
323
- display: "flex",
324
- flexDirection: "column",
325
- gap: "0.5rem",
326
- }}
327
- >
328
- {PROGRESS_STEPS.map((step) => (
329
- <ProgressCard
330
- key={step.name}
331
- step={step}
332
- isCompleted={state[step.name as keyof AutoBeListenerState] !== null}
333
- results={step.getResults(state)}
334
- />
335
- ))}
336
- </div>
337
- </div>
338
- );
339
-
340
- const TokenRow = ({
341
- label,
342
- value,
343
- subInfo,
344
- }: {
345
- label: string;
346
- value: number;
347
- subInfo?: { label: string; value: number };
348
- }) => (
349
- <div
350
- style={{
351
- display: "flex",
352
- justifyContent: "space-between",
353
- alignItems: "center",
354
- }}
355
- >
356
- <div style={{ display: "flex", flexDirection: "column" }}>
357
- <span
358
- style={{
359
- fontSize: "0.7rem",
360
- fontWeight: "600",
361
- color: "#6b7280",
362
- }}
363
- >
364
- {label}
365
- </span>
366
- {subInfo && (
367
- <span
368
- style={{
369
- fontSize: "0.6rem",
370
- color: "#9ca3af",
371
- fontWeight: "500",
372
- }}
373
- >
374
- {subInfo.label}: {toCompactNumberFormat(subInfo.value)}
375
- </span>
376
- )}
377
- </div>
378
- <span
379
- style={{
380
- fontSize: "0.75rem",
381
- fontWeight: "700",
382
- color: "#1f2937",
383
- }}
384
- >
385
- {toCompactNumberFormat(value)}
386
- </span>
387
- </div>
388
- );
389
-
390
- const ComponentStats = ({
391
- name,
392
- component,
393
- }: {
394
- name: string;
395
- component: IAutoBeTokenUsageJson.IComponent;
396
- }) => (
397
- <div style={CARD_STYLES.base}>
398
- <h4 style={CARD_STYLES.header}>{name}</h4>
399
- <div
400
- style={{
401
- display: "flex",
402
- flexDirection: "column",
403
- gap: "0.4rem",
404
- }}
405
- >
406
- <div
407
- style={{
408
- display: "flex",
409
- flexDirection: "column",
410
- gap: "0.2rem",
411
- }}
412
- >
413
- <TokenRow label="Total" value={component.total} />
414
- <TokenRow
415
- label="Input"
416
- value={component.input.total}
417
- subInfo={
418
- component.input.cached > 0
419
- ? { label: "Cache", value: component.input.cached }
420
- : undefined
421
- }
422
- />
423
- <TokenRow label="Output" value={component.output.total} />
424
- </div>
425
- </div>
426
- </div>
427
- );
428
-
429
- const TokenUsage = ({
430
- tokenUsage,
431
- }: {
432
- tokenUsage: IAutoBeTokenUsageJson | null;
433
- }) => {
434
- if (!tokenUsage) {
435
- return (
436
- <div
437
- style={{
438
- padding: "2rem",
439
- textAlign: "center",
440
- color: "#6b7280",
441
- fontSize: "0.9rem",
442
- }}
443
- >
444
- Unable to load token usage information
445
- </div>
446
- );
447
- }
448
-
449
- return (
450
- <div>
451
- <SectionTitle>Token Usage - Total</SectionTitle>
452
- <ComponentStats name="total" component={tokenUsage.aggregate} />
453
- </div>
454
- );
455
- };
456
-
457
- export const AutoBeStatusModal = ({
458
- isOpen,
459
- onClose,
460
- }: IAutoBeStatusModalProps) => {
461
- const { tokenUsage, state } = useAutoBeAgent();
462
-
463
- useEscapeKey(isOpen, onClose);
464
-
465
- if (!isOpen) return null;
466
-
467
- return (
468
- <div style={MODAL_STYLES.overlay} onClick={onClose}>
469
- <div style={MODAL_STYLES.container} onClick={(e) => e.stopPropagation()}>
470
- <button onClick={onClose} style={MODAL_STYLES.closeButton}>
471
- ×
472
- </button>
473
-
474
- <div style={MODAL_STYLES.content}>
475
- <div style={MODAL_STYLES.section}>
476
- {/* <ConnectionInfo header={header} /> */}
477
- <ProgressStatus state={state} />
478
- <TokenUsage tokenUsage={tokenUsage} />
479
- </div>
480
- </div>
481
- </div>
482
- </div>
483
- );
484
- };
485
-
486
- export default AutoBeStatusModal;
1
+ import { IAutoBeTokenUsageJson } from "@autobe/interface";
2
+ import React from "react";
3
+
4
+ import { useAutoBeAgent } from "../context/AutoBeAgentContext";
5
+ import { useEscapeKey } from "../hooks";
6
+ import { AutoBeListenerState } from "../structure";
7
+ import { toCompactNumberFormat } from "../utils";
8
+
9
+ // Types
10
+ interface IAutoBeStatusModalProps {
11
+ isOpen: boolean;
12
+ onClose: () => void;
13
+ }
14
+
15
+ // Style constants
16
+ const MODAL_STYLES = {
17
+ overlay: {
18
+ position: "fixed" as const,
19
+ top: 0,
20
+ left: 0,
21
+ right: 0,
22
+ bottom: 0,
23
+ background: "rgba(0, 0, 0, 0.6)",
24
+ backdropFilter: "blur(8px)",
25
+ display: "flex",
26
+ alignItems: "center",
27
+ justifyContent: "center",
28
+ zIndex: 1001,
29
+ padding: "1rem",
30
+ },
31
+ container: {
32
+ background: "#ffffff",
33
+ borderRadius: "16px",
34
+ boxShadow:
35
+ "0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.05)",
36
+ maxWidth: "700px",
37
+ maxHeight: "85vh",
38
+ width: "100%",
39
+ overflowY: "auto" as const,
40
+ position: "relative" as const,
41
+ },
42
+ closeButton: {
43
+ position: "absolute" as const,
44
+ top: "1rem",
45
+ right: "1rem",
46
+ background: "rgba(107, 114, 128, 0.1)",
47
+ border: "none",
48
+ borderRadius: "50%",
49
+ width: "2rem",
50
+ height: "2rem",
51
+ display: "flex",
52
+ alignItems: "center",
53
+ justifyContent: "center",
54
+ cursor: "pointer",
55
+ color: "#6b7280",
56
+ fontSize: "1.2rem",
57
+ zIndex: 10,
58
+ },
59
+ content: {
60
+ padding: "1.25rem",
61
+ },
62
+ section: {
63
+ display: "flex",
64
+ flexDirection: "column" as const,
65
+ gap: "1.5rem",
66
+ },
67
+ } as const;
68
+
69
+ const CARD_STYLES = {
70
+ base: {
71
+ background: "linear-gradient(145deg, #ffffff, #f8fafc)",
72
+ borderRadius: "8px",
73
+ padding: "0.7rem",
74
+ marginBottom: "0.4rem",
75
+ border: "1px solid rgba(148, 163, 184, 0.15)",
76
+ boxShadow: "0 1px 3px 0 rgba(0, 0, 0, 0.1)",
77
+ },
78
+ header: {
79
+ margin: "0 0 0.5rem 0",
80
+ fontSize: "0.8rem",
81
+ fontWeight: "700",
82
+ color: "#374151",
83
+ textTransform: "capitalize" as const,
84
+ letterSpacing: "0.025em",
85
+ },
86
+ sectionTitle: {
87
+ margin: 0,
88
+ color: "#1e293b",
89
+ fontSize: "0.9rem",
90
+ fontWeight: "600",
91
+ letterSpacing: "-0.01em",
92
+ },
93
+ } as const;
94
+
95
+ const PROGRESS_STYLES = {
96
+ card: {
97
+ borderRadius: "10px",
98
+ padding: "0.75rem",
99
+ position: "relative" as const,
100
+ overflow: "hidden",
101
+ },
102
+ completed: {
103
+ background: "linear-gradient(135deg, #10b981, #059669)",
104
+ border: "1px solid rgba(16, 185, 129, 0.2)",
105
+ color: "white",
106
+ boxShadow: "0 2px 8px rgba(16, 185, 129, 0.25)",
107
+ },
108
+ pending: {
109
+ background: "linear-gradient(145deg, #ffffff, #f8fafc)",
110
+ border: "1px solid rgba(148, 163, 184, 0.15)",
111
+ color: "#6b7280",
112
+ boxShadow: "0 2px 4px -1px rgba(0, 0, 0, 0.05)",
113
+ },
114
+ } as const;
115
+
116
+ // Step configuration
117
+ const PROGRESS_STEPS = [
118
+ {
119
+ name: "analyze",
120
+ title: "Requirements Analysis",
121
+ getResults: (state: AutoBeListenerState) => {
122
+ if (!state.analyze) return null;
123
+ const fileCount = Object.keys(state.analyze.files).length;
124
+ const roleCount = state.analyze.actors.length;
125
+ return `${fileCount} analysis files, ${roleCount} actors`;
126
+ },
127
+ },
128
+ {
129
+ name: "database",
130
+ title: "Database Design",
131
+ getResults: (state: AutoBeListenerState) => {
132
+ if (!state.database) return null;
133
+ const schemaCount = Object.keys(state.database.schemas).length;
134
+ return `${schemaCount} schema files`;
135
+ },
136
+ },
137
+ {
138
+ name: "interface",
139
+ title: "API Interface",
140
+ getResults: (state: AutoBeListenerState) => {
141
+ if (!state.interface) return null;
142
+ const operationCount = state.interface.document.operations.length;
143
+ const authCount = state.interface.authorizations.length;
144
+ return `${operationCount} API endpoints, ${authCount} auth`;
145
+ },
146
+ },
147
+ {
148
+ name: "test",
149
+ title: "Test Code",
150
+ getResults: (state: AutoBeListenerState) => {
151
+ if (!state.test) return null;
152
+ const testCount = state.test.functions.filter(
153
+ (f) => f.type === "operation",
154
+ ).length;
155
+ return `${testCount} test files`;
156
+ },
157
+ },
158
+ {
159
+ name: "realize",
160
+ title: "Implementation Complete",
161
+ getResults: (state: AutoBeListenerState) => {
162
+ if (!state.realize) return null;
163
+ const functionCount = state.realize.functions.length;
164
+ const authCount = state.realize.authorizations.length;
165
+ return `${functionCount} implementation functions, ${authCount} auth decorators`;
166
+ },
167
+ },
168
+ ] as const;
169
+
170
+ // Helper components
171
+ const SectionTitle = ({ children }: { children: React.ReactNode }) => (
172
+ <div style={{ marginBottom: "1rem" }}>
173
+ <h3 style={CARD_STYLES.sectionTitle}>{children}</h3>
174
+ </div>
175
+ );
176
+
177
+ // const ConnectionInfo = ({
178
+ // header,
179
+ // }: {
180
+ // header: IAutoBePlaygroundHeader<ILlmSchema.Model> | null;
181
+ // }) => (
182
+ // <div>
183
+ // <SectionTitle>Connection Info</SectionTitle>
184
+ // <div
185
+ // style={{
186
+ // background: "linear-gradient(145deg, #ffffff, #f8fafc)",
187
+ // borderRadius: "10px",
188
+ // padding: "1rem",
189
+ // border: "1px solid rgba(148, 163, 184, 0.15)",
190
+ // boxShadow: "0 2px 4px -1px rgba(0, 0, 0, 0.05)",
191
+ // }}
192
+ // >
193
+ // <p
194
+ // style={{
195
+ // margin: 0,
196
+ // fontSize: "0.8rem",
197
+ // color: "#374151",
198
+ // lineHeight: 1.5,
199
+ // }}
200
+ // >
201
+ // <strong>Model:</strong> {header?.model || "N/A"} |{" "}
202
+ // <strong>Vendor:</strong> {header?.vendor.model || "N/A"} |{" "}
203
+ // <strong>Locale:</strong> {header?.locale || "N/A"} |{" "}
204
+ // <strong>Timezone:</strong> {header?.timezone || "N/A"}
205
+ // </p>
206
+ // </div>
207
+ // </div>
208
+ // );
209
+
210
+ const HighlightNumbers = ({
211
+ text,
212
+ isCompleted,
213
+ }: {
214
+ text: string;
215
+ isCompleted: boolean;
216
+ }) => {
217
+ const parts = text.split(/(\d+)/);
218
+ return (
219
+ <>
220
+ {parts.map((part, index) => {
221
+ const isNumber = /^\d+$/.test(part);
222
+ if (isNumber) {
223
+ return (
224
+ <span
225
+ key={index}
226
+ style={{
227
+ fontWeight: "700",
228
+ fontSize: "0.8rem",
229
+ color: isCompleted ? "#ffffff" : "#3b82f6",
230
+ }}
231
+ >
232
+ {part}
233
+ </span>
234
+ );
235
+ }
236
+ return part;
237
+ })}
238
+ </>
239
+ );
240
+ };
241
+
242
+ const ProgressCard = ({
243
+ step,
244
+ isCompleted,
245
+ results,
246
+ }: {
247
+ step: (typeof PROGRESS_STEPS)[number];
248
+ isCompleted: boolean;
249
+ results: string | null;
250
+ }) => (
251
+ <div
252
+ style={{
253
+ ...PROGRESS_STYLES.card,
254
+ ...(isCompleted ? PROGRESS_STYLES.completed : PROGRESS_STYLES.pending),
255
+ }}
256
+ >
257
+ <div
258
+ style={{
259
+ display: "flex",
260
+ justifyContent: "space-between",
261
+ alignItems: "center",
262
+ }}
263
+ >
264
+ <div style={{ flex: 1 }}>
265
+ <div style={{ display: "flex", flexDirection: "row", gap: "0.2rem" }}>
266
+ <span
267
+ style={{
268
+ fontSize: "0.85rem",
269
+ fontWeight: "700",
270
+ marginBottom: "0.2rem",
271
+ textTransform: "uppercase",
272
+ letterSpacing: "0.02em",
273
+ }}
274
+ >
275
+ {step.name}
276
+ </span>
277
+ <span
278
+ style={{
279
+ fontSize: "0.75rem",
280
+ opacity: 0.9,
281
+ marginBottom: "0.2rem",
282
+ }}
283
+ >
284
+ ({step.title})
285
+ </span>
286
+ </div>
287
+
288
+ {results && (
289
+ <div
290
+ style={{
291
+ fontSize: "0.7rem",
292
+ opacity: 0.8,
293
+ fontWeight: "500",
294
+ }}
295
+ >
296
+ <HighlightNumbers text={results} isCompleted={isCompleted} />
297
+ </div>
298
+ )}
299
+ </div>
300
+ <div
301
+ style={{
302
+ fontSize: "0.7rem",
303
+ fontWeight: "600",
304
+ padding: "0.3rem 0.6rem",
305
+ borderRadius: "10px",
306
+ background: isCompleted
307
+ ? "rgba(255, 255, 255, 0.2)"
308
+ : "rgba(107, 114, 128, 0.1)",
309
+ }}
310
+ >
311
+ {isCompleted ? "Completed" : "Pending"}
312
+ </div>
313
+ </div>
314
+ </div>
315
+ );
316
+
317
+ const ProgressStatus = ({ state }: { state: AutoBeListenerState | null }) =>
318
+ state && (
319
+ <div>
320
+ <SectionTitle>Progress Status</SectionTitle>
321
+ <div
322
+ style={{
323
+ display: "flex",
324
+ flexDirection: "column",
325
+ gap: "0.5rem",
326
+ }}
327
+ >
328
+ {PROGRESS_STEPS.map((step) => (
329
+ <ProgressCard
330
+ key={step.name}
331
+ step={step}
332
+ isCompleted={state[step.name as keyof AutoBeListenerState] !== null}
333
+ results={step.getResults(state)}
334
+ />
335
+ ))}
336
+ </div>
337
+ </div>
338
+ );
339
+
340
+ const TokenRow = ({
341
+ label,
342
+ value,
343
+ subInfo,
344
+ }: {
345
+ label: string;
346
+ value: number;
347
+ subInfo?: { label: string; value: number };
348
+ }) => (
349
+ <div
350
+ style={{
351
+ display: "flex",
352
+ justifyContent: "space-between",
353
+ alignItems: "center",
354
+ }}
355
+ >
356
+ <div style={{ display: "flex", flexDirection: "column" }}>
357
+ <span
358
+ style={{
359
+ fontSize: "0.7rem",
360
+ fontWeight: "600",
361
+ color: "#6b7280",
362
+ }}
363
+ >
364
+ {label}
365
+ </span>
366
+ {subInfo && (
367
+ <span
368
+ style={{
369
+ fontSize: "0.6rem",
370
+ color: "#9ca3af",
371
+ fontWeight: "500",
372
+ }}
373
+ >
374
+ {subInfo.label}: {toCompactNumberFormat(subInfo.value)}
375
+ </span>
376
+ )}
377
+ </div>
378
+ <span
379
+ style={{
380
+ fontSize: "0.75rem",
381
+ fontWeight: "700",
382
+ color: "#1f2937",
383
+ }}
384
+ >
385
+ {toCompactNumberFormat(value)}
386
+ </span>
387
+ </div>
388
+ );
389
+
390
+ const ComponentStats = ({
391
+ name,
392
+ component,
393
+ }: {
394
+ name: string;
395
+ component: IAutoBeTokenUsageJson.IComponent;
396
+ }) => (
397
+ <div style={CARD_STYLES.base}>
398
+ <h4 style={CARD_STYLES.header}>{name}</h4>
399
+ <div
400
+ style={{
401
+ display: "flex",
402
+ flexDirection: "column",
403
+ gap: "0.4rem",
404
+ }}
405
+ >
406
+ <div
407
+ style={{
408
+ display: "flex",
409
+ flexDirection: "column",
410
+ gap: "0.2rem",
411
+ }}
412
+ >
413
+ <TokenRow label="Total" value={component.total} />
414
+ <TokenRow
415
+ label="Input"
416
+ value={component.input.total}
417
+ subInfo={
418
+ component.input.cached > 0
419
+ ? { label: "Cache", value: component.input.cached }
420
+ : undefined
421
+ }
422
+ />
423
+ <TokenRow label="Output" value={component.output.total} />
424
+ </div>
425
+ </div>
426
+ </div>
427
+ );
428
+
429
+ const TokenUsage = ({
430
+ tokenUsage,
431
+ }: {
432
+ tokenUsage: IAutoBeTokenUsageJson | null;
433
+ }) => {
434
+ if (!tokenUsage) {
435
+ return (
436
+ <div
437
+ style={{
438
+ padding: "2rem",
439
+ textAlign: "center",
440
+ color: "#6b7280",
441
+ fontSize: "0.9rem",
442
+ }}
443
+ >
444
+ Unable to load token usage information
445
+ </div>
446
+ );
447
+ }
448
+
449
+ return (
450
+ <div>
451
+ <SectionTitle>Token Usage - Total</SectionTitle>
452
+ <ComponentStats name="total" component={tokenUsage.aggregate} />
453
+ </div>
454
+ );
455
+ };
456
+
457
+ export const AutoBeStatusModal = ({
458
+ isOpen,
459
+ onClose,
460
+ }: IAutoBeStatusModalProps) => {
461
+ const { tokenUsage, state } = useAutoBeAgent();
462
+
463
+ useEscapeKey(isOpen, onClose);
464
+
465
+ if (!isOpen) return null;
466
+
467
+ return (
468
+ <div style={MODAL_STYLES.overlay} onClick={onClose}>
469
+ <div style={MODAL_STYLES.container} onClick={(e) => e.stopPropagation()}>
470
+ <button onClick={onClose} style={MODAL_STYLES.closeButton}>
471
+ ×
472
+ </button>
473
+
474
+ <div style={MODAL_STYLES.content}>
475
+ <div style={MODAL_STYLES.section}>
476
+ {/* <ConnectionInfo header={header} /> */}
477
+ <ProgressStatus state={state} />
478
+ <TokenUsage tokenUsage={tokenUsage} />
479
+ </div>
480
+ </div>
481
+ </div>
482
+ </div>
483
+ );
484
+ };
485
+
486
+ export default AutoBeStatusModal;