|
5 | 5 | import BranchHeaderContextMenu from '$components/BranchHeaderContextMenu.svelte'; |
6 | 6 | import CardOverlay from '$components/CardOverlay.svelte'; |
7 | 7 | import ChecksPolling from '$components/ChecksPolling.svelte'; |
8 | | - import ClaudeSessionDescriptor from '$components/ClaudeSessionDescriptor.svelte'; |
9 | 8 | import CreateReviewBox from '$components/CreateReviewBox.svelte'; |
10 | 9 | import Dropzone from '$components/Dropzone.svelte'; |
11 | 10 | import PrNumberUpdater from '$components/PrNumberUpdater.svelte'; |
12 | | - import ReduxResult from '$components/ReduxResult.svelte'; |
13 | | - import CodegenBadge from '$components/codegen/CodegenBadge.svelte'; |
14 | 11 | import { BranchDropData } from '$lib/branches/dropHandler'; |
15 | | - import { CLAUDE_CODE_SERVICE } from '$lib/codegen/claude'; |
16 | | - import { CodegenRuleDropData, CodegenRuleDropHandler } from '$lib/codegen/dropzone'; |
17 | | - import { useGoToCodegenPage } from '$lib/codegen/redirect.svelte'; |
18 | 12 | import { MoveCommitDzHandler } from '$lib/commits/dropHandler'; |
19 | | - import { draggableChips } from '$lib/dragging/draggable'; |
20 | | - import { DROPZONE_REGISTRY } from '$lib/dragging/registry'; |
21 | 13 | import { ReorderCommitDzHandler } from '$lib/dragging/stackingReorderDropzoneManager'; |
22 | 14 | import { DEFAULT_FORGE_FACTORY } from '$lib/forge/forgeFactory.svelte'; |
23 | | - import { RULES_SERVICE } from '$lib/rules/rulesService.svelte'; |
24 | 15 | import { STACK_SERVICE } from '$lib/stacks/stackService.svelte'; |
25 | 16 | import { UI_STATE } from '$lib/state/uiState.svelte'; |
26 | 17 | import { inject } from '@gitbutler/core/context'; |
27 | 18 | import { ReviewBadge, TestId } from '@gitbutler/ui'; |
28 | | - import { DRAG_STATE_SERVICE } from '@gitbutler/ui/drag/dragStateService.svelte'; |
29 | 19 | import { getTimeAgo } from '@gitbutler/ui/utils/timeAgo'; |
30 | 20 | import { isDefined } from '@gitbutler/ui/utils/typeguards'; |
31 | 21 | import type { DropzoneHandler } from '$lib/dragging/handler'; |
32 | | - import type { RuleFilter } from '$lib/rules/rule'; |
33 | 22 | import type { PushStatus } from '$lib/stacks/stack'; |
34 | 23 | import type iconsJson from '@gitbutler/ui/data/icons.json'; |
35 | 24 | import type { Snippet } from 'svelte'; |
|
102 | 91 |
|
103 | 92 | let { projectId, branchName, lineColor, readonly, ...args }: Props = $props(); |
104 | 93 |
|
105 | | - const { goToCodegenPage } = useGoToCodegenPage(); |
106 | | -
|
107 | 94 | const uiState = inject(UI_STATE); |
108 | 95 | const stackService = inject(STACK_SERVICE); |
109 | 96 | const forge = inject(DEFAULT_FORGE_FACTORY); |
110 | | - const rulesService = inject(RULES_SERVICE); |
111 | | - const claudeCodeService = inject(CLAUDE_CODE_SERVICE); |
112 | | - const dropzoneRegistry = inject(DROPZONE_REGISTRY); |
113 | | - const dragStateService = inject(DRAG_STATE_SERVICE); |
114 | 97 |
|
115 | 98 | const prService = $derived(forge.current.prService); |
116 | 99 | const prUnit = $derived(prService?.unit); |
|
203 | 186 | <PrNumberUpdater {projectId} stackId={args.stackId} {branchName} /> |
204 | 187 | {/if} |
205 | 188 |
|
206 | | - {@const rule = args.stackId |
207 | | - ? rulesService.aiRuleForStack({ projectId, stackId: args.stackId }) |
208 | | - : undefined} |
209 | | - {@const codegenRuleHandler = args.stackId |
210 | | - ? new CodegenRuleDropHandler(projectId, args.stackId, rulesService, !!rule?.response) |
211 | | - : undefined} |
212 | | - |
213 | 189 | <Dropzone |
214 | | - handlers={args.first |
215 | | - ? [moveHandler, codegenRuleHandler, ...args.dropzones].filter(isDefined) |
216 | | - : args.dropzones} |
| 190 | + handlers={args.first ? [moveHandler, ...args.dropzones].filter(isDefined) : args.dropzones} |
217 | 191 | > |
218 | 192 | {#snippet overlay({ hovered, activated, handler })} |
219 | 193 | {@const label = |
220 | | - handler instanceof MoveCommitDzHandler || handler instanceof CodegenRuleDropHandler |
| 194 | + handler instanceof MoveCommitDzHandler |
221 | 195 | ? 'Move here' |
222 | 196 | : handler instanceof ReorderCommitDzHandler |
223 | 197 | ? 'Reorder here' |
|
277 | 251 | {#if args.buttons} |
278 | 252 | {@render args.buttons()} |
279 | 253 | {/if} |
280 | | - {#if args.first} |
281 | | - {@render claudeRule(args as StackBranchProps)} |
282 | | - {/if} |
283 | 254 | {/snippet} |
284 | 255 |
|
285 | 256 | {#snippet emptyState()} |
|
423 | 394 | {/if} |
424 | 395 | </div> |
425 | 396 |
|
426 | | -{#snippet claudeRule(args: StackBranchProps)} |
427 | | - {@const rule = args.stackId |
428 | | - ? rulesService.aiRuleForStack({ projectId, stackId: args.stackId }) |
429 | | - : undefined} |
430 | | - {#if rule} |
431 | | - <ReduxResult result={rule?.result} {projectId} stackId={args.stackId}> |
432 | | - {#snippet children(rule, { projectId, stackId })} |
433 | | - {#if rule} |
434 | | - {@const sessionId = (rule.filters[0]! as RuleFilter & { type: 'claudeCodeSessionId' }) |
435 | | - .subject} |
436 | | - {@const sessionDetails = claudeCodeService.sessionDetails(projectId, sessionId)} |
437 | | - <ReduxResult result={sessionDetails.result} {projectId} {stackId}> |
438 | | - {#snippet children(sessionDetails, { projectId, stackId: _stackId })} |
439 | | - <ClaudeSessionDescriptor {projectId} {sessionId}> |
440 | | - {#snippet loading()} |
441 | | - <CodegenBadge state="loading" /> |
442 | | - {/snippet} |
443 | | - {#snippet error()} |
444 | | - <CodegenBadge state="error" /> |
445 | | - {/snippet} |
446 | | - <div |
447 | | - class="branch-header__ai-pill" |
448 | | - use:draggableChips={{ |
449 | | - label: !sessionDetails.inGui ? 'CLI' : undefined, |
450 | | - data: new CodegenRuleDropData(rule), |
451 | | - chipType: 'ai-session', |
452 | | - dropzoneRegistry, |
453 | | - dragStateService |
454 | | - }} |
455 | | - > |
456 | | - <CodegenBadge |
457 | | - state={sessionDetails.inGui ? 'ebabled' : 'cli'} |
458 | | - onclick={async () => { |
459 | | - if (!args.stackId) return; |
460 | | - if (!sessionDetails.inGui) return; |
461 | | - |
462 | | - goToCodegenPage(projectId, args.stackId, branchName); |
463 | | - }} |
464 | | - /> |
465 | | - </div> |
466 | | - </ClaudeSessionDescriptor> |
467 | | - {/snippet} |
468 | | - </ReduxResult> |
469 | | - {/if} |
470 | | - {/snippet} |
471 | | - </ReduxResult> |
472 | | - {/if} |
473 | | -{/snippet} |
474 | | - |
475 | 397 | <style lang="postcss"> |
476 | 398 | .branch-card { |
477 | 399 | display: flex; |
|
508 | 430 | padding: 12px; |
509 | 431 | } |
510 | 432 | } |
511 | | -
|
512 | | - .branch-header__ai-pill { |
513 | | - display: flex; |
514 | | - overflow: hidden; |
515 | | - } |
516 | 433 | </style> |
0 commit comments