Skip to content

fix: repair broken Record() and improve error handling in APIManager#4

Open
LuciferDono wants to merge 1 commit intoCatrobat:mainfrom
LuciferDono:fix/api-manager-record-and-error-handling
Open

fix: repair broken Record() and improve error handling in APIManager#4
LuciferDono wants to merge 1 commit intoCatrobat:mainfrom
LuciferDono:fix/api-manager-record-and-error-handling

Conversation

@LuciferDono
Copy link

Summary

  • Fix APIManager.Record() which called StartCoroutine("hi!") — a non-functional no-op with no matching coroutine
  • Add StartRecording() public method to ARAppVoiceManager as a clean API for external callers
  • Improve error handling in SendDataToGas(): include actual error details, re-enable send button on failure, only trigger TTS on success

Changes

Assets/Scripts/APIManager.cs

  • Record(): Replace broken StartCoroutine("hi!") with voiceManager.StartRecording(), add null-safety
  • SendDataToGas(): Show www.error instead of generic message, log errors with Debug.LogError, re-enable sendButton after request completes (previously left disabled on failure), guard TTS behind success check

Assets/Scripts/Whisper&TTS/ARAppVoiceManager.cs

  • Add public StartRecording() method that delegates to the private OnRecordButtonPressed(), providing a clean API for APIManager and any future external callers

Test plan

  • Verify voice recording triggers correctly when Record button is pressed in the AI chat UI
  • Verify error messages display actual failure reason instead of "There was an error"
  • Verify send button is re-enabled after a failed API request
  • Verify TTS does not attempt to speak error messages
  • Verify null voiceManager produces a console warning instead of a crash

…anager

- Replace non-functional StartCoroutine("hi!") in Record() with proper
  delegation to ARAppVoiceManager via new public StartRecording() method
- Add StartRecording() to ARAppVoiceManager as public API for external
  callers, avoiding the anti-pattern of simulating UI button clicks
- Add null check with debug warning when voiceManager is not assigned
- Include actual error details (www.error) in failure responses instead
  of generic "There was an error" message
- Re-enable sendButton after request completes (was left disabled on failure)
- Only trigger TTS playback on successful API responses
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.

1 participant