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.
- package/README.md +2 -2
- package/client/api/workspace-keys.ts +1 -2
- package/client/app/AppRouter.tsx +10 -3
- package/client/app/routes/HomeRoute.tsx +1 -1
- package/client/app/shell/SidebarLayout.tsx +2 -14
- package/client/components/shared/BottomPanel.tsx +2 -1
- package/client/components/shared/Composer.tsx +20 -7
- package/client/components/shared/PanelHeader.tsx +8 -1
- package/client/components/ui/button.tsx +3 -3
- package/client/components/ui/dialog.tsx +1 -1
- package/client/components/ui/dropdown-menu.tsx +2 -2
- package/client/components/ui/hover-card.tsx +1 -1
- package/client/components/ui/popover.tsx +1 -1
- package/client/components/ui/resizable.tsx +40 -0
- package/client/features/applets/AppletMount.tsx +9 -22
- package/client/features/applets/applet-cache.ts +7 -0
- package/client/features/applets/applet-styles.ts +21 -1
- package/client/features/applets/useApplet.ts +1 -1
- package/client/features/chat/ChatEmptyState.tsx +9 -11
- package/client/features/chat/ChatPanel.tsx +76 -48
- package/client/features/chat/ChatPopup.tsx +16 -2
- package/client/features/chat/ChatPromptBubbles.tsx +6 -8
- package/client/features/chat/ChatSelector.tsx +25 -8
- package/client/features/chat/ModelPicker.tsx +5 -4
- package/client/features/chat/TurnView.tsx +108 -13
- package/client/features/chat/api.ts +1 -18
- package/client/features/chat/chat-send.ts +2 -2
- package/client/features/chat/{ChatComposer.tsx → composer/ChatComposer.tsx} +24 -9
- package/client/features/chat/composer/banners/ChatErrorBanner.tsx +28 -0
- package/client/features/chat/composer/banners/ComposerBanner.tsx +30 -0
- package/client/features/chat/composer/banners/WorkspaceAgentAvailabilityBanner.tsx +91 -0
- package/client/features/{workspace → chat/composer/banners}/WorkspaceSkillUpdateBanner.tsx +9 -7
- package/client/features/chat/composer/useWorkspaceComposerState.tsx +74 -0
- package/client/features/{workspace → chat/composer}/useWorkspaceSkillUpdates.ts +1 -1
- package/client/features/chat/group-turns.ts +46 -28
- package/client/features/chat/interleave-notices.ts +84 -0
- package/client/features/chat/model-order.ts +9 -3
- package/client/features/chat/tool-group/TimelineRow.tsx +23 -11
- package/client/features/chat/tool-group/ToolCallGroup.tsx +38 -3
- package/client/features/chat/tool-group/format.ts +23 -7
- package/client/features/chat/useAppletChatMessage.ts +11 -16
- package/client/features/chat/useChat.ts +3 -7
- package/client/features/dev/ChatStatesPage.tsx +428 -0
- package/client/features/dev/DevIndexPage.tsx +52 -0
- package/client/features/dev/DevRoutes.tsx +6 -3
- package/client/features/dev/HarnessDebugPage.tsx +3 -3
- package/client/features/dev/chat-states-fixtures.ts +744 -0
- package/client/features/home/api.ts +0 -10
- package/client/features/home/workspace-setup/CreateWorkspaceDialog.tsx +21 -64
- package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +1 -1
- package/client/features/scratchpad/Scratchpad.tsx +5 -3
- package/client/features/scratchpad/scratch-session.ts +71 -0
- package/client/features/views/ViewBuilderTab.tsx +5 -4
- package/client/features/views/ViewManager.tsx +258 -0
- package/client/features/views/useViewBuilderActions.ts +2 -2
- package/client/features/views/view-residency.ts +77 -0
- package/client/features/widgets/WidgetFrame.tsx +6 -2
- package/client/features/workspace/CustomizePanel.tsx +40 -24
- package/client/features/workspace/WorkspaceLayoutContext.tsx +12 -2
- package/client/features/workspace/WorkspaceScreen.tsx +131 -201
- package/client/features/workspace/WorkspaceSplitLayout.tsx +111 -0
- package/client/features/workspace/WorkspaceTabs.tsx +1 -1
- package/client/features/workspace/api.ts +33 -8
- package/client/features/workspace/useFitsSplitLayout.ts +31 -5
- package/client/index.css +5 -2
- package/client/lib/flags.ts +4 -3
- package/client/runtime/useWorkspaceEvents.ts +18 -1
- package/client/runtime/workspace-theme.ts +29 -10
- package/client/store/ui.ts +5 -1
- package/client/theme.css +96 -6
- package/dist/{chunk-0pcdwjkp.js → chunk-2vaafjp4.js} +1 -1
- package/dist/{chunk-9y2zbzqz.js → chunk-35fq49qa.js} +1 -1
- package/dist/chunk-gny990qx.css +1 -0
- package/dist/chunk-gt7n06ef.js +1 -0
- package/dist/{chunk-rxvx4ta9.js → chunk-kkj86722.js} +75 -75
- package/dist/chunk-n7pga5x3.js +80 -0
- package/dist/chunk-xeyxk7ep.js +10 -0
- package/dist/{chunk-w3tnv51j.js → chunk-xzx7c9hq.js} +1 -1
- package/dist/index.html +1 -1
- package/lib/format.ts +17 -1
- package/lib/themes.ts +123 -51
- package/lib/types.ts +40 -13
- package/lib/workspace-layout.ts +2 -2
- package/package.json +6 -4
- package/server/agent.ts +199 -0
- package/server/api.ts +38 -90
- package/server/bundler/build-applet.ts +7 -4
- package/server/cli.ts +46 -15
- package/server/control.ts +13 -6
- package/server/env-apply.ts +4 -0
- package/server/harness/README.md +28 -12
- package/server/harness/claude-code/auth.ts +54 -0
- package/server/harness/claude-code/index.ts +6 -1
- package/server/harness/codex/adapter.ts +9 -1
- package/server/harness/codex/auth.ts +50 -0
- package/server/harness/codex/index.ts +6 -1
- package/server/harness/codex/session.ts +33 -14
- package/server/harness/openclaw/NOTES.md +518 -187
- package/server/harness/openclaw/adapter.ts +125 -31
- package/server/harness/openclaw/compat.ts +99 -0
- package/server/harness/openclaw/cron-view.ts +78 -0
- package/server/harness/openclaw/discovery.ts +145 -52
- package/server/harness/openclaw/gateway.ts +224 -36
- package/server/harness/openclaw/index.ts +56 -21
- package/server/harness/openclaw/session.ts +971 -55
- package/server/harness/openclaw/strip.ts +87 -15
- package/server/harness/openclaw/thinking.ts +198 -0
- package/server/harness/types.ts +10 -5
- package/server/layout.ts +5 -2
- package/server/moi-scaffold.ts +1 -1
- package/server/registry.ts +0 -20
- package/server/theme.ts +24 -27
- package/workspace/.claude/skills/moi-workspace/DESIGN.md +100 -53
- package/workspace/.claude/skills/moi-workspace/SKILL.md +10 -12
- package/client/features/dev/PixelPainter.tsx +0 -94
- package/client/features/dev/PlaygroundPage.tsx +0 -69
- package/dist/chunk-175bm057.js +0 -27
- package/dist/chunk-55sh4dty.js +0 -2
- package/dist/chunk-afgbg75t.js +0 -50
- package/dist/chunk-agtetn7n.css +0 -1
- package/dist/chunk-dfs36zgc.js +0 -1
- package/dist/chunk-exj6hr30.js +0 -9
- package/dist/chunk-m11ckkxd.js +0 -51
|
@@ -1,27 +1,35 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef } from 'react'
|
|
2
2
|
|
|
3
|
-
import { IconChevronDown, IconX } from '@tabler/icons-react'
|
|
3
|
+
import { IconChevronDown, IconChevronsRight, IconX } from '@tabler/icons-react'
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
canSubmitComposerAction,
|
|
7
|
+
type ComposerAvailability,
|
|
8
|
+
focusComposer
|
|
9
|
+
} from '@/client/components/shared/Composer'
|
|
6
10
|
import { useStickToBottom } from '@/client/features/chat/useStickToBottom'
|
|
7
11
|
import { groupTurns } from '@/client/features/chat/group-turns'
|
|
12
|
+
import { chatNoticeLabel, interleaveNotices } from '@/client/features/chat/interleave-notices'
|
|
8
13
|
import { attachmentKey, useLive } from '@/client/features/chat/chat-store'
|
|
9
14
|
import type { ChatPromptBubble } from '@/client/features/chat/ChatPromptBubbles'
|
|
10
15
|
import type { ChatSendOptions } from '@/client/features/chat/chat-send'
|
|
11
16
|
import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
|
|
12
|
-
import type { Turn, ViewState } from '@/lib/types'
|
|
17
|
+
import type { SystemNotice, Turn, ViewState } from '@/lib/types'
|
|
13
18
|
|
|
14
|
-
import {
|
|
19
|
+
import type { ComposerBanner } from './composer/banners/ComposerBanner'
|
|
20
|
+
import { ChatComposer } from './composer/ChatComposer'
|
|
15
21
|
import { ChatEmptyState, resolveChatEmptyState } from './ChatEmptyState'
|
|
16
22
|
import { ChatSelector } from './ChatSelector'
|
|
17
23
|
import { ThinkingIndicator, TurnView } from './TurnView'
|
|
18
24
|
import { Button } from '@/client/components/ui/button'
|
|
25
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from '@/client/components/ui/tooltip'
|
|
19
26
|
import { cn } from '@/client/lib/cn'
|
|
20
27
|
import { useUiStore } from '@/client/store/ui'
|
|
21
28
|
|
|
22
29
|
type ChatPanelProps = {
|
|
23
30
|
active?: boolean
|
|
24
31
|
focusRequest?: number
|
|
32
|
+
docked?: boolean
|
|
25
33
|
chatLoaded: boolean
|
|
26
34
|
view: ViewState
|
|
27
35
|
// The live streaming preview as a synthetic assistant turn (or null). Merged
|
|
@@ -32,29 +40,26 @@ type ChatPanelProps = {
|
|
|
32
40
|
// session switch).
|
|
33
41
|
sessionId?: string | null
|
|
34
42
|
processing: boolean
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
composerBanner?: ReactNode
|
|
38
|
-
unavailableReason: string | null | undefined
|
|
43
|
+
composerBanner?: ComposerBanner
|
|
44
|
+
composerAvailability: ComposerAvailability
|
|
39
45
|
send: (text: string, options?: ChatSendOptions) => void
|
|
40
46
|
stop: () => void
|
|
41
47
|
onSelectSession: (sessionId: string | null) => void
|
|
42
|
-
//
|
|
48
|
+
// Chat on a separate tab doesn't have a close button
|
|
43
49
|
onClose?: () => void
|
|
44
50
|
}
|
|
45
51
|
|
|
46
52
|
export function ChatPanel({
|
|
47
53
|
active = true,
|
|
48
54
|
focusRequest = 0,
|
|
55
|
+
docked = false,
|
|
49
56
|
chatLoaded,
|
|
50
57
|
view,
|
|
51
58
|
previewTurn,
|
|
52
59
|
sessionId,
|
|
53
60
|
processing,
|
|
54
|
-
error,
|
|
55
|
-
onDismissError,
|
|
56
61
|
composerBanner,
|
|
57
|
-
|
|
62
|
+
composerAvailability,
|
|
58
63
|
send,
|
|
59
64
|
stop,
|
|
60
65
|
onSelectSession,
|
|
@@ -73,7 +78,7 @@ export function ChatPanel({
|
|
|
73
78
|
attachment => attachment.status === 'uploading'
|
|
74
79
|
)
|
|
75
80
|
)
|
|
76
|
-
const promptDisabled = !canSubmitComposerAction(true, attachmentsUploading,
|
|
81
|
+
const promptDisabled = !canSubmitComposerAction(true, attachmentsUploading, composerAvailability)
|
|
77
82
|
// Visual grouping: fold consecutive tool-only assistant turns into one
|
|
78
83
|
// synthetic turn so OpenAI Codex–style traces (which serialize one
|
|
79
84
|
// assistant message per agent step) don't render with the wider
|
|
@@ -84,7 +89,15 @@ export function ChatPanel({
|
|
|
84
89
|
() => groupTurns(previewTurn ? [...turns, previewTurn] : turns),
|
|
85
90
|
[turns, previewTurn]
|
|
86
91
|
)
|
|
87
|
-
|
|
92
|
+
// Grouped turns plus the renderable notices (compaction, model changes)
|
|
93
|
+
// woven in at the moment they happened. Interleaving runs AFTER grouping so
|
|
94
|
+
// a notice never splits a tool-only run apart.
|
|
95
|
+
const timeline = useMemo(
|
|
96
|
+
() => interleaveNotices(groupedTurns, view.notices),
|
|
97
|
+
[groupedTurns, view.notices]
|
|
98
|
+
)
|
|
99
|
+
const lastTurnId = groupedTurns.length > 0 ? groupedTurns[groupedTurns.length - 1].id : null
|
|
100
|
+
const showEmptyChat = chatLoaded && timeline.length === 0 && !processing
|
|
88
101
|
const emptyStateKind = resolveChatEmptyState({
|
|
89
102
|
hasSentMessageFromMoi,
|
|
90
103
|
isWorkspacePendingAnalysis
|
|
@@ -125,9 +138,21 @@ export function ChatPanel({
|
|
|
125
138
|
<div className="flex min-h-0 flex-1 flex-col pt-2 pb-3">
|
|
126
139
|
<header className="mx-auto flex w-full max-w-[calc(var(--chat-max-container)+40px)] items-center justify-between pr-2 pb-2 pl-2">
|
|
127
140
|
<ChatSelector selectedSessionId={sessionId ?? null} onSelectSession={onSelectSession} />
|
|
128
|
-
{onClose && (
|
|
129
|
-
<
|
|
130
|
-
<
|
|
141
|
+
{onClose && docked && (
|
|
142
|
+
<Tooltip>
|
|
143
|
+
<TooltipTrigger
|
|
144
|
+
render={
|
|
145
|
+
<Button variant="ghost" size="icon-sm" onClick={onClose} aria-label="Undock agent">
|
|
146
|
+
<IconChevronsRight className="size-5! text-muted-foreground" stroke={1.5} />
|
|
147
|
+
</Button>
|
|
148
|
+
}
|
|
149
|
+
/>
|
|
150
|
+
<TooltipContent>Undock agent</TooltipContent>
|
|
151
|
+
</Tooltip>
|
|
152
|
+
)}
|
|
153
|
+
{onClose && !docked && (
|
|
154
|
+
<Button variant="ghost" size="icon-sm" onClick={onClose} aria-label="Close chat">
|
|
155
|
+
<IconX stroke={2} />
|
|
131
156
|
</Button>
|
|
132
157
|
)}
|
|
133
158
|
</header>
|
|
@@ -137,7 +162,7 @@ export function ChatPanel({
|
|
|
137
162
|
ref={scrollRef}
|
|
138
163
|
className="flex scrollbar-thin flex-1 scroll-fade flex-col overflow-y-auto overscroll-contain px-5 pt-4 pb-12 [--scroll-fade-reveal:8px]"
|
|
139
164
|
>
|
|
140
|
-
<div className="mx-auto flex w-full max-w-(--chat-max-container) flex-1 flex-col gap-6">
|
|
165
|
+
<div className="mx-auto flex w-full max-w-(--chat-max-container) flex-1 flex-col items-center gap-6">
|
|
141
166
|
{showEmptyChat && (
|
|
142
167
|
<ChatEmptyState
|
|
143
168
|
kind={emptyStateKind}
|
|
@@ -145,13 +170,17 @@ export function ChatPanel({
|
|
|
145
170
|
onSelectPrompt={handlePromptSelect}
|
|
146
171
|
/>
|
|
147
172
|
)}
|
|
148
|
-
{
|
|
149
|
-
|
|
150
|
-
key={
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
173
|
+
{timeline.map(item =>
|
|
174
|
+
item.kind === 'notice' ? (
|
|
175
|
+
<ChatNoticeRow key={`notice:${item.notice.id}`} notice={item.notice} />
|
|
176
|
+
) : (
|
|
177
|
+
<TurnView
|
|
178
|
+
key={item.turn.id}
|
|
179
|
+
turn={item.turn}
|
|
180
|
+
processing={processing && item.turn.id === lastTurnId}
|
|
181
|
+
/>
|
|
182
|
+
)
|
|
183
|
+
)}
|
|
155
184
|
{/* Pulsing dots only before the first token — once the preview has
|
|
156
185
|
visible content it renders as a (possibly merged) grouped turn. */}
|
|
157
186
|
{processing && !previewTurn && <ThinkingIndicator />}
|
|
@@ -178,39 +207,38 @@ export function ChatPanel({
|
|
|
178
207
|
<div
|
|
179
208
|
className={cn(
|
|
180
209
|
'@container flex w-full flex-col transition-[padding]',
|
|
181
|
-
|
|
182
|
-
composerBanner && 'bg-muted',
|
|
183
|
-
|
|
210
|
+
composerBanner && 'gap-2 rounded-t-xl rounded-b-2xl p-2',
|
|
211
|
+
composerBanner?.tone === 'muted' && 'bg-muted',
|
|
212
|
+
composerBanner?.tone === 'destructive' && 'bg-destructive/10'
|
|
184
213
|
)}
|
|
185
214
|
>
|
|
186
|
-
{composerBanner}
|
|
187
|
-
{error && (
|
|
188
|
-
<div className="flex w-full items-center gap-2 p-1 pl-4 text-sm">
|
|
189
|
-
<span className="flex-1 wrap-break-word text-destructive">{error}</span>
|
|
190
|
-
{onDismissError && (
|
|
191
|
-
<Button
|
|
192
|
-
type="button"
|
|
193
|
-
variant="ghost"
|
|
194
|
-
size="icon-sm"
|
|
195
|
-
onClick={onDismissError}
|
|
196
|
-
className="text-destructive hover:text-destructive"
|
|
197
|
-
aria-label="Dismiss error"
|
|
198
|
-
>
|
|
199
|
-
<IconX stroke={1.75} />
|
|
200
|
-
</Button>
|
|
201
|
-
)}
|
|
202
|
-
</div>
|
|
203
|
-
)}
|
|
215
|
+
{composerBanner?.content}
|
|
204
216
|
<ChatComposer
|
|
205
217
|
composerRef={composerRef}
|
|
206
218
|
onSend={handleSend}
|
|
207
219
|
onStop={stop}
|
|
208
220
|
processing={processing}
|
|
209
221
|
sessionId={sessionId ?? null}
|
|
210
|
-
|
|
222
|
+
availability={composerAvailability}
|
|
211
223
|
/>
|
|
212
224
|
</div>
|
|
213
225
|
</div>
|
|
214
226
|
</div>
|
|
215
227
|
)
|
|
216
228
|
}
|
|
229
|
+
|
|
230
|
+
type ChatNoticeRowProps = { notice: SystemNotice }
|
|
231
|
+
|
|
232
|
+
// A quiet, centered one-liner marking a session event (context compacted,
|
|
233
|
+
// model changed) at its place in the transcript. Kinds without designed copy
|
|
234
|
+
// render nothing (see chatNoticeLabel). Exported for the /dev/chat-states
|
|
235
|
+
// catalog.
|
|
236
|
+
export function ChatNoticeRow({ notice }: ChatNoticeRowProps) {
|
|
237
|
+
const label = chatNoticeLabel(notice)
|
|
238
|
+
if (!label) return null
|
|
239
|
+
return (
|
|
240
|
+
<div className="flex justify-center">
|
|
241
|
+
<span className="max-w-full truncate text-xs text-muted-foreground">{label}</span>
|
|
242
|
+
</div>
|
|
243
|
+
)
|
|
244
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ReactNode } from 'react'
|
|
1
|
+
import type { ComponentProps, ReactNode } from 'react'
|
|
2
2
|
|
|
3
3
|
import { motion } from 'motion/react'
|
|
4
4
|
|
|
@@ -22,9 +22,23 @@ export function ChatPopup({
|
|
|
22
22
|
children
|
|
23
23
|
}: ChatPopupProps) {
|
|
24
24
|
const onClose = () => onOpenChange(false)
|
|
25
|
+
const handleOpenChange: NonNullable<ComponentProps<typeof Popover>['onOpenChange']> = (
|
|
26
|
+
nextOpen,
|
|
27
|
+
eventDetails
|
|
28
|
+
) => {
|
|
29
|
+
if (!nextOpen && eventDetails.reason === 'outside-press') {
|
|
30
|
+
eventDetails.cancel()
|
|
31
|
+
return
|
|
32
|
+
}
|
|
33
|
+
onOpenChange(nextOpen)
|
|
34
|
+
}
|
|
25
35
|
|
|
26
36
|
return (
|
|
27
|
-
<Popover
|
|
37
|
+
<Popover
|
|
38
|
+
open={open}
|
|
39
|
+
onOpenChange={handleOpenChange}
|
|
40
|
+
onOpenChangeComplete={onOpenChangeComplete}
|
|
41
|
+
>
|
|
28
42
|
<PopoverTrigger
|
|
29
43
|
render={
|
|
30
44
|
<div className="fixed right-4 bottom-4 sm:right-6 sm:bottom-6">
|
|
@@ -28,13 +28,11 @@ export function ChatPromptBubble({
|
|
|
28
28
|
return (
|
|
29
29
|
<Button
|
|
30
30
|
type="button"
|
|
31
|
-
variant="secondary"
|
|
32
31
|
size="sm"
|
|
33
32
|
disabled={disabled}
|
|
34
33
|
onClick={() => onSelect(prompt)}
|
|
35
34
|
className={cn(
|
|
36
|
-
'h-auto items-start justify-start gap-2 rounded-
|
|
37
|
-
'hover:bg-accent',
|
|
35
|
+
'h-auto items-start justify-start gap-2 rounded-lg p-2 px-3 text-left leading-snug whitespace-normal',
|
|
38
36
|
className
|
|
39
37
|
)}
|
|
40
38
|
>
|
|
@@ -52,7 +50,7 @@ type ChatPromptBubblesProps = {
|
|
|
52
50
|
|
|
53
51
|
export function ChatPromptBubbles({ prompts, disabled = false, onSelect }: ChatPromptBubblesProps) {
|
|
54
52
|
return (
|
|
55
|
-
<div className="grid w-full grid-cols-1 gap-3 py-2
|
|
53
|
+
<div className="row-gap-2 grid w-full grid-cols-1 gap-x-3 gap-y-2 py-2 @md:grid-cols-3">
|
|
56
54
|
{prompts.map((prompt, index) => {
|
|
57
55
|
return (
|
|
58
56
|
<ChatPromptBubble
|
|
@@ -61,10 +59,10 @@ export function ChatPromptBubbles({ prompts, disabled = false, onSelect }: ChatP
|
|
|
61
59
|
disabled={disabled}
|
|
62
60
|
onSelect={onSelect}
|
|
63
61
|
className={cn(
|
|
64
|
-
'h-full w-full',
|
|
65
|
-
index === 0 && 'translate-y-3 rotate-3 hover:translate-y-2.5',
|
|
66
|
-
index === 1 && '
|
|
67
|
-
index === 2 && 'translate-y-3
|
|
62
|
+
'h-full w-fit @md:w-full',
|
|
63
|
+
index === 0 && '@md:translate-y-3 @md:rotate-3 @md:hover:translate-y-2.5',
|
|
64
|
+
index === 1 && '@md:-rotate-1',
|
|
65
|
+
index === 2 && '@md:translate-y-3 @md:-rotate-4 @md:hover:translate-y-2.5'
|
|
68
66
|
)}
|
|
69
67
|
/>
|
|
70
68
|
)
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { useRef, useState } from 'react'
|
|
2
2
|
import { IconArchive, IconChevronDown, IconEdit } from '@tabler/icons-react'
|
|
3
3
|
|
|
4
|
-
import { useArchiveWorkspaceSession,
|
|
4
|
+
import { useArchiveWorkspaceSession, useWorkspaceSessions } from './api'
|
|
5
|
+
import { useWorkspaceAgent } from '@/client/features/workspace/api'
|
|
5
6
|
import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
|
|
6
7
|
import { cn } from '@/client/lib/cn'
|
|
7
8
|
import {
|
|
@@ -37,6 +38,15 @@ type ChatSessionGroup = {
|
|
|
37
38
|
sessions: SessionInfo[]
|
|
38
39
|
}
|
|
39
40
|
|
|
41
|
+
// One tiny text badge per row at most: a cron/subagent flavor wins; otherwise
|
|
42
|
+
// an external origin shows its provider lowercase (e.g. "irc", "telegram").
|
|
43
|
+
// Plain app chats get none.
|
|
44
|
+
export function sessionBadge(session: SessionInfo): string | null {
|
|
45
|
+
if (session.flavor === 'cron' || session.flavor === 'subagent') return session.flavor
|
|
46
|
+
const provider = session.origin?.provider.trim().toLowerCase()
|
|
47
|
+
return provider ? provider : null
|
|
48
|
+
}
|
|
49
|
+
|
|
40
50
|
type ChatSessionItemProps = {
|
|
41
51
|
active: boolean
|
|
42
52
|
canArchive: boolean
|
|
@@ -48,7 +58,9 @@ type ChatSessionItemProps = {
|
|
|
48
58
|
workspaceId: string
|
|
49
59
|
}
|
|
50
60
|
|
|
51
|
-
|
|
61
|
+
// One chat row inside the selector menu (summary, flavor/origin badge, running
|
|
62
|
+
// spinner, archive affordance). Exported for the /dev/chat-states catalog.
|
|
63
|
+
export function ChatSessionItem({
|
|
52
64
|
active,
|
|
53
65
|
canArchive,
|
|
54
66
|
confirmingArchive,
|
|
@@ -61,6 +73,7 @@ function ChatSessionItem({
|
|
|
61
73
|
const pendingRef = useRef(false)
|
|
62
74
|
const [pending, setPending] = useState(false)
|
|
63
75
|
const running = useLive(state => isSessionRunning(state.activity, workspaceId, session.sessionId))
|
|
76
|
+
const badge = sessionBadge(session)
|
|
64
77
|
|
|
65
78
|
function handleRequestArchive() {
|
|
66
79
|
onRequestArchive(session.sessionId)
|
|
@@ -102,15 +115,16 @@ function ChatSessionItem({
|
|
|
102
115
|
>
|
|
103
116
|
<span
|
|
104
117
|
className={cn(
|
|
105
|
-
'min-w-0
|
|
118
|
+
'flex min-w-0 items-baseline gap-1.5',
|
|
106
119
|
(running || pending) && '-mr-4',
|
|
107
120
|
confirmingArchive
|
|
108
|
-
? '-
|
|
121
|
+
? '-mr-14'
|
|
109
122
|
: canArchive &&
|
|
110
123
|
'group-focus-within/chat:-mr-4 group-hover/chat:-mr-4 [@media(hover:none)]:-mr-4'
|
|
111
124
|
)}
|
|
112
125
|
>
|
|
113
|
-
{session.summary}
|
|
126
|
+
<span className="min-w-0 truncate">{session.summary}</span>
|
|
127
|
+
{badge && <span className="shrink-0 text-xs text-muted-foreground">{badge}</span>}
|
|
114
128
|
</span>
|
|
115
129
|
</div>
|
|
116
130
|
</DropdownMenuItem>
|
|
@@ -221,7 +235,7 @@ export function ChatSelector({ onSelectSession, selectedSessionId }: ChatSelecto
|
|
|
221
235
|
const workspaceId = useWorkspaceId()
|
|
222
236
|
const [confirmingSessionId, setConfirmingSessionId] = useState<string | null>(null)
|
|
223
237
|
const { data: sessions = [] } = useWorkspaceSessions(workspaceId)
|
|
224
|
-
const canArchive =
|
|
238
|
+
const canArchive = useWorkspaceAgent(workspaceId).data?.supportsArchiving === true
|
|
225
239
|
const archiveSession = useArchiveWorkspaceSession(workspaceId)
|
|
226
240
|
const hasRunningBackgroundChat = useLive(state =>
|
|
227
241
|
hasRunningBackgroundSession(state.activity, workspaceId, selectedSessionId)
|
|
@@ -253,12 +267,15 @@ export function ChatSelector({ onSelectSession, selectedSessionId }: ChatSelecto
|
|
|
253
267
|
<DropdownMenu onOpenChange={handleMenuOpenChange}>
|
|
254
268
|
<DropdownMenuTrigger
|
|
255
269
|
render={
|
|
256
|
-
<Button variant="ghost">
|
|
270
|
+
<Button className="group" variant="ghost" size="sm">
|
|
257
271
|
<span className="max-w-64 truncate">{label}</span>
|
|
258
272
|
{hasRunningBackgroundChat ? (
|
|
259
273
|
<Spinner className="size-4!" stroke={2} />
|
|
260
274
|
) : (
|
|
261
|
-
<IconChevronDown
|
|
275
|
+
<IconChevronDown
|
|
276
|
+
className="text-muted-foreground group-hover:text-foreground"
|
|
277
|
+
stroke={1.75}
|
|
278
|
+
/>
|
|
262
279
|
)}
|
|
263
280
|
</Button>
|
|
264
281
|
}
|
|
@@ -4,7 +4,8 @@ import { AnimatePresence, motion } from 'motion/react'
|
|
|
4
4
|
|
|
5
5
|
import { IconBolt, IconBoltFilled } from '@tabler/icons-react'
|
|
6
6
|
|
|
7
|
-
import { useSaveSessionConfig, useSessionConfig
|
|
7
|
+
import { useSaveSessionConfig, useSessionConfig } from './api'
|
|
8
|
+
import { useWorkspaceAgent } from '@/client/features/workspace/api'
|
|
8
9
|
import {
|
|
9
10
|
hasEffortChoice,
|
|
10
11
|
resolveDisplayedEffort,
|
|
@@ -271,7 +272,7 @@ type ModelPickerProps = {
|
|
|
271
272
|
}
|
|
272
273
|
|
|
273
274
|
// Model selector for composer surfaces. The workspace's available models come
|
|
274
|
-
// from `/api/workspaces/:id/
|
|
275
|
+
// from `/api/workspaces/:id/agent`; effort options follow the selected model.
|
|
275
276
|
// Model, effort, and Fast mode persist per chat once one exists. A new chat
|
|
276
277
|
// edits the workspace defaults that seed it. All values are sent with each chat
|
|
277
278
|
// frame. The workspace scope gives new-chat surfaces such as the view builder
|
|
@@ -279,7 +280,7 @@ type ModelPickerProps = {
|
|
|
279
280
|
export const ModelPicker = memo(function ModelPicker({ scope = 'active-chat' }: ModelPickerProps) {
|
|
280
281
|
const { workspaceId, layout, setLayout } = useWorkspaceLayoutCtx()
|
|
281
282
|
const [selectedSessionId] = useSelectedSession()
|
|
282
|
-
const { data } =
|
|
283
|
+
const { data } = useWorkspaceAgent(workspaceId)
|
|
283
284
|
|
|
284
285
|
// The SDK prepends a synthetic "default" entry ("Use the default model
|
|
285
286
|
// (currently …)"). Drop it and name the concrete model it resolves to.
|
|
@@ -332,7 +333,7 @@ export const ModelPicker = memo(function ModelPicker({ scope = 'active-chat' }:
|
|
|
332
333
|
const currentModelValue = persistedModel ?? defaultModel.value
|
|
333
334
|
const model = models.find(item => item.value === currentModelValue) ?? models[0]
|
|
334
335
|
const effortLevels = model.supportsEffort ? (model.supportedEffortLevels ?? []) : []
|
|
335
|
-
const currentEffort = resolveDisplayedEffort(effortLevels, selectedEffort)
|
|
336
|
+
const currentEffort = resolveDisplayedEffort(effortLevels, selectedEffort, model.defaultEffort)
|
|
336
337
|
const showEffort = hasEffortChoice(effortLevels) && currentEffort !== undefined
|
|
337
338
|
const fastMode = resolveFastMode(model, selectedFastMode)
|
|
338
339
|
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import { memo } from 'react'
|
|
2
2
|
|
|
3
|
-
import { IconFile } from '@tabler/icons-react'
|
|
3
|
+
import { IconChevronRight, IconFile } from '@tabler/icons-react'
|
|
4
4
|
|
|
5
|
+
import type { Part, Turn } from '@/lib/types'
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
Collapsible,
|
|
9
|
+
CollapsibleContent,
|
|
10
|
+
CollapsibleTrigger
|
|
11
|
+
} from '@/client/components/ui/collapsible'
|
|
5
12
|
import { MarkdownContent } from '@/client/features/chat/MarkdownContent'
|
|
6
13
|
import { ToolCallGroup } from '@/client/features/chat/tool-group/ToolCallGroup'
|
|
14
|
+
import { formatDuration } from '@/client/features/chat/tool-group/format'
|
|
7
15
|
import { useWorkspaceLayoutCtx } from '@/client/features/workspace/WorkspaceLayoutContext'
|
|
8
|
-
import
|
|
16
|
+
import { cn } from '@/client/lib/cn'
|
|
9
17
|
|
|
10
18
|
export function ThinkingIndicator() {
|
|
11
19
|
return (
|
|
@@ -80,6 +88,89 @@ export function TurnParts({ parts, cwd, processing = false }: TurnPartsProps) {
|
|
|
80
88
|
)
|
|
81
89
|
}
|
|
82
90
|
|
|
91
|
+
type CompletedAssistantParts = { work: Part[]; response: Part[] }
|
|
92
|
+
|
|
93
|
+
function hasVisibleResponse(parts: Part[]): boolean {
|
|
94
|
+
return parts.some(part => part.type !== 'text' || part.text.trim().length > 0)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function splitCompletedAssistantParts(parts: Part[]): CompletedAssistantParts | null {
|
|
98
|
+
let lastWorkIndex = -1
|
|
99
|
+
for (let i = parts.length - 1; i >= 0; i--) {
|
|
100
|
+
if (isRunPart(parts[i])) {
|
|
101
|
+
lastWorkIndex = i
|
|
102
|
+
break
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (lastWorkIndex < 0) return null
|
|
106
|
+
|
|
107
|
+
const response = parts.slice(lastWorkIndex + 1)
|
|
108
|
+
if (!hasVisibleResponse(response)) return null
|
|
109
|
+
return { work: parts.slice(0, lastWorkIndex + 1), response }
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
type AgentWorkDisclosureProps = {
|
|
113
|
+
parts: Part[]
|
|
114
|
+
cwd: string | null
|
|
115
|
+
durationMs?: number
|
|
116
|
+
defaultOpen?: boolean
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function AgentWorkDisclosure({
|
|
120
|
+
parts,
|
|
121
|
+
cwd,
|
|
122
|
+
durationMs,
|
|
123
|
+
defaultOpen
|
|
124
|
+
}: AgentWorkDisclosureProps) {
|
|
125
|
+
const label = durationMs === undefined ? 'Worked' : `Worked for ${formatDuration(durationMs)}`
|
|
126
|
+
return (
|
|
127
|
+
<Collapsible defaultOpen={defaultOpen} className="group/collapsible">
|
|
128
|
+
<CollapsibleTrigger className="flex w-fit items-center gap-1 rounded-sm py-1 text-left text-sm text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring">
|
|
129
|
+
<span>{label}</span>
|
|
130
|
+
<IconChevronRight
|
|
131
|
+
size={16}
|
|
132
|
+
stroke={1.5}
|
|
133
|
+
className="shrink-0 transition-transform group-data-open/collapsible:rotate-90"
|
|
134
|
+
/>
|
|
135
|
+
</CollapsibleTrigger>
|
|
136
|
+
<CollapsibleContent className="overflow-hidden pt-2">
|
|
137
|
+
<TurnParts parts={parts} cwd={cwd} />
|
|
138
|
+
</CollapsibleContent>
|
|
139
|
+
</Collapsible>
|
|
140
|
+
)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
type AssistantTurnPartsProps = {
|
|
144
|
+
parts: Part[]
|
|
145
|
+
cwd: string | null
|
|
146
|
+
processing?: boolean
|
|
147
|
+
durationMs?: number
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export function AssistantTurnParts({
|
|
151
|
+
parts,
|
|
152
|
+
cwd,
|
|
153
|
+
processing = false,
|
|
154
|
+
durationMs
|
|
155
|
+
}: AssistantTurnPartsProps) {
|
|
156
|
+
const completed = processing ? null : splitCompletedAssistantParts(parts)
|
|
157
|
+
|
|
158
|
+
return (
|
|
159
|
+
<div className="w-full min-w-0">
|
|
160
|
+
{processing ? (
|
|
161
|
+
<TurnParts parts={parts} cwd={cwd} processing />
|
|
162
|
+
) : completed ? (
|
|
163
|
+
<div className="flex flex-col gap-3">
|
|
164
|
+
<AgentWorkDisclosure parts={completed.work} cwd={cwd} durationMs={durationMs} />
|
|
165
|
+
<TurnParts parts={completed.response} cwd={cwd} />
|
|
166
|
+
</div>
|
|
167
|
+
) : (
|
|
168
|
+
<TurnParts parts={parts} cwd={cwd} />
|
|
169
|
+
)}
|
|
170
|
+
</div>
|
|
171
|
+
)
|
|
172
|
+
}
|
|
173
|
+
|
|
83
174
|
type TurnViewProps = { turn: Turn; processing?: boolean }
|
|
84
175
|
|
|
85
176
|
// Memoized: the message list maps over grouped turns (stable identities — see
|
|
@@ -88,14 +179,6 @@ type TurnViewProps = { turn: Turn; processing?: boolean }
|
|
|
88
179
|
export const TurnView = memo(function TurnView({ turn, processing = false }: TurnViewProps) {
|
|
89
180
|
const cwd = useWorkspaceLayoutCtx().cwd
|
|
90
181
|
|
|
91
|
-
if (turn.origin.kind === 'replay') return null
|
|
92
|
-
|
|
93
|
-
// The SKILL.md body is captured as the owning Skill tool call's `skill.body`
|
|
94
|
-
// and not surfaced in the scroll. Other synthetic turns (system reminders,
|
|
95
|
-
// hook output) and subagent prompts stay hidden by default.
|
|
96
|
-
if (turn.origin.kind === 'synthetic') return null
|
|
97
|
-
if (turn.origin.kind === 'subagent-prompt') return null
|
|
98
|
-
|
|
99
182
|
if (turn.role === 'user' && turn.origin.kind === 'user-input') {
|
|
100
183
|
// Plain user input — right-aligned. Attachments (images/files) stack above
|
|
101
184
|
// the text bubble.
|
|
@@ -108,12 +191,17 @@ export const TurnView = memo(function TurnView({ turn, processing = false }: Tur
|
|
|
108
191
|
.join('\n')
|
|
109
192
|
if (!text && fileParts.length === 0) return null
|
|
110
193
|
return (
|
|
111
|
-
<div className="
|
|
194
|
+
<div className="flex w-full min-w-0 flex-col items-end gap-1.5 pl-8">
|
|
112
195
|
{fileParts.map((p, i) => (
|
|
113
196
|
<FilePart key={i} mediaType={p.mediaType} url={p.url} filename={p.filename} />
|
|
114
197
|
))}
|
|
115
198
|
{text && (
|
|
116
|
-
<p
|
|
199
|
+
<p
|
|
200
|
+
className={cn(
|
|
201
|
+
'max-w-full min-w-0 rounded-lg bg-primary px-3 py-2 text-sm leading-normal wrap-anywhere whitespace-pre-wrap text-primary-foreground',
|
|
202
|
+
'inset-shadow-[0_0_10px_color-mix(in_oklab,var(--color-white)_30%,transparent)]'
|
|
203
|
+
)}
|
|
204
|
+
>
|
|
117
205
|
{text}
|
|
118
206
|
</p>
|
|
119
207
|
)}
|
|
@@ -121,7 +209,14 @@ export const TurnView = memo(function TurnView({ turn, processing = false }: Tur
|
|
|
121
209
|
)
|
|
122
210
|
}
|
|
123
211
|
|
|
124
|
-
return
|
|
212
|
+
return (
|
|
213
|
+
<AssistantTurnParts
|
|
214
|
+
parts={turn.parts}
|
|
215
|
+
cwd={cwd}
|
|
216
|
+
processing={processing}
|
|
217
|
+
durationMs={turn.meta?.durationMs}
|
|
218
|
+
/>
|
|
219
|
+
)
|
|
125
220
|
})
|
|
126
221
|
|
|
127
222
|
type PartRendererProps = { part: Part }
|
|
@@ -4,13 +4,7 @@ import { jsonRequest, requestJson, requestVoid } from '@/client/api/http'
|
|
|
4
4
|
import { WORKSPACE_RESOURCE_OPTIONS } from '@/client/api/query-options'
|
|
5
5
|
import { workspaceKeys } from '@/client/api/workspace-keys'
|
|
6
6
|
import { applyEvents } from '@/lib/format'
|
|
7
|
-
import type {
|
|
8
|
-
SessionConfig,
|
|
9
|
-
SessionInfo,
|
|
10
|
-
StreamEvent,
|
|
11
|
-
ViewState,
|
|
12
|
-
WorkspaceModels
|
|
13
|
-
} from '@/lib/types'
|
|
7
|
+
import type { SessionConfig, SessionInfo, StreamEvent, ViewState } from '@/lib/types'
|
|
14
8
|
|
|
15
9
|
export function useWorkspaceSessions(workspaceId: string) {
|
|
16
10
|
return useQuery<SessionInfo[]>({
|
|
@@ -63,17 +57,6 @@ export function useSessionView(workspaceId: string, sessionId: string | null) {
|
|
|
63
57
|
})
|
|
64
58
|
}
|
|
65
59
|
|
|
66
|
-
export function useWorkspaceModels(workspaceId: string) {
|
|
67
|
-
return useQuery<WorkspaceModels>({
|
|
68
|
-
queryKey: workspaceKeys.models(workspaceId),
|
|
69
|
-
queryFn: () => requestJson(`/api/workspaces/${workspaceId}/models`),
|
|
70
|
-
staleTime: Infinity,
|
|
71
|
-
gcTime: Infinity,
|
|
72
|
-
refetchOnMount: false,
|
|
73
|
-
refetchOnWindowFocus: false
|
|
74
|
-
})
|
|
75
|
-
}
|
|
76
|
-
|
|
77
60
|
export function useSessionConfig(workspaceId: string, sessionId: string | null) {
|
|
78
61
|
return useQuery<SessionConfig>({
|
|
79
62
|
queryKey: workspaceKeys.sessionConfig(workspaceId, sessionId ?? ''),
|
|
@@ -6,7 +6,7 @@ import type { MoiUserMessageOptions } from '@/client/features/workspace/moi-cont
|
|
|
6
6
|
import { STREAM_RESPONSES } from '@/client/lib/flags'
|
|
7
7
|
import { formatChatTitle } from '@/lib/chat-title'
|
|
8
8
|
import { applyEvent, emptyViewState } from '@/lib/format'
|
|
9
|
-
import type { Part, SessionInfo, ViewState,
|
|
9
|
+
import type { Part, SessionInfo, ViewState, WorkspaceAgent } from '@/lib/types'
|
|
10
10
|
|
|
11
11
|
// What a caller may attach to one message beyond its text. All of it is
|
|
12
12
|
// envelope material — the agent sees it, the chat bubble does not.
|
|
@@ -87,7 +87,7 @@ export function startOptimisticSession({
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
export function resolveChatRunOptions(
|
|
90
|
-
modelsData:
|
|
90
|
+
modelsData: WorkspaceAgent | undefined,
|
|
91
91
|
pickedModel: string | undefined,
|
|
92
92
|
pickedEffort: string | undefined,
|
|
93
93
|
pickedFastMode?: boolean
|