@@ -4,8 +4,8 @@ import { create } from "zustand";
44import { persist } from "zustand/middleware" ;
55
66interface SessionConfigState {
7- /** Map of taskRunId -> persisted config options */
87 configsByRunId : Record < string , SessionConfigOption [ ] > ;
8+ alwaysOnSkillInstructionsByRunId : Record < string , string > ;
99}
1010
1111interface SessionConfigActions {
@@ -15,6 +15,12 @@ interface SessionConfigActions {
1515 getConfigOptions : ( taskRunId : string ) => SessionConfigOption [ ] | undefined ;
1616 /** Remove config options for a task run */
1717 removeConfigOptions : ( taskRunId : string ) => void ;
18+ setAlwaysOnSkillInstructions : (
19+ taskRunId : string ,
20+ instructions : string ,
21+ ) => void ;
22+ getAlwaysOnSkillInstructions : ( taskRunId : string ) => string | undefined ;
23+ removeAlwaysOnSkillInstructions : ( taskRunId : string ) => void ;
1824}
1925
2026type SessionConfigStore = SessionConfigState & SessionConfigActions ;
@@ -23,6 +29,7 @@ export const useSessionConfigStore = create<SessionConfigStore>()(
2329 persist (
2430 ( set , get ) => ( {
2531 configsByRunId : { } ,
32+ alwaysOnSkillInstructionsByRunId : { } ,
2633
2734 setConfigOptions : ( taskRunId , options ) =>
2835 set ( ( state ) => ( {
@@ -36,11 +43,30 @@ export const useSessionConfigStore = create<SessionConfigStore>()(
3643 const { [ taskRunId ] : _removed , ...rest } = state . configsByRunId ;
3744 return { configsByRunId : rest } ;
3845 } ) ,
46+ setAlwaysOnSkillInstructions : ( taskRunId , instructions ) =>
47+ set ( ( state ) => ( {
48+ alwaysOnSkillInstructionsByRunId : {
49+ ...state . alwaysOnSkillInstructionsByRunId ,
50+ [ taskRunId ] : instructions ,
51+ } ,
52+ } ) ) ,
53+ getAlwaysOnSkillInstructions : ( taskRunId ) =>
54+ get ( ) . alwaysOnSkillInstructionsByRunId [ taskRunId ] ,
55+ removeAlwaysOnSkillInstructions : ( taskRunId ) =>
56+ set ( ( state ) => {
57+ const { [ taskRunId ] : _removed , ...rest } =
58+ state . alwaysOnSkillInstructionsByRunId ;
59+ return { alwaysOnSkillInstructionsByRunId : rest } ;
60+ } ) ,
3961 } ) ,
4062 {
4163 name : "session-config-storage" ,
4264 storage : electronStorage ,
43- partialize : ( state ) => ( { configsByRunId : state . configsByRunId } ) ,
65+ partialize : ( state ) => ( {
66+ configsByRunId : state . configsByRunId ,
67+ alwaysOnSkillInstructionsByRunId :
68+ state . alwaysOnSkillInstructionsByRunId ,
69+ } ) ,
4470 } ,
4571 ) ,
4672) ;
@@ -64,3 +90,26 @@ export function setPersistedConfigOptions(
6490export function removePersistedConfigOptions ( taskRunId : string ) : void {
6591 useSessionConfigStore . getState ( ) . removeConfigOptions ( taskRunId ) ;
6692}
93+
94+ export function getPersistedAlwaysOnSkillInstructions (
95+ taskRunId : string ,
96+ ) : string | undefined {
97+ return useSessionConfigStore
98+ . getState ( )
99+ . getAlwaysOnSkillInstructions ( taskRunId ) ;
100+ }
101+
102+ export function setPersistedAlwaysOnSkillInstructions (
103+ taskRunId : string ,
104+ instructions : string ,
105+ ) : void {
106+ useSessionConfigStore
107+ . getState ( )
108+ . setAlwaysOnSkillInstructions ( taskRunId , instructions ) ;
109+ }
110+
111+ export function removePersistedAlwaysOnSkillInstructions (
112+ taskRunId : string ,
113+ ) : void {
114+ useSessionConfigStore . getState ( ) . removeAlwaysOnSkillInstructions ( taskRunId ) ;
115+ }
0 commit comments