@@ -44,6 +44,7 @@ import { TextGeneration } from "../../git/Services/TextGeneration.ts";
4444import { ProviderService } from "../../provider/Services/ProviderService.ts" ;
4545import { clearWorkspaceIndexCache } from "../../workspaceEntries.ts" ;
4646import {
47+ buildPriorTranscriptBootstrapText ,
4748 buildForkBootstrapText ,
4849 buildHandoffBootstrapText ,
4950 hasNativeAssistantMessagesBefore ,
@@ -793,6 +794,11 @@ const make = Effect.gen(function* () {
793794 if ( ! thread ) {
794795 return ;
795796 }
797+ const activeSessionBeforeEnsure = yield * providerService
798+ . listSessions ( )
799+ . pipe (
800+ Effect . map ( ( sessions ) => sessions . find ( ( session ) => session . threadId === input . threadId ) ) ,
801+ ) ;
796802 yield * ensureSessionForThread ( input . threadId , input . createdAt , {
797803 ...( input . modelSelection !== undefined ? { modelSelection : input . modelSelection } : { } ) ,
798804 ...( input . providerOptions !== undefined ? { providerOptions : input . providerOptions } : { } ) ,
@@ -825,13 +831,29 @@ const make = Effect.gen(function* () {
825831 shouldBootstrapSidechatContext && availableBootstrapChars > 0
826832 ? buildForkBootstrapText ( thread , availableBootstrapChars )
827833 : null ;
834+ const selectedProvider =
835+ input . modelSelection ?. provider ??
836+ threadModelSelections . get ( input . threadId ) ?. provider ??
837+ thread . session ?. providerName ??
838+ thread . modelSelection . provider ;
839+ const shouldBootstrapPriorTranscriptContext =
840+ ( selectedProvider === "kilo" || selectedProvider === "opencode" ) &&
841+ activeSessionBeforeEnsure === undefined &&
842+ ! handoffBootstrapText &&
843+ ! sidechatBootstrapText ;
844+ const priorTranscriptBootstrapText =
845+ shouldBootstrapPriorTranscriptContext && availableBootstrapChars > 0
846+ ? buildPriorTranscriptBootstrapText ( thread , input . messageId , availableBootstrapChars )
847+ : null ;
828848 const boundaryMessageText = thread . sidechatSourceThreadId
829849 ? wrapSidechatInput ( input . messageText )
830850 : input . messageText ;
831851 const providerInput = handoffBootstrapText
832852 ? `<handoff_context>\n${ handoffBootstrapText } \n</handoff_context>\n\n<latest_user_message>\n${ boundaryMessageText } \n</latest_user_message>`
833853 : sidechatBootstrapText
834854 ? `<sidechat_context>\n${ sidechatBootstrapText } \n</sidechat_context>\n\n${ boundaryMessageText } `
855+ : priorTranscriptBootstrapText
856+ ? `<thread_context>\n${ priorTranscriptBootstrapText } \n</thread_context>\n\n<latest_user_message>\n${ boundaryMessageText } \n</latest_user_message>`
835857 : boundaryMessageText ;
836858 const normalizedInput = toNonEmptyProviderInput ( providerInput ) ;
837859 const normalizedAttachments = input . attachments ?? [ ] ;
0 commit comments