Skip to content

Conversation

@Smidge
Copy link
Contributor

@Smidge Smidge commented Jul 29, 2025

  • Add sendHumanMessage() method for sending human text messages
  • Method checks streaming status and active session
  • Formats message with timestamp, session_id, and message_type
  • Add JSDoc documentation for talk() and sendDataMessage() methods

ao-anam and others added 3 commits July 2, 2025 14:55
Improve compatibility for older browsers and react native
- Add sendHumanMessage() method for sending human text messages
- Method checks streaming status and active session
- Formats message with timestamp, session_id, and message_type
- Add JSDoc documentation for talk() and sendDataMessage() methods
Copilot AI review requested due to automatic review settings July 29, 2025 08:50
@Smidge Smidge changed the base branch from main to alpha July 29, 2025 08:50
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new sendHumanMessage method to the AnamClient class for sending human text messages during active streaming sessions. The method validates streaming status and session state before formatting and sending messages through the WebRTC data channel.

  • Add sendHumanMessage() method with validation for streaming status and active session
  • Add JSDoc documentation for existing talk() and sendDataMessage() methods
  • Reorganize imports for better structure

throw new Error('Failed to send human message: no active session');
}

const currentTimestamp = new Date().toISOString().replace('Z', '');
Copy link

Copilot AI Jul 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The timestamp format removes the 'Z' suffix but doesn't replace it with anything, resulting in an incomplete ISO timestamp. This could cause issues with timestamp parsing. Consider using a proper timezone offset or keeping the 'Z' for UTC.

Suggested change
const currentTimestamp = new Date().toISOString().replace('Z', '');
const currentTimestamp = new Date().toISOString();

Copilot uses AI. Check for mistakes.
Comment on lines 429 to 431
console.warn(
'AnamClient: Not currently streaming. Human message will not be sent.',
);
Copy link

Copilot AI Jul 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Using console.warn followed by throwing an error creates redundant messaging. Consider either logging a warning and returning early, or throwing the error without the console warning to avoid duplicate error reporting.

Suggested change
console.warn(
'AnamClient: Not currently streaming. Human message will not be sent.',
);

Copilot uses AI. Check for mistakes.
content,
timestamp: currentTimestamp,
session_id: sessionId,
message_type: 'speech',
Copy link

Copilot AI Jul 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded 'speech' message type as a magic string should be extracted to a constant or enum to improve maintainability and prevent typos.

Suggested change
message_type: 'speech',
message_type: MESSAGE_TYPE_SPEECH,

Copilot uses AI. Check for mistakes.
ao-anam
ao-anam previously approved these changes Jul 29, 2025
- Rename method from sendHumanMessage() to sendUserMessage()
- Update JSDoc documentation to use 'user' instead of 'human'
- Update error messages and console warnings accordingly
@Smidge Smidge merged commit eda5f5a into alpha Jul 29, 2025
3 checks passed
@Smidge Smidge changed the title feat: add sendHumanMessage method to AnamClient feat: add sendUserMessage method to AnamClient Jul 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants