@agent-native/core 0.163.3 → 0.164.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/corpus/README.md +1 -1
  2. package/corpus/templates/analytics/app/hooks/use-dashboard-chat-context.ts +29 -0
  3. package/corpus/templates/analytics/app/pages/sessions/SessionsPage.tsx +1 -2
  4. package/corpus/templates/analytics/netlify.toml +2 -0
  5. package/corpus/templates/assets/netlify.toml +2 -0
  6. package/corpus/templates/brain/netlify.toml +2 -0
  7. package/corpus/templates/calendar/app/components/calendar/DayView.tsx +2 -1
  8. package/corpus/templates/calendar/changelog/2026-08-19-calendar-page-loads-stay-fast-after-idle-periods.md +6 -0
  9. package/corpus/templates/calendar/netlify.toml +2 -0
  10. package/corpus/templates/chat/netlify.toml +2 -0
  11. package/corpus/templates/clips/app/components/player/player-controls.tsx +3 -3
  12. package/corpus/templates/clips/app/components/player/reaction-emojis.ts +12 -0
  13. package/corpus/templates/clips/app/components/player/reactions-tray.tsx +90 -9
  14. package/corpus/templates/clips/app/components/player/scrubber.tsx +43 -10
  15. package/corpus/templates/clips/app/components/player/video-player.tsx +105 -15
  16. package/corpus/templates/clips/app/routes/_app.settings._index.tsx +1 -2
  17. package/corpus/templates/clips/app/routes/_index.tsx +10 -2
  18. package/corpus/templates/clips/app/routes/r.$recordingId.tsx +13 -8
  19. package/corpus/templates/clips/app/routes/share.$shareId.tsx +15 -8
  20. package/corpus/templates/clips/netlify.toml +2 -0
  21. package/corpus/templates/clips/server/routes/[...page].head.ts +5 -0
  22. package/corpus/templates/content/netlify.toml +2 -0
  23. package/corpus/templates/design/.agents/skills/design-editor-architecture/SKILL.md +103 -0
  24. package/corpus/templates/design/.agents/skills/design-generation/SKILL.md +2 -1
  25. package/corpus/templates/design/AGENTS.md +3 -1
  26. package/corpus/templates/design/app/components/design/bridge/editor-chrome.bridge.ts +3 -2
  27. package/corpus/templates/design/app/components/design/editor/AgentNativeMenuMark.tsx +25 -0
  28. package/corpus/templates/design/app/components/design/editor/DesignBottomToolbar.tsx +411 -0
  29. package/corpus/templates/design/app/components/design/editor/DesignCollaborators.tsx +153 -0
  30. package/corpus/templates/design/app/components/design/editor/DesignWorkspaceRail.tsx +231 -0
  31. package/corpus/templates/design/app/components/design/editor/MakeRealDialog.tsx +223 -0
  32. package/corpus/templates/design/app/components/design/editor/PendingScreenDeletionDialog.tsx +58 -0
  33. package/corpus/templates/design/app/components/design/editor/PendingVisualStyleWarningDialog.tsx +56 -0
  34. package/corpus/templates/design/app/components/design/editor/ReadOnlyEditorPanel.tsx +23 -0
  35. package/corpus/templates/design/app/components/design/editor/SaveTemplateDialog.tsx +161 -0
  36. package/corpus/templates/design/app/components/design/editor/toolbar-controls.tsx +185 -0
  37. package/corpus/templates/design/app/pages/DesignEditor.tsx +20913 -0
  38. package/corpus/templates/design/app/pages/design-editor/command-types.ts +120 -0
  39. package/corpus/templates/design/app/pages/design-editor/commands/README.md +193 -0
  40. package/corpus/templates/design/app/pages/design-editor/commands/add-auto-layout.ts +416 -0
  41. package/corpus/templates/design/app/pages/design-editor/commands/add-screen.ts +112 -0
  42. package/corpus/templates/design/app/pages/design-editor/commands/align-selection.ts +183 -0
  43. package/corpus/templates/design/app/pages/design-editor/commands/apply-design-editor-command.ts +243 -0
  44. package/corpus/templates/design/app/pages/design-editor/commands/apply-file-content-update.ts +236 -0
  45. package/corpus/templates/design/app/pages/design-editor/commands/apply-local-content-update.ts +304 -0
  46. package/corpus/templates/design/app/pages/design-editor/commands/apply-pending-visual-styles-with-agent.ts +376 -0
  47. package/corpus/templates/design/app/pages/design-editor/commands/apply-to-source.ts +132 -0
  48. package/corpus/templates/design/app/pages/design-editor/commands/can-move-layer.ts +117 -0
  49. package/corpus/templates/design/app/pages/design-editor/commands/change-selected-z-index.ts +212 -0
  50. package/corpus/templates/design/app/pages/design-editor/commands/commit-relative-style-delta-to-selected-layers.ts +176 -0
  51. package/corpus/templates/design/app/pages/design-editor/commands/commit-styles-to-selected-layers.ts +175 -0
  52. package/corpus/templates/design/app/pages/design-editor/commands/commit-visual-styles.ts +710 -0
  53. package/corpus/templates/design/app/pages/design-editor/commands/confirm-make-real.ts +99 -0
  54. package/corpus/templates/design/app/pages/design-editor/commands/copy-as-figma-svg.ts +95 -0
  55. package/corpus/templates/design/app/pages/design-editor/commands/copy-selection.ts +156 -0
  56. package/corpus/templates/design/app/pages/design-editor/commands/create-primitive.ts +291 -0
  57. package/corpus/templates/design/app/pages/design-editor/commands/create-screen-frame.ts +131 -0
  58. package/corpus/templates/design/app/pages/design-editor/commands/cross-screen-element-drop.ts +577 -0
  59. package/corpus/templates/design/app/pages/design-editor/commands/delete-files.ts +364 -0
  60. package/corpus/templates/design/app/pages/design-editor/commands/delete-selection.ts +521 -0
  61. package/corpus/templates/design/app/pages/design-editor/commands/detach-instance-menu-action.ts +88 -0
  62. package/corpus/templates/design/app/pages/design-editor/commands/distribute-selection.ts +114 -0
  63. package/corpus/templates/design/app/pages/design-editor/commands/download-all-screens-pdf.ts +116 -0
  64. package/corpus/templates/design/app/pages/design-editor/commands/download-pdf.ts +103 -0
  65. package/corpus/templates/design/app/pages/design-editor/commands/download-svg.ts +159 -0
  66. package/corpus/templates/design/app/pages/design-editor/commands/duplicate-screen.ts +201 -0
  67. package/corpus/templates/design/app/pages/design-editor/commands/duplicate-selection.ts +279 -0
  68. package/corpus/templates/design/app/pages/design-editor/commands/editor-paste.ts +81 -0
  69. package/corpus/templates/design/app/pages/design-editor/commands/enter-hotkey.ts +155 -0
  70. package/corpus/templates/design/app/pages/design-editor/commands/enter-single-screen.ts +168 -0
  71. package/corpus/templates/design/app/pages/design-editor/commands/escape-hotkey.ts +212 -0
  72. package/corpus/templates/design/app/pages/design-editor/commands/frame-selection.ts +119 -0
  73. package/corpus/templates/design/app/pages/design-editor/commands/geometry-commit.ts +169 -0
  74. package/corpus/templates/design/app/pages/design-editor/commands/get-selected-layer-snapshots.ts +177 -0
  75. package/corpus/templates/design/app/pages/design-editor/commands/group-selection.ts +127 -0
  76. package/corpus/templates/design/app/pages/design-editor/commands/iframe-context-menu.ts +121 -0
  77. package/corpus/templates/design/app/pages/design-editor/commands/import-figma-clipboard-into-design.ts +119 -0
  78. package/corpus/templates/design/app/pages/design-editor/commands/layer-marquee-selection-change.ts +163 -0
  79. package/corpus/templates/design/app/pages/design-editor/commands/layer-move-to-screen.ts +331 -0
  80. package/corpus/templates/design/app/pages/design-editor/commands/layer-move.ts +517 -0
  81. package/corpus/templates/design/app/pages/design-editor/commands/layer-rename.ts +247 -0
  82. package/corpus/templates/design/app/pages/design-editor/commands/layer-selection-change.ts +161 -0
  83. package/corpus/templates/design/app/pages/design-editor/commands/mode-change.ts +122 -0
  84. package/corpus/templates/design/app/pages/design-editor/commands/nudge-selection.ts +213 -0
  85. package/corpus/templates/design/app/pages/design-editor/commands/overview-primitive-reparent.ts +318 -0
  86. package/corpus/templates/design/app/pages/design-editor/commands/paste-copied-screens.ts +114 -0
  87. package/corpus/templates/design/app/pages/design-editor/commands/paste-over-selection.ts +70 -0
  88. package/corpus/templates/design/app/pages/design-editor/commands/paste-selection.ts +436 -0
  89. package/corpus/templates/design/app/pages/design-editor/commands/paste-to-replace.ts +135 -0
  90. package/corpus/templates/design/app/pages/design-editor/commands/pasted-image-files.ts +209 -0
  91. package/corpus/templates/design/app/pages/design-editor/commands/persist-frame-geometry-save.ts +113 -0
  92. package/corpus/templates/design/app/pages/design-editor/commands/persist-tweak-save.ts +160 -0
  93. package/corpus/templates/design/app/pages/design-editor/commands/primitive-created.ts +168 -0
  94. package/corpus/templates/design/app/pages/design-editor/commands/record-pending-live-layer-state-edit.ts +149 -0
  95. package/corpus/templates/design/app/pages/design-editor/commands/record-pending-live-structure-edit.ts +200 -0
  96. package/corpus/templates/design/app/pages/design-editor/commands/record-pending-live-text-edit.ts +152 -0
  97. package/corpus/templates/design/app/pages/design-editor/commands/record-pending-visual-style-edit.ts +247 -0
  98. package/corpus/templates/design/app/pages/design-editor/commands/redo.ts +1086 -0
  99. package/corpus/templates/design/app/pages/design-editor/commands/render-png-blob.ts +200 -0
  100. package/corpus/templates/design/app/pages/design-editor/commands/save-file-content.ts +207 -0
  101. package/corpus/templates/design/app/pages/design-editor/commands/screen-element-select.ts +262 -0
  102. package/corpus/templates/design/app/pages/design-editor/commands/screen-text-content-change.ts +216 -0
  103. package/corpus/templates/design/app/pages/design-editor/commands/screen-visual-duplicate-change.ts +108 -0
  104. package/corpus/templates/design/app/pages/design-editor/commands/screen-visual-structure-change.ts +280 -0
  105. package/corpus/templates/design/app/pages/design-editor/commands/screen-visual-style-change.ts +151 -0
  106. package/corpus/templates/design/app/pages/design-editor/commands/send-overview-annotations.ts +88 -0
  107. package/corpus/templates/design/app/pages/design-editor/commands/send-runtime-layer-move-semantic-handoff.ts +122 -0
  108. package/corpus/templates/design/app/pages/design-editor/commands/send-runtime-layer-semantic-handoff.ts +143 -0
  109. package/corpus/templates/design/app/pages/design-editor/commands/send-runtime-layer-state-semantic-handoff.ts +115 -0
  110. package/corpus/templates/design/app/pages/design-editor/commands/start-retry-generation.ts +152 -0
  111. package/corpus/templates/design/app/pages/design-editor/commands/start-sidebar-resize.ts +99 -0
  112. package/corpus/templates/design/app/pages/design-editor/commands/style-change.ts +152 -0
  113. package/corpus/templates/design/app/pages/design-editor/commands/styles-change.ts +155 -0
  114. package/corpus/templates/design/app/pages/design-editor/commands/suggest-auto-layout.ts +125 -0
  115. package/corpus/templates/design/app/pages/design-editor/commands/text-content-change.ts +201 -0
  116. package/corpus/templates/design/app/pages/design-editor/commands/tidy-up.ts +123 -0
  117. package/corpus/templates/design/app/pages/design-editor/commands/toggle-layer-hidden.ts +167 -0
  118. package/corpus/templates/design/app/pages/design-editor/commands/toggle-layer-locked.ts +175 -0
  119. package/corpus/templates/design/app/pages/design-editor/commands/toggle-motion-keyframe.ts +99 -0
  120. package/corpus/templates/design/app/pages/design-editor/commands/tweak-prompt-submit.ts +84 -0
  121. package/corpus/templates/design/app/pages/design-editor/commands/undo.ts +906 -0
  122. package/corpus/templates/design/app/pages/design-editor/commands/ungroup-selection.ts +170 -0
  123. package/corpus/templates/design/app/pages/design-editor/commands/visual-duplicate-change.ts +119 -0
  124. package/corpus/templates/design/app/pages/design-editor/commands/visual-structure-change.ts +274 -0
  125. package/corpus/templates/design/app/pages/design-editor/commands/write-frame-geometry-snapshot.ts +99 -0
  126. package/corpus/templates/design/app/pages/design-editor/derive/design-breakpoints.ts +56 -0
  127. package/corpus/templates/design/app/pages/design-editor/derive/overview-screens.ts +146 -0
  128. package/corpus/templates/design/app/pages/design-editor/domains/use-tweaks.ts +326 -0
  129. package/corpus/templates/design/app/pages/design-editor/editor-constants.ts +54 -0
  130. package/corpus/templates/design/app/pages/design-editor/editor-helpers.ts +183 -0
  131. package/corpus/templates/design/app/pages/design-editor/effects/adopt-db-file-content.ts +270 -0
  132. package/corpus/templates/design/app/pages/design-editor/effects/mirror-selection-to-agent-chat.ts +134 -0
  133. package/corpus/templates/design/app/pages/design-editor/effects/motion-autosave.ts +335 -0
  134. package/corpus/templates/design/app/pages/design-editor/effects/observe-collab-text.ts +183 -0
  135. package/corpus/templates/design/app/pages/design-editor/effects/publish-agent-selection-context.ts +252 -0
  136. package/corpus/templates/design/app/pages/design-editor/effects/resume-pending-generation.ts +178 -0
  137. package/corpus/templates/design/app/pages/design-editor/effects/seed-collab-content.ts +157 -0
  138. package/corpus/templates/design/app/pages/design-editor/preview-html.ts +19 -0
  139. package/corpus/templates/design/netlify.toml +2 -0
  140. package/corpus/templates/design/shared/board-file.ts +2 -1
  141. package/corpus/templates/dispatch/netlify.toml +2 -0
  142. package/corpus/templates/forms/netlify.toml +2 -0
  143. package/corpus/templates/mail/netlify.toml +2 -0
  144. package/corpus/templates/plan/netlify.toml +2 -0
  145. package/corpus/templates/slides/netlify.toml +2 -0
  146. package/dist/agent/engine/builder-engine.d.ts +6 -4
  147. package/dist/agent/engine/builder-engine.js +91 -26
  148. package/dist/agent/engine/registry.js +16 -0
  149. package/dist/cli/code-agent-agent-tools.d.ts +2 -0
  150. package/dist/cli/code-agent-agent-tools.js +188 -0
  151. package/dist/cli/code-agent-collaboration.d.ts +34 -0
  152. package/dist/cli/code-agent-collaboration.js +104 -0
  153. package/dist/cli/code-agent-executor.js +6 -0
  154. package/dist/cli/code-agent-schedules.d.ts +54 -0
  155. package/dist/cli/code-agent-schedules.js +198 -0
  156. package/dist/client/AgentPanel.js +1 -1
  157. package/dist/client/ConnectBuilderCard.js +5 -2
  158. package/dist/client/EnvironmentBadge.js +6 -5
  159. package/dist/client/chat/run-recovery.js +3 -2
  160. package/dist/client/chat/tool-call-display.js +2 -3
  161. package/dist/client/components/CodeRequiredDialog.js +4 -2
  162. package/dist/client/i18n.js +5 -4
  163. package/dist/client/settings/SettingsPanel.js +1 -1
  164. package/dist/client/settings/VoiceTranscriptionSection.js +1 -1
  165. package/dist/client/settings/useBuilderStatus.d.ts +6 -1
  166. package/dist/client/settings/useBuilderStatus.js +22 -33
  167. package/dist/client/transcription/BuilderTranscriptionCta.js +1 -1
  168. package/dist/code-agents/index.d.ts +2 -0
  169. package/dist/code-agents/index.js +2 -0
  170. package/dist/collab/routes.d.ts +1 -1
  171. package/dist/localization/shared.d.ts +2 -0
  172. package/dist/localization/shared.js +5 -0
  173. package/dist/mcp-client/oauth-client.d.ts +1 -0
  174. package/dist/mcp-client/oauth-client.js +50 -1
  175. package/dist/observability/routes.d.ts +1 -1
  176. package/dist/provider-api/actions/provider-api.d.ts +2 -2
  177. package/dist/resources/handlers.d.ts +1 -1
  178. package/dist/server/auth-marketing-locales.d.ts +7 -0
  179. package/dist/server/auth-marketing-locales.js +1322 -0
  180. package/dist/server/auth-marketing.d.ts +1 -0
  181. package/dist/server/auth-marketing.js +35 -6
  182. package/dist/server/auth.js +4 -17
  183. package/dist/server/builder-browser.d.ts +22 -0
  184. package/dist/server/builder-browser.js +77 -1
  185. package/dist/server/builder-oauth.d.ts +50 -0
  186. package/dist/server/builder-oauth.js +263 -0
  187. package/dist/server/core-routes-plugin.d.ts +11 -0
  188. package/dist/server/core-routes-plugin.js +291 -415
  189. package/dist/server/credential-provider.d.ts +1 -1
  190. package/dist/server/credential-provider.js +1 -1
  191. package/dist/server/csrf.js +2 -2
  192. package/dist/server/onboarding-html.js +52 -120
  193. package/dist/server/realtime-token.d.ts +1 -1
  194. package/dist/server/transcribe-voice.d.ts +1 -1
  195. package/dist/settings/store.d.ts +9 -0
  196. package/dist/settings/store.js +19 -0
  197. package/dist/templates/chat/netlify.toml +2 -0
  198. package/dist/vite/client.js +35 -37
  199. package/docs/content/deployment.mdx +2 -0
  200. package/docs/content/multi-app-workspace.mdx +1 -1
  201. package/package.json +2 -2
  202. package/src/templates/chat/netlify.toml +2 -0
@@ -0,0 +1,247 @@
1
+ import type { InteractionState } from "@shared/interaction-states";
2
+ import type { Dispatch, RefObject, SetStateAction } from "react";
3
+
4
+ import type { ElementInfo } from "@/components/design/types";
5
+ import { prettyScreenName } from "@/lib/screen-names";
6
+ import type {
7
+ PatchProofState,
8
+ PendingStructureVerificationStatus,
9
+ ResponsiveEditScope,
10
+ RuntimeLayerSnapshot,
11
+ } from "@/pages/design-editor/command-types";
12
+ import type { OverviewScreen } from "@/pages/design-editor/derive/overview-screens";
13
+ import { runtimeMultiplicityForElementProvenance } from "@/pages/design-editor/editor-helpers";
14
+ import type { ContentHistoryChange } from "@/pages/design-editor/history";
15
+ import { MAX_DESIGN_UNDO_STACK } from "@/pages/design-editor/history";
16
+ import type {
17
+ PendingLiveNonStyleUndoEntry,
18
+ PendingLiveStructureUndoEntry,
19
+ PendingVisualStyleEdit,
20
+ PendingVisualStyleUndoEntry,
21
+ } from "@/pages/design-editor/pending-edits";
22
+ import {
23
+ mergePendingVisualStyleEdits,
24
+ originalStylesForPendingVisualEdit,
25
+ pendingVisualStyleUndoRevertStyles,
26
+ reactSourceAnchorForPendingEdit,
27
+ } from "@/pages/design-editor/pending-edits";
28
+ import type { DesignFile } from "@/pages/design-editor/types";
29
+
30
+ export interface RecordPendingVisualStyleEditArgs {
31
+ activeBreakpointUpperBoundPx: number | null;
32
+ activeBreakpointWidthState: number | undefined;
33
+ activeFile: DesignFile;
34
+ canEditDesign: boolean;
35
+ cancelPendingStructureVerification: (
36
+ nextStatus?: PendingStructureVerificationStatus,
37
+ ) => void;
38
+ clipboardPasteRedoStackRef: RefObject<ContentHistoryChange[]>;
39
+ files: DesignFile[];
40
+ getProjectionContentForScreen: (screenId: string) => string;
41
+ localhostConnectionRootPathByIdRef: RefObject<Map<string, string>>;
42
+ overviewScreens: OverviewScreen[];
43
+ pendingLiveNonStyleRedoStackRef: RefObject<PendingLiveNonStyleUndoEntry[]>;
44
+ pendingStructureRedoReplayRef: RefObject<
45
+ PendingLiveStructureUndoEntry | undefined
46
+ >;
47
+ pendingStructureRedoReplayTimerRef: RefObject<number | undefined>;
48
+ pendingVisualStyleEditsRef: RefObject<PendingVisualStyleEdit[]>;
49
+ pendingVisualStyleRedoStackRef: RefObject<PendingVisualStyleUndoEntry[]>;
50
+ pendingVisualStyleUndoStackRef: RefObject<PendingVisualStyleUndoEntry[]>;
51
+ responsiveEditScopeRef: RefObject<ResponsiveEditScope>;
52
+ runtimeLayerSnapshotsById: Record<string, RuntimeLayerSnapshot>;
53
+ selectedElement: ElementInfo | null;
54
+ setPatchProof: Dispatch<SetStateAction<PatchProofState | null>>;
55
+ setPendingVisualStyleEdits: Dispatch<
56
+ SetStateAction<PendingVisualStyleEdit[]>
57
+ >;
58
+ setSelectedElement: Dispatch<SetStateAction<ElementInfo | null>>;
59
+ setSelectedLayerIdsState: Dispatch<SetStateAction<string[]>>;
60
+ }
61
+
62
+ export function runRecordPendingVisualStyleEdit(
63
+ {
64
+ activeBreakpointUpperBoundPx,
65
+ activeBreakpointWidthState,
66
+ activeFile,
67
+ canEditDesign,
68
+ cancelPendingStructureVerification,
69
+ clipboardPasteRedoStackRef,
70
+ files,
71
+ getProjectionContentForScreen,
72
+ localhostConnectionRootPathByIdRef,
73
+ overviewScreens,
74
+ pendingLiveNonStyleRedoStackRef,
75
+ pendingStructureRedoReplayRef,
76
+ pendingStructureRedoReplayTimerRef,
77
+ pendingVisualStyleEditsRef,
78
+ pendingVisualStyleRedoStackRef,
79
+ pendingVisualStyleUndoStackRef,
80
+ responsiveEditScopeRef,
81
+ runtimeLayerSnapshotsById,
82
+ selectedElement,
83
+ setPatchProof,
84
+ setPendingVisualStyleEdits,
85
+ setSelectedElement,
86
+ setSelectedLayerIdsState,
87
+ }: RecordPendingVisualStyleEditArgs,
88
+ screenId: string,
89
+ selector: string,
90
+ styles: Record<string, string>,
91
+ elementInfo?: ElementInfo,
92
+ metadata?: {
93
+ originalStyles?: Record<string, string>;
94
+ interactionState?: InteractionState;
95
+ },
96
+ ) {
97
+ if (!canEditDesign) return;
98
+ const entries = Object.entries(styles).filter(
99
+ ([, value]) => value !== undefined,
100
+ );
101
+ if (entries.length === 0) return;
102
+ const stylePatch = Object.fromEntries(entries);
103
+ const screen = files.find((file) => file.id === screenId);
104
+ const fallbackName = screen?.filename ?? screenId;
105
+ const sourceId =
106
+ elementInfo?.sourceId ??
107
+ (screenId === activeFile?.id ? selectedElement?.sourceId : null);
108
+ // A localhost screen's live document and its source projection use
109
+ // different node-id namespaces, so the projection pair above cannot
110
+ // address the running DOM. Carry the runtime pair too or every undo
111
+ // replay silently resolves nothing (see runtimeStyleTarget).
112
+ const runtimeInfo =
113
+ elementInfo ?? (screenId === activeFile?.id ? selectedElement : null);
114
+ const proofId =
115
+ typeof crypto !== "undefined" && "randomUUID" in crypto
116
+ ? crypto.randomUUID()
117
+ : `${Date.now()}-${Math.random().toString(16).slice(2)}`;
118
+ const [firstProperty, firstValue] = entries[0];
119
+ const baseStyles = metadata?.interactionState
120
+ ? originalStylesForPendingVisualEdit(
121
+ stylePatch,
122
+ screenId === activeFile?.id ? selectedElement : null,
123
+ elementInfo,
124
+ )
125
+ : undefined;
126
+ const originalStyles = metadata?.interactionState
127
+ ? Object.fromEntries(entries.map(([property]) => [property, ""]))
128
+ : (metadata?.originalStyles ??
129
+ originalStylesForPendingVisualEdit(
130
+ stylePatch,
131
+ screenId === activeFile?.id ? selectedElement : null,
132
+ elementInfo,
133
+ ));
134
+ cancelPendingStructureVerification("conflict");
135
+ pendingVisualStyleRedoStackRef.current = [];
136
+ pendingLiveNonStyleRedoStackRef.current = [];
137
+ clipboardPasteRedoStackRef.current = [];
138
+ pendingStructureRedoReplayRef.current = undefined;
139
+ if (pendingStructureRedoReplayTimerRef.current !== undefined) {
140
+ window.clearTimeout(pendingStructureRedoReplayTimerRef.current);
141
+ pendingStructureRedoReplayTimerRef.current = undefined;
142
+ }
143
+ const nextEdit: PendingVisualStyleEdit = {
144
+ screenId,
145
+ filename: fallbackName,
146
+ screenName: prettyScreenName(fallbackName),
147
+ selector,
148
+ sourceId,
149
+ runtimeSelector: runtimeInfo?.runtimeSelector ?? null,
150
+ runtimeSourceId: runtimeInfo?.runtimeSourceId ?? null,
151
+ sourceAnchor: reactSourceAnchorForPendingEdit({
152
+ info: elementInfo,
153
+ id: sourceId ?? undefined,
154
+ rootPath: (() => {
155
+ const connectionId = overviewScreens.find(
156
+ (candidate) => candidate.id === screenId,
157
+ )?.connectionId;
158
+ return connectionId
159
+ ? localhostConnectionRootPathByIdRef.current.get(connectionId)
160
+ : undefined;
161
+ })(),
162
+ runtimeMultiplicity: runtimeMultiplicityForElementProvenance(
163
+ runtimeLayerSnapshotsById,
164
+ elementInfo,
165
+ ),
166
+ }),
167
+ tagName: elementInfo?.tagName ?? null,
168
+ classes: elementInfo?.classes ?? [],
169
+ styles: stylePatch,
170
+ originalStyles,
171
+ ...(metadata?.interactionState
172
+ ? { interactionState: metadata.interactionState, baseStyles }
173
+ : {}),
174
+ updatedAt: Date.now(),
175
+ // §6.4 — stamp the active breakpoint scope so the agent applies
176
+ // these as width-scoped overrides, not base writes.
177
+ ...(activeBreakpointWidthState != null
178
+ ? {
179
+ breakpoint: {
180
+ activeWidthPx: activeBreakpointWidthState,
181
+ upperBoundPx: activeBreakpointUpperBoundPx,
182
+ editScope: responsiveEditScopeRef.current,
183
+ },
184
+ }
185
+ : {}),
186
+ };
187
+ const revertStyles = pendingVisualStyleUndoRevertStyles(
188
+ pendingVisualStyleEditsRef.current,
189
+ nextEdit,
190
+ );
191
+ pendingVisualStyleUndoStackRef.current = [
192
+ ...pendingVisualStyleUndoStackRef.current.slice(
193
+ -(MAX_DESIGN_UNDO_STACK - 1),
194
+ ),
195
+ { edit: nextEdit, revertStyles },
196
+ ];
197
+ const nextPending = mergePendingVisualStyleEdits(
198
+ pendingVisualStyleUndoStackRef.current.map((entry) => entry.edit),
199
+ );
200
+ pendingVisualStyleEditsRef.current = nextPending;
201
+ setPendingVisualStyleEdits(nextPending);
202
+ setPatchProof({
203
+ id: proofId,
204
+ fileId: screenId,
205
+ filename: fallbackName,
206
+ selector,
207
+ sourceId: sourceId ?? undefined,
208
+ property:
209
+ entries.length === 1
210
+ ? firstProperty
211
+ : entries.map(([property]) => property).join(", "),
212
+ previousValue:
213
+ elementInfo?.computedStyles?.[firstProperty] ??
214
+ (screenId === activeFile?.id
215
+ ? selectedElement?.computedStyles?.[firstProperty]
216
+ : undefined),
217
+ nextValue:
218
+ entries.length === 1
219
+ ? firstValue
220
+ : entries
221
+ .map(([property, value]) => `${property}: ${value}`)
222
+ .join("; "),
223
+ previousContent: getProjectionContentForScreen(screenId),
224
+ capability: "deterministic-style-edit",
225
+ confidence: 0.92,
226
+ status: "runtime",
227
+ createdAt: Date.now(),
228
+ });
229
+
230
+ if (screenId !== activeFile?.id) return;
231
+ setSelectedElement((prev) => {
232
+ const base = elementInfo ?? prev;
233
+ if (!base) return prev;
234
+ return {
235
+ ...base,
236
+ sourceId: sourceId ?? base.sourceId,
237
+ selector: selector || base.selector,
238
+ computedStyles: {
239
+ ...base.computedStyles,
240
+ ...stylePatch,
241
+ },
242
+ };
243
+ });
244
+ if (sourceId) {
245
+ setSelectedLayerIdsState([sourceId]);
246
+ }
247
+ }