sonance-brand-mcp 1.3.110 → 1.3.112
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/dist/assets/api/sonance-ai-edit/route.ts +30 -7
- package/dist/assets/api/sonance-save-image/route.ts +625 -0
- package/dist/assets/api/sonance-vision-apply/image-styling-detection.ts +1360 -0
- package/dist/assets/api/sonance-vision-apply/route.ts +1020 -64
- package/dist/assets/api/sonance-vision-apply/styling-detection.ts +730 -0
- package/dist/assets/api/sonance-vision-apply/theme-discovery.ts +1 -1
- package/dist/assets/api/sonance-vision-edit/route.ts +33 -8
- package/dist/assets/brand-system.ts +13 -12
- package/dist/assets/components/accordion.tsx +15 -7
- package/dist/assets/components/alert-dialog.tsx +35 -10
- package/dist/assets/components/alert.tsx +11 -10
- package/dist/assets/components/avatar.tsx +4 -4
- package/dist/assets/components/badge.tsx +16 -12
- package/dist/assets/components/button.stories.tsx +3 -3
- package/dist/assets/components/button.tsx +50 -31
- package/dist/assets/components/calendar.tsx +12 -8
- package/dist/assets/components/card.tsx +35 -29
- package/dist/assets/components/checkbox.tsx +9 -8
- package/dist/assets/components/code.tsx +19 -11
- package/dist/assets/components/command.tsx +32 -13
- package/dist/assets/components/context-menu.tsx +37 -16
- package/dist/assets/components/dialog.tsx +8 -5
- package/dist/assets/components/divider.tsx +15 -5
- package/dist/assets/components/drawer.tsx +4 -3
- package/dist/assets/components/dropdown-menu.tsx +15 -13
- package/dist/assets/components/hover-card.tsx +4 -1
- package/dist/assets/components/image.tsx +1 -1
- package/dist/assets/components/input.tsx +29 -14
- package/dist/assets/components/kbd.stories.tsx +3 -3
- package/dist/assets/components/kbd.tsx +29 -13
- package/dist/assets/components/listbox.tsx +8 -8
- package/dist/assets/components/menubar.tsx +50 -23
- package/dist/assets/components/navbar.stories.tsx +140 -13
- package/dist/assets/components/navbar.tsx +22 -5
- package/dist/assets/components/navigation-menu.tsx +28 -6
- package/dist/assets/components/pagination.tsx +10 -10
- package/dist/assets/components/popover.tsx +10 -8
- package/dist/assets/components/progress.tsx +6 -4
- package/dist/assets/components/radio-group.tsx +5 -5
- package/dist/assets/components/select.tsx +49 -29
- package/dist/assets/components/separator.tsx +3 -3
- package/dist/assets/components/sheet.tsx +4 -4
- package/dist/assets/components/sidebar.tsx +10 -10
- package/dist/assets/components/skeleton.tsx +13 -5
- package/dist/assets/components/slider.tsx +12 -10
- package/dist/assets/components/switch.tsx +4 -4
- package/dist/assets/components/table.tsx +5 -5
- package/dist/assets/components/tabs.tsx +8 -8
- package/dist/assets/components/textarea.tsx +11 -9
- package/dist/assets/components/toast.tsx +7 -7
- package/dist/assets/components/toggle.tsx +27 -7
- package/dist/assets/components/tooltip.tsx +10 -8
- package/dist/assets/components/user.tsx +8 -6
- package/dist/assets/dev-tools/SonanceDevTools.tsx +851 -708
- package/dist/assets/dev-tools/components/ApplyFirstPreview.tsx +10 -10
- package/dist/assets/dev-tools/components/ChatHistory.tsx +145 -0
- package/dist/assets/dev-tools/components/ChatInterface.tsx +444 -295
- package/dist/assets/dev-tools/components/ChatTabBar.tsx +82 -0
- package/dist/assets/dev-tools/components/DiffPreview.tsx +1 -1
- package/dist/assets/dev-tools/components/InlineDiffPreview.tsx +528 -0
- package/dist/assets/dev-tools/components/InspectorOverlay.tsx +21 -18
- package/dist/assets/dev-tools/components/PropertiesPanel.tsx +1345 -0
- package/dist/assets/dev-tools/components/ScreenshotAnnotator.tsx +1 -1
- package/dist/assets/dev-tools/components/SectionHighlight.tsx +1 -1
- package/dist/assets/dev-tools/components/VisionDiffPreview.tsx +7 -7
- package/dist/assets/dev-tools/components/VisionModeBorder.tsx +12 -63
- package/dist/assets/dev-tools/constants.ts +38 -6
- package/dist/assets/dev-tools/hooks/index.ts +69 -0
- package/dist/assets/dev-tools/hooks/useComponentDetection.ts +132 -0
- package/dist/assets/dev-tools/hooks/useComputedStyles.ts +471 -0
- package/dist/assets/dev-tools/hooks/useContentHash.ts +212 -0
- package/dist/assets/dev-tools/hooks/useElementScanner.ts +398 -0
- package/dist/assets/dev-tools/hooks/useImageDetection.ts +162 -0
- package/dist/assets/dev-tools/hooks/useTextDetection.ts +217 -0
- package/dist/assets/dev-tools/index.ts +3 -0
- package/dist/assets/dev-tools/panels/AnalysisPanel.tsx +32 -32
- package/dist/assets/dev-tools/panels/ComponentsPanel.tsx +384 -131
- package/dist/assets/dev-tools/panels/TextPanel.tsx +10 -10
- package/dist/assets/dev-tools/types.ts +93 -2
- package/dist/assets/globals.css +225 -9
- package/dist/assets/styles/brand-overrides.css +3 -2
- package/dist/assets/utils.ts +2 -1
- package/dist/index.js +22 -3
- package/package.json +2 -1
|
@@ -36,14 +36,14 @@ function FileModificationCard({
|
|
|
36
36
|
<ChevronRight className="h-3.5 w-3.5 text-gray-400 flex-shrink-0" />
|
|
37
37
|
)}
|
|
38
38
|
<FileCode className="h-3.5 w-3.5 text-green-500 flex-shrink-0" />
|
|
39
|
-
<span className="text-xs font-mono text-gray-700 truncate flex-1">
|
|
39
|
+
<span id="file-modification-card-span-modificationfilepath" className="text-xs font-mono text-gray-700 truncate flex-1">
|
|
40
40
|
{modification.filePath}
|
|
41
41
|
</span>
|
|
42
42
|
</button>
|
|
43
43
|
|
|
44
44
|
{/* Explanation */}
|
|
45
45
|
<div className="px-2 pb-2">
|
|
46
|
-
<p className="text-[10px] text-gray-500">{modification.explanation}</p>
|
|
46
|
+
<p id="file-modification-card-p-modificationexplanat" className="text-[10px] text-gray-500">{modification.explanation}</p>
|
|
47
47
|
</div>
|
|
48
48
|
|
|
49
49
|
{/* Expanded Diff */}
|
|
@@ -78,7 +78,7 @@ function FileModificationCard({
|
|
|
78
78
|
function HMRStatusBadge({ status }: { status: ApplyFirstStatus }) {
|
|
79
79
|
if (status === "waiting-hmr") {
|
|
80
80
|
return (
|
|
81
|
-
<span className="flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-amber-100 text-amber-700">
|
|
81
|
+
<span id="h-m-r-status-badge-span" className="flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-amber-100 text-amber-700">
|
|
82
82
|
<Loader2 className="h-3 w-3 animate-spin" />
|
|
83
83
|
Refreshing...
|
|
84
84
|
</span>
|
|
@@ -87,7 +87,7 @@ function HMRStatusBadge({ status }: { status: ApplyFirstStatus }) {
|
|
|
87
87
|
|
|
88
88
|
if (status === "reviewing") {
|
|
89
89
|
return (
|
|
90
|
-
<span className="flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-green-100 text-green-700">
|
|
90
|
+
<span id="h-m-r-status-badge-span" className="flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-green-100 text-green-700">
|
|
91
91
|
<Check className="h-3 w-3" />
|
|
92
92
|
Changes Live
|
|
93
93
|
</span>
|
|
@@ -142,10 +142,10 @@ export function ApplyFirstPreview({
|
|
|
142
142
|
<div className="flex items-center justify-between">
|
|
143
143
|
<div className="flex items-center gap-2">
|
|
144
144
|
<Zap className={cn("h-4 w-4", isPreviewMode ? "text-blue-600" : "text-green-600")} />
|
|
145
|
-
<span className="text-xs font-semibold text-gray-900">
|
|
145
|
+
<span id="apply-first-preview-span-ispreviewmode-propos" className="text-xs font-semibold text-gray-900">
|
|
146
146
|
{isPreviewMode ? "Proposed Changes" : "Changes Applied"}
|
|
147
147
|
</span>
|
|
148
|
-
<span className={cn(
|
|
148
|
+
<span id="apply-first-preview-span-filecount-filefileco" className={cn(
|
|
149
149
|
"text-[10px] px-1.5 py-0.5 rounded font-medium",
|
|
150
150
|
isPreviewMode
|
|
151
151
|
? "bg-blue-200 text-blue-700"
|
|
@@ -163,7 +163,7 @@ export function ApplyFirstPreview({
|
|
|
163
163
|
{isStaleSession ? (
|
|
164
164
|
<div className="flex items-start gap-2 p-2 rounded bg-amber-50 border border-amber-200">
|
|
165
165
|
<AlertTriangle className="h-3.5 w-3.5 text-amber-600 mt-0.5 flex-shrink-0" />
|
|
166
|
-
<span className="text-xs text-amber-700">
|
|
166
|
+
<span id="apply-first-preview-span" className="text-xs text-amber-700">
|
|
167
167
|
<strong>Stale session detected.</strong> The backup files may no longer exist.
|
|
168
168
|
Use "Force Clear" to dismiss this panel.
|
|
169
169
|
</span>
|
|
@@ -171,7 +171,7 @@ export function ApplyFirstPreview({
|
|
|
171
171
|
) : isPreviewMode ? (
|
|
172
172
|
<div className="flex items-start gap-2 p-2 rounded bg-blue-50 border border-blue-200">
|
|
173
173
|
<Info className="h-3.5 w-3.5 text-blue-600 mt-0.5 flex-shrink-0" />
|
|
174
|
-
<span className="text-xs text-blue-700">
|
|
174
|
+
<span id="apply-first-preview-span" className="text-xs text-blue-700">
|
|
175
175
|
<strong>Review the changes below.</strong> Click Accept to apply them to your files,
|
|
176
176
|
or Reject to discard.
|
|
177
177
|
</span>
|
|
@@ -179,7 +179,7 @@ export function ApplyFirstPreview({
|
|
|
179
179
|
) : (
|
|
180
180
|
<div className="flex items-start gap-2 p-2 rounded bg-blue-50 border border-blue-200">
|
|
181
181
|
<Info className="h-3.5 w-3.5 text-blue-600 mt-0.5 flex-shrink-0" />
|
|
182
|
-
<span className="text-xs text-blue-700">
|
|
182
|
+
<span id="apply-first-preview-span" className="text-xs text-blue-700">
|
|
183
183
|
<strong>Changes are live!</strong> Scroll around to see the actual result.
|
|
184
184
|
Your original files are safely backed up.
|
|
185
185
|
</span>
|
|
@@ -202,7 +202,7 @@ export function ApplyFirstPreview({
|
|
|
202
202
|
{!isPreviewMode && (
|
|
203
203
|
<div className="flex items-start gap-2 p-2 rounded bg-amber-50 border border-amber-200">
|
|
204
204
|
<AlertTriangle className="h-3.5 w-3.5 text-amber-600 mt-0.5 flex-shrink-0" />
|
|
205
|
-
<span className="text-xs text-amber-700">
|
|
205
|
+
<span id="apply-first-preview-span-navigating-away-will" className="text-xs text-amber-700">
|
|
206
206
|
Navigating away will automatically revert changes. Make sure to accept or revert first.
|
|
207
207
|
</span>
|
|
208
208
|
</div>
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React, { useRef, useEffect } from "react";
|
|
4
|
+
import { User, Bot, AlertCircle, CheckCircle, RotateCcw } from "lucide-react";
|
|
5
|
+
import { cn } from "../../../lib/utils";
|
|
6
|
+
import { ChatMessage, ApplyFirstStatus } from "../types";
|
|
7
|
+
import { InlineDiffPreview } from "./InlineDiffPreview";
|
|
8
|
+
|
|
9
|
+
export interface ChatHistoryProps {
|
|
10
|
+
messages: ChatMessage[];
|
|
11
|
+
onAcceptChanges?: (messageId: string) => void;
|
|
12
|
+
onRevertChanges?: (messageId: string) => void;
|
|
13
|
+
visionMode?: boolean;
|
|
14
|
+
// Live status for the most recent action
|
|
15
|
+
liveStatus?: ApplyFirstStatus;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function ChatHistory({
|
|
19
|
+
messages,
|
|
20
|
+
onAcceptChanges,
|
|
21
|
+
onRevertChanges,
|
|
22
|
+
visionMode = false,
|
|
23
|
+
liveStatus,
|
|
24
|
+
}: ChatHistoryProps) {
|
|
25
|
+
const scrollRef = useRef<HTMLDivElement>(null);
|
|
26
|
+
const bottomRef = useRef<HTMLDivElement>(null);
|
|
27
|
+
|
|
28
|
+
// Auto-scroll to bottom when new messages arrive
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
bottomRef.current?.scrollIntoView({ behavior: "smooth" });
|
|
31
|
+
}, [messages]);
|
|
32
|
+
|
|
33
|
+
// Format timestamp
|
|
34
|
+
const formatTime = (date: Date) => {
|
|
35
|
+
return date.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
if (messages.length === 0) {
|
|
39
|
+
return null; // Empty state is handled by parent
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<div
|
|
44
|
+
ref={scrollRef}
|
|
45
|
+
className="flex-1 overflow-y-auto px-3 py-4 space-y-4 bg-background"
|
|
46
|
+
style={{ overscrollBehavior: "contain" }}
|
|
47
|
+
>
|
|
48
|
+
{messages.map((message, index) => (
|
|
49
|
+
<div
|
|
50
|
+
key={message.id}
|
|
51
|
+
className={cn(
|
|
52
|
+
"flex gap-3 animate-in fade-in-0 slide-in-from-bottom-2",
|
|
53
|
+
message.role === "system" && "justify-center"
|
|
54
|
+
)}
|
|
55
|
+
style={{ animationDelay: `${Math.min(index * 30, 150)}ms` }}
|
|
56
|
+
>
|
|
57
|
+
{/* Avatar */}
|
|
58
|
+
{message.role !== "system" && (
|
|
59
|
+
<div
|
|
60
|
+
className={cn(
|
|
61
|
+
"flex-shrink-0 w-7 h-7 rounded-full flex items-center justify-center",
|
|
62
|
+
message.role === "user"
|
|
63
|
+
? "bg-gradient-to-br from-[#00A3E1] to-[#0090c8]"
|
|
64
|
+
: "bg-gradient-to-br from-gray-200 to-gray-300 dark:from-gray-600 dark:to-gray-700"
|
|
65
|
+
)}
|
|
66
|
+
>
|
|
67
|
+
{message.role === "user" ? (
|
|
68
|
+
<User className="h-3.5 w-3.5 text-white" />
|
|
69
|
+
) : (
|
|
70
|
+
<Bot className="h-3.5 w-3.5 text-gray-600 dark:text-gray-300" />
|
|
71
|
+
)}
|
|
72
|
+
</div>
|
|
73
|
+
)}
|
|
74
|
+
|
|
75
|
+
{/* Message Content */}
|
|
76
|
+
<div className={cn("flex-1 min-w-0", message.role === "system" && "text-center")}>
|
|
77
|
+
{/* Role Label + Timestamp */}
|
|
78
|
+
{message.role !== "system" && (
|
|
79
|
+
<div className="flex items-center gap-2 mb-1">
|
|
80
|
+
<span id="span-messagerole-user-you" className="text-[11px] font-semibold text-foreground">
|
|
81
|
+
{message.role === "user" ? "You" : "AI Assistant"}
|
|
82
|
+
</span>
|
|
83
|
+
<span id="span-formattimemessagetim" className="text-[10px] text-foreground-muted">
|
|
84
|
+
{formatTime(message.timestamp)}
|
|
85
|
+
</span>
|
|
86
|
+
</div>
|
|
87
|
+
)}
|
|
88
|
+
|
|
89
|
+
{/* Message Text */}
|
|
90
|
+
<div
|
|
91
|
+
className={cn(
|
|
92
|
+
"text-sm leading-relaxed",
|
|
93
|
+
message.role === "user" && "text-foreground",
|
|
94
|
+
message.role === "assistant" && "text-foreground-secondary",
|
|
95
|
+
message.role === "system" && "text-xs text-foreground-muted italic"
|
|
96
|
+
)}
|
|
97
|
+
>
|
|
98
|
+
<p id="p-messagecontent" className="whitespace-pre-wrap">{message.content}</p>
|
|
99
|
+
</div>
|
|
100
|
+
|
|
101
|
+
{/* Inline Diff Preview for actions */}
|
|
102
|
+
{message.action && message.action.files && message.action.files.length > 0 && (
|
|
103
|
+
<div className="mt-3">
|
|
104
|
+
<InlineDiffPreview
|
|
105
|
+
action={message.action}
|
|
106
|
+
onAccept={() => onAcceptChanges?.(message.id)}
|
|
107
|
+
onRevert={() => onRevertChanges?.(message.id)}
|
|
108
|
+
liveStatus={message.action.status === "pending" ? liveStatus : undefined}
|
|
109
|
+
/>
|
|
110
|
+
</div>
|
|
111
|
+
)}
|
|
112
|
+
|
|
113
|
+
{/* Status badge for actions without files */}
|
|
114
|
+
{message.action && (!message.action.files || message.action.files.length === 0) && (
|
|
115
|
+
<div className="mt-2">
|
|
116
|
+
{message.action.status === "accepted" && (
|
|
117
|
+
<div className="inline-flex items-center gap-1.5 px-2 py-1 bg-green-50 dark:bg-green-900/30 text-green-700 dark:text-green-400 text-xs rounded-md">
|
|
118
|
+
<CheckCircle className="h-3 w-3" />
|
|
119
|
+
<span id="span-changes-accepted">Changes accepted</span>
|
|
120
|
+
</div>
|
|
121
|
+
)}
|
|
122
|
+
{message.action.status === "reverted" && (
|
|
123
|
+
<div className="inline-flex items-center gap-1.5 px-2 py-1 bg-amber-50 dark:bg-amber-900/30 text-amber-700 dark:text-amber-400 text-xs rounded-md">
|
|
124
|
+
<RotateCcw className="h-3 w-3" />
|
|
125
|
+
<span id="span-changes-reverted">Changes reverted</span>
|
|
126
|
+
</div>
|
|
127
|
+
)}
|
|
128
|
+
{message.action.status === "error" && (
|
|
129
|
+
<div className="inline-flex items-center gap-1.5 px-2 py-1 bg-red-50 dark:bg-red-900/30 text-red-700 dark:text-red-400 text-xs rounded-md">
|
|
130
|
+
<AlertCircle className="h-3 w-3" />
|
|
131
|
+
<span id="span-error-occurred">Error occurred</span>
|
|
132
|
+
</div>
|
|
133
|
+
)}
|
|
134
|
+
</div>
|
|
135
|
+
)}
|
|
136
|
+
</div>
|
|
137
|
+
</div>
|
|
138
|
+
))}
|
|
139
|
+
|
|
140
|
+
{/* Scroll anchor */}
|
|
141
|
+
<div ref={bottomRef} />
|
|
142
|
+
</div>
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|