Skip to content

feat(frontend): add user activity timeline with chronological history and user isolation - #177

Merged
Abd-Standard merged 1 commit into
Core-Foundry:mainfrom
king-aj-the-first:user-activity-timeline
Aug 30, 2026
Merged

feat(frontend): add user activity timeline with chronological history and user isolation#177
Abd-Standard merged 1 commit into
Core-Foundry:mainfrom
king-aj-the-first:user-activity-timeline

Conversation

@king-aj-the-first

@king-aj-the-first king-aj-the-first commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

closes #168

Detailed PR Description

Summary

This pull request implements the User Activity Timeline feature in the frontend application. It provides users with a central, chronological activity stream tracking their actions
across the platform—such as saving grants, submitting applications, updating profiles, and submitting bounty deliverables.
All activity data is strictly isolated per user (ensuring users only see events tied to their wallet/account), formatted with relative timestamps, categorized with tailored icon
styling, and integrated directly into the User Overview dashboard.


Key Features & Architecture

1. Activity Domain Types (frontend/src/types/activity.ts)

  • Defined standard ActivityType union supporting key platform events:
    • grant_saved / grant_unsaved
    • application_submitted / application_status_updated
    • account_updated / profile_updated
    • bounty_created / submission_created / submission_reviewed
    • comment_posted
  • Created ActivityRecord structure including typed metadata fields (e.g. grantId, grantName, taskId, status, updatedFields).
  • Defined inputs and query parameter interfaces (CreateActivityInput, ListActivitiesQuery).

2. In-Memory Activity Store (frontend/src/lib/activity-store.ts)

  • Strict User Isolation: Queries filter exclusively by userId, preventing cross-user data leakage.
  • Chronological Sorting: Activities are automatically sorted in reverse chronological order (timestamp newest first).
  • Filtering & Pagination: Supports filtering by type as well as limit and offset pagination.
  • Initial Seed Helper: Seeds mock entries on initial fetch if the store is empty for instant visual feedback and demo states.

3. Activity API Endpoints (frontend/src/app/api/activities/route.ts)

  • GET /api/activities?userId=<address>&type=<type>&limit=<n>&offset=<n>:
    • Validates userId presence (returns 400 if missing).
    • Integrates rate-limiting (checkRateLimit) and applies Cache-Control: no-store headers.
    • Returns { ok: true, activities: [...], total: n }.
  • POST /api/activities:
    • Validates JSON payload, required fields (userId, type, title), and records the activity.
    • Returns 201 Created with the newly created ActivityRecord.

4. Custom Hook & UI Component

  • useActivityTimeline Hook (frontend/src/hooks/useActivityTimeline.ts):
    • Handles client-side fetching, polling intervals, loading/error states, and optimistic creation via addActivity().
  • UserActivityTimeline Component (frontend/src/components/UserActivityTimeline.tsx):
    • Interactive activity feed with category filtering (All, Saved Grants, Applications, Account Updates, Bounty Submissions).
    • Relative time formatting (Just now, Xm ago, Xh ago, Xd ago).
    • Distinct badge and icon themes per activity type (using lucide-react and Tailwind CSS).
    • Smooth entrance and layout animations using framer-motion.
  • Overview Page Integration (frontend/src/app/(dashboard)/user/overview/page.tsx):
    • Wired wallet detection via getPublicKey() from stellar-wallets-kit to automatically populate the timeline for the active user.

Acceptance Criteria Verification

  • Chronological Display: Activities are indexed and rendered in reverse chronological order (newest activities first).
  • Relevant Activity Types Supported: Explicit support for saved grants, submitted grant/bounty applications, account profile updates, and review statuses.
  • Strict User Isolation: Backend store queries and API routes strictly scope returned records by userId.
  • CI Compatibility: All modifications are strictly contained within frontend/**, ensuring frontend-ci.yml runs properly without triggering unmodified smart contract
    workflows.

Test Plan & Coverage

Unit Tests

  • frontend/src/lib/activity-store.test.ts:
    • Verified chronological sorting with multiple timestamps.
    • Verified strict user data isolation (User A never sees User B's activities).
    • Verified activity category filtering.
    • Verified limit/offset pagination.
    • Verified seeder initialization.
  • frontend/src/lib/activities-api.test.ts:
    • Verified GET error handling when userId is missing.
    • Verified GET response structure and status codes.
    • Verified POST payload validation and successful activity creation.
  • frontend/src/test/regression.test.ts:
    • Added regression test suite declarations for the activity timeline module and endpoints.

@Abd-Standard
Abd-Standard merged commit bd91c02 into Core-Foundry:main Aug 30, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a User Activity Timeline

2 participants