Skip to content

Commit 69309ec

Browse files
committed
Clean up autosend and continue options and enable mention menu
1 parent 2bc181d commit 69309ec

File tree

3 files changed

+26
-20
lines changed
  • apps/sim
    • app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/user-input
    • stores/panel/copilot

3 files changed

+26
-20
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/user-input/user-input.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ const UserInput = forwardRef<UserInputRef, UserInputProps>(
613613

614614
const insertTriggerAndOpenMenu = useCallback(
615615
(trigger: '@' | '/') => {
616-
if (disabled || isLoading) return
616+
if (disabled) return
617617
const textarea = mentionMenu.textareaRef.current
618618
if (!textarea) return
619619

@@ -642,7 +642,7 @@ const UserInput = forwardRef<UserInputRef, UserInputProps>(
642642
}
643643
mentionMenu.setSubmenuActiveIndex(0)
644644
},
645-
[disabled, isLoading, mentionMenu, message, setMessage]
645+
[disabled, mentionMenu, message, setMessage]
646646
)
647647

648648
const handleOpenMentionMenuWithAt = useCallback(
@@ -735,10 +735,7 @@ const UserInput = forwardRef<UserInputRef, UserInputProps>(
735735
variant='outline'
736736
onClick={handleOpenMentionMenuWithAt}
737737
title='Insert @'
738-
className={cn(
739-
'cursor-pointer rounded-[6px] p-[4.5px]',
740-
(disabled || isLoading) && 'cursor-not-allowed'
741-
)}
738+
className={cn('cursor-pointer rounded-[6px] p-[4.5px]', disabled && 'cursor-not-allowed')}
742739
>
743740
<AtSign className='h-3 w-3' strokeWidth={1.75} />
744741
</Badge>
@@ -747,10 +744,7 @@ const UserInput = forwardRef<UserInputRef, UserInputProps>(
747744
variant='outline'
748745
onClick={handleOpenSlashMenu}
749746
title='Insert /'
750-
className={cn(
751-
'cursor-pointer rounded-[6px] p-[4.5px]',
752-
(disabled || isLoading) && 'cursor-not-allowed'
753-
)}
747+
className={cn('cursor-pointer rounded-[6px] p-[4.5px]', disabled && 'cursor-not-allowed')}
754748
>
755749
<span className='flex h-3 w-3 items-center justify-center font-medium text-[11px] leading-none'>
756750
/

apps/sim/stores/panel/copilot/store.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,7 @@ interface StreamingContext {
838838
doneEventCount: number
839839
streamComplete?: boolean
840840
wasAborted?: boolean
841+
suppressContinueOption?: boolean
841842
/** Track active subagent sessions by parent tool call ID */
842843
subAgentParentToolCallId?: string
843844
/** Track subagent content per parent tool call */
@@ -2104,6 +2105,7 @@ const initialState = {
21042105
suppressAutoSelect: false,
21052106
autoAllowedTools: [] as string[],
21062107
messageQueue: [] as import('./types').QueuedMessage[],
2108+
suppressAbortContinueOption: false,
21072109
}
21082110

21092111
export const useCopilotStore = create<CopilotStore>()(
@@ -2612,10 +2614,11 @@ export const useCopilotStore = create<CopilotStore>()(
26122614
},
26132615

26142616
// Abort streaming
2615-
abortMessage: () => {
2617+
abortMessage: (options?: { suppressContinueOption?: boolean }) => {
26162618
const { abortController, isSendingMessage, messages } = get()
26172619
if (!isSendingMessage || !abortController) return
2618-
set({ isAborting: true })
2620+
const suppressContinueOption = options?.suppressContinueOption === true
2621+
set({ isAborting: true, suppressAbortContinueOption: suppressContinueOption })
26192622
try {
26202623
abortController.abort()
26212624
stopStreamingUpdates()
@@ -2626,15 +2629,17 @@ export const useCopilotStore = create<CopilotStore>()(
26262629
?.filter((b) => b.type === 'text')
26272630
.map((b: any) => b.content)
26282631
.join('') || ''
2629-
const nextContentBlocks = appendContinueOptionBlock(
2630-
lastMessage.contentBlocks ? [...lastMessage.contentBlocks] : []
2631-
)
2632+
const nextContentBlocks = suppressContinueOption
2633+
? lastMessage.contentBlocks ?? []
2634+
: appendContinueOptionBlock(lastMessage.contentBlocks ? [...lastMessage.contentBlocks] : [])
26322635
set((state) => ({
26332636
messages: state.messages.map((msg) =>
26342637
msg.id === lastMessage.id
26352638
? {
26362639
...msg,
2637-
content: appendContinueOption(textContent.trim() || 'Message was aborted'),
2640+
content: suppressContinueOption
2641+
? textContent.trim() || 'Message was aborted'
2642+
: appendContinueOption(textContent.trim() || 'Message was aborted'),
26382643
contentBlocks: nextContentBlocks,
26392644
}
26402645
: msg
@@ -3042,6 +3047,11 @@ export const useCopilotStore = create<CopilotStore>()(
30423047
const { abortController } = get()
30433048
if (abortController?.signal.aborted) {
30443049
context.wasAborted = true
3050+
const { suppressAbortContinueOption } = get()
3051+
context.suppressContinueOption = suppressAbortContinueOption === true
3052+
if (suppressAbortContinueOption) {
3053+
set({ suppressAbortContinueOption: false })
3054+
}
30453055
context.pendingContent = ''
30463056
finalizeThinkingBlock(context)
30473057
stopStreamingUpdates()
@@ -3166,7 +3176,7 @@ export const useCopilotStore = create<CopilotStore>()(
31663176
: block
31673177
)
31683178
}
3169-
if (context.wasAborted) {
3179+
if (context.wasAborted && !context.suppressContinueOption) {
31703180
sanitizedContentBlocks = appendContinueOptionBlock(sanitizedContentBlocks)
31713181
}
31723182

@@ -3179,7 +3189,7 @@ export const useCopilotStore = create<CopilotStore>()(
31793189
}
31803190

31813191
const finalContent = stripTodoTags(context.accumulatedContent.toString())
3182-
const finalContentWithOptions = context.wasAborted
3192+
const finalContentWithOptions = context.wasAborted && !context.suppressContinueOption
31833193
? appendContinueOption(finalContent)
31843194
: finalContent
31853195
set((state) => ({
@@ -3704,7 +3714,7 @@ export const useCopilotStore = create<CopilotStore>()(
37043714
// If currently sending, abort and send this one
37053715
const { isSendingMessage } = get()
37063716
if (isSendingMessage) {
3707-
get().abortMessage()
3717+
get().abortMessage({ suppressContinueOption: true })
37083718
// Wait a tick for abort to complete
37093719
await new Promise((resolve) => setTimeout(resolve, 50))
37103720
}

apps/sim/stores/panel/copilot/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ export interface CopilotState {
115115
isSaving: boolean
116116
isRevertingCheckpoint: boolean
117117
isAborting: boolean
118+
/** Skip adding Continue option on abort for queued send-now */
119+
suppressAbortContinueOption?: boolean
118120

119121
error: string | null
120122
saveError: string | null
@@ -175,7 +177,7 @@ export interface CopilotActions {
175177
messageId?: string
176178
}
177179
) => Promise<void>
178-
abortMessage: () => void
180+
abortMessage: (options?: { suppressContinueOption?: boolean }) => void
179181
sendImplicitFeedback: (
180182
implicitFeedback: string,
181183
toolCallState?: 'accepted' | 'rejected' | 'error'

0 commit comments

Comments
 (0)