8 Commits
Author SHA1 Message Date
linshen c8e06bdfb0 feat: 优化上下文模式架构,增强变量管理并修复核心功能
本次提交主要围绕上下文模式进行大规模重构与功能增强,并修复了关键的变量注入和模型初始化问题。

**核心重构与功能增强**
- **上下文模式架构优化**:
  - 将 `ContextWorkspace` 拆分为 `ContextSystemWorkspace` 和 `ContextUserWorkspace`,使组件职责更单一,消除内部条件逻辑。
  - 优化组件目录结构,按功能模块组织(如 `components/context-mode/`, `components/variable/`)。
  - 新增 `PromptPreviewPanel` 组件和 `usePromptPreview` composable,提供提示词实时预览功能。
  - 引入 `useContextManagement` composable,统一管理上下文状态和会话变量。
  - 为上下文模式添加 E2E 测试。
- **类型与构建**:
  - 扩展 `ContextMode` 相关类型定义,更新组件 Props 和 Events 类型。
  - 修复所有移动组件的相对导入路径和 `index.ts` 导出路径。

**主要问题修复**
- **修复上下文-用户模式会话变量注入问题**:
  - **核心问题**: `testPromptWithType` 中错误地展开了 `ComputedRef` 对象而非其值,导致 `variables` 对象混入 Vue 响应式系统内部属性,Mustache 模板引擎无法正确访问嵌套的会话变量值。
  - **修复内容**:
    - 优化 `App.vue` 变量合并逻辑,使用 `currentContextVariables.value` 获取实际值。
    - `useContextManagement.ts` 新增 `updateContextVariable` 函数,统一管理会话变量。
    - 简化 `TestAreaPanel.vue` 架构,移除 `userInputValues` 临时存储,改为单一数据源。
    - `ContextUserWorkspace.vue` 添加 `variable-change` 事件转发。
  - **影响范围**: 上下文-用户模式的变量替换功能、测试面板的会话变量输入、会话级变量管理和持久化。
  - **测试验证**: 会话变量正确注入到测试请求,全局变量和预定义变量正常工作,变量合并优先级正确(全局 < 会话 < 预定义),Mustache 模板引擎正确替换占位符。

- **修复模型选择初始化竞态条件**:
  - **问题描述**: 模型选择初始化时可能出现竞态条件,导致在初始化完成前触发不必要的保存操作或回退逻辑错误。
  - **修复内容**:
    - 引入 `isModelSelectionReady` 和 `isInitializing` 标志来精确跟踪初始化状态。
    - 防止在初始化阶段的 `watch` 触发不必要的保存操作。
    - 确保模型选择初始化完成后再执行回退逻辑。
    - 调整相关代码格式(单引号转换为双引号)。
2025-10-21 22:29:31 +08:00
linshen 98522a1306 refactor: 清理测试文件并移除不必要的测试代码
移除了 Web 包中的测试设置文件和 App 测试文件,同时在 LLM 服务中移除了 max_tokens 参数,并调整了 Prompt 服务的测试用例
2025-03-05 22:36:34 +08:00
linshen c1acf7d7b6 chore: Update project dependencies and development scripts
- Upgrade Vite, Vitest, and Vue-related dependencies to latest versions
- Modify package scripts for improved development workflow
- Update environment variable loading configuration
- Enhance test configuration and mocking strategies
- Simplify root and package-level scripts
- Improve cross-platform development support
2025-02-23 21:44:38 +08:00
linshen 4d88c3093d refactor: Consolidate and clean up test files across core and web packages
- Remove redundant integration and unit test files from web package
- Update import paths in remaining test files to use local source
- Remove console logs and unnecessary comments in test files
- Simplify test structure and remove duplicate test scenarios
- Add dotenv dependency to core package for environment variable support
2025-02-22 16:02:52 +08:00
linshen 58deb54a01 fix: Update Gemini API base URL and improve test suite
- Correct Gemini API base URL to official Google endpoint
- Enhance core package LLM tests with localStorage mock
- Update test cases for model management and service initialization
- Improve test coverage for App.vue with mocked components and services
2025-02-15 20:34:20 +08:00
linshen bff8f667a3 refactor: Simplify LLM service and remove deprecated request methods
- Remove manual request configuration and sending methods from LLMService
- Streamline model initialization logic with simplified provider handling
- Remove unnecessary type imports and unused request-related interfaces
- Update test suites to reflect new service architecture
- Add logging for connection testing
- Clean up unused code and improve type consistency
2025-02-15 00:06:58 +08:00
linshen cb720ea073 refactor: Migrate services to core package and update project dependencies
- Move services from web package to core package
- Update import statements across web package to use @prompt-optimizer/core
- Add LangChain and related dependencies to package.json
- Refactor and standardize service interfaces and implementations
- Update test suites to work with new package structure
- Improve module exports and type consistency
2025-02-14 22:24:51 +08:00
linshen 9be9f6b3ae refactor: Migrate project to monorepo structure with pnpm workspaces
- Convert project to monorepo with separate web and extension packages
- Update package.json scripts to support pnpm workspace commands
- Remove individual configuration files from root directory
- Adjust Vercel configuration for monorepo deployment
- Prepare for Chrome extension development
- Remove existing web application source files in preparation for restructuring
2025-02-13 22:51:28 +08:00