5.1 KiB
5.1 KiB
Refactor Summary
Scope
This branch captures local refactors focused on frontend UX polish, IPC call consolidation, transport abstraction, and channel page responsiveness.
Key Changes
1. Frontend IPC consolidation
- Replaced scattered direct
window.electron.ipcRenderer.invoke(...)calls with unifiedinvokeIpc(...)usage. - Added lint guard to prevent new direct renderer IPC invokes outside the API layer.
- Introduced a centralized API client with:
- error normalization (
AppError) - unified
app:requestsupport + compatibility fallback - retry helper for timeout/network errors
- error normalization (
2. Transport abstraction (extensible protocol layer)
- Added transport routing abstraction inside
src/lib/api-client.ts:ipc,ws,http- rule-based channel routing
- transport registration/unregistration
- failure backoff and fallback behavior
- Added default transport initialization in app entry.
- Added gateway-specific transport adapters for WS/HTTP.
3. HTTP path moved to Electron main-process proxy
- Added
gateway:httpProxyIPC handler in main process to avoid renderer-side CORS issues. - Preload allowlist updated for
gateway:httpProxy. - Gateway HTTP transport now uses IPC proxy instead of browser
fetchdirect-to-gateway.
4. Settings improvements (Developer-focused transport control)
- Added persisted setting
gatewayTransportPreference. - Added runtime application of transport preference in app bootstrap.
- Added UI option (Developer section) to choose routing strategy:
- WS First / HTTP First / WS Only / HTTP Only / IPC Only
- Added i18n strings for EN/ZH/JA.
5. Channel page performance optimization
fetchChannelsnow supports options:probe(manual refresh can force probe)silent(background refresh without full-page loading lock)
- Channel status event refresh now debounced (300ms) to reduce refresh storms.
- Initial loading spinner only shown when no existing data.
- Manual refresh uses local spinner state and non-blocking update.
6. UX and component enhancements
- Added shared feedback state component for consistent empty/loading/error states.
- Added telemetry helpers and quick-action/dashboard refinements.
- Setup/settings/providers/chat/skills/cron pages received targeted UX and reliability fixes.
7. IPC main handler compatibility improvements
- Expanded
app:requestcoverage for provider/update/settings/cron/usage actions. - Unsupported app requests now return structured error response instead of throwing, reducing noisy handler exceptions.
8. Tests
- Added unit tests for API client behavior and feedback state rendering.
- Added transport fallback/backoff coverage in API client tests.
Files Added
src/lib/api-client.tssrc/lib/telemetry.tssrc/components/common/FeedbackState.tsxtests/unit/api-client.test.tstests/unit/feedback-state.test.tsxrefactor.md
Notes
- Navigation order in sidebar is kept aligned with
mainordering. - This commit snapshots current local refactor state for follow-up cleanup/cherry-pick work.
Incremental Updates (2026-03-08)
9. Channel i18n fixes
- Added missing
channelslocale keys in EN/ZH/JA to prevent raw key fallback:configured,configuredDesc,configuredBadge,deleteConfirm
- Fixed confirm dialog namespace usage on Channels page:
common:actions.confirm,common:actions.delete,common:actions.cancel
10. Channel save/delete behavior aligned to reload-first strategy
- Added Gateway reload capability in
GatewayManager:reload()(SIGUSR1 on macOS/Linux, restart fallback on failure/unsupported platforms)debouncedReload()for coalesced config-change reloads
- Wired channel config operations to reload pipeline:
channel:saveConfigchannel:deleteConfigchannel:setEnabled
- Removed redundant renderer-side forced restart call after WhatsApp configuration.
11. OpenClaw config compatibility for graceful reload
- Ensured
commands.restart = trueis persisted in OpenClaw config write paths:electron/utils/channel-config.tselectron/utils/openclaw-auth.ts
- Added sanitize fallback that auto-enables
commands.restartbefore Gateway start.
12. Channels page data consistency fixes
- Unified configured state derivation so the following sections share one source:
- stats cards
- configured channels list
- available channel configured badge
- Fixed post-delete refresh by explicitly refetching both:
- configured channel types
- channel status list
13. Channels UX resilience during Gateway restart/reconnect
- Added delayed gateway warning display to reduce transient false alarms.
- Added "running snapshot" rendering strategy:
- keep previous channels/configured view during
starting/reconnectingwhen live response is temporarily empty - avoids UI flashing to zero counts / empty configured state
- keep previous channels/configured view during
- Added automatic refresh once Gateway transitions back to
running.
14. Configure-but-disable support
- Added enable toggle in channel setup dialog (
Enable Channel). - Save flow now persists
enabledwith configuration payload. - Existing config load now reads
enabledstate and pre-fills toggle accordingly.