diff --git a/packages/ui/src/lib/api/cloud/api.ts b/packages/ui/src/lib/api/cloud/api.ts index edf44371e..73e41a799 100644 --- a/packages/ui/src/lib/api/cloud/api.ts +++ b/packages/ui/src/lib/api/cloud/api.ts @@ -173,7 +173,7 @@ export function getCloudApiClient( summarize: { commit: ( token: string, - params: { diff: string; uid?: string } + params: { diff: string; uid?: string, brief?: boolean, emoji?: boolean } ): Promise<{ message: string }> => fetch(getUrl('summarize/commit.json'), { method: 'POST', diff --git a/packages/ui/src/lib/config/config.ts b/packages/ui/src/lib/config/config.ts index ec51e0f98..4fb935115 100644 --- a/packages/ui/src/lib/config/config.ts +++ b/packages/ui/src/lib/config/config.ts @@ -9,3 +9,13 @@ export function projectMergeUpstreamWarningDismissed(projectId: string): Persist const key = 'projectMergeUpstreamWarningDismissed_'; return persisted(false, key + projectId); } + +export function projectCommitGenerationExtraConcise(projectId: string): Persisted { + const key = 'projectCommitGenerationExtraConcise_'; + return persisted(false, key + projectId); +} + +export function projectCommitGenerationUseEmojis(projectId: string): Persisted { + const key = 'projectCommitGenerationUseEmojis_'; + return persisted(false, key + projectId); +} diff --git a/packages/ui/src/routes/repo/[projectId]/BranchLane.svelte b/packages/ui/src/routes/repo/[projectId]/BranchLane.svelte index 02a0a0133..0a0ee363d 100644 --- a/packages/ui/src/routes/repo/[projectId]/BranchLane.svelte +++ b/packages/ui/src/routes/repo/[projectId]/BranchLane.svelte @@ -507,7 +507,7 @@ {#if !maximized} (); let commitMessage: string; - $: messageRows = Math.min(Math.max(commitMessage ? commitMessage.split('\n').length : 0, 1), 10); + $: messageRows = + Math.min(Math.max(commitMessage ? commitMessage.split('\n').length : 0, 1), 10) + 2; function commit() { branchController.commitBranch({ @@ -46,12 +51,8 @@ $: checkCommitsAnnotated(); let isGeneratingCommigMessage = false; - function trimNonLetters(input: string): string { - const regex = /^[^a-zA-Z]+|[^a-zA-Z]+$/g; - const trimmedString = input.replace(regex, ''); - return trimmedString; - } async function generateCommitMessage(files: File[]) { + expanded = false; const diff = files .map((f) => f.hunks) .flat() @@ -66,15 +67,15 @@ cloud.summarize .commit(user.access_token, { diff, - uid: projectId + uid: projectId, + brief: $commitGenerationExtraConcise, + emoji: $commitGenerationUseEmojis }) .then(({ message }) => { const firstNewLine = message.indexOf('\n'); const summary = firstNewLine > -1 ? message.slice(0, firstNewLine).trim() : message; const description = firstNewLine > -1 ? message.slice(firstNewLine + 1).trim() : ''; - commitMessage = trimNonLetters( - description.length > 0 ? `${summary}\n\n${description}` : summary - ); + commitMessage = description.length > 0 ? `${summary}\n\n${description}` : summary; }) .catch(() => { toasts.error('Failed to generate commit message'); @@ -83,6 +84,9 @@ isGeneratingCommigMessage = false; }); } + let expanded = false; + const commitGenerationExtraConcise = projectCommitGenerationExtraConcise(projectId); + const commitGenerationUseEmojis = projectCommitGenerationUseEmojis(projectId);
@@ -108,21 +112,69 @@ />
-
+
{#if cloudEnabled && user} - +
+ + +
+ {#if expanded} +
+ + +
+ {/if} +
{:else}