moi-computer 0.7.0 → 0.8.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 (48) hide show
  1. package/README.md +2 -2
  2. package/client/components/shared/BottomPanel.tsx +2 -1
  3. package/client/components/shared/PanelHeader.tsx +1 -1
  4. package/client/features/applets/AppletMount.tsx +9 -22
  5. package/client/features/applets/applet-cache.ts +7 -0
  6. package/client/features/applets/applet-styles.ts +21 -1
  7. package/client/features/applets/useApplet.ts +1 -1
  8. package/client/features/chat/ChatComposer.tsx +18 -4
  9. package/client/features/chat/ChatSelector.tsx +1 -1
  10. package/client/features/chat/TurnView.tsx +1 -1
  11. package/client/features/home/api.ts +0 -10
  12. package/client/features/home/workspace-setup/CreateWorkspaceDialog.tsx +21 -64
  13. package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +1 -1
  14. package/client/features/scratchpad/Scratchpad.tsx +1 -3
  15. package/client/features/views/ViewManager.tsx +258 -0
  16. package/client/features/views/view-residency.ts +77 -0
  17. package/client/features/widgets/WidgetFrame.tsx +6 -2
  18. package/client/features/workspace/CustomizePanel.tsx +40 -24
  19. package/client/features/workspace/WorkspaceLayoutContext.tsx +8 -0
  20. package/client/features/workspace/WorkspaceScreen.tsx +51 -103
  21. package/client/features/workspace/WorkspaceTabs.tsx +1 -1
  22. package/client/index.css +4 -1
  23. package/client/runtime/workspace-theme.ts +29 -10
  24. package/client/theme.css +96 -6
  25. package/dist/chunk-0k7brsms.js +9 -0
  26. package/dist/{chunk-m11ckkxd.js → chunk-dtwxpxbg.js} +1 -1
  27. package/dist/{chunk-55sh4dty.js → chunk-ga7t9qsk.js} +1 -1
  28. package/dist/{chunk-w3tnv51j.js → chunk-h9h8f176.js} +1 -1
  29. package/dist/{chunk-rxvx4ta9.js → chunk-r5ce5cdg.js} +2 -2
  30. package/dist/chunk-tey2nq7c.js +31 -0
  31. package/dist/{chunk-afgbg75t.js → chunk-z73xpsa0.js} +1 -1
  32. package/dist/chunk-zzgredta.css +1 -0
  33. package/dist/index.html +1 -1
  34. package/lib/themes.ts +123 -51
  35. package/lib/types.ts +2 -5
  36. package/package.json +5 -4
  37. package/server/api.ts +2 -73
  38. package/server/bundler/build-applet.ts +7 -4
  39. package/server/cli.ts +46 -15
  40. package/server/control.ts +13 -6
  41. package/server/moi-scaffold.ts +1 -1
  42. package/server/registry.ts +0 -20
  43. package/server/theme.ts +24 -27
  44. package/workspace/.claude/skills/moi-workspace/DESIGN.md +94 -57
  45. package/workspace/.claude/skills/moi-workspace/SKILL.md +10 -12
  46. package/dist/chunk-175bm057.js +0 -27
  47. package/dist/chunk-agtetn7n.css +0 -1
  48. package/dist/chunk-exj6hr30.js +0 -9
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
@@ -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={{
@@ -2,7 +2,7 @@ import type { ReactNode } from 'react'
2
2
 
3
3
  export function PanelHeader({ children }: { children?: ReactNode }) {
4
4
  return (
5
- <header className="@container flex h-11 shrink-0 items-center gap-2.5 border-b border-border/75 pr-3 pl-4">
5
+ <header className="@container relative flex h-11 shrink-0 items-center gap-2.5 pr-3 pl-4 ring-1 ring-border">
6
6
  {children}
7
7
  </header>
8
8
  )
@@ -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 }
@@ -1,6 +1,12 @@
1
1
  import { type RefObject, useRef, useState } from 'react'
2
2
 
3
- import { IconFile, IconLoader2, IconPaperclip, IconPlayerStop, IconX } from '@tabler/icons-react'
3
+ import {
4
+ IconFile,
5
+ IconLoader2,
6
+ IconPaperclip,
7
+ IconPlayerStopFilled,
8
+ IconX
9
+ } from '@tabler/icons-react'
4
10
 
5
11
  import {
6
12
  canSubmitComposerAction,
@@ -10,6 +16,7 @@ import {
10
16
  ComposerTextarea
11
17
  } from '@/client/components/shared/Composer'
12
18
  import { Button } from '@/client/components/ui/button'
19
+ import { Tooltip, TooltipContent, TooltipTrigger } from '@/client/components/ui/tooltip'
13
20
  import { cn } from '@/client/lib/cn'
14
21
  import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
15
22
  import { uploadFiles } from '@/client/features/chat/uploads'
@@ -176,9 +183,16 @@ export function ChatComposer({
176
183
  </Button>
177
184
  <ModelPicker />
178
185
  {processing ? (
179
- <Button type="button" size="icon" onClick={onStop} aria-label="Stop agent">
180
- <IconPlayerStop stroke={1.5} />
181
- </Button>
186
+ <Tooltip>
187
+ <TooltipTrigger
188
+ render={
189
+ <Button type="button" size="icon" onClick={onStop} aria-label="Stop agent">
190
+ <IconPlayerStopFilled />
191
+ </Button>
192
+ }
193
+ />
194
+ <TooltipContent>Stop answering</TooltipContent>
195
+ </Tooltip>
182
196
  ) : (
183
197
  <ComposerSubmitButton
184
198
  label="Send message"
@@ -105,7 +105,7 @@ function ChatSessionItem({
105
105
  'min-w-0 truncate',
106
106
  (running || pending) && '-mr-4',
107
107
  confirmingArchive
108
- ? '-4'
108
+ ? '-mr-14'
109
109
  : canArchive &&
110
110
  'group-focus-within/chat:-mr-4 group-hover/chat:-mr-4 [@media(hover:none)]:-mr-4'
111
111
  )}
@@ -113,7 +113,7 @@ export const TurnView = memo(function TurnView({ turn, processing = false }: Tur
113
113
  <FilePart key={i} mediaType={p.mediaType} url={p.url} filename={p.filename} />
114
114
  ))}
115
115
  {text && (
116
- <p className="max-w-full min-w-0 rounded-lg bg-accent px-3 py-2 text-sm leading-normal wrap-anywhere whitespace-pre-wrap text-accent-foreground">
116
+ <p className="max-w-full min-w-0 rounded-lg bg-primary px-3 py-2 text-sm leading-normal wrap-anywhere whitespace-pre-wrap text-primary-foreground">
117
117
  {text}
118
118
  </p>
119
119
  )}
@@ -70,7 +70,6 @@ export type ImportWorkspaceInput = {
70
70
  export type WorkspaceSetupInfo = {
71
71
  root: string
72
72
  displayRoot: string
73
- canChooseFolder: boolean
74
73
  // Per-backend runtime availability (are the Claude/Codex CLIs installed?),
75
74
  // keyed by workspace type. Missing entries mean available.
76
75
  availability?: Partial<Record<WorkspaceType, HarnessAvailability>>
@@ -87,15 +86,6 @@ export function useWorkspaceSetupInfo() {
87
86
  })
88
87
  }
89
88
 
90
- export type ChooseFolderResult = DiscoveredWorkspace | { canceled: true }
91
-
92
- export function useChooseFolder() {
93
- return useMutation<ChooseFolderResult, Error, void>({
94
- mutationFn: () =>
95
- requestJson('/api/workspaces/choose-folder', { method: 'POST' }, 'Failed to choose folder')
96
- })
97
- }
98
-
99
89
  export type CreateWorkspaceInput = {
100
90
  name: string
101
91
  type: WorkspaceType
@@ -2,7 +2,7 @@ import { type FormEvent, type ReactElement, useState } from 'react'
2
2
 
3
3
  import { useLocation } from 'wouter'
4
4
 
5
- import { useChooseFolder, useCreateWorkspace, useWorkspaceSetupInfo } from '../api'
5
+ import { useCreateWorkspace, useWorkspaceSetupInfo } from '../api'
6
6
  import { Button } from '@/client/components/ui/button'
7
7
  import {
8
8
  Dialog,
@@ -12,15 +12,12 @@ import {
12
12
  } from '@/client/components/ui/dialog'
13
13
  import { Input } from '@/client/components/ui/input'
14
14
  import { Tooltip, TooltipContent, TooltipTrigger } from '@/client/components/ui/tooltip'
15
- import { cn } from '@/client/lib/cn'
16
15
  import { validateWorkspaceFolderName } from '@/lib/workspace-name'
17
16
  import { WORKSPACE_TYPE_ORDER } from '@/lib/workspace-types'
18
17
  import type { WorkspaceType } from '@/lib/types'
19
18
 
20
- import { ImportWorkspaceStep } from './ImportWorkspaceDialog'
21
19
  import { WorkspaceAgentStep } from './WorkspaceAgentStep'
22
20
  import { WorkspaceDialogContent } from './WorkspaceDialogContent'
23
- import { useWorkspaceImport } from './useWorkspaceImport'
24
21
 
25
22
  type CreateWorkspaceDialogProps = {
26
23
  trigger: ReactElement
@@ -34,8 +31,6 @@ export function CreateWorkspaceDialog({ trigger }: CreateWorkspaceDialogProps) {
34
31
  const [, navigate] = useLocation()
35
32
  const info = useWorkspaceSetupInfo()
36
33
  const createMutation = useCreateWorkspace()
37
- const chooseFolder = useChooseFolder()
38
- const importFlow = useWorkspaceImport({ onSuccess: entry => finish(entry.id) })
39
34
 
40
35
  const [open, setOpen] = useState(false)
41
36
  const [step, setStep] = useState<CreateWorkspaceStep>('agent')
@@ -44,8 +39,6 @@ export function CreateWorkspaceDialog({ trigger }: CreateWorkspaceDialogProps) {
44
39
 
45
40
  const trimmedName = name.trim()
46
41
  const nameError = trimmedName ? validateWorkspaceFolderName(trimmedName) : null
47
- const canChooseFolder = info.data?.canChooseFolder ?? true
48
- const isImporting = chooseFolder.isPending || importFlow.isPending
49
42
  const isCreating = createMutation.isPending
50
43
 
51
44
  function finish(workspaceId: string) {
@@ -57,23 +50,9 @@ export function CreateWorkspaceDialog({ trigger }: CreateWorkspaceDialogProps) {
57
50
  setStep('agent')
58
51
  setType(DEFAULT_WORKSPACE_TYPE)
59
52
  setName('')
60
- chooseFolder.reset()
61
- importFlow.reset()
62
53
  createMutation.reset()
63
54
  }
64
55
 
65
- async function chooseExistingFolder() {
66
- if (isImporting) return
67
- chooseFolder.reset()
68
-
69
- try {
70
- const result = await chooseFolder.mutateAsync()
71
- if (!('canceled' in result)) importFlow.startImport(result)
72
- } catch {
73
- // The agent step renders the folder-picker error.
74
- }
75
- }
76
-
77
56
  function continueToName() {
78
57
  createMutation.reset()
79
58
  setStep('name')
@@ -95,30 +74,13 @@ export function CreateWorkspaceDialog({ trigger }: CreateWorkspaceDialogProps) {
95
74
  >
96
75
  <DialogTrigger render={trigger} />
97
76
  <WorkspaceDialogContent>
98
- {importFlow.choice ? (
99
- <ImportWorkspaceStep
100
- choice={importFlow.choice}
101
- availability={info.data?.availability}
102
- isPending={importFlow.isPending}
103
- errorMessage={importFlow.error?.message}
104
- onTypeChange={importFlow.selectType}
105
- onCancel={importFlow.reset}
106
- onSubmit={importFlow.submit}
107
- />
108
- ) : step === 'agent' ? (
77
+ {step === 'agent' ? (
109
78
  <WorkspaceAgentStep
110
79
  title="Create new workspace"
111
80
  selectedType={type}
112
81
  availability={info.data?.availability}
113
- isPending={isImporting}
114
- errorMessage={(chooseFolder.error ?? importFlow.error)?.message}
115
- secondaryAction={
116
- <ExistingFolderButton
117
- available={canChooseFolder}
118
- disabled={isImporting}
119
- onClick={chooseExistingFolder}
120
- />
121
- }
82
+ isPending={false}
83
+ secondaryAction={<ExistingFolderButton />}
122
84
  primaryLabel="Next"
123
85
  onTypeChange={setType}
124
86
  onSubmit={continueToName}
@@ -204,39 +166,34 @@ function WorkspaceNameStep({
204
166
  )
205
167
  }
206
168
 
207
- type ExistingFolderButtonProps = {
208
- available: boolean
209
- disabled: boolean
210
- onClick: () => void
211
- }
212
-
213
- function ExistingFolderButton({ available, disabled, onClick }: ExistingFolderButtonProps) {
169
+ // Importing a folder from the app is on hold: the native picker only ever ran on
170
+ // macOS and cannot work at all when moi is opened from another device. The
171
+ // button stays as the signpost for the console route.
172
+ function ExistingFolderButton() {
214
173
  const button = (
215
174
  <Button
216
175
  variant="secondary"
217
- disabled={available && disabled}
218
- aria-disabled={!available || undefined}
219
- onClick={event => {
220
- if (!available) {
221
- event.preventDefault()
222
- return
223
- }
224
- onClick()
225
- }}
226
- className={cn(!available && 'cursor-not-allowed opacity-50')}
176
+ aria-disabled
177
+ onClick={event => event.preventDefault()}
178
+ className="cursor-not-allowed opacity-50"
227
179
  >
228
180
  Use existing folder
229
181
  </Button>
230
182
  )
231
183
 
232
- if (available) return button
233
-
234
184
  return (
235
185
  <Tooltip>
236
186
  <TooltipTrigger render={button} />
237
- <TooltipContent>
238
- Run <code className="rounded-xs bg-accent px-1 py-0.5 font-mono">moi init</code> in the
239
- folder to add it manually
187
+ <TooltipContent className="max-w-64">
188
+ {/* The popup lays its children out in a row — one span keeps the copy
189
+ flowing as a sentence with the command inline. */}
190
+ <span className="text-center">
191
+ Not supported yet — run{' '}
192
+ <code className="rounded-xs bg-accent px-1 py-0.5 font-mono whitespace-nowrap">
193
+ moi init
194
+ </code>{' '}
195
+ in the folder from your console to add it
196
+ </span>
240
197
  </TooltipContent>
241
198
  </Tooltip>
242
199
  )
@@ -19,7 +19,7 @@ type ImportWorkspaceStepProps = {
19
19
  onSubmit: () => void
20
20
  }
21
21
 
22
- export function ImportWorkspaceStep({
22
+ function ImportWorkspaceStep({
23
23
  choice,
24
24
  availability,
25
25
  isPending,
@@ -107,9 +107,7 @@ function makeAssetStore(workspaceId: string): TLAssetStore {
107
107
  // from the panel, leaving just the zoom menu. Kept on defaults: NavigationPanel
108
108
  // (zoom), ContextMenu, KeyboardShortcutsDialog.
109
109
  function ScratchBackground() {
110
- return (
111
- <div className="absolute inset-0 bg-[color-mix(in_oklch,var(--muted),var(--background)_50%)]" />
112
- )
110
+ return <div className="absolute inset-0 bg-background" />
113
111
  }
114
112
 
115
113
  function UniformGrid({ x, y, z, size }: TLGridProps) {