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,15 +1,23 @@
|
|
|
1
1
|
import { type RefObject, useRef, useState } from 'react'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
IconFile,
|
|
5
|
+
IconLoader2,
|
|
6
|
+
IconPaperclip,
|
|
7
|
+
IconPlayerStopFilled,
|
|
8
|
+
IconX
|
|
9
|
+
} from '@tabler/icons-react'
|
|
4
10
|
|
|
5
11
|
import {
|
|
6
12
|
canSubmitComposerAction,
|
|
13
|
+
type ComposerAvailability,
|
|
7
14
|
Composer,
|
|
8
15
|
ComposerFooter,
|
|
9
16
|
ComposerSubmitButton,
|
|
10
17
|
ComposerTextarea
|
|
11
18
|
} from '@/client/components/shared/Composer'
|
|
12
19
|
import { Button } from '@/client/components/ui/button'
|
|
20
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from '@/client/components/ui/tooltip'
|
|
13
21
|
import { cn } from '@/client/lib/cn'
|
|
14
22
|
import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
|
|
15
23
|
import { uploadFiles } from '@/client/features/chat/uploads'
|
|
@@ -21,7 +29,7 @@ import {
|
|
|
21
29
|
} from '@/client/features/chat/chat-store'
|
|
22
30
|
import { useUiStore } from '@/client/store/ui'
|
|
23
31
|
|
|
24
|
-
import { ModelPicker } from '
|
|
32
|
+
import { ModelPicker } from '../ModelPicker'
|
|
25
33
|
|
|
26
34
|
type ChatComposerProps = {
|
|
27
35
|
composerRef: RefObject<HTMLTextAreaElement | null>
|
|
@@ -29,7 +37,7 @@ type ChatComposerProps = {
|
|
|
29
37
|
onStop: () => void
|
|
30
38
|
processing: boolean
|
|
31
39
|
sessionId: string | null
|
|
32
|
-
|
|
40
|
+
availability: ComposerAvailability
|
|
33
41
|
}
|
|
34
42
|
|
|
35
43
|
// Draft text is persisted per workspace, while attachments remain ephemeral and
|
|
@@ -41,7 +49,7 @@ export function ChatComposer({
|
|
|
41
49
|
onStop,
|
|
42
50
|
processing,
|
|
43
51
|
sessionId,
|
|
44
|
-
|
|
52
|
+
availability
|
|
45
53
|
}: ChatComposerProps) {
|
|
46
54
|
const fileRef = useRef<HTMLInputElement>(null)
|
|
47
55
|
const workspaceId = useWorkspaceId()
|
|
@@ -52,7 +60,7 @@ export function ChatComposer({
|
|
|
52
60
|
const uploading = attachments.some(a => a.status === 'uploading')
|
|
53
61
|
const hasReady = attachments.some(a => a.status === 'ready')
|
|
54
62
|
const hasContent = value.trim().length > 0 || hasReady
|
|
55
|
-
const canSend = canSubmitComposerAction(hasContent, uploading,
|
|
63
|
+
const canSend = canSubmitComposerAction(hasContent, uploading, availability)
|
|
56
64
|
|
|
57
65
|
const onChange = (next: string) => useUiStore.getState().setComposerDraft(workspaceId, next)
|
|
58
66
|
|
|
@@ -176,15 +184,22 @@ export function ChatComposer({
|
|
|
176
184
|
</Button>
|
|
177
185
|
<ModelPicker />
|
|
178
186
|
{processing ? (
|
|
179
|
-
<
|
|
180
|
-
<
|
|
181
|
-
|
|
187
|
+
<Tooltip>
|
|
188
|
+
<TooltipTrigger
|
|
189
|
+
render={
|
|
190
|
+
<Button type="button" size="icon" onClick={onStop} aria-label="Stop agent">
|
|
191
|
+
<IconPlayerStopFilled />
|
|
192
|
+
</Button>
|
|
193
|
+
}
|
|
194
|
+
/>
|
|
195
|
+
<TooltipContent>Stop answering</TooltipContent>
|
|
196
|
+
</Tooltip>
|
|
182
197
|
) : (
|
|
183
198
|
<ComposerSubmitButton
|
|
184
199
|
label="Send message"
|
|
185
200
|
hasContent={hasContent}
|
|
186
201
|
busy={uploading}
|
|
187
|
-
|
|
202
|
+
availability={availability}
|
|
188
203
|
/>
|
|
189
204
|
)}
|
|
190
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
|
+
}
|
|
@@ -6,7 +6,7 @@ import { useUpdateWorkspaceSkills, useWorkspaceSkills } from '@/client/features/
|
|
|
6
6
|
import type {
|
|
7
7
|
WorkspaceSkillUpdateAction,
|
|
8
8
|
WorkspaceSkillUpdateBannerProps
|
|
9
|
-
} from './WorkspaceSkillUpdateBanner'
|
|
9
|
+
} from './banners/WorkspaceSkillUpdateBanner'
|
|
10
10
|
|
|
11
11
|
type VisitPhase = 'idle' | 'active' | 'dismissed'
|
|
12
12
|
|
|
@@ -1,44 +1,62 @@
|
|
|
1
|
-
// Visual
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
|
|
6
|
-
// with no text in between. Each turn renders as its own `<TurnView>` and
|
|
7
|
-
// inherits the wider inter-turn gap, which makes the chat feel sparse.
|
|
8
|
-
//
|
|
9
|
-
// This helper merges consecutive assistant turns into a single synthetic
|
|
10
|
-
// turn whenever they're "tool-only" — i.e. the joining turn has no `text`
|
|
11
|
-
// part. A turn that contains a `text` part *always* starts a new group.
|
|
12
|
-
// User turns, replays, and any non-assistant turn pass through unchanged.
|
|
13
|
-
//
|
|
14
|
-
// Key stability: the merged turn keeps the FIRST member's `id` (and `seq`,
|
|
15
|
-
// `timestamp`, `meta`, etc.). Live-stream upserts that update a member
|
|
16
|
-
// turn's parts (tool-result fold-in, optimistic-id rename) flow through
|
|
17
|
-
// without changing the merged group's key, so React's reconciliation
|
|
18
|
-
// updates in place. New turns appended later either join the same group
|
|
19
|
-
// (same key, more parts) or start a new one (their own id).
|
|
20
|
-
import type { Part, Turn } from '@/lib/types'
|
|
1
|
+
// Visual grouping on top of the raw `view.turns` stream. Providers serialize
|
|
2
|
+
// one agent run differently: Claude can mix several blocks in one assistant
|
|
3
|
+
// message, while Codex emits a separate item for every step. The chat renders
|
|
4
|
+
// consecutive assistant turns as one run so both shapes finish the same way.
|
|
5
|
+
import type { Turn } from '@/lib/types'
|
|
21
6
|
|
|
22
|
-
function
|
|
23
|
-
return
|
|
7
|
+
function isVisibleChatTurn(turn: Turn): boolean {
|
|
8
|
+
return (
|
|
9
|
+
turn.origin.kind !== 'replay' &&
|
|
10
|
+
turn.origin.kind !== 'synthetic' &&
|
|
11
|
+
turn.origin.kind !== 'subagent-prompt'
|
|
12
|
+
)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function mergeAssistantTurns(first: Turn, next: Turn): Turn {
|
|
16
|
+
const meta = first.meta || next.meta ? { ...first.meta, ...next.meta } : undefined
|
|
17
|
+
return {
|
|
18
|
+
...first,
|
|
19
|
+
parts: [...first.parts, ...next.parts],
|
|
20
|
+
timestamp: next.timestamp ?? first.timestamp,
|
|
21
|
+
meta
|
|
22
|
+
}
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
export function groupTurns(turns: Turn[]): Turn[] {
|
|
27
26
|
const out: Turn[] = []
|
|
28
27
|
for (const t of turns) {
|
|
28
|
+
if (!isVisibleChatTurn(t)) continue
|
|
29
29
|
if (t.role !== 'assistant') {
|
|
30
30
|
out.push(t)
|
|
31
31
|
continue
|
|
32
32
|
}
|
|
33
33
|
const last = out.length > 0 ? out[out.length - 1] : null
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
//
|
|
37
|
-
|
|
38
|
-
out[out.length - 1] = { ...last, parts: [...last.parts, ...t.parts] }
|
|
34
|
+
if (last?.role === 'assistant') {
|
|
35
|
+
// Keep the first id as the React key while carrying the latest timestamp
|
|
36
|
+
// and metadata forward for the completed run.
|
|
37
|
+
out[out.length - 1] = mergeAssistantTurns(last, t)
|
|
39
38
|
} else {
|
|
40
39
|
out.push(t)
|
|
41
40
|
}
|
|
42
41
|
}
|
|
43
|
-
return out
|
|
42
|
+
return out.map((turn, index) => {
|
|
43
|
+
const previous = out[index - 1]
|
|
44
|
+
if (
|
|
45
|
+
turn.role !== 'assistant' ||
|
|
46
|
+
previous?.role !== 'user' ||
|
|
47
|
+
previous.origin.kind !== 'user-input' ||
|
|
48
|
+
!previous.timestamp ||
|
|
49
|
+
!turn.timestamp
|
|
50
|
+
) {
|
|
51
|
+
return turn
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const startedAt = Date.parse(previous.timestamp)
|
|
55
|
+
const finishedAt = Date.parse(turn.timestamp)
|
|
56
|
+
if (!Number.isFinite(startedAt) || !Number.isFinite(finishedAt) || finishedAt < startedAt) {
|
|
57
|
+
return turn
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return { ...turn, meta: { ...turn.meta, durationMs: finishedAt - startedAt } }
|
|
61
|
+
})
|
|
44
62
|
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// Weaves transcript notices (context compaction, mid-session model switches)
|
|
2
|
+
// into the turn list so each one reads at the moment it happened.
|
|
3
|
+
//
|
|
4
|
+
// Only 'compact' and 'model-change' render today. Every other SystemNotice
|
|
5
|
+
// kind is claude-code-specific plumbing with no designed chat treatment yet,
|
|
6
|
+
// so `chatNoticeLabel` skips it explicitly.
|
|
7
|
+
import type { SystemNotice, Turn } from '@/lib/types'
|
|
8
|
+
|
|
9
|
+
export type ChatTimelineItem =
|
|
10
|
+
| { kind: 'turn'; turn: Turn }
|
|
11
|
+
| { kind: 'notice'; notice: SystemNotice }
|
|
12
|
+
|
|
13
|
+
// One-line copy for a notice row; null = this kind does not render in chat.
|
|
14
|
+
export function chatNoticeLabel(notice: SystemNotice): string | null {
|
|
15
|
+
switch (notice.kind) {
|
|
16
|
+
case 'compact':
|
|
17
|
+
return 'Context compacted'
|
|
18
|
+
case 'model-change':
|
|
19
|
+
return notice.prev
|
|
20
|
+
? `Model changed to ${notice.model} (was ${notice.prev})`
|
|
21
|
+
: `Model changed to ${notice.model}`
|
|
22
|
+
// Claude-code-specific notices without a designed chat treatment yet —
|
|
23
|
+
// skipped on purpose. New kinds stay hidden until designed.
|
|
24
|
+
case 'rate-limit':
|
|
25
|
+
case 'api-retry':
|
|
26
|
+
case 'hook':
|
|
27
|
+
case 'session-state':
|
|
28
|
+
case 'files-persisted':
|
|
29
|
+
case 'elicitation':
|
|
30
|
+
default:
|
|
31
|
+
return null
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function parseTime(value: string | undefined): number | undefined {
|
|
36
|
+
if (!value) return undefined
|
|
37
|
+
const time = Date.parse(value)
|
|
38
|
+
return Number.isNaN(time) ? undefined : time
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Merge renderable notices into the turn stream chronologically: a notice
|
|
42
|
+
// lands before the first turn strictly newer than its `at`. Turns keep their
|
|
43
|
+
// original order; a turn without a timestamp inherits the previous turn's, so
|
|
44
|
+
// notices never jump ahead of undated turns. Notices with no parseable `at`
|
|
45
|
+
// have no comparable anchor and go after the last turn.
|
|
46
|
+
//
|
|
47
|
+
// Known limitation — a transcript whose turns are ALL undated gives nothing to
|
|
48
|
+
// compare against, so every dated notice lands after the last turn. That is
|
|
49
|
+
// right while a session is live (compaction happens at the current end of the
|
|
50
|
+
// conversation) but drifts on replay: the notice follows the new end instead of
|
|
51
|
+
// staying where it happened. Codex hits this today — `codexItemToTurn` sets no
|
|
52
|
+
// `timestamp` and `codexItemToNotice` stamps `at` with replay-time `new Date()`
|
|
53
|
+
// — so fixing it means giving those rows a real anchor, not changing the merge.
|
|
54
|
+
export function interleaveNotices(turns: Turn[], notices: SystemNotice[]): ChatTimelineItem[] {
|
|
55
|
+
const shown = notices.filter(notice => chatNoticeLabel(notice) !== null)
|
|
56
|
+
if (shown.length === 0) return turns.map((turn): ChatTimelineItem => ({ kind: 'turn', turn }))
|
|
57
|
+
|
|
58
|
+
const dated: { notice: SystemNotice; time: number }[] = []
|
|
59
|
+
const anchorless: SystemNotice[] = []
|
|
60
|
+
for (const notice of shown) {
|
|
61
|
+
const time = parseTime(notice.at)
|
|
62
|
+
if (time === undefined) anchorless.push(notice)
|
|
63
|
+
else dated.push({ notice, time })
|
|
64
|
+
}
|
|
65
|
+
dated.sort((a, b) => a.time - b.time)
|
|
66
|
+
|
|
67
|
+
const out: ChatTimelineItem[] = []
|
|
68
|
+
let next = 0
|
|
69
|
+
let turnTime = Number.NEGATIVE_INFINITY
|
|
70
|
+
for (const turn of turns) {
|
|
71
|
+
turnTime = Math.max(turnTime, parseTime(turn.timestamp) ?? turnTime)
|
|
72
|
+
// `<=`: a notice stamped with the turn's own timestamp announces that
|
|
73
|
+
// turn (model-change carries the switching turn's time) and must render
|
|
74
|
+
// before it.
|
|
75
|
+
while (next < dated.length && dated[next].time <= turnTime) {
|
|
76
|
+
out.push({ kind: 'notice', notice: dated[next].notice })
|
|
77
|
+
next += 1
|
|
78
|
+
}
|
|
79
|
+
out.push({ kind: 'turn', turn })
|
|
80
|
+
}
|
|
81
|
+
for (; next < dated.length; next += 1) out.push({ kind: 'notice', notice: dated[next].notice })
|
|
82
|
+
for (const notice of anchorless) out.push({ kind: 'notice', notice })
|
|
83
|
+
return out
|
|
84
|
+
}
|
|
@@ -37,20 +37,26 @@ function stableSortModels(models: Model[], compare: ModelComparator): Model[] {
|
|
|
37
37
|
.map(({ model }) => model)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
// `modelDefault` is the provider's own resolved default for this model
|
|
41
|
+
// (OpenClaw `thinkingDefault`, which is `low` on one model and `off` on the
|
|
42
|
+
// next). It outranks the app-wide DEFAULT_EFFORT but never the user's pick.
|
|
40
43
|
export function resolveDisplayedEffort(
|
|
41
44
|
levels: readonly string[],
|
|
42
|
-
selectedEffort: string | undefined
|
|
45
|
+
selectedEffort: string | undefined,
|
|
46
|
+
modelDefault?: string
|
|
43
47
|
): string | undefined {
|
|
44
48
|
if (selectedEffort && levels.includes(selectedEffort)) return selectedEffort
|
|
49
|
+
if (modelDefault && levels.includes(modelDefault)) return modelDefault
|
|
45
50
|
if (levels.includes(DEFAULT_EFFORT)) return DEFAULT_EFFORT
|
|
46
51
|
return levels[levels.length - 1]
|
|
47
52
|
}
|
|
48
53
|
|
|
49
54
|
export function resolveEffortIndex(
|
|
50
55
|
levels: readonly string[],
|
|
51
|
-
selectedEffort: string | undefined
|
|
56
|
+
selectedEffort: string | undefined,
|
|
57
|
+
modelDefault?: string
|
|
52
58
|
): number {
|
|
53
|
-
const displayedEffort = resolveDisplayedEffort(levels, selectedEffort)
|
|
59
|
+
const displayedEffort = resolveDisplayedEffort(levels, selectedEffort, modelDefault)
|
|
54
60
|
return displayedEffort ? levels.indexOf(displayedEffort) : -1
|
|
55
61
|
}
|
|
56
62
|
|
|
@@ -41,31 +41,44 @@ export function TimelineRow({
|
|
|
41
41
|
isError = false,
|
|
42
42
|
children
|
|
43
43
|
}: TimelineRowProps) {
|
|
44
|
+
const hasLargeMarker = marker != null || loading
|
|
45
|
+
|
|
44
46
|
return (
|
|
45
47
|
<div className="relative flex gap-2.5">
|
|
46
48
|
{/* Odd rail width (13px) puts the centerline on a half-pixel, so a crisp
|
|
47
|
-
1px rule lands on a single pixel column instead of straddling two.
|
|
49
|
+
1px rule lands on a single pixel column instead of straddling two.
|
|
50
|
+
The split rule leaves a real gap around the node, so it works on any
|
|
51
|
+
surface without a background-colored halo. */}
|
|
48
52
|
<div className="relative w-[13px] shrink-0">
|
|
49
53
|
{!isFirst && (
|
|
50
|
-
<span
|
|
54
|
+
<span
|
|
55
|
+
className={cn(
|
|
56
|
+
'absolute top-0 left-1/2 w-px -translate-x-1/2 bg-border',
|
|
57
|
+
hasLargeMarker ? 'h-1' : 'h-2.5'
|
|
58
|
+
)}
|
|
59
|
+
/>
|
|
51
60
|
)}
|
|
52
61
|
{!isLast && (
|
|
53
|
-
<span
|
|
62
|
+
<span
|
|
63
|
+
className={cn(
|
|
64
|
+
'absolute bottom-0 left-1/2 w-px -translate-x-1/2 bg-border',
|
|
65
|
+
hasLargeMarker ? 'top-[26px]' : 'top-5'
|
|
66
|
+
)}
|
|
67
|
+
/>
|
|
54
68
|
)}
|
|
55
69
|
{marker ? (
|
|
56
70
|
<span className="absolute top-[15px] left-1/2 z-10 -translate-x-1/2 -translate-y-1/2">
|
|
57
71
|
{marker}
|
|
58
72
|
</span>
|
|
59
73
|
) : loading ? (
|
|
60
|
-
// A spinner node stands in for the dot
|
|
61
|
-
<span className="absolute top-[15px] left-1/2 z-10 flex -translate-x-1/2 -translate-y-1/2
|
|
74
|
+
// A spinner node stands in for the dot.
|
|
75
|
+
<span className="absolute top-[15px] left-1/2 z-10 flex -translate-x-1/2 -translate-y-1/2 p-0.5">
|
|
62
76
|
<IconLoader2 size={12} stroke={1.75} className="animate-spin text-muted-foreground" />
|
|
63
77
|
</span>
|
|
64
78
|
) : (
|
|
65
|
-
// Background-colored ring carves a gap in the rule around the dot.
|
|
66
79
|
<span
|
|
67
80
|
className={cn(
|
|
68
|
-
'absolute top-[15px] left-1/2 z-10 size-[5px] -translate-x-1/2 -translate-y-1/2 rounded-full
|
|
81
|
+
'absolute top-[15px] left-1/2 z-10 size-[5px] -translate-x-1/2 -translate-y-1/2 rounded-full',
|
|
69
82
|
isError ? 'bg-destructive' : 'bg-border'
|
|
70
83
|
)}
|
|
71
84
|
/>
|
|
@@ -95,14 +108,13 @@ export function RowChevron({ open }: { open: boolean }) {
|
|
|
95
108
|
)
|
|
96
109
|
}
|
|
97
110
|
|
|
98
|
-
// A rounded node box used as a timeline marker (size-4 by default).
|
|
99
|
-
//
|
|
100
|
-
// the skill node, and the (larger) subagent node; pass `className` to resize.
|
|
111
|
+
// A rounded node box used as a timeline marker (size-4 by default). Shared by the
|
|
112
|
+
// MCP logo, the skill node, and the (larger) subagent node; pass `className` to resize.
|
|
101
113
|
export function NodeBox({ children, className }: { children: ReactNode; className?: string }) {
|
|
102
114
|
return (
|
|
103
115
|
<span
|
|
104
116
|
className={cn(
|
|
105
|
-
'flex size-4 items-center justify-center overflow-hidden rounded-xs bg-muted
|
|
117
|
+
'flex size-4 items-center justify-center overflow-hidden rounded-xs bg-muted',
|
|
106
118
|
className
|
|
107
119
|
)}
|
|
108
120
|
>
|