moi-computer 0.11.1-next.5 → 0.12.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/features/chat/composer/attachments/draft-attachments.ts +21 -4
- package/dist/chunk-e2q5ken7.js +68 -0
- package/dist/{chunk-hvj7tp3y.js → chunk-ph0h6h86.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/server/cli.ts +26 -6
- package/server/moi-scaffold.ts +52 -20
- package/server/workspace-init.ts +6 -3
- package/dist/chunk-9zpvdws4.js +0 -68
|
@@ -6,7 +6,8 @@ import type {
|
|
|
6
6
|
WorkspaceTabId
|
|
7
7
|
} from '@/lib/types'
|
|
8
8
|
|
|
9
|
-
import { findAttachment, liveStore } from '../../chat-store'
|
|
9
|
+
import { attachmentKey, findAttachment, liveStore } from '../../chat-store'
|
|
10
|
+
import { MAX_MESSAGE_ATTACHMENTS } from '@/lib/message-attachments'
|
|
10
11
|
import { uploadChatFile } from './uploads'
|
|
11
12
|
import { reportAppletError } from '@/client/features/applets/applet-log'
|
|
12
13
|
import { toast } from '@/client/components/ui/toast'
|
|
@@ -16,6 +17,18 @@ type ComposerTarget = {
|
|
|
16
17
|
sessionId: string | null
|
|
17
18
|
}
|
|
18
19
|
|
|
20
|
+
function hasAttachmentRoom({ workspaceId, sessionId }: ComposerTarget): boolean {
|
|
21
|
+
const pending = liveStore.getState().attachments[attachmentKey(workspaceId, sessionId)] ?? []
|
|
22
|
+
if (pending.length < MAX_MESSAGE_ATTACHMENTS) return true
|
|
23
|
+
toast.add({
|
|
24
|
+
id: 'draft-attachment-limit',
|
|
25
|
+
title: 'Attachment limit reached',
|
|
26
|
+
description: `You can attach up to ${MAX_MESSAGE_ATTACHMENTS} items. Remove one to add another.`,
|
|
27
|
+
type: 'error'
|
|
28
|
+
})
|
|
29
|
+
return false
|
|
30
|
+
}
|
|
31
|
+
|
|
19
32
|
export function stageComposerFiles(target: ComposerTarget, files: File[]): void {
|
|
20
33
|
for (const file of files) void stageFile(target, file)
|
|
21
34
|
}
|
|
@@ -27,6 +40,7 @@ async function stageFile(
|
|
|
27
40
|
onError?: (message: string) => void,
|
|
28
41
|
source?: string
|
|
29
42
|
): Promise<void> {
|
|
43
|
+
if (!hasAttachmentRoom({ workspaceId, sessionId })) return
|
|
30
44
|
const file = typeof input === 'string' ? null : input
|
|
31
45
|
const label = typeof input === 'string' ? input.split('/').at(-1)! : input.name || 'file'
|
|
32
46
|
const localId = crypto.randomUUID()
|
|
@@ -99,11 +113,12 @@ export function stageDrawingDraft({
|
|
|
99
113
|
purpose,
|
|
100
114
|
source,
|
|
101
115
|
blob
|
|
102
|
-
}: StageDrawingDraftInput):
|
|
116
|
+
}: StageDrawingDraftInput): boolean {
|
|
103
117
|
const label = purpose === 'sketch' ? 'Sketch' : 'Annotation'
|
|
104
|
-
const previewUrl = URL.createObjectURL(blob)
|
|
105
118
|
const store = liveStore.getState()
|
|
106
119
|
const existing = findAttachment(store.attachments, workspaceId, localId)
|
|
120
|
+
if (!existing && !hasAttachmentRoom({ workspaceId, sessionId })) return false
|
|
121
|
+
const previewUrl = URL.createObjectURL(blob)
|
|
107
122
|
|
|
108
123
|
if (existing) {
|
|
109
124
|
store.updateAttachment(workspaceId, localId, {
|
|
@@ -125,6 +140,7 @@ export function stageDrawingDraft({
|
|
|
125
140
|
}
|
|
126
141
|
])
|
|
127
142
|
}
|
|
143
|
+
return true
|
|
128
144
|
}
|
|
129
145
|
|
|
130
146
|
type StageDrawingInput = StageDrawingDraftInput & {
|
|
@@ -137,7 +153,7 @@ type StageDrawingInput = StageDrawingDraftInput & {
|
|
|
137
153
|
export async function stageDrawing(input: StageDrawingInput): Promise<void> {
|
|
138
154
|
const { workspaceId, localId, purpose, blob, isCurrent } = input
|
|
139
155
|
const label = purpose === 'sketch' ? 'Sketch' : 'Annotation'
|
|
140
|
-
stageDrawingDraft(input)
|
|
156
|
+
if (!stageDrawingDraft(input)) return
|
|
141
157
|
liveStore.getState().updateAttachment(workspaceId, localId, { status: 'uploading' })
|
|
142
158
|
|
|
143
159
|
try {
|
|
@@ -161,6 +177,7 @@ export function stageTextAttachment(
|
|
|
161
177
|
{ workspaceId, sessionId }: ComposerTarget,
|
|
162
178
|
attachment: TextAttachment
|
|
163
179
|
): void {
|
|
180
|
+
if (!hasAttachmentRoom({ workspaceId, sessionId })) return
|
|
164
181
|
const store = liveStore.getState()
|
|
165
182
|
store.addAttachments(workspaceId, sessionId, [
|
|
166
183
|
{ kind: 'text', localId: crypto.randomUUID(), ...attachment }
|