Skip to content

fix: pre-populate memory onboarding step from existing settings#1992

Open
octo-patch wants to merge 1 commit intoAndyMik90:developfrom
octo-patch:fix/issue-1940-memory-step-defaults
Open

fix: pre-populate memory onboarding step from existing settings#1992
octo-patch wants to merge 1 commit intoAndyMik90:developfrom
octo-patch:fix/issue-1940-memory-step-defaults

Conversation

@octo-patch
Copy link
Copy Markdown

@octo-patch octo-patch commented Apr 2, 2026

Fixes #1940

Problem

The MemoryStep component in the onboarding wizard always initialized with hardcoded defaults, ignoring any previously saved configuration:

  • enabled was hardcoded to true instead of reading settings.memoryEnabled
  • embeddingProvider was hardcoded to 'ollama' instead of reading settings.memoryEmbeddingProvider
  • Azure OpenAI API key, base URL, and deployment were always empty strings
  • Voyage AI API key was always an empty string

When users re-ran the wizard via Settings → Re-run Wizard, the memory step always showed defaults instead of their saved settings. Clicking "Save & Continue" would then silently overwrite their configuration with the defaults.

Solution

Initialize all config fields from the existing settings store values, with appropriate fallbacks:

- enabled: true,
- embeddingProvider: 'ollama',
+ enabled: settings.memoryEnabled ?? true,
+ embeddingProvider: settings.memoryEmbeddingProvider || 'ollama',
  openaiApiKey: settings.globalOpenAIApiKey || '',
  openaiEmbeddingModel: settings.memoryOpenaiEmbeddingModel || '',
- azureOpenaiApiKey: '',
- azureOpenaiBaseUrl: '',
- azureOpenaiEmbeddingDeployment: '',
- voyageApiKey: '',
+ azureOpenaiApiKey: settings.memoryAzureApiKey || '',
+ azureOpenaiBaseUrl: settings.memoryAzureBaseUrl || '',
+ azureOpenaiEmbeddingDeployment: settings.memoryAzureEmbeddingDeployment || '',
+ voyageApiKey: settings.memoryVoyageApiKey || '',

Testing

  • Open the onboarding wizard with existing memory settings (e.g., with Voyage or Azure configured)
  • Verify the wizard now shows the previously saved settings instead of defaults
  • Verify Save & Continue correctly persists the (unchanged) settings

Summary by CodeRabbit

  • Bug Fixes
    • Memory configuration settings are now properly restored from your previous session, ensuring your selected embedding provider and saved API credentials are retained when reopening the app rather than resetting to defaults.

…AndyMik90#1940)

The MemoryStep component in the onboarding wizard always initialized with
hardcoded defaults (enabled=true, provider='ollama', empty Azure/Voyage keys),
ignoring any previously saved configuration.

When users re-ran the wizard via Settings, the memory step showed defaults
instead of their saved settings, which could silently overwrite configuration
on Save.
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 2, 2026

📝 Walkthrough

Walkthrough

Updated the MemoryStep component to initialize its configuration state from persisted settings values instead of hardcoded defaults. The enabled flag, embeddingProvider, and provider-specific API credentials (Azure and Voyage) now correctly source from the stored settings, allowing previously configured memory settings to be properly restored on component render.

Changes

Cohort / File(s) Summary
Memory Settings State Initialization
apps/desktop/src/renderer/components/onboarding/MemoryStep.tsx
Updated useState initial values to source defaults from persisted settings object for memory enabled flag, embedding provider selection, and provider-specific credentials (Azure API key/base URL/deployment, Voyage API key) instead of using empty or hardcoded placeholder values.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 wiggles nose with glee
Settings stored deep in the burrow so warm,
Now MemoryStep remembers their form!
From persisted defaults, no placeholders bare,
Azure and Voyage receive rightful care,
The UI bounds forth with memory so fair! 🌙✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: pre-populating the memory onboarding step from existing settings rather than hardcoded defaults.
Linked Issues check ✅ Passed The PR directly addresses issue #1940 by updating MemoryStep to initialize from persisted settings instead of hardcoded defaults, matching the expected behavior of displaying previously saved memory configuration.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the MemoryStep component initialization from settings; no unrelated modifications or out-of-scope changes are present.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

azureOpenaiEmbeddingDeployment: settings.memoryAzureEmbeddingDeployment || '',
voyageApiKey: settings.memoryVoyageApiKey || '',
voyageEmbeddingModel: settings.memoryVoyageEmbeddingModel || '',
googleApiKey: settings.globalGoogleApiKey || '',
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The memory onboarding step incorrectly uses the global globalGoogleApiKey setting instead of the memory-specific memoryGoogleApiKey, leading to incorrect key persistence and retrieval for Google embeddings.
Severity: MEDIUM

Suggested Fix

Update MemoryStep.tsx to use the memoryGoogleApiKey setting for both reading the initial value and for saving the updated value. Specifically, change settings.globalGoogleApiKey to settings.memoryGoogleApiKey where it's read and written. Additionally, ensure the memory-service-factory.ts uses settings.memoryGoogleApiKey when creating the embedding configuration.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: apps/desktop/src/renderer/components/onboarding/MemoryStep.tsx#L33

Potential issue: The `MemoryStep.tsx` component incorrectly reads from and writes to the
`globalGoogleApiKey` setting instead of the intended `memoryGoogleApiKey`. This is
inconsistent with the handling of Azure and Voyage keys, which were correctly updated in
this PR to use their memory-specific settings. As a result, if a user configures a
Google API key for memory, it will overwrite the global key. When re-running the wizard,
the global key will be displayed, and the memory-specific key will be permanently
ignored, breaking the separation of concerns for memory-specific configurations.

Did we get this right? 👍 / 👎 to inform future reviews.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/desktop/src/renderer/components/onboarding/MemoryStep.tsx (1)

23-38: ⚠️ Potential issue | 🟠 Major

Add useEffect to resync local config state when settings hydrate.

On Line 23, config is initialized from settings only once. Since loadSettings() is async and OnboardingWizard renders before completion, MemoryStep can mount while store settings are still loading with defaults. The local config state never updates when persisted settings arrive, causing Save & Continue to overwrite with defaults instead of pre-populating from existing configuration.

Add a useEffect dependency on settings to resync config when the store updates:

Suggested fix
+import { useEffect, useState } from 'react';
...
   const [config, setConfig] = useState<MemoryPanelConfig>({
     enabled: settings.memoryEnabled ?? true,
     embeddingProvider: settings.memoryEmbeddingProvider || 'ollama',
     openaiApiKey: settings.globalOpenAIApiKey || '',
     openaiEmbeddingModel: settings.memoryOpenaiEmbeddingModel || '',
     azureOpenaiApiKey: settings.memoryAzureApiKey || '',
     azureOpenaiBaseUrl: settings.memoryAzureBaseUrl || '',
     azureOpenaiEmbeddingDeployment: settings.memoryAzureEmbeddingDeployment || '',
     voyageApiKey: settings.memoryVoyageApiKey || '',
     voyageEmbeddingModel: settings.memoryVoyageEmbeddingModel || '',
     googleApiKey: settings.globalGoogleApiKey || '',
     googleEmbeddingModel: settings.memoryGoogleEmbeddingModel || '',
     ollamaBaseUrl: settings.ollamaBaseUrl || 'http://localhost:11434',
     ollamaEmbeddingModel: settings.memoryOllamaEmbeddingModel || 'qwen3-embedding:4b',
     ollamaEmbeddingDim: settings.memoryOllamaEmbeddingDim ?? 2560,
   });
+
+  useEffect(() => {
+    setConfig({
+      enabled: settings.memoryEnabled ?? true,
+      embeddingProvider: settings.memoryEmbeddingProvider || 'ollama',
+      openaiApiKey: settings.globalOpenAIApiKey || '',
+      openaiEmbeddingModel: settings.memoryOpenaiEmbeddingModel || '',
+      azureOpenaiApiKey: settings.memoryAzureApiKey || '',
+      azureOpenaiBaseUrl: settings.memoryAzureBaseUrl || '',
+      azureOpenaiEmbeddingDeployment: settings.memoryAzureEmbeddingDeployment || '',
+      voyageApiKey: settings.memoryVoyageApiKey || '',
+      voyageEmbeddingModel: settings.memoryVoyageEmbeddingModel || '',
+      googleApiKey: settings.globalGoogleApiKey || '',
+      googleEmbeddingModel: settings.memoryGoogleEmbeddingModel || '',
+      ollamaBaseUrl: settings.ollamaBaseUrl || 'http://localhost:11434',
+      ollamaEmbeddingModel: settings.memoryOllamaEmbeddingModel || 'qwen3-embedding:4b',
+      ollamaEmbeddingDim: settings.memoryOllamaEmbeddingDim ?? 2560,
+    });
+  }, [settings]);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/desktop/src/renderer/components/onboarding/MemoryStep.tsx` around lines
23 - 38, MemoryStep initializes local state variable config from settings only
once, so when loadSettings() hydrates asynchronously the prefilled values are
never applied; add a useEffect in the MemoryStep component that watches the
settings object and calls setConfig to resync the local config whenever settings
changes (keep existing default fallbacks when copying values like enabled,
embeddingProvider, openaiApiKey, ollamaBaseUrl, ollamaEmbeddingModel, etc.), so
Save & Continue uses the hydrated store values instead of overwriting with
defaults.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@apps/desktop/src/renderer/components/onboarding/MemoryStep.tsx`:
- Around line 23-38: MemoryStep initializes local state variable config from
settings only once, so when loadSettings() hydrates asynchronously the prefilled
values are never applied; add a useEffect in the MemoryStep component that
watches the settings object and calls setConfig to resync the local config
whenever settings changes (keep existing default fallbacks when copying values
like enabled, embeddingProvider, openaiApiKey, ollamaBaseUrl,
ollamaEmbeddingModel, etc.), so Save & Continue uses the hydrated store values
instead of overwriting with defaults.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1484a5c1-3533-4694-bbf4-921ba924e7aa

📥 Commits

Reviewing files that changed from the base of the PR and between cba7a02 and e75b9f8.

📒 Files selected for processing (1)
  • apps/desktop/src/renderer/components/onboarding/MemoryStep.tsx

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the MemoryStep component to initialize its configuration state using existing values from the settings store instead of hardcoded defaults. A suggestion was made to use lazy initialization for the useState hook to optimize performance by preventing the configuration object from being re-created on every render.

Comment on lines 23 to 34
const [config, setConfig] = useState<MemoryPanelConfig>({
enabled: true,
embeddingProvider: 'ollama',
enabled: settings.memoryEnabled ?? true,
embeddingProvider: settings.memoryEmbeddingProvider || 'ollama',
openaiApiKey: settings.globalOpenAIApiKey || '',
openaiEmbeddingModel: settings.memoryOpenaiEmbeddingModel || '',
azureOpenaiApiKey: '',
azureOpenaiBaseUrl: '',
azureOpenaiEmbeddingDeployment: '',
voyageApiKey: '',
azureOpenaiApiKey: settings.memoryAzureApiKey || '',
azureOpenaiBaseUrl: settings.memoryAzureBaseUrl || '',
azureOpenaiEmbeddingDeployment: settings.memoryAzureEmbeddingDeployment || '',
voyageApiKey: settings.memoryVoyageApiKey || '',
voyageEmbeddingModel: settings.memoryVoyageEmbeddingModel || '',
googleApiKey: settings.globalGoogleApiKey || '',
googleEmbeddingModel: settings.memoryGoogleEmbeddingModel || '',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To avoid re-creating this configuration object on every render, you can use the lazy initialization form of useState. This is a minor performance optimization but is a good practice in React when the initial state requires some computation or object creation.

This ensures the object is created only once on the initial render, not on every render.

const [config, setConfig] = useState<MemoryPanelConfig>(() => ({
  // ... all the properties
}));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v2.8.0-beta.1: memory system does show defaults, but not the changes from settings

2 participants