-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathaction-required-shared.ts
More file actions
111 lines (99 loc) · 4.82 KB
/
action-required-shared.ts
File metadata and controls
111 lines (99 loc) · 4.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
export const CODE_REVIEW_ACTION_REQUIRED_RUNTIME_STATE_KEY = 'code_review_action_required';
export const CODE_REVIEW_ACTION_REQUIRED_REASONS = [
'github_installation_required',
'github_ip_allow_list',
'byok_invalid_key',
'selected_model_unavailable',
] as const;
export type CodeReviewActionRequiredReason = (typeof CODE_REVIEW_ACTION_REQUIRED_REASONS)[number];
export type CodeReviewActionRequiredState = {
reason: CodeReviewActionRequiredReason;
detectedAt: string;
lastSeenAt: string;
triggeringReviewId?: string;
lastErrorMessage: string;
emailSentAt?: string;
};
export type CodeReviewActionRequiredCopy = {
title: string;
description: string;
recoveryLabel: string;
emailReason: string;
checkTitle: string;
checkSummary: string;
gitlabDescription: string;
};
const COPY_BY_REASON = {
github_installation_required: {
title: 'Code Reviewer needs attention',
description:
'Code Reviewer was disabled because Kilo cannot access this repository with an active GitHub App installation. Update the GitHub App installation, then enable Code Reviewer again.',
recoveryLabel: 'Update GitHub App',
emailReason: 'Kilo cannot access this repository with an active GitHub App installation.',
checkTitle: 'GitHub App access required',
checkSummary:
'Code Reviewer was disabled because Kilo cannot access this repository with an active GitHub App installation. Update the GitHub App installation, then enable Code Reviewer again.',
gitlabDescription: 'GitHub App access required for Code Reviewer',
},
github_ip_allow_list: {
title: 'Code Reviewer needs attention',
description:
'Code Reviewer was disabled because this GitHub organization uses an IP allow list that blocks Kilo. Contact hi@kilocode.ai to discuss supported access options, then enable Code Reviewer again.',
recoveryLabel: 'Contact support',
emailReason: 'This GitHub organization uses an IP allow list that blocks Kilo.',
checkTitle: 'GitHub IP allow list blocks Kilo',
checkSummary:
'Code Reviewer was disabled because this GitHub organization uses an IP allow list that blocks Kilo. Contact hi@kilocode.ai, then enable Code Reviewer again.',
gitlabDescription: 'GitHub IP allow list blocks Code Reviewer',
},
byok_invalid_key: {
title: 'Code Reviewer needs attention',
description:
'Code Reviewer was disabled because the selected BYOK API key is invalid or has been revoked. Update the key or choose another model, then enable Code Reviewer again.',
recoveryLabel: 'Update BYOK settings',
emailReason: 'The selected BYOK API key is invalid or has been revoked.',
checkTitle: 'BYOK API key needs attention',
checkSummary:
'Code Reviewer was disabled because the selected BYOK API key is invalid or has been revoked. Update the key or choose another model, then enable Code Reviewer again.',
gitlabDescription: 'BYOK API key needs attention for Code Reviewer',
},
selected_model_unavailable: {
title: 'Code Reviewer needs attention',
description:
'Code Reviewer was disabled because the selected model is not available for cloud agent sessions. Choose an available model, then enable Code Reviewer again.',
recoveryLabel: 'Update Code Reviewer settings',
emailReason: 'The selected model is not available for cloud agent sessions.',
checkTitle: 'Selected model unavailable',
checkSummary:
'Code Reviewer was disabled because the selected model is not available for cloud agent sessions. Choose an available model, then enable Code Reviewer again.',
gitlabDescription: 'Selected model unavailable for Code Reviewer',
},
} satisfies Record<CodeReviewActionRequiredReason, CodeReviewActionRequiredCopy>;
const ACTION_REQUIRED_REASON_SET = new Set<string>(CODE_REVIEW_ACTION_REQUIRED_REASONS);
export function isCodeReviewActionRequiredReason(
reason: string | null | undefined
): reason is CodeReviewActionRequiredReason {
return reason !== null && reason !== undefined && ACTION_REQUIRED_REASON_SET.has(reason);
}
export function getCodeReviewActionRequiredCopy(
reason: CodeReviewActionRequiredReason
): CodeReviewActionRequiredCopy {
return COPY_BY_REASON[reason];
}
export function getCodeReviewActionRequiredRecoveryHref(
reason: CodeReviewActionRequiredReason,
organizationId?: string
): string {
if (reason === 'github_installation_required') {
return organizationId
? `/organizations/${organizationId}/integrations/github`
: '/integrations/github';
}
if (reason === 'github_ip_allow_list') {
return 'mailto:hi@kilocode.ai?subject=GitHub%20IP%20allow%20list%20for%20Code%20Reviewer';
}
if (reason === 'selected_model_unavailable') {
return organizationId ? `/organizations/${organizationId}/code-reviews` : '/code-reviews';
}
return organizationId ? `/organizations/${organizationId}/byok` : '/byok';
}