Przeglądaj źródła

feat(speaking): add per-mode prompt/greeting slots + hydrateDefaults action

jimmylee 1 miesiąc temu
rodzic
commit
a157e05f74
1 zmienionych plików z 31 dodań i 0 usunięć
  1. 31 0
      src/store/speaking.ts

+ 31 - 0
src/store/speaking.ts

@@ -42,6 +42,12 @@ const DEFAULT_CONFIG: TopicDiscussionConfig = {
   },
   videoScene: {
     enabled: false,
+    systemPrompt: '',
+    greeting: '',
+  },
+  nonVideoScene: {
+    systemPrompt: '',
+    greeting: '',
   },
 }
 
@@ -74,6 +80,12 @@ const EMPTY_CONFIG: TopicDiscussionConfig = {
   },
   videoScene: {
     enabled: false,
+    systemPrompt: '',
+    greeting: '',
+  },
+  nonVideoScene: {
+    systemPrompt: '',
+    greeting: '',
   },
 }
 
@@ -174,5 +186,24 @@ export const useSpeakingStore = defineStore('speaking', {
     toggleVideoScene() {
       this.config.videoScene.enabled = !this.config.videoScene.enabled
     },
+
+    hydrateDefaults(payload: {
+      videoScene: { systemPrompt: string; greeting: string }
+      nonVideoScene: { systemPrompt: string; greeting: string }
+    }) {
+      // Fill only empty slots — preserve any teacher edits already present.
+      if (!this.config.videoScene.systemPrompt) {
+        this.config.videoScene.systemPrompt = payload.videoScene.systemPrompt
+      }
+      if (!this.config.videoScene.greeting) {
+        this.config.videoScene.greeting = payload.videoScene.greeting
+      }
+      if (!this.config.nonVideoScene.systemPrompt) {
+        this.config.nonVideoScene.systemPrompt = payload.nonVideoScene.systemPrompt
+      }
+      if (!this.config.nonVideoScene.greeting) {
+        this.config.nonVideoScene.greeting = payload.nonVideoScene.greeting
+      }
+    },
   },
 })