Commit Graph

209 Commits

Author SHA1 Message Date
bnvnvnv bc3c731ed2 feat: add site observability log drilldown 2026-03-11 11:03:57 +00:00
Hureru f5fcf5d707 fix: address code review findings
- fix(api): use effectiveTokenId in route channel insert to match duplicate detection logic
- fix(css): rename keyframes to kebab-case (filter-bar-slide-down/up)
- fix(web): wrap "保存中..." text with tr() in ManualRoutePanel
- fix(web): use ref for fresh cache check and add error handling in useRouteChannels
2026-03-11 15:51:10 +08:00
Hureru 8128d6e036 fix(web): remove outdated decision auto-skip hint from info tip 2026-03-11 14:58:33 +08:00
Hureru a0e474c561 perf(web): optimize TokenRoutes rendering and add infinite scroll
Rendering optimization:
- Extract stable routePatterns derived value to avoid expensive useMemo
  recomputation on enable/disable toggle (only recompute when patterns change)
- Stabilize all RouteCard callback props with useCallback+useRef pattern
- Pre-compute missingTokenSiteItems as useMemo index instead of per-render call
- Add EMPTY_MISSING_ITEMS constant for stable empty array reference

Infinite scroll:
- Replace manual "load more" button with IntersectionObserver sentinel
- Auto-load next chunk when scrolling within 200px of bottom
2026-03-11 14:06:23 +08:00
Hureru 47064ba7af perf(web): cache matchesModelPattern regex compilation and results
- Cache compiled glob RegExp objects to avoid repeated new RegExp()
- Cache model+pattern match results (up to 4000 entries)
- Significantly reduces CPU cost of pattern matching in route computations
2026-03-11 14:05:00 +08:00
Hureru 49dbaf3c6a fix(web): fix route card title overflow and optimize with React.memo
Layout fixes:
- Title uses flex:1 + text-overflow:ellipsis, badges always right-aligned
- Enable button has minWidth for cross-card vertical alignment
- Icon and badges use flexShrink:0 to prevent compression

Performance:
- Wrap RouteCard with React.memo to skip re-renders for unchanged routes
- Change callback props to accept routeId for stable reference compatibility
2026-03-11 14:04:04 +08:00
Hureru 69cc491d3a fix(web): fix AddChannelModal checkbox toggle and click area
- Move onClick handler to outer card div for full-area click support
- Set checkbox to readOnly with pointerEvents:none to prevent double-toggle
- Add stopPropagation on token select section to avoid unintended toggling
2026-03-11 14:01:45 +08:00
Hureru 90f92711fd fix(web): wire AddChannelModal with missing token hints and channel context
Pass missingTokenHints, onCreateTokenForMissing, and
existingChannelAccountIds to AddChannelModal so users can see
accounts that need token creation and identify already-added channels.
2026-03-11 12:00:07 +08:00
Hureru d2e1e7765d fix(web): add missing token hints and existing channel badge to AddChannelModal
- Display accounts that have model availability but lack tokens,
  with a "create token" action button for each
- Mark already-added channel accounts with a badge
- Improve empty state message to guide users on next steps
- Search now filters both available accounts and missing-token accounts
2026-03-11 11:53:26 +08:00
Hureru 457b4915da test: update TokenRoutes tests for summary-based data loading
Adapt all 3 test files to mock getRoutesSummary instead of getRoutes,
use summary-format data structures, and expand cards before asserting
channel-level content.
2026-03-11 01:15:02 +08:00
Hureru 1183d7fde0 refactor(web): rewrite TokenRoutes with grid layout and layered loading
Replace full-data loading with summary-first approach. Implement CSS Grid
multi-column card layout, collapsible filter panel, and collapsed-by-default
route cards that load channels on demand when expanded.
2026-03-11 01:14:52 +08:00
Hureru fa232950b9 refactor(web): extract TokenRoutes into modular sub-components
Split the 2447-line TokenRoutes.tsx into focused modules:
- types.ts: shared type definitions
- utils.ts: pure helper functions
- SortableChannelRow.tsx: DnD channel row component
- ManualRoutePanel.tsx: route create/edit form
- RouteFilterBar.tsx: collapsible filter panel with chip layout
- RouteCard.tsx: collapsed/expanded route card
- AddChannelModal.tsx: batch add channel modal
- useRouteChannels.ts: on-demand channel loading hook
2026-03-11 01:14:42 +08:00
Hureru bb7ea90f0b feat(api): add layered route loading endpoints
Add GET /api/routes/summary for lightweight first-screen data,
GET /api/routes/:id/channels for on-demand channel loading,
and POST /api/routes/:id/channels/batch for bulk channel creation.
Extract fetchChannelsForRoutes() as reusable helper.
2026-03-11 01:14:31 +08:00
Hureru 2343383729 feat: add lightweight /api/routes/lite endpoint for route selectors
Avoid loading full route data (channels, decision snapshots) when Settings
page only needs basic route info for selectors.
2026-03-10 23:06:56 +08:00
cita 5e14c2282f feat: Add MobileDrawer component and About page, and update package version. 2026-03-10 17:16:12 +08:00
cita 2268641759 Merge branch 'main' of https://github.com/cita-777/metapi 2026-03-10 16:59:43 +08:00
cita 521b5bf391 feat: Implement core web application with routing, user authentication, theme settings, user profiles, and mobile navigation. 2026-03-10 16:59:39 +08:00
Cita a60adf4e26 Merge pull request #50 from cita-777/codex/model-refresh-health
Codex/model refresh health
2026-03-10 16:55:47 +08:00
cita 747b985513 feat: refine model refresh toasts and failure handling 2026-03-10 16:44:10 +08:00
cita ab2220bc09 fix: export MobileDrawer 2026-03-10 16:25:44 +08:00
cita ab4033c1fa fix: avoid brandList TDZ in TokenRoutes 2026-03-10 16:18:44 +08:00
cita 1dbde9346a fix: guard useIsMobile in non-browser 2026-03-10 16:14:37 +08:00
cita 715a2dba9b feat: add mobile actions and CSS 2026-03-10 16:05:24 +08:00
cita f01379f7a3 feat: convert logs and routes pages to mobile cards 2026-03-10 15:48:10 +08:00
cita b8ebf98b68 fix: add account mobile hints 2026-03-10 15:35:13 +08:00
cita b23c5ece83 feat: convert core pages to mobile cards 2026-03-10 15:27:28 +08:00
cita 37e325d3cf feat: add mobile card components 2026-03-10 15:09:41 +08:00
cita d91a160455 feat: add mobile nav drawer 2026-03-10 15:00:43 +08:00
cita 2d8e1b9019 feat: add mobile drawer shell 2026-03-10 14:55:21 +08:00
cita ed830563d2 test: assert mobile layout attribute 2026-03-10 14:49:22 +08:00
cita 4e3d82aae1 feat: add mobile layout detection 2026-03-10 14:39:57 +08:00
cita 0f8176cd04 feat: Implement compatibility strategies for responses and chat endpoints
- Added `routeCompatibility.ts` to handle response compatibility for different endpoints.
- Introduced `chatEndpointStrategy.ts` to manage chat endpoint recovery and downgrading logic.
- Created tests for chat formats and input file handling in `chatFormatsCore.test.ts` and `inputFile.test.ts`.
- Developed `endpointCompatibility.ts` to define compatibility checks and header building for various endpoints.
- Implemented protocol lifecycle management in `protocolLifecycle.ts` and corresponding tests in `protocolModel.test.ts`.
- Enhanced tooltip functionality with a new `TooltipLayer` component and associated tests.
- Refactored existing components to improve tooltip handling and ensure proper rendering in the application.
2026-03-09 22:48:10 +08:00
cita 136a038538 feat(tests): enhance modelTesterSession tests and add proxy logs tests
- Updated modelTesterSession tests to serialize assistant history as output_text and removed mime_type from input_file.
- Introduced new tests for stats proxy logs routes, covering paginated log retrieval and detailed log views with parsed billing details.
- Added server-driven tests for ProxyLogs component to validate API interactions and UI rendering based on server data.
2026-03-09 13:48:39 +08:00
cita 7bd3114ea0 feat: implement proxy input file resolution and storage
- Added `inputFiles.ts` for handling input file resolution, including validation and normalization of file types.
- Introduced `proxyFileStore.ts` for managing file storage, retrieval, and deletion with owner-based isolation.
- Created tests for proxy file storage functionality in `proxyFileStore.test.ts`.
- Developed `proxyInputFileResolver.ts` to resolve input files in OpenAI and response formats.
- Added utility functions for handling reasoning signatures in `reasoningTransport.ts` and corresponding tests.
- Enhanced shared input file transformers in `inputFile.ts` for better file handling and type inference.
2026-03-08 22:10:31 +08:00
cita 4172ad4297 feat: Implement useThemeLabelColor hook and update components to utilize it for label color management 2026-03-08 13:07:27 +08:00
cita 23922a5965 feat: Add normalized types and utility functions for handling chat formats
- Introduced `NormalizedContentBlock`, `NormalizedUsage`, and related types for structured data handling.
- Implemented utility functions for creating and merging normalized usage statistics.
- Added a new module for shared transformers to manage chat formats.

feat: Implement app local state management

- Created functions to clear application installation state and manage local storage keys.
- Added constants for theme and user profile storage keys.

test: Add tests for BrandIcon component rendering

- Implemented tests to ensure BrandIcon does not force a colored background for recognized brands.

test: Enhance ModelAnalysisPanel tests

- Added tests for rendering token summaries with compact units in ModelAnalysisPanel.

test: Add tests for ModernSelect component

- Implemented tests to verify icon rendering for selected options in ModernSelect.

test: Add number formatting tests

- Created tests for `formatCompactTokenMetric` to validate token formatting logic.

feat: Implement account creation intent handling

- Added logic to handle session and API key creation intents in the Accounts page.

test: Add tests for dashboard performance card

- Implemented tests to verify rendering of performance metrics in the dashboard.

feat: Implement default connection segment resolution

- Added logic to determine initial connection segments based on platform types.

test: Add tests for settings factory reset functionality

- Implemented tests to verify the factory reset process and local state clearing.

test: Add tests for site creation redirect logic

- Implemented tests to verify redirection based on site capabilities during creation.

test: Add tests for token routes refresh decision action

- Implemented tests to verify refresh decision actions in TokenRoutes.

test: Add tests for token routes snapshot load

- Implemented tests to verify loading of cached snapshot data in TokenRoutes.
2026-03-08 12:08:57 +08:00
cita ed05b37626 feat: enhance TokenRoutes with edit functionality and route visibility management
- Added editing capabilities for route management in TokenRoutes, allowing users to modify existing routes.
- Introduced a reset function for the route form to clear inputs after adding or editing routes.
- Implemented a visibility filter for routes, ensuring exact routes covered by group routes are hidden from the main list.
- Updated tests to cover new functionalities, including editing routes and verifying visibility logic.
- Created a new helper function to build a list of visible routes based on defined criteria.
- Enhanced schema compatibility checks for site configurations, ensuring necessary columns are added to the database.
2026-03-07 19:56:40 +08:00
cita c437d93715 Add tests for centered modal adoption, search modal results, and accounts batch actions
- Implement tests for the CenteredModal component to ensure it follows the shared modal shell pattern.
- Add comprehensive tests for the SearchModal results, including API interactions and UI behavior.
- Create tests for accounts batch actions, verifying the functionality of refreshing balances and selecting accounts via row clicks.
- Introduce tests for the accounts centered modal to confirm the use of CenteredModal for add/edit/rebind flows.
- Add tests for the accounts edit panel to ensure proper rendering and functionality when opening the edit modal.
- Implement tests for the accounts tokens header to verify the reuse of the accounts page header in the tokens segment.
- Create tests for the system proxy settings, ensuring the correct saving of the proxy URL.
- Add tests for the tokens actions layout to confirm the proper layout and styling of token row actions.
- Implement tests for the tokens batch actions, including deletion of selected tokens and row selection behavior.
- Introduce tests for the tokens focus navigation to ensure the correct highlighting of focused token rows.
2026-03-07 18:04:05 +08:00
cita c31bbcbb51 refactor: remove deprecated apiKey from site management and update related functionality
- Removed apiKey from SiteRow type and related forms in Sites component.
- Updated site saving logic to handle site creation without apiKey.
- Adjusted tests to ensure apiKey is not included in site editor state.
- Refactored Tokens component to support embedded mode and redirect logic.
- Added migration tests for site apiKey to account migration service.
- Implemented siteApiKeyMigrationService to handle migration of apiKey to account tokens.
- Enhanced tests for segmented connections in Accounts and redirect logic for Tokens.
2026-03-07 15:03:30 +08:00
cita e88fc0a997 feat: implement proxy billing details handling and resolveProxyLogBilling function 2026-03-06 18:28:45 +08:00
cita 55b1ae564e feat: update error messages in NewApiAdapter tests to use correct Chinese translations
feat: enhance proxy usage parser to include cache read and creation tokens

feat: add billing details to ProxyLog interface and implement related formatting functions

fix: correct mojibake issues in source files and add regression test for mojibake detection

chore: add SQL migration for billing details in proxy_logs table

test: improve site speed button tests to ensure proper state updates without DOM lookups
2026-03-06 17:10:01 +08:00
cita 2a810facb8 feat: implement macOS notarization and ad-hoc signing in afterSign script
feat: add run-server script to manage server execution and compatibility checks

feat: create main application logic for desktop with window management, server handling, and auto-updater

test: add unit tests for desktop runtime helpers

feat: implement desktop server environment configuration and health check

test: add tests for server configuration and desktop routes

feat: add native module guard for better-sqlite3 compatibility

test: add tests for native module guard functionality

test: add comprehensive tests for account verification feedback handling

feat: implement account verification feedback helpers

chore: add TypeScript configuration for desktop builds
2026-03-06 16:24:41 +08:00
cita acdc846b13 Refactor logging timestamps to use formatUtcSqlDateTime function across proxy routes and services; add storedTimestampRepairService for fixing createdAt values in database 2026-03-06 11:57:30 +08:00
cita fdf4f30987 feat: add createdAt timestamps to check-in logs and improve i18n translations
- Added createdAt timestamps to various check-in log entries in checkinService.ts for better tracking.
- Updated i18n translations in Models.tsx to improve user experience with accurate Chinese translations.
- Reduced default page size in ProgramLogs.tsx and ProxyLogs.tsx from 80 and 100 to 50 for better performance.
- Enhanced ProxyLogs.tsx with memoization for filtered logs and summary statistics.
- Implemented support for parsing Unix timestamps and PostgreSQL-style timezone offsets in checkinLogTime.ts.
- Added comprehensive tests for database proxy query wrapper in index.proxy-wrap.test.ts to ensure functionality.
2026-03-05 21:18:49 +08:00
cita 0d5e56f478 feat(settings): add validation for SQLite connection strings and improve error messages 2026-03-05 19:37:09 +08:00
cita b122893796 Add tests for settings database runtime configuration API
- Implement tests for retrieving and saving runtime database configuration.
- Validate handling of invalid configuration payloads.
- Utilize Fastify for API testing with Vitest.
- Ensure proper cleanup of database state between tests.
2026-03-05 18:57:18 +08:00
cita 283c052fa5 test:Add database migration service with normalization and masking functions
- Implemented `normalizeMigrationInput` to standardize database migration input for sqlite, mysql, and postgres.
- Added `maskConnectionString` to obscure sensitive credentials in connection strings.
- Created comprehensive tests for migration input normalization and connection string masking.
- Established database schema creation logic for multiple dialects (sqlite, mysql, postgres).
- Developed functions for managing database transactions, including begin, commit, and rollback.
- Implemented data insertion logic from backup snapshots into the target database.
2026-03-05 17:38:52 +08:00
cita 4a61148b4f feat(accounts): extend rebind-session API to handle refresh token and expiration fields 2026-03-05 14:28:10 +08:00
cita 27501b5a85 feat(ProgramLogs): add event status summary parsing and corresponding labels 2026-03-05 13:08:59 +08:00
cita 9fbf434bd6 feat(proxy): enhance upstream endpoint handling and error summarization
- Added new utility functions for building minimal JSON headers and normalizing responses for compatibility.
- Implemented detailed error handling for unsupported media types and endpoint downgrade scenarios.
- Introduced a new endpoint flow mechanism to manage retries and downgrades between different upstream endpoints.
- Enhanced tests for endpoint flow and error summarization to cover various edge cases and scenarios.
- Updated CSS styles for accounts table to improve layout and responsiveness.
- Refactored ModelTester component to handle incremental text updates more effectively.
2026-03-04 20:59:48 +08:00