feat: integrate MiMo Claw agent provider - #865
Conversation
- Add WebSocket JSON-RPC gateway client (gateway.dart) - Add Xiaomi SSO auth service (auth.dart) - Add ChangeNotifier provider (provider.dart) - Add WebView login page (mimo_claw_login_page.dart) - Add settings page (mimo_claw_settings_page.dart) - Register MiMoClawProvider in main.dart - Add MiMo Claw entry to settings page - Add web_socket_channel dependency
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f330e4448e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| _wsSubscription?.cancel(); | ||
| _ws?.sink.close(1000, '用户断开'); | ||
| _ws = null; | ||
| _connectionReady?.completeError(Exception('连接已断开')); |
There was a problem hiding this comment.
Avoid completing the ready completer twice
After a successful handshake, _connectionReady has already been completed in _doConnect, but it remains non-null. Any later normal disconnect path, such as pressing logout, reconnecting, or disposing the provider after login, calls completeError on the same completed completer and throws Bad state: Future already completed, so the disconnect action can crash instead of cleaning up.
Useful? React with 👍 / 👎.
| _cookies = cookies; | ||
| _isLoggedIn = true; | ||
| notifyListeners(); |
There was a problem hiding this comment.
Roll back login state when gateway connection fails
When cookie validation succeeds but _gateway.connect fails because the WS ticket/handshake/network is unavailable, completeLogin returns false from the catch while leaving _cookies and _isLoggedIn set and listeners already notified. In that failure scenario the settings UI will think the account is logged in even though the gateway never connected, hiding the login flow until the user manually logs out.
Useful? React with 👍 / 👎.
| onTap: () async { | ||
| await widget.provider.completeLogin( | ||
| widget.provider.isLoggedIn ? '' : '', | ||
| ); |
There was a problem hiding this comment.
Reuse the saved cookies for reconnect
On the logged-in settings screen, tapping “重新连接” always calls completeLogin with an empty cookie string because both sides of the ternary are ''. Since completeLogin validates that cookie before reconnecting, this action cannot restore a dropped MiMo Claw connection; it should use the stored provider cookies instead.
Useful? React with 👍 / 👎.
MiMo Claw 集成
将小米 MiMo Claw 的完整 Agent 能力接入 Kelivo。
新增文件
lib/core/services/mimo_claw/gateway.dart- WebSocket JSON-RPC 客户端lib/core/services/mimo_claw/auth.dart- 小米 SSO 登录服务lib/core/services/mimo_claw/provider.dart- ChangeNotifier Providerlib/ui/screens/mimo_claw_login_page.dart- WebView 登录页lib/ui/screens/mimo_claw_settings_page.dart- 设置页面功能
使用方式
设置 → MiMo Claw → 登录 → 即可使用