mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-17 18:25:26 -04:00
fix(memory): let manual add specify memory category
Add a category selector on the Brain Add tab and include it in the /api/memory/add JSON payload instead of always defaulting to fact. Fixes #2784
This commit is contained in:
@@ -307,6 +307,7 @@
|
|||||||
<input type="text" id="new-memory-input" placeholder=" " class="memory-add-input skill-hint-input" aria-label="New memory text" />
|
<input type="text" id="new-memory-input" placeholder=" " class="memory-add-input skill-hint-input" aria-label="New memory text" />
|
||||||
<span class="skill-rich-ph"><span class="k">Add a memory</span> — e.g. 'I prefer concise replies' <svg class="k" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-left:4px;" aria-hidden="true"><polyline points="9 10 4 15 9 20"/><path d="M20 4v7a4 4 0 0 1-4 4H4"/></svg></span>
|
<span class="skill-rich-ph"><span class="k">Add a memory</span> — e.g. 'I prefer concise replies' <svg class="k" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:-2px;margin-left:4px;" aria-hidden="true"><polyline points="9 10 4 15 9 20"/><path d="M20 4v7a4 4 0 0 1-4 4H4"/></svg></span>
|
||||||
</div>
|
</div>
|
||||||
|
<select id="new-memory-category" class="memory-edit-cat-select" aria-label="Memory category"></select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="admin-card">
|
<div class="admin-card">
|
||||||
|
|||||||
@@ -18,6 +18,26 @@ let selectedIds = new Set();
|
|||||||
|
|
||||||
const MEMORY_CATEGORIES = ['fact', 'identity', 'preference', 'contact', 'project', 'goal', 'task'];
|
const MEMORY_CATEGORIES = ['fact', 'identity', 'preference', 'contact', 'project', 'goal', 'task'];
|
||||||
|
|
||||||
|
function _ensureNewMemoryCategorySelect() {
|
||||||
|
const sel = document.getElementById('new-memory-category');
|
||||||
|
if (!sel || sel.dataset.wired === '1') return;
|
||||||
|
sel.dataset.wired = '1';
|
||||||
|
MEMORY_CATEGORIES.forEach(cat => {
|
||||||
|
const opt = document.createElement('option');
|
||||||
|
opt.value = cat;
|
||||||
|
opt.textContent = cat;
|
||||||
|
if (cat === 'fact') opt.selected = true;
|
||||||
|
sel.appendChild(opt);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function _readNewMemoryCategory() {
|
||||||
|
_ensureNewMemoryCategorySelect();
|
||||||
|
const sel = document.getElementById('new-memory-category');
|
||||||
|
const cat = sel?.value || 'fact';
|
||||||
|
return MEMORY_CATEGORIES.includes(cat) ? cat : 'fact';
|
||||||
|
}
|
||||||
|
|
||||||
let _memoryDragWired = false;
|
let _memoryDragWired = false;
|
||||||
function _wireMemoryDrag() {
|
function _wireMemoryDrag() {
|
||||||
if (_memoryDragWired) return;
|
if (_memoryDragWired) return;
|
||||||
@@ -274,6 +294,7 @@ async function syncPrefToggle(elementId, prefKey, onMsg, offMsg, dimBelow = true
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function loadMemories() {
|
export async function loadMemories() {
|
||||||
|
_ensureNewMemoryCategorySelect();
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${window.location.origin}/api/memory`);
|
const response = await fetch(`${window.location.origin}/api/memory`);
|
||||||
|
|
||||||
@@ -977,6 +998,7 @@ export function updateMemoryCount() {
|
|||||||
export async function addNewMemory() {
|
export async function addNewMemory() {
|
||||||
const input = document.getElementById('new-memory-input');
|
const input = document.getElementById('new-memory-input');
|
||||||
const text = input.value.trim();
|
const text = input.value.trim();
|
||||||
|
const category = _readNewMemoryCategory();
|
||||||
|
|
||||||
if (!text) {
|
if (!text) {
|
||||||
showError('Memory text cannot be empty');
|
showError('Memory text cannot be empty');
|
||||||
@@ -991,6 +1013,7 @@ export async function addNewMemory() {
|
|||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
text: text,
|
text: text,
|
||||||
|
category: category,
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user