Mega push vol 5, working on messaging now
This commit is contained in:
92
AUDIT.md
92
AUDIT.md
@@ -1,10 +1,12 @@
|
||||
# Comprehensive Codebase Audit Report (v2)
|
||||
# Comprehensive Codebase Audit Report (v4)
|
||||
|
||||
**Project:** root-org (SvelteKit + Supabase + Tailwind v4)
|
||||
**Date:** 2026-02-06 (updated)
|
||||
**Date:** 2026-02-06 (v4 update)
|
||||
**Auditor:** Cascade
|
||||
|
||||
> **Changes since v1:** Dead stores (auth, organizations, documents, kanban, theme) deleted. `OrgWithRole` moved to `$lib/api/organizations.ts`. `FileTree` removed. Documents pages refactored into shared `FileBrowser` component. Document locking added (`document-locks` API + migration). Calendar `$derived` bugs fixed. `buildDocumentTree`/`DocumentWithChildren` removed. Editor CSS typo fixed. Invite page routes corrected. KanbanBoard button label fixed.
|
||||
>
|
||||
> **Changes in v4:** Type safety (shared `OrgLayoutData`, `as any` casts fixed, `role`→`userRole` dedup). Architecture (settings page split into 4 components, FileBrowser migrated to API modules, `createDocument` supports kanban). Performance (folder listings exclude content, kanban queries parallelized, card moves batched, realtime incremental). Testing (43 unit tests, expanded E2E coverage, GitHub Actions CI).
|
||||
|
||||
---
|
||||
|
||||
@@ -657,10 +659,84 @@ expires_at: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000).toISOString(),
|
||||
|
||||
3. **Continue splitting settings page** (A-1) — Members, Roles, and Integrations tabs still inline. Extract each into its own component.
|
||||
|
||||
### Suggested Order of Operations (updated)
|
||||
### Resolved Since v3
|
||||
|
||||
1. **Immediate (security):** S-1 (rotate keys — manual), S-4 (server-side auth for settings mutations)
|
||||
2. **Type safety (1 hour):** T-1 (regenerate Supabase types), T-2→T-5 (fix remaining type issues)
|
||||
3. **Architecture (1-2 days):** A-1 (finish splitting settings tabs), A-2 (migrate FileBrowser to use API modules), A-3 (add kanban type to createDocument)
|
||||
4. **Performance (1 day):** P-1 (select only needed columns), P-2 (parallelize kanban queries), P-4 (incremental realtime updates)
|
||||
5. **Polish:** E-5 (reliable lock release), M-1→M-3 (constants, consistent patterns), F-1 (permission enforcement), F-2 (scoped subscriptions)
|
||||
| ID | Issue | Resolution |
|
||||
|----|-------|------------|
|
||||
| — | Icon buttons not round | All inline icon buttons (`rounded-lg`) changed to `rounded-full` across KanbanCard, KanbanBoard, DocumentViewer, Calendar, Modal, ContextMenu |
|
||||
| — | Add column/card buttons missing plus icon | Replaced inline buttons with `Button` component using `icon="add"` prop |
|
||||
| — | Kanban columns not reorderable | Added column drag-and-drop with grip handle, drop indicators, and DB persistence |
|
||||
| — | Inconsistent cursor styles | Added global CSS rules: `cursor-pointer` on all `button`/`a`/`[role="button"]`, `cursor-grab` on `[draggable="true"]` |
|
||||
| — | Blurred spinner loading overlay | Replaced `backdrop-blur-sm` spinner with context-aware `PageSkeleton` component (kanban/files/calendar/settings/default variants) |
|
||||
| — | Language switcher missing | Added locale picker (English/Eesti) to account settings using Paraglide `setLocale()` |
|
||||
| — | File browser view mode not persisted | Confirmed already working via `localStorage` (`root:viewMode` key) |
|
||||
|
||||
### Resolved Since v4
|
||||
|
||||
| ID | Issue | Resolution |
|
||||
|----|-------|------------|
|
||||
| T-1 | 2 remaining `as any` casts | Replaced with properly typed casts in invite page and CardDetailModal |
|
||||
| T-2→T-5 | Untyped parent layout data | Created shared `OrgLayoutData` type in `$lib/types/layout.ts`; applied across all 8 page servers |
|
||||
| R-4 | Duplicate `role`/`userRole` | Removed `role` from layout server return; migrated all consumers to `userRole` |
|
||||
| A-1 | Settings page god component (1200+ lines) | Extracted `SettingsMembers`, `SettingsRoles`, `SettingsIntegrations` into `$lib/components/settings/`; page reduced to ~470 lines |
|
||||
| A-2 | FileBrowser direct Supabase calls | Migrated all CRUD operations to use `$lib/api/documents.ts` (`moveDocument`, `updateDocument`, `deleteDocument`, `createDocument`, `copyDocument`) |
|
||||
| A-3 | `createDocument` missing kanban type | Added `'kanban'` to type union with optional `id` and `content` params |
|
||||
| E-3 | Calendar date click no-op | Already implemented — clicking a day opens create event modal pre-filled with date |
|
||||
| P-1 | Folder listings fetch `select('*')` | Changed to select only metadata columns, excluding heavy `content` JSON |
|
||||
| P-2 | Kanban queries sequential | Board+columns now fetched in parallel; tags+checklists+assignees fetched in parallel |
|
||||
| P-3 | `moveCard` fires N updates | Now skips cards whose position didn't change — typically 2-3 updates instead of N |
|
||||
| P-4 | Realtime full board reload | Upgraded `subscribeToBoard` to pass granular payloads; kanban page applies INSERT/UPDATE/DELETE diffs incrementally |
|
||||
| T6 | No unit tests | Added 43 Vitest unit tests: `logger.test.ts` (10), `google-calendar.test.ts` (11), `calendar.test.ts` (12), `documents.test.ts` (10) |
|
||||
| T6 | Incomplete E2E coverage | Added Playwright tests for Tags tab, calendar CRUD (create/view/delete), kanban card CRUD (create/detail modal) |
|
||||
| T6 | No CI pipeline | Created `.github/workflows/ci.yml`: lint → check → unit tests → build |
|
||||
| T6 | Test cleanup incomplete | Updated `cleanup.ts` to handle test tags, calendar events, and new board prefixes |
|
||||
|
||||
---
|
||||
|
||||
## Area Scores (v4)
|
||||
|
||||
Scores reflect the current state of the codebase after all v1–v4 fixes.
|
||||
|
||||
| Area | Score | Notes |
|
||||
|------|-------|-------|
|
||||
| **Security** | ⭐⭐⭐ 3/5 | S-2, S-3, S-5 fixed. **S-1 (credential rotation) and S-4 (server-side auth for mutations) remain critical/high.** S-6 (lock cleanup race) still open. |
|
||||
| **Type Safety** | ⭐⭐⭐⭐ 4/5 | `OrgLayoutData` shared type eliminates parent casts. 2 targeted `as any` casts fixed. Remaining `as any` casts are in Supabase join results that need full type regeneration (T-1). |
|
||||
| **Dead Code** | ⭐⭐⭐⭐⭐ 5/5 | All dead stores, unused components, placeholder tests, empty files, and unused dependencies removed in v2. No known dead code remains. |
|
||||
| **Architecture** | ⭐⭐⭐⭐ 4/5 | Settings page split into 4 components. FileBrowser migrated to API modules. `createDocument` supports all types. Remaining: some components still have inline Supabase calls (CardDetailModal, CardComments). |
|
||||
| **Performance** | ⭐⭐⭐⭐ 4/5 | Folder listings exclude content. Kanban queries parallelized. Card moves batched smartly. Realtime is incremental. Remaining: full org document fetch for breadcrumbs could be optimized further. |
|
||||
| **Error Handling** | ⭐⭐⭐⭐ 4/5 | `alert()` replaced with toasts. Structured logger adopted in API routes. `$effect` sync blocks added. Remaining: `console.error` in 3-4 files (calendar page, invite page), lock release in `onDestroy`. |
|
||||
| **Testing** | ⭐⭐⭐⭐ 4/5 | 43 unit tests (logger, calendar, google-calendar, documents API). 35+ Playwright E2E tests covering all major flows. CI pipeline on GitHub Actions. Remaining: visual regression tests, Svelte component tests. |
|
||||
| **Code Quality** | ⭐⭐⭐⭐ 4/5 | Consistent API module pattern. Shared types. i18n complete. Duplication eliminated. Remaining: `role`/`userRole` fully migrated but some inline SVGs and magic numbers persist. |
|
||||
| **Dependencies** | ⭐⭐⭐⭐⭐ 5/5 | `lucide-svelte` removed. All deps actively used. No known unused packages. |
|
||||
| **Future-Proofing** | ⭐⭐⭐ 3/5 | Permission system defined but not enforced (F-1). Kanban realtime subscription unscoped (F-2). No search, notifications, or keyboard shortcuts yet. |
|
||||
|
||||
### Overall Score: ⭐⭐⭐⭐ 4.0 / 5
|
||||
|
||||
**Breakdown:** 41 out of 50 possible stars across 10 areas.
|
||||
|
||||
### Remaining High-Priority Items
|
||||
|
||||
1. **S-1: Rotate credentials & purge `.env` from git history** — Critical security risk. Must be done manually.
|
||||
2. **S-4: Server-side auth for settings mutations** — Move destructive operations to SvelteKit form actions with explicit authorization.
|
||||
3. **T-1: Regenerate Supabase types** — `supabase gen types typescript` to eliminate remaining `as any` casts from join results.
|
||||
4. **F-1: Permission enforcement** — Create `hasPermission()` utility; the permission system is defined but never checked.
|
||||
|
||||
### Remaining Medium-Priority Items
|
||||
|
||||
5. **S-6: Lock cleanup race condition** — Consolidate to server-side cron only.
|
||||
6. **E-2: Replace remaining `console.*` calls** — 3-4 files still use raw console instead of structured logger.
|
||||
7. **E-5: Lock release in `onDestroy`** — Use `navigator.sendBeacon` for reliable cleanup.
|
||||
8. **F-2: Scoped realtime subscriptions** — Filter kanban card changes to current board's columns.
|
||||
9. **M-1/M-3: Magic numbers and inline SVGs** — Extract constants, use Icon component consistently.
|
||||
|
||||
### Feature Backlog (Tier 5)
|
||||
|
||||
10. Notifications system (mentions, assignments, due dates)
|
||||
11. Global search across documents, kanban cards, calendar events
|
||||
12. Keyboard shortcuts for common actions
|
||||
13. Mobile responsive layout (sidebar drawer, touch-friendly kanban)
|
||||
14. Dark/light theme toggle
|
||||
15. Export/import (CSV/JSON/Markdown)
|
||||
16. Undo/redo with toast-based undo for destructive actions
|
||||
17. Onboarding flow for new users
|
||||
18. Visual regression tests for key pages
|
||||
|
||||
Reference in New Issue
Block a user