sonance-brand-mcp 1.3.49 → 1.3.50

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.
@@ -1228,6 +1228,23 @@ export function SonanceDevTools() {
1228
1228
  }
1229
1229
  }, [applyFirstSession]);
1230
1230
 
1231
+ // Force clear stale session - clears state without calling API
1232
+ const handleApplyFirstForceClear = useCallback(() => {
1233
+ console.log("[Apply-First] Force clearing stale session");
1234
+ setApplyFirstSession(null);
1235
+ setApplyFirstStatus("idle");
1236
+ setVisionFocusedElements([]);
1237
+ setChangedElements([]);
1238
+
1239
+ // Clear persisted session from localStorage
1240
+ try {
1241
+ localStorage.removeItem("sonance-apply-first-session");
1242
+ console.log("[Apply-First] Session force-cleared from localStorage");
1243
+ } catch (e) {
1244
+ console.warn("[Apply-First] Failed to clear session:", e);
1245
+ }
1246
+ }, []);
1247
+
1231
1248
  // Auto-revert on navigation (beforeunload)
1232
1249
  useEffect(() => {
1233
1250
  if (!applyFirstSession) return;
@@ -2533,6 +2550,7 @@ export function SonanceDevTools() {
2533
2550
  onApplyFirstComplete={handleApplyFirstComplete}
2534
2551
  onApplyFirstAccept={handleApplyFirstAccept}
2535
2552
  onApplyFirstRevert={handleApplyFirstRevert}
2553
+ onApplyFirstForceClear={handleApplyFirstForceClear}
2536
2554
  />
2537
2555
  )}
2538
2556
 
@@ -10,6 +10,7 @@ export interface ApplyFirstPreviewProps {
10
10
  status: ApplyFirstStatus;
11
11
  onAccept: () => void;
12
12
  onRevert: () => void;
13
+ onForceClear?: () => void; // Force clear stale sessions
13
14
  }
14
15
 
15
16
  function FileModificationCard({
@@ -100,6 +101,7 @@ export function ApplyFirstPreview({
100
101
  status,
101
102
  onAccept,
102
103
  onRevert,
104
+ onForceClear,
103
105
  }: ApplyFirstPreviewProps) {
104
106
  const [expandedFiles, setExpandedFiles] = useState<Set<string>>(new Set());
105
107
 
@@ -124,6 +126,7 @@ export function ApplyFirstPreview({
124
126
 
125
127
  const fileCount = session.modifications.length;
126
128
  const isLoading = status === "accepting" || status === "reverting";
129
+ const isStaleSession = fileCount === 0 || status === "error";
127
130
 
128
131
  return (
129
132
  <div className="space-y-3 p-3 rounded border border-green-300 bg-green-50">
@@ -141,14 +144,24 @@ export function ApplyFirstPreview({
141
144
  <HMRStatusBadge status={status} />
142
145
  </div>
143
146
 
144
- {/* Info Banner */}
145
- <div className="flex items-start gap-2 p-2 rounded bg-blue-50 border border-blue-200">
146
- <Info className="h-3.5 w-3.5 text-blue-600 mt-0.5 flex-shrink-0" />
147
- <span className="text-xs text-blue-700">
148
- <strong>Changes are live!</strong> Scroll around to see the actual result.
149
- Your original files are safely backed up.
150
- </span>
151
- </div>
147
+ {/* Info Banner - show different message for stale sessions */}
148
+ {isStaleSession ? (
149
+ <div className="flex items-start gap-2 p-2 rounded bg-amber-50 border border-amber-200">
150
+ <AlertTriangle className="h-3.5 w-3.5 text-amber-600 mt-0.5 flex-shrink-0" />
151
+ <span className="text-xs text-amber-700">
152
+ <strong>Stale session detected.</strong> The backup files may no longer exist.
153
+ Use &quot;Force Clear&quot; to dismiss this panel.
154
+ </span>
155
+ </div>
156
+ ) : (
157
+ <div className="flex items-start gap-2 p-2 rounded bg-blue-50 border border-blue-200">
158
+ <Info className="h-3.5 w-3.5 text-blue-600 mt-0.5 flex-shrink-0" />
159
+ <span className="text-xs text-blue-700">
160
+ <strong>Changes are live!</strong> Scroll around to see the actual result.
161
+ Your original files are safely backed up.
162
+ </span>
163
+ </div>
164
+ )}
152
165
 
153
166
  {/* File Modifications List */}
154
167
  <div className="space-y-2 max-h-80 overflow-y-auto">
@@ -172,29 +185,31 @@ export function ApplyFirstPreview({
172
185
 
173
186
  {/* Action Buttons */}
174
187
  <div className="flex gap-2">
175
- {/* Accept Button */}
176
- <button
177
- onClick={onAccept}
178
- disabled={isLoading}
179
- className={cn(
180
- "flex-1 flex items-center justify-center gap-2 py-2.5",
181
- "text-xs font-medium rounded transition-colors",
182
- "bg-green-600 text-white hover:bg-green-700",
183
- "disabled:opacity-50 disabled:cursor-not-allowed"
184
- )}
185
- >
186
- {status === "accepting" ? (
187
- <>
188
- <Loader2 className="h-3.5 w-3.5 animate-spin" />
189
- Accepting...
190
- </>
191
- ) : (
192
- <>
193
- <Check className="h-3.5 w-3.5" />
194
- Keep Changes
195
- </>
196
- )}
197
- </button>
188
+ {/* Accept Button - hide for stale sessions */}
189
+ {!isStaleSession && (
190
+ <button
191
+ onClick={onAccept}
192
+ disabled={isLoading}
193
+ className={cn(
194
+ "flex-1 flex items-center justify-center gap-2 py-2.5",
195
+ "text-xs font-medium rounded transition-colors",
196
+ "bg-green-600 text-white hover:bg-green-700",
197
+ "disabled:opacity-50 disabled:cursor-not-allowed"
198
+ )}
199
+ >
200
+ {status === "accepting" ? (
201
+ <>
202
+ <Loader2 className="h-3.5 w-3.5 animate-spin" />
203
+ Accepting...
204
+ </>
205
+ ) : (
206
+ <>
207
+ <Check className="h-3.5 w-3.5" />
208
+ Keep Changes
209
+ </>
210
+ )}
211
+ </button>
212
+ )}
198
213
 
199
214
  {/* Revert Button */}
200
215
  <button
@@ -219,6 +234,23 @@ export function ApplyFirstPreview({
219
234
  </>
220
235
  )}
221
236
  </button>
237
+
238
+ {/* Force Clear Button - show for stale sessions or errors */}
239
+ {isStaleSession && onForceClear && (
240
+ <button
241
+ onClick={onForceClear}
242
+ disabled={isLoading}
243
+ className={cn(
244
+ "flex-1 flex items-center justify-center gap-2 py-2.5",
245
+ "text-xs font-medium rounded transition-colors",
246
+ "border border-red-300 text-red-700 bg-red-50 hover:bg-red-100",
247
+ "disabled:opacity-50 disabled:cursor-not-allowed"
248
+ )}
249
+ >
250
+ <X className="h-3.5 w-3.5" />
251
+ Force Clear
252
+ </button>
253
+ )}
222
254
  </div>
223
255
 
224
256
  {/* Session Info (for debugging) */}
@@ -56,6 +56,7 @@ export interface ComponentsPanelProps {
56
56
  onApplyFirstComplete?: (session: ApplyFirstSession) => void;
57
57
  onApplyFirstAccept?: () => void;
58
58
  onApplyFirstRevert?: () => void;
59
+ onApplyFirstForceClear?: () => void;
59
60
  }
60
61
 
61
62
  export function ComponentsPanel({
@@ -95,6 +96,7 @@ export function ComponentsPanel({
95
96
  onApplyFirstComplete,
96
97
  onApplyFirstAccept,
97
98
  onApplyFirstRevert,
99
+ onApplyFirstForceClear,
98
100
  }: ComponentsPanelProps) {
99
101
  // Auto-activate inspector when entering this tab
100
102
  useEffect(() => {
@@ -578,6 +580,7 @@ export function ComponentsPanel({
578
580
  status={applyFirstStatus}
579
581
  onAccept={onApplyFirstAccept}
580
582
  onRevert={onApplyFirstRevert}
583
+ onForceClear={onApplyFirstForceClear}
581
584
  />
582
585
  )}
583
586
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sonance-brand-mcp",
3
- "version": "1.3.49",
3
+ "version": "1.3.50",
4
4
  "description": "MCP Server for Sonance Brand Guidelines and Component Library - gives Claude instant access to brand colors, typography, and UI components.",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",