Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
feat: recommend and download a CoS memory embedding model
[._.]/ Adam Eivy3958415991e5
diff --git a/client/src/components/cos/MemoryEmbeddingRecommendation.jsx b/client/src/components/cos/MemoryEmbeddingRecommendation.jsxnew file mode 100644index 0000000000..703a4f1423--- /dev/null+++ b/client/src/components/cos/MemoryEmbeddingRecommendation.jsx@@ -0,0 +1,40 @@+import { useState } from 'react';+import { Link } from 'react-router';+import { Download } from 'lucide-react';+import { installLocalLlmModel } from '../../services/apiLocalLlm';+import { useAsyncAction } from '../../hooks/useAsyncAction';++const MODEL = 'nomic-embed-text';++export default function MemoryEmbeddingRecommendation({ onSelect, disabled }) {+ const [installed, setInstalled] = useState(false);+ const [install, installing] = useAsyncAction(async () => {+ const result = await installLocalLlmModel('ollama', MODEL, { silent: true });+ if (result.success && !result.pending) setInstalled(true);+ });+ const [select, selecting] = useAsyncAction(() => onSelect('ollama', MODEL));++ return (+ <div className="mt-4 space-y-2 border-t border-port-border pt-4">+ <p className="text-sm text-port-text">+ Recommended: <strong>nomic-embed-text</strong> on Ollama+ </p>+ <p className="text-xs text-port-text-muted">+ A dedicated text embedding model for semantic memory retrieval (768 dimensions, about 274 MB).+ Chat models may not support embeddings. Download runs on this PortOS machine and requires Ollama.+ </p>+ <div className="flex flex-wrap items-center gap-3">+ <button type="button" disabled={installing || selecting || disabled}+ onClick={() => installed ? select() : install()}+ className="inline-flex items-center gap-2 rounded-lg bg-port-accent px-3 py-2 text-sm text-white disabled:opacity-50">+ <Download size={14} aria-hidden="true" />+ {installing ? 'Downloading nomic-embed-text…' : selecting ? 'Saving…' : installed ? 'Use for memory embeddings' : 'Download nomic-embed-text'}+ </button>+ <Link to="/models/llms-runtimes" className="text-xs text-port-accent hover:underline">Manage Ollama</Link>+ </div>+ <p role="status" className="text-xs text-port-text-muted">+ {installed ? 'Installed locally. Use for memory embeddings to save Ollama and this model.' : 'Your saved provider and model stay in place until you choose Use for memory embeddings.'}+ </p>+ </div>+ );+}diff --git a/client/src/components/cos/MemoryEmbeddingRecommendation.test.jsx b/client/src/components/cos/MemoryEmbeddingRecommendation.test.jsxnew file mode 100644index 0000000000..5c92527f94--- /dev/null+++ b/client/src/components/cos/MemoryEmbeddingRecommendation.test.jsx@@ -0,0 +1,34 @@+import { beforeEach, expect, it, vi } from 'vitest';+import { fireEvent, render, screen, waitFor } from '@testing-library/react';+import { MemoryRouter } from 'react-router';+import MemoryEmbeddingRecommendation from './MemoryEmbeddingRecommendation';+import { installLocalLlmModel } from '../../services/apiLocalLlm';+import toast from '../ui/Toast';++vi.mock('../../services/apiLocalLlm', () => ({ installLocalLlmModel: vi.fn() }));+vi.mock('../ui/Toast', () => ({ default: { error: vi.fn() } }));+beforeEach(() => vi.clearAllMocks());++it('downloads only on request and saves the recommendation only after explicit selection', async () => {+ let finish;+ installLocalLlmModel.mockReturnValue(new Promise(resolve => { finish = resolve; }));+ const onSelect = vi.fn().mockResolvedValue({});+ render(<MemoryRouter><MemoryEmbeddingRecommendation onSelect={onSelect} /></MemoryRouter>);+ expect(installLocalLlmModel).not.toHaveBeenCalled();+ fireEvent.click(screen.getByRole('button', { name: 'Download nomic-embed-text' }));+ expect(screen.getByRole('button', { name: /Downloading/ })).toBeDisabled();+ expect(installLocalLlmModel).toHaveBeenCalledWith('ollama', 'nomic-embed-text', { silent: true });+ finish({ success: true });+ fireEvent.click(await screen.findByRole('button', { name: 'Use for memory embeddings' }));+ await waitFor(() => expect(onSelect).toHaveBeenCalledWith('ollama', 'nomic-embed-text'));+});++it('keeps failed downloads retryable without changing the saved selection', async () => {+ installLocalLlmModel.mockRejectedValue(new Error('Ollama is unavailable'));+ const onSelect = vi.fn();+ render(<MemoryRouter><MemoryEmbeddingRecommendation onSelect={onSelect} /></MemoryRouter>);+ fireEvent.click(screen.getByRole('button', { name: 'Download nomic-embed-text' }));+ await waitFor(() => expect(toast.error).toHaveBeenCalledWith('Ollama is unavailable'));+ expect(screen.getByRole('button', { name: 'Download nomic-embed-text' })).toBeEnabled();+ expect(onSelect).not.toHaveBeenCalled();+});diff --git a/client/src/components/cos/tabs/ConfigTab.jsx b/client/src/components/cos/tabs/ConfigTab.jsxindex a6e9a5ae5b..841f9c4f4b 100644--- a/client/src/components/cos/tabs/ConfigTab.jsx+++ b/client/src/components/cos/tabs/ConfigTab.jsx@@ -18,6 +18,7 @@ import { useSocketResource } from '../../../hooks/useSocketResource.js';import PersistentMindProfileControls from '../PersistentMindProfileControls';import { PersistentMindThoughtStatus } from '../PersistentMindRuntimePanel';import ConfigRow from './ConfigRow';+import MemoryEmbeddingRecommendation from '../MemoryEmbeddingRecommendation';import {AVATAR_STYLE_LABELS,AUTONOMY_DOMAINS,@@ -523,6 +524,20 @@ export default function ConfigTab({ config, onUpdate, onEvaluate, avatarStyle, r}}label="Embedding provider"/>+ <MemoryEmbeddingRecommendation+ disabled={saveStatus === 'saving'}+ onSelect={(id, model) => {+ pendingConfigFieldsRef.current.set('embeddingProviderId', id);+ pendingConfigFieldsRef.current.set('embeddingModel', model);+ setEmbeddingProviderId(id);+ setProviderHook(id);+ setEmbeddingModel(model);+ setModelHook(model);+ return saveConfigPatch({ embeddingProviderId: id, embeddingModel: model }, {+ failureKeys: ['embeddingProviderId', 'embeddingModel'],+ });+ }}+ /></div></section>