MCPcopy Create free account
hub / github.com/codeaashu/claude-code / countUnseenAssistantTurns

Function countUnseenAssistantTurns

src/components/FullscreenLayout.tsx:200–216  ·  view source on GitHub ↗
(messages: readonly Message[], dividerIndex: number)

Source from the content-addressed store, hash-verified

198 * so "⏺ Searched for 13 patterns, read 6 files" doesn't tick the pill.
199 */
200export function countUnseenAssistantTurns(messages: readonly Message[], dividerIndex: number): number {
201 let count = 0;
202 let prevWasAssistant = false;
203 for (let i = dividerIndex; i < messages.length; i++) {
204 const m = messages[i]!;
205 if (m.type === 'progress') continue;
206 // Tool-use-only assistant entries aren't "new messages" to the user —
207 // skip them the same way we skip progress. prevWasAssistant is NOT
208 // updated, so a text block immediately following still counts as the
209 // same turn (tool_use + text from one API response = 1).
210 if (m.type === 'assistant' && !assistantHasVisibleText(m)) continue;
211 const isAssistant = m.type === 'assistant';
212 if (isAssistant && !prevWasAssistant) count++;
213 prevWasAssistant = isAssistant;
214 }
215 return count;
216}
217function assistantHasVisibleText(m: Message): boolean {
218 if (m.type !== 'assistant') return false;
219 for (const b of m.message.content) {

Callers 1

computeUnseenDividerFunction · 0.85

Calls 1

assistantHasVisibleTextFunction · 0.85

Tested by

no test coverage detected