moi-computer 0.9.0 → 0.9.1-next.1
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.
- package/client/api/app-config.ts +51 -0
- package/client/api/workspace-keys.ts +1 -0
- package/client/app/routes/WorkspaceRoute.tsx +4 -2
- package/client/assets/hermes.png +0 -0
- package/client/components/shared/IconGhost.tsx +15 -18
- package/client/components/ui/button.tsx +2 -2
- package/client/components/ui/hover-card.tsx +1 -1
- package/client/components/ui/popover.tsx +3 -1
- package/client/features/applets/api.ts +38 -0
- package/client/features/applets/applet-thumbnail.ts +208 -0
- package/client/features/chat/ChatEmptyState.tsx +30 -10
- package/client/features/chat/ChatPanel.tsx +67 -31
- package/client/features/chat/ChatPopup.tsx +3 -2
- package/client/features/chat/ChatPromptBubbles.tsx +1 -1
- package/client/features/chat/ChatSelector.tsx +29 -10
- package/client/features/chat/MarkdownContent.tsx +3 -3
- package/client/features/chat/attachment-staging.ts +153 -0
- package/client/features/chat/chat-send.ts +55 -0
- package/client/features/chat/chat-store.ts +32 -8
- package/client/features/chat/composer/ChatComposer.tsx +190 -77
- package/client/features/chat/{ModelPicker.tsx → composer/ModelPicker.tsx} +29 -25
- package/client/features/chat/composer/banners/ComposerBanner.tsx +1 -1
- package/client/features/chat/composer/banners/WorkspaceAgentAvailabilityBanner.tsx +4 -13
- package/client/features/chat/{model-order.ts → composer/model-order.ts} +16 -0
- package/client/features/chat/composer/useWorkspaceComposerState.tsx +9 -4
- package/client/features/chat/tool-group/format/claude.ts +48 -0
- package/client/features/chat/tool-group/format/codex.ts +126 -0
- package/client/features/chat/tool-group/format/hermes.ts +68 -0
- package/client/features/chat/tool-group/format/index.ts +34 -0
- package/client/features/chat/tool-group/format/mcp.ts +64 -0
- package/client/features/chat/tool-group/format/openclaw.ts +116 -0
- package/client/features/chat/tool-group/format/shared.ts +49 -0
- package/client/features/chat/useChat.ts +5 -10
- package/client/features/drawings/DrawingLayer.tsx +49 -0
- package/client/features/drawings/DrawingToolbar.tsx +95 -0
- package/client/features/drawings/capture-element.ts +45 -0
- package/client/features/drawings/useChatAnnotation.ts +222 -0
- package/client/features/drawings/useDrawingLayer.ts +758 -0
- package/client/features/drawings/useViewBuilderSketch.ts +151 -0
- package/client/features/home/HomePage.tsx +13 -0
- package/client/features/home/WorkspacePreview.tsx +10 -5
- package/client/features/home/workspace-presentation.tsx +6 -2
- package/client/features/home/workspace-setup/CreateWorkspaceDialog.tsx +9 -0
- package/client/features/home/workspace-setup/InstallMoiDialog.tsx +245 -0
- package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +13 -7
- package/client/features/home/workspace-setup/WorkspaceDialogContent.tsx +1 -1
- package/client/features/scratchpad/ScratchpadControls.tsx +19 -5
- package/client/features/views/ViewBuilder.tsx +238 -0
- package/client/features/views/ViewManager.tsx +18 -2
- package/client/features/views/api.ts +1 -0
- package/client/features/views/useViewBuilderActions.ts +24 -3
- package/client/features/views/useViewBuilderDrafts.ts +66 -0
- package/client/features/widgets/WidgetFrame.tsx +1 -1
- package/client/features/widgets/WidgetGrid.tsx +1 -1
- package/client/features/widgets/Widgets.tsx +39 -54
- package/client/features/workspace/CustomizePanel.tsx +30 -9
- package/client/features/workspace/WorkspaceScreen.tsx +158 -64
- package/client/features/workspace/WorkspaceTabs.tsx +3 -3
- package/client/features/workspace/useFitsSplitLayout.ts +14 -8
- package/client/index.css +8 -0
- package/client/index.tsx +6 -1
- package/client/runtime/useWorkspaceEvents.ts +17 -0
- package/client/runtime/workspace-theme.ts +29 -6
- package/client/store/ui.ts +19 -0
- package/client/theme.css +33 -8
- package/dist/chunk-5c19v3zr.js +10 -0
- package/dist/chunk-6wx91x8j.js +1 -0
- package/dist/chunk-8s41nd3g.js +1 -0
- package/dist/{chunk-kkj86722.js → chunk-a7fzp0z0.js} +78 -78
- package/dist/{chunk-2vaafjp4.js → chunk-b959mdkj.js} +1 -1
- package/dist/chunk-cagtq45k.js +1 -0
- package/dist/chunk-cva7jpt4.js +82 -0
- package/dist/chunk-sapvd7he.css +1 -0
- package/dist/{chunk-35fq49qa.js → chunk-zbeq02yc.js} +1 -1
- package/dist/chunk-zbt8emsw.js +2 -0
- package/dist/chunk-zfz3b4xg.js +2 -0
- package/dist/hermes-pznd63x9.png +0 -0
- package/dist/index.html +1 -1
- package/lib/format.ts +1 -1
- package/lib/themes.ts +8 -8
- package/lib/types.ts +68 -42
- package/lib/workspace-types.ts +2 -1
- package/package.json +2 -1
- package/server/api.ts +90 -33
- package/server/app-config.ts +144 -0
- package/server/applets.ts +17 -0
- package/server/cli.ts +235 -14
- package/server/harness/README.md +64 -17
- package/server/harness/acp/adapter.ts +220 -0
- package/server/harness/acp/archived.ts +88 -0
- package/server/harness/acp/client.ts +328 -0
- package/server/harness/acp/discovery.ts +130 -0
- package/server/harness/acp/run-durations.ts +68 -0
- package/server/harness/acp/session.ts +788 -0
- package/server/harness/acp/wire.ts +132 -0
- package/server/harness/executable.ts +15 -1
- package/server/harness/hermes/NOTES.md +815 -0
- package/server/harness/hermes/discovery.ts +155 -0
- package/server/harness/hermes/index.ts +155 -0
- package/server/harness/hermes/models.ts +79 -0
- package/server/harness/registry.ts +3 -1
- package/server/layout.ts +40 -45
- package/server/moi-scaffold.ts +37 -1
- package/server/thumbnails.ts +197 -0
- package/server/view-builders.ts +4 -2
- package/server/views.ts +10 -1
- package/server/widgets.ts +4 -18
- package/server/workspace-import.ts +30 -1
- package/workspace/.claude/skills/moi-workspace/SKILL.md +13 -1
- package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +153 -253
- package/client/features/chat/tool-group/format.ts +0 -384
- package/client/features/views/ViewBuilderTab.tsx +0 -152
- package/client/features/widgets/api.ts +0 -47
- package/client/features/widgets/useWidgetThumbnails.ts +0 -107
- package/client/features/widgets/widget-snapshot.ts +0 -71
- package/dist/chunk-3b3rkjet.js +0 -1
- package/dist/chunk-gt7n06ef.js +0 -1
- package/dist/chunk-ty1sqbmn.js +0 -80
- package/dist/chunk-xeyxk7ep.js +0 -10
- package/dist/chunk-yz6wd5vc.css +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { lazy, Suspense, useEffect, useState } from 'react'
|
|
1
|
+
import { lazy, Suspense, useEffect, useRef, useState } from 'react'
|
|
2
2
|
|
|
3
3
|
import { AnimatePresence } from 'motion/react'
|
|
4
4
|
|
|
@@ -12,6 +12,9 @@ import {
|
|
|
12
12
|
} from '@tabler/icons-react'
|
|
13
13
|
|
|
14
14
|
import { IconGhost } from '@/client/components/shared/IconGhost'
|
|
15
|
+
import { DrawingLayer } from '@/client/features/drawings/DrawingLayer'
|
|
16
|
+
import { DrawingToolbar } from '@/client/features/drawings/DrawingToolbar'
|
|
17
|
+
import { useChatAnnotation } from '@/client/features/drawings/useChatAnnotation'
|
|
15
18
|
import { ChatPanel } from '@/client/features/chat/ChatPanel'
|
|
16
19
|
import { ChatPopup } from '@/client/features/chat/ChatPopup'
|
|
17
20
|
import { CustomizePanel } from '@/client/features/workspace/CustomizePanel'
|
|
@@ -24,9 +27,10 @@ import { Tooltip, TooltipContent, TooltipTrigger } from '@/client/components/ui/
|
|
|
24
27
|
import { WorkspaceSettings } from '@/client/features/settings/WorkspaceSettings'
|
|
25
28
|
import { useAppletChatMessage } from '@/client/features/chat/useAppletChatMessage'
|
|
26
29
|
import { useChat } from '@/client/features/chat/useChat'
|
|
27
|
-
import {
|
|
30
|
+
import { ViewBuilder, type ViewBuilderHandle } from '@/client/features/views/ViewBuilder'
|
|
28
31
|
import { ViewManager } from '@/client/features/views/ViewManager'
|
|
29
32
|
import { useViewBuilderActions } from '@/client/features/views/useViewBuilderActions'
|
|
33
|
+
import { useViewBuilderDrafts } from '@/client/features/views/useViewBuilderDrafts'
|
|
30
34
|
import { useFitsSplitLayout } from '@/client/features/workspace/useFitsSplitLayout'
|
|
31
35
|
import { useWorkspaceComposerState } from '@/client/features/chat/composer/useWorkspaceComposerState'
|
|
32
36
|
import { useWorkspaceTheme } from '@/client/runtime/workspace-theme'
|
|
@@ -51,7 +55,13 @@ import {
|
|
|
51
55
|
type WorkspaceTabItem,
|
|
52
56
|
WorkspaceTabs
|
|
53
57
|
} from '@/client/features/workspace/WorkspaceTabs'
|
|
54
|
-
import type {
|
|
58
|
+
import type {
|
|
59
|
+
LayoutMode,
|
|
60
|
+
ViewBuilder as ViewBuilderData,
|
|
61
|
+
ViewInfo,
|
|
62
|
+
WidgetInfo,
|
|
63
|
+
WorkspaceTabId
|
|
64
|
+
} from '@/lib/types'
|
|
55
65
|
import {
|
|
56
66
|
viewBuilderIdFromTab,
|
|
57
67
|
viewBuilderTabId,
|
|
@@ -70,9 +80,9 @@ const Scratchpad = lazy(() =>
|
|
|
70
80
|
// Tab label for a view: its configured title, or the file-name id as fallback.
|
|
71
81
|
const viewLabel = (v: ViewInfo) => v.config.title || v.id
|
|
72
82
|
|
|
73
|
-
const viewBuilderIcon = (builder:
|
|
83
|
+
const viewBuilderIcon = (builder: ViewBuilderData) => resolveAppIcon(builder.icon) ?? IconArticle
|
|
74
84
|
|
|
75
|
-
function viewIcon(view: ViewInfo, builders:
|
|
85
|
+
function viewIcon(view: ViewInfo, builders: ViewBuilderData[]) {
|
|
76
86
|
const builder = builders.find(candidate => candidate.viewId === view.id)
|
|
77
87
|
return resolveAppIcon(view.config.icon) ?? resolveAppIcon(builder?.icon) ?? IconArticle
|
|
78
88
|
}
|
|
@@ -108,11 +118,12 @@ function WorkspaceCustomizeAction({ active, onToggle }: WorkspaceCustomizeAction
|
|
|
108
118
|
<TooltipTrigger
|
|
109
119
|
render={
|
|
110
120
|
<Button
|
|
111
|
-
variant=
|
|
121
|
+
variant="ghost"
|
|
112
122
|
size="icon-sm"
|
|
113
123
|
aria-label="Customize"
|
|
114
124
|
aria-pressed={active}
|
|
115
125
|
onClick={onToggle}
|
|
126
|
+
className={cn(active && 'bg-accent')}
|
|
116
127
|
>
|
|
117
128
|
<IconLetterCase stroke={1.75} />
|
|
118
129
|
</Button>
|
|
@@ -126,7 +137,7 @@ function WorkspaceCustomizeAction({ active, onToggle }: WorkspaceCustomizeAction
|
|
|
126
137
|
type WorkspaceScreenProps = {
|
|
127
138
|
widgets: WidgetInfo[]
|
|
128
139
|
views: ViewInfo[]
|
|
129
|
-
builders:
|
|
140
|
+
builders: ViewBuilderData[]
|
|
130
141
|
}
|
|
131
142
|
|
|
132
143
|
type WidgetMode = 'idle' | 'editing' | 'customizing'
|
|
@@ -134,7 +145,7 @@ type WidgetMode = 'idle' | 'editing' | 'customizing'
|
|
|
134
145
|
function tabItemFor(
|
|
135
146
|
tab: WorkspaceTabId,
|
|
136
147
|
views: ViewInfo[],
|
|
137
|
-
builders:
|
|
148
|
+
builders: ViewBuilderData[],
|
|
138
149
|
closable: boolean,
|
|
139
150
|
agentRunning: boolean,
|
|
140
151
|
builderRunning: (sessionId: string) => boolean
|
|
@@ -208,10 +219,15 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
208
219
|
const [widgetMode, setWidgetMode] = useState<WidgetMode>('idle')
|
|
209
220
|
const [floatingChatOpen, setFloatingChatOpen] = useState(false)
|
|
210
221
|
const [chatFocusRequest, setChatFocusRequest] = useState(0)
|
|
222
|
+
const builderRefs = useRef(new Map<string, ViewBuilderHandle>())
|
|
211
223
|
const dockedChatWidth = useUiStore(state => state.dockedChatWidth)
|
|
212
224
|
const setDockedChatWidth = useUiStore(state => state.setDockedChatWidth)
|
|
213
225
|
const sessionActivity = useLive(state => state.activity)
|
|
214
226
|
const hasRunningSession = hasRunningWorkspaceActivity(sessionActivity, workspaceId)
|
|
227
|
+
const builderDrafts = useViewBuilderDrafts({
|
|
228
|
+
builders,
|
|
229
|
+
onSave: (builderId, requirements) => builderActions.save(builderId, requirements)
|
|
230
|
+
})
|
|
215
231
|
|
|
216
232
|
useWorkspaceTheme(layout.theme)
|
|
217
233
|
|
|
@@ -251,10 +267,13 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
251
267
|
selectSession,
|
|
252
268
|
dismissError
|
|
253
269
|
} = useChat({ activeTab, appletParams })
|
|
254
|
-
const { composerBanner, composerAvailability } = useWorkspaceComposerState(
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
270
|
+
const { composerBanner, builderComposerBanner, composerAvailability } = useWorkspaceComposerState(
|
|
271
|
+
workspaceId,
|
|
272
|
+
{
|
|
273
|
+
chatError: error,
|
|
274
|
+
onDismissChatError: dismissError
|
|
275
|
+
}
|
|
276
|
+
)
|
|
258
277
|
|
|
259
278
|
const openSet = new Set(tabsState.open)
|
|
260
279
|
|
|
@@ -285,6 +304,24 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
285
304
|
const activeBuilder = activeBuilderId
|
|
286
305
|
? builders.find(builder => builder.id === activeBuilderId)
|
|
287
306
|
: undefined
|
|
307
|
+
const activeDraftBuilder =
|
|
308
|
+
activeBuilder?.status === 'draft' &&
|
|
309
|
+
!isSessionRunning(sessionActivity, workspaceId, activeBuilder.sessionId)
|
|
310
|
+
? activeBuilder
|
|
311
|
+
: undefined
|
|
312
|
+
const activeDraftBuilderId = activeDraftBuilder?.id
|
|
313
|
+
const canAnnotate =
|
|
314
|
+
widgetMode === 'idle' &&
|
|
315
|
+
((activeTab === 'widgets' && widgets.length > 0) || activeView !== undefined)
|
|
316
|
+
const annotation = useChatAnnotation({
|
|
317
|
+
workspaceId,
|
|
318
|
+
sessionId,
|
|
319
|
+
activeTab,
|
|
320
|
+
mode,
|
|
321
|
+
available: canAnnotate,
|
|
322
|
+
closePopup: () => setFloatingChatOpen(false),
|
|
323
|
+
openPopup: () => setFloatingChatOpen(true)
|
|
324
|
+
})
|
|
288
325
|
|
|
289
326
|
useEffect(() => {
|
|
290
327
|
const open = tabsState.open.filter(tab => tabAvailable(tab, views, builders))
|
|
@@ -339,6 +376,12 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
339
376
|
}
|
|
340
377
|
}, [activeTab, mode])
|
|
341
378
|
|
|
379
|
+
useEffect(() => {
|
|
380
|
+
if (!activeDraftBuilderId) return
|
|
381
|
+
if (mode === 'fullscreen') setFloatingChatOpen(true)
|
|
382
|
+
setChatFocusRequest(request => request + 1)
|
|
383
|
+
}, [activeDraftBuilderId, mode])
|
|
384
|
+
|
|
342
385
|
// Tab switching is navigation; the saved default and the open set follow via
|
|
343
386
|
// the navigation hook. Only the chat side effects belong to the screen.
|
|
344
387
|
const openTab = (tab: WorkspaceTabId, params?: Record<string, unknown>) => {
|
|
@@ -382,10 +425,14 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
382
425
|
// tabsStateRef) can't resurrect the closed tab.
|
|
383
426
|
setTabs({ open, active })
|
|
384
427
|
if (activeTab === tab) navigateToTab(nextTab)
|
|
385
|
-
if (builder?.status === 'draft')
|
|
428
|
+
if (builder?.status === 'draft') {
|
|
429
|
+
void builderRefs.current.get(builder.id)?.resetSketch()
|
|
430
|
+
builderDrafts.clear(builder.id)
|
|
431
|
+
void builderActions.discard(builder.id)
|
|
432
|
+
}
|
|
386
433
|
}
|
|
387
434
|
|
|
388
|
-
const discardBuilder = (builder:
|
|
435
|
+
const discardBuilder = (builder: ViewBuilderData) => {
|
|
389
436
|
const tab = viewBuilderTabId(builder.id)
|
|
390
437
|
if (openSet.has(tab)) {
|
|
391
438
|
let open = tabsState.open.filter(item => item !== tab)
|
|
@@ -393,6 +440,8 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
393
440
|
setTabs({ open, active: tabsState.active === tab ? open[0] : tabsState.active })
|
|
394
441
|
if (activeTab === tab) navigateToTab(open[0])
|
|
395
442
|
}
|
|
443
|
+
void builderRefs.current.get(builder.id)?.resetSketch()
|
|
444
|
+
builderDrafts.clear(builder.id)
|
|
396
445
|
void builderActions.discard(builder.id)
|
|
397
446
|
}
|
|
398
447
|
|
|
@@ -489,6 +538,25 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
489
538
|
}
|
|
490
539
|
]
|
|
491
540
|
|
|
541
|
+
const builderChatDraft = activeDraftBuilder
|
|
542
|
+
? {
|
|
543
|
+
sessionId: activeDraftBuilder.sessionId,
|
|
544
|
+
builderId: activeDraftBuilder.id,
|
|
545
|
+
initialValue: activeDraftBuilder.input.requirements,
|
|
546
|
+
onChange: (value: string) => builderDrafts.change(activeDraftBuilder.id, value),
|
|
547
|
+
onRemoveDrawing: () => {
|
|
548
|
+
void builderRefs.current.get(activeDraftBuilder.id)?.resetSketch()
|
|
549
|
+
},
|
|
550
|
+
onSubmit: async (value: string) => {
|
|
551
|
+
const builderView = builderRefs.current.get(activeDraftBuilder.id)
|
|
552
|
+
await builderView?.prepareSketchForSend()
|
|
553
|
+
await builderActions.submit(activeDraftBuilder, value)
|
|
554
|
+
// Submit clears the sent attachment. Keep the canvas until the built view replaces it.
|
|
555
|
+
builderDrafts.clear(activeDraftBuilder.id)
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
: undefined
|
|
559
|
+
|
|
492
560
|
// The docked split chat. Full-screen Agent uses the tabbed chat below.
|
|
493
561
|
const dockedChat = (
|
|
494
562
|
<ChatPanel
|
|
@@ -499,12 +567,13 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
499
567
|
previewTurn={previewTurn}
|
|
500
568
|
sessionId={sessionId}
|
|
501
569
|
processing={processing}
|
|
502
|
-
composerBanner={composerBanner}
|
|
570
|
+
composerBanner={builderChatDraft ? builderComposerBanner : composerBanner}
|
|
503
571
|
composerAvailability={composerAvailability}
|
|
504
572
|
send={send}
|
|
505
573
|
stop={stop}
|
|
506
|
-
onSelectSession={selectSession}
|
|
507
574
|
onClose={() => setMode('fullscreen')}
|
|
575
|
+
annotation={annotation.docked}
|
|
576
|
+
builderDraft={builderChatDraft}
|
|
508
577
|
docked
|
|
509
578
|
/>
|
|
510
579
|
)
|
|
@@ -522,57 +591,85 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
522
591
|
composerAvailability={composerAvailability}
|
|
523
592
|
send={send}
|
|
524
593
|
stop={stop}
|
|
525
|
-
onSelectSession={selectSession}
|
|
526
594
|
/>
|
|
527
595
|
)
|
|
528
|
-
|
|
529
596
|
const workspacePanel = (
|
|
530
597
|
<div
|
|
531
598
|
className={cn(
|
|
532
|
-
'flex h-full min-h-0 min-w-0 flex-1 flex-col-reverse overflow-hidden bg-background shadow-
|
|
599
|
+
'@container/workspace relative flex h-full min-h-0 min-w-0 flex-1 flex-col-reverse overflow-hidden bg-background shadow-md transition-[border-radius]',
|
|
533
600
|
mode === 'split' && 'rounded-xl'
|
|
534
601
|
)}
|
|
535
602
|
>
|
|
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
|
-
|
|
603
|
+
<div className="relative flex min-h-0 flex-1">
|
|
604
|
+
<div
|
|
605
|
+
ref={annotation.targetRef}
|
|
606
|
+
inert={annotation.controls.active || undefined}
|
|
607
|
+
aria-hidden={annotation.controls.active || undefined}
|
|
608
|
+
className="flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-background"
|
|
609
|
+
>
|
|
610
|
+
{activeTab === 'agent' ? (
|
|
611
|
+
tabbedChat
|
|
612
|
+
) : activeTab === 'widgets' ? (
|
|
613
|
+
<Widgets
|
|
614
|
+
editing={widgetMode === 'editing'}
|
|
615
|
+
onEditingChange={editing => setWidgetMode(editing ? 'editing' : 'idle')}
|
|
616
|
+
widgets={widgets}
|
|
617
|
+
onCreateWidget={() => {
|
|
618
|
+
selectSession(null)
|
|
619
|
+
openChat('Create widget')
|
|
620
|
+
}}
|
|
621
|
+
/>
|
|
622
|
+
) : activeTab === 'scratchpad' ? (
|
|
623
|
+
<Suspense fallback={null}>
|
|
624
|
+
<Scratchpad />
|
|
625
|
+
</Suspense>
|
|
626
|
+
) : null}
|
|
627
|
+
|
|
628
|
+
{builders
|
|
629
|
+
.filter(builder => builder.status !== 'ready')
|
|
630
|
+
.map(builder => (
|
|
631
|
+
<ViewBuilder
|
|
632
|
+
key={builder.id}
|
|
633
|
+
ref={handle => {
|
|
634
|
+
if (handle) builderRefs.current.set(builder.id, handle)
|
|
635
|
+
else builderRefs.current.delete(builder.id)
|
|
636
|
+
}}
|
|
637
|
+
active={activeBuilder?.id === builder.id}
|
|
638
|
+
builder={builder}
|
|
639
|
+
chatDocked={mode === 'split'}
|
|
640
|
+
workspaceId={workspaceId}
|
|
641
|
+
onEditingStart={() => {
|
|
642
|
+
if (mode === 'fullscreen') setFloatingChatOpen(false)
|
|
643
|
+
}}
|
|
644
|
+
onContinueInChat={openChat}
|
|
645
|
+
onOpenChat={() => {
|
|
646
|
+
selectSession(builder.sessionId)
|
|
647
|
+
openChat()
|
|
648
|
+
}}
|
|
649
|
+
onDiscard={() => discardBuilder(builder)}
|
|
650
|
+
/>
|
|
651
|
+
))}
|
|
652
|
+
|
|
653
|
+
{/* Views are not part of the chain above: ViewManager keeps them
|
|
654
|
+
mounted across tab switches (and collapses to nothing while
|
|
655
|
+
another tab is on screen), which is what makes a switch back
|
|
656
|
+
instant. */}
|
|
657
|
+
<ViewManager views={views} activeViewId={activeView?.id ?? null} params={appletParams} />
|
|
658
|
+
</div>
|
|
569
659
|
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
660
|
+
<DrawingLayer {...annotation.layerProps}>
|
|
661
|
+
<DrawingToolbar
|
|
662
|
+
controls={annotation.controls}
|
|
663
|
+
title="Draw annotation"
|
|
664
|
+
busy={annotation.controls.finishing}
|
|
665
|
+
onComplete={() => void annotation.controls.finish()}
|
|
666
|
+
/>
|
|
667
|
+
</DrawingLayer>
|
|
668
|
+
</div>
|
|
669
|
+
|
|
670
|
+
<AnimatePresence>
|
|
671
|
+
{widgetMode === 'customizing' && <CustomizePanel onClose={() => setWidgetMode('idle')} />}
|
|
672
|
+
</AnimatePresence>
|
|
576
673
|
|
|
577
674
|
<PanelHeader>
|
|
578
675
|
<div className="flex min-w-0 flex-1 items-center gap-4">
|
|
@@ -625,10 +722,6 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
625
722
|
)}
|
|
626
723
|
</div>
|
|
627
724
|
|
|
628
|
-
<AnimatePresence>
|
|
629
|
-
{widgetMode === 'customizing' && <CustomizePanel onClose={() => setWidgetMode('idle')} />}
|
|
630
|
-
</AnimatePresence>
|
|
631
|
-
|
|
632
725
|
{mode === 'fullscreen' && activeTab !== 'agent' && hasWorkspaceContent && (
|
|
633
726
|
<ChatPopup
|
|
634
727
|
loading={hasRunningSession}
|
|
@@ -649,12 +742,13 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
649
742
|
previewTurn={previewTurn}
|
|
650
743
|
sessionId={sessionId}
|
|
651
744
|
processing={processing}
|
|
652
|
-
composerBanner={composerBanner}
|
|
745
|
+
composerBanner={builderChatDraft ? builderComposerBanner : composerBanner}
|
|
653
746
|
composerAvailability={composerAvailability}
|
|
654
747
|
send={send}
|
|
655
748
|
stop={stop}
|
|
656
|
-
onSelectSession={selectSession}
|
|
657
749
|
onClose={onClose}
|
|
750
|
+
annotation={annotation.popup}
|
|
751
|
+
builderDraft={builderChatDraft}
|
|
658
752
|
/>
|
|
659
753
|
)}
|
|
660
754
|
</ChatPopup>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IconPlus, IconX, type
|
|
1
|
+
import { IconPlus, IconX, type Icon as TabIcon } from '@tabler/icons-react'
|
|
2
2
|
import { cva } from 'class-variance-authority'
|
|
3
3
|
|
|
4
4
|
import { IconGhost } from '@/client/components/shared/IconGhost'
|
|
@@ -18,7 +18,7 @@ import type { WorkspaceTabId } from '@/lib/types'
|
|
|
18
18
|
|
|
19
19
|
export type WorkspaceTabItem = {
|
|
20
20
|
key: WorkspaceTabId
|
|
21
|
-
Icon:
|
|
21
|
+
Icon: TabIcon
|
|
22
22
|
label: string
|
|
23
23
|
closable?: boolean
|
|
24
24
|
loading?: boolean
|
|
@@ -26,7 +26,7 @@ export type WorkspaceTabItem = {
|
|
|
26
26
|
|
|
27
27
|
export type CreateWorkspaceTabItem = {
|
|
28
28
|
key: string
|
|
29
|
-
Icon:
|
|
29
|
+
Icon: TabIcon
|
|
30
30
|
label: string
|
|
31
31
|
onClick: () => void
|
|
32
32
|
}
|
|
@@ -18,7 +18,7 @@ function tokenPx(name: string): number {
|
|
|
18
18
|
return raw.endsWith('rem') ? value * Number.parseFloat(getComputedStyle(root).fontSize) : value
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
//
|
|
21
|
+
// Measure the full workspace row, not either pane, so split-fit measurement does
|
|
22
22
|
// not oscillate when the chat column appears or disappears.
|
|
23
23
|
export function useFitsSplitLayout<T extends HTMLElement>() {
|
|
24
24
|
const ref = useRef<T>(null)
|
|
@@ -32,21 +32,27 @@ export function useFitsSplitLayout<T extends HTMLElement>() {
|
|
|
32
32
|
const workspaceMinWidth = tokenPx('--column-w')
|
|
33
33
|
const chatMinWidth = tokenPx('--chat-min')
|
|
34
34
|
const chatMaxWidth = tokenPx('--chat-max')
|
|
35
|
-
|
|
35
|
+
const next = {
|
|
36
36
|
fits: width - chatMinWidth >= workspaceMinWidth,
|
|
37
37
|
workspaceMinWidth,
|
|
38
38
|
chatMinWidth,
|
|
39
39
|
chatMaxWidth
|
|
40
|
-
}
|
|
40
|
+
}
|
|
41
|
+
setState(current =>
|
|
42
|
+
current?.fits === next.fits &&
|
|
43
|
+
current.workspaceMinWidth === next.workspaceMinWidth &&
|
|
44
|
+
current.chatMinWidth === next.chatMinWidth &&
|
|
45
|
+
current.chatMaxWidth === next.chatMaxWidth
|
|
46
|
+
? current
|
|
47
|
+
: next
|
|
48
|
+
)
|
|
41
49
|
}
|
|
42
50
|
|
|
43
51
|
update(el.getBoundingClientRect().width)
|
|
44
52
|
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
ro.observe(el)
|
|
49
|
-
return () => ro.disconnect()
|
|
53
|
+
const onResize = () => update(el.getBoundingClientRect().width)
|
|
54
|
+
window.addEventListener('resize', onResize)
|
|
55
|
+
return () => window.removeEventListener('resize', onResize)
|
|
50
56
|
}, [])
|
|
51
57
|
|
|
52
58
|
return {
|
package/client/index.css
CHANGED
|
@@ -15,6 +15,10 @@
|
|
|
15
15
|
@custom-variant dark-or-widget (&:is(.dark *, [data-widget-chrome] *));
|
|
16
16
|
|
|
17
17
|
:root {
|
|
18
|
+
--cursor-pencil:
|
|
19
|
+
url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='white' stroke='%23171717' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cdefs%3E%3Cfilter id='s' x='-20%25' y='-20%25' width='140%25' height='150%25'%3E%3CfeDropShadow dx='0' dy='1' stdDeviation='.65' flood-color='%23000' flood-opacity='.14'/%3E%3C/filter%3E%3C/defs%3E%3Cg filter='url(%23s)'%3E%3Cpath d='M4 20h4l10.5-10.5a2.828 2.828 0 1 0-4-4L4 16v4'/%3E%3Cpath d='m13.5 6.5 4 4'/%3E%3C/g%3E%3C/svg%3E")
|
|
20
|
+
3 17,
|
|
21
|
+
crosshair;
|
|
18
22
|
--background: oklch(1 0 0);
|
|
19
23
|
--foreground: oklch(0.145 0 0);
|
|
20
24
|
--card: oklch(1 0 0);
|
|
@@ -172,6 +176,10 @@
|
|
|
172
176
|
}
|
|
173
177
|
}
|
|
174
178
|
|
|
179
|
+
@utility cursor-pencil {
|
|
180
|
+
cursor: var(--cursor-pencil);
|
|
181
|
+
}
|
|
182
|
+
|
|
175
183
|
/* Tool details toggle */
|
|
176
184
|
details > summary {
|
|
177
185
|
list-style: none;
|
package/client/index.tsx
CHANGED
|
@@ -21,7 +21,12 @@ if (import.meta.hot) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export async function init(el: HTMLElement) {
|
|
24
|
-
|
|
24
|
+
// Startup config loads in parallel with the main chunk, so it is available
|
|
25
|
+
// synchronously to every component from the first render.
|
|
26
|
+
const [{ mount }] = await Promise.all([
|
|
27
|
+
import('./main'),
|
|
28
|
+
import('./api/app-config').then(m => m.loadAppConfig())
|
|
29
|
+
])
|
|
25
30
|
mount(el)
|
|
26
31
|
}
|
|
27
32
|
|
|
@@ -56,6 +56,11 @@ export type WorkspaceEvent =
|
|
|
56
56
|
type WorkspaceEventHandler = (event: WorkspaceEvent) => void
|
|
57
57
|
|
|
58
58
|
const listeners = new Set<WorkspaceEventHandler>()
|
|
59
|
+
// Fired when the socket comes back after a drop — for the SPA that means the
|
|
60
|
+
// server restarted (it holds the connection for its whole lifetime), so
|
|
61
|
+
// restart-scoped state such as the startup config can refetch.
|
|
62
|
+
const reconnectListeners = new Set<() => void>()
|
|
63
|
+
let everConnected = false
|
|
59
64
|
let ws: WebSocket | null = null
|
|
60
65
|
let connecting = false
|
|
61
66
|
|
|
@@ -68,6 +73,8 @@ function ensureConnection() {
|
|
|
68
73
|
socket.onopen = () => {
|
|
69
74
|
ws = socket
|
|
70
75
|
connecting = false
|
|
76
|
+
if (everConnected) for (const handler of reconnectListeners) handler()
|
|
77
|
+
everConnected = true
|
|
71
78
|
}
|
|
72
79
|
|
|
73
80
|
socket.onmessage = event => {
|
|
@@ -91,6 +98,16 @@ function ensureConnection() {
|
|
|
91
98
|
}
|
|
92
99
|
}
|
|
93
100
|
|
|
101
|
+
// Subscribe to reconnects; returns the unsubscribe. Only fires while some
|
|
102
|
+
// component holds the events socket open via useWorkspaceEvent (the app shell
|
|
103
|
+
// always does).
|
|
104
|
+
export function onWorkspaceEventsReconnect(handler: () => void): () => void {
|
|
105
|
+
reconnectListeners.add(handler)
|
|
106
|
+
return () => {
|
|
107
|
+
reconnectListeners.delete(handler)
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
94
111
|
export function useWorkspaceEvent(handler: WorkspaceEventHandler) {
|
|
95
112
|
const handlerRef = useRef(handler)
|
|
96
113
|
handlerRef.current = handler
|
|
@@ -43,27 +43,50 @@ function themeColorProperty(token: ThemeColorToken): `--${string}` {
|
|
|
43
43
|
return `--${name}`
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
export function
|
|
46
|
+
export function getWorkspaceThemeFontStyle(theme: WorkspaceLayout['theme']): WorkspaceThemeStyle {
|
|
47
|
+
const style: WorkspaceThemeStyle = {}
|
|
48
|
+
const resolved = resolveWorkspaceTheme(theme)
|
|
49
|
+
const font = FONT_THEMES[resolved.font] ?? FONT_THEMES[DEFAULT_WORKSPACE_THEME.font]
|
|
50
|
+
for (const [token, property] of WORKSPACE_FONT_PROPERTIES) {
|
|
51
|
+
style[property] = font[token]
|
|
52
|
+
}
|
|
53
|
+
return style
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function getWorkspaceThemeColorStyle(
|
|
47
57
|
theme: WorkspaceLayout['theme'],
|
|
48
58
|
colorMode: ThemeColorMode = 'workspace'
|
|
49
59
|
): WorkspaceThemeStyle {
|
|
50
60
|
const style: WorkspaceThemeStyle = {}
|
|
51
61
|
const resolved = resolveWorkspaceTheme(theme)
|
|
52
|
-
const font = FONT_THEMES[resolved.font] ?? FONT_THEMES[DEFAULT_WORKSPACE_THEME.font]
|
|
53
62
|
const color = COLOR_THEMES[resolved.color] ?? COLOR_THEMES[DEFAULT_WORKSPACE_THEME.color]
|
|
54
63
|
const primary = color.primary ?? (colorMode === 'widget' ? DEFAULT_PRIMARY_COLOR : undefined)
|
|
55
64
|
const colors = primary ? deriveThemeColors(primary, colorMode) : undefined
|
|
56
|
-
const radius = RADIUS_THEMES[resolved.radius] ?? RADIUS_THEMES[DEFAULT_WORKSPACE_THEME.radius]
|
|
57
|
-
for (const [token, property] of WORKSPACE_FONT_PROPERTIES) {
|
|
58
|
-
style[property] = font[token]
|
|
59
|
-
}
|
|
60
65
|
for (const [token, property] of WORKSPACE_COLOR_PROPERTIES) {
|
|
61
66
|
style[property] = colors?.[token]
|
|
62
67
|
}
|
|
68
|
+
return style
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function getWorkspaceThemeRadiusStyle(theme: WorkspaceLayout['theme']): WorkspaceThemeStyle {
|
|
72
|
+
const style: WorkspaceThemeStyle = {}
|
|
73
|
+
const resolved = resolveWorkspaceTheme(theme)
|
|
74
|
+
const radius = RADIUS_THEMES[resolved.radius] ?? RADIUS_THEMES[DEFAULT_WORKSPACE_THEME.radius]
|
|
63
75
|
style[WORKSPACE_RADIUS_PROPERTY] = radius.radius
|
|
64
76
|
return style
|
|
65
77
|
}
|
|
66
78
|
|
|
79
|
+
export function getWorkspaceThemeStyle(
|
|
80
|
+
theme: WorkspaceLayout['theme'],
|
|
81
|
+
colorMode: ThemeColorMode = 'workspace'
|
|
82
|
+
): WorkspaceThemeStyle {
|
|
83
|
+
return {
|
|
84
|
+
...getWorkspaceThemeFontStyle(theme),
|
|
85
|
+
...getWorkspaceThemeColorStyle(theme, colorMode),
|
|
86
|
+
...getWorkspaceThemeRadiusStyle(theme)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
67
90
|
export function usePreloadWorkspaceFonts() {
|
|
68
91
|
useEffect(() => {
|
|
69
92
|
if (document.getElementById(FONT_PREVIEW_LINK_ID)) return
|
package/client/store/ui.ts
CHANGED
|
@@ -9,11 +9,13 @@ type UiStore = {
|
|
|
9
9
|
hasSentMessageFromMoi: boolean
|
|
10
10
|
workspaceIdsPendingAnalysis: string[]
|
|
11
11
|
composerDrafts: Record<string, string>
|
|
12
|
+
viewBuilderDrafts: Record<string, string>
|
|
12
13
|
dockedChatWidth: number
|
|
13
14
|
setDiscoveredWorkspacesOpen: (open: boolean) => void
|
|
14
15
|
markWorkspacePendingAnalysis: (workspaceId: string) => void
|
|
15
16
|
markMessageSentFromMoi: (workspaceId: string) => void
|
|
16
17
|
setComposerDraft: (workspaceId: string, value: string) => void
|
|
18
|
+
setViewBuilderDraft: (builderId: string, value: string | null) => void
|
|
17
19
|
setDockedChatWidth: (width: number) => void
|
|
18
20
|
}
|
|
19
21
|
|
|
@@ -25,6 +27,7 @@ export const createUiStore = (storage?: StateStorage) =>
|
|
|
25
27
|
hasSentMessageFromMoi: false,
|
|
26
28
|
workspaceIdsPendingAnalysis: [],
|
|
27
29
|
composerDrafts: {},
|
|
30
|
+
viewBuilderDrafts: {},
|
|
28
31
|
dockedChatWidth: 360,
|
|
29
32
|
setDiscoveredWorkspacesOpen: open => set({ discoveredWorkspacesOpen: open }),
|
|
30
33
|
markWorkspacePendingAnalysis: workspaceId =>
|
|
@@ -50,6 +53,22 @@ export const createUiStore = (storage?: StateStorage) =>
|
|
|
50
53
|
else delete composerDrafts[workspaceId]
|
|
51
54
|
return { composerDrafts }
|
|
52
55
|
}),
|
|
56
|
+
// Unlike composer drafts, an empty string stays stored: the composer
|
|
57
|
+
// falls back to the builder's server-saved requirements when no draft
|
|
58
|
+
// exists, and deleting all text must not resurrect them. Pass null to
|
|
59
|
+
// drop the draft (submit, discard).
|
|
60
|
+
setViewBuilderDraft: (builderId, value) =>
|
|
61
|
+
set(state => {
|
|
62
|
+
const current = state.viewBuilderDrafts ?? {}
|
|
63
|
+
if (value === null) {
|
|
64
|
+
if (!(builderId in current)) return state
|
|
65
|
+
const viewBuilderDrafts = { ...current }
|
|
66
|
+
delete viewBuilderDrafts[builderId]
|
|
67
|
+
return { viewBuilderDrafts }
|
|
68
|
+
}
|
|
69
|
+
if (current[builderId] === value) return state
|
|
70
|
+
return { viewBuilderDrafts: { ...current, [builderId]: value } }
|
|
71
|
+
}),
|
|
53
72
|
setDockedChatWidth: width => set({ dockedChatWidth: width })
|
|
54
73
|
}),
|
|
55
74
|
storage
|