@decido/shell 1.0.0

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 (208) hide show
  1. package/.turbo/turbo-build.log +13 -0
  2. package/package.json +65 -0
  3. package/src/AgentPlayer.tsx +105 -0
  4. package/src/DecidoPlayer.tsx +117 -0
  5. package/src/bridge/BridgeAgent.ts +443 -0
  6. package/src/components/DecidoIcon.tsx +56 -0
  7. package/src/components/JsonTreeEditor.tsx +117 -0
  8. package/src/components/PanelSplitter.tsx +71 -0
  9. package/src/components/PluginErrorBoundary.tsx +69 -0
  10. package/src/components/SafeLiquidUI.tsx +114 -0
  11. package/src/components/TransientLayer.tsx +92 -0
  12. package/src/components/agent/AgentChat.tsx +134 -0
  13. package/src/components/chat-extensions/IntentCatalogPanel.tsx +81 -0
  14. package/src/components/chat-extensions/chatSlashCommands.ts +101 -0
  15. package/src/components/controls/CreatorInputBar.tsx +144 -0
  16. package/src/components/controls/OSToolbar.tsx +90 -0
  17. package/src/components/controls/TimelineTape.tsx +43 -0
  18. package/src/components/debug/ActionTimelineTab.tsx +111 -0
  19. package/src/components/debug/CSSInspectorTab.tsx +436 -0
  20. package/src/components/debug/ExportTab.tsx +192 -0
  21. package/src/components/debug/FlowHealthTab.tsx +86 -0
  22. package/src/components/debug/LogsTab.tsx +110 -0
  23. package/src/components/debug/MorphStackTab.tsx +241 -0
  24. package/src/components/debug/NetworkTab.tsx +173 -0
  25. package/src/components/debug/PerformanceTab.tsx +171 -0
  26. package/src/components/debug/ProfilesTab.tsx +238 -0
  27. package/src/components/debug/ReplayTab.tsx +70 -0
  28. package/src/components/debug/StoresTab.tsx +255 -0
  29. package/src/components/debug/TopologyTab.tsx +59 -0
  30. package/src/components/debug/debugConfig.tsx +66 -0
  31. package/src/components/playground/DebugPanel.tsx +112 -0
  32. package/src/components/playground/HeaderCenterControls.tsx +92 -0
  33. package/src/components/playground/KeyframeListItem.tsx +70 -0
  34. package/src/components/playground/PlaygroundAppSidebar.tsx +171 -0
  35. package/src/components/playground/PlaygroundBottomControls.tsx +132 -0
  36. package/src/components/playground/PlaygroundCanvas.tsx +87 -0
  37. package/src/components/playground/PlaygroundChat.tsx +236 -0
  38. package/src/components/playground/PlaygroundErrorBoundary.tsx +63 -0
  39. package/src/components/playground/PlaygroundFloatingInput.tsx +352 -0
  40. package/src/components/playground/PlaygroundHeader.tsx +222 -0
  41. package/src/components/playground/PlaygroundSidebar.tsx +136 -0
  42. package/src/components/playground/PlaygroundTerminal.tsx +44 -0
  43. package/src/components/playground/SuggestionCards.tsx +29 -0
  44. package/src/components/playground/demos/ClinicaAINode.tsx +221 -0
  45. package/src/components/playground/demos/FinanceAINode.tsx +226 -0
  46. package/src/components/playground/demos/KiaAcademyNode.tsx +250 -0
  47. package/src/components/playground/demos/KiaBotNode.tsx +207 -0
  48. package/src/components/playground/demos/KiaCampaignNode.tsx +191 -0
  49. package/src/components/playground/demos/KiaComplianceNode.tsx +140 -0
  50. package/src/components/playground/demos/KiaCustomerJourneyNode.tsx +220 -0
  51. package/src/components/playground/demos/KiaCyberNode.tsx +203 -0
  52. package/src/components/playground/demos/KiaDashboardNode.tsx +399 -0
  53. package/src/components/playground/demos/KiaEmbudoOverviewNode.tsx +168 -0
  54. package/src/components/playground/demos/KiaExecutiveNode.tsx +169 -0
  55. package/src/components/playground/demos/KiaGamificationNode.tsx +229 -0
  56. package/src/components/playground/demos/KiaIntelligenceHubNode.tsx +165 -0
  57. package/src/components/playground/demos/KiaInventoryNode.tsx +183 -0
  58. package/src/components/playground/demos/KiaLeadScoringNode.tsx +226 -0
  59. package/src/components/playground/demos/KiaLiveSimulationNode.tsx +177 -0
  60. package/src/components/playground/demos/KiaMultiDealerNode.tsx +223 -0
  61. package/src/components/playground/demos/KiaNPSVoiceNode.tsx +214 -0
  62. package/src/components/playground/demos/KiaOmnichannelNode.tsx +162 -0
  63. package/src/components/playground/demos/KiaPBIBudgetNode.tsx +152 -0
  64. package/src/components/playground/demos/KiaPBIConversionNode.tsx +206 -0
  65. package/src/components/playground/demos/KiaPBIFunnelNode.tsx +184 -0
  66. package/src/components/playground/demos/KiaPBIOwnershipNode.tsx +113 -0
  67. package/src/components/playground/demos/KiaPBIPartnerNode.tsx +143 -0
  68. package/src/components/playground/demos/KiaPBIPreciosNode.tsx +120 -0
  69. package/src/components/playground/demos/KiaPBIRuntNode.tsx +205 -0
  70. package/src/components/playground/demos/KiaPartnerScoreNode.tsx +206 -0
  71. package/src/components/playground/demos/KiaPredictiveNode.tsx +226 -0
  72. package/src/components/playground/demos/KiaShowroomNode.tsx +194 -0
  73. package/src/components/playground/demos/KiaStoreNode.tsx +215 -0
  74. package/src/components/playground/demos/KiaSustainabilityNode.tsx +173 -0
  75. package/src/components/playground/demos/KiaUsedVehiclesNode.tsx +163 -0
  76. package/src/components/playground/demos/KiaWorkshopNode.tsx +221 -0
  77. package/src/components/playground/demos/SmartCityNode.tsx +205 -0
  78. package/src/components/playground/demos/kia_campaign_manifest.json +112 -0
  79. package/src/components/playground/input-parts/AIModelSelector.tsx +156 -0
  80. package/src/components/playground/input-parts/InputActions.tsx +80 -0
  81. package/src/components/playground/input-parts/InputToolbar.tsx +245 -0
  82. package/src/components/playground/input-parts/ResourceLibraryPanel.tsx +287 -0
  83. package/src/components/playground/sidebarDsdIO.ts +82 -0
  84. package/src/components/settings/SettingsPanel.tsx +267 -0
  85. package/src/components/shell/AppHeader.tsx +9 -0
  86. package/src/components/shell/AppShell.tsx +139 -0
  87. package/src/components/shell/ArtifactBar.tsx +97 -0
  88. package/src/components/shell/BootScreen.tsx +19 -0
  89. package/src/components/shell/CenterComposite.tsx +87 -0
  90. package/src/components/shell/CodeEditorPanel.tsx +88 -0
  91. package/src/components/shell/GlobalOverlays.tsx +228 -0
  92. package/src/components/shell/LayoutConfigurator.tsx +209 -0
  93. package/src/components/shell/LayoutGrid.tsx +178 -0
  94. package/src/components/shell/MorphShell.tsx +368 -0
  95. package/src/components/shell/PluginViewer.tsx +147 -0
  96. package/src/components/shell/ShellNexusPreview.tsx +458 -0
  97. package/src/components/shell/SlotRenderer.tsx +115 -0
  98. package/src/components/shell/TabBar.tsx +94 -0
  99. package/src/components/shell/TemplateLibrary.tsx +195 -0
  100. package/src/components/shell/layoutConstants.ts +35 -0
  101. package/src/components/shell/morphStageMeta.ts +15 -0
  102. package/src/components/shell/shells/BuiltInShells.tsx +443 -0
  103. package/src/components/shell/shells/DatawayChatShell.tsx +42 -0
  104. package/src/components/shell/shells/TokenPreview.tsx +339 -0
  105. package/src/components/shell/shells/bootShells.ts +31 -0
  106. package/src/components/shells/CreatorShell.tsx +37 -0
  107. package/src/components/shells/DecidoShell.tsx +447 -0
  108. package/src/components/shells/ExperimentalChatShell.tsx +245 -0
  109. package/src/components/shells/UserCanvas.tsx +44 -0
  110. package/src/components/studio/BlueprintManagerPanel.tsx +137 -0
  111. package/src/components/studio/DependencyTreePanel.tsx +192 -0
  112. package/src/components/studio/NodePalette.tsx +92 -0
  113. package/src/components/studio/NodePropertiesPanel.tsx +81 -0
  114. package/src/components/studio/ReactFlowEditor.tsx +242 -0
  115. package/src/components/studio/TimelineEditor.tsx +122 -0
  116. package/src/components/studio/TimelineKeyframeCard.tsx +99 -0
  117. package/src/components/studio/VariablePanel.tsx +181 -0
  118. package/src/components/studio/blueprint/BlueprintCard.tsx +82 -0
  119. package/src/components/studio/editor/CanvasContextMenu.tsx +107 -0
  120. package/src/components/studio/editor/EditorToolbar.tsx +80 -0
  121. package/src/components/studio/editor/StageContentRenderer.tsx +134 -0
  122. package/src/components/studio/editor/TrackPropertyEditors.tsx +133 -0
  123. package/src/components/studio/editor/TreeNodeItem.tsx +91 -0
  124. package/src/components/studio/editor/edgeStyles.ts +43 -0
  125. package/src/components/studio/editor/editorKeyHandler.ts +95 -0
  126. package/src/components/studio/editor/nodeTypeRegistry.ts +137 -0
  127. package/src/components/studio/editor/paletteCatalog.tsx +84 -0
  128. package/src/components/studio/nodes/shell/InteractionNodes.tsx +82 -0
  129. package/src/components/studio/nodes/shell/LayoutControlNodes.tsx +69 -0
  130. package/src/components/studio/nodes/shell/RegisterActionNode.tsx +20 -0
  131. package/src/components/studio/nodes/shell/RegisterButtonNode.tsx +22 -0
  132. package/src/components/studio/nodes/shell/RegisterPanelNode.tsx +19 -0
  133. package/src/components/studio/nodes/shell/RegisterSidebarNode.tsx +19 -0
  134. package/src/components/studio/nodes/shell/RegisterStatusBarNode.tsx +22 -0
  135. package/src/components/studio/nodes/shell/RegisterTabNode.tsx +21 -0
  136. package/src/components/studio/nodes/shell/RegisterTopBarNode.tsx +22 -0
  137. package/src/components/studio/nodes/shell/ShellConfigNode.tsx +51 -0
  138. package/src/components/studio/nodes/shell/ShellNodeBase.tsx +100 -0
  139. package/src/components/studio/nodes/shell/ThemeNodes.tsx +51 -0
  140. package/src/components/studio/nodes/shell/index.ts +12 -0
  141. package/src/components/widgets/BroadcastWidget.tsx +93 -0
  142. package/src/components/widgets/MarketplaceWidget.tsx +298 -0
  143. package/src/components/widgets/McpToolsWidget.tsx +231 -0
  144. package/src/components/widgets/OpsDashboard.tsx +59 -0
  145. package/src/components/widgets/QuickActionsWidget.tsx +60 -0
  146. package/src/components/widgets/UsageWidget.tsx +112 -0
  147. package/src/components/widgets/WidgetRenderer.tsx +892 -0
  148. package/src/components/widgets/WidgetSlotPanel.tsx +213 -0
  149. package/src/config/IconRegistry.ts +126 -0
  150. package/src/contexts/NetworkProvider.tsx +162 -0
  151. package/src/core/AIDirector.ts +71 -0
  152. package/src/core/EventBus.ts +37 -0
  153. package/src/core/PluginContext.tsx +141 -0
  154. package/src/hooks/listeners/useUIStateListener.ts +59 -0
  155. package/src/hooks/listeners/useWhatsAppListener.ts +110 -0
  156. package/src/hooks/morphBridge.ts +82 -0
  157. package/src/hooks/useAIModelSelector.ts +144 -0
  158. package/src/hooks/useAgentStream.ts +220 -0
  159. package/src/hooks/useAutoUpdater.ts +89 -0
  160. package/src/hooks/useBootSequence.ts +20 -0
  161. package/src/hooks/useExportDSD.ts +53 -0
  162. package/src/hooks/useFullscreen.ts +35 -0
  163. package/src/hooks/useGeminiStream.ts +282 -0
  164. package/src/hooks/useIntentLens.ts +224 -0
  165. package/src/hooks/useKeyboardShortcuts.ts +69 -0
  166. package/src/hooks/useLoggerBridge.ts +32 -0
  167. package/src/hooks/useMcpClient.ts +112 -0
  168. package/src/hooks/useNexusaiDeploy.ts +118 -0
  169. package/src/hooks/usePlaybackEngine.ts +21 -0
  170. package/src/hooks/usePlaygroundCommander.ts +475 -0
  171. package/src/hooks/usePluginEngine.ts +165 -0
  172. package/src/hooks/useScreenRecorder.ts +73 -0
  173. package/src/hooks/useShellKeyboard.ts +40 -0
  174. package/src/hooks/useShellShortcuts.ts +118 -0
  175. package/src/hooks/useSoundEffects.ts +35 -0
  176. package/src/hooks/useStudioConfig.ts +72 -0
  177. package/src/hooks/useSystemBoot.ts +84 -0
  178. package/src/hooks/useSystemTelemetry.ts +62 -0
  179. package/src/index.ts +97 -0
  180. package/src/lib/debugLogger.ts +80 -0
  181. package/src/lib/networkInterceptor.ts +100 -0
  182. package/src/mocks/decido.tsx +41 -0
  183. package/src/plugins/pluginAPI.ts +190 -0
  184. package/src/store/McpStore.ts +69 -0
  185. package/src/store/UpdaterStore.ts +60 -0
  186. package/src/store/engine.ts +392 -0
  187. package/src/store/index.ts +4 -0
  188. package/src/store/layoutPresets.ts +66 -0
  189. package/src/store/playgroundTypes.ts +98 -0
  190. package/src/store/useActionTimelineStore.ts +48 -0
  191. package/src/store/useDebugPanelStore.ts +98 -0
  192. package/src/store/useDebugProfileStore.ts +130 -0
  193. package/src/store/useLayoutStore.ts +205 -0
  194. package/src/store/useMorphInstanceStore.ts +289 -0
  195. package/src/store/useMorphologyStore.ts +103 -0
  196. package/src/store/usePlaygroundStore.ts +236 -0
  197. package/src/store/useShellRegistry.ts +123 -0
  198. package/src/store/useSuggestionsStore.ts +57 -0
  199. package/src/store/useThemeStore.ts +399 -0
  200. package/src/store/useUIComponentStore.ts +179 -0
  201. package/src/types/DecidoStoryDefinition.ts +43 -0
  202. package/src/utils/ai/ai-architect.ts +92 -0
  203. package/src/utils/ai/ai-code.ts +187 -0
  204. package/src/utils/ai/ai-core.ts +50 -0
  205. package/src/utils/ai/ai-media.ts +292 -0
  206. package/src/utils/layoutGraph.ts +67 -0
  207. package/tsconfig.json +17 -0
  208. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1,222 @@
1
+ import React from 'react';
2
+ import { PanelLeftClose, PanelLeftOpen, Plus, Share2, Bug, Sun, Moon, MessageSquare, MessageSquareOff } from 'lucide-react';
3
+ import { useTheme } from '../../store/useThemeStore';
4
+ import { HeaderCenterControls } from './HeaderCenterControls';
5
+ import { LayoutConfigurator } from '../shell/LayoutConfigurator';
6
+ import { usePlaygroundStore } from '../../store/usePlaygroundStore';
7
+ import { useEngineStore } from '@decido/engine';
8
+ import { useDebugPanelStore } from '../../store/useDebugPanelStore';
9
+ import { useLayoutStore } from '../../store/useLayoutStore';
10
+
11
+ // --------------------------------------------------
12
+ // Types
13
+ // --------------------------------------------------
14
+ export interface HeaderAction {
15
+ id: string;
16
+ icon?: React.ReactNode;
17
+ label?: string;
18
+ onClick: () => void;
19
+ variant?: 'ghost' | 'outline' | 'accent';
20
+ /** Show a pulsing dot indicator */
21
+ showIndicator?: boolean;
22
+ indicatorColor?: string;
23
+ /** Only show in creator / player / both */
24
+ visibleIn?: 'creator' | 'player' | 'both';
25
+ className?: string;
26
+ }
27
+
28
+ export interface PlaygroundHeaderProps {
29
+ /** Additional dynamic action buttons */
30
+ extraActions?: HeaderAction[];
31
+ /** Active model / persona label */
32
+ modelLabel?: string;
33
+ onModelClick?: () => void;
34
+ }
35
+
36
+ // ─── Theme Toggle Button ───
37
+ function ThemeToggleBtn() {
38
+ const currentThemeId = useTheme((s) => s.currentThemeId);
39
+ const setTheme = useTheme((s) => s.setTheme);
40
+ const isDark = currentThemeId !== 'decido-light';
41
+
42
+ return (
43
+ <button
44
+ onClick={() => setTheme(isDark ? 'decido-light' : 'decido-dark')}
45
+ className="w-8 h-8 rounded-lg flex items-center justify-center transition-all duration-200 border text-text-secondary hover:text-text-primary hover:bg-surface-glass border-transparent"
46
+ title={isDark ? 'Cambiar a Decido Light' : 'Cambiar a Decido Dark'}
47
+ aria-label={isDark ? 'Cambiar a tema claro' : 'Cambiar a tema oscuro'}
48
+ >
49
+ <div className="relative w-4 h-4">
50
+ <Sun
51
+ size={16}
52
+ className="absolute inset-0 transition-all duration-300"
53
+ style={{
54
+ opacity: isDark ? 0 : 1,
55
+ transform: isDark ? 'rotate(-90deg) scale(0.5)' : 'rotate(0deg) scale(1)',
56
+ color: isDark ? undefined : '#f59e0b',
57
+ }}
58
+ />
59
+ <Moon
60
+ size={16}
61
+ className="absolute inset-0 transition-all duration-300"
62
+ style={{
63
+ opacity: isDark ? 1 : 0,
64
+ transform: isDark ? 'rotate(0deg) scale(1)' : 'rotate(90deg) scale(0.5)',
65
+ color: isDark ? '#a78bfa' : undefined,
66
+ }}
67
+ />
68
+ </div>
69
+ </button>
70
+ );
71
+ }
72
+
73
+ export const PlaygroundHeader = React.memo(function PlaygroundHeader({
74
+ extraActions = [],
75
+ modelLabel,
76
+ onModelClick,
77
+ }: PlaygroundHeaderProps) {
78
+ // ── Read from stores ──
79
+ const isSidebarOpen = usePlaygroundStore((s) => s.isSidebarOpen);
80
+ const setIsSidebarOpen = usePlaygroundStore((s) => s.setIsSidebarOpen);
81
+ const prototypeBrand = usePlaygroundStore((s) => s.prototypeBrand);
82
+ const isCreatorMode = usePlaygroundStore((s) => s.isCreatorMode);
83
+ const setIsCreatorMode = usePlaygroundStore((s) => s.setIsCreatorMode);
84
+ const creatorViewMode = usePlaygroundStore((s) => s.creatorViewMode);
85
+ const setCreatorViewMode = usePlaygroundStore((s) => s.setCreatorViewMode);
86
+ const isVoiceActive = usePlaygroundStore((s) => s.isVoiceActive);
87
+ const { isSpeaking } = useEngineStore();
88
+ const debugIsOpen = useDebugPanelStore((s) => s.isOpen);
89
+ const debugErrorCount = useDebugPanelStore((s) => s.errorCount);
90
+ const toggleDebugPanel = useDebugPanelStore((s) => s.togglePanel);
91
+ const showChat = useLayoutStore((s) => s.showChat);
92
+ const setShowChat = useLayoutStore((s) => s.setShowChat);
93
+ const pgSetShowChat = usePlaygroundStore((s) => s.setShowChat);
94
+
95
+ const toggleChat = () => {
96
+ const newVal = !showChat;
97
+ setShowChat(newVal);
98
+ pgSetShowChat(newVal);
99
+ };
100
+
101
+ // Sync layout store on mode toggle
102
+ const syncCreatorMode = (newVal: boolean) => {
103
+ setIsCreatorMode(newVal);
104
+ useLayoutStore.getState().setIsCreatorMode(newVal);
105
+ };
106
+
107
+ // Built-in actions
108
+ const builtInActions: HeaderAction[] = [
109
+ {
110
+ id: 'toggle-chat',
111
+ icon: showChat ? <MessageSquareOff size={16} /> : <MessageSquare size={16} />,
112
+ label: showChat ? 'Ocultar chat' : 'Mostrar chat',
113
+ onClick: toggleChat,
114
+ variant: showChat ? 'ghost' : 'outline',
115
+ visibleIn: 'both',
116
+ className: showChat ? 'text-text-secondary' : 'text-accent-cyan bg-surface-glass border-accent-cyan/30',
117
+ },
118
+ {
119
+ id: 'debug-panel',
120
+ icon: <Bug size={16} />,
121
+ onClick: toggleDebugPanel,
122
+ variant: debugIsOpen ? 'accent' : 'ghost',
123
+ showIndicator: debugErrorCount > 0,
124
+ indicatorColor: 'bg-status-error',
125
+ visibleIn: 'both',
126
+ },
127
+ ];
128
+
129
+ const allActions = [...builtInActions, ...extraActions];
130
+ const visibleActions = allActions.filter(a =>
131
+ !a.visibleIn || a.visibleIn === 'both' ||
132
+ (a.visibleIn === 'creator' && isCreatorMode) ||
133
+ (a.visibleIn === 'player' && !isCreatorMode)
134
+ );
135
+
136
+ const getVariantClasses = (variant: HeaderAction['variant'] = 'ghost') => {
137
+ switch (variant) {
138
+ case 'accent':
139
+ return 'bg-surface-glass text-accent-cyan hover:bg-surface-elevated border border-accent-cyan';
140
+ case 'outline':
141
+ return 'bg-transparent text-text-primary hover:bg-surface-glass border-border-default';
142
+ default:
143
+ return 'bg-transparent text-text-secondary hover:text-text-primary hover:bg-surface-glass border-transparent';
144
+ }
145
+ };
146
+
147
+ return (
148
+ <header
149
+ data-tauri-drag-region
150
+ className="flex-none h-12 px-3 flex items-center justify-between bg-surface-secondary backdrop-blur-md border-b border-border-default shadow-[0_1px_3px_0_rgba(0,0,0,0.08)] z-30 select-none"
151
+ >
152
+ {/* ─── LEFT ─── */}
153
+ <div className="flex items-center gap-1.5 min-w-0">
154
+ {/* Sidebar Toggle */}
155
+ <button
156
+ onClick={() => setIsSidebarOpen(!isSidebarOpen)}
157
+ className="w-8 h-8 rounded-lg text-text-secondary hover:text-text-primary hover:bg-surface-glass flex items-center justify-center transition-all duration-150 shrink-0"
158
+ title={isSidebarOpen ? 'Cerrar panel' : 'Abrir panel'}
159
+ >
160
+ {isSidebarOpen ? <PanelLeftClose size={18} /> : <PanelLeftOpen size={18} />}
161
+ </button>
162
+
163
+ {/* New Chat / Action */}
164
+ <button
165
+ className="w-8 h-8 rounded-lg text-text-secondary hover:text-text-primary hover:bg-surface-glass flex items-center justify-center transition-all duration-150 shrink-0"
166
+ title="Nueva Conversación"
167
+ >
168
+ <Plus size={18} />
169
+ </button>
170
+
171
+ <div className="h-4 w-px bg-border-subtle mx-1 hidden sm:block" />
172
+
173
+ {/* Brand / Title */}
174
+ <div
175
+ data-tauri-drag-region
176
+ className="flex items-center gap-2 min-w-0 cursor-default"
177
+ >
178
+ <span className="text-sm font-semibold text-text-primary/80 tracking-tight truncate hidden sm:inline">
179
+ <span className="text-accent-cyan capitalize">{prototypeBrand || 'Decido'} OS</span>
180
+ </span>
181
+ </div>
182
+ </div>
183
+
184
+ {/* ─── CENTER: Controls ─── */}
185
+ <HeaderCenterControls isSpeaking={!!isSpeaking} isCreatorMode={isCreatorMode} creatorViewMode={creatorViewMode}
186
+ modelLabel={modelLabel} onModelClick={onModelClick} onSyncCreatorMode={syncCreatorMode} onSetCreatorViewMode={setCreatorViewMode} />
187
+
188
+ {/* ─── RIGHT: Dynamic Action Buttons ─── */}
189
+ <div className="flex items-center gap-1">
190
+ {visibleActions.map(action => (
191
+ <button
192
+ key={action.id}
193
+ onClick={action.onClick}
194
+ className={`relative h-8 rounded-lg flex items-center justify-center transition-all duration-150 border text-xs font-medium ${action.className || ''} ${getVariantClasses(action.variant)} ${action.label ? 'px-3 gap-1.5' : 'w-8'}`}
195
+ title={action.label}
196
+ >
197
+ {action.icon}
198
+ {action.label && <span className="hidden sm:inline">{action.label}</span>}
199
+ {action.showIndicator && (
200
+ <span className={`absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full ${action.indicatorColor || 'bg-accent-cyan'} shadow-[0_0_6px] animate-pulse`} />
201
+ )}
202
+ </button>
203
+ ))}
204
+
205
+ {/* Theme Toggle (Dark ↔ Light) */}
206
+ <ThemeToggleBtn />
207
+
208
+ {/* Layout Configurator */}
209
+ <LayoutConfigurator />
210
+
211
+ {/* Share / Export (static) */}
212
+ <button
213
+ className="w-8 h-8 rounded-lg text-text-secondary hover:text-text-primary hover:bg-surface-glass flex items-center justify-center transition-all duration-150"
214
+ title="Compartir"
215
+ >
216
+ <Share2 size={16} />
217
+ </button>
218
+ </div>
219
+ </header>
220
+ );
221
+ });
222
+
@@ -0,0 +1,136 @@
1
+ import React from 'react';
2
+ import { Menu, Play, Trash2, Save, Download, Upload, Database } from 'lucide-react';
3
+ import { usePlaygroundStore } from '../../store/usePlaygroundStore';
4
+ import { useEngineStore } from '@decido/engine';
5
+ import { KeyframeListItem } from './KeyframeListItem';
6
+ import { downloadSequenceAsDSD, handleSequenceUpload } from './sidebarDsdIO';
7
+
8
+ export interface PlaygroundSidebarProps {
9
+ isSidebarOpen: boolean;
10
+ setIsSidebarOpen: (open: boolean) => void;
11
+ prototypeBrand: string;
12
+ dynamicTimelines: any;
13
+ setDynamicTimelines: any;
14
+ currentTime: number;
15
+ setCurrentTime: (time: number) => void;
16
+ }
17
+
18
+ export const PlaygroundSidebar = React.memo(function PlaygroundSidebar({
19
+ isSidebarOpen, setIsSidebarOpen, prototypeBrand, dynamicTimelines, setDynamicTimelines, currentTime, setCurrentTime
20
+ }: PlaygroundSidebarProps) {
21
+ const [editingKeyframe, setEditingKeyframe] = React.useState<number | null>(null);
22
+ const savedSequences = usePlaygroundStore(state => state.savedSequences);
23
+ const removeSavedSequence = usePlaygroundStore(state => state.removeSavedSequence);
24
+ const variables = useEngineStore(state => state.variables);
25
+
26
+ const brandSequences = savedSequences.filter(seq => seq.brand === prototypeBrand);
27
+
28
+ const loadSequence = (seq: any) => {
29
+ setDynamicTimelines((prev: any) => ({
30
+ ...prev,
31
+ [prototypeBrand]: { duration: seq.duration, keyframes: seq.keyframes }
32
+ }));
33
+ setCurrentTime(0);
34
+ };
35
+
36
+ const handleUpdateKeyframe = (index: number, newTime: string, newSpeech: string) => {
37
+ const t = parseFloat(newTime);
38
+ if (isNaN(t)) return;
39
+ setDynamicTimelines((prev: any) => {
40
+ const currentTimelines = { ...prev };
41
+ const updatedKeyframes = [...currentTimelines[prototypeBrand].keyframes];
42
+ updatedKeyframes[index] = { ...updatedKeyframes[index], t, speech: newSpeech };
43
+ updatedKeyframes.sort((a, b) => a.t - b.t);
44
+ return { ...currentTimelines, [prototypeBrand]: { ...currentTimelines[prototypeBrand], keyframes: updatedKeyframes } };
45
+ });
46
+ setEditingKeyframe(null);
47
+ };
48
+
49
+ if (!dynamicTimelines[prototypeBrand]) return null;
50
+
51
+ const keyframes = dynamicTimelines[prototypeBrand].keyframes;
52
+
53
+ return (
54
+ <div className="flex flex-col h-full w-full bg-surface-secondary/90 backdrop-blur-xl border-r border-border-subtle z-30 overflow-hidden">
55
+ <div className="w-full min-w-0 p-4 flex flex-col h-full opacity-100">
56
+ <div className="flex items-center gap-3 mb-6 mt-2">
57
+ <button onClick={() => setIsSidebarOpen(false)} className="p-2 -ml-2 rounded-full hover:bg-surface-glass text-text-secondary hover:text-text-primary transition-colors">
58
+ <Menu size={22} />
59
+ </button>
60
+ <span className="font-bold text-text-primary tracking-wide">Inspector de Capas</span>
61
+ </div>
62
+
63
+ <div className="flex-1 overflow-y-auto space-y-4 pr-2 custom-scrollbar">
64
+ {/* Saved Sequences */}
65
+ {brandSequences.length > 0 && (
66
+ <div className="space-y-2 mb-6">
67
+ <div className="flex items-center justify-between px-2 mb-2">
68
+ <div className="text-xs font-mono text-text-muted tracking-wider flex items-center gap-2 uppercase">
69
+ <Save size={12} /> Secuencias Guardadas
70
+ </div>
71
+ <label className="cursor-pointer text-text-muted hover:text-cyan-400 transition-colors p-1" title="Importar Secuencia JSON">
72
+ <Upload size={14} />
73
+ <input type="file" accept=".json" className="hidden" onChange={(e) => handleSequenceUpload(e, prototypeBrand)} />
74
+ </label>
75
+ </div>
76
+ <div className="space-y-1">
77
+ {brandSequences.map((seq) => (
78
+ <div key={seq.id} className="flex items-center justify-between p-2 rounded-lg bg-surface-glass hover:bg-surface-glass border border-border-subtle transition-colors group">
79
+ <button onClick={() => loadSequence(seq)} className="flex-1 text-left min-w-0 pr-2">
80
+ <div className="text-xs font-medium text-text-primary truncate" title={seq.prompt}>{seq.prompt}</div>
81
+ <div className="text-[10px] text-text-muted font-mono mt-0.5">{seq.duration.toFixed(1)}s • {seq.keyframes.length} frames</div>
82
+ </button>
83
+ <div className="flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity">
84
+ <button onClick={() => downloadSequenceAsDSD(seq)} className="p-1.5 rounded hover:bg-purple-500/20 text-purple-400 transition-colors" title="Exportar JSON"><Download size={14} /></button>
85
+ <button onClick={() => loadSequence(seq)} className="p-1.5 rounded hover:bg-cyan-500/20 text-cyan-400 transition-colors" title="Cargar y reproducir"><Play size={14} /></button>
86
+ <button onClick={() => removeSavedSequence(seq.id)} className="p-1.5 rounded hover:bg-red-500/20 text-red-400 transition-colors" title="Eliminar secuencia"><Trash2 size={14} /></button>
87
+ </div>
88
+ </div>
89
+ ))}
90
+ </div>
91
+ </div>
92
+ )}
93
+
94
+ {/* Watch Panel */}
95
+ <div className="space-y-2 mb-6 select-text">
96
+ <div className="flex items-center justify-between px-2 mb-2">
97
+ <div className="text-xs font-mono text-cyan-500 tracking-wider flex items-center gap-2 uppercase">
98
+ <Database size={12} /> Watch: Variables Globales
99
+ </div>
100
+ </div>
101
+ <div className="bg-surface-overlay border border-border-subtle rounded-lg p-2 font-mono text-[10px] overflow-hidden">
102
+ {Object.keys(variables).length === 0 ? (
103
+ <div className="text-text-muted italic px-1">Memoria vacía. El runtime iniciará las variables al ejecutar Nodos.</div>
104
+ ) : (
105
+ <div className="space-y-1">
106
+ {Object.entries(variables).map(([key, value]) => (
107
+ <div key={key} className="flex flex-col group hover:bg-surface-glass rounded px-1 transition-colors">
108
+ <span className="text-purple-400 font-bold">{key}:</span>
109
+ <span className="text-text-primary pl-2 break-all">
110
+ {typeof value === 'object' ? JSON.stringify(value) : String(value)}
111
+ </span>
112
+ </div>
113
+ ))}
114
+ </div>
115
+ )}
116
+ </div>
117
+ </div>
118
+
119
+ {/* Keyframe Timeline */}
120
+ <div className="space-y-2">
121
+ <div className="text-xs font-mono text-text-muted px-2 tracking-wider uppercase">Línea de Tiempo ({prototypeBrand})</div>
122
+ {keyframes.map((kf: any, i: number) => {
123
+ const isPast = currentTime >= kf.t;
124
+ const isActive = isPast && (i === keyframes.length - 1 || currentTime < keyframes[i + 1].t);
125
+ return (
126
+ <KeyframeListItem key={i} kf={kf} index={i} isActive={isActive} isPast={isPast}
127
+ isEditing={editingKeyframe === i} isLast={i === keyframes.length - 1}
128
+ onSeek={setCurrentTime} onStartEdit={setEditingKeyframe} onSaveEdit={handleUpdateKeyframe} />
129
+ );
130
+ })}
131
+ </div>
132
+ </div>
133
+ </div>
134
+ </div>
135
+ );
136
+ });
@@ -0,0 +1,44 @@
1
+ import React from 'react';
2
+ import { motion, AnimatePresence } from 'motion/react';
3
+ import { Terminal, Trash2, X } from 'lucide-react';
4
+
5
+ export interface PlaygroundTerminalProps {
6
+ isOpen: boolean;
7
+ setIsOpen: (open: boolean) => void;
8
+ logs: { time: string, msg: string, type: string }[];
9
+ setLogs: (logs: { time: string, msg: string, type: string }[]) => void;
10
+ logsEndRef: React.RefObject<HTMLDivElement | null>;
11
+ }
12
+
13
+ export const PlaygroundTerminal = React.memo(function PlaygroundTerminal({ isOpen, setIsOpen, logs, setLogs, logsEndRef }: PlaygroundTerminalProps) {
14
+ return (
15
+ <AnimatePresence>
16
+ {isOpen && (
17
+ <motion.div
18
+ initial={{ opacity: 0, y: 50 }} animate={{ opacity: 1, y: 0 }} exit={{ opacity: 0, y: 50 }}
19
+ className="absolute right-6 bottom-40 w-80 h-64 bg-surface-overlay backdrop-blur-md border border-border-default rounded-xl flex flex-col overflow-hidden z-30 shadow-2xl"
20
+ >
21
+ <div className="flex items-center justify-between px-3 py-2 border-b border-border-default bg-surface-glass">
22
+ <div className="flex items-center gap-2">
23
+ <Terminal size={14} className="text-text-secondary" />
24
+ <span className="text-xs font-mono text-text-secondary">System Log</span>
25
+ </div>
26
+ <div className="flex items-center gap-2">
27
+ <button onClick={() => setLogs([])} className="text-text-muted hover:text-red-400 transition-colors" title="Limpiar logs"><Trash2 size={14} /></button>
28
+ <button onClick={() => setIsOpen(false)} className="text-text-muted hover:text-text-primary transition-colors"><X size={14} /></button>
29
+ </div>
30
+ </div>
31
+ <div className="flex-1 overflow-y-auto p-3 font-mono text-[10px] space-y-1 custom-scrollbar">
32
+ {logs.map((log, i) => (
33
+ <div key={i} className={`flex gap-2 ${log.type === 'error' ? 'text-red-400' : log.type === 'success' ? 'text-emerald-400' : log.type === 'system' ? 'text-purple-400' : 'text-text-secondary'}`}>
34
+ <span className="opacity-50 shrink-0">[{log.time}]</span>
35
+ <span className="wrap-break-word">{log.msg}</span>
36
+ </div>
37
+ ))}
38
+ <div ref={logsEndRef} />
39
+ </div>
40
+ </motion.div>
41
+ )}
42
+ </AnimatePresence>
43
+ );
44
+ });
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import { resolveIcon, resolveColor } from '../../config/IconRegistry';
3
+
4
+ interface SuggestionCardsProps {
5
+ suggestions: any[];
6
+ onSelect: (command: string) => void;
7
+ }
8
+
9
+ export const SuggestionCards = React.memo(function SuggestionCards({ suggestions, onSelect }: SuggestionCardsProps) {
10
+ return (
11
+ <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2.5 sm:gap-3 w-full min-w-0 max-w-full mt-3 sm:mt-4">
12
+ {suggestions.map((sug, i) => {
13
+ const IconComponent = resolveIcon(sug.icon);
14
+ const colorClass = resolveColor(sug.color);
15
+ return (
16
+ <div key={i} className="group relative flex flex-col p-3 sm:p-4 bg-surface-tertiary hover:bg-surface-elevated border border-border-subtle hover:border-border-default rounded-xl sm:rounded-2xl text-left transition-all overflow-hidden h-auto min-h-[6rem] sm:h-32 min-w-0">
17
+ <div className="flex-1 cursor-pointer flex flex-col min-w-0" onClick={() => onSelect(sug.command)}>
18
+ <div className="flex items-center gap-2 mb-1.5 sm:mb-2">
19
+ <div className={`p-1 sm:p-1.5 rounded-full bg-surface-glass shrink-0 ${colorClass}`}><IconComponent size={12} className="sm:w-3.5 sm:h-3.5" /></div>
20
+ <span className={`text-[11px] sm:text-xs font-bold truncate ${colorClass}`}>{sug.title}</span>
21
+ </div>
22
+ <p className="text-xs sm:text-sm text-text-secondary flex-1 leading-snug line-clamp-2 sm:line-clamp-3 overflow-hidden break-words">"{sug.command}"</p>
23
+ </div>
24
+ </div>
25
+ );
26
+ })}
27
+ </div>
28
+ );
29
+ });