@agent-native/core 0.80.8 → 0.80.9
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 +2 -2
- package/corpus/core/CHANGELOG.md +12 -0
- package/corpus/core/docs/content/locales/ar-SA/template-design.mdx +6 -0
- package/corpus/core/docs/content/locales/de-DE/template-design.mdx +8 -0
- package/corpus/core/docs/content/locales/es-ES/template-design.mdx +10 -2
- package/corpus/core/docs/content/locales/fr-FR/template-design.mdx +10 -2
- package/corpus/core/docs/content/locales/hi-IN/template-design.mdx +7 -0
- package/corpus/core/docs/content/locales/ja-JP/template-design.mdx +7 -0
- package/corpus/core/docs/content/locales/ko-KR/template-design.mdx +7 -0
- package/corpus/core/docs/content/locales/pt-BR/template-design.mdx +9 -2
- package/corpus/core/docs/content/locales/zh-CN/template-design.mdx +6 -0
- package/corpus/core/docs/content/locales/zh-TW/template-design.mdx +6 -0
- package/corpus/core/docs/content/template-design.mdx +9 -2
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/cli/mcp.ts +10 -0
- package/corpus/core/src/cli/skills.ts +58 -12
- package/corpus/core/src/client/error-format.ts +25 -0
- package/corpus/core/src/client/extensions/ExtensionViewer.tsx +13 -11
- package/corpus/core/src/client/guided-questions.tsx +32 -4
- package/corpus/core/src/client/onboarding/OnboardingPanel.tsx +33 -1
- package/corpus/core/src/client/resources/BuiltinCapabilityDetail.tsx +8 -0
- package/corpus/core/src/client/resources/use-builtin-capabilities.ts +4 -2
- package/corpus/core/src/client/session-replay.ts +34 -0
- package/corpus/core/src/client/sharing/ShareButton.tsx +106 -21
- package/corpus/core/src/coding-tools/index.ts +1 -1
- package/corpus/core/src/mcp/index.ts +2 -0
- package/corpus/core/src/mcp/screen-memory-stdio.ts +290 -0
- package/corpus/core/src/mcp-client/builtin-capabilities.ts +13 -1
- package/corpus/core/src/mcp-client/index.ts +9 -0
- package/corpus/core/src/mcp-client/screen-memory-local.ts +461 -0
- package/corpus/core/src/onboarding/types.ts +7 -0
- package/corpus/core/src/server/agent-chat-plugin.ts +25 -0
- package/corpus/core/src/server/agents-bundle.ts +35 -7
- package/corpus/core/src/styles/agent-native.css +5 -0
- package/corpus/core/src/templates/default/app/global.css +35 -35
- package/corpus/templates/analytics/AGENTS.md +6 -0
- package/corpus/templates/analytics/actions/github-repo-files.ts +9 -0
- package/corpus/templates/analytics/app/components/layout/Layout.tsx +4 -4
- package/corpus/templates/analytics/app/global.css +144 -40
- package/corpus/templates/analytics/app/pages/adhoc/explorer/index.tsx +1 -1
- package/corpus/templates/analytics/app/pages/adhoc/explorer-dashboard/ChartCard.tsx +1 -1
- package/corpus/templates/analytics/app/pages/adhoc/explorer-dashboard/index.tsx +1 -1
- package/corpus/templates/analytics/app/pages/sessions/SessionDetailPage.tsx +4 -4
- package/corpus/templates/analytics/app/pages/sessions/SessionsPage.tsx +9 -9
- package/corpus/templates/analytics/changelog/2026-06-29-agents-can-search-and-read-connected-github-repositories-whe.md +6 -0
- package/corpus/templates/analytics/changelog/2026-06-29-sessions-and-explorer-layouts-adapt-when-the-agent-sidebar-is.md +6 -0
- package/corpus/templates/assets/app/components/layout/Layout.tsx +3 -1
- package/corpus/templates/assets/app/components/library/LibraryPresetGrid.tsx +1 -1
- package/corpus/templates/assets/app/global.css +99 -35
- package/corpus/templates/assets/app/routes/asset.$id.tsx +2 -2
- package/corpus/templates/assets/app/routes/brand-kits.$id.tsx +4 -4
- package/corpus/templates/assets/app/routes/library.tsx +4 -4
- package/corpus/templates/assets/changelog/2026-06-29-asset-library-and-detail-layouts-adapt-when-the-agent-sidebar.md +6 -0
- package/corpus/templates/brain/app/components/layout/Layout.tsx +1 -1
- package/corpus/templates/brain/app/global.css +63 -35
- package/corpus/templates/brain/app/routes/search.tsx +1 -1
- package/corpus/templates/brain/app/routes/settings.tsx +1 -1
- package/corpus/templates/brain/app/routes/sources.tsx +2 -2
- package/corpus/templates/brain/changelog/2026-06-29-search-settings-and-source-layouts-adapt-when-the-agent-sidebar.md +6 -0
- package/corpus/templates/calendar/app/components/calendar/EventDetailPanel.tsx +4 -4
- package/corpus/templates/calendar/app/components/calendar/FindTimePanel.tsx +3 -2
- package/corpus/templates/calendar/app/components/layout/AppLayout.tsx +4 -2
- package/corpus/templates/calendar/app/global.css +69 -35
- package/corpus/templates/calendar/changelog/2026-06-29-event-and-find-time-layouts-adapt-when-the-agent-sidebar-is.md +6 -0
- package/corpus/templates/chat/app/components/layout/Layout.tsx +1 -1
- package/corpus/templates/chat/app/global.css +35 -35
- package/corpus/templates/chat/changelog/2026-06-29-chat-layouts-adapt-when-the-agent-sidebar-is-open.md +6 -0
- package/corpus/templates/clips/AGENTS.md +13 -0
- package/corpus/templates/clips/actions/get-screen-memory-status.ts +12 -0
- package/corpus/templates/clips/actions/query-screen-memory-context.ts +29 -0
- package/corpus/templates/clips/actions/view-screen.ts +2 -2
- package/corpus/templates/clips/app/components/library/library-layout.tsx +1 -1
- package/corpus/templates/clips/app/global.css +47 -35
- package/corpus/templates/clips/app/routes/_app.meetings.$meetingId.tsx +3 -3
- package/corpus/templates/clips/app/routes/r.$recordingId.tsx +45 -18
- package/corpus/templates/clips/changelog/2026-06-29-meeting-detail-layouts-adapt-when-the-agent-sidebar-is-open.md +6 -0
- package/corpus/templates/clips/changelog/2026-06-29-screen-memory-keeps-a-local-rolling-screen-buffer-for-agent-context.md +5 -0
- package/corpus/templates/clips/changelog/2026-06-29-video-chat-is-easier-to-find-on-recording-pages-and-s3-setup.md +6 -0
- package/corpus/templates/clips/chrome-extension/src/styles.css +39 -39
- package/corpus/templates/clips/desktop/src/app.tsx +290 -1
- package/corpus/templates/clips/desktop/src/shared/config.ts +83 -0
- package/corpus/templates/clips/desktop/src/styles.css +67 -52
- package/corpus/templates/clips/desktop/src-tauri/src/config.rs +50 -0
- package/corpus/templates/clips/desktop/src-tauri/src/lib.rs +17 -0
- package/corpus/templates/clips/desktop/src-tauri/src/native_screen.rs +13 -13
- package/corpus/templates/clips/desktop/src-tauri/src/screen_memory.rs +990 -0
- package/corpus/templates/clips/server/plugins/onboarding.ts +2 -0
- package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +3 -3
- package/corpus/templates/content/app/components/layout/Layout.tsx +1 -1
- package/corpus/templates/content/app/global.css +29 -15
- package/corpus/templates/content/changelog/2026-06-29-database-gallery-layouts-adapt-when-the-agent-sidebar-is-open.md +6 -0
- package/corpus/templates/design/.agents/skills/design-generation/SKILL.md +25 -20
- package/corpus/templates/design/.agents/skills/design-systems/SKILL.md +8 -0
- package/corpus/templates/design/.agents/skills/export-handoff/SKILL.md +8 -0
- package/corpus/templates/design/.agents/skills/visual-edit/SKILL.md +13 -0
- package/corpus/templates/design/AGENTS.md +20 -12
- package/corpus/templates/design/CODE_NATIVE_DESIGN_STUDIO_IMPLEMENTATION_PLAN.md +1054 -0
- package/corpus/templates/design/actions/apply-visual-edit.ts +24 -4
- package/corpus/templates/design/actions/export-coding-handoff.ts +12 -4
- package/corpus/templates/design/actions/generate-design.ts +6 -21
- package/corpus/templates/design/actions/generate-screens.ts +43 -2
- package/corpus/templates/design/actions/get-design.ts +1 -0
- package/corpus/templates/design/actions/present-design-variants.ts +355 -30
- package/corpus/templates/design/actions/view-screen.ts +75 -31
- package/corpus/templates/design/app/components/design/DesignCanvas.tsx +329 -69
- package/corpus/templates/design/app/components/design/DesignEditorSkeleton.tsx +1 -1
- package/corpus/templates/design/app/components/design/EditPanel.tsx +479 -77
- package/corpus/templates/design/app/components/design/LayersPanel.tsx +380 -216
- package/corpus/templates/design/app/components/design/MultiScreenCanvas.tsx +1050 -196
- package/corpus/templates/design/app/components/design/QuestionFlow.tsx +83 -206
- package/corpus/templates/design/app/components/design/TweaksPanel.tsx +1 -1
- package/corpus/templates/design/app/components/design/index.ts +0 -1
- package/corpus/templates/design/app/components/design/inspector/AutoLayoutMatrix.tsx +225 -133
- package/corpus/templates/design/app/components/design/inspector/DesignColorPicker.tsx +122 -11
- package/corpus/templates/design/app/components/design/inspector/ExportSettingsPanel.tsx +24 -5
- package/corpus/templates/design/app/components/design/inspector/ImageFillControls.tsx +57 -1
- package/corpus/templates/design/app/components/design/inspector/ScrubInput.tsx +37 -12
- package/corpus/templates/design/app/components/design/inspector/index.ts +1 -0
- package/corpus/templates/design/app/components/design/inspector/scrub-input-utils.ts +12 -5
- package/corpus/templates/design/app/components/design/types.ts +9 -0
- package/corpus/templates/design/app/components/layout/Layout.tsx +23 -5
- package/corpus/templates/design/app/global.css +77 -49
- package/corpus/templates/design/app/hooks/use-question-flow.ts +2 -2
- package/corpus/templates/design/app/hooks/useDesignHotkeys.ts +8 -1
- package/corpus/templates/design/app/i18n/zh-TW.ts +3 -0
- package/corpus/templates/design/app/i18n-data.ts +45 -3
- package/corpus/templates/design/app/pages/DesignEditor.tsx +2602 -657
- package/corpus/templates/design/app/root.tsx +1 -1
- package/corpus/templates/design/changelog/2026-06-29-containers-no-longer-block-selecting-nested-elements-and-nor.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-design-agents-now-generate-and-refine-variants-from-stronger.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-design-inspector-controls-now-match-figmas-softer-dark-chrome.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-design-questions-now-appear-as-a-cleaner-canvas-intake-with-.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-design-variant-directions-now-appear-as-board-screens-with-chat-buttons.md +5 -0
- package/corpus/templates/design/changelog/2026-06-29-element-selection-no-longer-snaps-back-to-the-previous-layer.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-frame-resize-measurements-now-stay-beside-the-cursor-while-d.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-inspector-number-fields-have-cleaner-tooltips-and-draggable-.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-layer-locking-layer-nesting-generated-question-intake-and-im.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-layer-names-in-the-sidebar-can-scroll-horizontally-instead-o.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-layer-nesting-in-the-sidebar-now-uses-tighter-spacing-so-nam.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-layers-no-longer-repeat-document-wrapper-rows-when-a-screen-.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-overview-previews-now-keep-element-hover-and-selection-tied-.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-pressing-escape-now-cancels-a-stuck-screen-drag-in-the-overv.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-screen-overview-is-easier-to-find-and-named-screens-open-dir.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-screen-overview-only-highlights-screens-when-the-frame-or-ti.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-screen-overview-previews-now-resize-to-match-the-selected-de.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-screen-overview-selection-now-uses-a-pointer-cursor-instead-.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-screen-overview-selection-outlines-now-stay-locked-to-the-se.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-screen-overview-zoom-now-reports-real-screen-scale-separatel.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-screen-overview-zooming-feels-smoother-and-selection-outline.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-screen-overview-zooming-now-stays-on-the-overview-canvas-ins.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-selecting-a-nested-layer-from-all-screens-now-keeps-you-in-a.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-share-now-groups-link-sharing-exports-and-agent-handoff.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-the-design-editor-loading-skeleton-now-uses-a-softer-charcoa.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-the-device-preview-menu-now-sits-next-to-the-preview-button-.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-the-inspector-stays-read-only-while-an-empty-design-is-still.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-the-missing-design-view-now-matches-the-rest-of-the-editor-c.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-the-pen-tool-icon-and-tool-option-menus-better-match-the-edi.md +6 -0
- package/corpus/templates/design/changelog/2026-06-29-typography-controls-now-keep-the-font-name-visible-and-move-.md +6 -0
- package/corpus/templates/design/e2e/README.md +3 -3
- package/corpus/templates/design/e2e/global-setup.ts +11 -22
- package/corpus/templates/design/e2e/helpers.ts +122 -11
- package/corpus/templates/design/playwright.config.ts +9 -3
- package/corpus/templates/design/server/lib/coding-handoff.ts +126 -2
- package/corpus/templates/design/server/plugins/core-routes.ts +1 -2
- package/corpus/templates/design/server/routes/api/design-handoff/[id].zip.get.ts +86 -0
- package/corpus/templates/design/shared/code-layer.ts +125 -22
- package/corpus/templates/design/shared/generation-session.ts +41 -0
- package/corpus/templates/dispatch/app/global.css +79 -35
- package/corpus/templates/dispatch/app/routes/integrations.tsx +8 -7
- package/corpus/templates/dispatch/changelog/2026-06-29-integration-layouts-adapt-when-the-agent-sidebar-is-open.md +6 -0
- package/corpus/templates/forms/app/components/layout/Layout.tsx +6 -2
- package/corpus/templates/forms/app/global.css +64 -35
- package/corpus/templates/forms/app/pages/FormsListPage.tsx +2 -2
- package/corpus/templates/forms/app/pages/ResponseInsightsPage.tsx +3 -3
- package/corpus/templates/forms/changelog/2026-06-29-form-list-and-insight-layouts-adapt-when-the-agent-sidebar.md +6 -0
- package/corpus/templates/macros/app/components/layout/AppLayout.tsx +3 -1
- package/corpus/templates/macros/app/global.css +25 -9
- package/corpus/templates/macros/changelog/2026-06-29-macro-layouts-adapt-when-the-agent-sidebar-is-open.md +6 -0
- package/corpus/templates/mail/app/components/layout/AppLayout.tsx +6 -2
- package/corpus/templates/mail/app/global.css +42 -36
- package/corpus/templates/mail/app/pages/InboxPage.tsx +1 -1
- package/corpus/templates/mail/changelog/2026-06-29-the-contact-panel-now-adapts-to-the-available-mail-pane-width.md +6 -0
- package/corpus/templates/plan/app/components/layout/Layout.tsx +3 -1
- package/corpus/templates/plan/app/components/plan/DocumentArea.tsx +6 -7
- package/corpus/templates/plan/app/global.css +74 -42
- package/corpus/templates/plan/changelog/2026-06-29-plan-document-blocks-adapt-to-the-available-document-width.md +6 -0
- package/corpus/templates/plan/changelog/2026-06-29-plan-titles-and-summaries-can-be-edited-inline-without-focus.md +6 -0
- package/corpus/templates/slides/app/components/layout/Layout.tsx +3 -1
- package/corpus/templates/slides/app/global.css +49 -33
- package/corpus/templates/slides/changelog/2026-06-29-slide-layouts-adapt-when-the-agent-sidebar-is-open.md +6 -0
- package/corpus/templates/videos/app/components/layout/Layout.tsx +3 -1
- package/corpus/templates/videos/app/global.css +35 -35
- package/corpus/templates/videos/changelog/2026-06-29-video-layouts-adapt-when-the-agent-sidebar-is-open.md +6 -0
- package/dist/cli/mcp.d.ts.map +1 -1
- package/dist/cli/mcp.js +10 -0
- package/dist/cli/mcp.js.map +1 -1
- package/dist/cli/skills.d.ts.map +1 -1
- package/dist/cli/skills.js +58 -12
- package/dist/cli/skills.js.map +1 -1
- package/dist/client/error-format.d.ts.map +1 -1
- package/dist/client/error-format.js +17 -0
- package/dist/client/error-format.js.map +1 -1
- package/dist/client/extensions/ExtensionViewer.d.ts.map +1 -1
- package/dist/client/extensions/ExtensionViewer.js +3 -4
- package/dist/client/extensions/ExtensionViewer.js.map +1 -1
- package/dist/client/guided-questions.d.ts +4 -0
- package/dist/client/guided-questions.d.ts.map +1 -1
- package/dist/client/guided-questions.js +16 -7
- package/dist/client/guided-questions.js.map +1 -1
- package/dist/client/onboarding/OnboardingPanel.js +26 -1
- package/dist/client/onboarding/OnboardingPanel.js.map +1 -1
- package/dist/client/resources/BuiltinCapabilityDetail.d.ts.map +1 -1
- package/dist/client/resources/BuiltinCapabilityDetail.js +1 -1
- package/dist/client/resources/BuiltinCapabilityDetail.js.map +1 -1
- package/dist/client/resources/use-builtin-capabilities.d.ts +1 -1
- package/dist/client/resources/use-builtin-capabilities.d.ts.map +1 -1
- package/dist/client/resources/use-builtin-capabilities.js +2 -1
- package/dist/client/resources/use-builtin-capabilities.js.map +1 -1
- package/dist/client/session-replay.d.ts.map +1 -1
- package/dist/client/session-replay.js +31 -0
- package/dist/client/session-replay.js.map +1 -1
- package/dist/client/sharing/ShareButton.d.ts +14 -0
- package/dist/client/sharing/ShareButton.d.ts.map +1 -1
- package/dist/client/sharing/ShareButton.js +36 -7
- package/dist/client/sharing/ShareButton.js.map +1 -1
- package/dist/coding-tools/index.js +1 -1
- package/dist/coding-tools/index.js.map +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/file-upload/actions/upload-image.d.ts +2 -2
- package/dist/mcp/index.d.ts +2 -0
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +1 -0
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/screen-memory-stdio.d.ts +6 -0
- package/dist/mcp/screen-memory-stdio.d.ts.map +1 -0
- package/dist/mcp/screen-memory-stdio.js +213 -0
- package/dist/mcp/screen-memory-stdio.js.map +1 -0
- package/dist/mcp-client/builtin-capabilities.d.ts +1 -1
- package/dist/mcp-client/builtin-capabilities.d.ts.map +1 -1
- package/dist/mcp-client/builtin-capabilities.js +10 -0
- package/dist/mcp-client/builtin-capabilities.js.map +1 -1
- package/dist/mcp-client/index.d.ts +1 -0
- package/dist/mcp-client/index.d.ts.map +1 -1
- package/dist/mcp-client/index.js +1 -0
- package/dist/mcp-client/index.js.map +1 -1
- package/dist/mcp-client/screen-memory-local.d.ts +61 -0
- package/dist/mcp-client/screen-memory-local.d.ts.map +1 -0
- package/dist/mcp-client/screen-memory-local.js +336 -0
- package/dist/mcp-client/screen-memory-local.js.map +1 -0
- package/dist/notifications/routes.d.ts +2 -2
- package/dist/observability/routes.d.ts +8 -8
- package/dist/onboarding/types.d.ts +7 -0
- package/dist/onboarding/types.d.ts.map +1 -1
- package/dist/onboarding/types.js.map +1 -1
- package/dist/resources/handlers.d.ts +2 -2
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +26 -0
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/agents-bundle.d.ts.map +1 -1
- package/dist/server/agents-bundle.js +22 -7
- package/dist/server/agents-bundle.js.map +1 -1
- package/dist/server/transcribe-voice.d.ts +1 -1
- package/dist/styles/agent-native.css +5 -0
- package/dist/templates/default/app/global.css +35 -35
- package/docs/content/locales/ar-SA/template-design.mdx +6 -0
- package/docs/content/locales/de-DE/template-design.mdx +8 -0
- package/docs/content/locales/es-ES/template-design.mdx +10 -2
- package/docs/content/locales/fr-FR/template-design.mdx +10 -2
- package/docs/content/locales/hi-IN/template-design.mdx +7 -0
- package/docs/content/locales/ja-JP/template-design.mdx +7 -0
- package/docs/content/locales/ko-KR/template-design.mdx +7 -0
- package/docs/content/locales/pt-BR/template-design.mdx +9 -2
- package/docs/content/locales/zh-CN/template-design.mdx +6 -0
- package/docs/content/locales/zh-TW/template-design.mdx +6 -0
- package/docs/content/template-design.mdx +9 -2
- package/package.json +1 -1
- package/src/templates/default/app/global.css +35 -35
- package/corpus/templates/design/app/components/design/VariantGrid.tsx +0 -189
- package/corpus/templates/design/app/components/design/VariantHandoffCard.tsx +0 -115
- package/corpus/templates/design/app/hooks/use-variant-flow.ts +0 -342
|
@@ -1,342 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
sendToAgentChat,
|
|
3
|
-
agentNativePath,
|
|
4
|
-
callAction,
|
|
5
|
-
isEmbedAuthActive,
|
|
6
|
-
} from "@agent-native/core/client";
|
|
7
|
-
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
8
|
-
import { useEffect, useCallback, useRef, useState } from "react";
|
|
9
|
-
|
|
10
|
-
import { toast } from "@/hooks/use-toast";
|
|
11
|
-
|
|
12
|
-
export const DESIGN_VARIANT_PICKED_EVENT = "agent-native-design-variant-picked";
|
|
13
|
-
|
|
14
|
-
export interface VariantCandidate {
|
|
15
|
-
id: string;
|
|
16
|
-
label: string;
|
|
17
|
-
content: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface VariantState {
|
|
21
|
-
designId: string;
|
|
22
|
-
variants: VariantCandidate[];
|
|
23
|
-
/** Optional caption above the grid, e.g. "Pick a direction". */
|
|
24
|
-
prompt?: string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/** A pick/dismiss surfaced as a copyable handoff for link-only hosts. */
|
|
28
|
-
export interface StandalonePick {
|
|
29
|
-
/** Card heading, e.g. "Direction selected" or "Closed without picking". */
|
|
30
|
-
heading: string;
|
|
31
|
-
/** Chosen variant name, when a direction was picked. */
|
|
32
|
-
label?: string;
|
|
33
|
-
/** Paste-back text the user copies into their coding agent's chat. */
|
|
34
|
-
text: string;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* True when this editor was opened from a link-only host (CLI / Codex / Claude
|
|
39
|
-
* Code) that can't render the inline MCP app — the deep link carries
|
|
40
|
-
* `handoff=chat`. There's no host chat bridge to receive the pick, so after the
|
|
41
|
-
* user chooses we show a copyable summary to paste back into their agent.
|
|
42
|
-
*/
|
|
43
|
-
function isLinkOnlyHandoff(): boolean {
|
|
44
|
-
if (typeof window === "undefined") return false;
|
|
45
|
-
try {
|
|
46
|
-
return (
|
|
47
|
-
new URLSearchParams(window.location.search).get("handoff") === "chat"
|
|
48
|
-
);
|
|
49
|
-
} catch {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function variantHandoffText(
|
|
55
|
-
designId: string,
|
|
56
|
-
variant: VariantCandidate,
|
|
57
|
-
persisted: boolean,
|
|
58
|
-
): string {
|
|
59
|
-
const context = {
|
|
60
|
-
selectedDesign: {
|
|
61
|
-
designId,
|
|
62
|
-
variantId: variant.id,
|
|
63
|
-
label: variant.label,
|
|
64
|
-
file: "index.html",
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
return [
|
|
68
|
-
"Paste this back into your chat so your agent continues from the chosen design.",
|
|
69
|
-
"",
|
|
70
|
-
`I picked the "${variant.label}" design direction.`,
|
|
71
|
-
persisted
|
|
72
|
-
? `It's saved as index.html in design ${designId}. Refine from here with get-design-snapshot + generate-design, or export-coding-handoff to bring it into code. Don't show new variants unless I ask.`
|
|
73
|
-
: `Saving didn't finish — re-run present-design-variants or generate-design for design ${designId} before refining.`,
|
|
74
|
-
"",
|
|
75
|
-
"Design selection context:",
|
|
76
|
-
JSON.stringify(context, null, 2),
|
|
77
|
-
].join("\n");
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function variantDismissText(): string {
|
|
81
|
-
return [
|
|
82
|
-
"Paste this back into your chat to keep going.",
|
|
83
|
-
"",
|
|
84
|
-
"I closed the design directions without picking one. Show me a different direction.",
|
|
85
|
-
].join("\n");
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Polls `application-state/design-variants`. When the agent generates 2-5
|
|
90
|
-
* candidate variations, it writes them here; the editor surfaces a
|
|
91
|
-
* full-canvas grid (Claude Design-style: pick a direction before refining).
|
|
92
|
-
*
|
|
93
|
-
* On "Use this one", the chosen variant's HTML is persisted to the design as
|
|
94
|
-
* `index.html` via `generate-design`, and the pick is reported back through the
|
|
95
|
-
* right channel for the host: an embedded MCP host gets a chat message over the
|
|
96
|
-
* bridge; the first-party app posts to its own sidebar; a link-only host (CLI)
|
|
97
|
-
* gets a copyable summary to paste back. The variant state is then cleared.
|
|
98
|
-
*/
|
|
99
|
-
export function useVariantFlow(designId: string | undefined) {
|
|
100
|
-
const qc = useQueryClient();
|
|
101
|
-
const [state, setState] = useState<VariantState | null>(null);
|
|
102
|
-
const [standalonePick, setStandalonePick] = useState<StandalonePick | null>(
|
|
103
|
-
null,
|
|
104
|
-
);
|
|
105
|
-
// Re-entry latch so a double-click on "Use this direction" can't fire two
|
|
106
|
-
// generate-design writes + two pick messages.
|
|
107
|
-
const pickingRef = useRef(false);
|
|
108
|
-
// Set once a pick commits; keeps the 2s poll from re-showing the grid in the
|
|
109
|
-
// window before the server DELETE lands. Cleared once the server state is gone
|
|
110
|
-
// so a later, genuinely new variant set can still appear.
|
|
111
|
-
const pickedRef = useRef(false);
|
|
112
|
-
|
|
113
|
-
// Tracks the designId of a consumed variant set so stale in-flight poll
|
|
114
|
-
// responses with the same designId cannot re-open the grid, even if the
|
|
115
|
-
// server DELETE is delayed or the user picks while a poll is in-flight.
|
|
116
|
-
const consumedDesignIdRef = useRef<string | null>(null);
|
|
117
|
-
// Bounded suppression window (epoch ms). After it elapses we stop suppressing
|
|
118
|
-
// so a failed DELETE or a fast follow-up present-design-variants for the same
|
|
119
|
-
// design can't keep the picker hidden indefinitely.
|
|
120
|
-
const consumedUntilRef = useRef(0);
|
|
121
|
-
|
|
122
|
-
const { data } = useQuery({
|
|
123
|
-
queryKey: ["design-variants"],
|
|
124
|
-
queryFn: async () => {
|
|
125
|
-
const res = await fetch(
|
|
126
|
-
agentNativePath("/_agent-native/application-state/design-variants"),
|
|
127
|
-
);
|
|
128
|
-
if (!res.ok) return null;
|
|
129
|
-
const text = await res.text();
|
|
130
|
-
if (!text) return null;
|
|
131
|
-
try {
|
|
132
|
-
return JSON.parse(text) as VariantState;
|
|
133
|
-
} catch {
|
|
134
|
-
return null;
|
|
135
|
-
}
|
|
136
|
-
},
|
|
137
|
-
refetchInterval: 2_000,
|
|
138
|
-
structuralSharing: false,
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
useEffect(() => {
|
|
142
|
-
const hasVariants = Boolean(
|
|
143
|
-
data?.variants && data.variants.length > 0 && data.designId === designId,
|
|
144
|
-
);
|
|
145
|
-
// Suppression after a pick covers two things: the brief window where a stale
|
|
146
|
-
// in-flight poll could re-open the just-picked grid, and the gap until the
|
|
147
|
-
// server DELETE lands. It is bounded in time so a failed DELETE (server state
|
|
148
|
-
// never clears) or a fast follow-up variant set for the same design can't
|
|
149
|
-
// keep the picker hidden forever.
|
|
150
|
-
const windowElapsed = Date.now() >= consumedUntilRef.current;
|
|
151
|
-
if ((consumedDesignIdRef.current || pickedRef.current) && windowElapsed) {
|
|
152
|
-
consumedDesignIdRef.current = null;
|
|
153
|
-
pickedRef.current = false;
|
|
154
|
-
} else if (
|
|
155
|
-
data?.designId &&
|
|
156
|
-
data.designId === consumedDesignIdRef.current
|
|
157
|
-
) {
|
|
158
|
-
// Re-arm early once the server confirms the consumed state is gone.
|
|
159
|
-
if (!hasVariants) consumedDesignIdRef.current = null;
|
|
160
|
-
setState(null);
|
|
161
|
-
return;
|
|
162
|
-
} else if (pickedRef.current) {
|
|
163
|
-
if (!hasVariants) pickedRef.current = false;
|
|
164
|
-
setState(null);
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
setState(hasVariants && data ? data : null);
|
|
168
|
-
}, [data, designId]);
|
|
169
|
-
|
|
170
|
-
const clear = useCallback(
|
|
171
|
-
async (consumedId?: string) => {
|
|
172
|
-
setState(null);
|
|
173
|
-
// Mark the designId as consumed before issuing the DELETE so any
|
|
174
|
-
// in-flight or subsequent polls with this designId are suppressed
|
|
175
|
-
// even if the network request is delayed.
|
|
176
|
-
if (consumedId) {
|
|
177
|
-
consumedDesignIdRef.current = consumedId;
|
|
178
|
-
consumedUntilRef.current = Date.now() + 6000;
|
|
179
|
-
}
|
|
180
|
-
qc.setQueryData(["design-variants"], null);
|
|
181
|
-
try {
|
|
182
|
-
const res = await fetch(
|
|
183
|
-
agentNativePath("/_agent-native/application-state/design-variants"),
|
|
184
|
-
{ method: "DELETE" },
|
|
185
|
-
);
|
|
186
|
-
if (!res.ok) {
|
|
187
|
-
// DELETE failed — the consumed marker keeps the grid hidden client-side,
|
|
188
|
-
// but log so the issue is visible rather than silently swallowed.
|
|
189
|
-
console.warn(
|
|
190
|
-
"[use-variant-flow] Failed to clear design-variants state:",
|
|
191
|
-
res.status,
|
|
192
|
-
);
|
|
193
|
-
}
|
|
194
|
-
} catch (err) {
|
|
195
|
-
// Network error — same: log but don't re-show grid (consumed marker holds).
|
|
196
|
-
console.warn(
|
|
197
|
-
"[use-variant-flow] Error clearing design-variants state:",
|
|
198
|
-
err,
|
|
199
|
-
);
|
|
200
|
-
}
|
|
201
|
-
},
|
|
202
|
-
[qc],
|
|
203
|
-
);
|
|
204
|
-
|
|
205
|
-
const dismissStandalonePick = useCallback(() => setStandalonePick(null), []);
|
|
206
|
-
|
|
207
|
-
const useVariant = useCallback(
|
|
208
|
-
async (variantId: string) => {
|
|
209
|
-
if (!state || !designId) return;
|
|
210
|
-
const chosen = state.variants.find((v) => v.id === variantId);
|
|
211
|
-
if (!chosen) return;
|
|
212
|
-
if (pickingRef.current) return;
|
|
213
|
-
pickingRef.current = true;
|
|
214
|
-
pickedRef.current = true;
|
|
215
|
-
// Start the bounded suppression window so the just-picked grid stays hidden
|
|
216
|
-
// through the DELETE round-trip + a poll cycle, but not indefinitely.
|
|
217
|
-
consumedUntilRef.current = Date.now() + 6000;
|
|
218
|
-
try {
|
|
219
|
-
// Persist the chosen variant as the design's primary file via the
|
|
220
|
-
// agent's own action endpoint so every host lands on the same design.
|
|
221
|
-
let persisted = false;
|
|
222
|
-
try {
|
|
223
|
-
await callAction(
|
|
224
|
-
"generate-design" as any,
|
|
225
|
-
{
|
|
226
|
-
designId,
|
|
227
|
-
prompt: `User picked variant "${chosen.label}"`,
|
|
228
|
-
files: [
|
|
229
|
-
{
|
|
230
|
-
filename: "index.html",
|
|
231
|
-
content: chosen.content,
|
|
232
|
-
fileType: "html",
|
|
233
|
-
},
|
|
234
|
-
],
|
|
235
|
-
} as any,
|
|
236
|
-
);
|
|
237
|
-
await Promise.all([
|
|
238
|
-
qc.invalidateQueries({
|
|
239
|
-
queryKey: ["action", "get-design", { id: designId }],
|
|
240
|
-
}),
|
|
241
|
-
qc.invalidateQueries({ queryKey: ["action", "get-design"] }),
|
|
242
|
-
qc.invalidateQueries({ queryKey: ["action", "list-designs"] }),
|
|
243
|
-
]);
|
|
244
|
-
persisted = true;
|
|
245
|
-
if (typeof window !== "undefined") {
|
|
246
|
-
window.dispatchEvent(
|
|
247
|
-
new CustomEvent(DESIGN_VARIANT_PICKED_EVENT, {
|
|
248
|
-
detail: { designId, content: chosen.content },
|
|
249
|
-
}),
|
|
250
|
-
);
|
|
251
|
-
}
|
|
252
|
-
} catch {
|
|
253
|
-
// Network error: show a visible error and keep the grid open so
|
|
254
|
-
// the user can retry rather than silently losing their choice.
|
|
255
|
-
toast({
|
|
256
|
-
title: "Couldn't save your pick",
|
|
257
|
-
description:
|
|
258
|
-
"Saving didn't finish. Try again or refresh and re-pick.",
|
|
259
|
-
variant: "destructive",
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
const refineHint = persisted
|
|
264
|
-
? `Its content has been saved as index.html. Continue refining from there if the user asks.`
|
|
265
|
-
: `Saving the chosen variant did not complete. Ask the user whether to retry before refining it.`;
|
|
266
|
-
const guardHint = persisted
|
|
267
|
-
? `Do not show further variants unless the user explicitly asks for "more options" or "alternatives".`
|
|
268
|
-
: `Do not claim the design file was updated until generate-design succeeds.`;
|
|
269
|
-
|
|
270
|
-
if (isEmbedAuthActive()) {
|
|
271
|
-
// Embedded MCP host (ChatGPT / Claude): the pick rides the host chat
|
|
272
|
-
// bridge straight into the conversation.
|
|
273
|
-
sendToAgentChat({
|
|
274
|
-
message: `I picked "${chosen.label}".`,
|
|
275
|
-
context: [
|
|
276
|
-
`The user chose variant "${chosen.label}" (id: ${chosen.id}) for design ${designId} inside the embedded Design app.`,
|
|
277
|
-
refineHint,
|
|
278
|
-
guardHint,
|
|
279
|
-
].join("\n"),
|
|
280
|
-
submit: true,
|
|
281
|
-
openSidebar: false,
|
|
282
|
-
});
|
|
283
|
-
} else if (isLinkOnlyHandoff()) {
|
|
284
|
-
// Link-only host (CLI / Codex / Claude Code): no chat bridge — show a
|
|
285
|
-
// copyable summary the user pastes back into their coding agent. The
|
|
286
|
-
// card owns the clipboard write so its "Copied" state stays truthful.
|
|
287
|
-
setStandalonePick({
|
|
288
|
-
heading: "Direction selected",
|
|
289
|
-
label: chosen.label,
|
|
290
|
-
text: variantHandoffText(designId, chosen, persisted),
|
|
291
|
-
});
|
|
292
|
-
} else {
|
|
293
|
-
// First-party app: post the pick to its own agent sidebar composer.
|
|
294
|
-
sendToAgentChat({
|
|
295
|
-
message: `I picked "${chosen.label}".`,
|
|
296
|
-
context: [
|
|
297
|
-
`The user chose variant "${chosen.label}" (id: ${chosen.id}) for design ${designId}.`,
|
|
298
|
-
refineHint,
|
|
299
|
-
guardHint,
|
|
300
|
-
].join("\n"),
|
|
301
|
-
submit: true,
|
|
302
|
-
});
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
// Only clear the grid when the variant was successfully persisted.
|
|
306
|
-
// If saving failed, keep the grid open so the user can retry.
|
|
307
|
-
if (persisted) {
|
|
308
|
-
await clear(designId);
|
|
309
|
-
} else {
|
|
310
|
-
// Re-arm the picking latch so the user can try again.
|
|
311
|
-
pickedRef.current = false;
|
|
312
|
-
}
|
|
313
|
-
} finally {
|
|
314
|
-
pickingRef.current = false;
|
|
315
|
-
}
|
|
316
|
-
},
|
|
317
|
-
[state, designId, qc, clear],
|
|
318
|
-
);
|
|
319
|
-
|
|
320
|
-
const dismiss = useCallback(() => {
|
|
321
|
-
const embedded = isEmbedAuthActive();
|
|
322
|
-
void clear(designId);
|
|
323
|
-
if (isLinkOnlyHandoff() && !isEmbedAuthActive()) {
|
|
324
|
-
// No chat bridge to relay the dismissal — give the user a copyable note
|
|
325
|
-
// so their coding agent doesn't wait on a pick that isn't coming.
|
|
326
|
-
setStandalonePick({
|
|
327
|
-
heading: "Closed without picking",
|
|
328
|
-
text: variantDismissText(),
|
|
329
|
-
});
|
|
330
|
-
return;
|
|
331
|
-
}
|
|
332
|
-
sendToAgentChat({
|
|
333
|
-
message: "Close the variants — none of these.",
|
|
334
|
-
context:
|
|
335
|
-
"User dismissed the variant grid without picking. Ask what direction they want instead.",
|
|
336
|
-
submit: embedded,
|
|
337
|
-
...(embedded ? { openSidebar: false } : {}),
|
|
338
|
-
});
|
|
339
|
-
}, [clear, designId]);
|
|
340
|
-
|
|
341
|
-
return { state, useVariant, dismiss, standalonePick, dismissStandalonePick };
|
|
342
|
-
}
|