Skip to content

Commit 2bcaa96

Browse files
committed
Merge remote-tracking branch 'origin/improvement/platform-core-chat' into wip/platform-org-wiring
# Conflicts: # apps/sim/app/o/[organizationId]/components/organization-conversation-queued-edit.test.tsx # apps/sim/platform/app/(shell)/_components/chat/live/live-chat.tsx # apps/sim/platform/docs/org-parity.md # apps/sim/platform/lib/data/chat.ts
2 parents f9d6310 + 1fa797e commit 2bcaa96

120 files changed

Lines changed: 9278 additions & 8274 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/scripts/http-e2e.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ case "$group" in
382382
export BROWSER_EXTENSION_IDS=abcdefghijklmnopabcdefghijklmnop
383383
bun --no-env-file scripts/org-redesign-seed.ts
384384
start_browser_install org-redesign --only-shell chromium
385-
bun --no-env-file scripts/org-redesign-e2e/scripted-agent.ts 3031 \
385+
bun --no-env-file platform/checks/live/support/scripted-agent.ts 3031 \
386386
> "$report_dir/org-redesign-agent.log" 2>&1 &
387387
agent_pid=$!
388388
wait_ready "$agent_pid" http://127.0.0.1:3031/health 'scripted agent'

‎apps/sim/app/_organization-conversation/composer/use-composer.ts‎

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ export interface ConversationComposerProps {
3939
text: string,
4040
contexts?: ChatContext[]
4141
) => undefined | false | PendingComposerSubmission
42-
onSendQueuedHead: () => void
43-
onEditQueuedTail: () => boolean
4442
messages: readonly ChatMessage[]
4543
onStop: () => void
4644
}
@@ -83,11 +81,8 @@ export function useComposer({
8381
draftKeys,
8482
files,
8583
submission,
86-
isSending,
8784
restoredContexts,
8885
onSubmit,
89-
onSendQueuedHead,
90-
onEditQueuedTail,
9186
messages,
9287
waitsForFullLists,
9388
hasAdditionalAttachments = false,
@@ -148,7 +143,7 @@ export function useComposer({
148143
const { textareaRef, setValue, setContexts, getValue, getPlainValue, restorePrompt } = editor
149144
/**
150145
* The editor holds chips, the draft holds plain text, so neither can be the other's value. A write
151-
* from outside, a queued message restored or a chat cleared, reaches the editor here.
146+
* from outside, a chat cleared, reaches the editor here.
152147
*/
153148
useEffect(() => {
154149
if (value === getPlainValue()) return
@@ -185,10 +180,7 @@ export function useComposer({
185180
const send = () => {
186181
const filesAtSend = files.getAttachedFiles()
187182
if (filesAtSend.some((file) => file.uploading)) return
188-
if (!hasPayload(getValue(), filesAtSend)) {
189-
if (isSending) onSendQueuedHead()
190-
return
191-
}
183+
if (!hasPayload(getValue(), filesAtSend)) return
192184
const contexts = imagesOnly
193185
? filterContextsPresentInMessage(
194186
editor.contexts.filter((context) => context.kind === 'browser_page'),
@@ -268,10 +260,6 @@ export function useComposer({
268260
const rect = event.currentTarget.getBoundingClientRect()
269261
editor.openResourceMenu({ left: rect.left, top: rect.top })
270262
}
271-
const recallQueuedTail = () => {
272-
if (hasAdditionalAttachments || files.getAttachedFiles().length > 0) return false
273-
return onEditQueuedTail()
274-
}
275263

276264
return {
277265
editor,
@@ -284,7 +272,6 @@ export function useComposer({
284272
/** Enter and the arrow keys' policy, shared by the prompt editor and the plain Assistant field. */
285273
keyPolicy: {
286274
onNavigateHistory: hasAdditionalAttachments ? undefined : history.navigate,
287-
onArrowUpOnEmpty: recallQueuedTail,
288275
},
289276
frameProps: {
290277
'aria-busy': preparingSubmission || Boolean(heldSend) || undefined,

‎apps/sim/app/_organization-conversation/use-organization-conversation.ts‎

Lines changed: 2 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ import type { WorkspaceSearchFilters } from '@/lib/api/contracts/knowledge'
1111
import { getWorkspaceHostContextContract } from '@/lib/api/contracts/workspaces'
1212
import { useFeatureFlag } from '@/lib/core/config/feature-flags-context'
1313
import { BrowserStorage } from '@/lib/core/utils/browser-storage'
14-
import {
15-
getMothershipAttachmentPreviewUrl,
16-
getMothershipAttachmentUrl,
17-
} from '@/lib/mothership/chat/attachment-preview'
1814
import { organizationRoutes } from '@/lib/navigation/paths'
1915
import { organizationDraftKey, SEARCH_ASSISTANT_DRAFT_SLOT } from '@/lib/organizations/draft-key'
2016
import { useOrganization } from '@/lib/organizations/provider'
@@ -373,35 +369,6 @@ export function useOrganizationConversation({
373369
: commit({ message: text.trim(), contexts })
374370
}
375371

376-
const editQueuedMessage = (id: string) => {
377-
const queued = chat.editQueuedMessage(id)
378-
if (queued) {
379-
const store = useMothershipDraftsStore.getState()
380-
store.setDraft(draftKey, {
381-
...store.drafts[draftKey],
382-
text: queued.content,
383-
contexts: queued.contexts,
384-
})
385-
setRestoredContexts(queued.contexts ?? [])
386-
files.restoreAttachedFiles(
387-
(queued.fileAttachments ?? []).map((file) => ({
388-
id: file.id,
389-
key: file.key,
390-
name: file.filename,
391-
type: file.media_type,
392-
size: file.size,
393-
path:
394-
file.path ||
395-
getMothershipAttachmentPreviewUrl(file) ||
396-
getMothershipAttachmentUrl(file),
397-
previewUrl: getMothershipAttachmentPreviewUrl(file),
398-
uploading: false,
399-
}))
400-
)
401-
}
402-
return queued
403-
}
404-
405372
const allowBuildControls = requestMode !== 'assistant' && canBuild
406373
const stopGeneration = () => {
407374
void chat.stopGeneration()
@@ -416,17 +383,10 @@ export function useOrganizationConversation({
416383
draftKeys,
417384
restoredContexts,
418385
messages: chat.messages,
419-
onEditQueuedTail: () => {
420-
const tail = chat.messageQueue.at(-1)
421-
return tail ? Boolean(editQueuedMessage(tail.id)) : false
422-
},
423386
files,
424387
isInitialView: !hasChat,
425388
isSending: chat.isSending || chat.isReconnecting,
426389
onSubmit: submit,
427-
onSendQueuedHead: () => {
428-
void chat.sendNow()
429-
},
430390
onStop: stopGeneration,
431391
}
432392
/** What both views' threads take; each adds its own layout around them. */
@@ -444,13 +404,8 @@ export function useOrganizationConversation({
444404
isLoading: Boolean(chatId) && !chat.messages.length && chat.isChatHistoryPending,
445405
onSubmit: send,
446406
onStopGeneration: stopGeneration,
447-
messageQueue: chat.messageQueue,
448-
editingQueuedId: chat.editingQueuedId,
449-
dispatchingHeadId: chat.dispatchingHeadId,
450-
onRemoveQueuedMessage: chat.removeFromQueue,
451-
onSendQueuedMessage: chat.sendNow,
452-
onEditQueuedMessage: editQueuedMessage,
453-
onCancelQueueEdit: chat.cancelQueueEdit,
407+
onRetryMessage: chat.retryMessage,
408+
onDismissMessage: chat.dismissMessage,
454409
userId,
455410
chatId: chat.resolvedChatId,
456411
onWorkspaceResourceSelect: requestMode !== 'assistant' ? selectResource : undefined,
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { copilotChatDismissSteeringContract } from '@/lib/api/contracts/copilot'
2+
import {
3+
defineInternalJsonRoute,
4+
internalOrchestrationErrorPolicy,
5+
internalRateLimits,
6+
internalSessionAuth,
7+
} from '@/lib/api/server/routes'
8+
import { dismissSteeringMessage } from '@/lib/mothership/chat/application/steering-fallback'
9+
10+
/** Drops a steering message the user gave up on, under the chat owner's current access. */
11+
export const POST = defineInternalJsonRoute({
12+
contract: copilotChatDismissSteeringContract,
13+
auth: internalSessionAuth,
14+
operation: dismissSteeringMessage.operation,
15+
rateLimit: internalRateLimits.none({
16+
reason: 'Authenticated cleanup of one message the user already sent; it starts no work.',
17+
}),
18+
errorPolicy: internalOrchestrationErrorPolicy,
19+
mapInput: ({ body }) => ({ chatId: body.chatId, messageId: body.steeringId }),
20+
useCase: dismissSteeringMessage,
21+
})

0 commit comments

Comments
 (0)