💄 feedback counts
This commit is contained in:
@@ -52,7 +52,8 @@ export function AnalysisToolbar(): JSX.Element {
|
|||||||
const runPassiveVoice = (): void => {
|
const runPassiveVoice = (): void => {
|
||||||
if (!hasFile) return
|
if (!hasFile) return
|
||||||
const found = detectPassiveVoice(activeFileContent)
|
const found = detectPassiveVoice(activeFileContent)
|
||||||
setAnnotations(found)
|
const existing = useEditorStore.getState().annotations.filter((a) => a.type !== 'passive_voice')
|
||||||
|
setAnnotations([...existing, ...found])
|
||||||
setAnalysisMode('passive_voice')
|
setAnalysisMode('passive_voice')
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +95,10 @@ export function AnalysisToolbar(): JSX.Element {
|
|||||||
const lastMsg = currentHistory[currentHistory.length - 1]
|
const lastMsg = currentHistory[currentHistory.length - 1]
|
||||||
if (lastMsg?.role === 'assistant' && lastMsg.content.length > 0) {
|
if (lastMsg?.role === 'assistant' && lastMsg.content.length > 0) {
|
||||||
const newAnnotations = parseAnnotationsFromAIResponse(lastMsg.content, activeFileContent)
|
const newAnnotations = parseAnnotationsFromAIResponse(lastMsg.content, activeFileContent)
|
||||||
if (newAnnotations.length > 0) setAnnotations(newAnnotations)
|
if (newAnnotations.length > 0) {
|
||||||
|
const existing = useEditorStore.getState().annotations.filter((a) => a.type !== mode)
|
||||||
|
setAnnotations([...existing, ...newAnnotations])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setAIError(err instanceof Error ? err.message : 'Analysis failed')
|
setAIError(err instanceof Error ? err.message : 'Analysis failed')
|
||||||
@@ -104,7 +108,9 @@ export function AnalysisToolbar(): JSX.Element {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const passiveCount = annotations.filter((a) => a.type === 'passive_voice').length
|
const passiveCount = annotations.filter((a) => a.type === 'passive_voice').length
|
||||||
const otherCount = annotations.filter((a) => a.type !== 'passive_voice').length
|
const consistencyCount = annotations.filter((a) => a.type === 'consistency').length
|
||||||
|
const styleCount = annotations.filter((a) => a.type === 'style').length
|
||||||
|
const critiqueCount = annotations.filter((a) => a.type === 'critique').length
|
||||||
const docWordCount = countWords(activeFileContent)
|
const docWordCount = countWords(activeFileContent)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -117,7 +123,7 @@ export function AnalysisToolbar(): JSX.Element {
|
|||||||
title="Highlight passive voice sentences instantly (no AI required)"
|
title="Highlight passive voice sentences instantly (no AI required)"
|
||||||
>
|
>
|
||||||
Passive Voice
|
Passive Voice
|
||||||
{analysisMode === 'passive_voice' && passiveCount > 0 && (
|
{passiveCount > 0 && (
|
||||||
<span className="toolbar-badge">{passiveCount}</span>
|
<span className="toolbar-badge">{passiveCount}</span>
|
||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
@@ -129,8 +135,8 @@ export function AnalysisToolbar(): JSX.Element {
|
|||||||
title="Check character names, timeline, and repeated phrases via AI"
|
title="Check character names, timeline, and repeated phrases via AI"
|
||||||
>
|
>
|
||||||
{isAILoading && analysisMode === 'consistency' ? 'Checking…' : 'Consistency'}
|
{isAILoading && analysisMode === 'consistency' ? 'Checking…' : 'Consistency'}
|
||||||
{analysisMode === 'consistency' && otherCount > 0 && (
|
{consistencyCount > 0 && (
|
||||||
<span className="toolbar-badge">{otherCount}</span>
|
<span className="toolbar-badge">{consistencyCount}</span>
|
||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
@@ -141,8 +147,8 @@ export function AnalysisToolbar(): JSX.Element {
|
|||||||
title="Pacing, sentence variety, show-don't-tell feedback via AI"
|
title="Pacing, sentence variety, show-don't-tell feedback via AI"
|
||||||
>
|
>
|
||||||
{isAILoading && analysisMode === 'style' ? 'Analyzing…' : 'Style'}
|
{isAILoading && analysisMode === 'style' ? 'Analyzing…' : 'Style'}
|
||||||
{analysisMode === 'style' && otherCount > 0 && (
|
{styleCount > 0 && (
|
||||||
<span className="toolbar-badge">{otherCount}</span>
|
<span className="toolbar-badge">{styleCount}</span>
|
||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
@@ -153,8 +159,8 @@ export function AnalysisToolbar(): JSX.Element {
|
|||||||
title="Honest overall critique of this chapter via AI"
|
title="Honest overall critique of this chapter via AI"
|
||||||
>
|
>
|
||||||
{isAILoading && analysisMode === 'critique' ? 'Reading…' : 'Critique'}
|
{isAILoading && analysisMode === 'critique' ? 'Reading…' : 'Critique'}
|
||||||
{analysisMode === 'critique' && otherCount > 0 && (
|
{critiqueCount > 0 && (
|
||||||
<span className="toolbar-badge">{otherCount}</span>
|
<span className="toolbar-badge">{critiqueCount}</span>
|
||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user