moi-computer 0.5.2-next.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/AGENTS.md +9 -0
- package/client/api/app-ui-keys.ts +4 -0
- package/client/api/workspace-keys.ts +2 -2
- package/client/app/routes/WorkspaceRoute.tsx +8 -28
- package/client/app/shell/SidebarLayout.tsx +1 -1
- package/client/components/shared/Composer.tsx +15 -9
- package/client/components/shared/IconGhost.tsx +130 -0
- package/client/components/ui/dropdown-menu.tsx +2 -5
- package/client/components/ui/popover.tsx +11 -4
- package/client/components/ui/slider.tsx +70 -0
- package/client/components/ui/spinner.tsx +18 -0
- package/client/components/ui/toast.tsx +220 -0
- package/client/components/ui/tooltip.tsx +1 -1
- package/client/features/chat/ChatComposer.tsx +11 -14
- package/client/features/chat/ChatPanel.tsx +15 -14
- package/client/features/chat/ChatPopup.tsx +10 -4
- package/client/features/chat/ChatSelector.tsx +263 -48
- package/client/features/chat/ModelPicker.tsx +295 -121
- package/client/features/chat/TurnView.tsx +1 -1
- package/client/features/chat/api.ts +36 -9
- package/client/features/chat/chat-frames.ts +35 -6
- package/client/features/chat/chat-send.ts +40 -6
- package/client/features/chat/chat-store.ts +52 -40
- package/client/features/chat/model-order.ts +50 -28
- package/client/features/chat/useChat.ts +71 -60
- package/client/features/chat/useSelectedSession.ts +151 -0
- package/client/features/chat/useStickToBottom.ts +3 -3
- package/client/features/home/api.ts +0 -2
- package/client/features/scratchpad/ScratchpadControls.tsx +2 -2
- package/client/features/settings/IconPicker.tsx +2 -2
- package/client/features/settings/WorkspaceSettings.tsx +6 -6
- package/client/features/views/ViewBuilderTab.tsx +3 -4
- package/client/features/views/api.ts +1 -0
- package/client/features/views/useViewBuilderActions.ts +7 -3
- package/client/features/workspace/WorkspaceScreen.tsx +40 -19
- package/client/features/workspace/WorkspaceSkillUpdateBanner.tsx +2 -2
- package/client/features/workspace/WorkspaceTabs.tsx +10 -1
- package/client/index.css +5 -3
- package/client/main.tsx +2 -0
- package/client/runtime/useWorkspaceEvents.ts +1 -0
- package/client/store/ui.ts +13 -3
- package/dist/{chunk-m9qja0nx.js → chunk-0pcdwjkp.js} +1 -1
- package/dist/chunk-55sh4dty.js +2 -0
- package/dist/{chunk-h3evrtyp.js → chunk-9y2zbzqz.js} +1 -1
- package/dist/{chunk-7bzpmtxp.js → chunk-afgbg75t.js} +1 -1
- package/dist/chunk-agtetn7n.css +1 -0
- package/dist/chunk-bv6vrvqf.js +27 -0
- package/dist/chunk-dfs36zgc.js +1 -0
- package/dist/chunk-exj6hr30.js +9 -0
- package/dist/{chunk-v797g6ap.js → chunk-m11ckkxd.js} +1 -1
- package/dist/chunk-n6t40enm.js +1 -0
- package/dist/{chunk-jg6ezptn.js → chunk-rxvx4ta9.js} +3 -3
- package/dist/index.html +1 -1
- package/lib/attachment-note.ts +18 -0
- package/lib/chat-title.ts +6 -0
- package/lib/types.ts +33 -10
- package/package.json +1 -1
- package/server/api.ts +100 -10
- package/server/app-settings.ts +1 -1
- package/server/data-dir.ts +1 -1
- package/server/harness/README.md +6 -0
- package/server/harness/claude-code/adapter.ts +2 -2
- package/server/harness/claude-code/index.ts +7 -1
- package/server/harness/claude-code/models.ts +25 -2
- package/server/harness/claude-code/session-title.ts +106 -0
- package/server/harness/claude-code/session.ts +114 -17
- package/server/harness/claude-code/sessions.ts +35 -4
- package/server/harness/codex/adapter.ts +27 -2
- package/server/harness/codex/client.ts +56 -9
- package/server/harness/codex/index.ts +2 -0
- package/server/harness/codex/session-title.ts +149 -0
- package/server/harness/codex/session.ts +96 -14
- package/server/harness/openclaw/adapter.ts +4 -2
- package/server/harness/openclaw/discovery.ts +2 -0
- package/server/harness/openclaw/session.ts +15 -7
- package/server/harness/session-title.ts +96 -0
- package/server/harness/types.ts +5 -2
- package/server/selected-session.ts +132 -0
- package/server/session-config.ts +146 -0
- package/server/web.ts +15 -1
- package/workspace/.claude/skills/moi-workspace/DESIGN.md +54 -68
- package/workspace/.claude/skills/moi-workspace/SKILL.md +8 -2
- package/dist/chunk-5vaevt8z.js +0 -2
- package/dist/chunk-fhhv99bd.js +0 -1
- package/dist/chunk-h0hk61pm.js +0 -9
- package/dist/chunk-k5sjx9s5.js +0 -1
- package/dist/chunk-rs9nb0fr.js +0 -27
- package/dist/chunk-s7za1qsv.css +0 -1
- package/server/thread-config.ts +0 -124
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { Toast as ToastPrimitive } from '@base-ui/react/toast'
|
|
3
|
+
|
|
4
|
+
import { cn } from '@/client/lib/cn'
|
|
5
|
+
import { Button } from '@/client/components/ui/button'
|
|
6
|
+
import {
|
|
7
|
+
IconX,
|
|
8
|
+
IconCircleCheck,
|
|
9
|
+
IconInfoCircle,
|
|
10
|
+
IconAlertTriangle,
|
|
11
|
+
IconAlertOctagon,
|
|
12
|
+
IconLoader
|
|
13
|
+
} from '@tabler/icons-react'
|
|
14
|
+
|
|
15
|
+
const toast = ToastPrimitive.createToastManager()
|
|
16
|
+
|
|
17
|
+
function ToastProvider({ ...props }: ToastPrimitive.Provider.Props) {
|
|
18
|
+
return <ToastPrimitive.Provider {...props} />
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function ToastPortal({ ...props }: ToastPrimitive.Portal.Props) {
|
|
22
|
+
return <ToastPrimitive.Portal data-slot="toast-portal" {...props} />
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function ToastViewport({ className, ...props }: ToastPrimitive.Viewport.Props) {
|
|
26
|
+
return (
|
|
27
|
+
<ToastPrimitive.Viewport
|
|
28
|
+
data-slot="toast-viewport"
|
|
29
|
+
className={cn(
|
|
30
|
+
'pointer-events-none fixed inset-x-4 bottom-4 z-50 mx-auto w-auto max-w-sm outline-none sm:right-4 sm:left-auto sm:mx-0 sm:w-full',
|
|
31
|
+
className
|
|
32
|
+
)}
|
|
33
|
+
{...props}
|
|
34
|
+
/>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function Toast({ className, ...props }: ToastPrimitive.Root.Props) {
|
|
39
|
+
return (
|
|
40
|
+
<ToastPrimitive.Root
|
|
41
|
+
data-slot="toast"
|
|
42
|
+
className={cn(
|
|
43
|
+
'group/toast pointer-events-auto absolute right-0 bottom-0 z-[calc(1000-var(--toast-index))] w-full origin-bottom rounded-2xl border bg-popover text-popover-foreground shadow-lg will-change-transform outline-none select-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50',
|
|
44
|
+
'[--gap:0.75rem] [--height:var(--toast-frontmost-height,var(--toast-height))] [--offset-y:calc(var(--toast-offset-y)*-1+calc(var(--toast-index)*var(--gap)*-1)+var(--toast-swipe-movement-y))] [--peek:0.75rem] [--scale:calc(max(0,1-(var(--toast-index)*0.1)))] [--shrink:calc(1-var(--scale))]',
|
|
45
|
+
'h-(--height) [transform:translateX(var(--toast-swipe-movement-x))_translateY(calc(var(--toast-swipe-movement-y)-(var(--toast-index)*var(--peek))-(var(--shrink)*var(--height))))_scale(var(--scale))] [transition:transform_500ms_cubic-bezier(0.22,1,0.36,1),opacity_500ms,height_150ms]',
|
|
46
|
+
"after:absolute after:top-full after:left-0 after:h-[calc(var(--gap)+1px)] after:w-full after:content-['']",
|
|
47
|
+
'data-expanded:h-(--toast-height) data-expanded:[transform:translateX(var(--toast-swipe-movement-x))_translateY(var(--offset-y))]',
|
|
48
|
+
'data-limited:opacity-0 data-starting-style:[transform:translateY(150%)]',
|
|
49
|
+
'[&[data-ending-style]:not([data-limited]):not([data-swipe-direction])]:[transform:translateY(150%)]',
|
|
50
|
+
'data-ending-style:data-[swipe-direction=down]:[transform:translateY(calc(var(--toast-swipe-movement-y)+150%))]',
|
|
51
|
+
'data-ending-style:data-[swipe-direction=left]:[transform:translateX(calc(var(--toast-swipe-movement-x)-150%))_translateY(var(--offset-y))]',
|
|
52
|
+
'data-ending-style:data-[swipe-direction=right]:[transform:translateX(calc(var(--toast-swipe-movement-x)+150%))_translateY(var(--offset-y))]',
|
|
53
|
+
'data-ending-style:data-[swipe-direction=up]:[transform:translateY(calc(var(--toast-swipe-movement-y)-150%))]',
|
|
54
|
+
'data-expanded:data-ending-style:data-[swipe-direction=down]:[transform:translateY(calc(var(--toast-swipe-movement-y)+150%))]',
|
|
55
|
+
'data-expanded:data-ending-style:data-[swipe-direction=left]:[transform:translateX(calc(var(--toast-swipe-movement-x)-150%))_translateY(var(--offset-y))]',
|
|
56
|
+
'data-expanded:data-ending-style:data-[swipe-direction=right]:[transform:translateX(calc(var(--toast-swipe-movement-x)+150%))_translateY(var(--offset-y))]',
|
|
57
|
+
'data-expanded:data-ending-style:data-[swipe-direction=up]:[transform:translateY(calc(var(--toast-swipe-movement-y)-150%))]',
|
|
58
|
+
className
|
|
59
|
+
)}
|
|
60
|
+
{...props}
|
|
61
|
+
/>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function ToastContent({ className, ...props }: ToastPrimitive.Content.Props) {
|
|
66
|
+
return (
|
|
67
|
+
<ToastPrimitive.Content
|
|
68
|
+
data-slot="toast-content"
|
|
69
|
+
className={cn(
|
|
70
|
+
'flex h-full items-center gap-3 overflow-hidden p-4 transition-opacity duration-250 ease-[cubic-bezier(0.22,1,0.36,1)] data-behind:opacity-0 data-expanded:opacity-100',
|
|
71
|
+
className
|
|
72
|
+
)}
|
|
73
|
+
{...props}
|
|
74
|
+
/>
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function ToastTitle({ className, ...props }: ToastPrimitive.Title.Props) {
|
|
79
|
+
return (
|
|
80
|
+
<ToastPrimitive.Title
|
|
81
|
+
data-slot="toast-title"
|
|
82
|
+
className={cn('text-sm font-medium', className)}
|
|
83
|
+
{...props}
|
|
84
|
+
/>
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function ToastDescription({ className, ...props }: ToastPrimitive.Description.Props) {
|
|
89
|
+
return (
|
|
90
|
+
<ToastPrimitive.Description
|
|
91
|
+
data-slot="toast-description"
|
|
92
|
+
className={cn('text-sm text-muted-foreground', className)}
|
|
93
|
+
{...props}
|
|
94
|
+
/>
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function ToastAction({
|
|
99
|
+
className,
|
|
100
|
+
render = <Button variant="outline" size="sm" />,
|
|
101
|
+
...props
|
|
102
|
+
}: ToastPrimitive.Action.Props) {
|
|
103
|
+
return (
|
|
104
|
+
<ToastPrimitive.Action
|
|
105
|
+
data-slot="toast-action"
|
|
106
|
+
render={render}
|
|
107
|
+
className={cn('shrink-0', className)}
|
|
108
|
+
{...props}
|
|
109
|
+
/>
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function ToastClose({
|
|
114
|
+
className,
|
|
115
|
+
children,
|
|
116
|
+
render = <Button variant="ghost" size="icon-sm" />,
|
|
117
|
+
...props
|
|
118
|
+
}: ToastPrimitive.Close.Props) {
|
|
119
|
+
return (
|
|
120
|
+
<ToastPrimitive.Close
|
|
121
|
+
data-slot="toast-close"
|
|
122
|
+
aria-label="Close toast"
|
|
123
|
+
render={render}
|
|
124
|
+
className={cn(
|
|
125
|
+
"relative shrink-0 text-muted-foreground after:absolute after:-inset-2 after:content-[''] hover:text-foreground",
|
|
126
|
+
className
|
|
127
|
+
)}
|
|
128
|
+
{...props}
|
|
129
|
+
>
|
|
130
|
+
{children ?? <IconX aria-hidden="true" stroke={1.75} />}
|
|
131
|
+
</ToastPrimitive.Close>
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function ToastIcon({ type }: { type: string | undefined }) {
|
|
136
|
+
let icon: React.ReactNode = null
|
|
137
|
+
|
|
138
|
+
if (type === 'success') {
|
|
139
|
+
icon = <IconCircleCheck aria-hidden="true" stroke={1.75} />
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (type === 'info') {
|
|
143
|
+
icon = <IconInfoCircle aria-hidden="true" stroke={1.75} />
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (type === 'warning') {
|
|
147
|
+
icon = <IconAlertTriangle aria-hidden="true" stroke={1.75} />
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (type === 'error') {
|
|
151
|
+
icon = <IconAlertOctagon className="text-destructive" aria-hidden="true" stroke={1.75} />
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (type === 'loading') {
|
|
155
|
+
icon = <IconLoader className="animate-spin" aria-hidden="true" stroke={1.75} />
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (!icon) {
|
|
159
|
+
return null
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return (
|
|
163
|
+
<span
|
|
164
|
+
data-slot="toast-icon"
|
|
165
|
+
className="shrink-0 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4"
|
|
166
|
+
>
|
|
167
|
+
{icon}
|
|
168
|
+
</span>
|
|
169
|
+
)
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function ToastList() {
|
|
173
|
+
const { toasts } = ToastPrimitive.useToastManager()
|
|
174
|
+
|
|
175
|
+
return toasts.map(toastItem => (
|
|
176
|
+
<Toast key={toastItem.id} toast={toastItem}>
|
|
177
|
+
<ToastContent>
|
|
178
|
+
<ToastIcon type={toastItem.type} />
|
|
179
|
+
<div className="flex min-w-0 flex-1 flex-col gap-1">
|
|
180
|
+
<ToastTitle />
|
|
181
|
+
<ToastDescription />
|
|
182
|
+
</div>
|
|
183
|
+
<ToastAction />
|
|
184
|
+
<ToastClose />
|
|
185
|
+
</ToastContent>
|
|
186
|
+
</Toast>
|
|
187
|
+
))
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function Toaster({ children, toastManager = toast, ...props }: ToastPrimitive.Provider.Props) {
|
|
191
|
+
return (
|
|
192
|
+
<ToastProvider toastManager={toastManager} {...props}>
|
|
193
|
+
{children}
|
|
194
|
+
<ToastPortal>
|
|
195
|
+
<ToastViewport>
|
|
196
|
+
<ToastList />
|
|
197
|
+
</ToastViewport>
|
|
198
|
+
</ToastPortal>
|
|
199
|
+
</ToastProvider>
|
|
200
|
+
)
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const createToastManager = ToastPrimitive.createToastManager
|
|
204
|
+
const useToastManager = ToastPrimitive.useToastManager
|
|
205
|
+
|
|
206
|
+
export {
|
|
207
|
+
Toaster,
|
|
208
|
+
Toast,
|
|
209
|
+
ToastAction,
|
|
210
|
+
ToastClose,
|
|
211
|
+
ToastContent,
|
|
212
|
+
ToastDescription,
|
|
213
|
+
ToastPortal,
|
|
214
|
+
ToastProvider,
|
|
215
|
+
ToastTitle,
|
|
216
|
+
ToastViewport,
|
|
217
|
+
createToastManager,
|
|
218
|
+
toast,
|
|
219
|
+
useToastManager
|
|
220
|
+
}
|
|
@@ -36,7 +36,7 @@ function TooltipContent({
|
|
|
36
36
|
<TooltipPrimitive.Popup
|
|
37
37
|
data-slot="tooltip-content"
|
|
38
38
|
className={cn(
|
|
39
|
-
'z-50 w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-lg bg-popover px-2.5 py-1.5 text-xs font-medium text-popover-foreground shadow-md has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-lg data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
|
|
39
|
+
'z-50 flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-lg bg-popover px-2.5 py-1.5 text-xs font-medium text-popover-foreground shadow-md has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-lg data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
|
|
40
40
|
className
|
|
41
41
|
)}
|
|
42
42
|
{...props}
|
|
@@ -15,10 +15,11 @@ import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
|
|
|
15
15
|
import { uploadFiles } from '@/client/features/chat/uploads'
|
|
16
16
|
import {
|
|
17
17
|
type ChatAttachment,
|
|
18
|
-
|
|
18
|
+
attachmentKey,
|
|
19
19
|
liveStore,
|
|
20
20
|
useLive
|
|
21
21
|
} from '@/client/features/chat/chat-store'
|
|
22
|
+
import { useUiStore } from '@/client/store/ui'
|
|
22
23
|
|
|
23
24
|
import { ModelPicker } from './ModelPicker'
|
|
24
25
|
|
|
@@ -27,26 +28,25 @@ type ChatComposerProps = {
|
|
|
27
28
|
onSend: (text: string) => void
|
|
28
29
|
onStop: () => void
|
|
29
30
|
processing: boolean
|
|
31
|
+
sessionId: string | null
|
|
30
32
|
unavailableReason: string | null | undefined
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
//
|
|
34
|
-
//
|
|
35
|
-
//
|
|
36
|
-
// active thread, so switching threads swaps the unsent text with you. Attachments
|
|
37
|
-
// (drag/drop, paste, attach button) are tracked the same way and cleared on send.
|
|
35
|
+
// Draft text is persisted per workspace, while attachments remain ephemeral and
|
|
36
|
+
// follow the selected chat. Both stores are subscribed here so a keystroke or
|
|
37
|
+
// upload re-renders only the composer.
|
|
38
38
|
export function ChatComposer({
|
|
39
39
|
composerRef,
|
|
40
40
|
onSend,
|
|
41
41
|
onStop,
|
|
42
42
|
processing,
|
|
43
|
+
sessionId,
|
|
43
44
|
unavailableReason
|
|
44
45
|
}: ChatComposerProps) {
|
|
45
46
|
const fileRef = useRef<HTMLInputElement>(null)
|
|
46
47
|
const workspaceId = useWorkspaceId()
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
const attachments = useLive(s => s.attachments[draftKey(workspaceId, sessionId)] ?? EMPTY)
|
|
48
|
+
const value = useUiStore(s => s.composerDrafts[workspaceId] ?? '')
|
|
49
|
+
const attachments = useLive(s => s.attachments[attachmentKey(workspaceId, sessionId)] ?? EMPTY)
|
|
50
50
|
const [dragOver, setDragOver] = useState(false)
|
|
51
51
|
|
|
52
52
|
const uploading = attachments.some(a => a.status === 'uploading')
|
|
@@ -54,7 +54,7 @@ export function ChatComposer({
|
|
|
54
54
|
const hasContent = value.trim().length > 0 || hasReady
|
|
55
55
|
const canSend = canSubmitComposerAction(hasContent, uploading, unavailableReason)
|
|
56
56
|
|
|
57
|
-
const onChange = (next: string) =>
|
|
57
|
+
const onChange = (next: string) => useUiStore.getState().setComposerDraft(workspaceId, next)
|
|
58
58
|
|
|
59
59
|
// Upload each picked file immediately, tracking its in-flight status so the
|
|
60
60
|
// thumbnail row can show a spinner / error per file.
|
|
@@ -90,10 +90,7 @@ export function ChatComposer({
|
|
|
90
90
|
const send = () => {
|
|
91
91
|
if (!canSend) return
|
|
92
92
|
onSend(value)
|
|
93
|
-
|
|
94
|
-
// this clears the `'new'` draft; `send` then mints the real id and the input
|
|
95
|
-
// re-renders empty under the new key. (Attachments are cleared by `send`.)
|
|
96
|
-
liveStore.getState().setDraft(workspaceId, sessionId, '')
|
|
93
|
+
useUiStore.getState().setComposerDraft(workspaceId, '')
|
|
97
94
|
}
|
|
98
95
|
|
|
99
96
|
return (
|
|
@@ -2,10 +2,10 @@ import { type ReactNode, useCallback, useEffect, useLayoutEffect, useMemo, useRe
|
|
|
2
2
|
|
|
3
3
|
import { IconChevronDown, IconX } from '@tabler/icons-react'
|
|
4
4
|
|
|
5
|
-
import { canSubmitComposerAction } from '@/client/components/shared/Composer'
|
|
5
|
+
import { canSubmitComposerAction, focusComposer } from '@/client/components/shared/Composer'
|
|
6
6
|
import { useStickToBottom } from '@/client/features/chat/useStickToBottom'
|
|
7
7
|
import { groupTurns } from '@/client/features/chat/group-turns'
|
|
8
|
-
import {
|
|
8
|
+
import { attachmentKey, useLive } from '@/client/features/chat/chat-store'
|
|
9
9
|
import type { ChatPromptBubble } from '@/client/features/chat/ChatPromptBubbles'
|
|
10
10
|
import type { ChatSendOptions } from '@/client/features/chat/chat-send'
|
|
11
11
|
import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
|
|
@@ -28,8 +28,8 @@ type ChatPanelProps = {
|
|
|
28
28
|
// into the transcript through the same groupTurns pipeline so a thinking-only
|
|
29
29
|
// preview folds into the current tool group. See client/lib/preview-turn.ts.
|
|
30
30
|
previewTurn?: Turn | null
|
|
31
|
-
//
|
|
32
|
-
//
|
|
31
|
+
// Selected session id — used only as the scroll reset key (jump to bottom on
|
|
32
|
+
// session switch).
|
|
33
33
|
sessionId?: string | null
|
|
34
34
|
processing: boolean
|
|
35
35
|
error?: string | null
|
|
@@ -38,7 +38,7 @@ type ChatPanelProps = {
|
|
|
38
38
|
unavailableReason: string | null | undefined
|
|
39
39
|
send: (text: string, options?: ChatSendOptions) => void
|
|
40
40
|
stop: () => void
|
|
41
|
-
|
|
41
|
+
onSelectSession: (sessionId: string | null) => void
|
|
42
42
|
// Floating popup: render a close (X) button that dismisses the popup.
|
|
43
43
|
onClose?: () => void
|
|
44
44
|
}
|
|
@@ -57,7 +57,7 @@ export function ChatPanel({
|
|
|
57
57
|
unavailableReason,
|
|
58
58
|
send,
|
|
59
59
|
stop,
|
|
60
|
-
|
|
60
|
+
onSelectSession,
|
|
61
61
|
onClose
|
|
62
62
|
}: ChatPanelProps) {
|
|
63
63
|
const workspaceId = useWorkspaceId()
|
|
@@ -69,7 +69,7 @@ export function ChatPanel({
|
|
|
69
69
|
(state.workspaceIdsPendingAnalysis ?? []).includes(workspaceId)
|
|
70
70
|
)
|
|
71
71
|
const attachmentsUploading = useLive(state =>
|
|
72
|
-
(state.attachments[
|
|
72
|
+
(state.attachments[attachmentKey(workspaceId, sessionId ?? null)] ?? []).some(
|
|
73
73
|
attachment => attachment.status === 'uploading'
|
|
74
74
|
)
|
|
75
75
|
)
|
|
@@ -90,7 +90,7 @@ export function ChatPanel({
|
|
|
90
90
|
isWorkspacePendingAnalysis
|
|
91
91
|
})
|
|
92
92
|
|
|
93
|
-
// Stick to the bottom while pinned; respect scroll-up; jump on
|
|
93
|
+
// Stick to the bottom while pinned; respect scroll-up; jump on session switch.
|
|
94
94
|
const { atBottom, scrollToBottom, scrollToTop } = useStickToBottom(scrollRef, sessionId)
|
|
95
95
|
|
|
96
96
|
useLayoutEffect(() => {
|
|
@@ -100,7 +100,7 @@ export function ChatPanel({
|
|
|
100
100
|
// The active chat surface owns initial focus. A monotonically increasing
|
|
101
101
|
// request also refocuses an already-visible composer after intent actions.
|
|
102
102
|
useEffect(() => {
|
|
103
|
-
if (active) composerRef.current
|
|
103
|
+
if (active) focusComposer(composerRef.current)
|
|
104
104
|
}, [active, focusRequest])
|
|
105
105
|
|
|
106
106
|
// Sending always returns the user to the bottom, even if they'd scrolled up —
|
|
@@ -124,7 +124,7 @@ export function ChatPanel({
|
|
|
124
124
|
return (
|
|
125
125
|
<div className="flex min-h-0 flex-1 flex-col pt-2 pb-3">
|
|
126
126
|
<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
|
-
<ChatSelector
|
|
127
|
+
<ChatSelector selectedSessionId={sessionId ?? null} onSelectSession={onSelectSession} />
|
|
128
128
|
{onClose && (
|
|
129
129
|
<Button variant="ghost" size="icon" onClick={onClose} aria-label="Close chat">
|
|
130
130
|
<IconX stroke={1.5} />
|
|
@@ -178,22 +178,22 @@ export function ChatPanel({
|
|
|
178
178
|
<div
|
|
179
179
|
className={cn(
|
|
180
180
|
'@container flex w-full flex-col transition-[padding]',
|
|
181
|
-
(composerBanner || error) && 'gap-
|
|
181
|
+
(composerBanner || error) && 'gap-2 rounded-t-xl rounded-b-2xl p-2',
|
|
182
182
|
composerBanner && 'bg-muted',
|
|
183
183
|
error && 'bg-destructive/10'
|
|
184
184
|
)}
|
|
185
185
|
>
|
|
186
186
|
{composerBanner}
|
|
187
187
|
{error && (
|
|
188
|
-
<div className="flex w-full items-
|
|
189
|
-
<span className="flex-1 wrap-break-word">{error}</span>
|
|
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
190
|
{onDismissError && (
|
|
191
191
|
<Button
|
|
192
192
|
type="button"
|
|
193
193
|
variant="ghost"
|
|
194
194
|
size="icon-sm"
|
|
195
195
|
onClick={onDismissError}
|
|
196
|
-
className="-
|
|
196
|
+
className="text-destructive hover:text-destructive"
|
|
197
197
|
aria-label="Dismiss error"
|
|
198
198
|
>
|
|
199
199
|
<IconX stroke={1.75} />
|
|
@@ -206,6 +206,7 @@ export function ChatPanel({
|
|
|
206
206
|
onSend={handleSend}
|
|
207
207
|
onStop={stop}
|
|
208
208
|
processing={processing}
|
|
209
|
+
sessionId={sessionId ?? null}
|
|
209
210
|
unavailableReason={unavailableReason}
|
|
210
211
|
/>
|
|
211
212
|
</div>
|
|
@@ -2,19 +2,25 @@ import type { ReactNode } from 'react'
|
|
|
2
2
|
|
|
3
3
|
import { motion } from 'motion/react'
|
|
4
4
|
|
|
5
|
-
import { IconGhost } from '
|
|
6
|
-
|
|
5
|
+
import { IconGhost } from '@/client/components/shared/IconGhost'
|
|
7
6
|
import { Button } from '@/client/components/ui/button'
|
|
8
7
|
import { Popover, PopoverContent, PopoverTrigger } from '@/client/components/ui/popover'
|
|
9
8
|
|
|
10
9
|
type ChatPopupProps = {
|
|
10
|
+
loading: boolean
|
|
11
11
|
open: boolean
|
|
12
12
|
onOpenChange: (open: boolean) => void
|
|
13
13
|
onOpenChangeComplete: (open: boolean) => void
|
|
14
14
|
children: (onClose: () => void) => ReactNode
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export function ChatPopup({
|
|
17
|
+
export function ChatPopup({
|
|
18
|
+
loading,
|
|
19
|
+
open,
|
|
20
|
+
onOpenChange,
|
|
21
|
+
onOpenChangeComplete,
|
|
22
|
+
children
|
|
23
|
+
}: ChatPopupProps) {
|
|
18
24
|
const onClose = () => onOpenChange(false)
|
|
19
25
|
|
|
20
26
|
return (
|
|
@@ -40,7 +46,7 @@ export function ChatPopup({ open, onOpenChange, onOpenChangeComplete, children }
|
|
|
40
46
|
className="bg-card shadow-md hover:shadow-lg"
|
|
41
47
|
aria-label="Agent"
|
|
42
48
|
>
|
|
43
|
-
<IconGhost stroke={1.75} />
|
|
49
|
+
<IconGhost animated={loading} stroke={1.75} />
|
|
44
50
|
</Button>
|
|
45
51
|
</motion.div>
|
|
46
52
|
</div>
|