Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(conversations): correct mention source to include user display name

Steven Enamakele9acf086098c
diff --git a/app/src/features/conversations/aui/useMentionSource.test.tsx b/app/src/features/conversations/aui/useMentionSource.test.tsx
index 08dc09c70f..9020eecfb8 100644
--- a/app/src/features/conversations/aui/useMentionSource.test.tsx
+++ b/app/src/features/conversations/aui/useMentionSource.test.tsx
@@ -11,32 +11,21 @@ import type { ReactNode } from 'react';
import { Provider } from 'react-redux';
import { beforeEach, describe, expect, it, vi } from 'vitest';
-import { MOCK_MEMORY_RECALL } from '../../../pages/dev/assistant-ui-demo/assistantUiMock/mockScript';
+import { MOCK_MEMORY_FETCH } from '../../../pages/dev/assistant-ui-demo/assistantUiMock/mockScript';
+import type { Hit } from '../../../services/api/memoryApi';
import { callCoreRpc } from '../../../services/coreRpcClient';
import chatRuntimeReducer, { type ArtifactSnapshot } from '../../../store/chatRuntimeSlice';
-import type { Chunk } from '../../../utils/tauriCommands/memoryTree';
import {
fileMentionsFromArtifacts,
- memoryMentionsFromChunks,
+ memoryMentionsFromHits,
trailingMentionQuery,
useMentionSource,
} from './useMentionSource';
vi.mock('../../../services/coreRpcClient', () => ({ callCoreRpc: vi.fn() }));
-function chunk(id: string, preview: string): Chunk {
- return {
- id,
- source_kind: 'email',
- source_id: 'thread-9',
- owner: 'me',
- timestamp_ms: 0,
- token_count: 10,
- lifecycle_status: 'admitted',
- content_preview: preview,
- has_embedding: true,
- tags: [],
- } as Chunk;
+function hit(id: string, text: string): Hit {
+ return { id, kind: 'conversation', text, meta: { thread_id: 'thread-9' }, score: 0.5 };
}
const READY: ArtifactSnapshot = {
@@ -90,15 +79,15 @@ describe('trailingMentionQuery', () => {
});
});
-describe('memoryMentionsFromChunks', () => {
+describe('memoryMentionsFromHits', () => {
it('builds a single-line label that survives the directive syntax', () => {
- const [mention] = memoryMentionsFromChunks([
- chunk('c1', 'Design [sync]\nnotes {v2} with a very long tail that keeps going on'),
+ const [mention] = memoryMentionsFromHits([
+ hit('c1', 'Design [sync]\nnotes {v2} with a very long tail that keeps going on'),
]);
expect(mention).toMatchObject({
id: 'c1',
type: 'memory',
- description: 'email',
+ description: 'conversation',
icon: 'memory',
});
expect(mention!.label).toBe('Design sync notes v2 with a very long tail that…');
@@ -109,16 +98,14 @@ describe('memoryMentionsFromChunks', () => {
]);
});
- it('maps the dev recall fixture to one memory mention per chunk', () => {
- const mentions = memoryMentionsFromChunks(MOCK_MEMORY_RECALL.chunks);
- expect(mentions.map(m => m.id)).toEqual(MOCK_MEMORY_RECALL.chunks.map(c => c.id));
+ it('maps the dev fetch fixture to one memory mention per hit', () => {
+ const mentions = memoryMentionsFromHits(MOCK_MEMORY_FETCH.hits);
+ expect(mentions.map(m => m.id)).toEqual(MOCK_MEMORY_FETCH.hits.map(h => h.id));
expect(mentions.every(m => m.label.length > 0)).toBe(true);
});
- it('falls back to the source id when a chunk has no preview', () => {
- const [mention] = memoryMentionsFromChunks([
- { ...chunk('c2', ''), content_preview: undefined },
- ]);
+ it('falls back to the thread id when a hit has no text', () => {
+ const [mention] = memoryMentionsFromHits([hit('c2', '')]);
expect(mention!.label).toBe('thread-9');
});
});
@@ -152,9 +139,9 @@ describe('useMentionSource', () => {
expect(callCoreRpc).not.toHaveBeenCalled();
});
- it('searches memory recall for a typed @query and surfaces the hits', async () => {
+ it('searches memory for a typed @query and surfaces the hits', async () => {
vi.mocked(callCoreRpc).mockResolvedValue({
- result: { chunks: [chunk('c1', 'Quarterly planning notes')], scores: [0.9] },
+ result: { hits: [hit('c1', 'Quarterly planning notes')] },
});
const { result } = setup();
@@ -164,17 +151,14 @@ describe('useMentionSource', () => {
expect(result.current.source.adapter.search?.('quart').map(i => i.id)).toContain('c1')
);
expect(callCoreRpc).toHaveBeenCalledWith({
- method: 'openhuman.memory_tree_recall',
- params: { query: 'quart', k: 8 },
+ method: 'openhuman.memory_fetch',
+ params: { query: 'quart', limit: 8 },
});
expect(result.current.source.adapter.categoryItems('memory').map(i => i.id)).toEqual(['c1']);
});
it('keeps semantic hits even when their label does not contain the query', async () => {
- vi.mocked(callCoreRpc).mockResolvedValue({
- chunks: [chunk('c3', 'Roadmap review')],
- scores: [0.7],
- });
+ vi.mocked(callCoreRpc).mockResolvedValue({ hits: [hit('c3', 'Roadmap review')] });
const { result } = setup();
act(() => result.current.aui.composer.setText('@planning'));
await waitFor(() =>
@@ -182,10 +166,10 @@ describe('useMentionSource', () => {
);
});
- it('treats a failed recall as no memory hits', async () => {
+ it('treats a failed fetch (memory off) as no memory hits', async () => {
vi.mocked(callCoreRpc).mockImplementation(async request => {
- if (request?.method === 'openhuman.memory_tree_recall') {
- throw new Error('memory tree disabled');
+ if (request?.method === 'openhuman.memory_fetch') {
+ throw new Error('MEMORY_OFF: no engine');
}
return {} as never;
});
diff --git a/app/src/features/conversations/aui/useMentionSource.ts b/app/src/features/conversations/aui/useMentionSource.ts
index d7bf192e0f..89cb7e70a2 100644
--- a/app/src/features/conversations/aui/useMentionSource.ts
+++ b/app/src/features/conversations/aui/useMentionSource.ts
@@ -3,9 +3,9 @@
* `unstable_useMentionAdapter` for the vendored `ComposerTriggerPopover`.
*
* Two categories:
- * - **Memory** — semantic recall over the memory tree
- * (`openhuman.memory_tree_recall` via {@link memoryTreeRecall}) for the
- * `@query` being typed, debounced. The adapter's own search is a substring
+ * - **Memory** — a search of stored memory (`openhuman.memory_fetch` via
+ * {@link memoryFetch}, the engine's default mode) for the `@query` being
+ * typed, debounced. With memory off the call fails and the category is empty. The adapter's own search is a substring
* filter, which would drop semantic hits whose label does not literally
* contain the query, so `search` is extended to always include them.
* - **Files** — the thread's ready artifacts, read from
@@ -28,13 +28,13 @@ import { AtSignIcon, BrainIcon, FileIcon } from 'lucide-react';
import { useEffect, useMemo, useRef, useState } from 'react';
import { useT } from '../../../lib/i18n/I18nContext';
+import { type Hit, memoryFetch } from '../../../services/api/memoryApi';
import type { ArtifactSnapshot } from '../../../store/chatRuntimeSlice';
import { useAppSelector } from '../../../store/hooks';
-import { type Chunk, memoryTreeRecall } from '../../../utils/tauriCommands/memoryTree';
const log = debug('openhuman:chat:mentions');
-const RECALL_K = 8;
+const FETCH_LIMIT = 8;
const RECALL_DEBOUNCE_MS = 200;
const MIN_QUERY_LENGTH = 2;
const MAX_LABEL_LENGTH = 48;
@@ -60,12 +60,12 @@ function directiveSafe(text: string): string {
: flat;
}
-export function memoryMentionsFromChunks(chunks: readonly Chunk[]): Unstable_Mention[] {
- return chunks.map(chunk => ({
- id: directiveSafe(chunk.id),
+export function memoryMentionsFromHits(hits: readonly Hit[]): Unstable_Mention[] {
+ return hits.map(hit => ({
+ id: directiveSafe(hit.id),
type: 'memory',
- label: directiveSafe(chunk.content_preview || chunk.source_id),
- description: chunk.source_kind,
+ label: directiveSafe(hit.text || hit.meta?.file_path || hit.meta?.thread_id || hit.id),
+ description: hit.kind,
icon: 'memory',
}));
}
@@ -100,16 +100,16 @@ export function useMentionSource(threadId: string | null) {
const seq = ++requestSeq.current;
setIsLoading(true);
const timer = setTimeout(() => {
- log('recall: query_len=%d', query.length);
- memoryTreeRecall(query, RECALL_K)
- .then(response => memoryMentionsFromChunks(response.chunks ?? []))
+ log('fetch: query_len=%d', query.length);
+ memoryFetch({ query, limit: FETCH_LIMIT })
+ .then(response => memoryMentionsFromHits(response.hits ?? []))
.catch(error => {
- log('recall failed, no memory mentions: %o', error);
+ log('fetch failed, no memory mentions: %o', error);
return [] as Unstable_Mention[];
})
.then(mentions => {
if (seq !== requestSeq.current) return;
- log('recall: %d hit(s)', mentions.length);
+ log('fetch: %d hit(s)', mentions.length);
setMemory(mentions);
setIsLoading(false);
});
diff --git a/vendor/tinymemory b/vendor/tinymemory
index 3b3711fbe3..68a6a3e1b6 160000
--- a/vendor/tinymemory
+++ b/vendor/tinymemory
@@ -1 +1 @@
-Subproject commit 3b3711fbe3cfa211906d58f0b333e926f752d709
+Subproject commit 68a6a3e1b64b4cbf1cc44aabb1aa9e34e0e75f14