feat: add conversation log panel below Generate Deck button

This commit is contained in:
KoalaTrapLord authored and GitHub committed 2026-03-19 11:31:10 -04:00
1 parent 633fd43b28
commit 70a7c07b81
3 files changed
+74 -1

No files matched your search

+42
View File
@@ -1256,3 +1256,45 @@
.dg-stat-substituted .dg-stat-num { color: #60a5fa; }
.dg-stat-missing .dg-stat-num { color: #f59e0b; }
.dg-stat-price .dg-stat-num { color: #a78bfa; }
/* -- Conversation Log ---------------------------------------- */
.dg-conversation-log {
margin-top: var(--sp-3);
max-height: 200px;
overflow-y: auto;
background: var(--surface-1);
border: 1px solid var(--border);
border-radius: var(--radius-sm);
padding: var(--sp-3);
font-family: 'Courier New', monospace;
font-size: 0.8rem;
scrollbar-width: thin;
}
.dg-log-entry {
padding: 3px 0;
line-height: 1.5;
border-bottom: 1px solid rgba(255,255,255,0.05);
}
.dg-log-entry:last-child {
border-bottom: none;
}
.dg-log-ts {
color: var(--text-muted);
margin-right: 6px;
}
.dg-log-info {
color: var(--text);
}
.dg-log-success {
color: #60a5fa;
}
.dg-log-error {
color: #f59e0b;
}
+3
View File
@@ -145,6 +145,9 @@
</button>
</div>
<!-- Conversation Log -->
<div id="dg-conversation-log" class="dg-conversation-log" style="display:none"></div>
</section>
<!-- RIGHT: Preview Results -->
+29 -1
View File
@@ -253,14 +253,38 @@ const DeckGenerator = (() => {
$('dg-commander-dropdown').classList.remove('open');
}
// -- Conversation Log Helper --
function logMessage(msg, type = 'info') {
const log = $('dg-conversation-log');
if (!log) return;
log.style.display = 'block';
const entry = document.createElement('div');
entry.className = 'dg-log-entry dg-log-' + type;
const ts = new Date().toLocaleTimeString();
entry.innerHTML = '<span class="dg-log-ts">[' + ts + ']</span> ' + msg;
log.appendChild(entry);
log.scrollTop = log.scrollHeight;
}
function clearLog() {
const log = $('dg-conversation-log');
if (!log) return;
log.innerHTML = '';
log.style.display = 'none';
}
// ── Generate Deck ───────────────────────────────────────
async function generateDeck() {
clearLog();
logMessage('Connecting to local AI model (gpt-oss:20b)...', 'info');
if (!state.commander) { toast('Select a commander first', 'error'); return; }
if (!state.v3Ready) { toast('V3 generator not ready — check Perplexity API key', 'error'); return; }
logMessage('Building request body with commander: <b>' + state.commander.name + '</b>', 'info');
setLoading(true, 'Generating deck via Perplexity AI...');
setLoading(true, 'Generating deck via Local AI...');
const body = buildRequestBody();
logMessage('Sending request to AI model... this may take a moment.', 'info');
state.lastRequestBody = body;
try {
@@ -276,12 +300,16 @@ const DeckGenerator = (() => {
}
state.previewResult = await resp.json();
logMessage('AI response received! Processing deck data...', 'success');
const cardCount = (stats.total_cards || 0);
logMessage('Deck generated: <b>' + cardCount + ' cards</b> | $' + (stats.total_price || 0).toFixed(2) + ' estimated', 'success');
renderResults(state.previewResult);
const stats = state.previewResult.stats || {};
toast('Deck generated: ' + (stats.total_cards || 0) + ' cards | $' + (stats.total_price_usd || 0), 'success');
} catch (e) {
toast(e.message || 'Generation failed', 'error');
logMessage('Error: ' + (e.message || 'Unknown error'), 'error');
setLoading(false);
}
}