Skip to content

Refactor UI auth/bootstrap and remove legacy UI runtime layers#63

Merged
senamakel merged 18 commits into
tinyhumansai:mainfrom
senamakel:fix/ui-flow-phase2
Mar 30, 2026
Merged

Refactor UI auth/bootstrap and remove legacy UI runtime layers#63
senamakel merged 18 commits into
tinyhumansai:mainfrom
senamakel:fix/ui-flow-phase2

Conversation

@senamakel
Copy link
Copy Markdown
Member

Summary

  • Removed legacy React providers (AIProvider, SkillProvider) from app composition and deleted their modules.
  • Changed auth bootstrap so UI no longer depends on /telegram/me during startup.
  • Fixed infinite /telegram/me retry behavior by limiting auto-fetch in useUser to once per token.
  • Removed unused UI-side Gmail/Notion state slices and most obsolete app/src/lib modules that duplicated core/runtime logic.
  • Kept runtime-used lib surfaces (skills, mcp, channels routing, local core ai memory shim, tools file watcher compatibility) to avoid UI breakage.
  • Included hook-driven lint/format/cargo-fmt cleanups required by pre-push checks.

Problem

  • UI still contained duplicated local runtime/business logic even though behavior moved to core RPC.
  • Startup/logout flow could be incorrect when session existed in core but /telegram/me failed.
  • Repeated 401s from /telegram/me caused repeated fetch attempts and noisy/infinite request loops.

Solution

  • Simplified provider chain and removed legacy local AI/skill providers from App.tsx.
  • Kept auth bootstrap source-of-truth in core session RPC (get_state + get_session_token).
  • Removed startup dependency on /telegram/me from UserProvider.
  • Updated useUser with a per-token auto-fetch guard to prevent repeated failed retries.
  • Removed dead slices/files (gmailSlice, notionSlice, unused app/src/lib trees) and adjusted tests/types where needed.
  • Preserved compatibility shims where still imported by runtime code (forceToolsCacheRefresh no-op).

Testing

  • yarn -s compile
  • cargo check --manifest-path app/src-tauri/Cargo.toml
  • Other checks run (list commands)
  • yarn --cwd app vitest run --config test/vitest.config.ts src/utils/__tests__/authFlow.e2e.test.tsx src/store/__tests__/authSelectors.test.ts
  • yarn format:check (via pre-push)
  • yarn lint (via pre-push)
  • yarn compile (via pre-push)
  • Manual validation completed (list scenarios)
  • Stored a valid core session via CLI, opened app UI, verified no forced logout from startup /telegram/me check.
  • Verified repeated 401 behavior no longer loops infinitely due to auto-fetch guard.

Impact

  • Desktop UI auth flow is now more aligned with core-side session state.
  • Lower frontend complexity and maintenance burden by removing duplicated UI runtime logic.
  • Reduced backend noise from repeated unauthorized user-profile fetches.

Breaking Changes

  • None
  • Yes (describe clearly, including migration steps)

Related

  • Issue(s): n/a
  • Follow-up PR(s)/TODOs:
  • Continue migrating remaining UI skill orchestration details to core RPC surfaces where appropriate.

- Updated `e2e-build.sh` to set CI environment variable correctly for compatibility with various CI runners.
- Refactored `backendUrl.ts` to support dynamic backend URL resolution from Vite environment variables, improving flexibility in different deployment contexts.
- Introduced new web channel commands for sending and canceling chat messages, improving user interaction with the chat system.
- Added support for server-sent events (SSE) to handle real-time updates for chat interactions, enhancing responsiveness.
- Refactored existing code to improve readability and maintainability, including updates to the core HTTP router and JSON-RPC handling.
- Implemented comprehensive end-to-end tests for the web channel flow, ensuring robust functionality and user experience.
- Enhanced the overall structure of the web channel module, including event publishing and subscription mechanisms for better scalability.
- Removed Tauri-specific socket handling from various components, streamlining the codebase to use a single Socket.IO client for both web and desktop environments.
- Updated the `useIntelligenceSocket` hook to eliminate Tauri checks and directly utilize the socket service for message sending and chat initialization.
- Refactored metadata synchronization in Gmail and Notion services to use the unified socket service, enhancing consistency in socket communication.
- Improved error handling and logging across socket interactions to provide clearer feedback during connection issues.
- Enhanced the Conversations component to manage socket connection status, ensuring a more robust user experience during chat interactions.
- Replaced the deprecated `getBackendUrl` function with `resolveCoreSocketBaseUrl` to improve backend URL resolution for socket connections, accommodating both Tauri and non-Tauri environments.
- Introduced `coreSocketBaseFromRpcUrl` to streamline the processing of RPC URLs.
- Removed the `tauriSocket.ts` file, consolidating socket handling into a unified service for better maintainability and clarity.
- Updated the socket connection logging to provide more informative messages during connection attempts.
…argo.toml

- Introduced new packages: `engineioxide` and `socketioxide`, both at version 0.15.2, enhancing the project's capabilities.
- Updated `Cargo.toml` to include `socketioxide` with the "extensions" feature, ensuring proper integration with the existing codebase.
- Added dependencies for both packages, improving modularity and functionality across the application.
- Removed unused imports and functions related to Notion context and socket handling, simplifying the Conversations component.
- Enhanced error handling during chat interactions, ensuring clearer feedback for users.
- Updated chatSend function parameters to eliminate unnecessary context, improving the clarity of the API call.
- Consolidated logic for managing chat message history and context, enhancing maintainability and readability of the code.
- Introduced debug logging for socket RPC requests and responses, providing better visibility into the communication process.
- Enhanced error handling in the core RPC client to log detailed error messages, improving debugging capabilities.
- Updated socket service to log inbound events, ensuring comprehensive tracking of socket interactions.
- Removed deprecated MCP handlers from the socket service, streamlining the codebase and improving maintainability.
- Changed the declaration of `_getToken` from `let` to `var` in `apiClient.ts` to enhance variable scoping.
- Removed unused imports in `socketService.ts`, streamlining the code and improving readability.
- Updated the deep link configuration in `lib.rs` to use a more generalized `#[cfg(desktop)]` directive, improving compatibility across desktop platforms.
- Enhanced the `triggerDeepLink` function in `deep-link-helpers.ts` to include macOS-specific app activation and launching logic, ensuring better integration with the macOS environment.
- Introduced a new `buildBypassJwt` function to generate bypass JWT tokens for E2E testing, improving the flexibility of authentication flows in tests.
- Updated E2E tests in `conversations-web-channel-flow.spec.ts` to utilize the new `triggerAuthDeepLinkBypass` function, enhancing the testing of authentication scenarios.
- Updated `triggerAuthDeepLink` in `deep-link-helpers.ts` to support environment-based bypass tokens, improving flexibility in authentication flows during E2E tests.
- Modified the `serve_on_ephemeral` function call in `json_rpc_e2e.rs` to disable the core HTTP router's default behavior, enhancing test isolation and control over the testing environment.
- Updated `authFlow.e2e.test.tsx` to utilize `window.__simulateDeepLink` for simulating deep links, improving test accuracy and alignment with real-world scenarios.
- Modified `lib.rs` to restrict deep link registration to Windows and Linux platforms, clarifying platform-specific behavior.
- Enhanced `deep-link-helpers.ts` with a new function to simulate deep links in the WebView, providing a fallback mechanism for E2E tests.
- Updated `conversations-web-channel-flow.spec.ts` to reflect changes in deep link triggering, improving logging and test clarity.
… stability

- Removed several unused dependencies from `Cargo.lock` and `Cargo.toml`, including `aes-gcm`, `argon2`, and `async-imap`, streamlining the project and reducing potential security vulnerabilities.
- Updated existing dependencies to their latest versions, ensuring compatibility and leveraging improvements in performance and security.
- Simplified the dependency structure by consolidating features and removing unnecessary comments, enhancing clarity and maintainability of the configuration files.
- Removed `AIProvider` and `SkillProvider` from the `App` component, streamlining the component structure and improving readability.
- Updated the `UserProvider` to focus solely on bootstrapping the authentication token, enhancing its clarity and purpose.
- Adjusted the layout within the `App` component to maintain functionality without the removed providers, ensuring a smooth user experience.
- Deleted the `index.ts`, `loader.ts`, `types.ts`, and related test files from the AI module, streamlining the codebase by removing unused and outdated components.
- Eliminated the `default-constitution.md` and associated constitution files, which were no longer relevant to the current architecture.
- This cleanup enhances maintainability and reduces complexity within the AI system.
- Enhanced the `useUser` hook to prevent infinite retry loops by implementing a token check with a reference to track the last auto-fetch token.
- Removed the legacy file watcher for `TOOLS.md`, transitioning to a core RPC and socket event-based refresh mechanism for tool/config updates.
- Updated test state structure to include `isAuthBootstrapComplete` and `channelConnections`, improving test coverage and state management.
- Consolidated channel modules under a new `providers` directory, improving organization and clarity.
- Introduced new channel providers for DingTalk, Discord, Email, iMessage, IRC, and Lark, expanding the messaging capabilities of the application.
- Updated the `mod.rs` file to reflect the new structure and ensure proper module exports, enhancing maintainability and ease of use.
@senamakel senamakel merged commit 7ad3c73 into tinyhumansai:main Mar 30, 2026
2 of 5 checks passed
@senamakel senamakel deleted the fix/ui-flow-phase2 branch March 31, 2026 00:55
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