moi-computer 0.8.0 → 0.9.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/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/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/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 +24 -7
- package/client/features/chat/MarkdownContent.tsx +1 -1
- 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} +6 -5
- 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 +51 -10
- package/client/features/chat/useAppletChatMessage.ts +11 -16
- package/client/features/chat/useChat.ts +3 -7
- package/client/features/dev/ChatStatesPage.tsx +466 -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/scratchpad/Scratchpad.tsx +4 -0
- package/client/features/scratchpad/scratch-session.ts +71 -0
- package/client/features/views/ViewBuilderTab.tsx +5 -4
- package/client/features/views/useViewBuilderActions.ts +2 -2
- package/client/features/workspace/WorkspaceLayoutContext.tsx +4 -2
- package/client/features/workspace/WorkspaceScreen.tsx +128 -146
- package/client/features/workspace/WorkspaceSplitLayout.tsx +111 -0
- package/client/features/workspace/api.ts +33 -8
- package/client/features/workspace/useFitsSplitLayout.ts +31 -5
- package/client/index.css +1 -1
- package/client/lib/flags.ts +4 -3
- package/client/runtime/useWorkspaceEvents.ts +18 -1
- package/client/store/ui.ts +5 -1
- package/dist/{chunk-0pcdwjkp.js → chunk-2vaafjp4.js} +1 -1
- package/dist/{chunk-9y2zbzqz.js → chunk-35fq49qa.js} +1 -1
- package/dist/{chunk-h9h8f176.js → chunk-3b3rkjet.js} +1 -1
- package/dist/chunk-gt7n06ef.js +1 -0
- package/dist/{chunk-r5ce5cdg.js → chunk-kkj86722.js} +75 -75
- package/dist/chunk-ty1sqbmn.js +80 -0
- package/dist/chunk-xeyxk7ep.js +10 -0
- package/dist/chunk-yz6wd5vc.css +1 -0
- package/dist/index.html +1 -1
- package/lib/format.ts +37 -7
- package/lib/themes.ts +2 -2
- package/lib/types.ts +38 -8
- package/lib/workspace-layout.ts +2 -2
- package/package.json +6 -4
- package/server/agent.ts +199 -0
- package/server/api.ts +36 -17
- package/server/bundler/build-applet.ts +35 -44
- package/server/cli-env.ts +2 -2
- package/server/cli.ts +39 -53
- package/server/constants.ts +8 -0
- package/server/control-client.ts +124 -0
- package/server/control.ts +2 -2
- package/server/env-apply.ts +4 -0
- package/server/harness/README.md +32 -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 +619 -186
- package/server/harness/openclaw/adapter.ts +121 -54
- package/server/harness/openclaw/compat.ts +95 -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 +1002 -67
- package/server/harness/openclaw/strip.ts +71 -23
- package/server/harness/openclaw/thinking.ts +150 -0
- package/server/harness/types.ts +10 -5
- package/server/layout.ts +5 -2
- package/server/service.ts +2 -2
- package/workspace/.claude/skills/moi-workspace/SKILL.md +6 -6
- package/workspace/.claude/skills/moi-workspace/{DESIGN.md → references/DESIGN.md} +19 -9
- package/client/features/dev/PixelPainter.tsx +0 -94
- package/client/features/dev/PlaygroundPage.tsx +0 -69
- package/dist/chunk-0k7brsms.js +0 -9
- package/dist/chunk-dfs36zgc.js +0 -1
- package/dist/chunk-dtwxpxbg.js +0 -51
- package/dist/chunk-ga7t9qsk.js +0 -2
- package/dist/chunk-tey2nq7c.js +0 -31
- package/dist/chunk-z73xpsa0.js +0 -50
- package/dist/chunk-zzgredta.css +0 -1
- /package/workspace/.claude/skills/moi-workspace/{SCRATCHPAD.md → references/SCRATCHPAD.md} +0 -0
|
@@ -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,7 +115,7 @@ 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'
|
|
@@ -110,7 +123,8 @@ function ChatSessionItem({
|
|
|
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
|
}
|
|
@@ -25,7 +25,7 @@ const components = {
|
|
|
25
25
|
},
|
|
26
26
|
pre({ children }: ComponentProps<'pre'>) {
|
|
27
27
|
return (
|
|
28
|
-
<div className="not-prose my-2 rounded-lg border border-border bg-
|
|
28
|
+
<div className="not-prose my-2 rounded-lg border border-border bg-[color-mix(var(--foreground)_5%,transparent)] px-3 py-2.5">
|
|
29
29
|
<pre className="overflow-auto font-mono text-xs leading-relaxed whitespace-pre text-foreground [&>code]:rounded-none [&>code]:bg-transparent [&>code]:p-0">
|
|
30
30
|
{children}
|
|
31
31
|
</pre>
|
|
@@ -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
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
|
|
11
11
|
import {
|
|
12
12
|
canSubmitComposerAction,
|
|
13
|
+
type ComposerAvailability,
|
|
13
14
|
Composer,
|
|
14
15
|
ComposerFooter,
|
|
15
16
|
ComposerSubmitButton,
|
|
@@ -28,7 +29,7 @@ import {
|
|
|
28
29
|
} from '@/client/features/chat/chat-store'
|
|
29
30
|
import { useUiStore } from '@/client/store/ui'
|
|
30
31
|
|
|
31
|
-
import { ModelPicker } from '
|
|
32
|
+
import { ModelPicker } from '../ModelPicker'
|
|
32
33
|
|
|
33
34
|
type ChatComposerProps = {
|
|
34
35
|
composerRef: RefObject<HTMLTextAreaElement | null>
|
|
@@ -36,7 +37,7 @@ type ChatComposerProps = {
|
|
|
36
37
|
onStop: () => void
|
|
37
38
|
processing: boolean
|
|
38
39
|
sessionId: string | null
|
|
39
|
-
|
|
40
|
+
availability: ComposerAvailability
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
// Draft text is persisted per workspace, while attachments remain ephemeral and
|
|
@@ -48,7 +49,7 @@ export function ChatComposer({
|
|
|
48
49
|
onStop,
|
|
49
50
|
processing,
|
|
50
51
|
sessionId,
|
|
51
|
-
|
|
52
|
+
availability
|
|
52
53
|
}: ChatComposerProps) {
|
|
53
54
|
const fileRef = useRef<HTMLInputElement>(null)
|
|
54
55
|
const workspaceId = useWorkspaceId()
|
|
@@ -59,7 +60,7 @@ export function ChatComposer({
|
|
|
59
60
|
const uploading = attachments.some(a => a.status === 'uploading')
|
|
60
61
|
const hasReady = attachments.some(a => a.status === 'ready')
|
|
61
62
|
const hasContent = value.trim().length > 0 || hasReady
|
|
62
|
-
const canSend = canSubmitComposerAction(hasContent, uploading,
|
|
63
|
+
const canSend = canSubmitComposerAction(hasContent, uploading, availability)
|
|
63
64
|
|
|
64
65
|
const onChange = (next: string) => useUiStore.getState().setComposerDraft(workspaceId, next)
|
|
65
66
|
|
|
@@ -198,7 +199,7 @@ export function ChatComposer({
|
|
|
198
199
|
label="Send message"
|
|
199
200
|
hasContent={hasContent}
|
|
200
201
|
busy={uploading}
|
|
201
|
-
|
|
202
|
+
availability={availability}
|
|
202
203
|
/>
|
|
203
204
|
)}
|
|
204
205
|
</ComposerFooter>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { IconX } from '@tabler/icons-react'
|
|
2
|
+
|
|
3
|
+
import { Button } from '@/client/components/ui/button'
|
|
4
|
+
|
|
5
|
+
import { ComposerBannerShell } from './ComposerBanner'
|
|
6
|
+
|
|
7
|
+
type ChatErrorBannerProps = {
|
|
8
|
+
error: string
|
|
9
|
+
onDismiss: () => void
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function ChatErrorBanner({ error, onDismiss }: ChatErrorBannerProps) {
|
|
13
|
+
return (
|
|
14
|
+
<ComposerBannerShell role="alert" className="flex items-center gap-2 text-destructive">
|
|
15
|
+
<span className="flex-1 wrap-break-word">{error}</span>
|
|
16
|
+
<Button
|
|
17
|
+
type="button"
|
|
18
|
+
variant="ghost"
|
|
19
|
+
size="icon-sm"
|
|
20
|
+
onClick={onDismiss}
|
|
21
|
+
className="text-destructive hover:text-destructive"
|
|
22
|
+
aria-label="Dismiss error"
|
|
23
|
+
>
|
|
24
|
+
<IconX stroke={1.75} />
|
|
25
|
+
</Button>
|
|
26
|
+
</ComposerBannerShell>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ComponentProps, ReactNode } from 'react'
|
|
2
|
+
|
|
3
|
+
import { cn } from '@/client/lib/cn'
|
|
4
|
+
|
|
5
|
+
export type ComposerBannerTone = 'muted' | 'destructive'
|
|
6
|
+
|
|
7
|
+
export type ComposerBanner = {
|
|
8
|
+
tone: ComposerBannerTone
|
|
9
|
+
content: ReactNode
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
type ComposerBannerCandidates = {
|
|
13
|
+
agentUnavailable?: ComposerBanner
|
|
14
|
+
chatError?: ComposerBanner
|
|
15
|
+
skillUpdate?: ComposerBanner
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function resolveComposerBanner({
|
|
19
|
+
agentUnavailable,
|
|
20
|
+
chatError,
|
|
21
|
+
skillUpdate
|
|
22
|
+
}: ComposerBannerCandidates): ComposerBanner | undefined {
|
|
23
|
+
return agentUnavailable ?? chatError ?? skillUpdate
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
type ComposerBannerShellProps = ComponentProps<'div'>
|
|
27
|
+
|
|
28
|
+
export function ComposerBannerShell({ className, ...props }: ComposerBannerShellProps) {
|
|
29
|
+
return <div {...props} className={cn('w-full p-2 text-sm @xl:p-1 @xl:pl-3', className)} />
|
|
30
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react'
|
|
2
|
+
|
|
3
|
+
import { IconLoader2, IconLogin } from '@tabler/icons-react'
|
|
4
|
+
|
|
5
|
+
import { Button } from '@/client/components/ui/button'
|
|
6
|
+
import type { AgentLoginState, HarnessAvailability, HarnessLogin } from '@/lib/types'
|
|
7
|
+
|
|
8
|
+
import { ComposerBannerShell } from './ComposerBanner'
|
|
9
|
+
|
|
10
|
+
type WorkspaceAgentAvailabilityBannerProps = {
|
|
11
|
+
availability: Extract<HarnessAvailability, { available: false }>
|
|
12
|
+
// The server-owned ceremony. `pending` means some tab (maybe this one)
|
|
13
|
+
// started a login and the server is watching for it to land; `failed` means
|
|
14
|
+
// the last ceremony timed out or errored.
|
|
15
|
+
login?: AgentLoginState
|
|
16
|
+
onStartLogin: () => Promise<HarnessLogin>
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function WorkspaceAgentAvailabilityBanner({
|
|
20
|
+
availability,
|
|
21
|
+
login,
|
|
22
|
+
onStartLogin
|
|
23
|
+
}: WorkspaceAgentAvailabilityBannerProps) {
|
|
24
|
+
// Local phase only bridges the gap between the POST resolving and the
|
|
25
|
+
// server's `agent:updated` event landing; the ceremony state is the truth.
|
|
26
|
+
const [phase, setPhase] = useState<'idle' | 'starting' | 'waiting'>('idle')
|
|
27
|
+
const [error, setError] = useState<string | null>(null)
|
|
28
|
+
|
|
29
|
+
// A settled ceremony (failed, or replaced by a fresh signed-out state)
|
|
30
|
+
// re-enables the button.
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (login?.state !== 'pending') setPhase('idle')
|
|
33
|
+
}, [login?.state])
|
|
34
|
+
|
|
35
|
+
const waiting = login?.state === 'pending' || phase === 'waiting'
|
|
36
|
+
const failure = login?.state === 'failed' ? login.reason : null
|
|
37
|
+
const busy = waiting || phase === 'starting'
|
|
38
|
+
|
|
39
|
+
const startLogin = async () => {
|
|
40
|
+
const authWindow = window.open('about:blank', 'moi-agent-login')
|
|
41
|
+
if (authWindow) authWindow.opener = null
|
|
42
|
+
setPhase('starting')
|
|
43
|
+
setError(null)
|
|
44
|
+
try {
|
|
45
|
+
const result = await onStartLogin()
|
|
46
|
+
if (result.url) {
|
|
47
|
+
if (!authWindow) throw new Error('Allow pop-ups, then try again')
|
|
48
|
+
authWindow.location.href = result.url
|
|
49
|
+
} else {
|
|
50
|
+
authWindow?.close()
|
|
51
|
+
}
|
|
52
|
+
setPhase('waiting')
|
|
53
|
+
} catch (err) {
|
|
54
|
+
authWindow?.close()
|
|
55
|
+
setPhase('idle')
|
|
56
|
+
setError(err instanceof Error ? err.message : 'Could not start sign-in')
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<ComposerBannerShell
|
|
62
|
+
role="alert"
|
|
63
|
+
className="grid grid-cols-[auto_minmax(0,1fr)] gap-2 @xl:grid-cols-[auto_minmax(0,1fr)_auto] @xl:items-center"
|
|
64
|
+
>
|
|
65
|
+
<IconLogin size={20} stroke={1.5} />
|
|
66
|
+
<div className="min-w-0 space-y-1">
|
|
67
|
+
<div className="wrap-break-word">Log in to your agent provider to send messages</div>
|
|
68
|
+
{(error ?? failure) && (
|
|
69
|
+
<div className="wrap-break-word text-destructive">{error ?? failure}</div>
|
|
70
|
+
)}
|
|
71
|
+
</div>
|
|
72
|
+
|
|
73
|
+
{availability.loginCommand && (
|
|
74
|
+
<Button
|
|
75
|
+
type="button"
|
|
76
|
+
size="sm"
|
|
77
|
+
onClick={() => void startLogin()}
|
|
78
|
+
disabled={busy}
|
|
79
|
+
className="col-span-2 w-fit @xl:col-span-1"
|
|
80
|
+
>
|
|
81
|
+
{busy && <IconLoader2 stroke={1.75} className="animate-spin" />}
|
|
82
|
+
{phase === 'starting'
|
|
83
|
+
? 'Opening browser to sign in…'
|
|
84
|
+
: waiting
|
|
85
|
+
? 'Waiting for log in…'
|
|
86
|
+
: 'Log in'}
|
|
87
|
+
</Button>
|
|
88
|
+
)}
|
|
89
|
+
</ComposerBannerShell>
|
|
90
|
+
)
|
|
91
|
+
}
|
|
@@ -3,6 +3,8 @@ import { IconFolderExclamation, IconLoader2, IconX } from '@tabler/icons-react'
|
|
|
3
3
|
import { Button } from '@/client/components/ui/button'
|
|
4
4
|
import { cn } from '@/client/lib/cn'
|
|
5
5
|
|
|
6
|
+
import { ComposerBannerShell } from './ComposerBanner'
|
|
7
|
+
|
|
6
8
|
export type WorkspaceSkillUpdateAction = 'auto' | 'once'
|
|
7
9
|
|
|
8
10
|
export type WorkspaceSkillUpdateBannerProps = {
|
|
@@ -20,24 +22,24 @@ export function WorkspaceSkillUpdateBanner({
|
|
|
20
22
|
}: WorkspaceSkillUpdateBannerProps) {
|
|
21
23
|
if (!error && pendingAction === 'auto') {
|
|
22
24
|
return (
|
|
23
|
-
<
|
|
25
|
+
<ComposerBannerShell
|
|
24
26
|
role="status"
|
|
25
|
-
className="flex
|
|
27
|
+
className="flex items-center gap-1.5 text-muted-foreground"
|
|
26
28
|
>
|
|
27
29
|
<IconLoader2 size={20} stroke={1.5} className="shrink-0 animate-spin" />
|
|
28
30
|
<span className="wrap-break-word">Updating moi skills…</span>
|
|
29
|
-
</
|
|
31
|
+
</ComposerBannerShell>
|
|
30
32
|
)
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
const pending = pendingAction !== null
|
|
34
36
|
|
|
35
37
|
return (
|
|
36
|
-
<
|
|
38
|
+
<ComposerBannerShell
|
|
37
39
|
role={error ? 'alert' : 'status'}
|
|
38
40
|
className={cn(
|
|
39
|
-
'grid
|
|
40
|
-
'@xl:flex @xl:items-center
|
|
41
|
+
'grid grid-cols-[minmax(0,1fr)_auto] gap-x-2 gap-y-2',
|
|
42
|
+
'@xl:flex @xl:items-center',
|
|
41
43
|
error && 'text-destructive'
|
|
42
44
|
)}
|
|
43
45
|
>
|
|
@@ -86,6 +88,6 @@ export function WorkspaceSkillUpdateBanner({
|
|
|
86
88
|
{pendingAction === 'once' ? 'Updating…' : 'Update once'}
|
|
87
89
|
</Button>
|
|
88
90
|
</div>
|
|
89
|
-
</
|
|
91
|
+
</ComposerBannerShell>
|
|
90
92
|
)
|
|
91
93
|
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { ComposerAvailability } from '@/client/components/shared/Composer'
|
|
2
|
+
import { startWorkspaceLogin, useWorkspaceAgent } from '@/client/features/workspace/api'
|
|
3
|
+
|
|
4
|
+
import { ChatErrorBanner } from './banners/ChatErrorBanner'
|
|
5
|
+
import { resolveComposerBanner, type ComposerBanner } from './banners/ComposerBanner'
|
|
6
|
+
import { WorkspaceAgentAvailabilityBanner } from './banners/WorkspaceAgentAvailabilityBanner'
|
|
7
|
+
import { WorkspaceSkillUpdateBanner } from './banners/WorkspaceSkillUpdateBanner'
|
|
8
|
+
import { useWorkspaceSkillUpdates } from './useWorkspaceSkillUpdates'
|
|
9
|
+
|
|
10
|
+
type WorkspaceComposerStateOptions = {
|
|
11
|
+
chatError: string | null
|
|
12
|
+
onDismissChatError: () => void
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type WorkspaceComposerState = {
|
|
16
|
+
composerBanner?: ComposerBanner
|
|
17
|
+
composerAvailability: ComposerAvailability
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function useWorkspaceComposerState(
|
|
21
|
+
workspaceId: string,
|
|
22
|
+
{ chatError, onDismissChatError }: WorkspaceComposerStateOptions
|
|
23
|
+
): WorkspaceComposerState {
|
|
24
|
+
const { data: agent, error } = useWorkspaceAgent(workspaceId)
|
|
25
|
+
const availability = agent?.availability
|
|
26
|
+
const { bannerProps: skillUpdateBanner } = useWorkspaceSkillUpdates(workspaceId)
|
|
27
|
+
|
|
28
|
+
let unavailable = availability?.available === false ? availability : undefined
|
|
29
|
+
if (error) {
|
|
30
|
+
unavailable = {
|
|
31
|
+
available: false,
|
|
32
|
+
reason: `Could not check agent status: ${error.message}`
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
let composerAvailability: ComposerAvailability = { status: 'checking' }
|
|
37
|
+
if (unavailable) {
|
|
38
|
+
composerAvailability = { status: 'unavailable' }
|
|
39
|
+
} else if (availability) {
|
|
40
|
+
composerAvailability = { status: 'available' }
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const agentUnavailableBanner: ComposerBanner | undefined = unavailable
|
|
44
|
+
? {
|
|
45
|
+
tone: 'muted',
|
|
46
|
+
content: (
|
|
47
|
+
<WorkspaceAgentAvailabilityBanner
|
|
48
|
+
availability={unavailable}
|
|
49
|
+
login={agent?.login}
|
|
50
|
+
onStartLogin={() => startWorkspaceLogin(workspaceId)}
|
|
51
|
+
/>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
: undefined
|
|
55
|
+
const chatErrorBanner: ComposerBanner | undefined = chatError
|
|
56
|
+
? {
|
|
57
|
+
tone: 'destructive',
|
|
58
|
+
content: <ChatErrorBanner error={chatError} onDismiss={onDismissChatError} />
|
|
59
|
+
}
|
|
60
|
+
: undefined
|
|
61
|
+
const skillUpdate: ComposerBanner | undefined = skillUpdateBanner
|
|
62
|
+
? {
|
|
63
|
+
tone: 'muted',
|
|
64
|
+
content: <WorkspaceSkillUpdateBanner {...skillUpdateBanner} />
|
|
65
|
+
}
|
|
66
|
+
: undefined
|
|
67
|
+
const composerBanner = resolveComposerBanner({
|
|
68
|
+
agentUnavailable: agentUnavailableBanner,
|
|
69
|
+
chatError: chatErrorBanner,
|
|
70
|
+
skillUpdate
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
return { composerAvailability, composerBanner }
|
|
74
|
+
}
|