mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-08-26 17:31:55 +00:00
Reuse loaded AI config when restarting stopped service
This commit is contained in:
parent
ba3cdca961
commit
716340dcd6
2 changed files with 7 additions and 3 deletions
|
|
@ -311,6 +311,10 @@ type AIStateProvider interface {
|
|||
func (h *AIHandler) Start(ctx context.Context, stateProvider AIStateProvider) error {
|
||||
log.Info().Msg("AIHandler.Start called")
|
||||
aiCfg := h.loadAIConfig(ctx)
|
||||
return h.startWithConfig(ctx, stateProvider, aiCfg)
|
||||
}
|
||||
|
||||
func (h *AIHandler) startWithConfig(ctx context.Context, stateProvider AIStateProvider, aiCfg *config.AIConfig) error {
|
||||
if aiCfg == nil {
|
||||
log.Info().Msg("AI config is nil, AI is disabled")
|
||||
return nil
|
||||
|
|
@ -396,7 +400,7 @@ func (h *AIHandler) Restart(ctx context.Context) error {
|
|||
}
|
||||
h.stateProvidersMu.RUnlock()
|
||||
|
||||
return h.Start(ctx, sp)
|
||||
return h.startWithConfig(ctx, sp, newCfg)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -307,7 +307,7 @@ func TestRestart_StartsStoppedServiceWithSavedStateProvider(t *testing.T) {
|
|||
assert.Equal(t, "data", capturedCfg.DataDir)
|
||||
}
|
||||
|
||||
func TestStart_AllowsEmptyPersistenceDataDir(t *testing.T) {
|
||||
func TestStart_DefaultsEmptyPersistenceDataDir(t *testing.T) {
|
||||
oldNewService := newChatService
|
||||
defer func() { newChatService = oldNewService }()
|
||||
|
||||
|
|
@ -327,7 +327,7 @@ func TestStart_AllowsEmptyPersistenceDataDir(t *testing.T) {
|
|||
|
||||
err := h.Start(context.Background(), mockState)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "", capturedCfg.DataDir)
|
||||
assert.Equal(t, "data", capturedCfg.DataDir)
|
||||
assert.Same(t, mockState, capturedCfg.StateProvider)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue