Persist inferred sessions, simplify feed, add session editing#856
Persist inferred sessions, simplify feed, add session editing#856marcodejongh merged 15 commits intomainfrom
Conversation
Replace individual ascent cards with session-grouped feed. Sessions with explicit sessionId (party mode) group naturally including multiple users. Aurora-synced ticks get inferred per-user sessions based on a 4-hour gap heuristic via a background job and read-time CTE grouping. Key changes: - New inferred_sessions table + inferredSessionId column on ticks - Session feed resolver with CTE-based grouping (party/inferred/ungrouped) - Background job for bulk tick session assignment - Session detail page at /session/[id] with per-tick voting - Reusable grade distribution chart component - Session feed card with stats, charts, and social buttons - Fix dev-db-up.sh for robust pg_hba.conf, password, and migration sync - 74 tests (34 backend + 40 frontend) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…on support - Fix session detail 404 for ungrouped sessions (ug: prefix IDs) by re-running LAG window query in resolver - Separate avatar/name click (profile) from card body click (session detail) - Switch to like-only voting on feed cards and session detail page - Redesign grade distribution chart: stacked bars matching profile page, dense layout, ascending grade order - Card design polish: pill-style stats, grade-colored chips, hover shadows, comment icon, simplified board types - Add userId to SessionDetailTick for per-user display in multi-user sessions - Generate session names from day + board type when no name is set - Show session title prominently right-aligned in feed card header - Update tests for new behavior Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Show flash/send/attempt proportions as a compact doughnut alongside the grade distribution bar on desktop (≥768px). Hidden on mobile to preserve the existing layout. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add name/description columns to inferred_sessions table - Create session_member_overrides table for tracking manual user additions - Add previousInferredSessionId to boardsesh_ticks for non-destructive undo - Replace 48h-window builder with batched full-history builder - Add backfill migration (0060) that assigns inferred sessions to all ungrouped ticks using the same UUIDv5 deterministic IDs - Simplify feed resolver: remove ~300 lines of ungrouped session handling - Remove ug: special-case from entity validation - Add GraphQL mutations: updateInferredSession, addUserToSession, removeUserFromSession with auth checks and stats recalculation - Add session editing UI: rename sessions, add/remove participants - Add user search dialog for finding climbers to add to sessions - Trigger inferred session builder after Aurora sync - Add standalone backfill script (npm run backfill-sessions) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Claude Review✅ Ready to merge - Minor issues noted below, but nothing blocking. The PR is well-structured with good test coverage for the core session builder logic. Documentation is added appropriately. Issues
Documentation Check
|
… participants - Fix race condition in assignInferredSession: use ON CONFLICT DO NOTHING + recalculateSessionStats instead of incrementing counters - Fix orphaned ticks on removeUserFromSession: reassign via assignInferredSession instead of setting to NULL - Deduplicate fetchSessionDetail with React.cache() in page.tsx - Guard against empty participants array in session-feed-card href Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Migration 0057 creates board_climbs_setter_username_idx on (setter_username), then 0058 tries to create the same-named index on (board_type, setter_username) without IF NOT EXISTS. Drop first to avoid conflict in CI. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Claude Review✅ Ready to merge - Minor issues noted below, but nothing blocking. The architecture is solid, migrations are well-structured, and the core logic is correct. Issues
|
Add vi.mock for useSession, useWsAuthToken, useSnackbar, createGraphQLHttpClient, activity-feed operations, theme-config, and UserSearchDialog needed after session editing changes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Claude Review✅ Ready to merge - Minor issues noted below, but nothing blocking. Issues
|
- Wrap assignInferredSession in db.transaction() and use recalculateSessionStats for both join/create paths - Replace hardcoded CSS vars with themeTokens in session detail - Add validation schema tests for session mutations - Add inferred sessions documentation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add ownerUserId to SessionFeedItem and SessionDetail GraphQL types, sourced from inferred_sessions.user_id / board_sessions.created_by_user_id instead of assuming participants[0] is the owner - Add 10 edge case tests for session mutation resolvers: auth checks, session not found, non-participant rejection, no overlapping ticks, cannot remove owner - Update social-features-plan.md to reference inferred sessions docs - Update inferred-sessions.md to document ownerUserId field Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Claude Review✅ Ready to merge - Well-structured implementation with comprehensive tests. Minor issues noted below. Issues
DocumentationThe new |
…n tests - Make recalculateSessionStats accept optional db/tx parameter so it runs within the calling transaction in assignInferredSession for consistent reads - Export pure functions from web-side inferred session builder and add 15 tests covering grouping, ID generation, stats counting, and sort order - Expand mutation resolver tests from 10 to 14: add override member auth, user not found, non-participant removal rejection, and setupSelectChain helper Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Claude Review✅ Ready to merge - Well-structured PR with good test coverage. Minor issues noted below, nothing blocking. IssuesPerformance
Potential Race Condition
Type Safety
Suggestions (non-blocking)
DocumentationAppropriate new documentation added in |
…solvers - Batch feed enrichment: replace per-session queries with 3 batched queries using IN(...) clauses, reducing N+1 to constant query count - Wrap removeUserFromSession tick restoration in db.transaction() for atomicity - Add Zod schema validation for recalculateSessionStats raw SQL results - Fix web builder test mock for @/app/lib/db/schema Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Claude Review✅ Ready to merge - Minor issues noted below, but nothing blocking. The feature is well-designed with good test coverage and documentation. Issues
Test CoverageThe tests are good overall - they cover:
Missing:
DocumentationGood - new |
…ead code - Refactor assignInferredSession to accept optional conn parameter so it participates in outer transactions instead of creating nested ones - Wrap addUserToSession tick reassignment, override insert, and stats recalculation in db.transaction() for atomicity - Remove unused fetchGradeDistribution and fetchSessionMeta (replaced by batch versions) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Claude Review✅ Ready to merge - Well-structured PR with comprehensive documentation and test coverage. Minor issues noted below, but nothing blocking. Issues
DocumentationDocumentation is properly updated:
Test CoverageGood test coverage added across multiple files:
Tests use mocks which is appropriate for unit testing. The test file comments correctly note that integration tests with a real database can be run by setting DATABASE_URL. |
- Await status update in joinSession so inactive→active transition is visible to callers immediately (fixes session-persistence test) - Remove unused sessionTypes parameter from fetchParticipantsBatch and fetchGradeDistributionBatch (only used by fetchSessionMetaBatch) - Add recovery context comment and userId to assignInferredSession error log Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Claude Review✅ Ready to merge - Well-structured PR with good test coverage. Minor issues noted below, but nothing blocking. Issues FoundMemory Leak - UserSearchDialog (
useEffect(() => {
return () => {
if (debounceRef.current) clearTimeout(debounceRef.current);
};
}, []);Web-side session builder lacks batching (
Minor Observations (Non-blocking)
Documentation
|
SessionFeedCard used data-testid="session-feed-card" but e2e tests expect data-testid="activity-feed-item" (matching other feed item types). Updated component and unit tests to use consistent testid. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Claude Review✅ Ready to merge - Minor issues noted below, but nothing blocking. The implementation is well-structured with good test coverage and proper documentation. IssuesRace condition in session stats calculation (medium)
UserSearchDialog debounce timer not cleaned up on unmount
Unrelated change in room-manager.ts
|
- Refactor UserSearchDialog debounce to useEffect with cleanup to prevent timer leak on unmount - Add batchSize parameter (default 5000) to web-side session builder to process large tick counts in batches - Replace additive ON CONFLICT stats accumulation with recalculateSessionStats in both backend and web builders to prevent double-counting when concurrent builders race on the same user's ticks Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Claude Review✅ Ready to merge - Well-structured PR with comprehensive test coverage and proper documentation. Minor issues noted below. Issues
Documentation
Test Coverage
|
Summary
session_id(party) orinferred_session_id(inferred). A SQL migration (0060) backfills all existing ungrouped ticks using the same UUIDv5 deterministic IDs as the TypeScript builder, so there's zero gap on deploy.ug:synthetic IDs,resolveUngroupedSession()).previousInferredSessionId— fully non-destructive.Changes
Schema (
packages/db)inferred_sessions: addname,descriptioncolumnsboardsesh_ticks: addprevious_inferred_session_idcolumn (for undo)session_member_overridestable (tracks manual user additions)Backend (
packages/backend)session-feed.ts— removed ungrouped CTEs,UngroupedFilter,resolveUngroupedSession()session-mutations.ts—updateInferredSession,addUserToSession,removeUserFromSessionmutationsug:handling from entity validationbackfill-sessionsnpm scriptShared Schema (
packages/shared-schema)Frontend (
packages/web)Test plan
/session/fx-party-session-001— should load party session correctlySELECT COUNT(*) FROM boardsesh_ticks WHERE session_id IS NULL AND inferred_session_id IS NULLreturns 0 after migrationnpm run typecheck— all packages pass🤖 Generated with Claude Code