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
@@ -0,0 +1,77 @@
1
+ // Which views the workspace keeps mounted, and for how long.
2
+ //
3
+ // A view is not remounted on every tab switch. The one on screen is visible,
4
+ // recently-visited ones stay mounted but hidden — DOM, component state, and
5
+ // styles intact — so coming back inside the retention window is instant. Past
6
+ // the window the view is disposed and the next visit re-loads it behind the
7
+ // splash. The cap bounds what fast tab-cycling can pin in memory: the least
8
+ // recently visited view is dropped first.
9
+ //
10
+ // The policy is pure so the timing rules stay testable; ViewManager owns the
11
+ // clock and the timers.
12
+
13
+ export const VIEW_RETENTION_MS = 60_000
14
+ export const MAX_RESIDENT_VIEWS = 4
15
+
16
+ export type ResidentView = {
17
+ id: string
18
+ // When the view stopped being the active one — null while it is active. The
19
+ // retention deadline is measured from here, and it is set ONCE per departure:
20
+ // re-running the policy must not restart the clock.
21
+ releasedAt: number | null
22
+ }
23
+
24
+ type ReconcileInput = {
25
+ // The view the active tab names, or null when another tab is on screen —
26
+ // which releases every resident, so parking on the chat expires them too.
27
+ activeId: string | null
28
+ // View ids that still exist. A deleted view is dropped immediately; its
29
+ // bundle is gone and its parked DOM would only hold dead styles.
30
+ available: ReadonlySet<string>
31
+ now: number
32
+ }
33
+
34
+ // The resident set after promoting the active view and expiring the rest.
35
+ // Ordered most-recently-active first, so the cap drops the coldest view.
36
+ export function reconcileResidents(
37
+ residents: readonly ResidentView[],
38
+ { activeId, available, now }: ReconcileInput
39
+ ): ResidentView[] {
40
+ const next: ResidentView[] = []
41
+ if (activeId !== null && available.has(activeId)) next.push({ id: activeId, releasedAt: null })
42
+
43
+ for (const resident of residents) {
44
+ if (resident.id === activeId || !available.has(resident.id)) continue
45
+ const releasedAt = resident.releasedAt ?? now
46
+ if (now - releasedAt >= VIEW_RETENTION_MS) continue
47
+ if (next.length >= MAX_RESIDENT_VIEWS) break
48
+ next.push({ id: resident.id, releasedAt })
49
+ }
50
+
51
+ return next
52
+ }
53
+
54
+ // Milliseconds until the next resident falls out of the retention window, or
55
+ // null when nothing is on the clock (every resident is active). ViewManager
56
+ // arms a single timer on this instead of one timer per view.
57
+ export function nextEvictionDelay(residents: readonly ResidentView[], now: number): number | null {
58
+ let earliest: number | null = null
59
+ for (const { releasedAt } of residents) {
60
+ if (releasedAt === null) continue
61
+ const deadline = releasedAt + VIEW_RETENTION_MS
62
+ if (earliest === null || deadline < earliest) earliest = deadline
63
+ }
64
+ return earliest === null ? null : Math.max(0, earliest - now)
65
+ }
66
+
67
+ // Whether a reconcile changed anything — lets the caller keep the previous
68
+ // array identity and skip the re-render (and the timer effect it would rerun).
69
+ export function sameResidents(a: readonly ResidentView[], b: readonly ResidentView[]): boolean {
70
+ return (
71
+ a.length === b.length &&
72
+ a.every((resident, index) => {
73
+ const other = b[index]
74
+ return resident.id === other.id && resident.releasedAt === other.releasedAt
75
+ })
76
+ )
77
+ }
@@ -7,6 +7,8 @@ import { IconMinus, IconPlus } from '@tabler/icons-react'
7
7
  import { cn } from '@/client/lib/cn'
8
8
 
9
9
  import { Button } from '@/client/components/ui/button'
10
+ import { useWorkspaceThemeSetting } from '@/client/features/workspace/WorkspaceLayoutContext'
11
+ import { getWorkspaceThemeStyle } from '@/client/runtime/workspace-theme'
10
12
 
11
13
  type WidgetFrameProps = {
12
14
  editing?: boolean
@@ -16,6 +18,8 @@ type WidgetFrameProps = {
16
18
  }
17
19
 
18
20
  export function WidgetFrame({ editing, hidden, onRemove, children }: WidgetFrameProps) {
21
+ const theme = useWorkspaceThemeSetting()
22
+
19
23
  return (
20
24
  <motion.div
21
25
  variants={{
@@ -35,8 +39,9 @@ export function WidgetFrame({ editing, hidden, onRemove, children }: WidgetFrame
35
39
  // Stable hook for widget snapshots: the capture clone overrides this
36
40
  // element's chrome (radius/shadow/stroke) so thumbnails come out square.
37
41
  data-widget-chrome
42
+ style={getWorkspaceThemeStyle(theme, 'widget')}
38
43
  className={cn(
39
- 'dark absolute inset-0 overflow-hidden rounded-2xl [corner-shape:superellipse(1.2)]',
44
+ 'absolute inset-0 overflow-hidden rounded-2xl text-foreground [corner-shape:superellipse(1.2)]',
40
45
  // Outer drop shadow on the wrapper itself.
41
46
  'shadow-[0_1px_2px_-1px_rgba(0,0,0,0.08),0_2px_4px_0_rgba(0,0,0,0.03)]',
42
47
  // 1px inset stroke painted on a pseudo so it lands ON TOP of the
@@ -45,7 +50,6 @@ export function WidgetFrame({ editing, hidden, onRemove, children }: WidgetFrame
45
50
  'after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit]',
46
51
  "after:content-[''] after:[corner-shape:inherit]",
47
52
  'after:shadow-[inset_0_0_0_1px_rgba(0,0,0,0.05)]',
48
- 'text-foreground',
49
53
  editing && 'pointer-events-none'
50
54
  )}
51
55
  >
@@ -6,16 +6,21 @@ import { useWorkspaceLayoutCtx } from '@/client/features/workspace/WorkspaceLayo
6
6
  import { BottomPanel } from '@/client/components/shared/BottomPanel'
7
7
  import { cn } from '@/client/lib/cn'
8
8
  import { getWorkspaceThemeStyle, usePreloadWorkspaceFonts } from '@/client/runtime/workspace-theme'
9
- import { COLOR_THEMES, type ColorThemeConfig, FONT_THEMES } from '@/lib/themes'
10
- import type { ColorTheme, FontTheme } from '@/lib/types'
9
+ import {
10
+ COLOR_THEMES,
11
+ type ColorThemeConfig,
12
+ FONT_THEMES,
13
+ RADIUS_THEMES,
14
+ type RadiusThemeConfig,
15
+ resolveWorkspaceTheme
16
+ } from '@/lib/themes'
17
+ import type { ColorTheme, FontTheme, RadiusTheme, WorkspaceTheme } from '@/lib/types'
11
18
 
12
19
  const FONT_OPTIONS = Object.entries(FONT_THEMES) as [FontTheme, (typeof FONT_THEMES)[FontTheme]][]
13
20
 
14
21
  const COLOR_OPTIONS = Object.entries(COLOR_THEMES) as [ColorTheme, ColorThemeConfig][]
15
22
 
16
- function presetMatches(preset: ColorThemeConfig, primary?: string): boolean {
17
- return (preset.primary ?? undefined) === primary
18
- }
23
+ const RADIUS_OPTIONS = Object.entries(RADIUS_THEMES) as [RadiusTheme, RadiusThemeConfig][]
19
24
 
20
25
  type CustomizeOptionGroupProps = {
21
26
  children: ReactNode
@@ -26,7 +31,7 @@ function CustomizeOptionGroup({ children, label }: CustomizeOptionGroupProps) {
26
31
  return (
27
32
  <div className="flex flex-col gap-2">
28
33
  <p className="text-xs font-medium">{label}</p>
29
- <div role="group" aria-label={label} className="grid grid-cols-3 gap-2">
34
+ <div role="group" aria-label={label} className="grid grid-cols-4 gap-2">
30
35
  {children}
31
36
  </div>
32
37
  </div>
@@ -55,7 +60,7 @@ function CustomizeOption({ active, children, className, onSelect, style }: Custo
55
60
  )}
56
61
  style={style}
57
62
  >
58
- <div className="flex-1">{children}</div>
63
+ <div className="flex flex-1 flex-col justify-center">{children}</div>
59
64
  {active && <IconCircleCheckFilled size={20} stroke={1.5} aria-hidden="true" />}
60
65
  </button>
61
66
  )
@@ -69,11 +74,10 @@ type CustomizePanelProps = {
69
74
  export function CustomizePanel({ onClose, ref }: CustomizePanelProps) {
70
75
  usePreloadWorkspaceFonts()
71
76
  const { layout, setLayout } = useWorkspaceLayoutCtx()
72
- const currentFont = layout.theme?.font ?? 'default'
73
- const currentPrimary = layout.theme?.primary
77
+ const theme = resolveWorkspaceTheme(layout.theme)
74
78
 
75
- function setTheme(font: FontTheme, primary: string | undefined) {
76
- setLayout({ theme: { font, ...(primary ? { primary } : {}) } })
79
+ function setTheme(update: Partial<WorkspaceTheme>) {
80
+ setLayout({ theme: { ...theme, ...update } })
77
81
  }
78
82
 
79
83
  return (
@@ -83,14 +87,11 @@ export function CustomizePanel({ onClose, ref }: CustomizePanelProps) {
83
87
  {FONT_OPTIONS.map(([key, config]) => (
84
88
  <CustomizeOption
85
89
  key={key}
86
- active={key === currentFont}
87
- onSelect={() => setTheme(key, currentPrimary)}
90
+ active={key === theme.font}
91
+ onSelect={() => setTheme({ font: key })}
88
92
  style={{ fontFamily: config.sans }}
89
93
  >
90
- <div className="flex flex-col">
91
- <span className="text-sm font-medium">{config.label}</span>
92
- <span className="text-xs text-muted-foreground">{config.feel}</span>
93
- </div>
94
+ <span className="text-sm font-medium">{config.label}</span>
94
95
  </CustomizeOption>
95
96
  ))}
96
97
  </CustomizeOptionGroup>
@@ -99,14 +100,10 @@ export function CustomizePanel({ onClose, ref }: CustomizePanelProps) {
99
100
  {COLOR_OPTIONS.map(([key, preset]) => (
100
101
  <CustomizeOption
101
102
  key={key}
102
- active={presetMatches(preset, currentPrimary)}
103
+ active={key === theme.color}
103
104
  className={preset.primary && 'bg-background text-foreground'}
104
- onSelect={() => setTheme(currentFont, preset.primary)}
105
- style={
106
- preset.primary
107
- ? getWorkspaceThemeStyle({ font: currentFont, primary: preset.primary })
108
- : undefined
109
- }
105
+ onSelect={() => setTheme({ color: key })}
106
+ style={getWorkspaceThemeStyle({ ...theme, color: key })}
110
107
  >
111
108
  <div className="flex gap-2">
112
109
  <span
@@ -124,6 +121,25 @@ export function CustomizePanel({ onClose, ref }: CustomizePanelProps) {
124
121
  </CustomizeOption>
125
122
  ))}
126
123
  </CustomizeOptionGroup>
124
+
125
+ <CustomizeOptionGroup label="Radius">
126
+ {RADIUS_OPTIONS.map(([key, preset]) => (
127
+ <CustomizeOption
128
+ key={key}
129
+ active={key === theme.radius}
130
+ onSelect={() => setTheme({ radius: key })}
131
+ style={getWorkspaceThemeStyle({ ...theme, radius: key })}
132
+ >
133
+ <div className="flex items-center gap-2">
134
+ <span
135
+ className="size-5 shrink-0 rounded-sm bg-card texture-checker-[10px] shadow-xs"
136
+ aria-hidden="true"
137
+ />
138
+ <span className="text-sm font-medium">{preset.label}</span>
139
+ </div>
140
+ </CustomizeOption>
141
+ ))}
142
+ </CustomizeOptionGroup>
127
143
  </div>
128
144
  </BottomPanel>
129
145
  )
@@ -11,7 +11,7 @@ import { workspaceKeys } from '@/client/api/workspace-keys'
11
11
  import type { WorkspaceLayout, WorkspaceType } from '@/lib/types'
12
12
  import { createDefaultWorkspaceLayout } from '@/lib/workspace-layout'
13
13
 
14
- type WorkspaceLayoutContextValue = {
14
+ export type WorkspaceLayoutContextValue = {
15
15
  // The persisted layout (widget grid, layout mode, theme). Falls back to an
16
16
  // empty default while the query is still loading.
17
17
  layout: WorkspaceLayout
@@ -33,7 +33,9 @@ type WorkspaceLayoutContextValue = {
33
33
  isLoading: boolean
34
34
  }
35
35
 
36
- const WorkspaceLayoutContext = createContext<WorkspaceLayoutContextValue | null>(null)
36
+ // Exported (with its value type) so fixture surfaces like /dev/chat-states can
37
+ // provide a static value without mounting the query-backed provider.
38
+ export const WorkspaceLayoutContext = createContext<WorkspaceLayoutContextValue | null>(null)
37
39
 
38
40
  export function useWorkspaceLayoutCtx(): WorkspaceLayoutContextValue {
39
41
  const ctx = useContext(WorkspaceLayoutContext)
@@ -41,6 +43,14 @@ export function useWorkspaceLayoutCtx(): WorkspaceLayoutContextValue {
41
43
  return ctx
42
44
  }
43
45
 
46
+ // The theme alone, for chrome that only needs to paint itself (widget frames,
47
+ // previews). Unlike `useWorkspaceLayoutCtx` this tolerates being read outside a
48
+ // provider and returns `undefined` there, which callers already treat as "use
49
+ // the default theme" — so the same component still renders in isolation.
50
+ export function useWorkspaceThemeSetting(): WorkspaceLayout['theme'] {
51
+ return useContext(WorkspaceLayoutContext)?.layout.theme
52
+ }
53
+
44
54
  // Strip the server-only metadata so what we PUT back (and expose as `layout`)
45
55
  // is just the persisted `WorkspaceLayout`.
46
56
  function stripMeta(data: WorkspaceLayoutResponse): WorkspaceLayout {