openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

feat(mascot): react to conversation cues

Open aqilaziz opened this issue 6 months ago • 3 comments

## Summary

  • Adds a deterministic conversation-cue layer for the desktop mascot acknowledgement face after chat turns finish.
  • Maps chat_done.reaction_emoji and clear response text cues into happy, confused, or concerned beats while preserving existing runtime states for thinking/speaking/listening.
  • Keeps synth/playback/decoder failures on the concerned recovery path instead of showing a normal acknowledgement.
  • Documents the post-turn reaction model in the mascot GitBook page.

Problem

#1144 asks for the mascot to react to message/conversation meaning instead of only transport phases. The hook already reacts to runtime events; this PR adds the first bounded message-aware layer without introducing animation noise.

Solution

  • Adds pickConversationAckFace to classify explicit reaction emoji first, then deterministic response text cues.
  • Uses the selected ack face for text-only completion and after successful TTS playback.
  • Leaves voice/TTS synth, playback, and decoder failure behavior as concerned so recovery states still take priority.

Submission Checklist

  • [x] Tests added or updated (happy path + at least one failure / edge case) per Testing Strategy.
  • [x] Diff coverage >= 80% - useHumanMascot.test.ts covers emoji, text-cue, neutral fallback, TTS success, synth failure, and playback failure transitions.
  • [x] Coverage matrix updated - N/A: existing mascot hook test path already covers this UI behavior; no matrix catalog ID changed.
  • [x] All affected feature IDs from the matrix are listed in the PR description under ## Related - N/A.
  • [x] No new external network dependencies introduced.
  • [x] Manual smoke checklist updated if this touches release-cut surfaces - N/A: deterministic UI reaction logic only.
  • [x] Linked issue closed via Closes #NNN in the ## Related section - N/A: partial #1144 implementation, references only.

Validation

  • [x] pnpm install --offline --frozen-lockfile
  • [x] pnpm --dir app test -- src/features/human/useHumanMascot.test.ts - 1 file, 34 tests.
  • [x] pnpm --dir app compile
  • [x] pnpm --dir app exec prettier --check src/features/human/useHumanMascot.ts src/features/human/useHumanMascot.test.ts
  • [x] git diff --check

Related

  • Refs #1144

AI Authored PR Metadata (required for Codex/Linear PRs)

Linear Issue

  • Key: N/A
  • URL: N/A

Commit & Branch

  • Branch: codex/1144-mascot-reactions
  • Commit SHA: 5a4aca728432b2e5327dc84a3b090c7eb714bfde

Validation Run

  • [x] Frontend targeted test passed: 1 file, 34 tests.
  • [x] TypeScript compile passed.
  • [x] Prettier check passed on changed TS files.
  • [x] Diff whitespace check passed.

Validation Blocked

  • N/A

Behavior Changes

  • Intended behavior change: completed turns can now produce a short happy, confused, or concerned mascot acknowledgement based on conversation cues.
  • User-visible effect: mascot post-turn face better matches success, uncertainty, and warning/failure outcomes.

Parity Contract

  • Legacy behavior preserved: no-cue completions still use the existing happy acknowledgement; thinking/speaking/listening/error state priority is unchanged.
  • Guard/fallback/dispatch parity checks: TTS degradation still forces concerned; unknown reaction cues fall back to prior behavior.

Duplicate / Superseded PR Handling

  • Duplicate PR(s): none found for this scoped #1144 slice.
  • Canonical PR: this PR.
  • Resolution: N/A.

Summary by CodeRabbit

  • New Features

    • Mascot now chooses post-turn facial expressions from conversation cues (emoji or result text): happy for success, confused for uncertainty, concerned for warnings/failures; integrates with TTS and falls back to calm/idle when no cue exists. Also shows concerned if audio playback fails, then returns to idle.
  • Tests

    • Added unit tests for acknowledgement-face selection and post-turn behavior with and without TTS, including audio-failure handling.
  • Documentation

    • Updated mascot docs to describe conversation-aware post-turn expressions.

Review Change Stack

aqilaziz avatar May 21 '26 08:05 aqilaziz

📝 Walkthrough

Walkthrough

The mascot now selects a post-turn acknowledgement face (happy, confused, or concerned) per chat result using a new pickConversationAckFace classifier (reaction_emoji or full_response cues), and threads that face through chat_done non-TTS holds and TTS playback flows; tests and docs updated.

Changes

Mascot Acknowledgement Face Selection

Layer / File(s) Summary
Acknowledgement face classification contract and function
app/src/features/human/useHumanMascot.ts, app/src/features/human/useHumanMascot.test.ts
New ConversationAckFace type and exported pickConversationAckFace function classify faces via emoji sets and response-text regex patterns. Unit tests cover explicit reaction_emoji, implicit full_response cues, and null fallback cases.
State machine and TTS flow integration
app/src/features/human/useHumanMascot.ts, app/src/features/human/useHumanMascot.test.ts
chat_done computes derived ackFace (default 'happy') using pickConversationAckFace; non-TTS path holds that face briefly then idles; TTS path receives ackFace via startTtsPlayback and holds it after playback. State-machine tests verify confused and concerned outcomes, idle timing, and a TTS playback rejection scenario.
Feature documentation
gitbooks/features/mascot/README.md
Documents post-turn acknowledgement selection: mascot inspects conversation cues and selects face type (happy for success, confused for uncertainty, concerned for warnings/failure), falling back to calm/idle when no strong cue is present.

Sequence Diagram(s)

sequenceDiagram
  participant ChatDoneEvent
  participant useHumanMascot
  participant startTtsPlayback
  ChatDoneEvent->>useHumanMascot: chat_done(event)
  useHumanMascot->>useHumanMascot: pickConversationAckFace(event)
  alt TTS enabled
    useHumanMascot->>startTtsPlayback: startTtsPlayback(ackFace)
    startTtsPlayback->>useHumanMascot: finally -> hold ackFace
  else TTS disabled
    useHumanMascot->>useHumanMascot: holdThenIdle(ackFace)
  end

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

feature, working

"I'm a little rabbit, nose a-twitch with grace,
I read the emoji and the message's face.
Sometimes confused, sometimes concerned I'll be,
Or happy when the chat sings sweet to me.
Hop, hop — the mascot learns to read the tree!"

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(mascot): react to conversation cues' directly and clearly describes the main change: adding conversation-cue-aware reactions to the mascot acknowledgement behavior.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar May 21 '26 08:05 coderabbitai[bot]

placeholder

oxoxDev avatar May 21 '26 08:05 oxoxDev

placeholder

oxoxDev avatar May 21 '26 08:05 oxoxDev