feat: replace Tone Analysis with Explain - simplifies highlighted text in plain language
Some checks failed
CI — Test & Build / Test & Build (push) Failing after 49s

This commit is contained in:
Forge
2026-03-06 15:27:40 +08:00
parent 107929c9e3
commit 1490e6641f
3 changed files with 9 additions and 10 deletions

View File

@@ -53,11 +53,10 @@ function getSystemPrompt(action: string): string {
'You are an experienced writer. Expand the provided text with more detail, context, and supporting points. ' + 'You are an experienced writer. Expand the provided text with more detail, context, and supporting points. ' +
'Make it richer and more informative while staying on topic. ' + 'Make it richer and more informative while staying on topic. ' +
'Return ONLY the expanded text.', 'Return ONLY the expanded text.',
tone: explain:
'You are a writing coach. Analyze the tone of the provided text. ' + 'You are a helpful teacher. Explain the following text in simple, easy-to-understand language. ' +
'Describe the tone characteristics (e.g. formal, casual, aggressive, passive, confident, etc.) ' + 'Break down complex terms, jargon, or concepts so anyone can understand. ' +
'and note any issues like passive voice, wordiness, or emotional bias. ' + 'Be concise but clear. Return only the explanation, no extra commentary.',
'Return a brief, clear analysis — no rewriting, no extra commentary.',
}; };
return prompts[action] ?? prompts.grammar; return prompts[action] ?? prompts.grammar;
} }
@@ -411,8 +410,8 @@ export default defineBackground(() => {
contexts: ['selection'], contexts: ['selection'],
}); });
chrome.contextMenus.create({ chrome.contextMenus.create({
id: 'lexai-tone', id: 'lexai-explain',
title: '⚡ LexAI: Analyze Tone', title: '⚡ LexAI: Explain',
contexts: ['selection'], contexts: ['selection'],
}); });
}); });

View File

@@ -199,7 +199,7 @@ export default defineContentScript({
{ label: '↺ Rephrase', action: 'rephrase', color: '#89b4fa' }, { label: '↺ Rephrase', action: 'rephrase', color: '#89b4fa' },
{ label: '↓ Shorten', action: 'shorten', color: '#fab387' }, { label: '↓ Shorten', action: 'shorten', color: '#fab387' },
{ label: '↑ Expand', action: 'expand', color: '#cba6f7' }, { label: '↑ Expand', action: 'expand', color: '#cba6f7' },
{ label: '🎭 Tone', action: 'tone', color: '#2dd4bf' }, { label: '💡 Explain', action: 'explain', color: '#2dd4bf' },
]; ];
actions.forEach(({ label, action, color }) => { actions.forEach(({ label, action, color }) => {
@@ -618,10 +618,10 @@ export default defineContentScript({
showModal(`${response.error}`, null, snapStart, snapEnd, snapElement, snapRange); showModal(`${response.error}`, null, snapStart, snapEnd, snapElement, snapRange);
} else { } else {
// Tone analysis is display-only — no Replace button (pass null for originalText) // Tone analysis is display-only — no Replace button (pass null for originalText)
const isToneAction = action === 'tone'; const isExplainAction = action === 'explain';
showModal( showModal(
response?.result ?? '(no result)', response?.result ?? '(no result)',
isToneAction ? null : textToProcess, isExplainAction ? null : textToProcess,
snapStart, snapEnd, snapElement, snapRange, snapStart, snapEnd, snapElement, snapRange,
); );
} }

Binary file not shown.