|
| 1 | +import { |
| 2 | + Button, |
| 3 | + Codeline, |
| 4 | + Flex, |
| 5 | + InlineCode, |
| 6 | + Modal, |
| 7 | + TerminalIcon, |
| 8 | +} from '@pluralsh/design-system' |
| 9 | +import { InlineLink } from 'components/utils/typography/InlineLink.tsx' |
| 10 | +import { useState } from 'react' |
| 11 | +import { useTheme } from 'styled-components' |
| 12 | + |
| 13 | +export function AIAgentRunLocalButton({ |
| 14 | + runId, |
| 15 | + repository, |
| 16 | +}: { |
| 17 | + runId: string |
| 18 | + repository: string |
| 19 | +}) { |
| 20 | + const { colors, spacing } = useTheme() |
| 21 | + const [open, setOpen] = useState(false) |
| 22 | + const command = `plural agents resume ${runId}` |
| 23 | + const repositoryDisplay = repository.startsWith('http') ? ( |
| 24 | + <InlineLink |
| 25 | + href={repository} |
| 26 | + target="_blank" |
| 27 | + rel="noreferrer" |
| 28 | + > |
| 29 | + {repository} |
| 30 | + </InlineLink> |
| 31 | + ) : ( |
| 32 | + <InlineCode>{repository}</InlineCode> |
| 33 | + ) |
| 34 | + |
| 35 | + return ( |
| 36 | + <> |
| 37 | + <Button |
| 38 | + small |
| 39 | + secondary |
| 40 | + startIcon={<TerminalIcon />} |
| 41 | + onClick={() => setOpen(true)} |
| 42 | + > |
| 43 | + Run locally |
| 44 | + </Button> |
| 45 | + <Modal |
| 46 | + header="Run agent locally" |
| 47 | + open={open} |
| 48 | + onClose={() => setOpen(false)} |
| 49 | + size="large" |
| 50 | + actions={ |
| 51 | + <Button |
| 52 | + secondary |
| 53 | + onClick={() => setOpen(false)} |
| 54 | + > |
| 55 | + Close |
| 56 | + </Button> |
| 57 | + } |
| 58 | + > |
| 59 | + <Flex |
| 60 | + direction="column" |
| 61 | + gap="large" |
| 62 | + > |
| 63 | + <span> |
| 64 | + Resume this agent session from your local terminal with the Plural |
| 65 | + CLI. Use your local checkout of {repositoryDisplay}, and run the |
| 66 | + command from that repository directory so local file paths and git |
| 67 | + state line up. |
| 68 | + </span> |
| 69 | + <Flex |
| 70 | + direction="column" |
| 71 | + gap="small" |
| 72 | + > |
| 73 | + <span> |
| 74 | + 1. Open your local checkout of the repository the agent used. |
| 75 | + </span> |
| 76 | + <Codeline css={{ background: colors['fill-two'] }}> |
| 77 | + cd /path/to/repository |
| 78 | + </Codeline> |
| 79 | + </Flex> |
| 80 | + <Flex |
| 81 | + direction="column" |
| 82 | + gap="small" |
| 83 | + > |
| 84 | + <span>2. Resume the uploaded agent session.</span> |
| 85 | + <Codeline css={{ background: colors['fill-two'] }}> |
| 86 | + {command} |
| 87 | + </Codeline> |
| 88 | + </Flex> |
| 89 | + <span |
| 90 | + css={{ color: colors['text-light'], marginTop: spacing.xsmall }} |
| 91 | + > |
| 92 | + The Plural CLI should already be installed and authenticated on your |
| 93 | + machine before running this command. |
| 94 | + </span> |
| 95 | + </Flex> |
| 96 | + </Modal> |
| 97 | + </> |
| 98 | + ) |
| 99 | +} |
0 commit comments