Added RPG
This commit is contained in:
+23
-2
@@ -1,6 +1,6 @@
|
||||
import { sessionId, setSessionId, setCurrentPersona, currentPersona, dom } from './state.js';
|
||||
import { sessionId, setSessionId, setCurrentPersona, currentPersona, dom, setRpgEnabled } from './state.js';
|
||||
import { clearMessages, addMessage, initChat } from './chat.js';
|
||||
import { highlightPersona } from './personas.js';
|
||||
import { highlightPersona, personaIndex } from './personas.js';
|
||||
|
||||
function escapeTitle(t) {
|
||||
const d = document.createElement('div');
|
||||
@@ -16,8 +16,10 @@ export async function loadSessions() {
|
||||
sessions.forEach(s => {
|
||||
const item = document.createElement('div');
|
||||
item.className = 'session-item' + (s.session_id === sessionId ? ' active' : '');
|
||||
const personaName = personaIndex.get(s.persona_id)?.name || s.persona_id || 'default';
|
||||
item.innerHTML = `
|
||||
<div class="s-title">${escapeTitle(s.title || 'Новый чат')}</div>
|
||||
<div class="s-companion">С: ${escapeTitle(personaName)}</div>
|
||||
<div class="s-meta">${s.message_count} сообщ.</div>
|
||||
<button class="s-del" type="button">🗑</button>
|
||||
`;
|
||||
@@ -48,8 +50,27 @@ export async function loadChatHistory(id) {
|
||||
setCurrentPersona(s.persona_id);
|
||||
highlightPersona(s.persona_id);
|
||||
}
|
||||
if (dom.rpgToggle) {
|
||||
const enabled = !!s.rpg_enabled;
|
||||
dom.rpgToggle.checked = enabled;
|
||||
setRpgEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
// system blob
|
||||
try {
|
||||
const blobRes = await fetch(`/chat/system/${id}`);
|
||||
if (blobRes.ok) {
|
||||
const blob = await blobRes.json();
|
||||
const parts = [];
|
||||
if (blob.system_prompt) parts.push(blob.system_prompt);
|
||||
if (blob.status_quo) parts.push(`--- Status quo ---\n${blob.status_quo}\n---`);
|
||||
if (blob.facts_json) parts.push(`facts_json: ${blob.facts_json}`);
|
||||
if (blob.plot_arc_json) parts.push(`plot_arc_json: ${blob.plot_arc_json}`);
|
||||
dom.systemBlobContent.textContent = parts.filter(Boolean).join('\n\n') || '—';
|
||||
}
|
||||
} catch { /* ignore */ }
|
||||
|
||||
const histRes = await fetch(`/chat/history/${id}`);
|
||||
if (!histRes.ok) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user