-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Expand file tree
/
Copy pathEntryShell.tsx
More file actions
3803 lines (3685 loc) · 140 KB
/
Copy pathEntryShell.tsx
File metadata and controls
3803 lines (3685 loc) · 140 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// EntryShell — the centered-hero entry layout.
//
// This component owns the entire JSX render and local UI state for
// the redesigned home view (left rail + sticky settings cog + hero +
// recent projects + plugins section + new-project modal). It is
// intentionally a sibling of `EntryView` so that upstream `main`
// changes to `EntryView` (props, connector lifecycle, helpers, exports)
// can be rebased without touching this file. `EntryView` becomes a
// thin wrapper that passes data and callbacks through to this shell.
import {
useCallback,
useEffect,
useLayoutEffect,
useRef,
useState,
type CSSProperties,
type Dispatch,
type KeyboardEvent as ReactKeyboardEvent,
type ReactNode,
type SetStateAction,
} from 'react';
import {
defaultScenarioPluginIdForProjectMetadata,
PROFILE_MEMORY_ID,
type ChatSessionMode,
type ConnectorDetail,
type InstalledPluginRecord,
type RunContextSelection,
type UpsertMemoryRequest,
} from '@open-design/contracts';
import type { OpenDesignHostProjectImportSuccess } from '@open-design/host';
import type { DesignSystemGenerateSnapshot } from './DesignSystemFlow';
import { useAnalytics } from '../analytics/provider';
import {
trackHomeNavClick,
trackHomeToolbarClick,
trackOnboardingClick,
trackOnboardingCompleteResult,
trackOnboardingRuntimeScanResult,
trackPageView,
} from '../analytics/events';
import {
amrHandoffDeviceId,
recordAmrEntry,
syncAmrAttributionWithOnboardingProfile,
type AmrEntryAttribution,
} from '../analytics/amr-attribution';
import { getResolvedDeviceId } from '../analytics/client';
import {
beginAmrAuthTracking,
resolveAmrAuthTracking,
} from '../analytics/amr-auth';
import { setOnboardingAttributionPersonProperties } from '../analytics/source-attribution';
import {
clearOnboardingSessionId,
getOrCreateOnboardingSessionId,
} from '../analytics/onboarding-session';
import type {
TrackingOnboardingArea,
TrackingOnboardingStepIndex,
TrackingOnboardingStepName,
TrackingOnboardingClickElement,
TrackingOnboardingClickAction,
TrackingOnboardingRuntimeType,
TrackingOnboardingCompletionResult,
TrackingOnboardingCompletionType,
TrackingCliProviderId,
} from '@open-design/contracts/analytics';
import { agentIdToTracking } from '@open-design/contracts/analytics';
import { useT, useI18n } from '../i18n';
import { navigate, useRoute } from '../router';
import { setPendingDesignSystemCreateEntry } from '../analytics/ds-create-entry';
import type {
AgentInfo,
ApiProtocol,
ApiProtocolConfig,
AppConfig,
AppTheme,
ConnectionTestResponse,
DesignSystemSummary,
ExecMode,
Project,
ProjectMetadata,
ProjectTemplate,
PromptTemplateSummary,
ProviderModelOption,
ProviderModelsResponse,
SkillSummary,
} from '../types';
import { CenteredLoader } from './Loading';
import { DesignsTab } from './DesignsTab';
import { DesignSystemsTab } from './DesignSystemsTab';
import { BrandsTab } from './BrandsTab';
import { EntryNavRail, type EntryView as EntryViewKind } from './EntryNavRail';
import { LibrarySection } from './LibrarySection';
import { UpdaterPopup } from './UpdaterPopup';
import { GithubStarBadge } from './GithubStarBadge';
import {
formatDiscordPresenceCount,
useDiscordPresence,
} from './useDiscordPresence';
import { HomeView, seedHomeComposerPrompt } from './HomeView';
import {
createPluginAuthoringHandoff,
createPluginUseHandoff,
type HomePromptHandoff,
} from './home-hero/plugin-authoring';
import { ONBOARDING_ARTIFACT_CHIP_IDS } from './home-hero/chips';
import { homeHeroChipLabel } from './home-hero/chip-labels';
import type { PluginUseAction } from './plugins-home/useActions';
import { Icon } from './Icon';
import { AgentIcon } from './AgentIcon';
import { CommunityView } from './CommunityView';
import { TeamSlotPlaceholder } from './TeamSlotPlaceholder';
import { useWorkspaceContext } from '../collab/useWorkspaceContext';
import { LanguageMenu } from './LanguageMenu';
import { IntegrationsView, type IntegrationTab } from './IntegrationsView';
import { InlineModelSwitcher } from './InlineModelSwitcher';
import { enterpriseUrl } from './enterpriseUrl';
import {
EntrySettingsMenu,
type EntrySettingsSection,
} from './EntrySettingsMenu';
import { NewProjectModal } from './NewProjectModal';
import { PluginsView } from './PluginsView';
import type { CreateInput, CreateTab, ImportClaudeDesignOutcome } from './NewProjectPanel';
import type { PluginLoopSubmit } from './PluginLoopHome';
import {
createProject,
type PluginShareAction,
type PluginShareProjectOutcome,
} from '../state/projects';
import { TasksView } from './TasksView';
import { TeamProjectsView } from './TeamProjectsView';
import {
API_KEY_PLACEHOLDERS,
API_PROTOCOL_TABS,
SUGGESTED_MODELS_BY_PROTOCOL,
} from '../state/apiProtocols';
import { KNOWN_PROVIDERS } from '../state/config';
import type { KnownProvider } from '../state/config';
import { saveOnboardingProfile } from '../state/onboarding-profile';
import { testApiProvider } from '../providers/connection-test';
import { fetchProviderModels } from '../providers/provider-models';
import {
cancelVelaLogin,
fetchVelaLoginStatus,
startVelaLogin,
type VelaLoginStatus,
} from '../providers/daemon';
import {
AMR_LOGIN_POLL_INTERVAL_MS,
amrLoginPollOutcome,
notifyAmrLoginStatusChanged,
} from './amrLoginPolling';
import { closeAmrActivationWindowBestEffort } from './AmrLoginPill';
import { smoothScrollToTop } from '../utils/smoothScrollToTop';
import { summarizeProjectNameFromPrompt } from '../utils/projectName';
import { LIBRARY_UI_VISIBLE } from '../features/libraryUi';
import {
providerModelsCacheKey,
type ProviderModelsCache,
} from './providerModelsCache';
// Persist the entry nav-rail open/collapsed state so it survives both a
// home -> project -> home navigation (EntryShell unmounts on the project
// route) and a full reload. Without this the rail always reset to its
// collapsed default on return.
const RAIL_OPEN_STORAGE_KEY = 'od.entry.railOpen';
function readStoredRailOpen(): boolean {
if (typeof window === 'undefined') return false;
try {
return window.localStorage.getItem(RAIL_OPEN_STORAGE_KEY) === 'true';
} catch {
return false;
}
}
function writeStoredRailOpen(open: boolean): void {
if (typeof window === 'undefined') return;
try {
window.localStorage.setItem(RAIL_OPEN_STORAGE_KEY, open ? 'true' : 'false');
} catch {
/* ignore quota / disabled storage */
}
}
const DISCORD_URL = 'https://discord.gg/mHAjSMV6gz';
const X_URL = 'https://x.com/OpenDesignHQ';
const ONBOARDING_DROPDOWN_OPEN_EVENT = 'open-design:onboarding-dropdown-open';
// The topbar chips (GitHub star, model switcher, Use everywhere)
// collapse into the settings dropdown when the viewport gets
// narrow. The transition is driven entirely by CSS @media queries
// in `entry-layout.css` so server and client render identical
// markup — both surfaces are always present, and CSS toggles
// `display` based on `--compact-topbar` breakpoint (900px).
// Default scenario plugin for each project kind/intent. The mapping
// lives in `@open-design/contracts` so the daemon's `/api/projects`
// and `/api/runs` fallbacks resolve to the same plugin id when no
// `pluginId` is on the request body — plan §3.3 of
// `specs/current/plugin-driven-flow-plan.md`.
// Newsletter signup endpoint. Lives on the marketing site (Cloudflare Pages
// Function backed by KV), so this is a cross-origin POST from the desktop
// client. Overridable at build time via NEXT_PUBLIC_NEWSLETTER_URL — e.g. point
// it at a local `wrangler pages dev` instance during development.
const NEWSLETTER_SUBSCRIBE_URL =
process.env.NEXT_PUBLIC_NEWSLETTER_URL ?? 'https://open-design.ai/subscribe';
const NEWSLETTER_EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
const ONBOARDING_BYOK_AUTO_FETCH_DELAY_MS = 300;
const ONBOARDING_BYOK_AUTO_TEST_DELAY_MS = 500;
const ONBOARDING_AMR_MODEL_OPTIONS: NonNullable<AgentInfo['models']> = [
{ id: 'claude-opus-4.8', label: 'Claude Opus 4.8' },
{ id: 'deepseek-v4-flash', label: 'DeepSeek V4 Flash' },
{ id: 'gemini-2.5-flash', label: 'Gemini 2.5 Flash' },
{ id: 'glm-5.1', label: 'GLM 5.1' },
];
type OnboardingProfileState = {
role: string;
orgSize: string;
useCase: string[];
source: string;
email: string;
};
type EntryCreateProjectInput = Omit<CreateInput, 'metadata'> & {
metadata?: CreateInput['metadata'];
pendingPrompt?: string;
pluginId?: string;
pluginType?: string;
appliedPluginSnapshotId?: string;
pluginInputs?: Record<string, unknown>;
initialRunContext?: RunContextSelection | null;
conversationMode?: ChatSessionMode;
autoSendFirstMessage?: boolean;
requestId?: string;
pendingFiles?: File[];
userWorkingDirToken?: string;
linkedDirs?: string[] | null;
};
function defaultPluginIdForMetadata(metadata: ProjectMetadata): string | null {
return defaultScenarioPluginIdForProjectMetadata(metadata);
}
function defaultPluginInputsForCreate(
input: CreateInput,
pluginId: string | null,
): Record<string, unknown> | null {
const kind = input.metadata.kind;
const projectName = input.name.trim();
if (pluginId === 'example-web-prototype') {
return {
artifactKind: input.metadata.includeLandingPage
? 'landing page'
: 'web prototype',
fidelity: input.metadata.fidelity ?? 'high-fidelity',
audience: 'product evaluators',
designSystem: 'the active project design system',
template: input.metadata.templateLabel ?? 'the bundled web prototype seed',
};
}
if (pluginId === 'example-simple-deck') {
return {
deckType: 'pitch deck',
topic: projectName || 'the user brief',
audience: 'decision makers',
slideCount: '10-15 pages',
speakerNotes: input.metadata.speakerNotes
? 'include speaker notes'
: 'no speaker notes',
designSystem: 'the active project design system',
};
}
if (pluginId === 'od-new-generation') {
const templateLabel = input.metadata.templateLabel?.trim();
const artifactKind =
kind === 'template'
? 'artifact based on a saved template'
: kind === 'other'
? 'custom design artifact'
: `${kind} artifact`;
return {
artifactKind,
audience: 'product and design reviewers',
topic: templateLabel || projectName || 'the user brief',
};
}
if (pluginId !== 'od-media-generation') return null;
if (kind !== 'image' && kind !== 'video' && kind !== 'audio') return null;
const promptTemplate = input.metadata.promptTemplate;
const subject =
promptTemplate?.prompt?.trim()
|| projectName
|| promptTemplate?.title?.trim()
|| `${kind} concept`;
const style =
promptTemplate?.summary?.trim()
|| 'cinematic, high-quality, on-brand';
const aspect =
kind === 'image'
? input.metadata.imageAspect
: kind === 'video'
? input.metadata.videoAspect
: undefined;
return {
mediaKind: kind,
subject,
style,
...(aspect ? { aspect } : {}),
};
}
interface Props {
skills: SkillSummary[];
designTemplates: SkillSummary[];
designSystems: DesignSystemSummary[];
projects: Project[];
templates: ProjectTemplate[];
onDeleteTemplate?: (id: string) => Promise<boolean>;
promptTemplates: PromptTemplateSummary[];
defaultDesignSystemId: string | null;
connectors: ConnectorDetail[];
connectorsLoading: boolean;
integrationInitialTab?: IntegrationTab;
composioConfigLoading?: boolean;
skillsLoading?: boolean;
designSystemsLoading?: boolean;
projectsLoading?: boolean;
// Execution / model-switching context. Threaded down from `App` so the
// top-bar `InlineModelSwitcher` can render the active mode/agent/model
// and persist changes through the same callbacks the project view uses.
config: AppConfig;
providerModelsCache?: ProviderModelsCache;
onProviderModelsCacheChange?: Dispatch<SetStateAction<ProviderModelsCache>>;
agents: AgentInfo[];
// True while the cold-start agent detection stream is still in flight
// (`fetchAgentsStream` has not reached its terminal `done`). Onboarding
// uses this to show the AMR cloud card in a detecting/skeleton state
// instead of hiding it during the seconds AMR's probe takes to settle.
agentsLoading?: boolean;
daemonLive: boolean;
onModeChange: (mode: ExecMode) => void;
onAgentChange: (id: string) => void;
onAgentModelChange: (
id: string,
choice: { model?: string; reasoning?: string },
) => void;
onApiProtocolChange: (protocol: ApiProtocol) => void;
onApiModelChange: (model: string) => void;
onConfigPersist: (cfg: AppConfig) => Promise<void> | void;
onSkillsRefresh?: () => Promise<void> | void;
onSkillsChanged?: (affectedSkillId?: string) => void;
onRefreshAgents: () => Promise<AgentInfo[]> | AgentInfo[];
// Quick theme switch from the avatar-popover dropdown. Lets the user
// flip between system / light / dark without opening the full Settings
// dialog. App owns persistence; this component just calls the callback.
onThemeChange: (theme: AppTheme) => void;
onCreateProject: (input: EntryCreateProjectInput) => Promise<boolean> | boolean | void;
onCreatePluginShareProject: (
pluginId: string,
action: PluginShareAction,
locale?: string,
) => Promise<PluginShareProjectOutcome>;
onImportClaudeDesign: (
file: File,
) => Promise<ImportClaudeDesignOutcome | void> | ImportClaudeDesignOutcome | void;
onImportFolder?: (baseDir: string) => Promise<void> | void;
onImportFolderResponse?: (response: OpenDesignHostProjectImportSuccess) => Promise<void> | void;
onOpenProject: (id: string, fileName?: string) => Promise<boolean> | boolean | void;
onOpenLiveArtifact: (projectId: string, artifactId: string) => void;
onDeleteProject: (id: string) => Promise<boolean | void> | boolean | void;
onDuplicateProject?: (id: string) => Promise<void> | void;
onRenameProject: (id: string, name: string) => void;
onProjectsRefresh?: () => Promise<void> | void;
onChangeDefaultDesignSystem: (id: string) => void;
onCreateDesignSystem?: () => void;
// NOTE: first-run onboarding intentionally no longer hosts guided
// design-system creation. The previous step-3 design-system surface was
// replaced by the newsletter and brand-extraction steps, so EntryShell does
// not accept a `renderDesignSystemCreation` renderer. Guided creation stays
// reachable from the standalone `design-system-create` route and the
// Design Systems tab; do not re-thread an onboarding renderer here.
onOpenDesignSystem?: (id: string) => void;
onDesignSystemsRefresh?: () => Promise<void> | void;
onPersistComposioKey: (composio: AppConfig['composio']) => Promise<void> | void;
onOpenSettings: (section?: EntrySettingsSection) => void;
onCompleteOnboarding: () => void;
}
// Map an EntryNavRail view id to the analytics `element` enum on
// `home/nav` ui_click. Returns `null` for views without a dedicated nav
// button (the rail's "Home" target is the brand logo, which gets its own
// element value via the logo click handler — not the changeView path).
function navElementForView(
next: EntryViewKind,
):
| 'home'
| 'projects'
| 'automations'
| 'plugins'
| 'design_systems'
| 'integrations'
| null {
switch (next) {
case 'home':
return 'home';
case 'projects':
return 'projects';
case 'tasks':
return 'automations';
case 'plugins':
return 'plugins';
case 'design-systems':
return 'design_systems';
case 'brands':
// No dedicated brands analytics element yet; reuse the design_systems
// slot since Brands replaces that nav destination.
return 'design_systems';
case 'integrations':
return 'integrations';
default:
return null;
}
}
// Tab views stay mounted (so previews/thumbnails survive a tab switch) but the
// inactive ones must leave layout, the accessibility tree, and tab order.
// `content-visibility: hidden` still reserves the hidden pane's block size,
// which pushes later sidebar destinations far below the sticky topbar.
function inactiveViewProps(active: boolean) {
return {
style: active ? undefined : ({ display: 'none' } as const),
inert: !active,
'aria-hidden': !active,
};
}
export function EntryShell({
skills,
designTemplates,
designSystems,
projects,
templates,
onDeleteTemplate,
promptTemplates,
defaultDesignSystemId,
connectors,
connectorsLoading,
integrationInitialTab = 'mcp',
composioConfigLoading = false,
skillsLoading = false,
designSystemsLoading = false,
projectsLoading = false,
config,
providerModelsCache: sharedProviderModelsCache,
onProviderModelsCacheChange,
agents,
agentsLoading = false,
daemonLive,
onModeChange,
onAgentChange,
onAgentModelChange,
onApiProtocolChange,
onApiModelChange,
onConfigPersist,
onSkillsRefresh,
onSkillsChanged,
onRefreshAgents,
onThemeChange,
onCreateProject,
onCreatePluginShareProject,
onImportClaudeDesign,
onImportFolder,
onImportFolderResponse,
onOpenProject,
onOpenLiveArtifact,
onDeleteProject,
onDuplicateProject,
onRenameProject,
onProjectsRefresh,
onChangeDefaultDesignSystem,
onCreateDesignSystem,
onOpenDesignSystem,
onDesignSystemsRefresh,
onPersistComposioKey,
onOpenSettings,
onCompleteOnboarding,
}: Props) {
const t = useT();
const { locale: uiLocale } = useI18n();
const discordPresence = useDiscordPresence();
// Each entry sub-view (home / projects / design-systems) is its own
// URL now, so the browser back/forward buttons work and a deep link
// to /design-systems lands on that section. We derive the active
// view from the route rather than keeping it in component state.
const route = useRoute();
const view: EntryViewKind = route.kind === 'home' ? route.view : 'home';
// The one shared workspace context. Drives the two-state nav shell: team rail
// (context non-null && workspaceType === 'team') vs. local rail. Every team
// surface reads THIS read; the rail never re-derives role/permission gates.
const { context: workspaceContext, loading: workspaceLoading } = useWorkspaceContext();
const isTeamWorkspace =
Boolean(workspaceContext) && workspaceContext!.workspaceType === 'team';
// Team-only destinations. In the local state the rail never links to these; a
// deep link to one (or losing team access) falls back to home once the context
// has resolved. `community` is allowed in both states, so it is not guarded.
const isTeamOnlyView =
view === 'drafts' ||
view === 'all-projects' ||
view === 'members' ||
view === 'board' ||
view === 'workspace-settings';
useEffect(() => {
if (workspaceLoading) return;
if (isTeamOnlyView && !isTeamWorkspace) {
navigate({ kind: 'home', view: 'home' }, { replace: true });
}
}, [workspaceLoading, isTeamOnlyView, isTeamWorkspace]);
const [newProjectOpen, setNewProjectOpen] = useState(false);
useEffect(() => {
if (view !== 'design-systems') return;
void onDesignSystemsRefresh?.();
}, [onDesignSystemsRefresh, view]);
// The entry nav rail is collapsed by default (Manus-style) so the entry
// view opens clean and full-width; the panel toggle in the topbar opens it
// as an overlay that dismisses on selection / backdrop click / Escape.
// Its open/collapsed state is persisted (localStorage) so it survives a
// home -> project -> home round trip (EntryShell unmounts on the project
// route) and a reload, instead of snapping back to collapsed.
const [railOpen, setRailOpen] = useState<boolean>(readStoredRailOpen);
useEffect(() => {
writeStoredRailOpen(railOpen);
}, [railOpen]);
const [localProviderModelsCache, setLocalProviderModelsCache] =
useState<ProviderModelsCache>({});
const hasSharedProviderModelsCache =
Boolean(sharedProviderModelsCache) && Boolean(onProviderModelsCacheChange);
const activeProviderModelsCache =
hasSharedProviderModelsCache
? sharedProviderModelsCache!
: localProviderModelsCache;
const activeSetProviderModelsCache =
hasSharedProviderModelsCache
? onProviderModelsCacheChange!
: setLocalProviderModelsCache;
const [newProjectInitialTab, setNewProjectInitialTab] =
useState<CreateTab>('prototype');
const [integrationTab, setIntegrationTab] = useState<IntegrationTab>(integrationInitialTab);
const [homePromptHandoff, setHomePromptHandoff] = useState<HomePromptHandoff | null>(null);
const entryMainScrollRef = useRef<HTMLElement | null>(null);
const analytics = useAnalytics();
const discordOnlineLabel = discordPresence
? t('entry.discordOnlineLabel', {
count: formatDiscordPresenceCount(discordPresence.onlineCount),
})
: null;
const discordAriaLabel = discordOnlineLabel
? t('entry.discordAriaWithOnline', { online: discordOnlineLabel })
: t('entry.discordAria');
function changeView(next: EntryViewKind) {
const navElement = navElementForView(next);
if (navElement) {
trackHomeNavClick(analytics.track, {
page_name: 'home',
area: 'nav',
element: navElement,
});
}
navigate({ kind: 'home', view: next });
}
function startPluginAuthoring(goal?: string) {
setHomePromptHandoff(
createPluginAuthoringHandoff(Date.now(), goal),
);
changeView('home');
}
function usePluginFromLibrary(
record: InstalledPluginRecord,
action: PluginUseAction = 'use',
) {
setHomePromptHandoff(
createPluginUseHandoff(Date.now(), record.id, { action }),
);
changeView('home');
}
useEffect(() => {
if (view !== 'home' || !homePromptHandoff) return;
const frame = window.requestAnimationFrame(() => {
const scrollContainer = entryMainScrollRef.current;
if (!scrollContainer) return;
smoothScrollToTop(scrollContainer);
});
return () => window.cancelAnimationFrame(frame);
}, [homePromptHandoff?.id, view]);
useEffect(() => {
setIntegrationTab(integrationInitialTab);
}, [integrationInitialTab]);
function openIntegrationTab(tab: IntegrationTab) {
setIntegrationTab(tab);
changeView('integrations');
}
function openNewProject(tab: CreateTab = 'prototype') {
setNewProjectInitialTab(tab);
setNewProjectOpen(true);
}
function startBlankProjectFromRail() {
void Promise.resolve(
onCreateProject({
name: t('common.untitled'),
skillId: null,
designSystemId: null,
}),
).catch((err) => {
console.warn('Failed to create blank project from entry rail', err);
});
}
function handleCreate(input: CreateInput) {
// The NewProjectModal no longer asks the user to pick a plugin.
// Each project kind is silently bound to its default scenario
// pipeline at creation time so the user lands in a running flow
// without having to reason about pipeline internals. The mapping
// is intentionally explicit so future kind-specific scenarios
// (e.g. a deck- or image-specialized pipeline) can take over a
// single row without touching the form.
const pluginId = defaultPluginIdForMetadata(input.metadata);
const pluginInputs = defaultPluginInputsForCreate(input, pluginId);
return onCreateProject({
...input,
...(pluginId ? { pluginId } : {}),
...(pluginInputs ? { pluginInputs } : {}),
});
}
// Plan §3.F5 — the home prompt-loop submit path. The user picks a
// plugin (which calls /api/plugins/:id/apply and binds a snapshot),
// edits the rendered example query if any, then presses Enter. We
// derive a project name from the active plugin (or prompt head),
// forward the pluginId so POST /api/projects pins the snapshot to
// project + conversation, and request auto-send of the first
// message so the user lands inside a running pipeline.
//
// Stage B of plugin-driven-flow-plan: the rail can stamp a
// `projectKind` on the payload so the created project records the
// chosen surface (image / video / audio, etc.). Free-form Home
// submits now arrive with the hidden od-default router plugin and
// projectKind='other', so the agent asks for the exact task type
// before continuing.
function handlePluginLoopSubmit(payload: PluginLoopSubmit) {
const summarizedName = summarizeProjectNameFromPrompt(payload.prompt);
const head = payload.prompt.trim().split(/\s+/).slice(0, 8).join(' ');
const firstAttachmentName = payload.attachments?.[0]?.name ?? '';
const fallbackName =
summarizedName || (head.length > 0 ? head : firstAttachmentName || 'Untitled');
const name =
payload.pluginTitle && payload.pluginTitle.trim().length > 0
? payload.pluginTitle.trim()
: fallbackName;
const linkedDirs = Array.from(
new Set(
[
...(payload.workingDir ? [payload.workingDir] : []),
...(payload.linkedDirs ?? []),
].map((dir) => dir.trim()).filter(Boolean),
),
);
const metadata: ProjectMetadata = {
...(payload.projectMetadata ?? {}),
kind: payload.projectKind ?? payload.projectMetadata?.kind ?? 'prototype',
nameSource: 'prompt',
...(payload.contextPlugins && payload.contextPlugins.length > 0
? { contextPlugins: payload.contextPlugins }
: {}),
...(payload.contextMcpServers && payload.contextMcpServers.length > 0
? { contextMcpServers: payload.contextMcpServers }
: {}),
...(payload.contextConnectors && payload.contextConnectors.length > 0
? { contextConnectors: payload.contextConnectors }
: {}),
// The Home working-directory picker grants the agent read-only
// awareness of a local folder (via `--add-dir`), it does NOT import
// that folder into Design Files. So the picked path becomes the new
// project's `linkedDirs` rather than its `baseDir`/`userWorkingDir`:
// Design Files stays the managed `.od/projects/<id>` artifact store,
// independent of the user's local files.
...(linkedDirs.length > 0 ? { linkedDirs } : {}),
...(payload.examplePromptContext ? {
examplePrompt: true,
examplePromptTitle: payload.examplePromptContext.title,
examplePromptBrief: payload.examplePromptContext.brief,
} : {}),
};
return onCreateProject({
name,
skillId: payload.skillId ?? null,
designSystemId: payload.designSystemId ?? null,
metadata,
pendingPrompt: payload.prompt,
...(payload.pluginId ? { pluginId: payload.pluginId } : {}),
...(payload.pluginType ? { pluginType: payload.pluginType } : {}),
...(payload.appliedPluginSnapshotId
? { appliedPluginSnapshotId: payload.appliedPluginSnapshotId }
: {}),
...(payload.pluginInputs ? { pluginInputs: payload.pluginInputs } : {}),
...(payload.initialRunContext ? { initialRunContext: payload.initialRunContext } : {}),
...(payload.conversationMode ? { conversationMode: payload.conversationMode } : {}),
...(payload.attachments && payload.attachments.length > 0
? { pendingFiles: payload.attachments }
: {}),
// No `userWorkingDirToken`: linkedDirs grant read-only `--add-dir`
// access and are validated by the daemon at create time, so they do
// not need the desktop main-process trust token that baseDir imports
// require for write access.
autoSendFirstMessage: true,
});
}
function finishOnboarding() {
onCompleteOnboarding();
changeView('home');
}
const avatarMenu = (
<EntrySettingsMenu
config={config}
onThemeChange={onThemeChange}
onOpenSettings={onOpenSettings}
onTrackTriggerClick={() => {
trackHomeToolbarClick(analytics.track, {
page_name: 'home',
area: 'toolbar',
element: 'settings',
});
}}
/>
);
if (view === 'onboarding') {
return (
<div className="entry-shell entry-shell--no-header entry-shell--onboarding">
<main className="entry-onboarding-modal" aria-label={t('settings.welcomeTitle')}>
<OnboardingView
config={config}
agents={agents}
agentsLoading={agentsLoading}
providerModelsCache={activeProviderModelsCache}
onProviderModelsCacheChange={activeSetProviderModelsCache}
daemonLive={daemonLive}
onModeChange={onModeChange}
onAgentChange={onAgentChange}
onAgentModelChange={onAgentModelChange}
onApiProtocolChange={onApiProtocolChange}
onApiModelChange={onApiModelChange}
onConfigPersist={onConfigPersist}
onRefreshAgents={onRefreshAgents}
onFinish={finishOnboarding}
onThemeChange={onThemeChange}
onGoBuild={() => {
onCompleteOnboarding();
setPendingDesignSystemCreateEntry('onboarding');
navigate({ kind: 'design-system-create' });
}}
/>
</main>
</div>
);
}
const executionSwitcher = (
<InlineModelSwitcher
config={config}
agents={agents}
providerModelsCache={activeProviderModelsCache}
onProviderModelsCacheChange={activeSetProviderModelsCache}
daemonLive={daemonLive}
onModeChange={onModeChange}
onAgentChange={onAgentChange}
onAgentModelChange={onAgentModelChange}
onApiProtocolChange={onApiProtocolChange}
onApiModelChange={onApiModelChange}
onOpenSettings={onOpenSettings}
/>
);
const homeExecutionSwitcher = (
<InlineModelSwitcher
compact
config={config}
agents={agents}
providerModelsCache={activeProviderModelsCache}
onProviderModelsCacheChange={activeSetProviderModelsCache}
daemonLive={daemonLive}
onModeChange={onModeChange}
onAgentChange={onAgentChange}
onAgentModelChange={onAgentModelChange}
onApiProtocolChange={onApiProtocolChange}
onApiModelChange={onApiModelChange}
onOpenSettings={onOpenSettings}
/>
);
return (
<div className="entry-shell entry-shell--no-header">
<div
className={`entry${railOpen ? ' entry--rail-open' : ''}`}
// The team/local shell is a labeled Manus-style rail, so widen the rail
// track (the base 56px icon-rail clips the labels + team affordances).
style={{ ['--entry-rail-width' as string]: '236px' }}
>
<EntryNavRail
view={view}
onViewChange={changeView}
onNewProject={() => {
trackHomeNavClick(analytics.track, {
page_name: 'home',
area: 'nav',
element: 'new_project_plus',
});
openNewProject();
}}
open={railOpen}
onClose={() => setRailOpen(false)}
context={workspaceContext}
onOpenSettings={onOpenSettings}
onInvite={() => changeView('members')}
onSignInCloud={() => navigate({ kind: 'home', view: 'onboarding' })}
/>
<main className="entry-main entry-main--scroll" ref={entryMainScrollRef}>
<div className="entry-main__topbar">
<button
type="button"
className="entry-rail-toggle"
onClick={() => setRailOpen((prev) => !prev)}
aria-label={t('entry.navExpand')}
aria-expanded={railOpen}
data-testid="entry-rail-toggle"
>
<Icon name="panel-left" size={20} />
</button>
<div className="entry-main__topbar-chips entry-main__topbar-chips--icon-only">
{/* The workspace switcher moved into the nav rail's team state. */}
<GithubStarBadge />
<a
className="entry-workspace-chip od-tooltip"
href={enterpriseUrl(uiLocale)}
target="_blank"
rel="noreferrer noopener"
onClick={() => {
trackHomeToolbarClick(analytics.track, {
page_name: 'home',
area: 'toolbar',
element: 'workspace_teams',
});
}}
data-tooltip={t('entry.workspaceTeamsTitle')}
data-tooltip-placement="bottom"
aria-label={t('entry.workspaceTeamsAria')}
data-testid="entry-workspace-teams"
>
<Icon
name="sparkles"
size={14}
className="entry-workspace-chip__icon"
/>
<span className="entry-workspace-chip__label">
{t('entry.workspaceTeamsLabel')}
</span>
</a>
<a
className="entry-discord-badge od-tooltip"
href={DISCORD_URL}
aria-label={discordAriaLabel}
data-tooltip={discordAriaLabel}
data-tooltip-placement="bottom"
data-testid="entry-discord-badge"
>
<Icon name="discord" size={14} className="entry-discord-badge__icon" />
<span className="entry-discord-badge__label">{t('entry.discordLabel')}</span>
{discordOnlineLabel ? (
<>
<span className="entry-discord-badge__sep" aria-hidden>
·
</span>
<span className="entry-discord-badge__online">
{discordOnlineLabel}
</span>
</>
) : null}
</a>
{view === 'home' ? null : executionSwitcher}
<button
type="button"
className="use-everywhere-chip od-tooltip"
onClick={() => {
trackHomeToolbarClick(analytics.track, {
page_name: 'home',
area: 'toolbar',
element: 'use_everywhere',
});
openIntegrationTab('use-everywhere');
}}
data-tooltip={t('entry.useEverywhereTitle')}
data-tooltip-placement="bottom"
aria-label={t('entry.useEverywhereAria')}
data-testid="entry-use-everywhere-button"
>
<span className="use-everywhere-chip__icon" aria-hidden>
<Icon name="hammer" size={13} />
</span>
<span className="use-everywhere-chip__label">
{t('entry.useEverywhereTitle')}
</span>
</button>
</div>
<UpdaterPopup />
{avatarMenu}
</div>
<div
className={`entry-main__inner${
view === 'home' ? '' : ' entry-main__inner--wide'
}`}
>
<div data-testid="entry-view-home" data-active={view === 'home' ? 'true' : 'false'} {...inactiveViewProps(view === 'home')}>
<HomeView
isActive={view === 'home'}
projects={projects}
projectsLoading={projectsLoading}
designSystems={designSystems}
defaultDesignSystemId={defaultDesignSystemId}
onSubmit={handlePluginLoopSubmit}
onOpenProject={onOpenProject}
onViewAllProjects={() => changeView('projects')}
onDeleteProject={onDeleteProject}
onDuplicateProject={onDuplicateProject}
onRenameProject={onRenameProject}
onBrowseRegistry={() => changeView('plugins')}
onOpenIntegrations={() => openIntegrationTab('connectors')}
onOpenMcp={() => openIntegrationTab('mcp')}
onOpenNewProject={(tab) => {
openNewProject(tab);
}}
onStartBlankProject={startBlankProjectFromRail}
promptHandoff={homePromptHandoff}
skills={skills}
skillsLoading={skillsLoading}
connectors={connectors}
promptTemplates={promptTemplates}
executionSwitcher={view === 'home' ? homeExecutionSwitcher : undefined}
/>
</div>
<div data-testid="entry-view-projects" data-active={view === 'projects' ? 'true' : 'false'} {...inactiveViewProps(view === 'projects')}>
{projectsLoading || skillsLoading || designSystemsLoading ? (
<CenteredLoader label={t('common.loading')} />
) : (
<div className="entry-section">
<header className="entry-section__head">
<h1 className="entry-section__title">{t('entry.navProjects')}</h1>
</header>
<DesignsTab
projects={projects}
skills={skills}
designSystems={designSystems}
onOpen={onOpenProject}
onOpenLiveArtifact={onOpenLiveArtifact}
onDelete={onDeleteProject}
onDuplicate={onDuplicateProject}
onRename={onRenameProject}
onRefresh={onProjectsRefresh}
isActive={view === 'projects'}
onNewProject={() => {
openNewProject();
}}
/>
</div>
)}
</div>
<div data-testid="entry-view-tasks" data-active={view === 'tasks' ? 'true' : 'false'} {...inactiveViewProps(view === 'tasks')}>
<TasksView
skills={skills}
designTemplates={designTemplates}
connectors={connectors}