9 Commits

Author SHA1 Message Date
Arvin Xu
0a8c80dfd2 🐛 fix: fix duplicate tools id issue and fix link dialog issue (#9731)
* add

* baseline

*  test(store): add tests for discover store plugin and mcp slices

- Add comprehensive tests for discover/slices/plugin/action.ts (15 tests)
- Add comprehensive tests for discover/slices/mcp/action.ts (11 tests)
- Update test-coverage.md with new metrics and completed work
- Coverage: 74.24% overall (+26 tests, 2 new test files)
- Action files coverage: 29/40 tested (72.5%, +2 files)

Features tested:
- Plugin/MCP categories, detail, identifiers, and list fetching
- SWR key generation with locale and parameters
- SWR configuration verification
- Service integration with discoverService

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* 📝 docs(testing): add SWR hooks testing guide and subagent workflow

Testing Guide Updates:
- Add comprehensive SWR hooks testing section with examples
- Document key differences from regular action tests
- Add examples for testing SWR key generation and configuration
- Add examples for testing conditional fetching
- Update references to include SWR hook test examples

Test Coverage Guide Updates:
- Add detailed subagent workflow for parallel testing
- Document when and how to use subagents for testing
- Add complete workflow example using subagents
- Add benefits and best practices for subagent usage
- Clarify that subagents should NOT commit or update docs
- Add step-by-step guide for launching parallel subagents

Key improvements:
- Better documentation for testing SWR-based store actions
- Clear workflow for efficient parallel testing using subagents
- Single atomic commit strategy after all subagents complete
- Improved testing efficiency and organization

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* ♻️ refactor(test): fix SWR mock strategy to properly test fetcher

Previously, tests were hardcoding return values instead of calling
the fetcher function. This bypassed the actual service call logic.

Changes:
- Fix useSWR mock to call fetcher and return its Promise
- Update assertions to await Promise results
- Update testing guide with correct mock pattern
- Add explanation of why this approach is correct

Before (incorrect):
```typescript
useSWRMock.mockImplementation(((key, fetcher) => {
  fetcher?.(); // Call but ignore result
  return { data: mockData }; // Hardcoded
}) as any);
expect(result.current.data).toEqual(mockData);
```

After (correct):
```typescript
useSWRMock.mockImplementation(((key, fetcher) => {
  const data = fetcher?.(); // Get Promise from fetcher
  return { data }; // Return Promise
}) as any);
const resolvedData = await result.current.data;
expect(resolvedData).toEqual(mockData);
```

Benefits:
-  Actually tests the fetcher function
-  Mirrors real SWR behavior (data is Promise)
-  Service calls are properly verified
-  Tests are more accurate and maintainable

Updated files:
- .cursor/rules/testing-guide/zustand-store-action-test.mdc
- src/store/discover/slices/plugin/action.test.ts
- src/store/discover/slices/mcp/action.test.ts

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* 🐛 fix(test): correct SWR mock strategy to match project standards

- Remove useSWR mocking, use real SWR implementation instead
- Only mock service methods (fetchers) with vi.spyOn
- Use waitFor for async assertions
- Update testing guide with correct SWR pattern
- Add reference to src/store/chat/slices/message/action.test.ts

This fixes the incorrect mocking approach from previous commits.
All 13 tests pass with the corrected strategy.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

*  test(store): add comprehensive tests for high priority action files

- Add mcpStore action tests (41 tests, 624 LOC covered)
  - MCP plugin installation flow (normal, resume, dependencies, config)
  - Connection testing (HTTP and STDIO)
  - Plugin lifecycle management
  - Error handling and cancellation flows

- Add fileManager action tests (35 tests, 205 LOC covered)
  - File upload and processing workflows
  - Chunk embedding and parsing
  - File list management and refresh
  - SWR data fetching

Testing approach:
- Used parallel subagents for efficient development
- Followed zustand testing patterns from guide
- Proper test layering and per-test mocking
- All tests pass type-check and lint

Coverage improvement: 74.24% → ~76% (+76 tests, 2 files)
Action files: 29/40 → 31/40 tested (77.5%)

🏆 Milestone: All high priority files (>200 LOC) now have tests!

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

*  test(store): complete 100% action file coverage with 160 new tests

Added comprehensive tests for all remaining 9 medium-priority action files:

Discovery Store (33 tests):
- assistant/action.ts: 10 tests (SWR hooks, categories, detail, identifiers, list)
- provider/action.ts: 11 tests (SWR hooks, detail with readme, identifiers, list with filters)
- model/action.ts: 12 tests (SWR hooks, categories, detail, identifiers, list with params)

Knowledge Base Store (29 tests):
- crud/action.ts: 19 tests (create, update, remove, refresh, loading states, SWR hooks)
- content/action.ts: 10 tests (add files, remove files, error handling)

File Store (36 tests):
- upload/action.ts: 18 tests (base64 upload, file upload with progress, type detection, KB integration)
- chunk/action.ts: 18 tests (drawer management, highlight, semantic search)

AI Infrastructure Store (23 tests):
- aiModel/action.ts: 23 tests (CRUD, batch operations, remote sync, toggle enabled, SWR hooks)

Chat Store (39 tests):
- thread/action.ts: 39 tests (CRUD, messaging, AI title generation, validation, loading states)

Testing approach:
- Used 9 parallel subagents for efficient development
- Followed zustand testing patterns from guide
- SWR hook testing for discovery slices
- Complex async flows with proper error handling
- File operations with progress callbacks
- Semantic search and RAG integration

Coverage improvement: ~76% → ~80% (+160 tests, 9 files)
Action files: 31/40 → 40/40 tested (100%)

🎉 MILESTONE: All 40 action files now have comprehensive test coverage!

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix test

* fix test

* fix context-engine

* add tests

* remove

* remove tools bar

* pin bun version

* fix

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-15 22:38:53 +08:00
Asuka109
d1c5645517 🔨 chore: add docker compose to setup local services for development (#8608)
Some checks failed
Upstream Sync / Sync latest commits from upstream repo (push) Has been cancelled
Release CI / Release (push) Has been cancelled
Test CI / Test package electron-server-ipc (push) Has been cancelled
Test CI / Test package file-loaders (push) Has been cancelled
Test CI / Test package model-runtime (push) Has been cancelled
Test CI / Test package prompts (push) Has been cancelled
Test CI / Test package utils (push) Has been cancelled
Test CI / Test package web-crawler (push) Has been cancelled
Test CI / Test package model-bank (push) Has been cancelled
Test CI / Test Website (push) Has been cancelled
Test CI / Test Database (push) Has been cancelled
Lighthouse Badger / LobeChat | Chat (push) Has been cancelled
Lighthouse Badger / LobeChat | Market (push) Has been cancelled
Issue Close Require / issue-check-inactive (push) Has been cancelled
Issue Close Require / issue-close-require (push) Has been cancelled
Daily i18n Update / update-i18n (push) Has been cancelled
* 👷 build: add docker compose to setup local services for development

* 👷 build: setup dotenv-expand for all the npm scripts

* 🐛 fix: remove useless comments

* 📚 docs: add server-side database setup guide with i18n support

- Add comprehensive server-side database setup documentation
- Include step-by-step Docker service configuration
- Add Chinese localization for better developer experience
- Cover environment setup, database migration, and verification steps
2025-09-02 17:06:01 +08:00
Arvin Xu
849584479a 🔨 chore: visualize db schema with dbdocs (#6950)
Some checks failed
Release CI / Release (push) Waiting to run
Test CI / test (push) Waiting to run
Database Schema Visualization CI / build (push) Has been cancelled
* test db schema

* Update sync-database-schema.yml

* Update sync-database-schema.yml

* Update sync-database-schema.yml

* Update package.json

* Update sync-database-schema.yml

* Delete docs/developer/database-schema.dbml

* update workflow

* Update sync-database-schema.yml
2025-03-14 14:24:39 +08:00
Arvin Xu
811e571fe4 🎨 chore: files feature pre-commit to reduce code update (#3488)
* 🎨 chore: pre commit to reduce code update

* 🎨 chore: pre commit to reduce code update

* 🎨 chore: pre commit to reduce code update

*  test: fix test

* 🚚 refactor: move image files to chat

*  test: add tests

*  test: add tests
2024-08-17 22:29:05 +08:00
Arvin Xu
bf8ef1f862 feat: support clerk as auth provider (#2374)
*  feat: support clerk as auth provider

* ♻️ refactor: refactor the auth env config to `s3-oss/env`

*  test: add test for the theme mode and action

* 💄 style: fix style

* 🌐 chore: update locale

*  test: add more test

* 🎨 chore: clean code

* 📝 docs: update docs
2024-05-05 23:15:40 +08:00
Arvin Xu
e012597226 ♻️ refactor: refactor for session server mode (#2163)
* ♻️ refactor: refactor for session server mode

*  test: fix test

*  test: add tests

* 🚨 chore: fix lint
2024-04-24 01:01:51 +08:00
Arvin Xu
79be7afed7 🔍️ perf: add sitemap and robot.txt to improve SEO (#1337)
* 🔍️ fix: add sitemap and robots.txt

* 🐛 fix: fix canonical url

* 🐛 fix: fix canonical url

* 🐛 fix: fix canonical url

* 🐛 fix: fix deploy url

* 🐛 fix: fix canonical url

* 🐛 fix: fix the robots config
2024-02-20 21:33:10 +08:00
canisminor1990
4e522a6e2b 🔧 chore: Update setting
This commit introduces new components, modules, and features related to chat, sessions, and settings. It includes modifications to configuration files, updates to dependencies, adjustments to styles and layouts, and additions of new components and modules. The changes also involve updates to functions, interfaces, selectors, actions, and reducers. Additionally, there are modifications to TypeScript interfaces and types, as well as changes to parameters and functions in certain files.
2023-07-15 15:48:20 +08:00
arvinxx
250dda4499 🔧 chore: add project config 2023-05-21 15:42:20 +08:00