Common Change Recipes
These are the safest implementation paths for common Compass changes.
Add A Backend Endpoint
- Define or extend a shared schema/type in
packages/core/src/typesif the contract is shared. - Add the route to the relevant
packages/backend/src/*/*.routes.config.ts. - Keep the controller thin in
controllers/*.controller.ts. - Put business logic in
services/*.service.ts. - Add controller or service tests.
- If the endpoint affects realtime UI, decide whether an SSE event is required.
Add A New Event Field
- Update the event schema/types in
packages/core/src/types/event.types.ts. - Update any mapper or utility code in
packages/core/src/mappersorpackages/core/src/util/event. - Update backend persistence or parser logic if the field is stored or transformed.
- Update web editors, selectors, and rendering.
- Add tests in
core,web, andbackendas needed.
Rule: never treat event shape as web-only unless the field is strictly presentational.
Change Recurring Event Behavior
- Read
packages/core/src/types/event.types.ts. - Read
docs/features/recurring-events-handling.md. - Read
packages/backend/src/event/classes/compass.event.generator.ts. - Read
packages/backend/src/event/classes/compass.event.parser.ts. - Read
packages/backend/src/event/classes/compass.event.executor.ts. - Read
packages/backend/src/sync/services/event-propagation/compass-to-google/compass-to-google.event-propagation.ts. - Update the planner, executor, or scope-expansion path that actually owns the behavior.
- Add focused tests for the exact recurrence transition you changed.
Do not edit recurring behavior from one layer only.
Common Mistakes
- Changing only the executor without updating the parser plan builders — the executor reads the
stepsarray that the parser produces. If the plan builder for a given transition key is wrong, the executor will silently do the wrong thing even if the executor logic looks correct. Always trace fromPLAN_BUILDERSincompass.event.parser.tsto confirmstepsandgoogleEffectmatch the intended behavior. - Missing a database migration for existing recurring events — existing user data will not be retroactively updated by code changes alone. If you modify how recurring series are stored or processed, add a migration to
packages/scripts/src/migrations. - Testing only the happy-path transition — someday and cancellation transitions follow different planner paths. A test that only covers the primary create/update flow can pass while someday transitions break silently.
Triage A Recurrence Sync Regression
- Reproduce with one event and one expected transition outcome.
- Capture Compass-to-Google event propagation logs for the transition key:
Handle Compass event(<id>): <transitionKey>
- Find the key in
PLAN_BUILDERSinpackages/backend/src/event/classes/compass.event.parser.ts. - Confirm planned
stepsandgoogleEffectmatch expected behavior. - Confirm executor step mapping in
packages/backend/src/event/classes/compass.event.executor.ts. - Run focused tests:
bun run test:backend --runTestsByPath packages/backend/src/event/classes/compass.event.parser.test.ts packages/backend/src/event/classes/compass.event.executor.test.ts packages/backend/src/sync/services/event-propagation/__tests__/compass-to-google.event-propagation.test.ts --runInBand
Add An SSE Event
- Add the event name to
packages/core/src/constants/sse.constants.ts. - Update shared payload types in
packages/core/src/types/sse.types.tsif needed. - Emit from
packages/backend/src/servers/sse/sse.server.ts(or call site that usespublish). - Consume it in a web hook under
packages/web/src/sse/hooks(listeners onEventSource). - Add tests on both emitter and listener sides.
Add Or Change Local Storage Data
- Update
packages/web/src/common/storage/adapter/storage.adapter.tsif the public adapter contract changes. - Update
packages/web/src/common/storage/adapter/indexeddb.adapter.ts. - Add a migration if existing user data could become invalid.
- Add adapter and migration tests.
Common Mistakes
- Adding new fields without a migration — existing users already have data in IndexedDB without the new field. If your code expects the field to be present, it will fail silently or throw on their existing records. Always add a migration in
packages/web/src/common/storage/migrations/migrations.tsand test the migration path, not just the new code path. - Testing only the new code path — write a test that starts with pre-migration data (the old shape) and confirms the migration transforms it correctly. A test that only creates fresh data will not catch migration regressions.
Change Repository Selection Or Offline Behavior
- Start in
packages/web/src/common/repositories/event/event.repository.util.ts. - Verify auth-state implications in
packages/web/src/auth/session/SessionProvider.tsxand auth-state helpers. - Test both never-authenticated and previously-authenticated behavior.
Change Day View Task Behavior
- Start in
packages/web/src/views/Day/hooks/tasks. - Inspect supporting UI in
packages/web/src/views/Day/components/TaskList. - If persistence changed, update storage adapter code and tests.
Change A Shared Hotkey Dialog (Day + Week)
Use this for overlays mounted in both CalendarView and DayViewContent (for example Dedication).
- Update the shared dialog component in
packages/web/src/views/Calendar/components/Dedication/Dedication.tsx. - Confirm both mount points still render it:
packages/web/src/views/Calendar/Calendar.tsxpackages/web/src/views/Day/view/DayViewContent.tsx
- Keep keyboard behavior aligned:
- toggle hotkey (
ctrl+shift+0) - close hotkey (
escapewhen open)
- toggle hotkey (
- Preserve the transition lifecycle:
- open with
showModal()then set visible state - close by state first, then
dialog.close()inonTransitionEnd - keep
onCancel(e.preventDefault())so Escape uses the animated close path
- open with
Common pitfall: calling dialog.close() directly in an event handler will skip the CSS exit transition and can produce abrupt UI changes.
Add A Migration Or Seeder
For database migrations:
- inspect
packages/scripts/src/commands/migrate.ts - add migration under
packages/scripts/src/migrations - run the relevant scripts tests
For web local-data migrations:
- inspect
packages/web/src/common/storage/migrations/migrations.ts - add the migration to the correct registry
- add migration tests
Change Environment Handling
- Update the relevant env schema:
- backend:
packages/backend/src/common/constants/env.constants.ts - web:
packages/web/src/common/constants/env.constants.ts
- backend:
- Confirm startup behavior still works in the intended dev mode.
- Document any new required variables.
Add A New CLI Command
- Register the command in
packages/scripts/src/cli.ts. - Implement behavior in
packages/scripts/src/commands. - Reuse shared CLI utilities from
packages/scripts/src/common. - Add integration tests in
packages/scripts/src/__tests__.