|
18 | 18 | import { PROMPT_SERVICE } from '$lib/ai/promptService';
|
19 | 19 | import { AI_SERVICE } from '$lib/ai/service';
|
20 | 20 | import { CLIPBOARD_SERVICE } from '$lib/backend/clipboard';
|
| 21 | + import { CLAUDE_CODE_SERVICE } from '$lib/codegen/claude'; |
21 | 22 | import { projectAiGenEnabled } from '$lib/config/config';
|
22 | 23 | import { DEFAULT_FORGE_FACTORY } from '$lib/forge/forgeFactory.svelte';
|
| 24 | + import { codegenPath } from '$lib/routes/routes.svelte'; |
23 | 25 | import { STACK_SERVICE } from '$lib/stacks/stackService.svelte';
|
24 | 26 | import { URL_SERVICE } from '$lib/utils/url';
|
25 | 27 | import { inject } from '@gitbutler/core/context';
|
|
33 | 35 | } from '@gitbutler/ui';
|
34 | 36 |
|
35 | 37 | import { tick } from 'svelte';
|
| 38 | + import { goto } from '$app/navigation'; |
36 | 39 | import type { AnchorPosition, BranchDetails } from '$lib/stacks/stack';
|
37 | 40 |
|
38 | 41 | type Props = {
|
|
59 | 62 | const promptService = inject(PROMPT_SERVICE);
|
60 | 63 | const urlService = inject(URL_SERVICE);
|
61 | 64 | const clipboardService = inject(CLIPBOARD_SERVICE);
|
| 65 | + const claudeCodeService = inject(CLAUDE_CODE_SERVICE); |
62 | 66 | const [insertBlankCommitInBranch, commitInsertion] = stackService.insertBlankCommit;
|
63 | 67 | const [updateBranchNameMutation] = stackService.updateBranchName;
|
64 | 68 | const [createRef, refCreation] = stackService.createReference;
|
|
99 | 103 | aiConfigurationValid = await aiService.validateConfiguration();
|
100 | 104 | }
|
101 | 105 |
|
| 106 | + async function startCodingSession() { |
| 107 | + if (!stackId) return; |
| 108 | + goto(`${codegenPath(projectId)}?stackId=${stackId}`); |
| 109 | + close(); |
| 110 | + } |
| 111 | +
|
102 | 112 | async function generateBranchName(stackId: string, branchName: string) {
|
103 | 113 | if (!$aiGenEnabled || !aiConfigurationValid) return;
|
104 | 114 |
|
|
265 | 275 | {/if}
|
266 | 276 | </ContextMenuSection>
|
267 | 277 | <ContextMenuSection>
|
| 278 | + {#if $aiGenEnabled && aiConfigurationValid && stackId} |
| 279 | + <ContextMenuItem |
| 280 | + label="Start Coding Agent session" |
| 281 | + icon="ai" |
| 282 | + testId={TestId.BranchHeaderContextMenu_StartCodingSession} |
| 283 | + disabled={isReadOnly} |
| 284 | + onclick={() => { |
| 285 | + startCodingSession(); |
| 286 | + }} |
| 287 | + /> |
| 288 | + {/if} |
268 | 289 | {#if $aiGenEnabled && aiConfigurationValid && !branch.remoteTrackingBranch && stackId}
|
269 | 290 | <ContextMenuItem
|
270 | 291 | label="Generate branch name"
|
|
0 commit comments