moi-computer 0.5.2-next.0 → 0.6.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.
- package/client/AGENTS.md +9 -0
- package/client/api/app-ui-keys.ts +4 -0
- package/client/api/workspace-keys.ts +2 -2
- package/client/app/routes/WorkspaceRoute.tsx +8 -28
- package/client/app/shell/SidebarLayout.tsx +1 -1
- package/client/components/shared/Composer.tsx +15 -9
- package/client/components/shared/IconGhost.tsx +130 -0
- package/client/components/ui/dropdown-menu.tsx +2 -5
- package/client/components/ui/popover.tsx +11 -4
- package/client/components/ui/slider.tsx +70 -0
- package/client/components/ui/spinner.tsx +18 -0
- package/client/components/ui/toast.tsx +220 -0
- package/client/components/ui/tooltip.tsx +1 -1
- package/client/features/chat/ChatComposer.tsx +11 -14
- package/client/features/chat/ChatPanel.tsx +15 -14
- package/client/features/chat/ChatPopup.tsx +10 -4
- package/client/features/chat/ChatSelector.tsx +263 -48
- package/client/features/chat/ModelPicker.tsx +295 -121
- package/client/features/chat/TurnView.tsx +1 -1
- package/client/features/chat/api.ts +36 -9
- package/client/features/chat/chat-frames.ts +35 -6
- package/client/features/chat/chat-send.ts +40 -6
- package/client/features/chat/chat-store.ts +52 -40
- package/client/features/chat/model-order.ts +50 -28
- package/client/features/chat/useChat.ts +71 -60
- package/client/features/chat/useSelectedSession.ts +151 -0
- package/client/features/chat/useStickToBottom.ts +3 -3
- package/client/features/home/api.ts +0 -2
- package/client/features/scratchpad/ScratchpadControls.tsx +2 -2
- package/client/features/settings/IconPicker.tsx +2 -2
- package/client/features/settings/WorkspaceSettings.tsx +6 -6
- package/client/features/views/ViewBuilderTab.tsx +3 -4
- package/client/features/views/api.ts +1 -0
- package/client/features/views/useViewBuilderActions.ts +7 -3
- package/client/features/workspace/WorkspaceScreen.tsx +40 -19
- package/client/features/workspace/WorkspaceSkillUpdateBanner.tsx +2 -2
- package/client/features/workspace/WorkspaceTabs.tsx +10 -1
- package/client/index.css +5 -3
- package/client/main.tsx +2 -0
- package/client/runtime/useWorkspaceEvents.ts +1 -0
- package/client/store/ui.ts +13 -3
- package/dist/{chunk-m9qja0nx.js → chunk-0pcdwjkp.js} +1 -1
- package/dist/chunk-55sh4dty.js +2 -0
- package/dist/{chunk-h3evrtyp.js → chunk-9y2zbzqz.js} +1 -1
- package/dist/{chunk-7bzpmtxp.js → chunk-afgbg75t.js} +1 -1
- package/dist/chunk-agtetn7n.css +1 -0
- package/dist/chunk-bv6vrvqf.js +27 -0
- package/dist/chunk-dfs36zgc.js +1 -0
- package/dist/chunk-exj6hr30.js +9 -0
- package/dist/{chunk-v797g6ap.js → chunk-m11ckkxd.js} +1 -1
- package/dist/chunk-n6t40enm.js +1 -0
- package/dist/{chunk-jg6ezptn.js → chunk-rxvx4ta9.js} +3 -3
- package/dist/index.html +1 -1
- package/lib/attachment-note.ts +18 -0
- package/lib/chat-title.ts +6 -0
- package/lib/types.ts +33 -10
- package/package.json +1 -1
- package/server/api.ts +100 -10
- package/server/app-settings.ts +1 -1
- package/server/data-dir.ts +1 -1
- package/server/harness/README.md +6 -0
- package/server/harness/claude-code/adapter.ts +2 -2
- package/server/harness/claude-code/index.ts +7 -1
- package/server/harness/claude-code/models.ts +25 -2
- package/server/harness/claude-code/session-title.ts +106 -0
- package/server/harness/claude-code/session.ts +114 -17
- package/server/harness/claude-code/sessions.ts +35 -4
- package/server/harness/codex/adapter.ts +27 -2
- package/server/harness/codex/client.ts +56 -9
- package/server/harness/codex/index.ts +2 -0
- package/server/harness/codex/session-title.ts +149 -0
- package/server/harness/codex/session.ts +96 -14
- package/server/harness/openclaw/adapter.ts +4 -2
- package/server/harness/openclaw/discovery.ts +2 -0
- package/server/harness/openclaw/session.ts +15 -7
- package/server/harness/session-title.ts +96 -0
- package/server/harness/types.ts +5 -2
- package/server/selected-session.ts +132 -0
- package/server/session-config.ts +146 -0
- package/server/web.ts +15 -1
- package/workspace/.claude/skills/moi-workspace/DESIGN.md +54 -68
- package/workspace/.claude/skills/moi-workspace/SKILL.md +8 -2
- package/dist/chunk-5vaevt8z.js +0 -2
- package/dist/chunk-fhhv99bd.js +0 -1
- package/dist/chunk-h0hk61pm.js +0 -9
- package/dist/chunk-k5sjx9s5.js +0 -1
- package/dist/chunk-rs9nb0fr.js +0 -27
- package/dist/chunk-s7za1qsv.css +0 -1
- package/server/thread-config.ts +0 -124
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { useCallback, useMemo } from 'react'
|
|
2
|
+
|
|
3
|
+
import { useIsMutating, useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
|
4
|
+
import type { QueryClient } from '@tanstack/react-query'
|
|
5
|
+
|
|
6
|
+
import { appUiKeys } from '@/client/api/app-ui-keys'
|
|
7
|
+
import { jsonRequest, requestJson } from '@/client/api/http'
|
|
8
|
+
import { toast } from '@/client/components/ui/toast'
|
|
9
|
+
import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
|
|
10
|
+
import { useWorkspaceEvent } from '@/client/runtime/useWorkspaceEvents'
|
|
11
|
+
import type { SelectedSessionState } from '@/lib/types'
|
|
12
|
+
|
|
13
|
+
type SaveSelectedSessionInput = {
|
|
14
|
+
sessionId: string | null
|
|
15
|
+
previousSessionId: string | null
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type SetSelectedSession = (sessionId: string | null) => void
|
|
19
|
+
|
|
20
|
+
type SelectedSessionResult = readonly [
|
|
21
|
+
sessionId: string | null | undefined,
|
|
22
|
+
setSessionId: SetSelectedSession
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
export type SelectedSessionSaveResult = 'applied' | 'conflict' | 'ignored'
|
|
26
|
+
|
|
27
|
+
function selectedSessionMutationKey(workspaceId: string) {
|
|
28
|
+
return [...appUiKeys.selectedSession(workspaceId), 'save'] as const
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function optimisticallySetSelectedSession(
|
|
32
|
+
queryClient: QueryClient,
|
|
33
|
+
workspaceId: string,
|
|
34
|
+
sessionId: string | null
|
|
35
|
+
): SaveSelectedSessionInput | null {
|
|
36
|
+
const queryKey = appUiKeys.selectedSession(workspaceId)
|
|
37
|
+
const current = queryClient.getQueryData<SelectedSessionState>(queryKey)
|
|
38
|
+
const previousSessionId = current?.sessionId ?? null
|
|
39
|
+
if (current && previousSessionId === sessionId) return null
|
|
40
|
+
|
|
41
|
+
queryClient.setQueryData<SelectedSessionState>(queryKey, { sessionId })
|
|
42
|
+
return { sessionId, previousSessionId }
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function settleSelectedSessionSave(
|
|
46
|
+
queryClient: QueryClient,
|
|
47
|
+
workspaceId: string,
|
|
48
|
+
saved: SelectedSessionState,
|
|
49
|
+
input: SaveSelectedSessionInput
|
|
50
|
+
): SelectedSessionSaveResult {
|
|
51
|
+
const queryKey = appUiKeys.selectedSession(workspaceId)
|
|
52
|
+
const current = queryClient.getQueryData<SelectedSessionState>(queryKey)
|
|
53
|
+
|
|
54
|
+
if (saved.sessionId !== input.sessionId && current?.sessionId !== saved.sessionId) {
|
|
55
|
+
return 'conflict'
|
|
56
|
+
}
|
|
57
|
+
if (current?.sessionId !== input.sessionId && current?.sessionId !== input.previousSessionId) {
|
|
58
|
+
return 'ignored'
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
queryClient.setQueryData<SelectedSessionState>(queryKey, saved)
|
|
62
|
+
return 'applied'
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function applySelectedSessionEvent(
|
|
66
|
+
queryClient: QueryClient,
|
|
67
|
+
workspaceId: string,
|
|
68
|
+
sessionId: string | null,
|
|
69
|
+
hasPendingSave: boolean
|
|
70
|
+
): void {
|
|
71
|
+
if (hasPendingSave) return
|
|
72
|
+
queryClient.setQueryData<SelectedSessionState>(appUiKeys.selectedSession(workspaceId), {
|
|
73
|
+
sessionId
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function renameSelectedSessionInCache(
|
|
78
|
+
queryClient: QueryClient,
|
|
79
|
+
workspaceId: string,
|
|
80
|
+
from: string,
|
|
81
|
+
to: string
|
|
82
|
+
): void {
|
|
83
|
+
queryClient.setQueryData<SelectedSessionState>(appUiKeys.selectedSession(workspaceId), current =>
|
|
84
|
+
current?.sessionId === from ? { sessionId: to } : current
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function useSelectedSession(): SelectedSessionResult {
|
|
89
|
+
const workspaceId = useWorkspaceId()
|
|
90
|
+
const queryClient = useQueryClient()
|
|
91
|
+
const queryKey = useMemo(() => appUiKeys.selectedSession(workspaceId), [workspaceId])
|
|
92
|
+
const mutationKey = useMemo(() => selectedSessionMutationKey(workspaceId), [workspaceId])
|
|
93
|
+
const pendingSaves = useIsMutating({ mutationKey, exact: true })
|
|
94
|
+
|
|
95
|
+
// WorkspaceLoader remains an observer for the active workspace. Nested hook
|
|
96
|
+
// users reuse its result without refetching; once the route unmounts, dropping
|
|
97
|
+
// the cache makes the next visit load the server-owned selection again.
|
|
98
|
+
const query = useQuery<SelectedSessionState>({
|
|
99
|
+
queryKey,
|
|
100
|
+
queryFn: () => requestJson(`/api/workspaces/${workspaceId}/selected-session`),
|
|
101
|
+
staleTime: Infinity,
|
|
102
|
+
gcTime: 0,
|
|
103
|
+
refetchOnMount: false,
|
|
104
|
+
refetchOnWindowFocus: false
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
const { mutate: saveSelectedSession } = useMutation<
|
|
108
|
+
SelectedSessionState,
|
|
109
|
+
Error,
|
|
110
|
+
SaveSelectedSessionInput
|
|
111
|
+
>({
|
|
112
|
+
mutationKey,
|
|
113
|
+
scope: { id: `selected-session:${workspaceId}` },
|
|
114
|
+
mutationFn: input =>
|
|
115
|
+
requestJson(
|
|
116
|
+
`/api/workspaces/${workspaceId}/selected-session`,
|
|
117
|
+
jsonRequest('PUT', input),
|
|
118
|
+
'Couldn’t save selected chat'
|
|
119
|
+
),
|
|
120
|
+
onSuccess: (saved, input) => {
|
|
121
|
+
const result = settleSelectedSessionSave(queryClient, workspaceId, saved, input)
|
|
122
|
+
if (result !== 'conflict') return
|
|
123
|
+
|
|
124
|
+
toast.add({ title: 'Couldn’t save selected chat', type: 'error' })
|
|
125
|
+
queryClient.invalidateQueries({ queryKey })
|
|
126
|
+
},
|
|
127
|
+
onError: (_error, input) => {
|
|
128
|
+
const current = queryClient.getQueryData<SelectedSessionState>(queryKey)
|
|
129
|
+
if (current?.sessionId !== input.sessionId) return
|
|
130
|
+
|
|
131
|
+
toast.add({ title: 'Couldn’t save selected chat', type: 'error' })
|
|
132
|
+
queryClient.invalidateQueries({ queryKey })
|
|
133
|
+
}
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
const setSelectedSessionId = useCallback<SetSelectedSession>(
|
|
137
|
+
sessionId => {
|
|
138
|
+
const input = optimisticallySetSelectedSession(queryClient, workspaceId, sessionId)
|
|
139
|
+
if (input) saveSelectedSession(input)
|
|
140
|
+
},
|
|
141
|
+
[queryClient, saveSelectedSession, workspaceId]
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
useWorkspaceEvent(event => {
|
|
145
|
+
if (event.type !== 'selected-session:updated' || event.workspaceId !== workspaceId) return
|
|
146
|
+
applySelectedSessionEvent(queryClient, workspaceId, event.sessionId, pendingSaves > 0)
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
const selectedSessionId = query.isLoading ? undefined : (query.data?.sessionId ?? null)
|
|
150
|
+
return [selectedSessionId, setSelectedSessionId]
|
|
151
|
+
}
|
|
@@ -7,7 +7,7 @@ import { type RefObject, useCallback, useEffect, useLayoutEffect, useRef, useSta
|
|
|
7
7
|
// they read history.
|
|
8
8
|
// • Re-pin automatically when they scroll back to (near) the bottom.
|
|
9
9
|
// • `scrollToBottom()` for the "jump to latest" button and for send.
|
|
10
|
-
// • On mount and whenever `resetKey` changes (
|
|
10
|
+
// • On mount and whenever `resetKey` changes (session switch), jump to bottom.
|
|
11
11
|
//
|
|
12
12
|
// Content growth is followed via a ResizeObserver on the scroll content, so we
|
|
13
13
|
// don't depend on React deps to know when to scroll — it just works for any
|
|
@@ -85,8 +85,8 @@ export function useStickToBottom(
|
|
|
85
85
|
return () => ro.disconnect()
|
|
86
86
|
}, [scrollRef])
|
|
87
87
|
|
|
88
|
-
// Jump to bottom on mount and on
|
|
89
|
-
// If the new
|
|
88
|
+
// Jump to bottom on mount and on session switch (before paint, so no flash).
|
|
89
|
+
// If the new session's content is still loading, the ResizeObserver above lands
|
|
90
90
|
// us at the bottom once it arrives (pin is set here).
|
|
91
91
|
useLayoutEffect(() => {
|
|
92
92
|
scrollToBottom('auto')
|
|
@@ -2,7 +2,6 @@ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
|
|
2
2
|
|
|
3
3
|
import { jsonRequest, requestJson, requestVoid } from '@/client/api/http'
|
|
4
4
|
import { workspaceKeys } from '@/client/api/workspace-keys'
|
|
5
|
-
import { liveStore } from '@/client/features/chat/chat-store'
|
|
6
5
|
import { useUiStore } from '@/client/store/ui'
|
|
7
6
|
import type {
|
|
8
7
|
DiscoveredWorkspace,
|
|
@@ -52,7 +51,6 @@ export function useImportWorkspace() {
|
|
|
52
51
|
mutationFn: input =>
|
|
53
52
|
requestJson('/api/workspaces', jsonRequest('POST', input), 'Failed to add workspace'),
|
|
54
53
|
onSuccess: (entry, input) => {
|
|
55
|
-
liveStore.getState().setActive(entry.id, null)
|
|
56
54
|
useUiStore.getState().markWorkspacePendingAnalysis(entry.id)
|
|
57
55
|
queryClient.setQueryData<WorkspaceEntry[]>(workspaceKeys.all, previous =>
|
|
58
56
|
upsertWorkspaceEntry(previous, entry)
|
|
@@ -148,7 +148,7 @@ export function ScratchToolbar({ editor }: ScratchToolbarProps) {
|
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
return (
|
|
151
|
-
<div className="absolute top-1/2 left-2
|
|
151
|
+
<div className="absolute top-1/2 left-2 -translate-y-1/2">
|
|
152
152
|
<motion.div
|
|
153
153
|
initial={{ x: -72, opacity: 0 }}
|
|
154
154
|
animate={{ x: 0, opacity: 1 }}
|
|
@@ -491,7 +491,7 @@ export function ScratchStyleBar({ editor }: ScratchStyleBarProps) {
|
|
|
491
491
|
}
|
|
492
492
|
|
|
493
493
|
return (
|
|
494
|
-
<div className="absolute top-1/2 left-14
|
|
494
|
+
<div className="absolute top-1/2 left-14 flex -translate-y-1/2 flex-col items-center gap-1.5 rounded-full bg-background/95 px-1 py-1 shadow-[0_2px_8px_rgba(0,0,0,0.08),0_4px_16px_rgba(0,0,0,0.06),0_0_0_1px_rgba(0,0,0,0.04)] backdrop-blur">
|
|
495
495
|
{state.controls.map((control, i) => (
|
|
496
496
|
<Fragment key={control}>
|
|
497
497
|
{i > 0 && <div className="h-px w-5 bg-border" />}
|
|
@@ -182,11 +182,11 @@ export function IconPicker({ icon }: IconPickerProps) {
|
|
|
182
182
|
<div className="flex w-24 shrink-0 flex-col items-center gap-2.5">
|
|
183
183
|
<div
|
|
184
184
|
className={cn(
|
|
185
|
-
'flex size-24 items-center justify-center overflow-hidden rounded-xl
|
|
185
|
+
'flex size-24 items-center justify-center overflow-hidden rounded-xl',
|
|
186
186
|
// Checkerboard hints at transparency when no background is chosen.
|
|
187
187
|
previewKind !== 'image' &&
|
|
188
188
|
!onGradient &&
|
|
189
|
-
'bg-[repeating-conic-gradient(#0000000d_0%_25%,transparent_0%_50%)] bg-[
|
|
189
|
+
'bg-[repeating-conic-gradient(#0000000d_0%_25%,transparent_0%_50%)] bg-size-[16px_16px]'
|
|
190
190
|
)}
|
|
191
191
|
// Gradient colors are generated at runtime (shuffle), so they can't be
|
|
192
192
|
// static Tailwind classes — set the composed background inline.
|
|
@@ -67,23 +67,23 @@ export function WorkspaceSettings() {
|
|
|
67
67
|
|
|
68
68
|
{/* Page */}
|
|
69
69
|
<div className="relative scrollbar-thin min-w-0 flex-1 overflow-y-auto">
|
|
70
|
+
<div className="px-8 py-7">
|
|
71
|
+
{page === 'general' && <GeneralSettings />}
|
|
72
|
+
{page === 'connectors' && <ConnectorsSettings />}
|
|
73
|
+
{page === 'environment' && <EnvironmentSettings />}
|
|
74
|
+
</div>
|
|
70
75
|
<DialogClose
|
|
71
76
|
render={
|
|
72
77
|
<Button
|
|
73
78
|
variant="ghost"
|
|
74
79
|
size="icon"
|
|
75
80
|
aria-label="Close"
|
|
76
|
-
className="absolute top-3 right-3
|
|
81
|
+
className="absolute top-3 right-3"
|
|
77
82
|
>
|
|
78
83
|
<IconX stroke={1.5} />
|
|
79
84
|
</Button>
|
|
80
85
|
}
|
|
81
86
|
/>
|
|
82
|
-
<div className="px-8 py-7">
|
|
83
|
-
{page === 'general' && <GeneralSettings />}
|
|
84
|
-
{page === 'connectors' && <ConnectorsSettings />}
|
|
85
|
-
{page === 'environment' && <EnvironmentSettings />}
|
|
86
|
-
</div>
|
|
87
87
|
</div>
|
|
88
88
|
</DialogContent>
|
|
89
89
|
</Dialog>
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { type FormEvent, type KeyboardEvent, useEffect, useRef, useState } from 'react'
|
|
2
2
|
|
|
3
|
-
import { IconLoader2 } from '@tabler/icons-react'
|
|
4
|
-
|
|
5
3
|
import { Button } from '@/client/components/ui/button'
|
|
6
4
|
import {
|
|
7
5
|
canSubmitComposerAction,
|
|
@@ -12,6 +10,7 @@ import {
|
|
|
12
10
|
} from '@/client/components/shared/Composer'
|
|
13
11
|
import { ModelPicker } from '@/client/features/chat/ModelPicker'
|
|
14
12
|
import type { ViewBuilder } from '@/lib/types'
|
|
13
|
+
import { Spinner } from '@/client/components/ui/spinner'
|
|
15
14
|
|
|
16
15
|
type ViewBuilderTabProps = {
|
|
17
16
|
builder: ViewBuilder
|
|
@@ -144,8 +143,8 @@ export function ViewBuilderTab({
|
|
|
144
143
|
return (
|
|
145
144
|
<div className="flex min-h-0 flex-1 items-center justify-center p-6">
|
|
146
145
|
<div className="flex items-center gap-2 text-sm text-muted-foreground">
|
|
147
|
-
<
|
|
148
|
-
{builder.status === 'ready' ? 'Opening view…' : 'Building
|
|
146
|
+
<Spinner />
|
|
147
|
+
{builder.status === 'ready' ? 'Opening view…' : 'Building view…'}
|
|
149
148
|
</div>
|
|
150
149
|
</div>
|
|
151
150
|
)
|
|
@@ -3,6 +3,7 @@ import { useQueryClient } from '@tanstack/react-query'
|
|
|
3
3
|
import { useWorkspaceModels } from '@/client/features/chat/api'
|
|
4
4
|
import { resolveChatRunOptions, startOptimisticTurn } from '@/client/features/chat/chat-send'
|
|
5
5
|
import { liveStore } from '@/client/features/chat/chat-store'
|
|
6
|
+
import { useSelectedSession } from '@/client/features/chat/useSelectedSession'
|
|
6
7
|
import { useWorkspaceLayoutCtx } from '@/client/features/workspace/WorkspaceLayoutContext'
|
|
7
8
|
import {
|
|
8
9
|
useCreateViewBuilder,
|
|
@@ -15,6 +16,7 @@ import type { ViewBuilder } from '@/lib/types'
|
|
|
15
16
|
export function useViewBuilderActions() {
|
|
16
17
|
const queryClient = useQueryClient()
|
|
17
18
|
const { workspaceId, layout } = useWorkspaceLayoutCtx()
|
|
19
|
+
const [, selectSession] = useSelectedSession()
|
|
18
20
|
const modelData = useWorkspaceModels(workspaceId).data
|
|
19
21
|
const createMutation = useCreateViewBuilder(workspaceId)
|
|
20
22
|
const saveMutation = useSaveViewBuilder(workspaceId)
|
|
@@ -36,12 +38,13 @@ export function useViewBuilderActions() {
|
|
|
36
38
|
sessionId: builder.sessionId,
|
|
37
39
|
parts: [{ type: 'text', text }]
|
|
38
40
|
})
|
|
39
|
-
|
|
41
|
+
selectSession(builder.sessionId)
|
|
40
42
|
|
|
41
|
-
const { model, effort, stream } = resolveChatRunOptions(
|
|
43
|
+
const { model, effort, fastMode, stream } = resolveChatRunOptions(
|
|
42
44
|
modelData,
|
|
43
45
|
layout.selectedModel,
|
|
44
|
-
layout.selectedEffort
|
|
46
|
+
layout.selectedEffort,
|
|
47
|
+
layout.selectedFastMode
|
|
45
48
|
)
|
|
46
49
|
|
|
47
50
|
try {
|
|
@@ -51,6 +54,7 @@ export function useViewBuilderActions() {
|
|
|
51
54
|
optimisticId,
|
|
52
55
|
model,
|
|
53
56
|
effort,
|
|
57
|
+
fastMode,
|
|
54
58
|
stream
|
|
55
59
|
})
|
|
56
60
|
} catch (error) {
|
|
@@ -5,12 +5,13 @@ import { AnimatePresence, motion } from 'motion/react'
|
|
|
5
5
|
import {
|
|
6
6
|
IconArticle,
|
|
7
7
|
IconBrowserPlus,
|
|
8
|
-
IconGhost,
|
|
9
8
|
IconLayout2,
|
|
10
9
|
IconLayoutSidebarRight,
|
|
11
10
|
IconLetterCase,
|
|
12
11
|
IconSketching
|
|
13
12
|
} from '@tabler/icons-react'
|
|
13
|
+
|
|
14
|
+
import { IconGhost } from '@/client/components/shared/IconGhost'
|
|
14
15
|
import { ChatPanel } from '@/client/features/chat/ChatPanel'
|
|
15
16
|
import { ChatPopup } from '@/client/features/chat/ChatPopup'
|
|
16
17
|
import { CustomizePanel } from '@/client/features/workspace/CustomizePanel'
|
|
@@ -33,6 +34,11 @@ import { useWorkspaceAvailability } from '@/client/features/workspace/api'
|
|
|
33
34
|
import { WorkspaceSkillUpdateBanner } from '@/client/features/workspace/WorkspaceSkillUpdateBanner'
|
|
34
35
|
import { useWorkspaceSkillUpdates } from '@/client/features/workspace/useWorkspaceSkillUpdates'
|
|
35
36
|
import { useWorkspaceTheme } from '@/client/runtime/workspace-theme'
|
|
37
|
+
import {
|
|
38
|
+
hasRunningWorkspaceActivity,
|
|
39
|
+
isSessionRunning,
|
|
40
|
+
useLive
|
|
41
|
+
} from '@/client/features/chat/chat-store'
|
|
36
42
|
import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
|
|
37
43
|
import { useWorkspaceLayoutCtx } from '@/client/features/workspace/WorkspaceLayoutContext'
|
|
38
44
|
import {
|
|
@@ -43,8 +49,8 @@ import {
|
|
|
43
49
|
import { useWorkspaceNavigation } from '@/client/features/workspace/useWorkspaceNavigation'
|
|
44
50
|
import { resolveAppIcon } from '@/client/lib/app-icon-registry'
|
|
45
51
|
import { cn } from '@/client/lib/cn'
|
|
46
|
-
import { liveStore } from '@/client/features/chat/chat-store'
|
|
47
52
|
import { useWorkspaceEvent } from '@/client/runtime/useWorkspaceEvents'
|
|
53
|
+
import { useUiStore } from '@/client/store/ui'
|
|
48
54
|
import {
|
|
49
55
|
type CreateWorkspaceTabItem,
|
|
50
56
|
type WorkspaceTabItem,
|
|
@@ -193,14 +199,17 @@ function tabItemFor(
|
|
|
193
199
|
tab: WorkspaceTabId,
|
|
194
200
|
views: ViewInfo[],
|
|
195
201
|
builders: ViewBuilder[],
|
|
196
|
-
closable: boolean
|
|
202
|
+
closable: boolean,
|
|
203
|
+
agentRunning: boolean,
|
|
204
|
+
builderRunning: (sessionId: string) => boolean
|
|
197
205
|
): WorkspaceTabItem | null {
|
|
198
206
|
if (tab === 'agent') {
|
|
199
207
|
return {
|
|
200
208
|
key: tab,
|
|
201
209
|
Icon: IconGhost,
|
|
202
210
|
label: 'Agent',
|
|
203
|
-
closable
|
|
211
|
+
closable,
|
|
212
|
+
loading: agentRunning
|
|
204
213
|
}
|
|
205
214
|
}
|
|
206
215
|
if (tab === 'widgets') {
|
|
@@ -226,7 +235,8 @@ function tabItemFor(
|
|
|
226
235
|
key: tab,
|
|
227
236
|
Icon: viewBuilderIcon(builder),
|
|
228
237
|
label: builder.title || builder.viewId || 'New view',
|
|
229
|
-
closable
|
|
238
|
+
closable,
|
|
239
|
+
loading: builderRunning(builder.sessionId)
|
|
230
240
|
}
|
|
231
241
|
}
|
|
232
242
|
const viewId = viewIdFromTab(tab)
|
|
@@ -264,6 +274,8 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
264
274
|
const [widgetMode, setWidgetMode] = useState<WidgetMode>('idle')
|
|
265
275
|
const [floatingChatOpen, setFloatingChatOpen] = useState(false)
|
|
266
276
|
const [chatFocusRequest, setChatFocusRequest] = useState(0)
|
|
277
|
+
const sessionActivity = useLive(state => state.activity)
|
|
278
|
+
const hasRunningSession = hasRunningWorkspaceActivity(sessionActivity, workspaceId)
|
|
267
279
|
|
|
268
280
|
useWorkspaceTheme(layout.theme)
|
|
269
281
|
|
|
@@ -300,7 +312,7 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
300
312
|
error,
|
|
301
313
|
send,
|
|
302
314
|
stop,
|
|
303
|
-
|
|
315
|
+
selectSession,
|
|
304
316
|
dismissError
|
|
305
317
|
} = useChat({ activeTab, appletParams })
|
|
306
318
|
|
|
@@ -317,7 +329,14 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
317
329
|
const canCloseTabs = openTabIds.length > 1
|
|
318
330
|
const tabItems = visibleTabIds
|
|
319
331
|
.map(tab =>
|
|
320
|
-
tabItemFor(
|
|
332
|
+
tabItemFor(
|
|
333
|
+
tab,
|
|
334
|
+
views,
|
|
335
|
+
builders,
|
|
336
|
+
canCloseTabs || viewBuilderIdFromTab(tab) !== null,
|
|
337
|
+
hasRunningSession,
|
|
338
|
+
sessionId => isSessionRunning(sessionActivity, workspaceId, sessionId)
|
|
339
|
+
)
|
|
321
340
|
)
|
|
322
341
|
.filter((tab): tab is WorkspaceTabItem => Boolean(tab))
|
|
323
342
|
const activeViewId = viewIdFromTab(activeTab)
|
|
@@ -374,11 +393,6 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
374
393
|
setLayout({ tabs: { open: open.length > 0 ? open : ['agent'], active } })
|
|
375
394
|
}, [activeTab, builders, navigateToTab, setLayout, tabsState, views])
|
|
376
395
|
|
|
377
|
-
useEffect(() => {
|
|
378
|
-
const linked = activeBuilder ?? builders.find(builder => builder.viewId === activeViewId)
|
|
379
|
-
if (linked) liveStore.getState().setActive(workspaceId, linked.sessionId)
|
|
380
|
-
}, [activeBuilder, activeViewId, builders, workspaceId])
|
|
381
|
-
|
|
382
396
|
useEffect(() => {
|
|
383
397
|
if (mode !== 'fullscreen' || activeTab === 'agent') {
|
|
384
398
|
setFloatingChatOpen(false)
|
|
@@ -450,7 +464,7 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
450
464
|
|
|
451
465
|
const openChat = (intent?: string) => {
|
|
452
466
|
if (intent !== undefined) {
|
|
453
|
-
|
|
467
|
+
useUiStore.getState().setComposerDraft(workspaceId, intent)
|
|
454
468
|
}
|
|
455
469
|
if (mode === 'fullscreen' && activeTab !== 'agent') {
|
|
456
470
|
setFloatingChatOpen(true)
|
|
@@ -526,7 +540,10 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
526
540
|
Icon: IconBrowserPlus,
|
|
527
541
|
label: 'New view',
|
|
528
542
|
onClick: () => {
|
|
529
|
-
void builderActions.create().then(builder =>
|
|
543
|
+
void builderActions.create().then(builder => {
|
|
544
|
+
selectSession(builder.sessionId)
|
|
545
|
+
openTab(viewBuilderTabId(builder.id))
|
|
546
|
+
})
|
|
530
547
|
}
|
|
531
548
|
}
|
|
532
549
|
]
|
|
@@ -549,7 +566,7 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
549
566
|
unavailableReason={unavailableReason}
|
|
550
567
|
send={send}
|
|
551
568
|
stop={stop}
|
|
552
|
-
|
|
569
|
+
onSelectSession={selectSession}
|
|
553
570
|
/>
|
|
554
571
|
)
|
|
555
572
|
|
|
@@ -570,7 +587,7 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
570
587
|
unavailableReason={unavailableReason}
|
|
571
588
|
send={send}
|
|
572
589
|
stop={stop}
|
|
573
|
-
|
|
590
|
+
onSelectSession={selectSession}
|
|
574
591
|
/>
|
|
575
592
|
)
|
|
576
593
|
|
|
@@ -627,7 +644,10 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
627
644
|
editing={widgetMode === 'editing'}
|
|
628
645
|
onEditingChange={editing => setWidgetMode(editing ? 'editing' : 'idle')}
|
|
629
646
|
widgets={widgets}
|
|
630
|
-
onCreateWidget={() =>
|
|
647
|
+
onCreateWidget={() => {
|
|
648
|
+
selectSession(null)
|
|
649
|
+
openChat('Create widget')
|
|
650
|
+
}}
|
|
631
651
|
/>
|
|
632
652
|
) : activeTab === 'scratchpad' ? (
|
|
633
653
|
<Suspense fallback={null}>
|
|
@@ -644,7 +664,7 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
644
664
|
return builderActions.submit(activeBuilder, requirements)
|
|
645
665
|
}}
|
|
646
666
|
onOpenChat={() => {
|
|
647
|
-
|
|
667
|
+
selectSession(activeBuilder.sessionId)
|
|
648
668
|
openChat()
|
|
649
669
|
}}
|
|
650
670
|
onDiscard={() => discardBuilder(activeBuilder)}
|
|
@@ -674,6 +694,7 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
674
694
|
|
|
675
695
|
{mode === 'fullscreen' && activeTab !== 'agent' && hasWorkspaceContent && (
|
|
676
696
|
<ChatPopup
|
|
697
|
+
loading={hasRunningSession}
|
|
677
698
|
open={floatingChatOpen}
|
|
678
699
|
onOpenChange={setFloatingChatOpen}
|
|
679
700
|
onOpenChangeComplete={open => {
|
|
@@ -701,7 +722,7 @@ export function WorkspaceScreen({ widgets, views, builders }: WorkspaceScreenPro
|
|
|
701
722
|
unavailableReason={unavailableReason}
|
|
702
723
|
send={send}
|
|
703
724
|
stop={stop}
|
|
704
|
-
|
|
725
|
+
onSelectSession={selectSession}
|
|
705
726
|
onClose={onClose}
|
|
706
727
|
/>
|
|
707
728
|
)}
|
|
@@ -22,7 +22,7 @@ export function WorkspaceSkillUpdateBanner({
|
|
|
22
22
|
return (
|
|
23
23
|
<div
|
|
24
24
|
role="status"
|
|
25
|
-
className="flex w-full items-center gap-1.5 p-2 text-sm text-muted-foreground"
|
|
25
|
+
className="flex w-full items-center gap-1.5 p-2 pl-3 text-sm text-muted-foreground"
|
|
26
26
|
>
|
|
27
27
|
<IconLoader2 size={20} stroke={1.5} className="shrink-0 animate-spin" />
|
|
28
28
|
<span className="wrap-break-word">Updating moi skills…</span>
|
|
@@ -37,7 +37,7 @@ export function WorkspaceSkillUpdateBanner({
|
|
|
37
37
|
role={error ? 'alert' : 'status'}
|
|
38
38
|
className={cn(
|
|
39
39
|
'grid w-full grid-cols-[minmax(0,1fr)_auto] gap-x-2 gap-y-2 p-2 text-sm',
|
|
40
|
-
'@xl:flex @xl:items-center @xl:
|
|
40
|
+
'@xl:flex @xl:items-center @xl:p-1 @xl:pl-3',
|
|
41
41
|
error && 'text-destructive'
|
|
42
42
|
)}
|
|
43
43
|
>
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { IconPlus, IconX, type TablerIcon } from '@tabler/icons-react'
|
|
2
2
|
import { cva } from 'class-variance-authority'
|
|
3
3
|
|
|
4
|
+
import { IconGhost } from '@/client/components/shared/IconGhost'
|
|
4
5
|
import { ReorderableList } from '@/client/components/shared/ReorderableList'
|
|
5
6
|
import type { ReorderableRenderState } from '@/client/components/shared/ReorderableList'
|
|
6
7
|
import { Button, buttonVariants } from '@/client/components/ui/button'
|
|
8
|
+
import { Spinner } from '@/client/components/ui/spinner'
|
|
7
9
|
import {
|
|
8
10
|
DropdownMenu,
|
|
9
11
|
DropdownMenuContent,
|
|
@@ -19,6 +21,7 @@ export type WorkspaceTabItem = {
|
|
|
19
21
|
Icon: TablerIcon
|
|
20
22
|
label: string
|
|
21
23
|
closable?: boolean
|
|
24
|
+
loading?: boolean
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
export type CreateWorkspaceTabItem = {
|
|
@@ -131,7 +134,13 @@ function WorkspaceTab(props: WorkspaceTabProps) {
|
|
|
131
134
|
tab.closable && 'group-hover/tab:mr-3'
|
|
132
135
|
)}
|
|
133
136
|
>
|
|
134
|
-
|
|
137
|
+
{tab.Icon === IconGhost ? (
|
|
138
|
+
<IconGhost data-icon="inline-start" stroke={2} animated={tab.loading} />
|
|
139
|
+
) : tab.loading ? (
|
|
140
|
+
<Spinner data-icon="inline-start" />
|
|
141
|
+
) : (
|
|
142
|
+
<tab.Icon data-icon="inline-start" stroke={2} />
|
|
143
|
+
)}
|
|
135
144
|
<span
|
|
136
145
|
className={cn(
|
|
137
146
|
'truncate',
|
package/client/index.css
CHANGED
|
@@ -31,8 +31,10 @@
|
|
|
31
31
|
--input: oklch(0.922 0 0);
|
|
32
32
|
--ring: oklch(0.708 0 0);
|
|
33
33
|
--radius: 0.625rem;
|
|
34
|
-
--sans: ui-sans-serif, system-ui, sans-serif;
|
|
35
|
-
--
|
|
34
|
+
--default-sans: ui-sans-serif, system-ui, sans-serif;
|
|
35
|
+
--sans: var(--default-sans);
|
|
36
|
+
--default-mono: ui-monospace, monospace;
|
|
37
|
+
--mono: var(--default-mono);
|
|
36
38
|
|
|
37
39
|
/* Workspace page layout — single source of truth for the widget/chat panel.
|
|
38
40
|
Read by routes/workspace/[id].tsx; don't hardcode equivalents. (The app
|
|
@@ -105,7 +107,7 @@
|
|
|
105
107
|
}
|
|
106
108
|
|
|
107
109
|
body {
|
|
108
|
-
@apply bg-background text-foreground;
|
|
110
|
+
@apply bg-background font-sans text-foreground;
|
|
109
111
|
}
|
|
110
112
|
}
|
|
111
113
|
|
package/client/main.tsx
CHANGED
|
@@ -3,6 +3,7 @@ import { Agentation } from 'agentation'
|
|
|
3
3
|
import { createRoot } from 'react-dom/client'
|
|
4
4
|
import { Router, useRoute } from 'wouter'
|
|
5
5
|
|
|
6
|
+
import { Toaster } from '@/client/components/ui/toast'
|
|
6
7
|
import { TooltipProvider } from '@/client/components/ui/tooltip'
|
|
7
8
|
import { installAppletErrorHook } from '@/client/features/applets/applet-log'
|
|
8
9
|
import { initConnection } from '@/client/features/chat/chat-connection'
|
|
@@ -35,6 +36,7 @@ export function mount(el: HTMLElement) {
|
|
|
35
36
|
<Router>
|
|
36
37
|
<AppRouter />
|
|
37
38
|
</Router>
|
|
39
|
+
<Toaster />
|
|
38
40
|
{process.env.NODE_ENV === 'development' && <DevAgentation />}
|
|
39
41
|
</TooltipProvider>
|
|
40
42
|
</QueryClientProvider>
|
|
@@ -13,6 +13,7 @@ export type WorkspaceEvent =
|
|
|
13
13
|
| { type: 'view-layout:updated'; views: ViewInfo[] }
|
|
14
14
|
| { type: 'view-builder:updated'; workspaceId: string; builder: ViewBuilder }
|
|
15
15
|
| { type: 'view-builder:deleted'; workspaceId: string; builderId: string }
|
|
16
|
+
| { type: 'selected-session:updated'; workspaceId: string; sessionId: string | null }
|
|
16
17
|
| { type: 'theme:updated' }
|
|
17
18
|
| { type: 'workspace:updated' }
|
|
18
19
|
// The registry list changed (reorder, create) without touching any open
|
package/client/store/ui.ts
CHANGED
|
@@ -2,15 +2,17 @@ import { create } from 'zustand'
|
|
|
2
2
|
import { createJSONStorage, persist } from 'zustand/middleware'
|
|
3
3
|
import type { StateStorage } from 'zustand/middleware'
|
|
4
4
|
|
|
5
|
-
//
|
|
6
|
-
// so they survive reloads. Server-
|
|
5
|
+
// Per-browser UI preferences and onboarding markers, persisted to localStorage
|
|
6
|
+
// so they survive reloads. Server-backed per-user app state belongs in DATA_DIR.
|
|
7
7
|
type UiStore = {
|
|
8
8
|
discoveredWorkspacesOpen: boolean
|
|
9
9
|
hasSentMessageFromMoi: boolean
|
|
10
10
|
workspaceIdsPendingAnalysis: string[]
|
|
11
|
+
composerDrafts: Record<string, string>
|
|
11
12
|
setDiscoveredWorkspacesOpen: (open: boolean) => void
|
|
12
13
|
markWorkspacePendingAnalysis: (workspaceId: string) => void
|
|
13
14
|
markMessageSentFromMoi: (workspaceId: string) => void
|
|
15
|
+
setComposerDraft: (workspaceId: string, value: string) => void
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
export const createUiStore = (storage?: StateStorage) =>
|
|
@@ -20,6 +22,7 @@ export const createUiStore = (storage?: StateStorage) =>
|
|
|
20
22
|
discoveredWorkspacesOpen: true,
|
|
21
23
|
hasSentMessageFromMoi: false,
|
|
22
24
|
workspaceIdsPendingAnalysis: [],
|
|
25
|
+
composerDrafts: {},
|
|
23
26
|
setDiscoveredWorkspacesOpen: open => set({ discoveredWorkspacesOpen: open }),
|
|
24
27
|
markWorkspacePendingAnalysis: workspaceId =>
|
|
25
28
|
set(state => {
|
|
@@ -36,7 +39,14 @@ export const createUiStore = (storage?: StateStorage) =>
|
|
|
36
39
|
workspaceIdsPendingAnalysis: (state.workspaceIdsPendingAnalysis ?? []).filter(
|
|
37
40
|
id => id !== workspaceId
|
|
38
41
|
)
|
|
39
|
-
}))
|
|
42
|
+
})),
|
|
43
|
+
setComposerDraft: (workspaceId, value) =>
|
|
44
|
+
set(state => {
|
|
45
|
+
const composerDrafts = { ...(state.composerDrafts ?? {}) }
|
|
46
|
+
if (value) composerDrafts[workspaceId] = value
|
|
47
|
+
else delete composerDrafts[workspaceId]
|
|
48
|
+
return { composerDrafts }
|
|
49
|
+
})
|
|
40
50
|
}),
|
|
41
51
|
storage
|
|
42
52
|
? {
|