feat: complete stage 4 cleanup and code formatting
This commit completes stage 4 of the refactoring plan, focusing on cleanup and optimization of the modernized codebase. ## Key Changes ### Code Cleanup - Remove legacy `src/lib/styles.ts` (no longer needed) - Remove old modal components (`ImportProgressModal.tsx`, `ProviderList.tsx`) - Streamline `src/lib/tauri-api.ts` from 712 lines to 17 lines (-97.6%) - Remove global `window.api` pollution - Keep only event listeners (`tauriEvents.onProviderSwitched`) - All API calls now use modular `@/lib/api/*` layer ### Type System - Clean up `src/vite-env.d.ts` (remove 156 lines of outdated types) - Remove obsolete global type declarations - All TypeScript checks pass with zero errors ### Code Formatting - Format all source files with Prettier (82 files) - Fix formatting issues in 15 files: - App.tsx and core components - MCP management components - Settings module components - Provider management components - UI components ### Documentation Updates - Update `REFACTORING_CHECKLIST.md` with stage 4 progress - Mark completed tasks in `REFACTORING_MASTER_PLAN.md` ## Impact **Code Reduction:** - Total: -1,753 lines, +384 lines (net -1,369 lines) - tauri-api.ts: 712 → 17 lines (-97.6%) - Removed styles.ts: -82 lines - Removed vite-env.d.ts declarations: -156 lines **Quality Improvements:** - ✅ Zero TypeScript errors - ✅ Zero TODO/FIXME comments - ✅ 100% Prettier compliant - ✅ Zero `window.api` references - ✅ Fully modular API layer ## Testing - [x] TypeScript compilation passes - [x] Code formatting validated - [x] No linting errors Stage 4 completion: 100% Ready for stage 5 (testing and bug fixes)
This commit is contained in:
@@ -4,3 +4,4 @@ export { settingsApi } from "./settings";
|
||||
export { mcpApi } from "./mcp";
|
||||
export { usageApi } from "./usage";
|
||||
export { vscodeApi } from "./vscode";
|
||||
export type { ProviderSwitchEvent } from "./providers";
|
||||
|
||||
@@ -18,7 +18,7 @@ export const mcpApi = {
|
||||
|
||||
async upsertServer(
|
||||
id: string,
|
||||
spec: McpServerSpec | Record<string, any>
|
||||
spec: McpServerSpec | Record<string, any>,
|
||||
): Promise<boolean> {
|
||||
return await invoke("upsert_claude_mcp_server", { id, spec });
|
||||
},
|
||||
@@ -35,11 +35,19 @@ export const mcpApi = {
|
||||
return await invoke("get_mcp_config", { app });
|
||||
},
|
||||
|
||||
async importFromClaude(): Promise<number> {
|
||||
return await invoke("import_mcp_from_claude");
|
||||
},
|
||||
|
||||
async importFromCodex(): Promise<number> {
|
||||
return await invoke("import_mcp_from_codex");
|
||||
},
|
||||
|
||||
async upsertServerInConfig(
|
||||
app: AppType,
|
||||
id: string,
|
||||
spec: McpServer,
|
||||
options?: { syncOtherSide?: boolean }
|
||||
options?: { syncOtherSide?: boolean },
|
||||
): Promise<boolean> {
|
||||
const payload = {
|
||||
app,
|
||||
@@ -55,7 +63,7 @@ export const mcpApi = {
|
||||
async deleteServerInConfig(
|
||||
app: AppType,
|
||||
id: string,
|
||||
options?: { syncOtherSide?: boolean }
|
||||
options?: { syncOtherSide?: boolean },
|
||||
): Promise<boolean> {
|
||||
const payload = {
|
||||
app,
|
||||
@@ -66,4 +74,20 @@ export const mcpApi = {
|
||||
};
|
||||
return await invoke("delete_mcp_server_in_config", payload);
|
||||
},
|
||||
|
||||
async setEnabled(
|
||||
app: AppType,
|
||||
id: string,
|
||||
enabled: boolean,
|
||||
): Promise<boolean> {
|
||||
return await invoke("set_mcp_enabled", { app, id, enabled });
|
||||
},
|
||||
|
||||
async syncEnabledToClaude(): Promise<boolean> {
|
||||
return await invoke("sync_enabled_mcp_to_claude");
|
||||
},
|
||||
|
||||
async syncEnabledToCodex(): Promise<boolean> {
|
||||
return await invoke("sync_enabled_mcp_to_codex");
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { listen, type UnlistenFn } from "@tauri-apps/api/event";
|
||||
import type { Provider } from "@/types";
|
||||
import type { AppType } from "./types";
|
||||
|
||||
@@ -7,6 +8,11 @@ export interface ProviderSortUpdate {
|
||||
sortIndex: number;
|
||||
}
|
||||
|
||||
export interface ProviderSwitchEvent {
|
||||
appType: AppType;
|
||||
providerId: string;
|
||||
}
|
||||
|
||||
export const providersApi = {
|
||||
async getAll(appType: AppType): Promise<Record<string, Provider>> {
|
||||
return await invoke("get_providers", { app_type: appType, app: appType });
|
||||
@@ -64,7 +70,7 @@ export const providersApi = {
|
||||
|
||||
async updateSortOrder(
|
||||
updates: ProviderSortUpdate[],
|
||||
appType: AppType
|
||||
appType: AppType,
|
||||
): Promise<boolean> {
|
||||
return await invoke("update_providers_sort_order", {
|
||||
updates,
|
||||
@@ -72,4 +78,13 @@ export const providersApi = {
|
||||
app: appType,
|
||||
});
|
||||
},
|
||||
|
||||
async onSwitched(
|
||||
handler: (event: ProviderSwitchEvent) => void,
|
||||
): Promise<UnlistenFn> {
|
||||
return await listen("provider-switched", (event) => {
|
||||
const payload = event.payload as ProviderSwitchEvent;
|
||||
handler(payload);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
@@ -20,7 +20,7 @@ export const vscodeApi = {
|
||||
|
||||
async testApiEndpoints(
|
||||
urls: string[],
|
||||
options?: { timeoutSecs?: number }
|
||||
options?: { timeoutSecs?: number },
|
||||
): Promise<EndpointLatencyResult[]> {
|
||||
return await invoke("test_api_endpoints", {
|
||||
urls,
|
||||
@@ -30,7 +30,7 @@ export const vscodeApi = {
|
||||
|
||||
async getCustomEndpoints(
|
||||
appType: AppType,
|
||||
providerId: string
|
||||
providerId: string,
|
||||
): Promise<CustomEndpoint[]> {
|
||||
return await invoke("get_custom_endpoints", {
|
||||
app_type: appType,
|
||||
@@ -44,7 +44,7 @@ export const vscodeApi = {
|
||||
async addCustomEndpoint(
|
||||
appType: AppType,
|
||||
providerId: string,
|
||||
url: string
|
||||
url: string,
|
||||
): Promise<void> {
|
||||
await invoke("add_custom_endpoint", {
|
||||
app_type: appType,
|
||||
@@ -59,7 +59,7 @@ export const vscodeApi = {
|
||||
async removeCustomEndpoint(
|
||||
appType: AppType,
|
||||
providerId: string,
|
||||
url: string
|
||||
url: string,
|
||||
): Promise<void> {
|
||||
await invoke("remove_custom_endpoint", {
|
||||
app_type: appType,
|
||||
@@ -74,7 +74,7 @@ export const vscodeApi = {
|
||||
async updateEndpointLastUsed(
|
||||
appType: AppType,
|
||||
providerId: string,
|
||||
url: string
|
||||
url: string,
|
||||
): Promise<void> {
|
||||
await invoke("update_endpoint_last_used", {
|
||||
app_type: appType,
|
||||
|
||||
Reference in New Issue
Block a user