File tree Expand file tree Collapse file tree 3 files changed +17
-5
lines changed
Expand file tree Collapse file tree 3 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ interface SummarizeCommitOpts extends BaseAIServiceOpts {
6262}
6363
6464interface SummarizeBranchOpts extends BaseAIServiceOpts {
65- hunks : Hunk [ ] ;
65+ hunks : DiffInput [ ] ;
6666 branchTemplate ?: Prompt ;
6767}
6868
@@ -75,8 +75,13 @@ interface SummarizePROpts extends BaseAIServiceOpts {
7575 prBodyTemplate ?: string ;
7676}
7777
78+ interface DiffInput {
79+ filePath : string ;
80+ diff : string ;
81+ }
82+
7883// Exported for testing only
79- export function buildDiff ( hunks : Hunk [ ] , limit : number ) {
84+ export function buildDiff ( hunks : DiffInput [ ] , limit : number ) {
8085 return shuffle ( hunks . map ( ( h ) => `${ h . filePath } - ${ h . diff } ` ) )
8186 . join ( '\n' )
8287 . slice ( 0 , limit ) ;
Original file line number Diff line number Diff line change 2323 import { isFailure } from ' $lib/result' ;
2424 import { openExternalUrl } from ' $lib/utils/url' ;
2525 import { BranchController } from ' $lib/vbranches/branchController' ;
26+ import { listCommitFiles } from ' $lib/vbranches/remoteCommits' ;
2627 import { PatchSeries , VirtualBranch , type CommitStatus } from ' $lib/vbranches/types' ;
2728 import { CloudBranchesService } from ' @gitbutler/shared/cloud/stacks/service' ;
2829 import { getContext , getContextStore } from ' @gitbutler/shared/context' ;
140141 async function generateBranchName() {
141142 if (! aiGenEnabled || ! currentSeries ) return ;
142143
143- const hunks = currentSeries .patches .flatMap ((p ) => p .files .flatMap ((f ) => f .hunks ));
144+ let hunk_promises = currentSeries .patches .flatMap (async (p ) => {
145+ let files = await listCommitFiles (project .id , p .id );
146+ return files .flatMap ((f ) =>
147+ f .hunks .map ((h ) => {
148+ return { filePath: f .path , diff: h .diff };
149+ })
150+ );
151+ });
152+ let hunks = (await Promise .all (hunk_promises )).flat ();
144153
145154 const prompt = promptService .selectedBranchPrompt (project .id );
146155 const messageResult = await aiService .summarizeBranch ({
Original file line number Diff line number Diff line change @@ -204,8 +204,6 @@ export class DetailedCommit {
204204 createdAt ! : Date ;
205205 isRemote ! : boolean ;
206206 isIntegrated ! : boolean ;
207- @Type ( ( ) => LocalFile )
208- files ! : LocalFile [ ] ;
209207 parentIds ! : string [ ] ;
210208 branchId ! : string ;
211209 changeId ! : string ;
You can’t perform that action at this time.
0 commit comments