# Work Activity Daily Report Implementation Plan

> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.

**Goal:** Add a lightweight work-activity layer and use it to build a more complete personal daily report.

**Architecture:** Add `WorkActivity` types, a Zustand store persisted through the existing `app_data` document API, and a pure `workspace-daily-report` aggregator that combines activities, legacy worklogs, and current workspace items. Store business actions create activity records at existing operation entry points.

**Tech Stack:** Next.js app router, Zustand stores, TypeScript pure functions, Node test runner through the existing web test command.

---

### Task 1: Activity Types And Daily Report Aggregation

**Files:**
- Create: `apps/web/lib/work-activity.ts`
- Modify: `apps/web/lib/workspace-daily-report.ts`
- Modify: `apps/web/lib/workspace-daily-report.test.ts`

- [ ] **Step 1: Write failing tests**

Add tests that call `getWorkspaceDailyReport` with `activities`, `worklogs`, `workItems`, `userId`, and `date`. Cover activity grouping, user/date filtering, old worklog compatibility, and needs-progress detection for an in-progress item without today's note.

- [ ] **Step 2: Run focused tests and verify failure**

Run: `pnpm --filter=web test -- workspace-daily-report`

Expected: FAIL because `activities` and `needsProgressItems` are not implemented.

- [ ] **Step 3: Implement minimal types and aggregation**

Create `WorkActivity` and update `WorkspaceDailyReport` with `groups`, `legacyWorklogs`, and `needsProgressItems`. Keep `items` as a compatibility alias for old worklog-derived rows until the UI is updated.

- [ ] **Step 4: Run focused tests and verify pass**

Run: `pnpm --filter=web test -- workspace-daily-report`

Expected: PASS.

### Task 2: Activity Persistence Store

**Files:**
- Create: `apps/web/stores/useWorkActivityStore.ts`
- Modify: `apps/web/lib/server-data.ts`
- Modify: `apps/server/src/modules/data/data-keys.ts`

- [ ] **Step 1: Write failing persistence/type test**

Extend an existing data-key or server-data test so `work-activities` is accepted.

- [ ] **Step 2: Run focused tests and verify failure**

Run: `pnpm --filter=web test -- workspace-daily-report`

Expected: FAIL or type-check failure until the new key is registered.

- [ ] **Step 3: Implement store and data key**

Add `useWorkActivityStore` with `fetchActivities`, `addActivity`, and `addProgressNote`, persisted through `saveServerData('work-activities', items)`.

- [ ] **Step 4: Run focused tests**

Run: `pnpm --filter=web test -- workspace-daily-report`

Expected: PASS.

### Task 3: Emit Activities From Business Stores

**Files:**
- Modify: `apps/web/stores/useVersionPlanStore.ts`
- Modify: `apps/web/stores/useDevTaskStore.ts`
- Modify: `apps/web/stores/useBugStore.ts`
- Modify if present: `apps/web/stores/useTestCaseStore.ts`

- [ ] **Step 1: Add tests for action-to-activity mapping where pure helpers exist**

Cover dev-task start/submitted, plan completion, and bug fixed/closed through helper-level tests or store-light tests if existing patterns allow.

- [ ] **Step 2: Run tests and verify failure**

Run: `pnpm --filter=web test -- workspace-daily-report dev-task-workflow bug-workflow version-plan-workflow`

Expected: FAIL for new activity mapping expectations.

- [ ] **Step 3: Emit activities in store methods**

Call `useWorkActivityStore.getState().addActivity(...)` after successful create, status transition, completion, blocked change, transfer, and progress-note actions.

- [ ] **Step 4: Run tests**

Run: `pnpm --filter=web test -- workspace-daily-report dev-task-workflow bug-workflow version-plan-workflow`

Expected: PASS.

### Task 4: Workspace And Drawer UI

**Files:**
- Modify: `apps/web/app/workspace/page.tsx`
- Modify: `apps/web/components/workspace/DailyReportPanel.tsx`
- Modify: `apps/web/components/dev-task/DevTaskDetailDrawer.tsx`

- [ ] **Step 1: Write/update UI-adjacent tests if existing component tests cover the panel**

Assert grouped labels render from the daily report model when component tests are available.

- [ ] **Step 2: Wire the workspace page**

Fetch `work-activities`, pass them into `getWorkspaceDailyReport`, and render grouped sections.

- [ ] **Step 3: Add progress-note controls in dev-task drawer**

Expose a compact form for ongoing work that records note, blocker/help/risk metadata through `addProgressNote`.

- [ ] **Step 4: Run web tests and type-check**

Run: `pnpm --filter=web test`

Run: `pnpm --filter=web type-check`

Expected: PASS.

### Task 5: Documentation And Final Verification

**Files:**
- Modify: `docs/architecture.md`
- Modify: `docs/decisions.md`
- Modify: `docs/roadmap.md`

- [ ] **Step 1: Document the new activity layer**

Add a short architecture note and decision explaining why this is an activity engine instead of a generic rules engine.

- [ ] **Step 2: Run full verification**

Run: `pnpm --filter=web test`

Run: `pnpm --filter=web type-check`

Run: `pnpm --filter=server test`

Run: `git diff --check`

Expected: all commands exit 0.
