@agent-native/core 0.90.1 → 0.90.2
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/corpus/README.md +1 -1
- package/corpus/core/CHANGELOG.md +14 -0
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/client/AgentPanel.tsx +1 -1
- package/corpus/core/src/client/rich-markdown-editor/useCollabReconcile.ts +11 -6
- package/corpus/core/src/client/use-action.ts +39 -2
- package/corpus/core/src/client/use-db-sync.ts +44 -18
- package/corpus/core/src/db/create-get-db.ts +32 -2
- package/corpus/core/src/server/framework-request-handler.ts +52 -4
- package/corpus/templates/assets/.agents/skills/asset-generation/SKILL.md +5 -0
- package/corpus/templates/assets/.agents/skills/logo-composite/SKILL.md +34 -6
- package/corpus/templates/assets/AGENTS.md +23 -4
- package/corpus/templates/assets/actions/_generation-preset-settings.ts +48 -0
- package/corpus/templates/assets/actions/_helpers.ts +8 -1
- package/corpus/templates/assets/actions/_preset-skeleton-validation.ts +64 -0
- package/corpus/templates/assets/actions/create-generation-preset.ts +11 -3
- package/corpus/templates/assets/actions/generate-image-batch.ts +7 -2
- package/corpus/templates/assets/actions/generate-image.ts +342 -25
- package/corpus/templates/assets/actions/get-library.ts +4 -3
- package/corpus/templates/assets/actions/navigate.ts +2 -1
- package/corpus/templates/assets/actions/refresh-generation-run.ts +5 -1
- package/corpus/templates/assets/actions/update-asset.ts +1 -0
- package/corpus/templates/assets/actions/update-generation-preset.ts +8 -1
- package/corpus/templates/assets/actions/view-screen.ts +8 -1
- package/corpus/templates/assets/app/components/generation/GenerationResults.tsx +9 -1
- package/corpus/templates/assets/app/hooks/use-image-model-menu.ts +1 -0
- package/corpus/templates/assets/app/hooks/use-navigation-state.ts +11 -0
- package/corpus/templates/assets/app/i18n/zh-TW.ts +64 -0
- package/corpus/templates/assets/app/i18n-data.ts +650 -0
- package/corpus/templates/assets/app/routes/asset.$id.tsx +2 -1
- package/corpus/templates/assets/app/routes/brand-kits.$id.tsx +44 -33
- package/corpus/templates/assets/app/routes/brand-kits.$id_.presets.$presetId.tsx +1474 -0
- package/corpus/templates/assets/app/routes/library.tsx +43 -1
- package/corpus/templates/assets/server/lib/generation.ts +366 -44
- package/corpus/templates/assets/server/lib/image-processing.ts +252 -0
- package/corpus/templates/assets/server/lib/preset-skeleton.ts +137 -0
- package/corpus/templates/assets/shared/api.ts +47 -0
- package/corpus/templates/clips/app/components/library/library-layout.tsx +7 -2
- package/corpus/templates/clips/app/components/library/sort-menu.tsx +1 -1
- package/corpus/templates/clips/app/components/recorder/recorder-engine.ts +114 -33
- package/corpus/templates/clips/app/routes/_app.library._index.tsx +27 -1
- package/corpus/templates/clips/app/routes/record.tsx +157 -68
- package/corpus/templates/clips/server/routes/api/uploads/[recordingId]/abort.post.ts +5 -5
- package/corpus/templates/clips/server/routes/api/uploads/[recordingId]/chunk.post.ts +20 -3
- package/corpus/templates/clips/shared/finalize-recovery.ts +23 -3
- package/corpus/templates/content/AGENTS.md +52 -52
- package/corpus/templates/content/actions/_builder-cms-read-client.ts +188 -8
- package/corpus/templates/content/actions/_builder-docs-client.ts +41 -3
- package/corpus/templates/content/actions/_database-source-utils.ts +998 -160
- package/corpus/templates/content/actions/_database-utils.ts +44 -4
- package/corpus/templates/content/actions/_notion-action-utils.ts +6 -2
- package/corpus/templates/content/actions/add-content-database-source-field-property.ts +23 -1
- package/corpus/templates/content/actions/attach-content-database-source.ts +85 -12
- package/corpus/templates/content/actions/change-content-database-source-role.ts +9 -1
- package/corpus/templates/content/actions/delete-content-database.ts +1 -0
- package/corpus/templates/content/actions/get-document.ts +11 -2
- package/corpus/templates/content/actions/list-content-databases.ts +57 -9
- package/corpus/templates/content/actions/prepare-builder-source-review.ts +23 -6
- package/corpus/templates/content/actions/refresh-content-database-source.ts +26 -3
- package/corpus/templates/content/actions/restore-content-database.ts +1 -0
- package/corpus/templates/content/actions/update-document.ts +43 -0
- package/corpus/templates/content/app/components/editor/BuilderBodySyncingNotice.tsx +21 -0
- package/corpus/templates/content/app/components/editor/DocumentDatabase.tsx +0 -1
- package/corpus/templates/content/app/components/editor/DocumentEditor.tsx +70 -28
- package/corpus/templates/content/app/components/editor/DocumentProperties.tsx +69 -17
- package/corpus/templates/content/app/components/editor/VisualEditor.tsx +4 -4
- package/corpus/templates/content/app/components/editor/body-hydration.ts +112 -0
- package/corpus/templates/content/app/components/editor/builder-body-hydration-pump.ts +52 -0
- package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +9076 -2876
- package/corpus/templates/content/app/components/editor/database-sources/BuilderSourceReviewDialog.tsx +41 -1
- package/corpus/templates/content/app/components/editor/extensions/ImageBlock.tsx +36 -11
- package/corpus/templates/content/app/components/editor/previewDocumentSaveController.ts +21 -1
- package/corpus/templates/content/app/components/sidebar/DocumentSidebar.tsx +11 -1
- package/corpus/templates/content/app/components/sidebar/DocumentTreeItem.tsx +11 -8
- package/corpus/templates/content/app/global.css +41 -0
- package/corpus/templates/content/app/hooks/use-content-database.ts +346 -42
- package/corpus/templates/content/app/hooks/use-db-sync.ts +9 -0
- package/corpus/templates/content/app/hooks/use-documents.ts +47 -0
- package/corpus/templates/content/app/hooks/use-notion.ts +12 -10
- package/corpus/templates/content/app/i18n/zh-TW.ts +35 -0
- package/corpus/templates/content/app/i18n-data.ts +355 -0
- package/corpus/templates/content/app/root.tsx +22 -0
- package/corpus/templates/content/changelog/2026-07-01-builder-database-sources-keep-loading-rows-in-the-background.md +6 -0
- package/corpus/templates/content/changelog/2026-07-01-builder-source-attach-starts-with-usable-rows.md +6 -0
- package/corpus/templates/content/changelog/2026-07-01-builder-source-attachment-now-stays-connected-after-large.md +6 -0
- package/corpus/templates/content/changelog/2026-07-01-builder-source-refreshes-now-show-progress-for-large-docs-blog.md +6 -0
- package/corpus/templates/content/changelog/2026-07-01-database-pages-now-delete-to-trash-without-route-errors.md +6 -0
- package/corpus/templates/content/changelog/2026-07-02-builder-source-refreshes-recover-from-stalled-background-row.md +6 -0
- package/corpus/templates/content/changelog/2026-07-02-builder-sourced-rows-open-with-sync-protection.md +6 -0
- package/corpus/templates/content/changelog/2026-07-02-database-rows-and-pages-open-faster-from-recently-loaded-dat.md +6 -0
- package/corpus/templates/content/changelog/2026-07-02-preview-panels-close-reliably-narrow-sidebar-row-actions-sta.md +6 -0
- package/corpus/templates/content/changelog/2026-07-06-builder-sync-progress-no-longer-shows-continue.md +6 -0
- package/corpus/templates/content/shared/api.ts +13 -0
- package/corpus/templates/content/shared/builder-mdx.ts +16 -3
- package/corpus/templates/design/.agents/skills/design-generation/SKILL.md +23 -13
- package/corpus/templates/design/.agents/skills/responsive-breakpoints/SKILL.md +98 -0
- package/corpus/templates/design/.agents/skills/shader-fills/SKILL.md +162 -0
- package/corpus/templates/design/AGENTS.md +9 -2
- package/corpus/templates/design/actions/add-breakpoint.ts +6 -3
- package/corpus/templates/design/actions/apply-a11y-fix.ts +57 -37
- package/corpus/templates/design/actions/apply-component-prop-edit.ts +41 -20
- package/corpus/templates/design/actions/apply-motion-edit.ts +251 -38
- package/corpus/templates/design/actions/apply-shader-fill.ts +90 -66
- package/corpus/templates/design/actions/apply-visual-edit.ts +282 -55
- package/corpus/templates/design/actions/create-component.ts +29 -60
- package/corpus/templates/design/actions/create-file.ts +9 -2
- package/corpus/templates/design/actions/duplicate-design.ts +31 -2
- package/corpus/templates/design/actions/edit-design.ts +36 -38
- package/corpus/templates/design/actions/generate-design-title.ts +87 -0
- package/corpus/templates/design/actions/generate-design.ts +53 -18
- package/corpus/templates/design/actions/generate-screens.ts +108 -4
- package/corpus/templates/design/actions/get-motion-timeline.ts +35 -7
- package/corpus/templates/design/actions/insert-asset.ts +34 -29
- package/corpus/templates/design/actions/insert-design-native-asset.ts +129 -32
- package/corpus/templates/design/actions/insert-figma-library-asset.ts +35 -30
- package/corpus/templates/design/actions/present-design-variants.ts +7 -2
- package/corpus/templates/design/actions/remove-motion-timeline.ts +31 -36
- package/corpus/templates/design/actions/update-file.ts +190 -75
- package/corpus/templates/design/app/components/design/BreakpointBar.tsx +403 -0
- package/corpus/templates/design/app/components/design/CanvasContextMenu.tsx +469 -222
- package/corpus/templates/design/app/components/design/DesignCanvas.tsx +708 -53
- package/corpus/templates/design/app/components/design/DesignExtensionsPanel.tsx +83 -3
- package/corpus/templates/design/app/components/design/EditPanel.tsx +1091 -6948
- package/corpus/templates/design/app/components/design/LayersPanel.tsx +419 -85
- package/corpus/templates/design/app/components/design/MotionDock.tsx +1124 -103
- package/corpus/templates/design/app/components/design/MultiScreenCanvas.tsx +2610 -1398
- package/corpus/templates/design/app/components/design/ReadOnlyDesignBanner.tsx +22 -0
- package/corpus/templates/design/app/components/design/bridge/editor-chrome.bridge.ts +2182 -235
- package/corpus/templates/design/app/components/design/bridge/motion-preview.bridge.ts +187 -11
- package/corpus/templates/design/app/components/design/bridge/shader-fill-preview.bridge.ts +376 -1
- package/corpus/templates/design/app/components/design/bridge/shader-runtime.bridge.ts +746 -0
- package/corpus/templates/design/app/components/design/canvas-primitive-style.ts +17 -0
- package/corpus/templates/design/app/components/design/code-workbench/SideBar.tsx +1 -1
- package/corpus/templates/design/app/components/design/code-workbench/explorer/FileTree.tsx +1 -3
- package/corpus/templates/design/app/components/design/code-workbench/quickinput/QuickInput.tsx +1 -1
- package/corpus/templates/design/app/components/design/edit-panel/appearance-properties.tsx +518 -0
- package/corpus/templates/design/app/components/design/edit-panel/code-inspect-helpers.tsx +562 -0
- package/corpus/templates/design/app/components/design/edit-panel/component-section.tsx +763 -0
- package/corpus/templates/design/app/components/design/edit-panel/document-colors.ts +94 -0
- package/corpus/templates/design/app/components/design/edit-panel/effects-properties.tsx +780 -0
- package/corpus/templates/design/app/components/design/edit-panel/element-classification.ts +446 -0
- package/corpus/templates/design/app/components/design/edit-panel/element-identity.ts +79 -0
- package/corpus/templates/design/app/components/design/edit-panel/field-primitives.tsx +315 -0
- package/corpus/templates/design/app/components/design/edit-panel/fill-gradient-helpers.ts +344 -0
- package/corpus/templates/design/app/components/design/edit-panel/fill-properties.tsx +594 -0
- package/corpus/templates/design/app/components/design/edit-panel/frame-presets-panel.tsx +119 -0
- package/corpus/templates/design/app/components/design/edit-panel/inspector-controls.tsx +248 -0
- package/corpus/templates/design/app/components/design/edit-panel/interaction-state-helpers.ts +45 -0
- package/corpus/templates/design/app/components/design/edit-panel/layout-properties.tsx +693 -0
- package/corpus/templates/design/app/components/design/edit-panel/panel-primitives.tsx +724 -0
- package/corpus/templates/design/app/components/design/edit-panel/position-helpers.ts +207 -0
- package/corpus/templates/design/app/components/design/edit-panel/position-layout-properties.tsx +628 -0
- package/corpus/templates/design/app/components/design/edit-panel/selection-helpers.ts +91 -0
- package/corpus/templates/design/app/components/design/edit-panel/stroke-properties.tsx +649 -0
- package/corpus/templates/design/app/components/design/edit-panel/style-change-types.ts +118 -0
- package/corpus/templates/design/app/components/design/edit-panel/style-options.ts +88 -0
- package/corpus/templates/design/app/components/design/edit-panel/transform-helpers.ts +100 -0
- package/corpus/templates/design/app/components/design/edit-panel/typography-helpers.ts +117 -0
- package/corpus/templates/design/app/components/design/edit-panel/typography-properties.tsx +501 -0
- package/corpus/templates/design/app/components/design/inspector/AutoLayoutMatrix.tsx +91 -40
- package/corpus/templates/design/app/components/design/inspector/BreakpointOverrideIndicator.tsx +82 -0
- package/corpus/templates/design/app/components/design/inspector/DesignColorPicker.tsx +189 -87
- package/corpus/templates/design/app/components/design/inspector/GlslShaderPanel.tsx +1097 -0
- package/corpus/templates/design/app/components/design/inspector/GradientEditor.tsx +44 -0
- package/corpus/templates/design/app/components/design/inspector/InteractionStatePanel.tsx +258 -0
- package/corpus/templates/design/app/components/design/inspector/MotionKeyframeDiamond.tsx +144 -0
- package/corpus/templates/design/app/components/design/inspector/ScrubInput.tsx +99 -9
- package/corpus/templates/design/app/components/design/inspector/frame-size-presets.ts +116 -0
- package/corpus/templates/design/app/components/design/inspector/index.ts +26 -0
- package/corpus/templates/design/app/components/design/inspector/scrub-input-utils.ts +29 -0
- package/corpus/templates/design/app/components/design/multi-screen/alt-hover-measurement.ts +171 -0
- package/corpus/templates/design/app/components/design/multi-screen/board-surface-html.ts +220 -0
- package/corpus/templates/design/app/components/design/multi-screen/chrome-transitions.ts +35 -0
- package/corpus/templates/design/app/components/design/multi-screen/cross-screen-drop.ts +134 -0
- package/corpus/templates/design/app/components/design/multi-screen/culling.ts +185 -0
- package/corpus/templates/design/app/components/design/multi-screen/gradient-overlay-geometry.ts +120 -0
- package/corpus/templates/design/app/components/design/multi-screen/types.ts +892 -0
- package/corpus/templates/design/app/components/design/multi-screen/vector-edit-geometry.ts +21 -0
- package/corpus/templates/design/app/components/design/types.ts +15 -0
- package/corpus/templates/design/app/components/editor/PromptDialog.tsx +109 -5
- package/corpus/templates/design/app/global.css +8 -8
- package/corpus/templates/design/app/hooks/useDesignHotkeys.ts +259 -2
- package/corpus/templates/design/app/i18n/zh-TW.ts +163 -9
- package/corpus/templates/design/app/i18n-breakpoints.ts +205 -0
- package/corpus/templates/design/app/i18n-data.ts +1664 -152
- package/corpus/templates/design/app/i18n-motion.ts +563 -0
- package/corpus/templates/design/app/lib/design-import.ts +73 -0
- package/corpus/templates/design/app/pages/Index.tsx +41 -22
- package/corpus/templates/design/changelog/2026-06-29-design-inspector-controls-now-match-figmas-softer-dark-chrome.md +1 -1
- package/corpus/templates/design/changelog/2026-06-30-design-now-has-a-figma-style-left-rail-for-file-agent-assets.md +1 -1
- package/corpus/templates/design/changelog/2026-06-30-design-tools-now-use-a-quieter-figma-style-list-layout.md +1 -1
- package/corpus/templates/design/changelog/2026-06-30-multi-select-outlines-now-stay-consistent-across-all-screens.md +1 -1
- package/corpus/templates/design/changelog/2026-07-03-canvas-interactions-now-match-figma-rotation-aware-resizing-.md +1 -1
- package/corpus/templates/design/changelog/2026-07-03-layers-panel-matches-figma-top-layer-on-top-drag-with-auto-s.md +1 -1
- package/corpus/templates/design/changelog/2026-07-05-designs-get-ai-generated-names-from-your-prompt.md +6 -0
- package/corpus/templates/design/changelog/2026-07-05-local-code-screens-keep-their-connection-when-duplicated-and.md +6 -0
- package/corpus/templates/design/changelog/2026-07-05-press-a-to-draw-screens-on-the-canvas-inside-a-screen-it-dr.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-3d-rotation-and-perspective-controls-on-every-element.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-ai-generated-and-duplicated-screens-now-get-their-editor-sel.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-applying-shaders-and-fills-in-quick-succession-can-no-longer.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-breakpoint-frames-in-the-overview-now-support-click-to-selec.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-breakpoint-segments-in-the-inspector-now-show-a-device-icon-.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-breakpoint-targeting-now-lives-in-one-compact-control-in-the.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-canvas-edits-can-no-longer-be-overwritten-by-stale-collabora.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-canvas-edits-inside-screens-save-reliably-again.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-cleaner-inspector-removed-the-ask-ai-box-from-the-design-tab.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-clicking-empty-canvas-space-now-deselects-an-element-inside-.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-dragging-an-element-onto-a-rectangle-now-nests-it-inside-wit.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-dragging-screens-and-objects-on-the-canvas-is-now-much-smoot.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-drawing-a-shape-or-text-on-the-canvas-no-longer-flashes-away.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-dropping-an-element-between-two-others-inside-a-screen-now-s.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-duplicating-a-screen-now-places-the-copy-exactly-where-you-d.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-edit-gradients-directly-on-elements-inside-screens-scale-str.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-edits-from-collaborators-and-the-agent-now-update-the-canvas.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-fixed-a-bug-where-most-style-position-and-text-edits-briefly.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-fixed-a-confusing-raw-error-message-when-a-file-upload-fails.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-fixed-a-rare-case-where-an-edit-could-be-silently-overwritte.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-fixed-inserted-assets-sometimes-disappearing-reappearing-or-.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-fixed-inspector-value-scrubbing-producing-erratic-numbers-an.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-fixed-padding-gap-and-min-max-size-scrubbing-not-updating-th.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-fixed-text-stroke-color-turning-black-and-glyphs-disappearin.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-fixed-the-collapsed-effects-and-stroke-inspector-sections-sh.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-fixed-the-new-design-dialog-closing-unexpectedly-when-using-.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-fixed-the-typography-section-missing-when-selecting-text-nes.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-full-view-no-longer-flashes-back-to-the-overview-on-entry-no.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-keyframe-animation-timeline-per-property-keyframes-easing-cu.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-moving-restyling-and-scrubbing-values-on-elements-in-ai-gene.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-padding-and-corner-radius-value-scrubbing-now-snaps-to-whole.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-padding-handles-now-only-resize-on-the-handle-line-itself-sh.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-preview-and-edit-hover-focus-and-pressed-states-with-real-cs.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-promoting-an-element-to-a-component-now-works-correctly-for-.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-reduced-url-history-churn-and-selection-overlay-flicker-whil.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-removed-the-decorative-dot-before-screen-names-in-the-overvi.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-responsive-breakpoints-edit-at-any-width-with-cascading-over.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-screen-labels-no-longer-turn-blue-when-you-hover-inside-the-.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-scrolling-a-screen-with-an-element-selected-stays-smooth-on-.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-selecting-multiple-elements-and-dragging-now-moves-the-whole.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-selection-borders-handles-and-value-readouts-now-stay-the-sa.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-selection-handles-and-editing-chrome-now-stay-a-constant-siz.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-shader-fills-and-effects-ai-authored-or-preset-glsl-shaders-.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-text-drawn-on-the-canvas-now-defaults-to-white-and-inter-in-.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-text-dropped-into-a-shape-now-stays-readable-instead-of-disa.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-the-add-tweak-controls-prompt-no-longer-jumps-to-the-corner-.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-the-padding-value-readout-now-stays-visible-while-you-hover-.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-the-selected-element-attachment-now-clears-from-the-chat-com.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-the-zoom-menu-is-more-compact-with-tight-rows-and-right-alig.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-undo-and-redo-no-longer-flash-the-screen-changes-now-apply-i.md +6 -0
- package/corpus/templates/design/changelog/2026-07-06-zoom-presets-like-zoom-to-50-now-stay-on-the-focused-screen-.md +6 -0
- package/corpus/templates/design/server/lib/import-design-files.ts +11 -2
- package/corpus/templates/design/server/source-workspace.ts +139 -59
- package/corpus/templates/design/shared/board-file.ts +11 -2
- package/corpus/templates/design/shared/breakpoint-media.ts +543 -0
- package/corpus/templates/design/shared/canvas-math.ts +354 -35
- package/corpus/templates/design/shared/code-layer.ts +277 -8
- package/corpus/templates/design/shared/design-state.ts +11 -4
- package/corpus/templates/design/shared/interaction-states.ts +548 -0
- package/corpus/templates/design/shared/motion-compiler.ts +186 -23
- package/corpus/templates/design/shared/motion-easing.ts +294 -0
- package/corpus/templates/design/shared/motion-timeline.ts +400 -34
- package/corpus/templates/design/shared/prompt-title.ts +95 -0
- package/corpus/templates/design/shared/responsive-classes.ts +448 -10
- package/corpus/templates/design/shared/screen-annotation.ts +46 -0
- package/corpus/templates/design/shared/shader-fills.ts +1009 -0
- package/corpus/templates/design/shared/shader-presets.ts +852 -4
- package/corpus/templates/slides/app/components/editor/EditorToolbar.tsx +15 -2
- package/corpus/templates/slides/app/components/editor/ImportButton.tsx +10 -1
- package/corpus/templates/slides/app/lib/upload-response.ts +71 -0
- package/dist/client/AgentPanel.js +1 -1
- package/dist/client/AgentPanel.js.map +1 -1
- package/dist/client/rich-markdown-editor/useCollabReconcile.d.ts.map +1 -1
- package/dist/client/rich-markdown-editor/useCollabReconcile.js +11 -6
- package/dist/client/rich-markdown-editor/useCollabReconcile.js.map +1 -1
- package/dist/client/use-action.d.ts +3 -0
- package/dist/client/use-action.d.ts.map +1 -1
- package/dist/client/use-action.js +34 -3
- package/dist/client/use-action.js.map +1 -1
- package/dist/client/use-db-sync.d.ts +4 -0
- package/dist/client/use-db-sync.d.ts.map +1 -1
- package/dist/client/use-db-sync.js +37 -18
- package/dist/client/use-db-sync.js.map +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/db/create-get-db.d.ts +25 -0
- package/dist/db/create-get-db.d.ts.map +1 -1
- package/dist/db/create-get-db.js +25 -2
- package/dist/db/create-get-db.js.map +1 -1
- package/dist/observability/routes.d.ts +3 -3
- package/dist/secrets/routes.d.ts +9 -9
- package/dist/server/framework-request-handler.d.ts.map +1 -1
- package/dist/server/framework-request-handler.js +37 -1
- package/dist/server/framework-request-handler.js.map +1 -1
- package/package.json +1 -1
- package/corpus/templates/design/app/components/design/inspector/InspectorAiActions.tsx +0 -153
- package/corpus/templates/design/app/hooks/useAgentEditRequest.ts +0 -133
- package/corpus/templates/design/app/pages/DesignEditor.tsx +0 -22924
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { defineAction } from "@agent-native/core";
|
|
2
2
|
import { readAppStateForCurrentTab } from "@agent-native/core/application-state";
|
|
3
|
-
import {
|
|
4
|
-
applyText,
|
|
5
|
-
getText,
|
|
6
|
-
hasCollabState,
|
|
7
|
-
seedFromText,
|
|
8
|
-
} from "@agent-native/core/collab";
|
|
9
3
|
import { accessFilter, assertAccess } from "@agent-native/core/sharing";
|
|
10
4
|
import { and, eq } from "drizzle-orm";
|
|
11
5
|
import { z } from "zod";
|
|
12
6
|
|
|
13
7
|
import { getDb, schema } from "../server/db/index.js";
|
|
8
|
+
import {
|
|
9
|
+
readLiveSourceFile,
|
|
10
|
+
writeInlineSourceFile,
|
|
11
|
+
type SourceWorkspaceFile,
|
|
12
|
+
} from "../server/source-workspace.js";
|
|
14
13
|
import {
|
|
15
14
|
DESIGN_NATIVE_ASSET_KINDS,
|
|
16
15
|
type DesignNativeAssetKind,
|
|
@@ -27,11 +26,31 @@ const schemaInput = z.object({
|
|
|
27
26
|
fileId: z
|
|
28
27
|
.string()
|
|
29
28
|
.optional()
|
|
30
|
-
.describe(
|
|
29
|
+
.describe(
|
|
30
|
+
"Design file id to insert into. Defaults to the active editor file. Also used as the fallback target when screenId is omitted or does not resolve.",
|
|
31
|
+
),
|
|
32
|
+
screenId: z
|
|
33
|
+
.string()
|
|
34
|
+
.optional()
|
|
35
|
+
.describe(
|
|
36
|
+
"Screen/design-file id to insert into, when it differs from the currently active editor file (e.g. a drop captured on a non-active screen in overview mode). Falls back to fileId, then the active editor file, when omitted or unresolvable.",
|
|
37
|
+
),
|
|
31
38
|
ownerId: z
|
|
32
39
|
.string()
|
|
33
40
|
.optional()
|
|
34
41
|
.describe("Design editor selection owner token from current screen state."),
|
|
42
|
+
x: z
|
|
43
|
+
.number()
|
|
44
|
+
.optional()
|
|
45
|
+
.describe(
|
|
46
|
+
"Drop position x, in the target screen's own content px (same coordinate space as committed canvas-primitive geometry — NOT viewport/client px). Optional; when omitted (or when y is omitted), the asset appends before </main>/</body> exactly as before this parameter existed.",
|
|
47
|
+
),
|
|
48
|
+
y: z
|
|
49
|
+
.number()
|
|
50
|
+
.optional()
|
|
51
|
+
.describe(
|
|
52
|
+
"Drop position y, in the target screen's own content px. See x for the coordinate-space contract. Both x and y must be provided together for positioned insertion to take effect.",
|
|
53
|
+
),
|
|
35
54
|
});
|
|
36
55
|
|
|
37
56
|
function stringFromState(state: unknown, key: string): string | undefined {
|
|
@@ -50,6 +69,49 @@ function insertBeforeClosingTag(
|
|
|
50
69
|
return html.replace(pattern, `${snippet}\n</${closingTag}>`);
|
|
51
70
|
}
|
|
52
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Whether a caller-supplied drop position should drive positioned insertion.
|
|
74
|
+
* Both x and y must be finite and non-negative — matching
|
|
75
|
+
* appendCanvasPrimitiveToHtml's own `Math.max(0, Math.round(geometry.x))`
|
|
76
|
+
* clamp for committed canvas primitives (MultiScreenCanvas.tsx /
|
|
77
|
+
* DesignEditor.tsx, not touched by this change) — so a caller that can only
|
|
78
|
+
* produce a raw/unconvertible point (see DesignExtensionsPanel's
|
|
79
|
+
* documented fallback contract) safely falls through to the exact
|
|
80
|
+
* append-before-closing-tag behavior this action always had.
|
|
81
|
+
*/
|
|
82
|
+
function isUsableDropPosition(
|
|
83
|
+
x: number | undefined,
|
|
84
|
+
y: number | undefined,
|
|
85
|
+
): x is number {
|
|
86
|
+
return (
|
|
87
|
+
typeof x === "number" &&
|
|
88
|
+
typeof y === "number" &&
|
|
89
|
+
Number.isFinite(x) &&
|
|
90
|
+
Number.isFinite(y) &&
|
|
91
|
+
x >= 0 &&
|
|
92
|
+
y >= 0
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Wraps `snippet` in an absolutely-positioned container at `{x, y}`, in the
|
|
98
|
+
* same coordinate space and CSS convention `appendCanvasPrimitiveToHtml` uses
|
|
99
|
+
* for committed canvas primitives (DesignEditor.tsx, not modified by this
|
|
100
|
+
* change): `position:absolute; left:{x}px; top:{y}px`. A wrapping `<div>`
|
|
101
|
+
* (rather than trying to graft a style attribute onto whichever element in
|
|
102
|
+
* `snippet` happens to carry `data-agent-native-node-id` — that element
|
|
103
|
+
* varies by kind, e.g. "button"/"card" put it on an inner element, not the
|
|
104
|
+
* outer section) keeps this correct regardless of the native asset kind's
|
|
105
|
+
* own markup shape. The wrapper carries no size, so the snippet's own
|
|
106
|
+
* classes (`max-w-*`, `mx-auto`, etc.) keep controlling its box — only its
|
|
107
|
+
* top-left anchor point moves.
|
|
108
|
+
*/
|
|
109
|
+
function positionSnippetAt(snippet: string, x: number, y: number): string {
|
|
110
|
+
const left = Math.round(x);
|
|
111
|
+
const top = Math.round(y);
|
|
112
|
+
return `\n <div data-agent-native-positioned-wrapper style="position:absolute;left:${left}px;top:${top}px;">${snippet}\n </div>`;
|
|
113
|
+
}
|
|
114
|
+
|
|
53
115
|
function createInsertedNodeId(prefix: string): string {
|
|
54
116
|
const random =
|
|
55
117
|
typeof crypto !== "undefined" && typeof crypto.randomUUID === "function"
|
|
@@ -142,12 +204,25 @@ function nativeSnippet(kind: DesignNativeAssetKind, nodeId: string): string {
|
|
|
142
204
|
}
|
|
143
205
|
}
|
|
144
206
|
|
|
207
|
+
/**
|
|
208
|
+
* Inserts a native-asset snippet into `html`. When `position` is provided
|
|
209
|
+
* (both x and y finite/non-negative — see isUsableDropPosition), the snippet
|
|
210
|
+
* is wrapped in an absolutely-positioned container anchored at that point
|
|
211
|
+
* (positionSnippetAt), matching how appendCanvasPrimitiveToHtml positions
|
|
212
|
+
* committed canvas primitives. Without a usable position, behavior is
|
|
213
|
+
* UNCHANGED from before this parameter existed: append before </main>/</body>
|
|
214
|
+
* (or at the end of the document as a last resort).
|
|
215
|
+
*/
|
|
145
216
|
function appendNativeAssetMarkup(
|
|
146
217
|
html: string,
|
|
147
218
|
kind: DesignNativeAssetKind,
|
|
148
219
|
nodeId: string,
|
|
220
|
+
position?: { x: number; y: number },
|
|
149
221
|
): string {
|
|
150
|
-
const
|
|
222
|
+
const rawSnippet = nativeSnippet(kind, nodeId);
|
|
223
|
+
const snippet = position
|
|
224
|
+
? positionSnippetAt(rawSnippet, position.x, position.y)
|
|
225
|
+
: rawSnippet;
|
|
151
226
|
return (
|
|
152
227
|
insertBeforeClosingTag(html, "main", snippet) ??
|
|
153
228
|
insertBeforeClosingTag(html, "body", snippet) ??
|
|
@@ -179,7 +254,14 @@ async function resolveTarget(args: z.infer<typeof schemaInput>) {
|
|
|
179
254
|
: undefined;
|
|
180
255
|
return {
|
|
181
256
|
designId,
|
|
257
|
+
// screenId (when the caller resolved a specific drop-target screen, e.g.
|
|
258
|
+
// a drop captured on a non-active overview screen) wins over fileId, but
|
|
259
|
+
// both are just candidates here — the run() below still validates the
|
|
260
|
+
// resolved id is an actual HTML file in this design and falls back to
|
|
261
|
+
// fileId/the active file exactly as before if it isn't (see the
|
|
262
|
+
// requestedFileId lookup in run()).
|
|
182
263
|
fileId:
|
|
264
|
+
args.screenId ??
|
|
183
265
|
args.fileId ??
|
|
184
266
|
(canUseSelection
|
|
185
267
|
? stringFromState(selection, "activeFileId")
|
|
@@ -238,33 +320,47 @@ export default defineAction({
|
|
|
238
320
|
if (!file) throw new Error("No editable HTML design file found.");
|
|
239
321
|
await assertAccess("design", file.designId, "editor");
|
|
240
322
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
323
|
+
// Read the LIVE base (collab text when present, else the SQL row) right
|
|
324
|
+
// before transforming, and carry its versionHash through to the write
|
|
325
|
+
// below. writeInlineSourceFile re-reads the live text immediately before
|
|
326
|
+
// its own applyText/DB write and rejects if it no longer matches this
|
|
327
|
+
// hash — closing the race window where a concurrent editor/agent write
|
|
328
|
+
// lands between this read and the persist (the same stale-diff-base bug
|
|
329
|
+
// fixed for update-file: a diff computed from a stale base, char-diffed
|
|
330
|
+
// into a collab doc that has since moved on, corrupts or drops the
|
|
331
|
+
// other writer's change). See update-file.ts and apply-source-edit.ts
|
|
332
|
+
// for the identical pattern. writeInlineSourceFile/readLiveSourceFile
|
|
333
|
+
// only ever dereference file.id (and content/filename for the read); the
|
|
334
|
+
// createdAt/updatedAt fields aren't selected above and aren't needed.
|
|
335
|
+
const workspaceFile: SourceWorkspaceFile = {
|
|
336
|
+
id: file.id,
|
|
337
|
+
designId: file.designId,
|
|
338
|
+
filename: file.filename ?? "",
|
|
339
|
+
fileType: file.fileType ?? "html",
|
|
340
|
+
content: file.content,
|
|
341
|
+
createdAt: null,
|
|
342
|
+
updatedAt: null,
|
|
343
|
+
};
|
|
344
|
+
const live = await readLiveSourceFile(workspaceFile);
|
|
345
|
+
const base = live.content;
|
|
250
346
|
|
|
251
347
|
const insertedNodeId = createInsertedNodeId("native");
|
|
252
|
-
const
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
.
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
.where(eq(schema.designs.id, file.designId));
|
|
348
|
+
const position = isUsableDropPosition(args.x, args.y)
|
|
349
|
+
? { x: args.x, y: args.y as number }
|
|
350
|
+
: undefined;
|
|
351
|
+
const content = appendNativeAssetMarkup(
|
|
352
|
+
base,
|
|
353
|
+
args.kind,
|
|
354
|
+
insertedNodeId,
|
|
355
|
+
position,
|
|
356
|
+
);
|
|
262
357
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
358
|
+
await writeInlineSourceFile({
|
|
359
|
+
designId: file.designId,
|
|
360
|
+
file: workspaceFile,
|
|
361
|
+
content,
|
|
362
|
+
expectedVersionHash: live.versionHash,
|
|
363
|
+
});
|
|
268
364
|
|
|
269
365
|
return {
|
|
270
366
|
designId: file.designId,
|
|
@@ -275,6 +371,7 @@ export default defineAction({
|
|
|
275
371
|
insertedSelector: `[data-agent-native-node-id="${insertedNodeId}"]`,
|
|
276
372
|
source: "design-native",
|
|
277
373
|
kind: args.kind,
|
|
374
|
+
positioned: Boolean(position),
|
|
278
375
|
};
|
|
279
376
|
},
|
|
280
377
|
});
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { defineAction } from "@agent-native/core";
|
|
2
2
|
import { readAppStateForCurrentTab } from "@agent-native/core/application-state";
|
|
3
|
-
import {
|
|
4
|
-
applyText,
|
|
5
|
-
getText,
|
|
6
|
-
hasCollabState,
|
|
7
|
-
seedFromText,
|
|
8
|
-
} from "@agent-native/core/collab";
|
|
9
3
|
import { accessFilter, assertAccess } from "@agent-native/core/sharing";
|
|
10
4
|
import { and, eq } from "drizzle-orm";
|
|
11
5
|
import { z } from "zod";
|
|
12
6
|
|
|
13
7
|
import { getDb, schema } from "../server/db/index.js";
|
|
8
|
+
import {
|
|
9
|
+
readLiveSourceFile,
|
|
10
|
+
writeInlineSourceFile,
|
|
11
|
+
type SourceWorkspaceFile,
|
|
12
|
+
} from "../server/source-workspace.js";
|
|
14
13
|
|
|
15
14
|
const schemaInput = z.object({
|
|
16
15
|
renderUrl: z
|
|
@@ -200,33 +199,39 @@ export default defineAction({
|
|
|
200
199
|
if (!file) throw new Error("No editable HTML design file found.");
|
|
201
200
|
await assertAccess("design", file.designId, "editor");
|
|
202
201
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
202
|
+
// Read the LIVE base (collab text when present, else the SQL row) right
|
|
203
|
+
// before transforming, and carry its versionHash through to the write
|
|
204
|
+
// below. writeInlineSourceFile re-reads the live text immediately before
|
|
205
|
+
// its own applyText/DB write and rejects if it no longer matches this
|
|
206
|
+
// hash — closing the race window where a concurrent editor/agent write
|
|
207
|
+
// lands between this read and the persist (the same stale-diff-base bug
|
|
208
|
+
// fixed for update-file: a diff computed from a stale base, char-diffed
|
|
209
|
+
// into a collab doc that has since moved on, corrupts or drops the
|
|
210
|
+
// other writer's change). See update-file.ts and apply-source-edit.ts
|
|
211
|
+
// for the identical pattern. writeInlineSourceFile/readLiveSourceFile
|
|
212
|
+
// only ever dereference file.id (and content/filename for the read); the
|
|
213
|
+
// createdAt/updatedAt fields aren't selected above and aren't needed.
|
|
214
|
+
const workspaceFile: SourceWorkspaceFile = {
|
|
215
|
+
id: file.id,
|
|
216
|
+
designId: file.designId,
|
|
217
|
+
filename: file.filename ?? "",
|
|
218
|
+
fileType: file.fileType ?? "html",
|
|
219
|
+
content: file.content,
|
|
220
|
+
createdAt: null,
|
|
221
|
+
updatedAt: null,
|
|
222
|
+
};
|
|
223
|
+
const live = await readLiveSourceFile(workspaceFile);
|
|
224
|
+
const base = live.content;
|
|
212
225
|
|
|
213
226
|
const insertedNodeId = createInsertedNodeId("figma");
|
|
214
227
|
const content = appendFigmaAssetMarkup(base, args, insertedNodeId);
|
|
215
|
-
|
|
216
|
-
await
|
|
217
|
-
.
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
.set({ updatedAt: now })
|
|
223
|
-
.where(eq(schema.designs.id, file.designId));
|
|
224
|
-
|
|
225
|
-
if (await hasCollabState(file.id)) {
|
|
226
|
-
await applyText(file.id, content, "content", "agent");
|
|
227
|
-
} else {
|
|
228
|
-
await seedFromText(file.id, content);
|
|
229
|
-
}
|
|
228
|
+
|
|
229
|
+
await writeInlineSourceFile({
|
|
230
|
+
designId: file.designId,
|
|
231
|
+
file: workspaceFile,
|
|
232
|
+
content,
|
|
233
|
+
expectedVersionHash: live.versionHash,
|
|
234
|
+
});
|
|
230
235
|
|
|
231
236
|
return {
|
|
232
237
|
designId: file.designId,
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
mergeCanvasFramePlacements,
|
|
18
18
|
type CanvasFramePlacement,
|
|
19
19
|
} from "../shared/canvas-frames.js";
|
|
20
|
+
import { annotateScreenHtmlForPersist } from "../shared/screen-annotation.js";
|
|
20
21
|
|
|
21
22
|
const VARIANT_GAP = 96;
|
|
22
23
|
const MAX_COLUMNS = 3;
|
|
@@ -493,12 +494,16 @@ export default defineAction({
|
|
|
493
494
|
const fileId = nanoid();
|
|
494
495
|
const providedContent = variant.content?.trim();
|
|
495
496
|
const initialSize = inferVariantSize(variant, prompt);
|
|
496
|
-
const
|
|
497
|
+
const rawContent =
|
|
497
498
|
providedContent ||
|
|
498
499
|
fallbackVariantContent(variant, index, prompt, initialSize);
|
|
499
500
|
const { width, height } = providedContent
|
|
500
|
-
? inferVariantSize({ ...variant, content })
|
|
501
|
+
? inferVariantSize({ ...variant, content: rawContent })
|
|
501
502
|
: initialSize;
|
|
503
|
+
// Stamp missing data-agent-native-node-id attributes before persisting
|
|
504
|
+
// so each variant screen is fully addressable by id-keyed editor
|
|
505
|
+
// operations as soon as it lands on the overview board.
|
|
506
|
+
const content = annotateScreenHtmlForPersist(rawContent, "html");
|
|
502
507
|
|
|
503
508
|
await db.insert(schema.designFiles).values({
|
|
504
509
|
id: fileId,
|
|
@@ -14,10 +14,6 @@ import { defineAction } from "@agent-native/core";
|
|
|
14
14
|
import {
|
|
15
15
|
agentEnterDocument,
|
|
16
16
|
agentLeaveDocument,
|
|
17
|
-
applyText,
|
|
18
|
-
getText,
|
|
19
|
-
hasCollabState,
|
|
20
|
-
seedFromText,
|
|
21
17
|
} from "@agent-native/core/collab";
|
|
22
18
|
import { accessFilter, assertAccess } from "@agent-native/core/sharing";
|
|
23
19
|
import { and, eq } from "drizzle-orm";
|
|
@@ -25,6 +21,11 @@ import { z } from "zod";
|
|
|
25
21
|
|
|
26
22
|
import { getDb, schema } from "../server/db/index.js";
|
|
27
23
|
import "../server/db/index.js"; // ensure registerShareableResource runs
|
|
24
|
+
import {
|
|
25
|
+
readLiveSourceFile,
|
|
26
|
+
writeInlineSourceFile,
|
|
27
|
+
type SourceWorkspaceFile,
|
|
28
|
+
} from "../server/source-workspace.js";
|
|
28
29
|
|
|
29
30
|
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
|
30
31
|
|
|
@@ -45,21 +46,6 @@ function removeMotionStyleBlock(html: string): string {
|
|
|
45
46
|
return html.slice(0, openIdx) + html.slice(tail);
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
async function liveFileContent(
|
|
49
|
-
fileId: string,
|
|
50
|
-
storedContent: string,
|
|
51
|
-
): Promise<string> {
|
|
52
|
-
try {
|
|
53
|
-
if (await hasCollabState(fileId)) {
|
|
54
|
-
const live = await getText(fileId, "content");
|
|
55
|
-
if (typeof live === "string") return live;
|
|
56
|
-
}
|
|
57
|
-
} catch {
|
|
58
|
-
// Best-effort; SQL is the fallback.
|
|
59
|
-
}
|
|
60
|
-
return storedContent;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
49
|
// ─── Action ───────────────────────────────────────────────────────────────────
|
|
64
50
|
|
|
65
51
|
export default defineAction({
|
|
@@ -83,7 +69,6 @@ export default defineAction({
|
|
|
83
69
|
await assertAccess("design", designId, "editor");
|
|
84
70
|
|
|
85
71
|
const db = getDb();
|
|
86
|
-
const now = new Date().toISOString();
|
|
87
72
|
|
|
88
73
|
// ── 1. Verify timeline exists and belongs to this design ────────────────
|
|
89
74
|
const [timeline] = await db
|
|
@@ -142,7 +127,26 @@ export default defineAction({
|
|
|
142
127
|
}
|
|
143
128
|
|
|
144
129
|
// ── 3. Remove the managed CSS block from the HTML ───────────────────────
|
|
145
|
-
|
|
130
|
+
// Read the LIVE base (collab text when present, else the SQL row) right
|
|
131
|
+
// before transforming, and carry its versionHash through to the write
|
|
132
|
+
// below. writeInlineSourceFile re-reads the live text immediately before
|
|
133
|
+
// its own applyText/DB write and rejects if it no longer matches this
|
|
134
|
+
// hash — closing the race window where a concurrent editor/agent write
|
|
135
|
+
// lands between this read and the persist (the same stale-diff-base bug
|
|
136
|
+
// fixed for insert-design-native-asset.ts/insert-asset.ts: a diff computed
|
|
137
|
+
// from a stale base, written unconditionally, can corrupt or drop the
|
|
138
|
+
// other writer's concurrent change).
|
|
139
|
+
const workspaceFile: SourceWorkspaceFile = {
|
|
140
|
+
id: file.id,
|
|
141
|
+
designId,
|
|
142
|
+
filename: "",
|
|
143
|
+
fileType: "html",
|
|
144
|
+
content: file.content,
|
|
145
|
+
createdAt: null,
|
|
146
|
+
updatedAt: null,
|
|
147
|
+
};
|
|
148
|
+
const live = await readLiveSourceFile(workspaceFile);
|
|
149
|
+
const currentContent = live.content;
|
|
146
150
|
const bytesBefore = currentContent.length;
|
|
147
151
|
const cleanedContent = removeMotionStyleBlock(currentContent);
|
|
148
152
|
const bytesAfter = cleanedContent.length;
|
|
@@ -156,21 +160,12 @@ export default defineAction({
|
|
|
156
160
|
if (htmlChanged) {
|
|
157
161
|
agentEnterDocument(file.id);
|
|
158
162
|
try {
|
|
159
|
-
await
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
await applyText(file.id, cleanedContent, "content", "agent");
|
|
166
|
-
} else {
|
|
167
|
-
await seedFromText(file.id, cleanedContent);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
await db
|
|
171
|
-
.update(schema.designs)
|
|
172
|
-
.set({ updatedAt: now })
|
|
173
|
-
.where(eq(schema.designs.id, designId));
|
|
163
|
+
await writeInlineSourceFile({
|
|
164
|
+
designId,
|
|
165
|
+
file: workspaceFile,
|
|
166
|
+
content: cleanedContent,
|
|
167
|
+
expectedVersionHash: live.versionHash,
|
|
168
|
+
});
|
|
174
169
|
} finally {
|
|
175
170
|
agentLeaveDocument(file.id);
|
|
176
171
|
}
|