Skip to content

Commit 27d86f5

Browse files
authored
feat(ai-agent): add local run button (#3690)
1 parent c0ea795 commit 27d86f5

5 files changed

Lines changed: 180 additions & 66 deletions

File tree

assets/src/components/ai/agent-runs/details/AIAgentRun.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {
3333
import styled, { useTheme } from 'styled-components'
3434
import { getAIBreadcrumbs } from '../../AI.tsx'
3535
import { AgentRunAnalysis } from './AIAgentRunAnalysis.tsx'
36+
import { AIAgentRunLocalButton } from './AIAgentRunLocalButton.tsx'
3637
import { AIAgentRunMessages } from './AIAgentRunMessages.tsx'
3738
import { AIAgentRunShareButton } from './AIAgentRunShareButton.tsx'
3839
import { AgentRunSidecar } from './AIAgentRunSidecar.tsx'
@@ -153,6 +154,12 @@ export function AIAgentRun() {
153154
Cancel agent run
154155
</Button>
155156
)}
157+
{run?.upload?.session && (
158+
<AIAgentRunLocalButton
159+
runId={run.id}
160+
repository={run.repository}
161+
/>
162+
)}
156163
{run && <AIAgentRunShareButton runId={run?.id} />}
157164
</Flex>
158165
</StretchedFlex>
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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

Comments
 (0)