@@ -119,6 +119,7 @@ import { UserReference } from '@worldbrain/memex-common/lib/web-interface/types/
119
119
import { convertLinksInAIResponse } from '@worldbrain/memex-common/lib/ai-chat/utils'
120
120
import { DEFAULT_AI_MODEL } from '@worldbrain/memex-common/lib/ai-chat/constants'
121
121
import { HighlightRendererInterface } from '@worldbrain/memex-common/lib/in-page-ui/highlighting/types'
122
+ import { PromptTemplate } from 'src/common-ui/components/prompt-templates/types'
122
123
const md = new MarkdownIt ( )
123
124
124
125
export type SidebarContainerOptions = SidebarContainerDependencies & {
@@ -3576,14 +3577,24 @@ export class SidebarContainerLogic extends UILogic<
3576
3577
let prompt = event . prompt
3577
3578
3578
3579
if ( event . prompt == null ) {
3579
- const syncsettings =
3580
- ( await this . syncSettings . openAI ?. get ( 'promptSuggestions' ) ) ??
3581
- AI_PROMPT_DEFAULTS . map ( ( text ) => ( {
3580
+ let savedPrompts = await this . syncSettings . openAI ?. get (
3581
+ 'promptSuggestions' ,
3582
+ )
3583
+ if ( ! savedPrompts ) {
3584
+ savedPrompts = AI_PROMPT_DEFAULTS . map ( ( text ) => ( {
3582
3585
text,
3583
3586
isEditing : null ,
3584
3587
isFocused : false ,
3585
3588
} ) )
3586
- prompt = marked . parse ( syncsettings [ 0 ] . text )
3589
+ } else if ( typeof savedPrompts [ 0 ] === 'string' ) {
3590
+ savedPrompts = ( ( savedPrompts as unknown ) as string [ ] ) . map (
3591
+ ( text ) => ( {
3592
+ text : text ,
3593
+ } ) ,
3594
+ )
3595
+ this . syncSettings . openAI ?. set ( 'promptSuggestions' , savedPrompts )
3596
+ }
3597
+ prompt = marked . parse ( savedPrompts [ 0 ] . text )
3587
3598
}
3588
3599
3589
3600
if ( event . textToProcess ) {
@@ -3609,21 +3620,6 @@ export class SidebarContainerLogic extends UILogic<
3609
3620
}
3610
3621
if ( ! event . textToProcess ) {
3611
3622
let executed = false
3612
- let prompt = event . prompt
3613
-
3614
- if ( event . prompt == null ) {
3615
- const syncsettings =
3616
- ( await this . syncSettings . openAI ?. get (
3617
- 'promptSuggestions' ,
3618
- ) ) ??
3619
- AI_PROMPT_DEFAULTS . map ( ( text ) => ( {
3620
- text,
3621
- isEditing : null ,
3622
- isFocused : false ,
3623
- } ) )
3624
- prompt = marked . parse ( syncsettings [ 0 ] . text )
3625
- }
3626
-
3627
3623
let retries = 0
3628
3624
const maxRetries = 100
3629
3625
while ( ! executed && retries < maxRetries ) {
@@ -3663,7 +3659,7 @@ export class SidebarContainerLogic extends UILogic<
3663
3659
isEditing : null ,
3664
3660
isFocused : false ,
3665
3661
} ) )
3666
- prompt = syncsettings [ 0 ] . text
3662
+ prompt = syncsettings [ 0 ] ? .text
3667
3663
}
3668
3664
3669
3665
if ( previousState . activeTab === 'summary' ) {
0 commit comments