| b69ab31 | | | 1 | /** |
| b69ab31 | | | 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. |
| b69ab31 | | | 3 | * |
| b69ab31 | | | 4 | * This source code is licensed under the MIT license found in the |
| b69ab31 | | | 5 | * LICENSE file in the root directory of this source tree. |
| b69ab31 | | | 6 | */ |
| b69ab31 | | | 7 | |
| b69ab31 | | | 8 | import {Button} from 'isl-components/Button'; |
| b69ab31 | | | 9 | import {Icon} from 'isl-components/Icon'; |
| b69ab31 | | | 10 | import {Tooltip} from 'isl-components/Tooltip'; |
| b69ab31 | | | 11 | import {useAtomValue} from 'jotai'; |
| b69ab31 | | | 12 | import {Suspense, useState} from 'react'; |
| b69ab31 | | | 13 | import {randomId} from 'shared/utils'; |
| b69ab31 | | | 14 | import {tracker} from '../analytics'; |
| b69ab31 | | | 15 | import serverAPI from '../ClientToServerAPI'; |
| b69ab31 | | | 16 | import {diffCommentData} from '../codeReview/codeReviewAtoms'; |
| b69ab31 | | | 17 | import {diffSummary} from '../codeReview/CodeReviewInfo'; |
| b69ab31 | | | 18 | import {DropdownFields} from '../DropdownFields'; |
| b69ab31 | | | 19 | import {useFeatureFlagAsync, useFeatureFlagSync} from '../featureFlags'; |
| b69ab31 | | | 20 | import {T} from '../i18n'; |
| b69ab31 | | | 21 | import {Internal} from '../Internal'; |
| b69ab31 | | | 22 | import {BaseSplitButton} from '../stackEdit/ui/BaseSplitButton'; |
| b69ab31 | | | 23 | import type {CommitInfo} from '../types'; |
| b69ab31 | | | 24 | |
| b69ab31 | | | 25 | import platform from '../platform'; |
| b69ab31 | | | 26 | import {repositoryInfo} from '../serverAPIState'; |
| b69ab31 | | | 27 | import './SmartActionsMenu.css'; |
| b69ab31 | | | 28 | |
| b69ab31 | | | 29 | export function SmartActionsMenu({commit}: {commit?: CommitInfo}) { |
| b69ab31 | | | 30 | const [dropdownVisible, setDropdownVisible] = useState(false); |
| b69ab31 | | | 31 | |
| b69ab31 | | | 32 | const smartActionsMenuEnabled = useFeatureFlagSync(Internal.featureFlags?.SmartActionsMenu); |
| b69ab31 | | | 33 | if (!smartActionsMenuEnabled || !Internal.smartActions?.showSmartActions) { |
| b69ab31 | | | 34 | return null; |
| b69ab31 | | | 35 | } |
| b69ab31 | | | 36 | |
| b69ab31 | | | 37 | return ( |
| b69ab31 | | | 38 | <Tooltip |
| b69ab31 | | | 39 | component={dismiss => { |
| b69ab31 | | | 40 | return ( |
| b69ab31 | | | 41 | <Suspense fallback={<Icon icon="loading" />}> |
| b69ab31 | | | 42 | <SmartActions commit={commit} dismiss={dismiss} /> |
| b69ab31 | | | 43 | </Suspense> |
| b69ab31 | | | 44 | ); |
| b69ab31 | | | 45 | }} |
| b69ab31 | | | 46 | trigger="click" |
| b69ab31 | | | 47 | title={<T>Smart Actions...</T>} |
| b69ab31 | | | 48 | onVisible={() => setDropdownVisible(true)} |
| b69ab31 | | | 49 | onDismiss={() => setDropdownVisible(false)} |
| b69ab31 | | | 50 | group="smart-actions"> |
| b69ab31 | | | 51 | <Button |
| b69ab31 | | | 52 | icon |
| b69ab31 | | | 53 | data-testid="smart-actions-button" |
| b69ab31 | | | 54 | onClick={() => tracker.track('SmartActionsMenuOpened')} |
| b69ab31 | | | 55 | className={'smart-actions-button' + (dropdownVisible ? ' dropdown-visible' : '')}> |
| b69ab31 | | | 56 | <Icon icon="lightbulb-sparkle" /> |
| b69ab31 | | | 57 | </Button> |
| b69ab31 | | | 58 | </Tooltip> |
| b69ab31 | | | 59 | ); |
| b69ab31 | | | 60 | } |
| b69ab31 | | | 61 | |
| b69ab31 | | | 62 | function SmartActions({commit, dismiss}: {commit?: CommitInfo; dismiss: () => void}) { |
| b69ab31 | | | 63 | const actions = []; |
| b69ab31 | | | 64 | |
| b69ab31 | | | 65 | const aiCommitSplitEnabled = useFeatureFlagAsync(Internal.featureFlags?.AICommitSplit); |
| b69ab31 | | | 66 | if (commit && aiCommitSplitEnabled) { |
| b69ab31 | | | 67 | actions.push(<AutoSplitButton key="auto-split" commit={commit} dismiss={dismiss} />); |
| b69ab31 | | | 68 | } |
| b69ab31 | | | 69 | |
| b69ab31 | | | 70 | const aiResolveCommentsEnabled = useFeatureFlagAsync( |
| b69ab31 | | | 71 | Internal.featureFlags?.InlineCommentAIResolve, |
| b69ab31 | | | 72 | ); |
| b69ab31 | | | 73 | // For now, only support this in VS Code |
| b69ab31 | | | 74 | if (aiResolveCommentsEnabled && commit?.diffId && platform.platformName === 'vscode') { |
| b69ab31 | | | 75 | actions.push( |
| b69ab31 | | | 76 | <ResolveCommentsButton |
| b69ab31 | | | 77 | key="resolve-comments" |
| b69ab31 | | | 78 | diffId={commit.diffId} |
| b69ab31 | | | 79 | filePathsSample={commit.filePathsSample} |
| b69ab31 | | | 80 | dismiss={dismiss} |
| b69ab31 | | | 81 | disabled={!commit.isDot} |
| b69ab31 | | | 82 | disabledReason="This action is only available for the current commit." |
| b69ab31 | | | 83 | />, |
| b69ab31 | | | 84 | ); |
| b69ab31 | | | 85 | } |
| b69ab31 | | | 86 | |
| b69ab31 | | | 87 | const aiResolveFailedSignalsEnabled = useFeatureFlagAsync( |
| b69ab31 | | | 88 | Internal.featureFlags?.AIResolveFailedSignals, |
| b69ab31 | | | 89 | ); |
| b69ab31 | | | 90 | // For now, only support this in VS Code |
| b69ab31 | | | 91 | if (aiResolveFailedSignalsEnabled && commit?.diffId && platform.platformName === 'vscode') { |
| b69ab31 | | | 92 | actions.push( |
| b69ab31 | | | 93 | <ResolveFailedSignalsButton |
| b69ab31 | | | 94 | key="resolve-failed-signals" |
| b69ab31 | | | 95 | hash={commit.hash} |
| b69ab31 | | | 96 | diffId={commit.diffId} |
| b69ab31 | | | 97 | dismiss={dismiss} |
| b69ab31 | | | 98 | disabled={!commit.isDot} |
| b69ab31 | | | 99 | disabledReason="This action is only available for the current commit." |
| b69ab31 | | | 100 | />, |
| b69ab31 | | | 101 | ); |
| b69ab31 | | | 102 | } |
| b69ab31 | | | 103 | |
| b69ab31 | | | 104 | const aiGenerateTestsForModifiedCodeEnabled = useFeatureFlagAsync( |
| b69ab31 | | | 105 | Internal.featureFlags?.AIGenerateTestsForModifiedCode, |
| b69ab31 | | | 106 | ); |
| b69ab31 | | | 107 | // For now, only support this in VS Code |
| b69ab31 | | | 108 | if (aiGenerateTestsForModifiedCodeEnabled && platform.platformName === 'vscode') { |
| b69ab31 | | | 109 | const enabled = !commit || commit.isDot; // Enabled for `uncommitted changes` or the `current commit`. |
| b69ab31 | | | 110 | actions.push( |
| b69ab31 | | | 111 | <GenerateTestsForModifiedCodeButton |
| b69ab31 | | | 112 | key="generate-tests" |
| b69ab31 | | | 113 | dismiss={dismiss} |
| b69ab31 | | | 114 | disabled={!enabled} |
| b69ab31 | | | 115 | disabledReason="This action is only available for the current commit and uncommitted changes." |
| b69ab31 | | | 116 | />, |
| b69ab31 | | | 117 | ); |
| b69ab31 | | | 118 | } |
| b69ab31 | | | 119 | |
| b69ab31 | | | 120 | const aiGenerateCommitMessageEnabled = useFeatureFlagAsync( |
| b69ab31 | | | 121 | Internal.featureFlags?.AIGenerateCommitMessage, |
| b69ab31 | | | 122 | ); |
| b69ab31 | | | 123 | // For now, only support this in VS Code |
| b69ab31 | | | 124 | if (!commit && aiGenerateCommitMessageEnabled && platform.platformName === 'vscode') { |
| b69ab31 | | | 125 | actions.push(<FillCommitInfoButton key="fill-commit-info" dismiss={dismiss} />); |
| b69ab31 | | | 126 | } |
| b69ab31 | | | 127 | |
| b69ab31 | | | 128 | const aiValidateChangesEnabled = useFeatureFlagAsync(Internal.featureFlags?.AIValidateChanges); |
| b69ab31 | | | 129 | // For now, only support this in VS Code |
| b69ab31 | | | 130 | if (!commit && aiValidateChangesEnabled && platform.platformName === 'vscode') { |
| b69ab31 | | | 131 | actions.push(<ValidateChangesButton key="validate-changes" dismiss={dismiss} />); |
| b69ab31 | | | 132 | } |
| b69ab31 | | | 133 | |
| b69ab31 | | | 134 | const aiCodeReviewUpsellEnabled = useFeatureFlagAsync(Internal.featureFlags?.AICodeReviewUpsell); |
| b69ab31 | | | 135 | // For now, only support this in VS Code |
| b69ab31 | | | 136 | if (aiCodeReviewUpsellEnabled && platform.platformName === 'vscode') { |
| b69ab31 | | | 137 | const enabled = !commit || commit.isDot; // Enabled for `uncommitted changes` or the `current commit`. |
| b69ab31 | | | 138 | actions.push( |
| b69ab31 | | | 139 | <ReviewCodeButton |
| b69ab31 | | | 140 | key="review-commit" |
| b69ab31 | | | 141 | commit={commit} |
| b69ab31 | | | 142 | dismiss={dismiss} |
| b69ab31 | | | 143 | disabled={!enabled} |
| b69ab31 | | | 144 | disabledReason="This action is only available for the current commit and uncommitted changes." |
| b69ab31 | | | 145 | />, |
| b69ab31 | | | 146 | ); |
| b69ab31 | | | 147 | } |
| b69ab31 | | | 148 | |
| b69ab31 | | | 149 | return ( |
| b69ab31 | | | 150 | <DropdownFields |
| b69ab31 | | | 151 | title={<T>Smart Actions</T>} |
| b69ab31 | | | 152 | icon="lightbulb-sparkle" |
| b69ab31 | | | 153 | className="smart-actions-dropdown" |
| b69ab31 | | | 154 | data-testid="smart-actions-dropdown"> |
| b69ab31 | | | 155 | {actions.length > 0 ? actions : <T>No smart actions available</T>} |
| b69ab31 | | | 156 | </DropdownFields> |
| b69ab31 | | | 157 | ); |
| b69ab31 | | | 158 | } |
| b69ab31 | | | 159 | |
| b69ab31 | | | 160 | /** Like SplitButton, but triggers AI split automatically. */ |
| b69ab31 | | | 161 | function AutoSplitButton({commit, dismiss}: {commit: CommitInfo; dismiss: () => void}) { |
| b69ab31 | | | 162 | return ( |
| b69ab31 | | | 163 | <BaseSplitButton |
| b69ab31 | | | 164 | commit={commit} |
| b69ab31 | | | 165 | trackerEventName="SplitOpenFromSmartActions" |
| b69ab31 | | | 166 | autoSplit={true} |
| b69ab31 | | | 167 | onSplitInitiated={() => { |
| b69ab31 | | | 168 | tracker.track('SmartActionClicked', {extras: {action: 'AutoSplit'}}); |
| b69ab31 | | | 169 | dismiss(); |
| b69ab31 | | | 170 | }}> |
| b69ab31 | | | 171 | <Icon icon="sparkle" /> |
| b69ab31 | | | 172 | <T>Auto-split</T> |
| b69ab31 | | | 173 | </BaseSplitButton> |
| b69ab31 | | | 174 | ); |
| b69ab31 | | | 175 | } |
| b69ab31 | | | 176 | |
| b69ab31 | | | 177 | /** Prompt AI to resolve all comments on a diff. */ |
| b69ab31 | | | 178 | function ResolveCommentsButton({ |
| b69ab31 | | | 179 | diffId, |
| b69ab31 | | | 180 | filePathsSample, |
| b69ab31 | | | 181 | dismiss, |
| b69ab31 | | | 182 | disabled, |
| b69ab31 | | | 183 | disabledReason, |
| b69ab31 | | | 184 | }: { |
| b69ab31 | | | 185 | diffId: string; |
| b69ab31 | | | 186 | filePathsSample: readonly string[]; |
| b69ab31 | | | 187 | dismiss: () => void; |
| b69ab31 | | | 188 | disabled?: boolean; |
| b69ab31 | | | 189 | disabledReason?: string; |
| b69ab31 | | | 190 | }) { |
| b69ab31 | | | 191 | const repo = useAtomValue(repositoryInfo); |
| b69ab31 | | | 192 | const repoPath = repo?.repoRoot; |
| b69ab31 | | | 193 | const diffComments = useAtomValue(diffCommentData(diffId)); |
| b69ab31 | | | 194 | if (diffComments.state === 'loading') { |
| b69ab31 | | | 195 | return <Icon icon="loading" />; |
| b69ab31 | | | 196 | } |
| b69ab31 | | | 197 | if (diffComments.state === 'hasError' || diffComments.data.length === 0) { |
| b69ab31 | | | 198 | return; |
| b69ab31 | | | 199 | } |
| b69ab31 | | | 200 | |
| b69ab31 | | | 201 | const button = ( |
| b69ab31 | | | 202 | <Button |
| b69ab31 | | | 203 | data-testid="review-comments-button" |
| b69ab31 | | | 204 | onClick={e => { |
| b69ab31 | | | 205 | tracker.track('SmartActionClicked', {extras: {action: 'ResolveAllComments'}}); |
| b69ab31 | | | 206 | serverAPI.postMessage({ |
| b69ab31 | | | 207 | type: 'platform/resolveAllCommentsWithAI', |
| b69ab31 | | | 208 | diffId, |
| b69ab31 | | | 209 | comments: diffComments.data, |
| b69ab31 | | | 210 | filePaths: [...filePathsSample], |
| b69ab31 | | | 211 | repoPath, |
| b69ab31 | | | 212 | }); |
| b69ab31 | | | 213 | dismiss(); |
| b69ab31 | | | 214 | e.stopPropagation(); |
| b69ab31 | | | 215 | }} |
| b69ab31 | | | 216 | disabled={disabled}> |
| b69ab31 | | | 217 | <Icon icon="sparkle" /> |
| b69ab31 | | | 218 | <T>Resolve all comments</T> |
| b69ab31 | | | 219 | </Button> |
| b69ab31 | | | 220 | ); |
| b69ab31 | | | 221 | |
| b69ab31 | | | 222 | return disabled ? <Tooltip title={disabledReason}>{button}</Tooltip> : button; |
| b69ab31 | | | 223 | } |
| b69ab31 | | | 224 | |
| b69ab31 | | | 225 | /** Prompt AI to fill commit info. */ |
| b69ab31 | | | 226 | function FillCommitInfoButton({dismiss}: {dismiss: () => void}) { |
| b69ab31 | | | 227 | return ( |
| b69ab31 | | | 228 | <Button |
| b69ab31 | | | 229 | data-testid="fill-commit-info-button" |
| b69ab31 | | | 230 | onClick={e => { |
| b69ab31 | | | 231 | tracker.track('SmartActionClicked', {extras: {action: 'FillCommitMessage'}}); |
| b69ab31 | | | 232 | serverAPI.postMessage({ |
| b69ab31 | | | 233 | type: 'platform/fillCommitMessageWithAI', |
| b69ab31 | | | 234 | id: randomId(), |
| b69ab31 | | | 235 | source: 'smartAction', |
| b69ab31 | | | 236 | }); |
| b69ab31 | | | 237 | dismiss(); |
| b69ab31 | | | 238 | e.stopPropagation(); |
| b69ab31 | | | 239 | }}> |
| b69ab31 | | | 240 | <Icon icon="sparkle" /> |
| b69ab31 | | | 241 | <T>Fill commit info</T> |
| b69ab31 | | | 242 | </Button> |
| b69ab31 | | | 243 | ); |
| b69ab31 | | | 244 | } |
| b69ab31 | | | 245 | |
| b69ab31 | | | 246 | /** Prompt AI to resolve failed signals on a diff. */ |
| b69ab31 | | | 247 | function ResolveFailedSignalsButton({ |
| b69ab31 | | | 248 | hash, |
| b69ab31 | | | 249 | diffId, |
| b69ab31 | | | 250 | dismiss, |
| b69ab31 | | | 251 | disabled, |
| b69ab31 | | | 252 | disabledReason, |
| b69ab31 | | | 253 | }: { |
| b69ab31 | | | 254 | hash: string; |
| b69ab31 | | | 255 | diffId: string; |
| b69ab31 | | | 256 | dismiss: () => void; |
| b69ab31 | | | 257 | disabled?: boolean; |
| b69ab31 | | | 258 | disabledReason?: string; |
| b69ab31 | | | 259 | }) { |
| b69ab31 | | | 260 | const repo = useAtomValue(repositoryInfo); |
| b69ab31 | | | 261 | const repoPath = repo?.repoRoot; |
| b69ab31 | | | 262 | const diffSummaryResult = useAtomValue(diffSummary(diffId)); |
| b69ab31 | | | 263 | |
| b69ab31 | | | 264 | // Only show the button if there are failed signals |
| b69ab31 | | | 265 | if ( |
| b69ab31 | | | 266 | diffSummaryResult.error || |
| b69ab31 | | | 267 | !diffSummaryResult.value?.signalSummary || |
| b69ab31 | | | 268 | diffSummaryResult.value.signalSummary !== 'failed' |
| b69ab31 | | | 269 | ) { |
| b69ab31 | | | 270 | return null; |
| b69ab31 | | | 271 | } |
| b69ab31 | | | 272 | |
| b69ab31 | | | 273 | const diffVersionNumber = Internal.getDiffVersionNumber?.(diffSummaryResult.value, hash); |
| b69ab31 | | | 274 | |
| b69ab31 | | | 275 | const button = ( |
| b69ab31 | | | 276 | <Button |
| b69ab31 | | | 277 | data-testid="resolve-failed-signals-button" |
| b69ab31 | | | 278 | onClick={e => { |
| b69ab31 | | | 279 | if (diffVersionNumber !== undefined) { |
| b69ab31 | | | 280 | tracker.track('SmartActionClicked', {extras: {action: 'ResolveFailedSignals'}}); |
| b69ab31 | | | 281 | serverAPI.postMessage({ |
| b69ab31 | | | 282 | type: 'platform/resolveFailedSignalsWithAI', |
| b69ab31 | | | 283 | diffId, |
| b69ab31 | | | 284 | diffVersionNumber, |
| b69ab31 | | | 285 | repoPath, |
| b69ab31 | | | 286 | }); |
| b69ab31 | | | 287 | dismiss(); |
| b69ab31 | | | 288 | } |
| b69ab31 | | | 289 | e.stopPropagation(); |
| b69ab31 | | | 290 | }} |
| b69ab31 | | | 291 | disabled={disabled || diffVersionNumber === undefined}> |
| b69ab31 | | | 292 | <Icon icon="sparkle" /> |
| b69ab31 | | | 293 | <T>Fix failed signals</T> |
| b69ab31 | | | 294 | </Button> |
| b69ab31 | | | 295 | ); |
| b69ab31 | | | 296 | |
| b69ab31 | | | 297 | return disabled || diffVersionNumber === undefined ? ( |
| b69ab31 | | | 298 | <Tooltip |
| b69ab31 | | | 299 | title={ |
| b69ab31 | | | 300 | diffVersionNumber === undefined |
| b69ab31 | | | 301 | ? 'Unable to determine Phabricator version number for this commit' |
| b69ab31 | | | 302 | : disabledReason |
| b69ab31 | | | 303 | }> |
| b69ab31 | | | 304 | {button} |
| b69ab31 | | | 305 | </Tooltip> |
| b69ab31 | | | 306 | ) : ( |
| b69ab31 | | | 307 | button |
| b69ab31 | | | 308 | ); |
| b69ab31 | | | 309 | } |
| b69ab31 | | | 310 | |
| b69ab31 | | | 311 | function GenerateTestsForModifiedCodeButton({ |
| b69ab31 | | | 312 | dismiss, |
| b69ab31 | | | 313 | disabled, |
| b69ab31 | | | 314 | disabledReason, |
| b69ab31 | | | 315 | }: { |
| b69ab31 | | | 316 | dismiss: () => void; |
| b69ab31 | | | 317 | disabled?: boolean; |
| b69ab31 | | | 318 | disabledReason?: string; |
| b69ab31 | | | 319 | }) { |
| b69ab31 | | | 320 | const button = ( |
| b69ab31 | | | 321 | <Button |
| b69ab31 | | | 322 | data-testid="generate-tests-for-modified-code-button" |
| b69ab31 | | | 323 | onClick={e => { |
| b69ab31 | | | 324 | tracker.track('SmartActionClicked', {extras: {action: 'GenerateTests'}}); |
| b69ab31 | | | 325 | serverAPI.postMessage({ |
| b69ab31 | | | 326 | type: 'platform/createTestForModifiedCodeWithAI', |
| b69ab31 | | | 327 | }); |
| b69ab31 | | | 328 | dismiss(); |
| b69ab31 | | | 329 | e.stopPropagation(); |
| b69ab31 | | | 330 | }} |
| b69ab31 | | | 331 | disabled={disabled}> |
| b69ab31 | | | 332 | <Icon icon="sparkle" /> |
| b69ab31 | | | 333 | <T>Generate tests for changes</T> |
| b69ab31 | | | 334 | </Button> |
| b69ab31 | | | 335 | ); |
| b69ab31 | | | 336 | |
| b69ab31 | | | 337 | return disabled ? <Tooltip title={disabledReason}>{button}</Tooltip> : button; |
| b69ab31 | | | 338 | } |
| b69ab31 | | | 339 | |
| b69ab31 | | | 340 | /** Prompt AI to validate code and fix errors in the working copy. */ |
| b69ab31 | | | 341 | function ValidateChangesButton({dismiss}: {dismiss: () => void}) { |
| b69ab31 | | | 342 | return ( |
| b69ab31 | | | 343 | <Button |
| b69ab31 | | | 344 | data-testid="validate-changes-button" |
| b69ab31 | | | 345 | onClick={e => { |
| b69ab31 | | | 346 | tracker.track('SmartActionClicked', {extras: {action: 'ValidateChanges'}}); |
| b69ab31 | | | 347 | serverAPI.postMessage({ |
| b69ab31 | | | 348 | type: 'platform/validateChangesWithAI', |
| b69ab31 | | | 349 | }); |
| b69ab31 | | | 350 | dismiss(); |
| b69ab31 | | | 351 | e.stopPropagation(); |
| b69ab31 | | | 352 | }}> |
| b69ab31 | | | 353 | <Icon icon="sparkle" /> |
| b69ab31 | | | 354 | <T>Validate Changes</T> |
| b69ab31 | | | 355 | </Button> |
| b69ab31 | | | 356 | ); |
| b69ab31 | | | 357 | } |
| b69ab31 | | | 358 | |
| b69ab31 | | | 359 | /** Prompt AI to review the current commit and add comments */ |
| b69ab31 | | | 360 | function ReviewCodeButton({ |
| b69ab31 | | | 361 | commit, |
| b69ab31 | | | 362 | dismiss, |
| b69ab31 | | | 363 | disabled, |
| b69ab31 | | | 364 | disabledReason, |
| b69ab31 | | | 365 | }: { |
| b69ab31 | | | 366 | commit?: CommitInfo; |
| b69ab31 | | | 367 | dismiss: () => void; |
| b69ab31 | | | 368 | disabled?: boolean; |
| b69ab31 | | | 369 | disabledReason?: string; |
| b69ab31 | | | 370 | }) { |
| b69ab31 | | | 371 | const button = ( |
| b69ab31 | | | 372 | <Button |
| b69ab31 | | | 373 | data-testid="review-commit-button" |
| b69ab31 | | | 374 | onClick={e => { |
| b69ab31 | | | 375 | tracker.track('SmartActionClicked', {extras: {action: 'ReviewCommit'}}); |
| b69ab31 | | | 376 | serverAPI.postMessage({ |
| b69ab31 | | | 377 | type: 'platform/runAICodeReviewChat', |
| b69ab31 | | | 378 | source: 'smartAction', |
| b69ab31 | | | 379 | reviewScope: commit ? 'current commit' : 'uncommitted changes', |
| b69ab31 | | | 380 | }); |
| b69ab31 | | | 381 | dismiss(); |
| b69ab31 | | | 382 | e.stopPropagation(); |
| b69ab31 | | | 383 | }} |
| b69ab31 | | | 384 | disabled={disabled}> |
| b69ab31 | | | 385 | <Icon icon="sparkle" /> |
| b69ab31 | | | 386 | <T>{commit ? 'Review commit' : 'Review changes'}</T> |
| b69ab31 | | | 387 | </Button> |
| b69ab31 | | | 388 | ); |
| b69ab31 | | | 389 | |
| b69ab31 | | | 390 | return disabled ? <Tooltip title={disabledReason}>{button}</Tooltip> : button; |
| b69ab31 | | | 391 | } |