Fix ChatGPT auto-read aloud for existing conversations#246
Merged
Conversation
Prevents auto-read aloud from triggering on previously completed messages when starting a voice call in an existing ChatGPT conversation. ## Problem When starting a voice call on first page load in an existing ChatGPT conversation, the last message was automatically read aloud even though it was already complete before the call started. This was inconsistent with Pi.ai's behavior, which only reads new streaming messages. ## Solution Added explicit tracking to distinguish between new/streaming messages and old/completed messages: - Added `isStreaming?: boolean` parameter to Chatbot interface - ChatHistoryNewMessageObserver passes `isStreaming=true` for new messages - ChatGPTResponse sets `data-saypi-unread="true"` attribute on streaming messages - Auto-click logic now checks for this attribute before triggering - Attribute is cleared after clicking to prevent duplicate reads ## Changes - Updated Chatbot interface and all implementations - Modified ChatGPTResponse to track and check unread status - Updated all auto-click guard methods to verify unread attribute - Added test case for old messages (should NOT auto-click) - Updated existing tests to pass isStreaming parameter ## Testing - All existing tests pass (6 passed, 1 skipped) - New test verifies old messages are not auto-read - Behavior now matches Pi.ai implementation Fixes #245 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an issue where ChatGPT's auto-read aloud feature would incorrectly trigger for already-completed messages when starting a voice call in an existing conversation. The solution introduces a data-saypi-unread attribute to distinguish between new streaming messages (which should be read aloud) and old completed messages (which should not).
Key Changes:
- Added
isStreamingparameter to the chatbot interface hierarchy to identify new vs. existing messages - Implemented
data-saypi-unreadattribute tracking inChatGPTResponseto mark streaming messages - Updated all auto-click methods to check for the
data-saypi-unreadattribute before triggering read aloud
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/chatbots/Chatbot.ts |
Added optional isStreaming parameter to interface method signature |
src/chatbots/AbstractChatbots.ts |
Propagated isStreaming parameter through abstract base class |
src/chatbots/ChatGPT.ts |
Updated createAssistantResponse to pass isStreaming to ChatGPTResponse |
src/chatbots/chatgpt/ChatGPTResponse.ts |
Core logic: sets data-saypi-unread attribute for streaming messages and guards auto-click methods |
src/chatbots/Claude.ts |
Updated method signature for consistency (no functional change) |
src/chatbots/Pi.ts |
Updated method signature for consistency (no functional change) |
src/dom/ChatHistory.ts |
Marks new messages as streaming when calling getAssistantResponse |
test/chatbots/ChatGPTAutoReadAloud.spec.ts |
Updated all test cases to pass isStreaming flag and added test for old message behavior |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #245 - Prevents auto-read aloud from triggering on previously completed messages when starting a voice call in an existing ChatGPT conversation.
Problem
When starting a voice call on first page load in an existing ChatGPT conversation, the last message was automatically read aloud even though it was already complete before the call started. This was inconsistent with Pi.ai's behavior, which only reads new streaming messages.
Solution
Added explicit tracking to distinguish between new/streaming messages and old/completed messages using a
data-saypi-unreadattribute:ChatHistoryNewMessageObserverare marked withdata-saypi-unread="true"data-saypi-unreadattributeTechnical Changes
Core Implementation
isStreaming?: booleanparameter togetAssistantResponse()isStreamingparameter through to implementationsdata-saypi-unread="true"whenisStreaming=truedata-saypi-unreadattribute:tryClickNativeReadAloud()autoClickNativeReadAloudWhenAvailable()tryOpenMoreActionsAndClickReadAloud()isStreaming=truefor new messagesTests
isStreaming=truefor new messagesResult
✅ Auto-read aloud only triggers for new messages streaming during an active call
✅ Previously completed messages are NOT read when starting a call
✅ Behavior is consistent with Pi.ai's implementation
✅ All tests pass
Testing Instructions
🤖 Generated with Claude Code