@autobe/ui 0.29.2 → 0.30.0-dev.20260315
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.
- package/LICENSE +661 -661
- package/README.md +261 -0
- package/lib/components/AutoBeChatMain.js +5 -5
- package/lib/components/AutoBeChatMain.js.map +1 -1
- package/lib/components/AutoBeConfigModal.js +9 -9
- package/lib/components/AutoBeStatusModal.js +4 -4
- package/lib/components/AutoBeStatusModal.js.map +1 -1
- package/lib/components/AutoBeUserMessageMovie.d.ts +2 -2
- package/lib/components/common/ChatBubble.d.ts +2 -2
- package/lib/components/common/openai/OpenAIContent.d.ts +2 -2
- package/lib/components/common/openai/OpenAIContent.js.map +1 -1
- package/lib/components/common/openai/OpenAIUserAudioContent.js +1 -1
- package/lib/components/common/openai/OpenAIUserAudioContent.js.map +1 -1
- package/lib/components/common/openai/OpenAIUserFileContent.js +1 -1
- package/lib/components/common/openai/OpenAIUserFileContent.js.map +1 -1
- package/lib/components/common/openai/OpenAIUserImageContent.d.ts +2 -2
- package/lib/components/events/AutoBeCompleteEventMovie.d.ts +2 -2
- package/lib/components/events/AutoBeCompleteEventMovie.js +5 -5
- package/lib/components/events/AutoBeCompleteEventMovie.js.map +1 -1
- package/lib/components/events/AutoBeCorrectEventMovie.d.ts +2 -2
- package/lib/components/events/AutoBeCorrectEventMovie.js +4 -4
- package/lib/components/events/AutoBeCorrectEventMovie.js.map +1 -1
- package/lib/components/events/AutoBeEventMovie.js +38 -17
- package/lib/components/events/AutoBeEventMovie.js.map +1 -1
- package/lib/components/events/AutoBeProgressEventMovie.js +73 -13
- package/lib/components/events/AutoBeProgressEventMovie.js.map +1 -1
- package/lib/components/events/AutoBeScenarioEventMovie.d.ts +2 -2
- package/lib/components/events/AutoBeScenarioEventMovie.js +18 -5
- package/lib/components/events/AutoBeScenarioEventMovie.js.map +1 -1
- package/lib/components/events/AutoBeStartEventMovie.d.ts +2 -2
- package/lib/components/events/AutoBeStartEventMovie.js +2 -2
- package/lib/components/events/AutoBeStartEventMovie.js.map +1 -1
- package/lib/components/events/AutoBeValidateEventMovie.d.ts +2 -2
- package/lib/components/events/AutoBeValidateEventMovie.js +3 -11
- package/lib/components/events/AutoBeValidateEventMovie.js.map +1 -1
- package/lib/components/events/groups/CorrectEventGroup.d.ts +2 -2
- package/lib/components/events/groups/CorrectEventGroup.js +1 -1
- package/lib/components/events/groups/CorrectEventGroup.js.map +1 -1
- package/lib/components/events/groups/ValidateEventGroup.d.ts +2 -2
- package/lib/components/events/groups/ValidateEventGroup.js +1 -2
- package/lib/components/events/groups/ValidateEventGroup.js.map +1 -1
- package/lib/components/events/utils/eventGrouper.js +1 -2
- package/lib/components/events/utils/eventGrouper.js.map +1 -1
- package/lib/components/upload/AutoBeChatUploadBox.d.ts +3 -4
- package/lib/components/upload/AutoBeChatUploadBox.js +2 -1
- package/lib/components/upload/AutoBeChatUploadBox.js.map +1 -1
- package/lib/components/upload/AutoBeChatUploadSendButton.js +1 -1
- package/lib/components/upload/AutoBeChatUploadSendButton.js.map +1 -1
- package/lib/context/AutoBeAgentContext.d.ts +1 -3
- package/lib/context/AutoBeAgentContext.js +0 -4
- package/lib/context/AutoBeAgentContext.js.map +1 -1
- package/lib/hooks/useSessionStorage.d.ts +4 -0
- package/lib/hooks/useSessionStorage.js +16 -0
- package/lib/hooks/useSessionStorage.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/strategy/AutoBeAgentSessionStorageStrategy.d.ts +10 -0
- package/lib/strategy/AutoBeAgentSessionStorageStrategy.js +117 -0
- package/lib/strategy/AutoBeAgentSessionStorageStrategy.js.map +1 -0
- package/lib/structure/AutoBeListener.js +91 -23
- package/lib/structure/AutoBeListener.js.map +1 -1
- package/lib/structure/AutoBeListenerState.d.ts +3 -3
- package/lib/structure/AutoBeListenerState.js +4 -4
- package/lib/structure/AutoBeListenerState.js.map +1 -1
- package/lib/structure/IAutoBeAgentSessionStorageStrategy.js +1 -1
- package/lib/structure/IAutoBeAgentSessionStorageStrategy.js.map +1 -1
- package/lib/utils/AutoBeFileUploader.d.ts +2 -2
- package/lib/utils/AutoBeFileUploader.js.map +1 -1
- package/package.json +3 -4
- package/src/components/AutoBeAssistantMessageMovie.tsx +22 -22
- package/src/components/AutoBeChatMain.tsx +376 -376
- package/src/components/AutoBeChatSidebar.tsx +414 -414
- package/src/components/AutoBeConfigButton.tsx +83 -83
- package/src/components/AutoBeConfigModal.tsx +443 -443
- package/src/components/AutoBeStatusButton.tsx +75 -75
- package/src/components/AutoBeStatusModal.tsx +486 -484
- package/src/components/AutoBeUserMessageMovie.tsx +27 -27
- package/src/components/common/ActionButton.tsx +205 -205
- package/src/components/common/ActionButtonGroup.tsx +80 -80
- package/src/components/common/AutoBeConfigInput.tsx +185 -185
- package/src/components/common/ChatBubble.tsx +119 -119
- package/src/components/common/Collapsible.tsx +95 -95
- package/src/components/common/CompactSessionIndicator.tsx +73 -73
- package/src/components/common/CompactSessionList.tsx +82 -82
- package/src/components/common/index.ts +8 -8
- package/src/components/common/openai/OpenAIContent.tsx +53 -53
- package/src/components/common/openai/OpenAIUserAudioContent.tsx +70 -70
- package/src/components/common/openai/OpenAIUserFileContent.tsx +76 -76
- package/src/components/common/openai/OpenAIUserImageContent.tsx +34 -34
- package/src/components/common/openai/OpenAIUserTextContent.tsx +15 -15
- package/src/components/common/openai/index.ts +5 -5
- package/src/components/events/AutoBeCompleteEventMovie.tsx +402 -402
- package/src/components/events/AutoBeCorrectEventMovie.tsx +354 -368
- package/src/components/events/AutoBeEventGroupMovie.tsx +18 -18
- package/src/components/events/AutoBeEventMovie.tsx +158 -139
- package/src/components/events/AutoBeProgressEventMovie.tsx +217 -157
- package/src/components/events/AutoBeScenarioEventMovie.tsx +135 -95
- package/src/components/events/AutoBeStartEventMovie.tsx +82 -82
- package/src/components/events/AutoBeValidateEventMovie.tsx +249 -286
- package/src/components/events/README.md +300 -300
- package/src/components/events/common/CollapsibleEventGroup.tsx +211 -211
- package/src/components/events/common/EventCard.tsx +61 -61
- package/src/components/events/common/EventContent.tsx +31 -31
- package/src/components/events/common/EventHeader.tsx +85 -85
- package/src/components/events/common/EventIcon.tsx +82 -82
- package/src/components/events/common/ProgressBar.tsx +64 -64
- package/src/components/events/common/index.ts +13 -13
- package/src/components/events/groups/CorrectEventGroup.tsx +183 -183
- package/src/components/events/groups/ValidateEventGroup.tsx +143 -146
- package/src/components/events/groups/index.ts +8 -8
- package/src/components/events/index.ts +16 -16
- package/src/components/events/utils/eventGrouper.tsx +116 -117
- package/src/components/events/utils/index.ts +1 -1
- package/src/components/index.ts +13 -13
- package/src/components/upload/AutoBeChatUploadBox.tsx +425 -424
- package/src/components/upload/AutoBeChatUploadSendButton.tsx +66 -66
- package/src/components/upload/AutoBeFileUploadBox.tsx +123 -123
- package/src/components/upload/AutoBeUploadConfig.ts +5 -5
- package/src/components/upload/AutoBeVoiceRecoderButton.tsx +100 -100
- package/src/components/upload/index.ts +5 -5
- package/src/constant/color.ts +28 -28
- package/src/context/AutoBeAgentContext.tsx +245 -258
- package/src/context/AutoBeAgentSessionList.tsx +58 -58
- package/src/context/SearchParamsContext.tsx +49 -49
- package/src/hooks/index.ts +3 -3
- package/src/hooks/useEscapeKey.ts +24 -24
- package/src/hooks/useIsomorphicLayoutEffect.ts +8 -8
- package/src/hooks/useMediaQuery.ts +73 -73
- package/src/hooks/useSessionStorage.ts +10 -0
- package/src/icons/Receipt.tsx +74 -74
- package/src/index.ts +9 -8
- package/src/strategy/AutoBeAgentSessionStorageStrategy.ts +127 -0
- package/src/structure/AutoBeListener.ts +373 -304
- package/src/structure/AutoBeListenerState.ts +53 -53
- package/src/structure/IAutoBeAgentSessionStorageStrategy.ts +87 -87
- package/src/structure/IAutoBeEventGroup.ts +6 -6
- package/src/structure/index.ts +4 -4
- package/src/types/config.ts +44 -44
- package/src/types/index.ts +1 -1
- package/src/utils/AutoBeFileUploader.ts +279 -279
- package/src/utils/AutoBeVoiceRecorder.ts +95 -95
- package/src/utils/__tests__/crypto.test.ts +286 -286
- package/src/utils/__tests__/storage.test.ts +229 -229
- package/src/utils/crypto.ts +95 -95
- package/src/utils/index.ts +6 -6
- package/src/utils/number.ts +17 -17
- package/src/utils/storage.ts +96 -96
- package/src/utils/time.ts +14 -14
- package/tsconfig.json +9 -9
- package/vitest.config.ts +15 -15
|
@@ -1,368 +1,354 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
AutoBeRealizeAuthorizationCorrectEvent,
|
|
4
|
-
AutoBeRealizeCorrectEvent,
|
|
5
|
-
AutoBeTestCorrectEvent,
|
|
6
|
-
} from "@autobe/interface";
|
|
7
|
-
import React from "react";
|
|
8
|
-
|
|
9
|
-
import { EventCard, EventContent, EventHeader } from "./common";
|
|
10
|
-
|
|
11
|
-
/** Props interface for AutoBeCorrectEventMovie component */
|
|
12
|
-
export interface IAutoBeCorrectEventMovieProps {
|
|
13
|
-
/** Correct event to display */
|
|
14
|
-
event:
|
|
15
|
-
|
|
|
16
|
-
| AutoBeTestCorrectEvent
|
|
17
|
-
| AutoBeRealizeCorrectEvent
|
|
18
|
-
| AutoBeRealizeAuthorizationCorrectEvent;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/** Event type definition */
|
|
22
|
-
type CorrectEventType =
|
|
23
|
-
| "
|
|
24
|
-
| "testCorrect"
|
|
25
|
-
| "realizeCorrect"
|
|
26
|
-
| "realizeAuthorizationCorrect";
|
|
27
|
-
|
|
28
|
-
/** Get step configuration based on event type */
|
|
29
|
-
function getStepConfig(eventType: CorrectEventType): {
|
|
30
|
-
title: string;
|
|
31
|
-
description: string;
|
|
32
|
-
} {
|
|
33
|
-
switch (eventType) {
|
|
34
|
-
case "
|
|
35
|
-
return {
|
|
36
|
-
title: "Prisma Schema Corrected",
|
|
37
|
-
description: "Database schema has been successfully corrected",
|
|
38
|
-
};
|
|
39
|
-
case "testCorrect":
|
|
40
|
-
return {
|
|
41
|
-
title: "Test Code Corrected",
|
|
42
|
-
description: "Test implementation has been successfully corrected",
|
|
43
|
-
};
|
|
44
|
-
case "realizeCorrect":
|
|
45
|
-
return {
|
|
46
|
-
title: "Implementation Corrected",
|
|
47
|
-
description: "API implementation has been successfully corrected",
|
|
48
|
-
};
|
|
49
|
-
case "realizeAuthorizationCorrect":
|
|
50
|
-
return {
|
|
51
|
-
title: "Authorization Corrected",
|
|
52
|
-
description: "Authorization logic has been successfully corrected",
|
|
53
|
-
};
|
|
54
|
-
default:
|
|
55
|
-
eventType satisfies never;
|
|
56
|
-
throw new Error(`Unknown event type: ${eventType}`);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/** Get additional details section based on event type */
|
|
61
|
-
function getEventDetails(
|
|
62
|
-
event: IAutoBeCorrectEventMovieProps["event"],
|
|
63
|
-
): React.ReactElement | null {
|
|
64
|
-
const containerStyle: React.CSSProperties = {
|
|
65
|
-
display: "flex",
|
|
66
|
-
flexDirection: "column",
|
|
67
|
-
gap: "1rem",
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const sectionStyle: React.CSSProperties = {
|
|
71
|
-
backgroundColor: "#f0fdf4",
|
|
72
|
-
padding: "1rem",
|
|
73
|
-
borderRadius: "0.5rem",
|
|
74
|
-
border: "1px solid #bbf7d0",
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
const headerStyle: React.CSSProperties = {
|
|
78
|
-
display: "flex",
|
|
79
|
-
alignItems: "center",
|
|
80
|
-
gap: "0.5rem",
|
|
81
|
-
marginBottom: "0.75rem",
|
|
82
|
-
fontSize: "0.875rem",
|
|
83
|
-
fontWeight: "600",
|
|
84
|
-
color: "#16a34a",
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
const infoItemStyle: React.CSSProperties = {
|
|
88
|
-
display: "flex",
|
|
89
|
-
justifyContent: "space-between",
|
|
90
|
-
alignItems: "center",
|
|
91
|
-
padding: "0.5rem",
|
|
92
|
-
backgroundColor: "#f8fafc",
|
|
93
|
-
borderRadius: "0.25rem",
|
|
94
|
-
fontSize: "0.75rem",
|
|
95
|
-
color: "#475569",
|
|
96
|
-
marginBottom: "0.5rem",
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
const labelStyle: React.CSSProperties = {
|
|
100
|
-
fontWeight: "500",
|
|
101
|
-
color: "#64748b",
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
const valueStyle: React.CSSProperties = {
|
|
105
|
-
fontFamily: "monospace",
|
|
106
|
-
backgroundColor: "#e2e8f0",
|
|
107
|
-
padding: "0.125rem 0.375rem",
|
|
108
|
-
borderRadius: "0.25rem",
|
|
109
|
-
fontSize: "0.625rem",
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
const codeBlockStyle: React.CSSProperties = {
|
|
113
|
-
backgroundColor: "#f1f5f9",
|
|
114
|
-
border: "1px solid #e2e8f0",
|
|
115
|
-
borderRadius: "0.375rem",
|
|
116
|
-
padding: "0.75rem",
|
|
117
|
-
marginTop: "0.5rem",
|
|
118
|
-
fontSize: "0.75rem",
|
|
119
|
-
fontFamily: "monospace",
|
|
120
|
-
color: "#475569",
|
|
121
|
-
maxHeight: "120px",
|
|
122
|
-
overflowY: "auto",
|
|
123
|
-
lineHeight: "1.4",
|
|
124
|
-
whiteSpace: "pre-wrap",
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
const badgeStyle: React.CSSProperties = {
|
|
128
|
-
display: "inline-flex",
|
|
129
|
-
alignItems: "center",
|
|
130
|
-
padding: "0.25rem 0.5rem",
|
|
131
|
-
backgroundColor: "#dcfce7",
|
|
132
|
-
color: "#16a34a",
|
|
133
|
-
borderRadius: "0.375rem",
|
|
134
|
-
fontSize: "0.75rem",
|
|
135
|
-
fontWeight: "500",
|
|
136
|
-
border: "1px solid #bbf7d0",
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
switch (event.type) {
|
|
140
|
-
case "
|
|
141
|
-
const prismaEvent = event as IAutoBeCorrectEventMovieProps["event"] & {
|
|
142
|
-
type: "
|
|
143
|
-
};
|
|
144
|
-
return (
|
|
145
|
-
<div style={containerStyle}>
|
|
146
|
-
<div style={sectionStyle}>
|
|
147
|
-
<div style={headerStyle}>
|
|
148
|
-
🗄️ <span>Database Schema Corrections</span>
|
|
149
|
-
</div>
|
|
150
|
-
|
|
151
|
-
<div style={infoItemStyle}>
|
|
152
|
-
<span style={labelStyle}>Analysis Step:</span>
|
|
153
|
-
<span style={valueStyle}>Step {prismaEvent.step}</span>
|
|
154
|
-
</div>
|
|
155
|
-
|
|
156
|
-
{prismaEvent.planning && (
|
|
157
|
-
<div>
|
|
158
|
-
<div style={labelStyle}>🎯 Correction Strategy:</div>
|
|
159
|
-
<div style={codeBlockStyle}>{prismaEvent.planning}</div>
|
|
160
|
-
</div>
|
|
161
|
-
)}
|
|
162
|
-
|
|
163
|
-
{prismaEvent.failure && (
|
|
164
|
-
<div>
|
|
165
|
-
<div style={labelStyle}>⚠️ Validation Issues:</div>
|
|
166
|
-
<div style={codeBlockStyle}>
|
|
167
|
-
{JSON.stringify(prismaEvent.failure, null, 2)}
|
|
168
|
-
</div>
|
|
169
|
-
</div>
|
|
170
|
-
)}
|
|
171
|
-
|
|
172
|
-
<div style={{ marginTop: "0.75rem" }}>
|
|
173
|
-
<span style={badgeStyle}>✓ Schema Validated</span>
|
|
174
|
-
</div>
|
|
175
|
-
</div>
|
|
176
|
-
</div>
|
|
177
|
-
);
|
|
178
|
-
|
|
179
|
-
case "testCorrect":
|
|
180
|
-
const testEvent = event as IAutoBeCorrectEventMovieProps["event"] & {
|
|
181
|
-
type: "testCorrect";
|
|
182
|
-
};
|
|
183
|
-
return (
|
|
184
|
-
<div style={containerStyle}>
|
|
185
|
-
<div style={sectionStyle}>
|
|
186
|
-
<div style={headerStyle}>
|
|
187
|
-
🧪 <span>Test Suite Corrections</span>
|
|
188
|
-
</div>
|
|
189
|
-
|
|
190
|
-
<div style={infoItemStyle}>
|
|
191
|
-
<span style={labelStyle}>Analysis Step:</span>
|
|
192
|
-
<span style={valueStyle}>Step {testEvent.step}</span>
|
|
193
|
-
</div>
|
|
194
|
-
|
|
195
|
-
{testEvent.
|
|
196
|
-
<div style={infoItemStyle}>
|
|
197
|
-
<span style={labelStyle}>Test File:</span>
|
|
198
|
-
<span style={valueStyle}>{testEvent.
|
|
199
|
-
</div>
|
|
200
|
-
)}
|
|
201
|
-
|
|
202
|
-
{
|
|
203
|
-
<
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
<div style={
|
|
217
|
-
<span
|
|
218
|
-
</div>
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
<span style={
|
|
242
|
-
</div>
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
<div style={
|
|
255
|
-
<span
|
|
256
|
-
</div>
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
<
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
>
|
|
356
|
-
The system has automatically detected and corrected issues in the
|
|
357
|
-
code. The corrected version is now ready for the next step.
|
|
358
|
-
</div>
|
|
359
|
-
|
|
360
|
-
{/* Additional details based on event type */}
|
|
361
|
-
{eventDetails}
|
|
362
|
-
</div>
|
|
363
|
-
</EventContent>
|
|
364
|
-
</EventCard>
|
|
365
|
-
);
|
|
366
|
-
};
|
|
367
|
-
|
|
368
|
-
export default AutoBeCorrectEventMovie;
|
|
1
|
+
import {
|
|
2
|
+
AutoBeDatabaseCorrectEvent,
|
|
3
|
+
AutoBeRealizeAuthorizationCorrectEvent,
|
|
4
|
+
AutoBeRealizeCorrectEvent,
|
|
5
|
+
AutoBeTestCorrectEvent,
|
|
6
|
+
} from "@autobe/interface";
|
|
7
|
+
import React from "react";
|
|
8
|
+
|
|
9
|
+
import { EventCard, EventContent, EventHeader } from "./common";
|
|
10
|
+
|
|
11
|
+
/** Props interface for AutoBeCorrectEventMovie component */
|
|
12
|
+
export interface IAutoBeCorrectEventMovieProps {
|
|
13
|
+
/** Correct event to display */
|
|
14
|
+
event:
|
|
15
|
+
| AutoBeDatabaseCorrectEvent
|
|
16
|
+
| AutoBeTestCorrectEvent
|
|
17
|
+
| AutoBeRealizeCorrectEvent
|
|
18
|
+
| AutoBeRealizeAuthorizationCorrectEvent;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Event type definition */
|
|
22
|
+
type CorrectEventType =
|
|
23
|
+
| "databaseCorrect"
|
|
24
|
+
| "testCorrect"
|
|
25
|
+
| "realizeCorrect"
|
|
26
|
+
| "realizeAuthorizationCorrect";
|
|
27
|
+
|
|
28
|
+
/** Get step configuration based on event type */
|
|
29
|
+
function getStepConfig(eventType: CorrectEventType): {
|
|
30
|
+
title: string;
|
|
31
|
+
description: string;
|
|
32
|
+
} {
|
|
33
|
+
switch (eventType) {
|
|
34
|
+
case "databaseCorrect":
|
|
35
|
+
return {
|
|
36
|
+
title: "Prisma Schema Corrected",
|
|
37
|
+
description: "Database schema has been successfully corrected",
|
|
38
|
+
};
|
|
39
|
+
case "testCorrect":
|
|
40
|
+
return {
|
|
41
|
+
title: "Test Code Corrected",
|
|
42
|
+
description: "Test implementation has been successfully corrected",
|
|
43
|
+
};
|
|
44
|
+
case "realizeCorrect":
|
|
45
|
+
return {
|
|
46
|
+
title: "Implementation Corrected",
|
|
47
|
+
description: "API implementation has been successfully corrected",
|
|
48
|
+
};
|
|
49
|
+
case "realizeAuthorizationCorrect":
|
|
50
|
+
return {
|
|
51
|
+
title: "Authorization Corrected",
|
|
52
|
+
description: "Authorization logic has been successfully corrected",
|
|
53
|
+
};
|
|
54
|
+
default:
|
|
55
|
+
eventType satisfies never;
|
|
56
|
+
throw new Error(`Unknown event type: ${eventType}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Get additional details section based on event type */
|
|
61
|
+
function getEventDetails(
|
|
62
|
+
event: IAutoBeCorrectEventMovieProps["event"],
|
|
63
|
+
): React.ReactElement | null {
|
|
64
|
+
const containerStyle: React.CSSProperties = {
|
|
65
|
+
display: "flex",
|
|
66
|
+
flexDirection: "column",
|
|
67
|
+
gap: "1rem",
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const sectionStyle: React.CSSProperties = {
|
|
71
|
+
backgroundColor: "#f0fdf4",
|
|
72
|
+
padding: "1rem",
|
|
73
|
+
borderRadius: "0.5rem",
|
|
74
|
+
border: "1px solid #bbf7d0",
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const headerStyle: React.CSSProperties = {
|
|
78
|
+
display: "flex",
|
|
79
|
+
alignItems: "center",
|
|
80
|
+
gap: "0.5rem",
|
|
81
|
+
marginBottom: "0.75rem",
|
|
82
|
+
fontSize: "0.875rem",
|
|
83
|
+
fontWeight: "600",
|
|
84
|
+
color: "#16a34a",
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const infoItemStyle: React.CSSProperties = {
|
|
88
|
+
display: "flex",
|
|
89
|
+
justifyContent: "space-between",
|
|
90
|
+
alignItems: "center",
|
|
91
|
+
padding: "0.5rem",
|
|
92
|
+
backgroundColor: "#f8fafc",
|
|
93
|
+
borderRadius: "0.25rem",
|
|
94
|
+
fontSize: "0.75rem",
|
|
95
|
+
color: "#475569",
|
|
96
|
+
marginBottom: "0.5rem",
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const labelStyle: React.CSSProperties = {
|
|
100
|
+
fontWeight: "500",
|
|
101
|
+
color: "#64748b",
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const valueStyle: React.CSSProperties = {
|
|
105
|
+
fontFamily: "monospace",
|
|
106
|
+
backgroundColor: "#e2e8f0",
|
|
107
|
+
padding: "0.125rem 0.375rem",
|
|
108
|
+
borderRadius: "0.25rem",
|
|
109
|
+
fontSize: "0.625rem",
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const codeBlockStyle: React.CSSProperties = {
|
|
113
|
+
backgroundColor: "#f1f5f9",
|
|
114
|
+
border: "1px solid #e2e8f0",
|
|
115
|
+
borderRadius: "0.375rem",
|
|
116
|
+
padding: "0.75rem",
|
|
117
|
+
marginTop: "0.5rem",
|
|
118
|
+
fontSize: "0.75rem",
|
|
119
|
+
fontFamily: "monospace",
|
|
120
|
+
color: "#475569",
|
|
121
|
+
maxHeight: "120px",
|
|
122
|
+
overflowY: "auto",
|
|
123
|
+
lineHeight: "1.4",
|
|
124
|
+
whiteSpace: "pre-wrap",
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const badgeStyle: React.CSSProperties = {
|
|
128
|
+
display: "inline-flex",
|
|
129
|
+
alignItems: "center",
|
|
130
|
+
padding: "0.25rem 0.5rem",
|
|
131
|
+
backgroundColor: "#dcfce7",
|
|
132
|
+
color: "#16a34a",
|
|
133
|
+
borderRadius: "0.375rem",
|
|
134
|
+
fontSize: "0.75rem",
|
|
135
|
+
fontWeight: "500",
|
|
136
|
+
border: "1px solid #bbf7d0",
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
switch (event.type) {
|
|
140
|
+
case "databaseCorrect":
|
|
141
|
+
const prismaEvent = event as IAutoBeCorrectEventMovieProps["event"] & {
|
|
142
|
+
type: "databaseCorrect";
|
|
143
|
+
};
|
|
144
|
+
return (
|
|
145
|
+
<div style={containerStyle}>
|
|
146
|
+
<div style={sectionStyle}>
|
|
147
|
+
<div style={headerStyle}>
|
|
148
|
+
🗄️ <span>Database Schema Corrections</span>
|
|
149
|
+
</div>
|
|
150
|
+
|
|
151
|
+
<div style={infoItemStyle}>
|
|
152
|
+
<span style={labelStyle}>Analysis Step:</span>
|
|
153
|
+
<span style={valueStyle}>Step {prismaEvent.step}</span>
|
|
154
|
+
</div>
|
|
155
|
+
|
|
156
|
+
{prismaEvent.planning && (
|
|
157
|
+
<div>
|
|
158
|
+
<div style={labelStyle}>🎯 Correction Strategy:</div>
|
|
159
|
+
<div style={codeBlockStyle}>{prismaEvent.planning}</div>
|
|
160
|
+
</div>
|
|
161
|
+
)}
|
|
162
|
+
|
|
163
|
+
{prismaEvent.failure && (
|
|
164
|
+
<div>
|
|
165
|
+
<div style={labelStyle}>⚠️ Validation Issues:</div>
|
|
166
|
+
<div style={codeBlockStyle}>
|
|
167
|
+
{JSON.stringify(prismaEvent.failure, null, 2)}
|
|
168
|
+
</div>
|
|
169
|
+
</div>
|
|
170
|
+
)}
|
|
171
|
+
|
|
172
|
+
<div style={{ marginTop: "0.75rem" }}>
|
|
173
|
+
<span style={badgeStyle}>✓ Schema Validated</span>
|
|
174
|
+
</div>
|
|
175
|
+
</div>
|
|
176
|
+
</div>
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
case "testCorrect":
|
|
180
|
+
const testEvent = event as IAutoBeCorrectEventMovieProps["event"] & {
|
|
181
|
+
type: "testCorrect";
|
|
182
|
+
};
|
|
183
|
+
return (
|
|
184
|
+
<div style={containerStyle}>
|
|
185
|
+
<div style={sectionStyle}>
|
|
186
|
+
<div style={headerStyle}>
|
|
187
|
+
🧪 <span>Test Suite Corrections</span>
|
|
188
|
+
</div>
|
|
189
|
+
|
|
190
|
+
<div style={infoItemStyle}>
|
|
191
|
+
<span style={labelStyle}>Analysis Step:</span>
|
|
192
|
+
<span style={valueStyle}>Step {testEvent.step}</span>
|
|
193
|
+
</div>
|
|
194
|
+
|
|
195
|
+
{testEvent.function?.location && (
|
|
196
|
+
<div style={infoItemStyle}>
|
|
197
|
+
<span style={labelStyle}>Test File:</span>
|
|
198
|
+
<span style={valueStyle}>{testEvent.function.location}</span>
|
|
199
|
+
</div>
|
|
200
|
+
)}
|
|
201
|
+
|
|
202
|
+
<div style={{ marginTop: "0.75rem" }}>
|
|
203
|
+
<span style={badgeStyle}>✓ Tests Corrected</span>
|
|
204
|
+
</div>
|
|
205
|
+
</div>
|
|
206
|
+
</div>
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
case "realizeCorrect":
|
|
210
|
+
const realizeEvent = event as IAutoBeCorrectEventMovieProps["event"] & {
|
|
211
|
+
type: "realizeCorrect";
|
|
212
|
+
};
|
|
213
|
+
return (
|
|
214
|
+
<div style={containerStyle}>
|
|
215
|
+
<div style={sectionStyle}>
|
|
216
|
+
<div style={headerStyle}>
|
|
217
|
+
⚙️ <span>Implementation Corrections</span>
|
|
218
|
+
</div>
|
|
219
|
+
|
|
220
|
+
<div style={infoItemStyle}>
|
|
221
|
+
<span style={labelStyle}>Analysis Step:</span>
|
|
222
|
+
<span style={valueStyle}>Step {realizeEvent.step}</span>
|
|
223
|
+
</div>
|
|
224
|
+
|
|
225
|
+
<div style={infoItemStyle}>
|
|
226
|
+
<span style={labelStyle}>File Location:</span>
|
|
227
|
+
<span style={valueStyle}>{realizeEvent.function.location}</span>
|
|
228
|
+
</div>
|
|
229
|
+
|
|
230
|
+
{realizeEvent.function.content && (
|
|
231
|
+
<div>
|
|
232
|
+
<div style={labelStyle}>📄 Corrected Implementation:</div>
|
|
233
|
+
<div style={codeBlockStyle}>
|
|
234
|
+
{realizeEvent.function.content.slice(0, 500)}
|
|
235
|
+
{realizeEvent.function.content.length > 500 && "..."}
|
|
236
|
+
</div>
|
|
237
|
+
</div>
|
|
238
|
+
)}
|
|
239
|
+
|
|
240
|
+
<div style={{ marginTop: "0.75rem" }}>
|
|
241
|
+
<span style={badgeStyle}>✓ Implementation Fixed</span>
|
|
242
|
+
</div>
|
|
243
|
+
</div>
|
|
244
|
+
</div>
|
|
245
|
+
);
|
|
246
|
+
|
|
247
|
+
case "realizeAuthorizationCorrect":
|
|
248
|
+
const authEvent = event as IAutoBeCorrectEventMovieProps["event"] & {
|
|
249
|
+
type: "realizeAuthorizationCorrect";
|
|
250
|
+
};
|
|
251
|
+
return (
|
|
252
|
+
<div style={containerStyle}>
|
|
253
|
+
<div style={sectionStyle}>
|
|
254
|
+
<div style={headerStyle}>
|
|
255
|
+
🔐 <span>Authorization Corrections</span>
|
|
256
|
+
</div>
|
|
257
|
+
|
|
258
|
+
<div style={infoItemStyle}>
|
|
259
|
+
<span style={labelStyle}>Analysis Step:</span>
|
|
260
|
+
<span style={valueStyle}>Step {authEvent.step}</span>
|
|
261
|
+
</div>
|
|
262
|
+
|
|
263
|
+
{authEvent.authorization && (
|
|
264
|
+
<div style={infoItemStyle}>
|
|
265
|
+
<span style={labelStyle}>Authorization Module:</span>
|
|
266
|
+
<span style={valueStyle}>
|
|
267
|
+
{JSON.stringify(authEvent.authorization).slice(0, 50)}...
|
|
268
|
+
</span>
|
|
269
|
+
</div>
|
|
270
|
+
)}
|
|
271
|
+
|
|
272
|
+
{authEvent.result && (
|
|
273
|
+
<div>
|
|
274
|
+
<div style={labelStyle}>⚠️ Compilation Issues:</div>
|
|
275
|
+
<div style={codeBlockStyle}>
|
|
276
|
+
{JSON.stringify(authEvent.result, null, 2)}
|
|
277
|
+
</div>
|
|
278
|
+
</div>
|
|
279
|
+
)}
|
|
280
|
+
|
|
281
|
+
<div style={{ marginTop: "0.75rem" }}>
|
|
282
|
+
<span style={badgeStyle}>✓ Authorization Secured</span>
|
|
283
|
+
</div>
|
|
284
|
+
</div>
|
|
285
|
+
</div>
|
|
286
|
+
);
|
|
287
|
+
|
|
288
|
+
default:
|
|
289
|
+
return null;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/** Component for displaying correction events */
|
|
294
|
+
export const AutoBeCorrectEventMovie = (
|
|
295
|
+
props: IAutoBeCorrectEventMovieProps,
|
|
296
|
+
) => {
|
|
297
|
+
const eventType = props.event.type;
|
|
298
|
+
const config = getStepConfig(eventType);
|
|
299
|
+
const eventDetails = getEventDetails(props.event);
|
|
300
|
+
|
|
301
|
+
return (
|
|
302
|
+
<EventCard variant="success">
|
|
303
|
+
<EventHeader
|
|
304
|
+
title={config.title}
|
|
305
|
+
subtitle={config.description}
|
|
306
|
+
timestamp={props.event.created_at}
|
|
307
|
+
iconType="success"
|
|
308
|
+
/>
|
|
309
|
+
<EventContent>
|
|
310
|
+
<div
|
|
311
|
+
style={{
|
|
312
|
+
display: "flex",
|
|
313
|
+
flexDirection: "column",
|
|
314
|
+
gap: "0.75rem",
|
|
315
|
+
}}
|
|
316
|
+
>
|
|
317
|
+
<div
|
|
318
|
+
style={{
|
|
319
|
+
display: "flex",
|
|
320
|
+
alignItems: "center",
|
|
321
|
+
gap: "0.5rem",
|
|
322
|
+
}}
|
|
323
|
+
>
|
|
324
|
+
<span
|
|
325
|
+
style={{
|
|
326
|
+
color: "#16a34a",
|
|
327
|
+
fontWeight: "600",
|
|
328
|
+
fontSize: "0.875rem",
|
|
329
|
+
}}
|
|
330
|
+
>
|
|
331
|
+
✓ Correction Applied
|
|
332
|
+
</span>
|
|
333
|
+
</div>
|
|
334
|
+
|
|
335
|
+
<div
|
|
336
|
+
style={{
|
|
337
|
+
fontSize: "0.875rem",
|
|
338
|
+
color: "#475569",
|
|
339
|
+
lineHeight: "1.5",
|
|
340
|
+
}}
|
|
341
|
+
>
|
|
342
|
+
The system has automatically detected and corrected issues in the
|
|
343
|
+
code. The corrected version is now ready for the next step.
|
|
344
|
+
</div>
|
|
345
|
+
|
|
346
|
+
{/* Additional details based on event type */}
|
|
347
|
+
{eventDetails}
|
|
348
|
+
</div>
|
|
349
|
+
</EventContent>
|
|
350
|
+
</EventCard>
|
|
351
|
+
);
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
export default AutoBeCorrectEventMovie;
|