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
|
@@ -1,88 +1,303 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useRef, useState } from 'react'
|
|
2
|
+
import { IconArchive, IconChevronDown, IconEdit } from '@tabler/icons-react'
|
|
2
3
|
|
|
3
|
-
import { useWorkspaceSessions } from './api'
|
|
4
|
+
import { useArchiveWorkspaceSession, useWorkspaceModels, useWorkspaceSessions } from './api'
|
|
4
5
|
import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
|
|
5
6
|
import { cn } from '@/client/lib/cn'
|
|
6
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
hasRunningBackgroundSession,
|
|
9
|
+
isSessionRunning,
|
|
10
|
+
liveStore,
|
|
11
|
+
useLive
|
|
12
|
+
} from '@/client/features/chat/chat-store'
|
|
13
|
+
import type { SessionInfo } from '@/lib/types'
|
|
7
14
|
|
|
8
15
|
import { Button } from '@/client/components/ui/button'
|
|
16
|
+
import { toast } from '@/client/components/ui/toast'
|
|
17
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from '@/client/components/ui/tooltip'
|
|
9
18
|
import {
|
|
10
19
|
DropdownMenu,
|
|
11
20
|
DropdownMenuContent,
|
|
12
21
|
DropdownMenuGroup,
|
|
13
22
|
DropdownMenuItem,
|
|
14
|
-
|
|
23
|
+
DropdownMenuLabel,
|
|
24
|
+
DropdownMenuSeparator,
|
|
15
25
|
DropdownMenuTrigger
|
|
16
26
|
} from '@/client/components/ui/dropdown-menu'
|
|
27
|
+
import { Spinner } from '@/client/components/ui/spinner'
|
|
17
28
|
|
|
18
29
|
type ChatSelectorProps = {
|
|
19
|
-
|
|
30
|
+
onSelectSession: (sessionId: string | null) => void
|
|
31
|
+
selectedSessionId: string | null
|
|
20
32
|
}
|
|
21
33
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const yesterday = new Date(now)
|
|
27
|
-
yesterday.setDate(yesterday.getDate() - 1)
|
|
28
|
-
const isYesterday = date.toDateString() === yesterday.toDateString()
|
|
29
|
-
|
|
30
|
-
if (isToday) return date.toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' })
|
|
31
|
-
if (isYesterday) return 'Yesterday'
|
|
32
|
-
return date.toLocaleDateString([], { month: 'short', day: 'numeric' })
|
|
34
|
+
type ChatSessionGroup = {
|
|
35
|
+
key: string
|
|
36
|
+
label: string
|
|
37
|
+
sessions: SessionInfo[]
|
|
33
38
|
}
|
|
34
39
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
type ChatSessionItemProps = {
|
|
41
|
+
active: boolean
|
|
42
|
+
canArchive: boolean
|
|
43
|
+
confirmingArchive: boolean
|
|
44
|
+
onArchive: (sessionId: string) => Promise<void>
|
|
45
|
+
onRequestArchive: (sessionId: string) => void
|
|
46
|
+
onSelect: (sessionId: string) => void
|
|
47
|
+
session: SessionInfo
|
|
48
|
+
workspaceId: string
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function ChatSessionItem({
|
|
52
|
+
active,
|
|
53
|
+
canArchive,
|
|
54
|
+
confirmingArchive,
|
|
55
|
+
onArchive,
|
|
56
|
+
onRequestArchive,
|
|
57
|
+
onSelect,
|
|
58
|
+
session,
|
|
59
|
+
workspaceId
|
|
60
|
+
}: ChatSessionItemProps) {
|
|
61
|
+
const pendingRef = useRef(false)
|
|
62
|
+
const [pending, setPending] = useState(false)
|
|
63
|
+
const running = useLive(state => isSessionRunning(state.activity, workspaceId, session.sessionId))
|
|
64
|
+
|
|
65
|
+
function handleRequestArchive() {
|
|
66
|
+
onRequestArchive(session.sessionId)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async function handleConfirmArchive() {
|
|
70
|
+
if (pendingRef.current) return
|
|
71
|
+
|
|
72
|
+
pendingRef.current = true
|
|
73
|
+
setPending(true)
|
|
74
|
+
try {
|
|
75
|
+
await onArchive(session.sessionId)
|
|
76
|
+
} catch {
|
|
77
|
+
toast.add({ title: 'Couldn’t archive chat', type: 'error' })
|
|
78
|
+
} finally {
|
|
79
|
+
pendingRef.current = false
|
|
80
|
+
setPending(false)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<div className="group/chat relative">
|
|
86
|
+
<DropdownMenuItem
|
|
87
|
+
className={cn(
|
|
88
|
+
'font-medium group-hover/chat:bg-accent group-hover/chat:text-accent-foreground',
|
|
89
|
+
active && 'bg-accent text-accent-foreground'
|
|
90
|
+
)}
|
|
91
|
+
onClick={() => onSelect(session.sessionId)}
|
|
92
|
+
>
|
|
93
|
+
<div
|
|
94
|
+
className={cn(
|
|
95
|
+
'flex min-w-0 flex-1 overflow-hidden',
|
|
96
|
+
(running || pending) && 'mr-4 mask-r-from-[calc(100%-16px)]',
|
|
97
|
+
canArchive &&
|
|
98
|
+
!confirmingArchive &&
|
|
99
|
+
'group-focus-within/chat:mr-4 group-focus-within/chat:mask-r-from-[calc(100%-16px)] group-hover/chat:mr-4 group-hover/chat:mask-r-from-[calc(100%-16px)] [@media(hover:none)]:mr-4 [@media(hover:none)]:mask-r-from-[calc(100%-16px)]',
|
|
100
|
+
confirmingArchive && 'mr-14 mask-r-from-[calc(100%-16px)]'
|
|
101
|
+
)}
|
|
102
|
+
>
|
|
103
|
+
<span
|
|
104
|
+
className={cn(
|
|
105
|
+
'min-w-0 truncate',
|
|
106
|
+
(running || pending) && '-mr-4',
|
|
107
|
+
confirmingArchive
|
|
108
|
+
? '-4'
|
|
109
|
+
: canArchive &&
|
|
110
|
+
'group-focus-within/chat:-mr-4 group-hover/chat:-mr-4 [@media(hover:none)]:-mr-4'
|
|
111
|
+
)}
|
|
112
|
+
>
|
|
113
|
+
{session.summary}
|
|
114
|
+
</span>
|
|
115
|
+
</div>
|
|
116
|
+
</DropdownMenuItem>
|
|
117
|
+
{running && (
|
|
118
|
+
<Spinner
|
|
119
|
+
className={cn(
|
|
120
|
+
'pointer-events-none absolute top-1/2 right-1.5 -translate-y-1/2 text-muted-foreground',
|
|
121
|
+
canArchive &&
|
|
122
|
+
'group-focus-within/chat:hidden group-hover/chat:hidden [@media(hover:none)]:hidden',
|
|
123
|
+
(confirmingArchive || pending) && 'hidden'
|
|
124
|
+
)}
|
|
125
|
+
/>
|
|
126
|
+
)}
|
|
127
|
+
{canArchive && (
|
|
128
|
+
<div
|
|
129
|
+
className={cn(
|
|
130
|
+
'absolute top-1/2 right-0 flex -translate-y-1/2 items-center opacity-100 transition-none',
|
|
131
|
+
!confirmingArchive &&
|
|
132
|
+
'group-focus-within/chat:opacity-100 group-hover/chat:opacity-100 [@media(hover:hover)]:opacity-0',
|
|
133
|
+
pending && 'opacity-100!'
|
|
134
|
+
)}
|
|
135
|
+
>
|
|
136
|
+
{confirmingArchive ? (
|
|
137
|
+
<Button
|
|
138
|
+
type="button"
|
|
139
|
+
variant="secondary"
|
|
140
|
+
size="sm"
|
|
141
|
+
aria-label={`Confirm archive ${session.summary}`}
|
|
142
|
+
tabIndex={-1}
|
|
143
|
+
className="mr-1 h-5 rounded-sm px-1.5 text-xs hover:bg-accent"
|
|
144
|
+
disabled={pending}
|
|
145
|
+
onClick={handleConfirmArchive}
|
|
146
|
+
onPointerDown={event => event.stopPropagation()}
|
|
147
|
+
>
|
|
148
|
+
Confirm
|
|
149
|
+
</Button>
|
|
150
|
+
) : (
|
|
151
|
+
<Tooltip>
|
|
152
|
+
<TooltipTrigger
|
|
153
|
+
render={
|
|
154
|
+
<Button
|
|
155
|
+
type="button"
|
|
156
|
+
variant="ghost"
|
|
157
|
+
size="icon-sm"
|
|
158
|
+
aria-label={`Archive ${session.summary}`}
|
|
159
|
+
tabIndex={-1}
|
|
160
|
+
className="text-muted-foreground hover:bg-transparent hover:text-foreground"
|
|
161
|
+
disabled={pending}
|
|
162
|
+
onClick={handleRequestArchive}
|
|
163
|
+
onPointerDown={event => event.stopPropagation()}
|
|
164
|
+
>
|
|
165
|
+
<IconArchive stroke={1.75} />
|
|
166
|
+
</Button>
|
|
167
|
+
}
|
|
168
|
+
/>
|
|
169
|
+
<TooltipContent side="right">Archive chat</TooltipContent>
|
|
170
|
+
</Tooltip>
|
|
171
|
+
)}
|
|
172
|
+
</div>
|
|
173
|
+
)}
|
|
174
|
+
</div>
|
|
175
|
+
)
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function localDateKey(date: Date): string {
|
|
179
|
+
return `${date.getFullYear()}-${date.getMonth()}-${date.getDate()}`
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function calendarDayNumber(date: Date): number {
|
|
183
|
+
return Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()) / 86_400_000
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function formatGroupLabel(date: Date, now: Date): string {
|
|
187
|
+
const daysAgo = calendarDayNumber(now) - calendarDayNumber(date)
|
|
188
|
+
if (daysAgo === 0) return 'Today'
|
|
189
|
+
if (daysAgo === 1) return 'Yesterday'
|
|
190
|
+
if (daysAgo >= 2 && daysAgo <= 5) return `${daysAgo} days ago`
|
|
191
|
+
|
|
192
|
+
return date.toLocaleDateString([], {
|
|
193
|
+
month: 'short',
|
|
194
|
+
day: 'numeric',
|
|
195
|
+
...(date.getFullYear() === now.getFullYear() ? {} : { year: 'numeric' })
|
|
196
|
+
})
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export function groupSessionsByDate(sessions: SessionInfo[], now = new Date()): ChatSessionGroup[] {
|
|
200
|
+
const groups = new Map<string, ChatSessionGroup>()
|
|
201
|
+
|
|
202
|
+
for (const session of sessions.slice().sort((a, b) => b.lastModified - a.lastModified)) {
|
|
203
|
+
const date = new Date(session.lastModified)
|
|
204
|
+
const key = localDateKey(date)
|
|
205
|
+
const group = groups.get(key)
|
|
206
|
+
if (group) {
|
|
207
|
+
group.sessions.push(session)
|
|
208
|
+
continue
|
|
209
|
+
}
|
|
210
|
+
groups.set(key, {
|
|
211
|
+
key,
|
|
212
|
+
label: formatGroupLabel(date, now),
|
|
213
|
+
sessions: [session]
|
|
214
|
+
})
|
|
215
|
+
}
|
|
39
216
|
|
|
40
|
-
|
|
217
|
+
return [...groups.values()]
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export function ChatSelector({ onSelectSession, selectedSessionId }: ChatSelectorProps) {
|
|
221
|
+
const workspaceId = useWorkspaceId()
|
|
222
|
+
const [confirmingSessionId, setConfirmingSessionId] = useState<string | null>(null)
|
|
223
|
+
const { data: sessions = [] } = useWorkspaceSessions(workspaceId)
|
|
224
|
+
const canArchive = useWorkspaceModels(workspaceId).data?.supportsArchiving === true
|
|
225
|
+
const archiveSession = useArchiveWorkspaceSession(workspaceId)
|
|
226
|
+
const hasRunningBackgroundChat = useLive(state =>
|
|
227
|
+
hasRunningBackgroundSession(state.activity, workspaceId, selectedSessionId)
|
|
228
|
+
)
|
|
229
|
+
const active = sessions.find(s => s.sessionId === selectedSessionId)
|
|
41
230
|
const label = active?.summary ?? 'New chat'
|
|
231
|
+
const sessionGroups = groupSessionsByDate(sessions)
|
|
42
232
|
|
|
43
233
|
function handleSelect(sessionId: string | null) {
|
|
44
|
-
|
|
234
|
+
onSelectSession(sessionId)
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function handleMenuOpenChange(open: boolean) {
|
|
238
|
+
if (!open) setConfirmingSessionId(null)
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
async function handleArchive(sessionId: string) {
|
|
242
|
+
setConfirmingSessionId(null)
|
|
243
|
+
await archiveSession.mutateAsync(sessionId)
|
|
244
|
+
const store = liveStore.getState()
|
|
245
|
+
store.clearAttachments(workspaceId, sessionId)
|
|
246
|
+
store.clearPreviewsForSession(workspaceId, sessionId)
|
|
247
|
+
if (selectedSessionId === sessionId) {
|
|
248
|
+
onSelectSession(null)
|
|
249
|
+
}
|
|
45
250
|
}
|
|
46
251
|
|
|
47
252
|
return (
|
|
48
|
-
<DropdownMenu
|
|
49
|
-
onOpenChange={open => {
|
|
50
|
-
if (open) refetch()
|
|
51
|
-
}}
|
|
52
|
-
>
|
|
253
|
+
<DropdownMenu onOpenChange={handleMenuOpenChange}>
|
|
53
254
|
<DropdownMenuTrigger
|
|
54
255
|
render={
|
|
55
256
|
<Button variant="ghost">
|
|
56
257
|
<span className="max-w-64 truncate">{label}</span>
|
|
57
|
-
|
|
258
|
+
{hasRunningBackgroundChat ? (
|
|
259
|
+
<Spinner className="size-4!" stroke={2} />
|
|
260
|
+
) : (
|
|
261
|
+
<IconChevronDown stroke={1.5} />
|
|
262
|
+
)}
|
|
58
263
|
</Button>
|
|
59
264
|
}
|
|
60
265
|
/>
|
|
61
|
-
<DropdownMenuContent
|
|
266
|
+
<DropdownMenuContent
|
|
267
|
+
align="start"
|
|
268
|
+
className="flex max-h-100 w-max max-w-72 min-w-40 flex-col overflow-hidden"
|
|
269
|
+
>
|
|
62
270
|
<DropdownMenuItem
|
|
63
|
-
className="text-muted-foreground! **:text-muted-foreground!"
|
|
271
|
+
className="shrink-0 gap-1 font-medium text-muted-foreground! **:text-muted-foreground!"
|
|
64
272
|
onClick={() => handleSelect(null)}
|
|
65
273
|
>
|
|
66
|
-
<
|
|
274
|
+
<IconEdit size={16} stroke={1.75} />
|
|
67
275
|
New chat
|
|
68
276
|
</DropdownMenuItem>
|
|
69
|
-
{
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
277
|
+
{sessionGroups.length > 0 && (
|
|
278
|
+
<>
|
|
279
|
+
<DropdownMenuSeparator className="shrink-0" />
|
|
280
|
+
<div className="no-scrollbar flex min-h-0 flex-1 scroll-fade flex-col gap-1 overflow-y-auto overscroll-contain [--scroll-fade-reveal:8px]">
|
|
281
|
+
{sessionGroups.map(group => (
|
|
282
|
+
<DropdownMenuGroup key={group.key}>
|
|
283
|
+
<DropdownMenuLabel>{group.label}</DropdownMenuLabel>
|
|
284
|
+
{group.sessions.map(session => (
|
|
285
|
+
<ChatSessionItem
|
|
286
|
+
key={session.sessionId}
|
|
287
|
+
session={session}
|
|
288
|
+
active={selectedSessionId === session.sessionId}
|
|
289
|
+
canArchive={canArchive}
|
|
290
|
+
confirmingArchive={confirmingSessionId === session.sessionId}
|
|
291
|
+
onSelect={handleSelect}
|
|
292
|
+
onArchive={handleArchive}
|
|
293
|
+
onRequestArchive={setConfirmingSessionId}
|
|
294
|
+
workspaceId={workspaceId}
|
|
295
|
+
/>
|
|
296
|
+
))}
|
|
297
|
+
</DropdownMenuGroup>
|
|
298
|
+
))}
|
|
299
|
+
</div>
|
|
300
|
+
</>
|
|
86
301
|
)}
|
|
87
302
|
</DropdownMenuContent>
|
|
88
303
|
</DropdownMenu>
|