Files
opencode-manager/backend/vitest.config.ts
T
Chris Scott 549e0ac7b2 feat: add model state persistence and improve model selection sync (#209)
* feat: add persistent model state storage with database backend

- Create opencode_model_state table for storing user model preferences
- Implement database-backed model state management (recent, favorite, variant)
- Add atomic JSON file utilities with file locking for concurrent safety
- Migrate providers routes from file-based to database storage
- Add backfill migration to preserve existing model.json data
- Include comprehensive tests for model-state and atomic-json modules
- Refactor useSessionAgent hook to simplify agent/model resolution logic
- Update getFileApiUrl to use consistent query parameter approach

* fix: include workspace dependencies in Docker image

* fix: overlay workspace node_modules after source to prevent layer overwrite

* fix: ensure model state table exists for existing databases

* feat: add model state persistence and improve model selection sync

- Add setActiveModel to modelStore and useModelSelection for direct model updates
- Sync session agent model/variant to store when messages load
- Include model, agent, and variant in optimistic user messages
- Fix useSessionAgent to check isFetching during message loading
- Update env.ts to use getter for BASE_PATH for dynamic resolution
- Fix test environment variable from OPENCODE_WORKSPACE_PATH to WORKSPACE_PATH
2026-04-29 21:44:47 -04:00

28 lines
651 B
TypeScript

import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
globals: true,
environment: 'node',
setupFiles: ['./test/setup.ts'],
include: ['test/**/*.{test,spec}.{ts,tsx}', 'src/**/*.test.ts'],
exclude: ['**/node_modules/**', '**/dist/**'],
coverage: {
provider: 'v8',
reporter: ['text', 'html'],
},
env: {
NODE_ENV: 'test',
PORT: '3001',
DATABASE_PATH: ':memory:',
AUTH_SECRET: 'test-secret-for-encryption',
WORKSPACE_PATH: '/tmp/test-workspace',
},
},
resolve: {
alias: {
'bun:sqlite': './test/mocks/bun-sqlite.ts',
},
},
})