-
Notifications
You must be signed in to change notification settings - Fork 38
[Improve] Reuse task prompts as automations #1649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,13 +10,16 @@ import { | |
| } from '@roomote/types'; | ||
|
|
||
| import { cn } from '@/lib/utils'; | ||
| import { SETTINGS_PATHS } from '@/lib/settings'; | ||
| import { useAuthorizedUser } from '@/hooks/useUser'; | ||
|
|
||
| import { | ||
| BasicTooltip, | ||
| Button, | ||
| ChevronDownIcon, | ||
| MediaViewerDialog, | ||
| MediaViewerImage, | ||
| Zap, | ||
| } from '@/components/system'; | ||
| import { | ||
| type CollapsibleToggleRenderProps, | ||
|
|
@@ -25,6 +28,7 @@ import { | |
| Attachments, | ||
| CollapsibleContent, | ||
| Message, | ||
| MessageAction, | ||
| MessageActions, | ||
| MessageContent, | ||
| MessagePlainText, | ||
|
|
@@ -41,6 +45,8 @@ import type { AcpUiMessage } from './types'; | |
| import { ProviderRetryNoticeMessage } from './ProviderRetryNoticeMessage'; | ||
| import { TerminalProviderErrorMessage } from './TerminalProviderErrorMessage'; | ||
|
|
||
| const MAX_AUTOMATION_PREFILL_LENGTH = 5_000; | ||
|
|
||
| const UserMessageToggle = ({ | ||
| isExpanded, | ||
| toggle, | ||
|
|
@@ -153,6 +159,7 @@ function getRequestUserInputResponseDisplay( | |
| } | ||
|
|
||
| export function AcpTextMessage({ msg }: AcpTextMessageProps) { | ||
| const { isAdmin } = useAuthorizedUser(); | ||
| const [selectedImageIndex, setSelectedImageIndex] = useState<number | null>( | ||
| null, | ||
| ); | ||
|
|
@@ -194,6 +201,13 @@ export function AcpTextMessage({ msg }: AcpTextMessageProps) { | |
| ) | ||
| .join('\n\n') | ||
| : baseContent; | ||
| const automationPrompt = | ||
| isAdmin && | ||
| isUser && | ||
| msg.updateType === ACP_ENVELOPE_EVENT_TYPES.UserPrompt && | ||
| baseContent.length <= MAX_AUTOMATION_PREFILL_LENGTH | ||
| ? baseContent | ||
| : null; | ||
| const shouldShowContentActions = isUser | ||
| ? msg.partial !== true && !taskTool && !linkedReviewResult | ||
| : msg.partial !== true && | ||
|
|
@@ -350,6 +364,16 @@ export function AcpTextMessage({ msg }: AcpTextMessageProps) { | |
| <MessageActions> | ||
| <MessageCopyButton content={content} /> | ||
| <MessageNewTaskButton content={content} /> | ||
| {automationPrompt !== null ? ( | ||
| <MessageAction | ||
| tooltip="Save as automation" | ||
| onClick={() => { | ||
| window.location.href = `${SETTINGS_PATHS.automations}?prompt=${encodeURIComponent(automationPrompt)}`; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This puts the complete task prompt in the initial |
||
| }} | ||
| > | ||
| <Zap className="size-4 text-muted-foreground" /> | ||
| </MessageAction> | ||
| ) : null} | ||
| {!showPersistentTimestamp && ( | ||
| <MessageTimestamp | ||
| ts={msg.ts} | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also enables the action for empty or whitespace-only prompts. Image-only user messages render actions because
msg.imagesis present, but the destination rejects?prompt=atCustomAutomationsSection.tsx:529-532, leaving the user on Automations with no dialog. RequirebaseContent.trim().length > 0before showing this action while still passing the untrimmed content through for valid prompts.