Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions apps/desktop/src/renderer/components/onboarding/MemoryStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ export function MemoryStep({ onNext, onBack }: MemoryStepProps) {
const { settings, updateSettings } = useSettingsStore();

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 || '',
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.

googleEmbeddingModel: settings.memoryGoogleEmbeddingModel || '',
Comment on lines 23 to 34
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
}));

Expand Down