Jason
85334d8dce
refine(usage): enhance query robustness and error handling
...
Backend improvements:
- Add InvalidHttpMethod error enum for better error semantics
- Clamp HTTP timeout to 2-30s to prevent config abuse
- Strict HTTP method validation instead of silent fallback to GET
Frontend improvements:
- Add i18n support for usage query errors (en/zh)
- Improve error handling with type-safe unknown instead of any
- Optimize i18n import (direct import instead of dynamic)
- Disable auto-retry for usage queries to avoid API stampede
Additional changes:
- Apply prettier formatting to affected files
Files changed:
- src-tauri/src/error.rs (+2)
- src-tauri/src/usage_script.rs (+8 -2)
- src/i18n/locales/{en,zh}.json (+4 -1 each)
- src/lib/api/usage.ts (+21 -4)
- src/lib/query/queries.ts (+1)
- style: prettier formatting on 6 other files
2025-11-03 10:24:59 +08:00
Jason
8e4a0a1bbb
refactor(types): rename AppType to AppId for semantic clarity
...
Rename `AppType` to `AppId` across the entire frontend codebase to better
reflect its purpose as an application identifier rather than a type category.
This aligns frontend naming with backend command parameter conventions.
Changes:
- Rename type `AppType` to `AppId` in src/lib/api/types.ts
- Remove `AppType` export from src/lib/api/index.ts
- Update all component props from `appType` to `appId` (43 files)
- Update all variable names from `appType` to `appId`
- Synchronize documentation (CHANGELOG, refactoring plans)
- Update test files and MSW mocks
BREAKING CHANGE: `AppType` type is no longer exported. Use `AppId` instead.
All component props have been renamed from `appType` to `appId`.
2025-10-30 14:59:15 +08:00
Jason
57552b3159
fix: unify dialog layout and fix content padding issues
...
- Fix negative margin overflow in all dialog content areas
- Standardize dialog structure with flex-col layout
- Add consistent py-4 spacing to all content areas
- Ensure proper spacing between header, content, and footer
Affected components:
- AddProviderDialog, EditProviderDialog
- McpFormModal, McpPanel
- UsageScriptModal
- SettingsDialog
All dialogs now follow unified layout pattern:
- DialogContent: flex flex-col max-h-[90vh]
- Content area: flex-1 overflow-y-auto px-6 py-4
- No negative margins that cause content overflow
2025-10-18 16:52:02 +08:00
Jason
f5c6363dee
fix: eliminate layout shift when switching between Claude and Codex
...
Fixed dual-source jitter issue:
1. Horizontal shift: Use overflow-y-scroll to force scrollbar gutter
2. Vertical jump: Use keepPreviousData to maintain content during app switch
2025-10-17 21:51:37 +08:00
Jason
0cff882a3f
refactor: improve code quality and consistency
...
Changes:
1. Remove unused variable in useSettings.ts (readPersistedLanguage)
2. Replace manual state management with React Query in UsageFooter
- Create useUsageQuery hook with 5-minute cache
- Simplify component from 227 lines to 81 lines (-64%)
- Improve consistency with project's React Query pattern
- Enable automatic refetch and error handling
2025-10-17 19:18:10 +08:00
Jason
f3e7412a14
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)
2025-10-16 12:13:51 +08:00
Jason
cc0b7053aa
feat: complete stage 1 infrastructure
2025-10-16 10:00:22 +08:00