mirror of
https://github.com/tinyhumansai/openhuman.git
synced 2026-07-29 22:23:01 +00:00
Emit tool:sync socket event on skill state changes (#83)
* Refactor BillingPanel to use updated user usage structure - Changed the usage data source in BillingPanel from activeTeam to user, aligning with the new IUserUsage interface. - Updated the display of token usage percentage and progress bar to reflect the new usage metrics (spentThisCycleUsd and cycleBudgetUsd). - Cleaned up commented-out code and improved layout for better readability and user experience. * Enhance skill synchronization and connection status management - Exported `deriveConnectionStatus` function from hooks for better accessibility. - Introduced `syncToolsToBackend` function to synchronize tool states with the backend, ensuring up-to-date connection status. - Integrated `syncToolsToBackend` calls in `SkillManager` lifecycle methods and socket connection events to maintain consistent state across the application. - Added new `sync.ts` file to encapsulate synchronization logic, improving code organization and maintainability. * Add Rust-side tool:sync emission and document dual socket codebase Implement tool:sync on the Rust side so desktop/mobile apps emit skill state to the backend natively, without relying on the frontend WebView. - SocketManager: add sync_tools() method, derive_connection_status() helper, and sync_tools_via_channel() for event handler context - SocketManager: emit tool:sync on "ready" (connect/reconnect) - RuntimeEngine: store SocketManager reference, call sync_tools after start_skill, stop_skill, and auto_start_skills - lib.rs: wire SocketManager into RuntimeEngine during setup - CLAUDE.md: add Dual Socket Codebase pattern noting that any socket event change must be implemented in both TypeScript and Rust Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
4be6693599
commit
d0048718ea
@@ -16,6 +16,7 @@
|
||||
import { isTauri as coreIsTauri, invoke } from '@tauri-apps/api/core';
|
||||
import { listen, UnlistenFn } from '@tauri-apps/api/event';
|
||||
|
||||
import { syncToolsToBackend } from '../lib/skills/sync';
|
||||
import { store } from '../store';
|
||||
import { setSocketIdForUser, setStatusForUser } from '../store/socketSlice';
|
||||
import { BACKEND_URL } from './config';
|
||||
@@ -149,6 +150,10 @@ export async function setupTauriSocketListeners(): Promise<void> {
|
||||
const mappedStatus: ReduxStatus = statusMap[status] || 'disconnected';
|
||||
store.dispatch(setStatusForUser({ userId: uid, status: mappedStatus }));
|
||||
store.dispatch(setSocketIdForUser({ userId: uid, socketId: socket_id ?? null }));
|
||||
|
||||
if (mappedStatus === 'connected') {
|
||||
syncToolsToBackend();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user