This commit is contained in:
NAME
2026-05-16 11:58:13 +00:00
parent 4c1f4ccd9d
commit 6a7856065a
2 changed files with 12 additions and 4 deletions
+2 -1
View File
@@ -55,7 +55,8 @@ async function handleGenerate({ text, lang, tone, angle }, tabId) {
const data = await res.json(); const data = await res.json();
if (!res.ok) throw new Error(`HTTP ${res.status}`); if (!res.ok) throw new Error(`HTTP ${res.status}`);
const comment = data.comment || data.text || JSON.stringify(data); const comment = data.comment || data.text || JSON.stringify(data);
await chrome.tabs.sendMessage(tabId, { action: 'SHOW_RESULT', comment }).catch(() => {}); const model = data.model || '';
await chrome.tabs.sendMessage(tabId, { action: 'SHOW_RESULT', comment , model}).catch(() => {});
} catch (err) { } catch (err) {
await chrome.tabs.sendMessage(tabId, { action: 'SHOW_ERROR', error: err.message }).catch(() => {}); await chrome.tabs.sendMessage(tabId, { action: 'SHOW_ERROR', error: err.message }).catch(() => {});
} }
+10 -3
View File
@@ -86,7 +86,7 @@
return false; return false;
} }
if (req.action === 'SHOW_RESULT') { if (req.action === 'SHOW_RESULT') {
showResult(req.comment); showResult(req.comment, req.model);
sendResponse({ ok: true }); sendResponse({ ok: true });
return false; return false;
} }
@@ -451,7 +451,7 @@
} }
// ===== SHOW RESULT / ERROR ===== // ===== SHOW RESULT / ERROR =====
function showResult(comment) { function showResult(comment, model= '') {
if (!sidebarHost) return; if (!sidebarHost) return;
const s = sidebarHost.shadowRoot; const s = sidebarHost.shadowRoot;
const statusEl = s.querySelector('#ai-status'); const statusEl = s.querySelector('#ai-status');
@@ -460,7 +460,14 @@
const drawer = s.querySelector('.drawer'); const drawer = s.querySelector('.drawer');
const typingOpts = s.querySelector('#ai-typing-opts'); const typingOpts = s.querySelector('#ai-typing-opts');
if (statusEl) { statusEl.style.display = 'block'; statusEl.className = 'status ok'; statusEl.textContent = comment; } console.log({model});
if (statusEl) {
statusEl.style.display = 'block';
statusEl.className = 'status ok';
statusEl.textContent = comment;
copyHint.textContent = model;
}
if (copyHint) copyHint.style.display = 'block'; if (copyHint) copyHint.style.display = 'block';
if (runBtn) runBtn.disabled = false; if (runBtn) runBtn.disabled = false;
if (drawer) drawer.classList.add('open'); if (drawer) drawer.classList.add('open');