Skip to content

Commit 6069f5c

Browse files
authored
Merge pull request #9444 from gitbutlerapp/feature-ai-experimental-flags
Add experimental AI feature flags and UI updates
2 parents 1924c98 + 77b28c7 commit 6069f5c

File tree

3 files changed

+40
-4
lines changed

3 files changed

+40
-4
lines changed

apps/desktop/src/components/CloudForm.svelte

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import AiPromptSelect from '$components/AIPromptSelect.svelte';
44
import Section from '$components/Section.svelte';
55
import WelcomeSigninAction from '$components/WelcomeSigninAction.svelte';
6-
import { projectAiGenEnabled } from '$lib/config/config';
6+
import { projectAiExperimentalFeaturesEnabled, projectAiGenEnabled } from '$lib/config/config';
77
import { Project } from '$lib/project/project';
88
import { UserService } from '$lib/user/userService';
99
import { getContext } from '@gitbutler/shared/context';
@@ -16,7 +16,8 @@
1616
const project = getContext(Project);
1717
const user = userService.user;
1818
19-
const aiGenEnabled = projectAiGenEnabled(project.id);
19+
const aiGenEnabled = $derived(projectAiGenEnabled(project.id));
20+
const experimentalAiGenEnabled = $derived(projectAiExperimentalFeaturesEnabled(project.id));
2021
</script>
2122

2223
<Section>
@@ -54,6 +55,33 @@
5455
</SectionCard>
5556
</div>
5657

58+
{#if $aiGenEnabled}
59+
<div class="options">
60+
<SectionCard labelFor="aiExperimental" orientation="row">
61+
{#snippet title()}
62+
Enable experimental AI features
63+
{/snippet}
64+
{#snippet caption()}
65+
If enabled, you will be able tu access the AI features currently in development.
66+
67+
<b
68+
>This also requires you to use OpenAI through GitButler in order for the features to
69+
work.</b
70+
>
71+
{/snippet}
72+
{#snippet actions()}
73+
<Toggle
74+
id="aiExperimental"
75+
checked={$experimentalAiGenEnabled}
76+
onclick={() => {
77+
$experimentalAiGenEnabled = !$experimentalAiGenEnabled;
78+
}}
79+
/>
80+
{/snippet}
81+
</SectionCard>
82+
</div>
83+
{/if}
84+
5785
<SectionCard>
5886
{#snippet title()}
5987
Custom prompts

apps/desktop/src/components/v3/FileContextMenu.svelte

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { AIService } from '$lib/ai/service';
55
import { writeClipboard } from '$lib/backend/clipboard';
66
import { changesToDiffSpec } from '$lib/commits/utils';
7-
import { projectAiGenEnabled } from '$lib/config/config';
7+
import { projectAiExperimentalFeaturesEnabled, projectAiGenEnabled } from '$lib/config/config';
88
import { isTreeChange, type TreeChange } from '$lib/hunks/change';
99
import { showToast } from '$lib/notifications/toasts';
1010
import { Project } from '$lib/project/project';
@@ -74,8 +74,11 @@
7474
let aiConfigurationValid = $state(false);
7575
7676
const aiGenEnabled = $derived(projectAiGenEnabled(projectId));
77+
const experimentalFeaturesEnabled = $derived(projectAiExperimentalFeaturesEnabled(projectId));
7778
78-
const canUseGBAI = $derived(aiGenEnabled && aiConfigurationValid);
79+
const canUseGBAI = $derived(
80+
$aiGenEnabled && aiConfigurationValid && $experimentalFeaturesEnabled
81+
);
7982
8083
function isDeleted(item: FileItem): boolean {
8184
return item.changes.some((change) => {

apps/desktop/src/lib/config/config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ export function projectAiGenEnabled(projectId: string): Persisted<boolean> {
3838
return persisted(false, key + projectId);
3939
}
4040

41+
export function projectAiExperimentalFeaturesEnabled(projectId: string): Persisted<boolean> {
42+
const key = 'projectAiExperimentalFeaturesEnabled_';
43+
return persisted(false, key + projectId);
44+
}
45+
4146
export function projectRunCommitHooks(projectId: string): Persisted<boolean> {
4247
const key = 'projectRunCommitHooks_';
4348
return persisted(false, key + projectId);

0 commit comments

Comments
 (0)