moi-computer 0.7.0 → 0.8.1-next.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 (123) hide show
  1. package/README.md +2 -2
  2. package/client/api/workspace-keys.ts +1 -2
  3. package/client/app/AppRouter.tsx +10 -3
  4. package/client/app/routes/HomeRoute.tsx +1 -1
  5. package/client/app/shell/SidebarLayout.tsx +2 -14
  6. package/client/components/shared/BottomPanel.tsx +2 -1
  7. package/client/components/shared/Composer.tsx +20 -7
  8. package/client/components/shared/PanelHeader.tsx +8 -1
  9. package/client/components/ui/button.tsx +3 -3
  10. package/client/components/ui/dialog.tsx +1 -1
  11. package/client/components/ui/dropdown-menu.tsx +2 -2
  12. package/client/components/ui/hover-card.tsx +1 -1
  13. package/client/components/ui/popover.tsx +1 -1
  14. package/client/components/ui/resizable.tsx +40 -0
  15. package/client/features/applets/AppletMount.tsx +9 -22
  16. package/client/features/applets/applet-cache.ts +7 -0
  17. package/client/features/applets/applet-styles.ts +21 -1
  18. package/client/features/applets/useApplet.ts +1 -1
  19. package/client/features/chat/ChatEmptyState.tsx +9 -11
  20. package/client/features/chat/ChatPanel.tsx +76 -48
  21. package/client/features/chat/ChatPopup.tsx +16 -2
  22. package/client/features/chat/ChatPromptBubbles.tsx +6 -8
  23. package/client/features/chat/ChatSelector.tsx +25 -8
  24. package/client/features/chat/ModelPicker.tsx +5 -4
  25. package/client/features/chat/TurnView.tsx +108 -13
  26. package/client/features/chat/api.ts +1 -18
  27. package/client/features/chat/chat-send.ts +2 -2
  28. package/client/features/chat/{ChatComposer.tsx → composer/ChatComposer.tsx} +24 -9
  29. package/client/features/chat/composer/banners/ChatErrorBanner.tsx +28 -0
  30. package/client/features/chat/composer/banners/ComposerBanner.tsx +30 -0
  31. package/client/features/chat/composer/banners/WorkspaceAgentAvailabilityBanner.tsx +91 -0
  32. package/client/features/{workspace → chat/composer/banners}/WorkspaceSkillUpdateBanner.tsx +9 -7
  33. package/client/features/chat/composer/useWorkspaceComposerState.tsx +74 -0
  34. package/client/features/{workspace → chat/composer}/useWorkspaceSkillUpdates.ts +1 -1
  35. package/client/features/chat/group-turns.ts +46 -28
  36. package/client/features/chat/interleave-notices.ts +84 -0
  37. package/client/features/chat/model-order.ts +9 -3
  38. package/client/features/chat/tool-group/TimelineRow.tsx +23 -11
  39. package/client/features/chat/tool-group/ToolCallGroup.tsx +38 -3
  40. package/client/features/chat/tool-group/format.ts +23 -7
  41. package/client/features/chat/useAppletChatMessage.ts +11 -16
  42. package/client/features/chat/useChat.ts +3 -7
  43. package/client/features/dev/ChatStatesPage.tsx +428 -0
  44. package/client/features/dev/DevIndexPage.tsx +52 -0
  45. package/client/features/dev/DevRoutes.tsx +6 -3
  46. package/client/features/dev/HarnessDebugPage.tsx +3 -3
  47. package/client/features/dev/chat-states-fixtures.ts +744 -0
  48. package/client/features/home/api.ts +0 -10
  49. package/client/features/home/workspace-setup/CreateWorkspaceDialog.tsx +21 -64
  50. package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +1 -1
  51. package/client/features/scratchpad/Scratchpad.tsx +5 -3
  52. package/client/features/scratchpad/scratch-session.ts +71 -0
  53. package/client/features/views/ViewBuilderTab.tsx +5 -4
  54. package/client/features/views/ViewManager.tsx +258 -0
  55. package/client/features/views/useViewBuilderActions.ts +2 -2
  56. package/client/features/views/view-residency.ts +77 -0
  57. package/client/features/widgets/WidgetFrame.tsx +6 -2
  58. package/client/features/workspace/CustomizePanel.tsx +40 -24
  59. package/client/features/workspace/WorkspaceLayoutContext.tsx +12 -2
  60. package/client/features/workspace/WorkspaceScreen.tsx +131 -201
  61. package/client/features/workspace/WorkspaceSplitLayout.tsx +111 -0
  62. package/client/features/workspace/WorkspaceTabs.tsx +1 -1
  63. package/client/features/workspace/api.ts +33 -8
  64. package/client/features/workspace/useFitsSplitLayout.ts +31 -5
  65. package/client/index.css +5 -2
  66. package/client/lib/flags.ts +4 -3
  67. package/client/runtime/useWorkspaceEvents.ts +18 -1
  68. package/client/runtime/workspace-theme.ts +29 -10
  69. package/client/store/ui.ts +5 -1
  70. package/client/theme.css +96 -6
  71. package/dist/{chunk-0pcdwjkp.js → chunk-2vaafjp4.js} +1 -1
  72. package/dist/{chunk-9y2zbzqz.js → chunk-35fq49qa.js} +1 -1
  73. package/dist/chunk-gny990qx.css +1 -0
  74. package/dist/chunk-gt7n06ef.js +1 -0
  75. package/dist/{chunk-rxvx4ta9.js → chunk-kkj86722.js} +75 -75
  76. package/dist/chunk-n7pga5x3.js +80 -0
  77. package/dist/chunk-xeyxk7ep.js +10 -0
  78. package/dist/{chunk-w3tnv51j.js → chunk-xzx7c9hq.js} +1 -1
  79. package/dist/index.html +1 -1
  80. package/lib/format.ts +17 -1
  81. package/lib/themes.ts +123 -51
  82. package/lib/types.ts +40 -13
  83. package/lib/workspace-layout.ts +2 -2
  84. package/package.json +6 -4
  85. package/server/agent.ts +199 -0
  86. package/server/api.ts +38 -90
  87. package/server/bundler/build-applet.ts +7 -4
  88. package/server/cli.ts +46 -15
  89. package/server/control.ts +13 -6
  90. package/server/env-apply.ts +4 -0
  91. package/server/harness/README.md +28 -12
  92. package/server/harness/claude-code/auth.ts +54 -0
  93. package/server/harness/claude-code/index.ts +6 -1
  94. package/server/harness/codex/adapter.ts +9 -1
  95. package/server/harness/codex/auth.ts +50 -0
  96. package/server/harness/codex/index.ts +6 -1
  97. package/server/harness/codex/session.ts +33 -14
  98. package/server/harness/openclaw/NOTES.md +518 -187
  99. package/server/harness/openclaw/adapter.ts +125 -31
  100. package/server/harness/openclaw/compat.ts +99 -0
  101. package/server/harness/openclaw/cron-view.ts +78 -0
  102. package/server/harness/openclaw/discovery.ts +145 -52
  103. package/server/harness/openclaw/gateway.ts +224 -36
  104. package/server/harness/openclaw/index.ts +56 -21
  105. package/server/harness/openclaw/session.ts +971 -55
  106. package/server/harness/openclaw/strip.ts +87 -15
  107. package/server/harness/openclaw/thinking.ts +198 -0
  108. package/server/harness/types.ts +10 -5
  109. package/server/layout.ts +5 -2
  110. package/server/moi-scaffold.ts +1 -1
  111. package/server/registry.ts +0 -20
  112. package/server/theme.ts +24 -27
  113. package/workspace/.claude/skills/moi-workspace/DESIGN.md +100 -53
  114. package/workspace/.claude/skills/moi-workspace/SKILL.md +10 -12
  115. package/client/features/dev/PixelPainter.tsx +0 -94
  116. package/client/features/dev/PlaygroundPage.tsx +0 -69
  117. package/dist/chunk-175bm057.js +0 -27
  118. package/dist/chunk-55sh4dty.js +0 -2
  119. package/dist/chunk-afgbg75t.js +0 -50
  120. package/dist/chunk-agtetn7n.css +0 -1
  121. package/dist/chunk-dfs36zgc.js +0 -1
  122. package/dist/chunk-exj6hr30.js +0 -9
  123. package/dist/chunk-m11ckkxd.js +0 -51
package/README.md CHANGED
@@ -57,7 +57,7 @@ Using Claude Code or Codex? Paste this prompt into an existing session and the
57
57
  agent will set everything up for you:
58
58
 
59
59
  ```
60
- Set up the moi workspace for this project. Fetch https://moi.computer/CC-INSTALL.md, and follow the steps.
60
+ Set up the moi workspace for this project. Fetch https://moi.computer/INSTALL.md, and follow the steps.
61
61
  ```
62
62
 
63
63
  For OpenClaw or a manual setup, read on.
@@ -76,7 +76,7 @@ moi start # http://localhost:13337
76
76
  Then bring in your project, either way works:
77
77
 
78
78
  - open [http://localhost:13337](http://localhost:13337) and create a workspace
79
- (or import an existing folder) right from the web UI;
79
+ (or import one moi found on this computer) right from the web UI;
80
80
  - or run `moi init` inside a folder to turn it into a workspace.
81
81
 
82
82
  ## Run as a service
@@ -12,8 +12,7 @@ export const workspaceKeys = {
12
12
  sessionConfig: (id: string, sessionId: string) =>
13
13
  ['workspaces', 'sessionConfig', id, sessionId] as const,
14
14
  mcp: (id: string) => ['workspaces', 'mcp', id] as const,
15
- models: (id: string) => ['workspaces', 'models', id] as const,
16
- availability: (id: string) => ['workspaces', 'availability', id] as const,
15
+ agent: (id: string) => ['workspaces', 'agent', id] as const,
17
16
  skills: (id: string) => ['workspaces', 'skills', id] as const,
18
17
  env: (id: string) => ['workspaces', 'env', id] as const
19
18
  }
@@ -1,6 +1,6 @@
1
1
  import { Suspense, lazy, useEffect } from 'react'
2
2
 
3
- import { Route, Switch, useLocation } from 'wouter'
3
+ import { Redirect, Route, Switch, useLocation } from 'wouter'
4
4
 
5
5
  import { setWorkspaceSwitchHandler } from '@/client/features/chat/chat-connection'
6
6
 
@@ -8,10 +8,17 @@ import { HomeRoute } from './routes/HomeRoute'
8
8
  import { WorkspaceRoute } from './routes/WorkspaceRoute'
9
9
 
10
10
  // Dev-only playground routes: colocated in features/dev and loaded as a
11
- // separate lazy chunk so none of it ships in the main bundle's hot path.
12
- const DevRoutes = lazy(() => import('@/client/features/dev/DevRoutes'))
11
+ // separate lazy chunk. The NODE_ENV gate is statically false in the prod
12
+ // build (scripts/build-client.ts defines it), so the bundler drops the
13
+ // dynamic import and none of features/dev is emitted into dist at all —
14
+ // same mechanism as DevAgentation in main.tsx. In prod /dev redirects home.
15
+ const DevRoutes =
16
+ process.env.NODE_ENV === 'development'
17
+ ? lazy(() => import('@/client/features/dev/DevRoutes'))
18
+ : null
13
19
 
14
20
  function DevLazy() {
21
+ if (!DevRoutes) return <Redirect to="/" />
15
22
  return (
16
23
  <Suspense fallback={null}>
17
24
  <DevRoutes />
@@ -4,7 +4,7 @@ import { HomePage } from '@/client/features/home/HomePage'
4
4
  // The `/` route: the app shell wrapping the workspaces view.
5
5
  export function HomeRoute() {
6
6
  return (
7
- <SidebarLayout panel="flat" showWorkspaces={false}>
7
+ <SidebarLayout showWorkspaces={false}>
8
8
  <div className="min-h-0 flex-1 overflow-y-auto">
9
9
  <HomePage />
10
10
  </div>
@@ -29,17 +29,12 @@ type SidebarLayoutProps = {
29
29
  // Full panel content — the page supplies its own header (compose it with
30
30
  // <PanelHeader>) and body.
31
31
  children?: ReactNode
32
- panel?: 'default' | 'flat'
33
32
  showWorkspaces?: boolean
34
33
  }
35
34
 
36
35
  // App shell: a slim icon rail beside the page content. The page owns the panel's
37
36
  // header and body.
38
- export function SidebarLayout({
39
- children,
40
- panel = 'default',
41
- showWorkspaces = true
42
- }: SidebarLayoutProps) {
37
+ export function SidebarLayout({ children, showWorkspaces = true }: SidebarLayoutProps) {
43
38
  const { data: workspaces } = useWorkspaces()
44
39
 
45
40
  // `moi config` / the settings modal broadcast `workspace:updated` (identity
@@ -57,14 +52,7 @@ export function SidebarLayout({
57
52
  return (
58
53
  <div className={cn('flex h-dvh bg-muted')}>
59
54
  <Sidebar workspaces={showWorkspaces ? (workspaces ?? []) : []} />
60
- <main
61
- className={cn(
62
- 'flex min-w-0 flex-1 flex-col overflow-hidden',
63
- panel === 'default' && 'bg-background shadow-xs'
64
- )}
65
- >
66
- {children}
67
- </main>
55
+ <main className="flex min-w-0 flex-1 flex-col">{children}</main>
68
56
  </div>
69
57
  )
70
58
  }
@@ -22,7 +22,8 @@ export function BottomPanel({ className, title, children, onClose, ref }: Bottom
22
22
  <motion.div
23
23
  ref={ref}
24
24
  className={cn(
25
- 'absolute inset-x-4 bottom-4 no-scrollbar flex max-h-full flex-col gap-4 overflow-y-auto rounded-2xl bg-card p-(--page-pad) pb-0 text-card-foreground shadow-md',
25
+ 'absolute inset-x-4 bottom-4 no-scrollbar flex max-h-full flex-col gap-4 overflow-y-auto rounded-2xl bg-card text-card-foreground shadow-md',
26
+ 'mx-auto max-w-[calc(var(--chat-max-container)+var(--page-pad)*2)] p-(--page-pad) pb-0',
26
27
  className
27
28
  )}
28
29
  variants={{
@@ -77,12 +77,24 @@ export function ComposerFooter({ className, children, ...props }: ComposerFooter
77
77
  )
78
78
  }
79
79
 
80
+ export type ComposerAvailability =
81
+ | { status: 'checking' }
82
+ | { status: 'available' }
83
+ | { status: 'unavailable' }
84
+
85
+ export function composerAvailabilityTooltip(
86
+ availability: ComposerAvailability
87
+ ): string | undefined {
88
+ if (availability.status === 'checking') return 'Checking agent status…'
89
+ return undefined
90
+ }
91
+
80
92
  export function canSubmitComposerAction(
81
93
  hasContent: boolean,
82
94
  busy: boolean,
83
- unavailableReason: string | null | undefined
95
+ availability: ComposerAvailability
84
96
  ): boolean {
85
- return hasContent && !busy && unavailableReason === null
97
+ return hasContent && !busy && availability.status === 'available'
86
98
  }
87
99
 
88
100
  type ComposerSubmitButtonProps = {
@@ -90,7 +102,7 @@ type ComposerSubmitButtonProps = {
90
102
  hasContent: boolean
91
103
  busy?: boolean
92
104
  loading?: boolean
93
- unavailableReason: string | null | undefined
105
+ availability: ComposerAvailability
94
106
  }
95
107
 
96
108
  export function ComposerSubmitButton({
@@ -98,21 +110,22 @@ export function ComposerSubmitButton({
98
110
  hasContent,
99
111
  busy = false,
100
112
  loading = false,
101
- unavailableReason
113
+ availability
102
114
  }: ComposerSubmitButtonProps) {
103
- const canSubmit = canSubmitComposerAction(hasContent, busy || loading, unavailableReason)
115
+ const canSubmit = canSubmitComposerAction(hasContent, busy || loading, availability)
116
+ const availabilityTooltip = composerAvailabilityTooltip(availability)
104
117
  const button = (
105
118
  <Button type="submit" size="icon" disabled={!canSubmit} aria-label={label}>
106
119
  {loading ? <Spinner /> : <IconArrowUp stroke={1.5} />}
107
120
  </Button>
108
121
  )
109
122
 
110
- if (loading || !unavailableReason) return button
123
+ if (loading || !availabilityTooltip) return button
111
124
 
112
125
  return (
113
126
  <Tooltip>
114
127
  <TooltipTrigger render={<span className="inline-flex">{button}</span>} />
115
- <TooltipContent className="max-w-64 text-center">{unavailableReason}</TooltipContent>
128
+ <TooltipContent className="max-w-64 text-center">{availabilityTooltip}</TooltipContent>
116
129
  </Tooltip>
117
130
  )
118
131
  }
@@ -1,8 +1,15 @@
1
+ import { cn } from '@/client/lib/cn'
1
2
  import type { ReactNode } from 'react'
2
3
 
3
4
  export function PanelHeader({ children }: { children?: ReactNode }) {
4
5
  return (
5
- <header className="@container flex h-11 shrink-0 items-center gap-2.5 border-b border-border/75 pr-3 pl-4">
6
+ <header
7
+ className={cn(
8
+ '@container relative flex shrink-0 items-center gap-2.5 py-2 pr-3 pl-4',
9
+ // Header bottom border that overflows the tab content and contrasts with it
10
+ 'after:absolute after:top-full after:left-0 after:h-px after:w-full after:bg-border'
11
+ )}
12
+ >
6
13
  {children}
7
14
  </header>
8
15
  )
@@ -4,12 +4,12 @@ import { type VariantProps, cva } from 'class-variance-authority'
4
4
  import { cn } from '@/client/lib/cn'
5
5
 
6
6
  const buttonVariants = cva(
7
- 'inline-flex shrink-0 cursor-pointer items-center justify-center gap-1.5 rounded-lg text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0',
7
+ 'inline-flex shrink-0 cursor-pointer items-center justify-center gap-1.5 rounded-lg text-sm font-medium whitespace-nowrap transition-all duration-100 outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0',
8
8
  {
9
9
  variants: {
10
10
  variant: {
11
11
  default:
12
- 'bg-primary text-primary-foreground hover:bg-primary/90 disabled:bg-muted disabled:text-muted-foreground disabled:opacity-100',
12
+ 'bg-primary text-primary-foreground hover:bg-primary/90 disabled:bg-accent disabled:text-muted-foreground disabled:opacity-100',
13
13
  secondary:
14
14
  'bg-accent text-foreground hover:bg-[color-mix(in_oklch,var(--accent),var(--foreground)_5%)] hover:text-accent-foreground',
15
15
  outline: 'bg-background shadow-xs hover:text-accent-foreground hover:shadow-sm',
@@ -18,7 +18,7 @@ const buttonVariants = cva(
18
18
  'bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20'
19
19
  },
20
20
  size: {
21
- sm: 'h-7 gap-1.5 rounded-md px-2.5 text-sm has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2 [&_svg]:size-4',
21
+ sm: 'h-7 gap-1.5 rounded-md px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2 [&_svg]:size-4',
22
22
  default:
23
23
  'h-8 px-3 has-data-[icon=inline-end]:pr-2.5 has-data-[icon=inline-start]:pl-2.5 [&_svg]:size-5',
24
24
  lg: 'h-10 rounded-xl px-4 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3 [&_svg]:size-5',
@@ -24,7 +24,7 @@ function DialogContent({ className, children, ...props }: DialogPrimitive.Popup.
24
24
  <DialogPrimitive.Popup
25
25
  data-slot="dialog-content"
26
26
  className={cn(
27
- 'fixed top-1/2 left-1/2 z-50 origin-center -translate-x-1/2 -translate-y-1/2 overflow-hidden rounded-xl bg-card text-card-foreground shadow-xl ring-1 ring-border outline-hidden duration-150 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
27
+ 'fixed top-1/2 left-1/2 z-50 origin-center -translate-x-1/2 -translate-y-1/2 overflow-hidden rounded-xl bg-card text-card-foreground shadow-xl outline-hidden duration-150 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
28
28
  className
29
29
  )}
30
30
  {...props}
@@ -38,7 +38,7 @@ function DropdownMenuContent({
38
38
  <MenuPrimitive.Popup
39
39
  data-slot="dropdown-menu-content"
40
40
  className={cn(
41
- 'z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-border duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95',
41
+ 'z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95',
42
42
  className
43
43
  )}
44
44
  {...props}
@@ -132,7 +132,7 @@ function DropdownMenuSubContent({
132
132
  <DropdownMenuContent
133
133
  data-slot="dropdown-menu-sub-content"
134
134
  className={cn(
135
- 'w-auto min-w-[96px] rounded-lg bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-border duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
135
+ 'w-auto min-w-[96px] rounded-lg bg-popover p-1 text-popover-foreground shadow-lg duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
136
136
  className
137
137
  )}
138
138
  align={align}
@@ -31,7 +31,7 @@ function HoverCardContent({
31
31
  <PreviewCardPrimitive.Popup
32
32
  data-slot="hover-card-content"
33
33
  className={cn(
34
- 'z-50 w-64 origin-(--transform-origin) rounded-xl bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-border outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
34
+ 'z-50 w-64 origin-(--transform-origin) rounded-xl bg-popover p-2.5 text-sm text-popover-foreground shadow-md outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
35
35
  className
36
36
  )}
37
37
  {...props}
@@ -43,7 +43,7 @@ function PopoverContent({
43
43
  <PopoverPrimitive.Popup
44
44
  data-slot="popover-content"
45
45
  className={cn(
46
- 'z-50 flex w-72 origin-(--transform-origin) flex-col gap-3 rounded-lg bg-popover p-3 text-sm text-popover-foreground shadow-md ring-1 ring-border outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
46
+ 'z-50 flex w-72 origin-(--transform-origin) flex-col gap-3 rounded-lg bg-popover p-3 text-sm text-popover-foreground shadow-md outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
47
47
  className
48
48
  )}
49
49
  {...props}
@@ -0,0 +1,40 @@
1
+ import * as ResizablePrimitive from 'react-resizable-panels'
2
+
3
+ import { cn } from '@/client/lib/cn'
4
+
5
+ function ResizablePanelGroup({ className, ...props }: ResizablePrimitive.GroupProps) {
6
+ return (
7
+ <ResizablePrimitive.Group
8
+ data-slot="resizable-panel-group"
9
+ className={cn('flex h-full w-full aria-[orientation=vertical]:flex-col', className)}
10
+ {...props}
11
+ />
12
+ )
13
+ }
14
+
15
+ function ResizablePanel({ ...props }: ResizablePrimitive.PanelProps) {
16
+ return <ResizablePrimitive.Panel data-slot="resizable-panel" {...props} />
17
+ }
18
+
19
+ function ResizableHandle({
20
+ withHandle,
21
+ className,
22
+ ...props
23
+ }: ResizablePrimitive.SeparatorProps & {
24
+ withHandle?: boolean
25
+ }) {
26
+ return (
27
+ <ResizablePrimitive.Separator
28
+ data-slot="resizable-handle"
29
+ className={cn(
30
+ 'relative flex w-0 items-center justify-center ring-offset-background after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-hidden aria-[orientation=horizontal]:h-0 aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90',
31
+ className
32
+ )}
33
+ {...props}
34
+ >
35
+ {withHandle && <div className="flex h-6 w-1 shrink-0 rounded-lg bg-border" />}
36
+ </ResizablePrimitive.Separator>
37
+ )
38
+ }
39
+
40
+ export { ResizableHandle, ResizablePanel, ResizablePanelGroup }
@@ -1,43 +1,30 @@
1
- import { type ReactElement, type ReactNode, cloneElement, isValidElement } from 'react'
1
+ import { type ReactNode } from 'react'
2
2
 
3
3
  import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
4
4
 
5
- import { type AppletSegment, appletStyleKey } from './applet-cache'
5
+ import { type AppletSegment, appletScope, appletStyleKey } from './applet-cache'
6
6
  import { useAppletStyle } from './applet-styles'
7
7
 
8
8
  type AppletMountProps = {
9
9
  segment: AppletSegment
10
10
  name: string
11
11
  version: number
12
- // Merge the scope attribute into the single child element instead of
13
- // rendering a wrapper — use when the caller already has a filled container
14
- // (e.g. the shells' motion.div), so no extra node enters the DOM. The child
15
- // must forward unknown props to its DOM element.
16
- asChild?: boolean
17
12
  children: ReactNode
18
13
  }
19
14
 
20
15
  // The style scope for one mounted applet: puts the `data-applet` attribute the
21
16
  // bundle's scoped CSS selectors key off (see server/bundler/applet-css.ts) on a
22
- // container, and keeps the applet's <style> tag mounted exactly as long as the
23
- // applet is — unmounting removes the styles from the page. Without `asChild`
24
- // it renders its own wrapper div filling the parent box (the widget path —
25
- // merging onto the shell's motion.div interferes with AnimatePresence there);
26
- // with `asChild` it merges onto the child element instead (the view path).
27
- export function AppletMount({ segment, name, version, asChild, children }: AppletMountProps) {
17
+ // wrapper filling the parent box, and keeps the applet's <style> tag mounted
18
+ // exactly as long as the applet is — unmounting removes the styles from the
19
+ // page. This is the widget path. Views don't use it: ViewManager parks a view's
20
+ // DOM offscreen instead of unmounting it, so it holds the styles itself, above
21
+ // the boundary that hides the view.
22
+ export function AppletMount({ segment, name, version, children }: AppletMountProps) {
28
23
  const workspaceId = useWorkspaceId()
29
24
  useAppletStyle(appletStyleKey(segment, workspaceId, name), version)
30
25
 
31
- const kind = segment === 'widgets' ? 'widget' : 'view'
32
- const scope = `${kind}:${name}`
33
-
34
- if (asChild && isValidElement(children)) {
35
- return cloneElement(children as ReactElement<{ 'data-applet'?: string }>, {
36
- 'data-applet': scope
37
- })
38
- }
39
26
  return (
40
- <div data-applet={scope} className="size-full">
27
+ <div data-applet={appletScope(segment, name)} className="size-full">
41
28
  {children}
42
29
  </div>
43
30
  )
@@ -54,6 +54,13 @@ export function appletStyleKey(segment: AppletSegment, workspaceId: string, name
54
54
  return `/api/workspaces/${workspaceId}/${segment}/${name}`
55
55
  }
56
56
 
57
+ // The `data-applet` value the bundle's scoped CSS selectors key off (see
58
+ // server/bundler/applet-css.ts). It goes on the container wrapping a mounted
59
+ // applet — AppletMount for widgets, the view slot for views.
60
+ export function appletScope(segment: AppletSegment, name: string): string {
61
+ return `${segment === 'widgets' ? 'widget' : 'view'}:${name}`
62
+ }
63
+
57
64
  export function getCachedApplet(key: string): Promise<unknown> | undefined {
58
65
  return moduleCache.get(key)
59
66
  }
@@ -52,10 +52,30 @@ export function acquireAppletStyle(key: string): () => void {
52
52
  }
53
53
  }
54
54
 
55
+ // Move an applet's <style> to the end of <head>. Everything in an applet sheet
56
+ // is scoped to its `[data-applet]` container and so can't collide — except the
57
+ // names of global at-rules (`@keyframes`, `@property`, `@font-face`), which the
58
+ // scoper leaves alone because they aren't selectors (server/bundler/applet-css.ts).
59
+ // Two applets defining `@keyframes pulse` differently therefore share one
60
+ // document-global name, and the last definition wins for both. Raising the
61
+ // applet the user is looking at makes the winner the one on screen.
62
+ export function raiseAppletStyle(key: string): void {
63
+ const entry = active.get(key)
64
+ if (!entry || entry.el === document.head.lastElementChild) return
65
+ document.head.appendChild(entry.el)
66
+ }
67
+
55
68
  // Keep the applet's <style> mounted for the lifetime of the calling component.
56
69
  // `version` re-runs the effect after a rebuild so the tag picks up the fresh
57
70
  // registry text. useInsertionEffect runs before layout effects and paint, so
58
71
  // the styles are in place before the applet's first frame.
59
- export function useAppletStyle(key: string, version: number): void {
72
+ //
73
+ // `onTop` marks the applet as the visible one — see `raiseAppletStyle`. Only
74
+ // ever set it on one mounted applet at a time; with several claiming it the
75
+ // winner is whichever effect React happens to run last.
76
+ export function useAppletStyle(key: string, version: number, onTop = false): void {
60
77
  useInsertionEffect(() => acquireAppletStyle(key), [key, version])
78
+ useInsertionEffect(() => {
79
+ if (onTop) raiseAppletStyle(key)
80
+ }, [key, onTop, version])
61
81
  }
@@ -24,7 +24,7 @@ export type AppletComponentProps = {
24
24
  params?: Record<string, unknown>
25
25
  }
26
26
 
27
- type AppletState =
27
+ export type AppletState =
28
28
  | { status: 'loading'; version: number }
29
29
  | { status: 'ready'; Component: ComponentType<AppletComponentProps>; version: number }
30
30
  | { status: 'error'; error: string; version: number }
@@ -120,20 +120,18 @@ type WelcomeProps = {
120
120
 
121
121
  export function ChatWelcome({ disabled = false, onSelectPrompt }: WelcomeProps) {
122
122
  return (
123
- <div className={cn(EMPTY_STATE_STYLES, 'max-w-md min-w-0 self-center')}>
123
+ <div className={cn(EMPTY_STATE_STYLES, '@container w-full max-w-md min-w-0')}>
124
124
  <div className="prose prose-sm min-w-0 wrap-anywhere prose-inherit">
125
- <p>moi is the visual workspace for you and your agent.</p>
126
125
  <p>
127
- It can grow and adapt to the work you're doing. Just describe what you want, and the agent
128
- will build small apps in the workspace.
126
+ moi is the visual workspace for you and your agent. It grows and adapts to the work you're
127
+ doing.
129
128
  </p>
130
129
  <p>
131
- You start chatting with <WelcomeTerm Icon={IconGhost}>Agent</WelcomeTerm>, where you can
132
- ask questions and build anything. <WelcomeTerm Icon={IconLayout2}>Widgets</WelcomeTerm>{' '}
133
- are small apps that surface information and provide quick actions. For more complex tools,
134
- you can build <WelcomeTerm Icon={IconArticle}>Views</WelcomeTerm> that open in their own
135
- tabs. <WelcomeTerm Icon={IconSketching}>Scratchpad</WelcomeTerm> is a shared canvas for
136
- exploring and shaping ideas with your agent.
130
+ Ask <WelcomeTerm Icon={IconGhost}>Agent</WelcomeTerm> to build{' '}
131
+ <WelcomeTerm Icon={IconLayout2}>Widgets</WelcomeTerm> that surface information and quick
132
+ actions, or entire <WelcomeTerm Icon={IconArticle}>Views</WelcomeTerm> for more complex
133
+ tools. Use <WelcomeTerm Icon={IconSketching}>Scratchpad</WelcomeTerm> for exploring and
134
+ shaping ideas with your agent.
137
135
  </p>
138
136
  <p>Give it a try:</p>
139
137
  </div>
@@ -164,7 +162,7 @@ export function ChatWorkspaceWelcome({ disabled = false, onSelectPrompt }: Welco
164
162
  function EmptyState() {
165
163
  return (
166
164
  <div className={cn(EMPTY_STATE_STYLES, 'gap-1 text-center')}>
167
- <p className="mx-auto max-w-sm text-sm text-muted-foreground">
165
+ <p className="mx-auto max-w-sm px-8 text-sm text-muted-foreground">
168
166
  Chat with your agent, create widgets and views, and manage your workspace context from here
169
167
  </p>
170
168
  </div>