mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
- List child sessions in the activity query and credit each child's latest update to its root, so Recent includes roots whose subagents were active inside the window; children never become rows, and only roots of in-window children are fetched - Show and sort activity rows by that rolled-up time - Restrict activityWindowMinutes to the selectable options on write, and coerce a stored unknown value to the default on read so it cannot reset every preference
30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
import { describe, expect, it, beforeEach } from 'vitest'
|
|
import { Database } from 'bun:sqlite'
|
|
import { DEFAULT_ACTIVITY_WINDOW_MINUTES } from '@opencode-manager/shared/schemas'
|
|
import { SettingsService } from '../../src/services/settings'
|
|
import { allMigrations } from '../../src/db/migrations'
|
|
import { migrate } from '../../src/db/migration-runner'
|
|
|
|
describe('SettingsService', () => {
|
|
let db: Database
|
|
let settingsService: SettingsService
|
|
|
|
beforeEach(() => {
|
|
db = new Database(':memory:')
|
|
migrate(db, allMigrations)
|
|
settingsService = new SettingsService(db)
|
|
})
|
|
|
|
it('recovers from a stored activityWindowMinutes outside the allowed options without losing other preferences', () => {
|
|
db.prepare(
|
|
`INSERT INTO user_preferences (user_id, preferences, updated_at)
|
|
VALUES (?, ?, ?)`
|
|
).run('default', JSON.stringify({ activityWindowMinutes: 5, autoScroll: false }), Date.now())
|
|
|
|
const settings = settingsService.getSettings()
|
|
|
|
expect(settings.preferences.activityWindowMinutes).toBe(DEFAULT_ACTIVITY_WINDOW_MINUTES)
|
|
expect(settings.preferences.autoScroll).toBe(false)
|
|
})
|
|
})
|