@widgetic/creator 0.4.42 → 0.4.44
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/CreatorApp.svelte +507 -71
- package/dist/CreatorApp.svelte.d.ts +1 -0
- package/dist/components/BrandKitPanel.svelte.d.ts +1 -1
- package/dist/components/EmbeddedSketchViewportShell.svelte +49 -0
- package/dist/components/EmbeddedSketchViewportShell.svelte.d.ts +13 -0
- package/dist/components/WidgetDetails.svelte +40 -13
- package/dist/components/WidgetDetails.svelte.d.ts +4 -0
- package/dist/creator-types.d.ts +5 -0
- package/dist/embeddedSketchLayout.d.ts +9 -0
- package/dist/embeddedSketchLayout.js +17 -0
- package/dist/errors/toUserFriendlyError.d.ts +44 -0
- package/dist/errors/toUserFriendlyError.js +236 -0
- package/dist/i18n/language.d.ts +19 -8
- package/dist/i18n/messages.d.ts +10 -2
- package/dist/i18n/messages.js +11 -2
- package/dist/i18n/statusText.d.ts +8 -3
- package/dist/i18n/statusText.js +48 -12
- package/dist/pageHelpers.d.ts +9 -3
- package/dist/pageHelpers.js +37 -15
- package/dist/sketchBoardVisibility.d.ts +17 -0
- package/dist/sketchBoardVisibility.js +22 -0
- package/dist/sketchChatDraftPrefill.d.ts +25 -0
- package/dist/sketchChatDraftPrefill.js +82 -0
- package/dist/utils/codegenStatusTails.d.ts +23 -0
- package/dist/utils/codegenStatusTails.js +77 -0
- package/package.json +1 -1
package/dist/CreatorApp.svelte
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
* COMPONENTS IMPORTS from WIDGETIC DS
|
|
9
9
|
*/
|
|
10
10
|
import { Button, DropdownMenu, PasswordInput, showToast, Dialog, GenerateLoader, Portal } from '@widgetic/design-system/components';
|
|
11
|
+
import type { EmbeddedSketchMobileTab } from './embeddedSketchLayout.js';
|
|
12
|
+
import EmbeddedSketchViewportShell from './components/EmbeddedSketchViewportShell.svelte';
|
|
11
13
|
import { LogoWidgeticType } from '@widgetic/design-system/icons';
|
|
12
14
|
|
|
13
15
|
/**
|
|
@@ -39,6 +41,11 @@
|
|
|
39
41
|
import type { SelectedWidgetElementReference } from './utils/widgetElementSelector.js';
|
|
40
42
|
import BrandKitPanel from './components/BrandKitPanel.svelte';
|
|
41
43
|
import { brandKitForRequest } from './generation/brandKitForRequest.js';
|
|
44
|
+
import {
|
|
45
|
+
shouldHideSketchOnBoard,
|
|
46
|
+
sketchCanvasJsonWithinPersistLimit,
|
|
47
|
+
widgetPanelIndicatesBuiltArtifact,
|
|
48
|
+
} from './sketchBoardVisibility.js';
|
|
42
49
|
|
|
43
50
|
/**
|
|
44
51
|
* Idempotency middleware (Phase 2 hardening): the gateway rejects
|
|
@@ -150,6 +157,7 @@
|
|
|
150
157
|
import {
|
|
151
158
|
normalizeErrorMessage,
|
|
152
159
|
codegenFailureChatLine,
|
|
160
|
+
friendlyTextFromStoredError,
|
|
153
161
|
toErrorMessage,
|
|
154
162
|
deriveApiErrorMessage,
|
|
155
163
|
extractDetailsMessage,
|
|
@@ -160,6 +168,7 @@
|
|
|
160
168
|
sanitizePreviewBuildError,
|
|
161
169
|
isInfrastructurePreviewError
|
|
162
170
|
} from './pageHelpers.js';
|
|
171
|
+
import { CANVAS_LOAD_ERROR_DISPLAY, CODEGEN_ERROR_DISPLAY } from './errors/toUserFriendlyError.js';
|
|
163
172
|
import {
|
|
164
173
|
ChatUploadRefusedError,
|
|
165
174
|
shouldUseTusForChatUpload,
|
|
@@ -202,6 +211,18 @@
|
|
|
202
211
|
type VersionRating
|
|
203
212
|
} from './utils/versionRatings.js';
|
|
204
213
|
import { generationVersionAndDocumentFields } from './utils/generationRequestFields.js';
|
|
214
|
+
import {
|
|
215
|
+
readGenerationStreamTail,
|
|
216
|
+
readPlanFromMetadata,
|
|
217
|
+
readThinkingTail,
|
|
218
|
+
type GenerationPlanWire,
|
|
219
|
+
} from './utils/codegenStatusTails.js';
|
|
220
|
+
import {
|
|
221
|
+
countDrawnCanvasObjectsInJson,
|
|
222
|
+
decideSketchDraftPrefill,
|
|
223
|
+
resolveSketchGenerateCodePrompt,
|
|
224
|
+
shouldScanBoardForSketchPrefill,
|
|
225
|
+
} from './sketchChatDraftPrefill.js';
|
|
205
226
|
import {
|
|
206
227
|
generationRefusalText,
|
|
207
228
|
headCommitForComparison,
|
|
@@ -325,6 +346,7 @@
|
|
|
325
346
|
export let onLimitReached: CreatorAppProps['onLimitReached'] = undefined;
|
|
326
347
|
export let onCanvasUnavailable: CreatorAppProps['onCanvasUnavailable'] = undefined;
|
|
327
348
|
export let onCanvasChanged: CreatorAppProps['onCanvasChanged'] = undefined;
|
|
349
|
+
export let replaceAddressBarUrl: CreatorAppProps['replaceAddressBarUrl'] = undefined;
|
|
328
350
|
export let onReady: CreatorAppProps['onReady'] = undefined;
|
|
329
351
|
/** Partner library for chat/canvas uploads (see `CreatorAppProps.mediaLibrary`). */
|
|
330
352
|
export let mediaLibrary: CreatorAppProps['mediaLibrary'] = undefined;
|
|
@@ -465,7 +487,12 @@
|
|
|
465
487
|
url.searchParams.delete('canvas-id');
|
|
466
488
|
url.searchParams.delete('widget_id');
|
|
467
489
|
url.searchParams.delete('new_widget');
|
|
468
|
-
|
|
490
|
+
const href = url.toString();
|
|
491
|
+
if (replaceAddressBarUrl) {
|
|
492
|
+
replaceAddressBarUrl(href);
|
|
493
|
+
} else {
|
|
494
|
+
window.history.replaceState(window.history.state, '', href);
|
|
495
|
+
}
|
|
469
496
|
// console.log('[CreatorApp] URL synced to canvas:', canvasIdToSync);
|
|
470
497
|
} catch (err) {
|
|
471
498
|
console.warn('[CreatorApp] Failed to sync canvas URL:', err);
|
|
@@ -1346,6 +1373,15 @@
|
|
|
1346
1373
|
emitCanvasWidgetsList('linked-ids');
|
|
1347
1374
|
}
|
|
1348
1375
|
|
|
1376
|
+
/**
|
|
1377
|
+
* Where the layers of the creator's own confirm dialogs start (`layerBase` of `Dialog.Content`). The design system stacks
|
|
1378
|
+
* dialogs from z 50, and the creator draws its floating panels at z 2003 (`floating-panels-overlay`): a confirm dialog has to
|
|
1379
|
+
* start above that, or the panels would be drawn over it and a click would go through to them. It used to be a global
|
|
1380
|
+
* `[data-dialog-overlay] { z-index: 9998 !important }`, which also lifted the scrim of every dialog of the dashboard above
|
|
1381
|
+
* its panel (see src/lib/dialogLayering.test.ts); this is the same wish, asked of the one dialog that needs it.
|
|
1382
|
+
*/
|
|
1383
|
+
const creatorDialogLayerBase = 2300;
|
|
1384
|
+
|
|
1349
1385
|
// Delete Widget Shape confirmation dialog state
|
|
1350
1386
|
let deleteDialogOpen = false;
|
|
1351
1387
|
let deleteDialogWidgetName = '';
|
|
@@ -1506,6 +1542,8 @@
|
|
|
1506
1542
|
const publishRevealTimers = new Map<string, ReturnType<typeof setTimeout>>();
|
|
1507
1543
|
/** Last slice of the model stream, per widget. Painted with the status throttle, not per token. */
|
|
1508
1544
|
let generationStreamByWidgetId: Record<string, string> = {};
|
|
1545
|
+
let generationThinkingByWidgetId: Record<string, string> = {};
|
|
1546
|
+
let generationPlanByWidgetId: Record<string, GenerationPlanWire> = {};
|
|
1509
1547
|
function isAnyWidgetGenerating(): boolean {
|
|
1510
1548
|
return isGeneratingCode || Object.keys(generatingWidgetIds).some((id) => generatingWidgetIds[id]);
|
|
1511
1549
|
}
|
|
@@ -1601,6 +1639,40 @@
|
|
|
1601
1639
|
/** Fabric JSON of the board, kept so the first checkpoint can put the sketch back. */
|
|
1602
1640
|
const draftConvertSketchJson = new Map<string, string>();
|
|
1603
1641
|
const sketchSnapshotsByWidgetId = new Map<string, string>();
|
|
1642
|
+
|
|
1643
|
+
function widgetBuiltForSketchHiding(widgetId: string): boolean {
|
|
1644
|
+
if (isDraftConvertId(widgetId)) return false;
|
|
1645
|
+
return widgetPanelIndicatesBuiltArtifact(getPanelState(widgetId));
|
|
1646
|
+
}
|
|
1647
|
+
|
|
1648
|
+
function rememberSketchSnapshotForWidget(widgetId: string, json: string | null | undefined): void {
|
|
1649
|
+
if (!widgetId || !sketchCanvasJsonWithinPersistLimit(json)) return;
|
|
1650
|
+
if (!sketchSnapshotsByWidgetId.has(widgetId)) {
|
|
1651
|
+
sketchSnapshotsByWidgetId.set(widgetId, json);
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
|
|
1655
|
+
/** Simple canvas: stash the sketch for restore, then show only the widget shape on the board. */
|
|
1656
|
+
function hideSketchOnBoardForWidget(widgetId: string): void {
|
|
1657
|
+
if (!shouldHideSketchOnBoard({
|
|
1658
|
+
embedded,
|
|
1659
|
+
advancedFeatures: canvasAdvancedFeatures,
|
|
1660
|
+
isDraftConvertId: isDraftConvertId(widgetId),
|
|
1661
|
+
widgetHasBuiltArtifact: widgetBuiltForSketchHiding(widgetId),
|
|
1662
|
+
})) return;
|
|
1663
|
+
if (!canvasRef) return;
|
|
1664
|
+
const board = canvasRef.saveCanvas?.() ?? null;
|
|
1665
|
+
rememberSketchSnapshotForWidget(widgetId, board);
|
|
1666
|
+
const pruner = canvasRef as typeof canvasRef & {
|
|
1667
|
+
removeSketchObjectsKeepingWidget?: (id: string) => number;
|
|
1668
|
+
};
|
|
1669
|
+
const removed = pruner.removeSketchObjectsKeepingWidget?.(widgetId) ?? 0;
|
|
1670
|
+
if (removed > 0) {
|
|
1671
|
+
canvasRef.saveNow?.();
|
|
1672
|
+
syncWidgetShapeLivePreviews();
|
|
1673
|
+
console.log('[CreatorApp] Sketch hidden on board after build', widgetId.substring(0, 8), removed);
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1604
1676
|
/** True while a draft conversion is being finalized (widget creation + shape replace). */
|
|
1605
1677
|
const finalizingDraftConversions = new Set<string>();
|
|
1606
1678
|
/** Keep Widget Details on this convert/draft widget until the user closes the panel. */
|
|
@@ -1644,6 +1716,16 @@
|
|
|
1644
1716
|
let promptLoadedForWidgetId: string | null = null;
|
|
1645
1717
|
/** Skip draft→prompt sync while restoring chat draft (avoids clearing promptImages). */
|
|
1646
1718
|
let suppressChatDraftSync = false;
|
|
1719
|
+
/** Sketch prefill: applied once per sketch session until the canvas clears or the user edits the draft. */
|
|
1720
|
+
let sketchPrefillApplied = false;
|
|
1721
|
+
/** Visitor-drawn shapes only (widget shapes on the board do not count). */
|
|
1722
|
+
let lastDrawnObjectCount = 0;
|
|
1723
|
+
/** Set when a prefill apply was decided before the panel Chat exposed setDraftText. */
|
|
1724
|
+
let pendingSketchGeneratePrefill = false;
|
|
1725
|
+
/** The one pending look at the board after the canvas went dirty (see `scheduleSketchPrefillFromCanvasDirty`). */
|
|
1726
|
+
let sketchPrefillDirtyTimer: ReturnType<typeof setTimeout> | null = null;
|
|
1727
|
+
/** A short delay: it coalesces a burst of dirty events into one look, and is still well ahead of the debounced autosave. */
|
|
1728
|
+
const SKETCH_PREFILL_DIRTY_DELAY_MS = 120;
|
|
1647
1729
|
|
|
1648
1730
|
// Current active conversation ID for the selected widget's chat.
|
|
1649
1731
|
// Populated via Chat's onConversationChange callback and passed to generateCode()
|
|
@@ -1917,12 +1999,21 @@
|
|
|
1917
1999
|
// picking up the line on the canvas instead of the widget.
|
|
1918
2000
|
if (!widgetAlreadyBuilt && embedded && !canvasAdvancedFeatures && sketchCanvas?.captureCanvasSketch) {
|
|
1919
2001
|
try {
|
|
2002
|
+
const sketchJsonBeforeSend = sketchCanvas.saveCanvas?.() ?? '';
|
|
2003
|
+
rememberSketchSnapshotForWidget(widgetId, sketchJsonBeforeSend);
|
|
1920
2004
|
const canvasSketch = await sketchCanvas.captureCanvasSketch();
|
|
1921
2005
|
if (canvasSketch?.startsWith('data:image/')) {
|
|
1922
2006
|
if (isDraftConvertId(widgetId)) {
|
|
1923
2007
|
draftConvertScreenshots.set(widgetId, canvasSketch);
|
|
1924
|
-
|
|
1925
|
-
|
|
2008
|
+
if (sketchJsonBeforeSend) draftConvertSketchJson.set(widgetId, sketchJsonBeforeSend);
|
|
2009
|
+
} else if (sketchCanvas.absorbCanvasSketchIntoWidget) {
|
|
2010
|
+
try {
|
|
2011
|
+
await sketchCanvas.absorbCanvasSketchIntoWidget(widgetId, canvasSketch);
|
|
2012
|
+
sketchCanvas.saveNow?.();
|
|
2013
|
+
syncWidgetShapeLivePreviews();
|
|
2014
|
+
} catch (absorbErr) {
|
|
2015
|
+
console.warn('[Chat→Sketch] Could not absorb sketch into widget shape', absorbErr);
|
|
2016
|
+
}
|
|
1926
2017
|
}
|
|
1927
2018
|
const alreadyHasImage = (attachments || []).some((attachment) =>
|
|
1928
2019
|
attachment.fileType?.startsWith('image/')
|
|
@@ -2157,7 +2248,7 @@
|
|
|
2157
2248
|
|
|
2158
2249
|
function pushCodegenFailureToChat(widgetId: string, errorText: string) {
|
|
2159
2250
|
const panelChat = getChatMethodsForWidget(widgetId);
|
|
2160
|
-
const content = codegenFailureChatLine(errorText);
|
|
2251
|
+
const content = codegenFailureChatLine(errorText, codegenErrorDisplay);
|
|
2161
2252
|
panelChat?.addAssistantMessage?.(content);
|
|
2162
2253
|
// console.log('[Chat] Codegen failure bubble:', content.slice(0, 160));
|
|
2163
2254
|
}
|
|
@@ -2167,7 +2258,7 @@
|
|
|
2167
2258
|
return /(?:Commit:?\s+|Code saved\s*\()[a-f0-9]{7,40}/i.test(String(content || ''));
|
|
2168
2259
|
}
|
|
2169
2260
|
|
|
2170
|
-
/** Retry failed codegen without duplicating the user bubble. A successful prompt forks a new message so each version
|
|
2261
|
+
/** Retry failed codegen without duplicating the user bubble. A successful prompt forks a new message so each version has its own turn. */
|
|
2171
2262
|
async function handleChatRetryMessage(content: string, sourceWidgetId?: string) {
|
|
2172
2263
|
const widgetId = sourceWidgetId ?? selectedWidgetId;
|
|
2173
2264
|
if (!widgetId) return;
|
|
@@ -2186,7 +2277,7 @@
|
|
|
2186
2277
|
const draftImageUrls = panelChat?.getAttachmentDataUrls?.() ?? [];
|
|
2187
2278
|
|
|
2188
2279
|
// A prompt that already has a commit must not reuse that bubble: Version N and
|
|
2189
|
-
// Version N+1 would share one message, and
|
|
2280
|
+
// Version N+1 would share one message, and the older version would have no turn of its own.
|
|
2190
2281
|
// The pictures of that sentence go with the retry, including when an earlier
|
|
2191
2282
|
// copy of the same sentence is the one that still has them.
|
|
2192
2283
|
let forkUserMessage = false;
|
|
@@ -2440,6 +2531,115 @@
|
|
|
2440
2531
|
}
|
|
2441
2532
|
}
|
|
2442
2533
|
|
|
2534
|
+
function sketchPrefillTargetWidgetId(widgetId?: string | null): string | null {
|
|
2535
|
+
return (
|
|
2536
|
+
widgetId ??
|
|
2537
|
+
focusedPanelWidgetId ??
|
|
2538
|
+
(canvasPrimaryWidgetId && !isDraftConvertId(canvasPrimaryWidgetId) ? canvasPrimaryWidgetId : null) ??
|
|
2539
|
+
(embedded && !canvasAdvancedFeatures ? CANVAS_SKETCH_DRAFT_ID : null) ??
|
|
2540
|
+
selectedWidgetId ??
|
|
2541
|
+
null
|
|
2542
|
+
);
|
|
2543
|
+
}
|
|
2544
|
+
|
|
2545
|
+
function sketchPrefillWidgetBuilt(targetWidgetId: string): boolean {
|
|
2546
|
+
if (!isDraftConvertId(targetWidgetId) && targetWidgetId === canvasPrimaryWidgetId) {
|
|
2547
|
+
return primaryWidgetHasGeneratedCode();
|
|
2548
|
+
}
|
|
2549
|
+
if (isDraftConvertId(targetWidgetId)) return false;
|
|
2550
|
+
const panel = getPanelState(targetWidgetId);
|
|
2551
|
+
return !!(panel.lastCommitId || panel.hasGeneratedCode || panel.lastPublishedVersion != null);
|
|
2552
|
+
}
|
|
2553
|
+
|
|
2554
|
+
/** Convert-to-widget owns the draft with CONVERT_PROMPT — never compete with generate-code prefill. */
|
|
2555
|
+
function sketchConvertDraftActive(targetWidgetId: string): boolean {
|
|
2556
|
+
if (promptLoadedForWidgetId === targetWidgetId && pendingChatDraftText === CONVERT_PROMPT) return true;
|
|
2557
|
+
if (codeGenerationPrompt === CONVERT_PROMPT && focusedPanelWidgetId === targetWidgetId) return true;
|
|
2558
|
+
return false;
|
|
2559
|
+
}
|
|
2560
|
+
|
|
2561
|
+
function noteDrawnObjectCount(drawnObjectCount: number) {
|
|
2562
|
+
if (lastDrawnObjectCount === 0 && drawnObjectCount > 0) {
|
|
2563
|
+
sketchPrefillApplied = false;
|
|
2564
|
+
}
|
|
2565
|
+
lastDrawnObjectCount = drawnObjectCount;
|
|
2566
|
+
}
|
|
2567
|
+
|
|
2568
|
+
/**
|
|
2569
|
+
* Faster than waiting for the debounced autosave, for ONE moment only: the first drawn object. A short coalescing timer (one look per
|
|
2570
|
+
* burst of dirty events, never one per event) reads the serialized board (the canvas has no "drawn objects only" count yet), and only
|
|
2571
|
+
* while no drawing is known and the widget is not built (`shouldScanBoardForSketchPrefill`), so drawing or dragging on a busy board
|
|
2572
|
+
* never costs a serialization per event. The autosave stays the source of truth for everything after (a cleared board, a typed draft).
|
|
2573
|
+
*/
|
|
2574
|
+
function scheduleSketchPrefillFromCanvasDirty() {
|
|
2575
|
+
if (!embedded || canvasAdvancedFeatures || !canvasRef?.saveCanvas) return;
|
|
2576
|
+
if (sketchPrefillDirtyTimer != null) return;
|
|
2577
|
+
if (!shouldScanBoardForSketchPrefill({ lastDrawnObjectCount, widgetBuilt: sketchPrefillWidgetBuiltNow() })) return;
|
|
2578
|
+
sketchPrefillDirtyTimer = setTimeout(() => {
|
|
2579
|
+
sketchPrefillDirtyTimer = null;
|
|
2580
|
+
try {
|
|
2581
|
+
if (!shouldScanBoardForSketchPrefill({ lastDrawnObjectCount, widgetBuilt: sketchPrefillWidgetBuiltNow() })) return;
|
|
2582
|
+
const json = canvasRef?.saveCanvas?.();
|
|
2583
|
+
const drawn = countDrawnCanvasObjectsInJson(json);
|
|
2584
|
+
if (drawn === lastDrawnObjectCount) return;
|
|
2585
|
+
noteDrawnObjectCount(drawn);
|
|
2586
|
+
maybeSyncSketchGeneratePrefill();
|
|
2587
|
+
} catch (error) {
|
|
2588
|
+
console.warn('[CreatorApp] Sketch prefill dirty check failed', error);
|
|
2589
|
+
}
|
|
2590
|
+
}, SKETCH_PREFILL_DIRTY_DELAY_MS);
|
|
2591
|
+
}
|
|
2592
|
+
|
|
2593
|
+
/** True once the widget the prefill would be for has generated code (the prefill never applies after that). */
|
|
2594
|
+
function sketchPrefillWidgetBuiltNow(): boolean {
|
|
2595
|
+
const targetWidgetId = sketchPrefillTargetWidgetId();
|
|
2596
|
+
return targetWidgetId ? sketchPrefillWidgetBuilt(targetWidgetId) : false;
|
|
2597
|
+
}
|
|
2598
|
+
|
|
2599
|
+
function maybeSyncSketchGeneratePrefill(widgetId?: string | null) {
|
|
2600
|
+
if (!embedded || canvasAdvancedFeatures) return;
|
|
2601
|
+
const targetWidgetId = sketchPrefillTargetWidgetId(widgetId);
|
|
2602
|
+
if (!targetWidgetId) return;
|
|
2603
|
+
if (sketchConvertDraftActive(targetWidgetId)) {
|
|
2604
|
+
pendingSketchGeneratePrefill = false;
|
|
2605
|
+
return;
|
|
2606
|
+
}
|
|
2607
|
+
const widgetBuilt = sketchPrefillWidgetBuilt(targetWidgetId);
|
|
2608
|
+
const prefillMessage = resolveSketchGenerateCodePrompt(locale, chatMessages);
|
|
2609
|
+
const chat = getChatMethodsForWidget(targetWidgetId);
|
|
2610
|
+
const draft = chat?.getDraftText?.() ?? '';
|
|
2611
|
+
const action = decideSketchDraftPrefill({
|
|
2612
|
+
drawnObjectCount: lastDrawnObjectCount,
|
|
2613
|
+
widgetBuilt,
|
|
2614
|
+
draft,
|
|
2615
|
+
prefillMessage,
|
|
2616
|
+
prefillAppliedForSketch: sketchPrefillApplied,
|
|
2617
|
+
});
|
|
2618
|
+
if (action === 'none') {
|
|
2619
|
+
if (pendingSketchGeneratePrefill && (widgetBuilt || lastDrawnObjectCount <= 0)) {
|
|
2620
|
+
pendingSketchGeneratePrefill = false;
|
|
2621
|
+
}
|
|
2622
|
+
return;
|
|
2623
|
+
}
|
|
2624
|
+
if (!chat?.getDraftText || !chat.setDraftText) {
|
|
2625
|
+
if (action === 'apply') pendingSketchGeneratePrefill = true;
|
|
2626
|
+
return;
|
|
2627
|
+
}
|
|
2628
|
+
pendingSketchGeneratePrefill = false;
|
|
2629
|
+
suppressChatDraftSync = true;
|
|
2630
|
+
try {
|
|
2631
|
+
if (action === 'apply') {
|
|
2632
|
+
chat.setDraftText(prefillMessage);
|
|
2633
|
+
sketchPrefillApplied = true;
|
|
2634
|
+
} else if (action === 'clear') {
|
|
2635
|
+
chat.setDraftText('');
|
|
2636
|
+
sketchPrefillApplied = false;
|
|
2637
|
+
}
|
|
2638
|
+
} finally {
|
|
2639
|
+
suppressChatDraftSync = false;
|
|
2640
|
+
}
|
|
2641
|
+
}
|
|
2642
|
+
|
|
2443
2643
|
function handleChatDraftChange(sourceWidgetId?: string) {
|
|
2444
2644
|
const widgetId = sourceWidgetId ?? selectedWidgetId;
|
|
2445
2645
|
if (suppressChatDraftSync || !widgetId) return;
|
|
@@ -2709,7 +2909,7 @@
|
|
|
2709
2909
|
display_order: att.display_order ?? i + 1,
|
|
2710
2910
|
}));
|
|
2711
2911
|
if (compressedPersistImages.length === 0 && persistFileItems.length === 0) {
|
|
2712
|
-
console.
|
|
2912
|
+
console.debug('[Codegen] Persist user message has no attachment URLs for widget', widgetId?.substring(0, 8));
|
|
2713
2913
|
}
|
|
2714
2914
|
const fileHasImage = persistFileItems.some((att) => {
|
|
2715
2915
|
const type = String(att.file_type || '');
|
|
@@ -6138,6 +6338,11 @@
|
|
|
6138
6338
|
|
|
6139
6339
|
// debugMode — current ON/OFF state. User can still toggle when the UI is available.
|
|
6140
6340
|
let debugMode = debugModeAvailable;
|
|
6341
|
+
$: codegenErrorDisplay = { debugMode, ...CODEGEN_ERROR_DISPLAY };
|
|
6342
|
+
$: canvasLoadErrorDisplay = { debugMode, ...CANVAS_LOAD_ERROR_DISPLAY };
|
|
6343
|
+
/** Mobile embedded sketch: Canvas | Chat tabs (both panes stay mounted; CSS hides the inactive one). */
|
|
6344
|
+
let embeddedSketchMobileTab: EmbeddedSketchMobileTab = 'canvas';
|
|
6345
|
+
$: embeddedSketchShell = embedded && !canvasAdvancedFeatures;
|
|
6141
6346
|
if (debugModeAvailable && typeof window !== 'undefined') {
|
|
6142
6347
|
try {
|
|
6143
6348
|
const storedDebugMode = creatorStorage.getItem('widgetic:site-debug-on');
|
|
@@ -6359,6 +6564,45 @@
|
|
|
6359
6564
|
*/
|
|
6360
6565
|
let singleWidgetChromeReady = false;
|
|
6361
6566
|
|
|
6567
|
+
/**
|
|
6568
|
+
* Lets the bottom bars appear once the canvas component is up and the canvas has been read.
|
|
6569
|
+
* `handleCanvasReady` does it for a canvas whose id was already known when the canvas component came up.
|
|
6570
|
+
* A canvas whose id is resolved afterwards (the person's latest canvas, the one remembered from the last
|
|
6571
|
+
* visit, or the blank one made for a person who has none) is read or made by other code, so that ends here
|
|
6572
|
+
* too: without it neither bar ever appeared on such a canvas, and the person had no tools and no selector.
|
|
6573
|
+
*/
|
|
6574
|
+
function releaseSingleWidgetChrome(): void {
|
|
6575
|
+
if (singleWidgetChromeReady || !canvasComponentReady || !isCanvasStateLoaded) return;
|
|
6576
|
+
singleWidgetChromeReady = true;
|
|
6577
|
+
console.log('[CreatorApp] Bottom bars released after the canvas was read', { canvasId, primaryId: canvasPrimaryWidgetId });
|
|
6578
|
+
}
|
|
6579
|
+
|
|
6580
|
+
// Whichever code made the canvas known, a canvas that is up, read, and has its primary widget gets its bar.
|
|
6581
|
+
$: if (!singleWidgetChromeReady && canvasComponentReady && isCanvasStateLoaded && !!(canvasPrimaryWidgetId || '').trim()) {
|
|
6582
|
+
releaseSingleWidgetChrome();
|
|
6583
|
+
}
|
|
6584
|
+
|
|
6585
|
+
/**
|
|
6586
|
+
* A net under all of the above: no way of loading a canvas may leave the person without bars for good.
|
|
6587
|
+
* Once the canvas is up and read, the bars come at the latest after this wait, even if none of the places that
|
|
6588
|
+
* release them ran. The person may then see the drawing tools first and the selector a moment later, as every
|
|
6589
|
+
* version before the bars waited for the widget showed them.
|
|
6590
|
+
*/
|
|
6591
|
+
const SINGLE_WIDGET_CHROME_FAILSAFE_MS = 2500;
|
|
6592
|
+
let singleWidgetChromeFailsafeTimer: ReturnType<typeof setTimeout> | null = null;
|
|
6593
|
+
|
|
6594
|
+
function armSingleWidgetChromeFailsafe(): void {
|
|
6595
|
+
if (singleWidgetChromeFailsafeTimer) return;
|
|
6596
|
+
singleWidgetChromeFailsafeTimer = setTimeout(() => {
|
|
6597
|
+
singleWidgetChromeFailsafeTimer = null;
|
|
6598
|
+
if (singleWidgetChromeReady) return;
|
|
6599
|
+
console.warn('[CreatorApp] Bottom bars released by the failsafe: no step of loading the canvas released them');
|
|
6600
|
+
releaseSingleWidgetChrome();
|
|
6601
|
+
}, SINGLE_WIDGET_CHROME_FAILSAFE_MS);
|
|
6602
|
+
}
|
|
6603
|
+
|
|
6604
|
+
$: if (!singleWidgetChromeReady && canvasComponentReady && isCanvasStateLoaded) armSingleWidgetChromeFailsafe();
|
|
6605
|
+
|
|
6362
6606
|
function primaryWidgetHasGeneratedCode(): boolean {
|
|
6363
6607
|
if (!canvasPrimaryWidgetId || isDraftConvertId(canvasPrimaryWidgetId)) return false;
|
|
6364
6608
|
const panel = getPanelState(canvasPrimaryWidgetId);
|
|
@@ -7021,6 +7265,9 @@
|
|
|
7021
7265
|
followedGenerationWidgetIds.add(widgetId);
|
|
7022
7266
|
generationOperationByWidgetId.set(widgetId, operationId);
|
|
7023
7267
|
generatingWidgetIds = { ...generatingWidgetIds, [widgetId]: true };
|
|
7268
|
+
clearGenerationStream(widgetId);
|
|
7269
|
+
clearGenerationThinking(widgetId);
|
|
7270
|
+
clearGenerationPlan(widgetId);
|
|
7024
7271
|
noteCodegenActive(true);
|
|
7025
7272
|
let endedOperation: OperationSnapshot | null = null;
|
|
7026
7273
|
try {
|
|
@@ -7118,13 +7365,16 @@
|
|
|
7118
7365
|
|
|
7119
7366
|
if (operation.status === 'failed') {
|
|
7120
7367
|
if (!announce) return;
|
|
7121
|
-
const
|
|
7368
|
+
const rawFailureText = operation.error || 'Unknown error';
|
|
7369
|
+
const failureText = friendlyTextFromStoredError(rawFailureText, codegenErrorDisplay);
|
|
7122
7370
|
patchCodegenUiState(widgetId, {
|
|
7123
7371
|
generateCodeStatus: '❌ Code generation failed',
|
|
7124
7372
|
lastGenerationFailed: true,
|
|
7125
7373
|
lastGenerationError: failureText,
|
|
7126
7374
|
});
|
|
7127
|
-
panelChat?.updateLatestCodegenStatusMessage?.(
|
|
7375
|
+
panelChat?.updateLatestCodegenStatusMessage?.(
|
|
7376
|
+
codegenFailureChatLine(rawFailureText, codegenErrorDisplay),
|
|
7377
|
+
);
|
|
7128
7378
|
showToast('error', $t('creator.status.failed'), { description: failureText, duration: 8000 });
|
|
7129
7379
|
// What the other tab saved of the failure reaches this tab's conversation
|
|
7130
7380
|
setTimeout(() => {
|
|
@@ -7593,6 +7843,7 @@
|
|
|
7593
7843
|
setTimeout(() => applyPrimarySelectionOnCanvas(primaryId), 80);
|
|
7594
7844
|
});
|
|
7595
7845
|
}
|
|
7846
|
+
releaseSingleWidgetChrome();
|
|
7596
7847
|
return;
|
|
7597
7848
|
}
|
|
7598
7849
|
}
|
|
@@ -7619,6 +7870,7 @@
|
|
|
7619
7870
|
setTimeout(() => applyPrimarySelectionOnCanvas(primaryId), 80);
|
|
7620
7871
|
});
|
|
7621
7872
|
}
|
|
7873
|
+
releaseSingleWidgetChrome();
|
|
7622
7874
|
} catch (error) {
|
|
7623
7875
|
console.error('Widget Creator: Load canvases error:', error);
|
|
7624
7876
|
const defaultError = $t('creator.canvas.failedToLoadCanvases');
|
|
@@ -8032,6 +8284,8 @@
|
|
|
8032
8284
|
canvasRef?.onClearAllObjects();
|
|
8033
8285
|
lastSavedCanvasObjectCount = 0;
|
|
8034
8286
|
markCanvasStateLoaded();
|
|
8287
|
+
// The canvas is empty: no widget to wait for.
|
|
8288
|
+
releaseSingleWidgetChrome();
|
|
8035
8289
|
// console.log('[WidgetCreator] New canvas ready:', createdId);
|
|
8036
8290
|
return createdId;
|
|
8037
8291
|
}
|
|
@@ -8071,6 +8325,8 @@
|
|
|
8071
8325
|
} finally {
|
|
8072
8326
|
markCanvasStateLoaded();
|
|
8073
8327
|
isLoadingWidgets = false;
|
|
8328
|
+
// A blank canvas has no widget to wait for: the person gets the drawing tools.
|
|
8329
|
+
releaseSingleWidgetChrome();
|
|
8074
8330
|
}
|
|
8075
8331
|
})();
|
|
8076
8332
|
return blankCanvasEnsurePromise;
|
|
@@ -8081,6 +8337,7 @@
|
|
|
8081
8337
|
// console.log('[CreatorApp] bootstrapEmbeddedNewWidget already ran — skip');
|
|
8082
8338
|
isLoadingWidgets = false;
|
|
8083
8339
|
markCanvasStateLoaded();
|
|
8340
|
+
releaseSingleWidgetChrome();
|
|
8084
8341
|
return;
|
|
8085
8342
|
}
|
|
8086
8343
|
didForceCreateNewWidget = true;
|
|
@@ -8102,6 +8359,8 @@
|
|
|
8102
8359
|
lastSavedCanvasObjectCount = 0;
|
|
8103
8360
|
markCanvasStateLoaded();
|
|
8104
8361
|
isLoadingWidgets = false;
|
|
8362
|
+
// A new widget starts on an empty canvas: nothing to wait for, so the drawing tools come at once.
|
|
8363
|
+
releaseSingleWidgetChrome();
|
|
8105
8364
|
setTimeout(() => {
|
|
8106
8365
|
ignoreIncomingCanvasLoads = false;
|
|
8107
8366
|
// console.log('[CreatorApp] New-widget canvas lock released');
|
|
@@ -8889,7 +9148,11 @@
|
|
|
8889
9148
|
err
|
|
8890
9149
|
);
|
|
8891
9150
|
// Partner mode: the first read to be told "no such canvas" says so for the whole creator.
|
|
8892
|
-
if (saysCanvasIsMissing(err))
|
|
9151
|
+
if (saysCanvasIsMissing(err))
|
|
9152
|
+
declareCanvasUnavailable(
|
|
9153
|
+
targetCanvasId,
|
|
9154
|
+
toErrorMessage(err, 'Canvas not found', canvasLoadErrorDisplay),
|
|
9155
|
+
);
|
|
8893
9156
|
return null;
|
|
8894
9157
|
}
|
|
8895
9158
|
}
|
|
@@ -10332,6 +10595,9 @@
|
|
|
10332
10595
|
chatMethods = methods;
|
|
10333
10596
|
restoreChatDraftFromStorage();
|
|
10334
10597
|
}
|
|
10598
|
+
if (pendingSketchGeneratePrefill || (embedded && !canvasAdvancedFeatures)) {
|
|
10599
|
+
maybeSyncSketchGeneratePrefill(ownerWidgetId);
|
|
10600
|
+
}
|
|
10335
10601
|
// console.log('[Chat] Chat ready for widget', ownerWidgetId?.substring(0, 8), 'methods exposed');
|
|
10336
10602
|
|
|
10337
10603
|
// A console helper of Widgetic's own pages; a partner's page gets no globals from the creator.
|
|
@@ -11221,6 +11487,9 @@ Requirements:
|
|
|
11221
11487
|
generationOperationByWidgetId.delete(generationWidgetId);
|
|
11222
11488
|
|
|
11223
11489
|
generatingWidgetIds = { ...generatingWidgetIds, [generationWidgetId]: true };
|
|
11490
|
+
clearGenerationStream(generationWidgetId);
|
|
11491
|
+
clearGenerationThinking(generationWidgetId);
|
|
11492
|
+
clearGenerationPlan(generationWidgetId);
|
|
11224
11493
|
// The preview address does not change between builds. Without this, the next build
|
|
11225
11494
|
// is treated as the one already on the shape, and the shape keeps the previous document.
|
|
11226
11495
|
lastRunningPreviewKey = '';
|
|
@@ -11476,6 +11745,10 @@ Requirements:
|
|
|
11476
11745
|
});
|
|
11477
11746
|
// Stopped, or replaced, while the request was being prepared: no job is started for a run nobody waits for
|
|
11478
11747
|
if (signal.aborted) return;
|
|
11748
|
+
// PLAN UI (metadata.plan): do not send `clientCapabilities` here yet. Shopify/editor-session
|
|
11749
|
+
// `POST /agent/code/generate` rejects any body key outside `EDITOR_SESSION_CREATOR_WRITABLE_FIELDS.codeGenerate`
|
|
11750
|
+
// (`editorSessionSurfaces.ts`); `clientCapabilities` is not on that list until the gateway owner adds it.
|
|
11751
|
+
// Once it is listed and plan policy is switched on, add e.g. `clientCapabilities: { plan: true }` beside the fields below.
|
|
11479
11752
|
// The generated client types this call as void and drops the 202 body.
|
|
11480
11753
|
// Read the raw JSON so operationId and the intent-gate payload survive.
|
|
11481
11754
|
const accepted = await agentClient.generateCodeRaw({
|
|
@@ -11665,7 +11938,10 @@ Requirements:
|
|
|
11665
11938
|
const generateEnvelope = response as unknown as { error?: string; message?: string };
|
|
11666
11939
|
const generateErrorMessage = generateEnvelope && (generateEnvelope.error || generateEnvelope.message);
|
|
11667
11940
|
if (generateErrorMessage) {
|
|
11668
|
-
const normalizedMessage =
|
|
11941
|
+
const normalizedMessage = friendlyTextFromStoredError(
|
|
11942
|
+
normalizeErrorMessage(generateErrorMessage),
|
|
11943
|
+
codegenErrorDisplay,
|
|
11944
|
+
);
|
|
11669
11945
|
patchCodegenUiState(generationWidgetId, {
|
|
11670
11946
|
generateCodeStatus: `❌ Code generation failed: ${normalizedMessage}`,
|
|
11671
11947
|
lastGenerationFailed: true,
|
|
@@ -11756,7 +12032,8 @@ Requirements:
|
|
|
11756
12032
|
}
|
|
11757
12033
|
|
|
11758
12034
|
if (op.status === 'failed') {
|
|
11759
|
-
const
|
|
12035
|
+
const rawErrorMsg = op.error || 'Unknown error';
|
|
12036
|
+
const errorMsg = friendlyTextFromStoredError(rawErrorMsg, codegenErrorDisplay);
|
|
11760
12037
|
patchCodegenUiState(generationWidgetId, {
|
|
11761
12038
|
generateCodeStatus: '❌ Code generation failed',
|
|
11762
12039
|
lastGenerationFailed: true,
|
|
@@ -11764,18 +12041,21 @@ Requirements:
|
|
|
11764
12041
|
});
|
|
11765
12042
|
clearActiveOperationId(generationWidgetId);
|
|
11766
12043
|
|
|
11767
|
-
const isGitlabLimit = /gitlab rate limit|gitlab refused the (save|rollback)|last status code:\s*429/i.test(
|
|
11768
|
-
const isServiceError =
|
|
11769
|
-
|
|
11770
|
-
|
|
11771
|
-
|
|
11772
|
-
|
|
11773
|
-
|
|
11774
|
-
|
|
12044
|
+
const isGitlabLimit = /gitlab rate limit|gitlab refused the (save|rollback)|last status code:\s*429/i.test(rawErrorMsg);
|
|
12045
|
+
const isServiceError =
|
|
12046
|
+
isGitlabLimit ||
|
|
12047
|
+
rawErrorMsg.includes('temporarily unavailable') ||
|
|
12048
|
+
rawErrorMsg.includes('Our team has been notified') ||
|
|
12049
|
+
rawErrorMsg.includes('Too many generation requests');
|
|
12050
|
+
const isSvelteSyntaxError =
|
|
12051
|
+
rawErrorMsg.includes('Svelte') ||
|
|
12052
|
+
rawErrorMsg.includes('rune') ||
|
|
12053
|
+
rawErrorMsg.includes('{#if}') ||
|
|
12054
|
+
rawErrorMsg.includes('{/if}');
|
|
11775
12055
|
|
|
11776
12056
|
const chatMessage = isServiceError
|
|
11777
|
-
? `⚠️ ${
|
|
11778
|
-
:
|
|
12057
|
+
? `⚠️ ${friendlyTextFromStoredError(rawErrorMsg, codegenErrorDisplay)}`
|
|
12058
|
+
: codegenFailureChatLine(rawErrorMsg, codegenErrorDisplay);
|
|
11779
12059
|
panelChat?.addAssistantMessage(chatMessage);
|
|
11780
12060
|
|
|
11781
12061
|
const toastDescription = isServiceError
|
|
@@ -12073,6 +12353,10 @@ Requirements:
|
|
|
12073
12353
|
);
|
|
12074
12354
|
}
|
|
12075
12355
|
|
|
12356
|
+
if (generationWidgetId && completedCommitSha) {
|
|
12357
|
+
hideSketchOnBoardForWidget(generationWidgetId);
|
|
12358
|
+
}
|
|
12359
|
+
|
|
12076
12360
|
if (isFocusedPanel) {
|
|
12077
12361
|
liveDesignValues = {};
|
|
12078
12362
|
liveContentValues = {};
|
|
@@ -12263,10 +12547,12 @@ Requirements:
|
|
|
12263
12547
|
patchCodegenUiState(generationWidgetId, {
|
|
12264
12548
|
generateCodeStatus: '⚠️ This app needs a refresh to continue.',
|
|
12265
12549
|
lastGenerationFailed: true,
|
|
12266
|
-
lastGenerationError:
|
|
12550
|
+
lastGenerationError: 'This app needs a refresh to continue.',
|
|
12267
12551
|
});
|
|
12268
12552
|
showToast('warning', $t('creator.common.thisAppNeedsARefresh'), {
|
|
12269
|
-
description:
|
|
12553
|
+
description: debugMode
|
|
12554
|
+
? error.message
|
|
12555
|
+
: $t('creator.status.needsRefresh'),
|
|
12270
12556
|
duration: 12000,
|
|
12271
12557
|
action: {
|
|
12272
12558
|
label: $t('creator.common.reload'),
|
|
@@ -12284,7 +12570,7 @@ Requirements:
|
|
|
12284
12570
|
// of half a minute would not help them. (The page is told by the limit middleware.)
|
|
12285
12571
|
if (partnerMode && hourlyBudget) {
|
|
12286
12572
|
console.warn('Widget Creator: the visitor reached their budget during code generation');
|
|
12287
|
-
const limitMessage = await deriveApiErrorMessage(error, 'Usage limit exceeded');
|
|
12573
|
+
const limitMessage = await deriveApiErrorMessage(error, 'Usage limit exceeded', codegenErrorDisplay);
|
|
12288
12574
|
patchCodegenUiState(generationWidgetId, {
|
|
12289
12575
|
generateCodeStatus: '⚠️ Limit reached for now. Please try again later.',
|
|
12290
12576
|
lastGenerationFailed: true,
|
|
@@ -12337,7 +12623,7 @@ Requirements:
|
|
|
12337
12623
|
}
|
|
12338
12624
|
|
|
12339
12625
|
console.error('Widget Creator: Code generation error response:', error);
|
|
12340
|
-
const message = await deriveApiErrorMessage(error, 'Code generation failed.');
|
|
12626
|
+
const message = await deriveApiErrorMessage(error, 'Code generation failed.', codegenErrorDisplay);
|
|
12341
12627
|
patchCodegenUiState(generationWidgetId, {
|
|
12342
12628
|
generateCodeStatus: `❌ ${message}`,
|
|
12343
12629
|
lastGenerationFailed: true,
|
|
@@ -12785,7 +13071,9 @@ Requirements:
|
|
|
12785
13071
|
setGoogleFontsApiKey(String(googleFontsKey));
|
|
12786
13072
|
// console.log('[CreatorApp] Google Fonts API key set for FontIC');
|
|
12787
13073
|
} else {
|
|
12788
|
-
console.
|
|
13074
|
+
console.info(
|
|
13075
|
+
'[CreatorApp] No PUBLIC_GOOGLE_FONTS_API_KEY — FontIC uses its fallback catalog (see site .env.example)'
|
|
13076
|
+
);
|
|
12789
13077
|
}
|
|
12790
13078
|
setWebsocketApiUrl(apiRoot ?? null);
|
|
12791
13079
|
if (partnerMode) {
|
|
@@ -12946,6 +13234,14 @@ Requirements:
|
|
|
12946
13234
|
mountUploadAbortController?.abort();
|
|
12947
13235
|
mountUploadAbortController = null;
|
|
12948
13236
|
clearCanvasLoadFailsafe();
|
|
13237
|
+
if (singleWidgetChromeFailsafeTimer) {
|
|
13238
|
+
clearTimeout(singleWidgetChromeFailsafeTimer);
|
|
13239
|
+
singleWidgetChromeFailsafeTimer = null;
|
|
13240
|
+
}
|
|
13241
|
+
if (sketchPrefillDirtyTimer != null) {
|
|
13242
|
+
clearTimeout(sketchPrefillDirtyTimer);
|
|
13243
|
+
sketchPrefillDirtyTimer = null;
|
|
13244
|
+
}
|
|
12949
13245
|
if (tokenCheckInterval) clearInterval(tokenCheckInterval);
|
|
12950
13246
|
if (tokenDisplayInterval) clearInterval(tokenDisplayInterval);
|
|
12951
13247
|
if (hydrationSafetyTimeout) clearTimeout(hydrationSafetyTimeout);
|
|
@@ -13341,11 +13637,16 @@ Requirements:
|
|
|
13341
13637
|
// reaches the API from the watchdog. Ordinary progress does not.
|
|
13342
13638
|
}
|
|
13343
13639
|
|
|
13344
|
-
function
|
|
13345
|
-
|
|
13346
|
-
|
|
13347
|
-
|
|
13348
|
-
|
|
13640
|
+
function readCodegenStreamTailFromOp(op: OperationStatus): string {
|
|
13641
|
+
return readGenerationStreamTail(op.metadata as Record<string, unknown> | undefined);
|
|
13642
|
+
}
|
|
13643
|
+
|
|
13644
|
+
function readCodegenThinkingTailFromOp(op: OperationStatus): string {
|
|
13645
|
+
return readThinkingTail(op.metadata as Record<string, unknown> | undefined);
|
|
13646
|
+
}
|
|
13647
|
+
|
|
13648
|
+
function readCodegenPlanFromOp(op: OperationStatus): GenerationPlanWire | null | undefined {
|
|
13649
|
+
return readPlanFromMetadata(op.metadata as Record<string, unknown> | undefined);
|
|
13349
13650
|
}
|
|
13350
13651
|
|
|
13351
13652
|
function holdPublishForGeneration(widgetId: string): void {
|
|
@@ -13392,6 +13693,7 @@ Requirements:
|
|
|
13392
13693
|
}
|
|
13393
13694
|
delete codegenStatusPendingLine[widgetId];
|
|
13394
13695
|
delete codegenStreamPending[widgetId];
|
|
13696
|
+
delete codegenThinkingPending[widgetId];
|
|
13395
13697
|
if (codegenChatStatusTimers[widgetId]) {
|
|
13396
13698
|
clearTimeout(codegenChatStatusTimers[widgetId]);
|
|
13397
13699
|
delete codegenChatStatusTimers[widgetId];
|
|
@@ -13434,10 +13736,20 @@ Requirements:
|
|
|
13434
13736
|
const status = String(op.status || '').toLowerCase();
|
|
13435
13737
|
if (status === 'completed' || status === 'failed' || status === 'cancelled') {
|
|
13436
13738
|
delete codegenStreamPending[widgetId];
|
|
13739
|
+
delete codegenThinkingPending[widgetId];
|
|
13740
|
+
delete codegenPlanPending[widgetId];
|
|
13437
13741
|
clearGenerationStream(widgetId);
|
|
13742
|
+
clearGenerationThinking(widgetId);
|
|
13743
|
+
clearGenerationPlan(widgetId);
|
|
13438
13744
|
scheduleCodegenStatusPush(widgetId, line);
|
|
13439
13745
|
} else {
|
|
13440
|
-
scheduleCodegenStatusPush(
|
|
13746
|
+
scheduleCodegenStatusPush(
|
|
13747
|
+
widgetId,
|
|
13748
|
+
line,
|
|
13749
|
+
readCodegenStreamTailFromOp(op),
|
|
13750
|
+
readCodegenThinkingTailFromOp(op),
|
|
13751
|
+
readCodegenPlanFromOp(op),
|
|
13752
|
+
);
|
|
13441
13753
|
}
|
|
13442
13754
|
}
|
|
13443
13755
|
scheduleCodegenChatStatusPush(widgetId, line);
|
|
@@ -13447,6 +13759,9 @@ Requirements:
|
|
|
13447
13759
|
const codegenStatusTimers: Record<string, ReturnType<typeof setTimeout>> = {};
|
|
13448
13760
|
const codegenStatusPendingLine: Record<string, string> = {};
|
|
13449
13761
|
const codegenStreamPending: Record<string, string> = {};
|
|
13762
|
+
const codegenThinkingPending: Record<string, string> = {};
|
|
13763
|
+
type CodegenPlanPending = { kind: 'clear' } | { kind: 'set'; plan: GenerationPlanWire };
|
|
13764
|
+
const codegenPlanPending: Record<string, CodegenPlanPending> = {};
|
|
13450
13765
|
const codegenChatStatusTimers: Record<string, ReturnType<typeof setTimeout>> = {};
|
|
13451
13766
|
const codegenChatStatusPendingLine: Record<string, string> = {};
|
|
13452
13767
|
|
|
@@ -13457,21 +13772,56 @@ Requirements:
|
|
|
13457
13772
|
generationStreamByWidgetId = next;
|
|
13458
13773
|
}
|
|
13459
13774
|
|
|
13775
|
+
function clearGenerationThinking(widgetId: string): void {
|
|
13776
|
+
if (!generationThinkingByWidgetId[widgetId]) return;
|
|
13777
|
+
const next = { ...generationThinkingByWidgetId };
|
|
13778
|
+
delete next[widgetId];
|
|
13779
|
+
generationThinkingByWidgetId = next;
|
|
13780
|
+
}
|
|
13781
|
+
|
|
13782
|
+
function clearGenerationPlan(widgetId: string): void {
|
|
13783
|
+
if (!generationPlanByWidgetId[widgetId]) return;
|
|
13784
|
+
const next = { ...generationPlanByWidgetId };
|
|
13785
|
+
delete next[widgetId];
|
|
13786
|
+
generationPlanByWidgetId = next;
|
|
13787
|
+
}
|
|
13788
|
+
|
|
13460
13789
|
/** At most one panel status write per widget per interval; trailing line always lands. */
|
|
13461
|
-
function scheduleCodegenStatusPush(
|
|
13790
|
+
function scheduleCodegenStatusPush(
|
|
13791
|
+
widgetId: string,
|
|
13792
|
+
line: string,
|
|
13793
|
+
streamTail = '',
|
|
13794
|
+
thinkingTail = '',
|
|
13795
|
+
plan?: GenerationPlanWire | null,
|
|
13796
|
+
): void {
|
|
13462
13797
|
codegenStatusPendingLine[widgetId] = line;
|
|
13463
13798
|
if (streamTail) codegenStreamPending[widgetId] = streamTail;
|
|
13799
|
+
if (thinkingTail) codegenThinkingPending[widgetId] = thinkingTail;
|
|
13800
|
+
if (plan !== undefined) {
|
|
13801
|
+
codegenPlanPending[widgetId] = plan === null ? { kind: 'clear' } : { kind: 'set', plan };
|
|
13802
|
+
}
|
|
13464
13803
|
if (codegenStatusTimers[widgetId]) return;
|
|
13465
13804
|
codegenStatusTimers[widgetId] = setTimeout(() => {
|
|
13466
13805
|
delete codegenStatusTimers[widgetId];
|
|
13467
13806
|
const pending = codegenStatusPendingLine[widgetId];
|
|
13468
13807
|
const pendingTail = codegenStreamPending[widgetId];
|
|
13808
|
+
const pendingThinking = codegenThinkingPending[widgetId];
|
|
13809
|
+
const pendingPlan = codegenPlanPending[widgetId];
|
|
13469
13810
|
delete codegenStatusPendingLine[widgetId];
|
|
13470
13811
|
delete codegenStreamPending[widgetId];
|
|
13812
|
+
delete codegenThinkingPending[widgetId];
|
|
13813
|
+
delete codegenPlanPending[widgetId];
|
|
13471
13814
|
if (pending && !previewReadyAnnouncedByWidgetId[widgetId]) patchCodegenUiState(widgetId, { generateCodeStatus: pending });
|
|
13472
13815
|
if (pendingTail && pendingTail !== generationStreamByWidgetId[widgetId]) {
|
|
13473
13816
|
generationStreamByWidgetId = { ...generationStreamByWidgetId, [widgetId]: pendingTail };
|
|
13474
13817
|
}
|
|
13818
|
+
if (pendingThinking && pendingThinking !== generationThinkingByWidgetId[widgetId]) {
|
|
13819
|
+
generationThinkingByWidgetId = { ...generationThinkingByWidgetId, [widgetId]: pendingThinking };
|
|
13820
|
+
}
|
|
13821
|
+
if (pendingPlan?.kind === 'clear') clearGenerationPlan(widgetId);
|
|
13822
|
+
else if (pendingPlan?.kind === 'set') {
|
|
13823
|
+
generationPlanByWidgetId = { ...generationPlanByWidgetId, [widgetId]: pendingPlan.plan };
|
|
13824
|
+
}
|
|
13475
13825
|
}, CODEGEN_STATUS_THROTTLE_MS);
|
|
13476
13826
|
}
|
|
13477
13827
|
|
|
@@ -13698,6 +14048,14 @@ Requirements:
|
|
|
13698
14048
|
let widgetPanelSnapshots: Record<string, WidgetPanelSnapshot> = {};
|
|
13699
14049
|
/** Bumped on every panel snapshot write so {#each} panels re-read display state. */
|
|
13700
14050
|
let panelDisplayRevision = 0;
|
|
14051
|
+
/** Mirrors WidgetDetails `showRuntimeConsole` for the docked chat header icon. */
|
|
14052
|
+
let panelConsoleOpenByWidgetId: Record<string, boolean> = {};
|
|
14053
|
+
|
|
14054
|
+
function toggleDockedChatConsole(panelWidgetId: string, panelInstanceKey: string) {
|
|
14055
|
+
widgetDetailsRefs[panelInstanceKey]?.toggleRuntimeConsole?.();
|
|
14056
|
+
const open = widgetDetailsRefs[panelInstanceKey]?.isRuntimeConsoleOpen?.() ?? false;
|
|
14057
|
+
panelConsoleOpenByWidgetId = { ...panelConsoleOpenByWidgetId, [panelWidgetId]: open };
|
|
14058
|
+
}
|
|
13701
14059
|
/** Bumped on rename so shape chrome / host title re-read widget names. */
|
|
13702
14060
|
let widgetNamesRevision = 0;
|
|
13703
14061
|
const schemaLoadInFlight = new Set<string>();
|
|
@@ -14249,6 +14607,16 @@ Requirements:
|
|
|
14249
14607
|
if (current && current !== liveId && current !== 'live') return;
|
|
14250
14608
|
const versionId = `v:${newestDraft}`;
|
|
14251
14609
|
selectVersionInDropdowns(widgetId, versionId);
|
|
14610
|
+
const draftRecord = getShapePublishHistory(widgetId).find((row) => Number(row.version) === newestDraft);
|
|
14611
|
+
const draftCommit = draftRecord?.commitSha ?? draftRecord?.commit_sha ?? null;
|
|
14612
|
+
if (!draftCommit) {
|
|
14613
|
+
// A version row with no commit has no build. Asking /preview for it is a 404.
|
|
14614
|
+
console.log('[VersionPreview] Newest draft has no build yet', {
|
|
14615
|
+
widgetId: widgetId.substring(0, 8),
|
|
14616
|
+
versionId,
|
|
14617
|
+
});
|
|
14618
|
+
return;
|
|
14619
|
+
}
|
|
14252
14620
|
shapePreviewSourceByWidgetId = {
|
|
14253
14621
|
...shapePreviewSourceByWidgetId,
|
|
14254
14622
|
[widgetId]: versionId,
|
|
@@ -14762,7 +15130,6 @@ Requirements:
|
|
|
14762
15130
|
let versionLabelsByWidgetId: Record<string, Record<string, string>> = {};
|
|
14763
15131
|
let versionPromptLabelsByWidgetId: Record<string, Record<string, string>> = {};
|
|
14764
15132
|
let versionTimelineByWidgetId: Record<string, Array<{ version: number; sha: string; prompt: string }>> = {};
|
|
14765
|
-
let viewingVersionByWidgetId: Record<string, number | null> = {};
|
|
14766
15133
|
const emptyVersionLabels: Record<string, string> = {};
|
|
14767
15134
|
const emptyVersionTimeline: Array<{ version: number; sha: string; prompt: string }> = [];
|
|
14768
15135
|
$: {
|
|
@@ -14776,13 +15143,11 @@ Requirements:
|
|
|
14776
15143
|
const nextLabels: Record<string, Record<string, string>> = {};
|
|
14777
15144
|
const nextPrompts: Record<string, Record<string, string>> = {};
|
|
14778
15145
|
const nextTimeline: Record<string, Array<{ version: number; sha: string; prompt: string }>> = {};
|
|
14779
|
-
const nextViewing: Record<string, number | null> = {};
|
|
14780
15146
|
for (const widgetId of openWidgetPanelIds) {
|
|
14781
15147
|
nextHeads[widgetId] = resolveViewingCommitShaForPanel(widgetId);
|
|
14782
15148
|
nextLabels[widgetId] = buildVersionLabelsForPanel(widgetId);
|
|
14783
15149
|
nextPrompts[widgetId] = buildVersionPromptLabelsForPanel(widgetId);
|
|
14784
15150
|
nextTimeline[widgetId] = buildVersionTimelineForPanel(widgetId);
|
|
14785
|
-
nextViewing[widgetId] = viewingVersionNumberForPanel(widgetId);
|
|
14786
15151
|
}
|
|
14787
15152
|
// A new object with the same contents still counts as a change and makes the
|
|
14788
15153
|
// chat rebuild every turn. That rebuild was running again on each progress tick.
|
|
@@ -14790,7 +15155,6 @@ Requirements:
|
|
|
14790
15155
|
if (JSON.stringify(versionLabelsByWidgetId) !== JSON.stringify(nextLabels)) versionLabelsByWidgetId = nextLabels;
|
|
14791
15156
|
if (JSON.stringify(versionPromptLabelsByWidgetId) !== JSON.stringify(nextPrompts)) versionPromptLabelsByWidgetId = nextPrompts;
|
|
14792
15157
|
if (JSON.stringify(versionTimelineByWidgetId) !== JSON.stringify(nextTimeline)) versionTimelineByWidgetId = nextTimeline;
|
|
14793
|
-
if (JSON.stringify(viewingVersionByWidgetId) !== JSON.stringify(nextViewing)) viewingVersionByWidgetId = nextViewing;
|
|
14794
15158
|
}
|
|
14795
15159
|
|
|
14796
15160
|
/** Commit shas are keyed on 7 chars — that is what the chat summaries carry. */
|
|
@@ -14855,13 +15219,6 @@ Requirements:
|
|
|
14855
15219
|
return labels;
|
|
14856
15220
|
}
|
|
14857
15221
|
|
|
14858
|
-
function viewingVersionNumberForPanel(widgetId: string): number | null {
|
|
14859
|
-
const selected = resolveWidgetShapeVersionSelectedId(widgetId);
|
|
14860
|
-
if (!selected?.startsWith('v:')) return null;
|
|
14861
|
-
const version = parseInt(selected.slice(2), 10);
|
|
14862
|
-
return Number.isFinite(version) ? version : null;
|
|
14863
|
-
}
|
|
14864
|
-
|
|
14865
15222
|
function syncWidgetShapeLivePreviews(): void {
|
|
14866
15223
|
// This runs once per canvas frame while a shape moves. A call limit here
|
|
14867
15224
|
// left the live iframe behind the shape.
|
|
@@ -16195,6 +16552,7 @@ Requirements:
|
|
|
16195
16552
|
*/
|
|
16196
16553
|
function notifyPublishComplete(publishedWidgetId: string, publishedVersion: number | undefined): void {
|
|
16197
16554
|
if (!embedded || !onPublishComplete) return;
|
|
16555
|
+
hideSketchOnBoardForWidget(publishedWidgetId);
|
|
16198
16556
|
void (async () => {
|
|
16199
16557
|
await Promise.race([
|
|
16200
16558
|
handleRefreshScreenshot(publishedWidgetId, { quiet: true }).catch((error) => {
|
|
@@ -16930,7 +17288,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
16930
17288
|
return;
|
|
16931
17289
|
}
|
|
16932
17290
|
|
|
16933
|
-
const derivedMessage = await deriveApiErrorMessage(error, defaultErrorMessage);
|
|
17291
|
+
const derivedMessage = await deriveApiErrorMessage(error, defaultErrorMessage, { debugMode });
|
|
16934
17292
|
authStatus = derivedMessage.startsWith(defaultErrorMessage)
|
|
16935
17293
|
? derivedMessage
|
|
16936
17294
|
: `${defaultErrorMessage}: ${derivedMessage}`;
|
|
@@ -17586,7 +17944,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
17586
17944
|
|
|
17587
17945
|
/** Simple canvas: one chat, always. The draft id stands in until the first Send creates the widget. */
|
|
17588
17946
|
async function ensureSimpleCanvasChat(): Promise<void> {
|
|
17589
|
-
if (!embedded || canvasAdvancedFeatures || !canvasComponentReady) return;
|
|
17947
|
+
if (!embedded || canvasAdvancedFeatures || !canvasComponentReady || !hasValidToken || !conversationsClient) return;
|
|
17590
17948
|
if (finalizingDraftConversions.size > 0) return;
|
|
17591
17949
|
const primaryId = (canvasPrimaryWidgetId || '').trim();
|
|
17592
17950
|
// The canvas JSON is loaded before the primary widget is known. Opening the draft chat in that gap
|
|
@@ -17610,7 +17968,14 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
17610
17968
|
}
|
|
17611
17969
|
}
|
|
17612
17970
|
|
|
17613
|
-
$: if (
|
|
17971
|
+
$: if (
|
|
17972
|
+
hasValidToken &&
|
|
17973
|
+
embedded &&
|
|
17974
|
+
!canvasAdvancedFeatures &&
|
|
17975
|
+
canvasComponentReady &&
|
|
17976
|
+
isCanvasStateLoaded &&
|
|
17977
|
+
(singleWidgetChromeReady || !!(canvasPrimaryWidgetId || '').trim())
|
|
17978
|
+
) {
|
|
17614
17979
|
void ensureSimpleCanvasChat();
|
|
17615
17980
|
}
|
|
17616
17981
|
|
|
@@ -17862,7 +18227,10 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
17862
18227
|
canvasShapesLoaded = true;
|
|
17863
18228
|
} catch (loadErr) {
|
|
17864
18229
|
console.warn('[WidgetCreator] canvasRef.loadCanvas failed/timed out — clearing loading overlay:', loadErr);
|
|
17865
|
-
canvasApiLoadError = toErrorMessage(loadErr, $t('creator.canvas.canvasShapesFailedToRender')
|
|
18230
|
+
canvasApiLoadError = toErrorMessage(loadErr, $t('creator.canvas.canvasShapesFailedToRender'), {
|
|
18231
|
+
debugMode,
|
|
18232
|
+
context: 'canvasLoad',
|
|
18233
|
+
});
|
|
17866
18234
|
}
|
|
17867
18235
|
if (canvasShapesLoaded) canvasApiLoadError = null;
|
|
17868
18236
|
}
|
|
@@ -17884,7 +18252,10 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
17884
18252
|
}
|
|
17885
18253
|
} catch (err) {
|
|
17886
18254
|
console.warn('[WidgetCreator] Failed to load canvas from API:', err);
|
|
17887
|
-
const errMsg = toErrorMessage(err, $t('creator.canvas.failedToLoadCanvasFrom')
|
|
18255
|
+
const errMsg = toErrorMessage(err, $t('creator.canvas.failedToLoadCanvasFrom'), {
|
|
18256
|
+
debugMode,
|
|
18257
|
+
context: 'canvasLoad',
|
|
18258
|
+
});
|
|
17888
18259
|
canvasApiLoadError = errMsg;
|
|
17889
18260
|
// Partner mode: the API says the canvas does not exist for this visitor. It is not an empty canvas to start on
|
|
17890
18261
|
// (the fallbacks below would call it one and say the creator is ready): the page is told, and that is the end.
|
|
@@ -18073,6 +18444,8 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
18073
18444
|
|
|
18074
18445
|
lastSavedCanvasObjectCount = objectCount;
|
|
18075
18446
|
try { creatorSessionStorage.setItem(CANVAS_OBJ_COUNT_KEY, String(objectCount)); } catch {}
|
|
18447
|
+
noteDrawnObjectCount(countDrawnCanvasObjectsInJson(json));
|
|
18448
|
+
maybeSyncSketchGeneratePrefill();
|
|
18076
18449
|
emitCreatorSaveState(false);
|
|
18077
18450
|
|
|
18078
18451
|
// Save to durable L1 fallback (always, even with 0 objects for legitimate clears)
|
|
@@ -18253,6 +18626,8 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
18253
18626
|
promptLoadedForWidgetId = draftId;
|
|
18254
18627
|
pendingChatDraftText = CONVERT_PROMPT;
|
|
18255
18628
|
chatDraftRestoredForWidgetId = null;
|
|
18629
|
+
pendingSketchGeneratePrefill = false;
|
|
18630
|
+
sketchPrefillApplied = true;
|
|
18256
18631
|
savePromptForWidget(draftId);
|
|
18257
18632
|
const panelChat = getChatMethodsForWidget(draftId);
|
|
18258
18633
|
if (panelChat) {
|
|
@@ -18516,10 +18891,8 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
18516
18891
|
promptLoadedForWidgetId = widgetId;
|
|
18517
18892
|
pendingChatDraftText = '';
|
|
18518
18893
|
|
|
18894
|
+
// No "Widget created" toast: the chat already shows the build starting, so the person sees it there.
|
|
18519
18895
|
authStatus = 'Widget created from design.';
|
|
18520
|
-
showToast('success', $t('creator.widget.widgetCreated'), {
|
|
18521
|
-
description: $t('creator.codegen.isReadyGenerationStarted', { name: newWidget.name || widgetName })
|
|
18522
|
-
});
|
|
18523
18896
|
return widgetId;
|
|
18524
18897
|
} catch (error) {
|
|
18525
18898
|
console.error('[WidgetCreator] finalizeDraftConversion error:', error);
|
|
@@ -18544,6 +18917,9 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
18544
18917
|
*/
|
|
18545
18918
|
async function lockSimpleCanvasToOneWidget(primaryId: string | null): Promise<void> {
|
|
18546
18919
|
if (!embedded || multipleWidgetsAllowed || !canvasRef || !primaryId) return;
|
|
18920
|
+
if (widgetBuiltForSketchHiding(primaryId)) {
|
|
18921
|
+
hideSketchOnBoardForWidget(primaryId);
|
|
18922
|
+
}
|
|
18547
18923
|
const removed = canvasRef.keepOnlyWidgetShape?.(primaryId) ?? 0;
|
|
18548
18924
|
const linked = canvasRef.getLinkedWidgetIds?.() ?? new Set<string>();
|
|
18549
18925
|
let placed = false;
|
|
@@ -18855,7 +19231,11 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
18855
19231
|
|
|
18856
19232
|
console.error('Failed to verify repository', error);
|
|
18857
19233
|
if (!silent) {
|
|
18858
|
-
const message = await deriveApiErrorMessage(
|
|
19234
|
+
const message = await deriveApiErrorMessage(
|
|
19235
|
+
error,
|
|
19236
|
+
$t('creator.codegen.unableToVerifyRepositoryStatus'),
|
|
19237
|
+
codegenErrorDisplay,
|
|
19238
|
+
);
|
|
18859
19239
|
showToast('error', $t('creator.codegen.repositoryVerificationFailed'), {
|
|
18860
19240
|
description: message,
|
|
18861
19241
|
duration: 5000
|
|
@@ -19231,7 +19611,29 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
19231
19611
|
|
|
19232
19612
|
|
|
19233
19613
|
<!-- Widgetic Canvas Editor - Full width background (lazy-loaded) -->
|
|
19234
|
-
<div
|
|
19614
|
+
<div
|
|
19615
|
+
class="wc-canvas-area flex-1 min-h-0 min-w-0 relative {embeddedSketchShell
|
|
19616
|
+
? 'flex flex-col lg:pe-[450px] max-lg:pe-0'
|
|
19617
|
+
: embedded && !canvasAdvancedFeatures
|
|
19618
|
+
? 'pe-[450px]'
|
|
19619
|
+
: ''}"
|
|
19620
|
+
>
|
|
19621
|
+
<EmbeddedSketchViewportShell
|
|
19622
|
+
{embedded}
|
|
19623
|
+
sketchShell={embeddedSketchShell}
|
|
19624
|
+
bind:mobileTab={embeddedSketchMobileTab}
|
|
19625
|
+
tabCanvasLabel={$t('creator.embedded.tabCanvas')}
|
|
19626
|
+
tabChatLabel={$t('creator.livePreviews.chat')}
|
|
19627
|
+
>
|
|
19628
|
+
{#snippet children()}
|
|
19629
|
+
<div
|
|
19630
|
+
class="embedded-sketch-canvas-stage flex-1 min-h-0 relative min-w-0 {embeddedSketchShell
|
|
19631
|
+
? 'max-lg:shrink-0 max-lg:basis-[58%] max-lg:min-h-0 max-md:absolute max-md:inset-0 max-md:z-0 max-md:basis-auto'
|
|
19632
|
+
: ''} {embeddedSketchShell && embeddedSketchMobileTab !== 'canvas'
|
|
19633
|
+
? 'max-md:pointer-events-none max-md:opacity-0 max-md:[visibility:hidden]'
|
|
19634
|
+
: ''}"
|
|
19635
|
+
aria-hidden={embeddedSketchShell && embeddedSketchMobileTab !== 'canvas' ? 'true' : undefined}
|
|
19636
|
+
>
|
|
19235
19637
|
<!-- Embedded: Debug toggle lives in site AppHeader (avoids overlapping Props Panel). -->
|
|
19236
19638
|
{#if canvasApiLoadError || canvasShapesMissingWarning}
|
|
19237
19639
|
<div class="canvas-state-warning-ct absolute top-3 left-1/2 -translate-x-1/2 z-30 max-w-lg w-[calc(100%-2rem)] pointer-events-auto">
|
|
@@ -19281,7 +19683,10 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
19281
19683
|
onConvertToWidget={handleConvertToWidget}
|
|
19282
19684
|
onRecognizeStroke={handleRecognizeStroke}
|
|
19283
19685
|
onWidgetImageClick={handleWidgetImageClick}
|
|
19284
|
-
onCanvasDirty={() =>
|
|
19686
|
+
onCanvasDirty={() => {
|
|
19687
|
+
emitCreatorSaveState(true);
|
|
19688
|
+
scheduleSketchPrefillFromCanvasDirty();
|
|
19689
|
+
}}
|
|
19285
19690
|
onWidgetShapeDuplicated={handleWidgetShapeDuplicated}
|
|
19286
19691
|
onWidgetShapeDeleting={handleWidgetShapeDeleting}
|
|
19287
19692
|
onWidgetRename={handleWidgetRename}
|
|
@@ -19338,7 +19743,14 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
19338
19743
|
</div>
|
|
19339
19744
|
|
|
19340
19745
|
<!-- FLOATING PANELS OVERLAY (pointer-events-none container, each panel is pointer-events-auto) -->
|
|
19341
|
-
<div
|
|
19746
|
+
<div
|
|
19747
|
+
class="floating-panels-overlay z-2003 pointer-events-none {embeddedSketchShell
|
|
19748
|
+
? 'max-lg:relative max-lg:inset-auto max-lg:flex max-lg:flex-1 max-lg:min-h-0 max-lg:basis-[42%] max-lg:shrink-0 max-lg:w-full max-md:absolute max-md:inset-0 max-md:z-[1] max-md:basis-auto lg:absolute lg:inset-0'
|
|
19749
|
+
: 'absolute inset-0'} {embeddedSketchShell && embeddedSketchMobileTab !== 'chat'
|
|
19750
|
+
? 'max-md:pointer-events-none max-md:opacity-0 max-md:[visibility:hidden]'
|
|
19751
|
+
: ''}"
|
|
19752
|
+
aria-hidden={embeddedSketchShell && embeddedSketchMobileTab !== 'chat' ? 'true' : undefined}
|
|
19753
|
+
>
|
|
19342
19754
|
|
|
19343
19755
|
<!-- W3: live iframe + drag bar on WidgetShapes (iframe interactive; body drag locked) -->
|
|
19344
19756
|
<WidgetShapeLivePreviews
|
|
@@ -20194,7 +20606,9 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
20194
20606
|
{/if}
|
|
20195
20607
|
</svelte:fragment>
|
|
20196
20608
|
<svelte:fragment slot="code-generation-models">
|
|
20609
|
+
<!-- The debug model list stays inside `{#if debugMode}`: the i18n source guard reads that test to leave debug words in English. -->
|
|
20197
20610
|
{#if debugMode}
|
|
20611
|
+
{#if !(!canvasAdvancedFeatures && embedded)}
|
|
20198
20612
|
<div class="generation-chat-sticky-header shrink-0 z-20 bg-white border-b border-gray-200">
|
|
20199
20613
|
<!-- svelte-ignore a11y_label_has_associated_control -->
|
|
20200
20614
|
<div class="generation-models-header flex items-center justify-end gap-2 px-2 py-1.5 bg-gray-50">
|
|
@@ -20217,6 +20631,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
20217
20631
|
</div>
|
|
20218
20632
|
</div>
|
|
20219
20633
|
{/if}
|
|
20634
|
+
{/if}
|
|
20220
20635
|
</svelte:fragment>
|
|
20221
20636
|
|
|
20222
20637
|
<svelte:fragment slot="code-generation-status">
|
|
@@ -20229,7 +20644,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
20229
20644
|
<span class="codegen-save-spinner inline-block h-3 w-3 shrink-0 animate-spin rounded-full border-2 border-gray-300 border-t-forest-green" aria-hidden="true"></span>
|
|
20230
20645
|
{/if}
|
|
20231
20646
|
<div class="generate-code-status-el text-xs flex-1 min-w-0 truncate text-gray-500">
|
|
20232
|
-
<span class="text-gray-400">{$t('creator.status.label')}</span> {hourlyLimit || ps.lastGenerationFailed ? $t('creator.status.ready') : statusLabel(statusText, $t)}
|
|
20647
|
+
<span class="text-gray-400">{$t('creator.status.label')}</span> {hourlyLimit || ps.lastGenerationFailed ? $t('creator.status.ready') : statusLabel(statusText, $t, codegenErrorDisplay)}
|
|
20233
20648
|
</div>
|
|
20234
20649
|
</div>
|
|
20235
20650
|
{#if publishPlanMessageByWidgetId[panelWidgetId]}
|
|
@@ -20275,7 +20690,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
20275
20690
|
>
|
|
20276
20691
|
{#if ps.lastGenerationFailed && !isHourlyLimitText(ps.lastGenerationError)}
|
|
20277
20692
|
<div class="generation-failed-overlay sticky top-0 z-20 mx-3 mt-3 border border-red-200 bg-red-50 p-3">
|
|
20278
|
-
<p class="text-xs text-red-700 whitespace-pre-wrap">{errorLabel(ps.lastGenerationError, $t)}</p>
|
|
20693
|
+
<p class="text-xs text-red-700 whitespace-pre-wrap">{errorLabel(ps.lastGenerationError, $t, codegenErrorDisplay)}</p>
|
|
20279
20694
|
<div class="generation-failed-actions mt-3 flex justify-center gap-2">
|
|
20280
20695
|
{#if isPlanLimitMessage(ps.lastGenerationError)}
|
|
20281
20696
|
<Button
|
|
@@ -20374,10 +20789,17 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
20374
20789
|
bind:language={widgetLanguage}
|
|
20375
20790
|
/>
|
|
20376
20791
|
{/snippet}
|
|
20377
|
-
|
|
20792
|
+
<!-- Svelte 5: `{@const}` must be the direct child of a block; this wrapper exists only for dockedChatPanel and composerModelOptions. -->
|
|
20793
|
+
{#if true}
|
|
20794
|
+
{@const dockedChatPanel = embedded && !canvasAdvancedFeatures}
|
|
20795
|
+
{@const composerModelOptions = debugMode
|
|
20796
|
+
? availableModels.map((model) => ({ id: model.id, label: model.name }))
|
|
20797
|
+
: []}
|
|
20798
|
+
<Chat class="code-generation-chat h-full w-full max-w-full rounded-none border-0"
|
|
20378
20799
|
locale={locale}
|
|
20379
20800
|
messages={chatMessages}
|
|
20380
|
-
storedLineLabel={(line) =>
|
|
20801
|
+
storedLineLabel={(line) =>
|
|
20802
|
+
conversationLineLabel(line, $t, codegenErrorDisplay)}
|
|
20381
20803
|
actionBarExtras={generationOptionChecks as any}
|
|
20382
20804
|
style="height: 100%; min-height: {chatUserHeight == null ? CHAT_AUTO_MIN_HEIGHT : CHAT_MIN_HEIGHT}px;"
|
|
20383
20805
|
resizeExpandsContainer={true}
|
|
@@ -20385,7 +20807,14 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
20385
20807
|
onMessagesResize={(deltaPx) => handleChatMessagesResize(panelWidgetId, deltaPx)}
|
|
20386
20808
|
showLogs={debugMode}
|
|
20387
20809
|
showHeader={false}
|
|
20810
|
+
showPanelHeader={dockedChatPanel}
|
|
20811
|
+
showConsoleControl={dockedChatPanel && debugMode}
|
|
20812
|
+
consoleOpen={!!panelConsoleOpenByWidgetId[panelWidgetId]}
|
|
20813
|
+
onToggleConsole={dockedChatPanel && debugMode ? () => toggleDockedChatConsole(panelWidgetId, panelInstanceKey) : undefined}
|
|
20388
20814
|
showDescriptionHeader={false}
|
|
20815
|
+
composerModels={composerModelOptions}
|
|
20816
|
+
selectedComposerModelId={selectedModelId}
|
|
20817
|
+
onSelectComposerModel={handleModelSelect}
|
|
20389
20818
|
context={{
|
|
20390
20819
|
id: panelWidgetId,
|
|
20391
20820
|
type: ContextType.FRAME,
|
|
@@ -20394,7 +20823,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
20394
20823
|
}}
|
|
20395
20824
|
config={{
|
|
20396
20825
|
features: {
|
|
20397
|
-
screenshot:
|
|
20826
|
+
screenshot: false,
|
|
20398
20827
|
screenRecording: false,
|
|
20399
20828
|
voiceTranscription: false,
|
|
20400
20829
|
fileUpload: true,
|
|
@@ -20412,7 +20841,6 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
20412
20841
|
versionLabelByCommitSha={versionLabelsByWidgetId[panelWidgetId] ?? emptyVersionLabels}
|
|
20413
20842
|
versionLabelByPrompt={versionPromptLabelsByWidgetId[panelWidgetId] ?? emptyVersionLabels}
|
|
20414
20843
|
versionTimeline={versionTimelineByWidgetId[panelWidgetId] ?? emptyVersionTimeline}
|
|
20415
|
-
viewingVersion={viewingVersionByWidgetId[panelWidgetId] ?? null}
|
|
20416
20844
|
showSelector={false}
|
|
20417
20845
|
isSelectorActive={!!selectorEnabledByWidgetId[panelWidgetId]}
|
|
20418
20846
|
selectedElements={selectedElementsByWidgetId[panelWidgetId] ?? []}
|
|
@@ -20423,7 +20851,6 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
20423
20851
|
onRetryMessage={(content) => handleChatRetryMessage(content, panelWidgetId)}
|
|
20424
20852
|
onUpgradePlans={openUpgradePlans}
|
|
20425
20853
|
onUploadChatFile={handleChatUploadFile}
|
|
20426
|
-
onTakeScreenshot={() => handleChatScreenshot(panelWidgetId)}
|
|
20427
20854
|
isCompleted={!!conversationCompletedByWidgetId[panelWidgetId]}
|
|
20428
20855
|
onCompletionToggle={(detail) => handleChatCompletionToggle(panelWidgetId, detail)}
|
|
20429
20856
|
onLoadConversations={handleLoadConversations}
|
|
@@ -20444,6 +20871,8 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
20444
20871
|
onConversationChange={(conversationId) => handleChatConversationChange(conversationId, panelWidgetId)}
|
|
20445
20872
|
isGenerating={!!generatingWidgetIds[panelWidgetId] && !previewUnblockedByWidgetId[panelWidgetId]}
|
|
20446
20873
|
generationStream={generationStreamByWidgetId[panelWidgetId] || ''}
|
|
20874
|
+
generationThinking={generationThinkingByWidgetId[panelWidgetId] || ''}
|
|
20875
|
+
generationPlan={generationPlanByWidgetId[panelWidgetId] ?? null}
|
|
20447
20876
|
onStopGeneration={() => {
|
|
20448
20877
|
if (!isPanelFocused) focusWidgetPanel(panelWidgetId);
|
|
20449
20878
|
// Stop belongs to the panel it was pressed in: the other panels' generations go on
|
|
@@ -20453,6 +20882,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
20453
20882
|
// console.log('[Chat] Stats update:', { messageCount, firstMessage });
|
|
20454
20883
|
}}
|
|
20455
20884
|
/>
|
|
20885
|
+
{/if}
|
|
20456
20886
|
</div>
|
|
20457
20887
|
{/key}
|
|
20458
20888
|
|
|
@@ -20882,6 +21312,9 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
20882
21312
|
{/if}
|
|
20883
21313
|
|
|
20884
21314
|
</div> <!-- end of floating-panels-overlay -->
|
|
21315
|
+
{/snippet}
|
|
21316
|
+
</EmbeddedSketchViewportShell>
|
|
21317
|
+
</div> <!-- end of wc-canvas-area -->
|
|
20885
21318
|
{/if} <!-- end of logged in section (canvas + main panel) -->
|
|
20886
21319
|
</div> <!-- end of widget-creator-root-page-ct -->
|
|
20887
21320
|
|
|
@@ -20956,7 +21389,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
20956
21389
|
<!-- Dialog.Root (bits-ui AlertDialogRoot) exposes no class prop — styling hooks
|
|
20957
21390
|
live on Content/Header below. -->
|
|
20958
21391
|
<Dialog.Root bind:open={deleteDialogOpen} onOpenChange={(open) => { if (!open) handleDeleteDialogResponse('cancel'); }}>
|
|
20959
|
-
<Dialog.Content closeLabel={$t('creator.common.close')} class="confirm-delete-dialog-content max-w-md bg-white z-9999">
|
|
21392
|
+
<Dialog.Content closeLabel={$t('creator.common.close')} layerBase={creatorDialogLayerBase} class="confirm-delete-dialog-content max-w-md bg-white z-9999">
|
|
20960
21393
|
<Dialog.Header class="confirm-delete-dialog-header">
|
|
20961
21394
|
<Dialog.Title>{$t('creator.widget.deleteWidgetShape')}</Dialog.Title>
|
|
20962
21395
|
<Dialog.Description>
|
|
@@ -20996,7 +21429,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
20996
21429
|
|
|
20997
21430
|
<!-- Delete Canvas Confirmation Dialog -->
|
|
20998
21431
|
<Dialog.Root bind:open={showDeleteCanvasDialog} onOpenChange={(open) => { if (!open) { showDeleteCanvasDialog = false; deleteCanvasTarget = null; } }}>
|
|
20999
|
-
<Dialog.Content closeLabel={$t('creator.common.close')} class="confirm-delete-canvas-dialog-content max-w-sm bg-white z-9999">
|
|
21432
|
+
<Dialog.Content closeLabel={$t('creator.common.close')} layerBase={creatorDialogLayerBase} class="confirm-delete-canvas-dialog-content max-w-sm bg-white z-9999">
|
|
21000
21433
|
<Dialog.Header class="confirm-delete-canvas-dialog-header">
|
|
21001
21434
|
<Dialog.Title>{$t('creator.canvas.deleteCanvas')}</Dialog.Title>
|
|
21002
21435
|
<Dialog.Description>
|
|
@@ -21061,7 +21494,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
21061
21494
|
if (!open) confirmGenerateWidgetId = null;
|
|
21062
21495
|
}}
|
|
21063
21496
|
>
|
|
21064
|
-
<Dialog.Content closeLabel={$t('creator.common.close')} class="confirm-generate-dialog-content max-w-lg bg-white z-9999">
|
|
21497
|
+
<Dialog.Content closeLabel={$t('creator.common.close')} layerBase={creatorDialogLayerBase} class="confirm-generate-dialog-content max-w-lg bg-white z-9999">
|
|
21065
21498
|
<Dialog.Header class="confirm-generate-dialog-header">
|
|
21066
21499
|
<Dialog.Title>{$t('creator.codegen.confirmCodeGeneration')}</Dialog.Title>
|
|
21067
21500
|
<Dialog.Description>
|
|
@@ -21186,10 +21619,13 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
21186
21619
|
.widget-item:hover .widget-item-edit-icon {
|
|
21187
21620
|
opacity: 1;
|
|
21188
21621
|
}
|
|
21189
|
-
/*
|
|
21190
|
-
|
|
21191
|
-
|
|
21192
|
-
|
|
21622
|
+
/*
|
|
21623
|
+
* No rule for the design system's dialogs here (`[data-dialog-overlay]`, `[data-widgetic-overlay]`): this style block is
|
|
21624
|
+
* global once the creator is loaded, so a `z-index` on the scrim of every dialog reaches the dashboard's too. One did
|
|
21625
|
+
* ("Dialog overlay + content must sit above FabricJS canvas": 9998 !important on the scrim, the panel left at 51) and
|
|
21626
|
+
* every dialog of the page, the Invite dialog first, was drawn under its own blur. The design system orders its own
|
|
21627
|
+
* layers (scrim, panel, popovers) and keeps them out of reach of page CSS; src/lib/dialogLayering.test.ts guards this.
|
|
21628
|
+
*/
|
|
21193
21629
|
.wc-version-history-toggle:focus,
|
|
21194
21630
|
.wc-version-history-toggle:focus-visible,
|
|
21195
21631
|
.wc-live-history-backdrop:focus,
|