feat: expose conversation backend contract - #441
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughChatService is abstracted to a minimal ChatAudioLike and implements an exported ConversationBackend type. Test infrastructure is added to stub ChatAudioIO for Node ESM resolution, and unit tests validate API forwarding, tool-schema conversion, and callback wiring. ChangesConversationBackend Interface and Contract Verification
Sequence DiagramsequenceDiagram
participant Test
participant ChatService
participant FakeChatAudioIO
Test->>ChatService: new ChatService(chatAudioIOCtor, options)
Test->>ChatService: start()
ChatService->>FakeChatAudioIO: connect()
FakeChatAudioIO-->>ChatService: connected
Test->>ChatService: sendText(text)
ChatService->>FakeChatAudioIO: sendText(text)
Test->>ChatService: setMicrophoneEnabled(flag)
ChatService->>FakeChatAudioIO: setMicrophoneEnabled(flag)
Test->>ChatService: stop()
ChatService->>FakeChatAudioIO: disconnect()
Test->>ChatService: close()
ChatService->>FakeChatAudioIO: close()
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@firmware/tests/unit/chat-service-contract.test.ts`:
- Around line 56-72: The test currently calls ChatService methods (start, stop,
sendText, sendFunctionResult, setMicrophoneEnabled, setVolume, close) but only
asserts final state; update the test to also assert that FakeChatAudioIO
recorded passthrough calls by checking FakeChatAudioIO.calls contains entries
for each invoked method (e.g., "start", "stop", "sendText:こんにちは",
"sendFunctionResult:call-1:set_emotion", "setMicrophoneEnabled:false",
"setVolume:0.4", "close"), so modify the assertions after exercising the API to
verify FakeChatAudioIO.calls includes those expected call strings in the same
order to catch noop/passthrough regressions in ChatService/ConversationBackend
integration.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 8e5eb34d-0608-414e-80bb-26b936806a4b
📒 Files selected for processing (5)
firmware/package.jsonfirmware/scripts/prepare-node-test-modules.jsfirmware/stackchan/services/chat.tsfirmware/tests/unit/chat-service-contract.test.tsfirmware/tsconfig.test.json
| onFunctionCall?: (call: string, name: string, params: Record<string, unknown>) => void | ||
| } | ||
|
|
||
| type ChatAudioLike = { |
There was a problem hiding this comment.
一段抽象化してパイプラインとChatAudioIOと従来のSTT/LLM/TTSを選んで差し込めるようにしたい
Summary
ConversationBackendcontract for Stack-chan conversation backends.ChatServicebehavior while making it implement the shared backend I/F.ChatAudioIOModdable module specifier through the existing stub.Review focus
This PR is intentionally small so we can review the I/F before adding the legacy
STT -> Dialogue -> TTSbackend.Please focus on:
ConversationBackendhas the right shape for bothChatAudioIOand legacy STT/LLM/TTS pipelines.sendFunctionResult,setMicrophoneEnabled, andsetVolumeare the right boundary.ChatCallbacksis enough for UI / face / transcript integration to stay backend-independent.Follow-up
After this I/F is agreed, the next slice will add a legacy pipeline backend that wraps:
Closes #440
Release impact
none — internal TypeScript contract/test-only change; no user-visible firmware behavior change.
Test Plan
npm run test:unitnpx biome lint stackchan/services/chat.ts tests/unit/chat-service-contract.test.ts scripts/prepare-node-test-modules.jsnpm run format -- stackchan/services/chat.ts tests/unit/chat-service-contract.test.ts scripts/prepare-node-test-modules.js package.json tsconfig.test.jsonNote: full
npm run lint -- ...currently scans the repo-wide script paths and reports pre-existing warnings in unrelated files; the targeted changed-file lint above is clean.Summary by CodeRabbit
Tests
Chores
Refactor