feat(perf): implement performance optimizations for session handling
- Introduced a new configuration file `config.yaml` for specifying project context and artifact rules. - Added `.openspec.yaml` files for tracking changes related to performance improvements. - Created design documents outlining the context, goals, decisions, and migration plans for optimizing session performance. - Proposed changes include batching database queries, debouncing event refreshes, purging old events, and implementing loading states for better user experience. - Added tasks and specifications to ensure proper implementation and validation of the new features. These enhancements aim to improve the scalability and responsiveness of the application during collaborative sessions.
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: Cached session list queries
|
||||
Frequently-called session list queries SHALL be cached using Next.js `unstable_cache` with user-scoped tags, avoiding redundant DB reads on repeated navigations.
|
||||
|
||||
#### Scenario: Session list served from cache on repeated navigation
|
||||
- **WHEN** a user navigates to the sessions page multiple times within the cache window
|
||||
- **THEN** the session list data SHALL be served from cache on subsequent requests
|
||||
- **THEN** no additional Prisma query SHALL be executed for cached data
|
||||
|
||||
#### Scenario: Cache invalidated after mutation
|
||||
- **WHEN** a Server Action creates, updates, or deletes a session
|
||||
- **THEN** the corresponding cache tag SHALL be invalidated via `revalidateTag`
|
||||
- **THEN** the next request SHALL fetch fresh data from the DB
|
||||
|
||||
### Requirement: Weather history bounded query
|
||||
The weather service SHALL limit historical data loading to a configurable maximum number of entries (default: 90), ordered by most recent first.
|
||||
|
||||
#### Scenario: Weather history respects limit
|
||||
- **WHEN** the weather service fetches historical entries
|
||||
- **THEN** at most `WEATHER_HISTORY_LIMIT` entries SHALL be returned
|
||||
- **THEN** entries SHALL be ordered by `createdAt` DESC (most recent first)
|
||||
|
||||
### Requirement: Minimal field selection on list queries
|
||||
Service functions returning lists for display purposes SHALL use Prisma `select` with only the fields required for the list UI, not full `include` of related models.
|
||||
|
||||
#### Scenario: Sessions list query returns only display fields
|
||||
- **WHEN** the sessions list service function is called
|
||||
- **THEN** the returned objects SHALL contain only fields needed for card display (id, title, createdAt, item count, share status)
|
||||
- **THEN** full related model objects (items array, events array) SHALL NOT be included
|
||||
Reference in New Issue
Block a user