Commit Graph

141 Commits

Author SHA1 Message Date
Michael Chihlas
84fa554a7a chore: add workspace file, update gitignore, and sync package deps
Add monaco-editor to frontend deps, gitignore temp files (test_results.txt,
stats.html, .agents/), and add VS Code workspace config.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 18:57:41 -05:00
Michael Chihlas
0e0e3572f4 refactor: replace barrel imports with direct module imports for tree-shaking
Replace all `from '@/api'` barrel imports with direct imports from
specific module files (e.g. `from '@/api/trees'`) across 20 files.
This enables better tree-shaking so each page only bundles the API
modules it actually uses.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 18:52:14 -05:00
Michael Chihlas
d155c83ef0 fix: split category fetch, safe localStorage, aria-labels on icon buttons
- TreeLibraryPage: split categories into a mount-only fetch so filter
  changes only re-fetch trees (not categories every time)
- Add safeGetItem/safeSetItem/safeRemoveItem helpers in utils.ts to
  prevent crashes in private browsing or when storage is unavailable
- Replace raw localStorage calls in ScratchpadSidebar, TreeNavigationPage,
  TreeEditorPage, and treeEditorStore with safe wrappers
- Add aria-label to 20 icon-only buttons across 8 component files
  for screen reader accessibility

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 18:41:46 -05:00
Michael Chihlas
0c9fbdc90b fix: replace N+1 API calls in MyTreesPage with 2 parallel requests
The page was making 1 API call per tree to fetch session stats, but the
backend sessions endpoint doesn't support tree_id filtering — so every
call returned identical data. Now fetches trees and sessions in parallel
(2 calls total), builds a lastUsed map client-side, and uses the existing
usage_count field from the tree list response for session counts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 17:53:42 -05:00
Michael Chihlas
e5e5922097 refactor: clean up dead files, restructure nav, align QuickStartPage to monochrome
- Delete 6 unused files: ThemeToggle, themeStore, AppLayout-original,
  QuickStartPage-Enhanced, UpgradePrompt, SettingsPage
- Restructure Account/Settings navigation: merge Settings into Account page,
  make AccountSettingsPage the /account index, remove orphaned /account-settings route
- Remove "Settings" nav item (consolidated under Account)
- Add export preferences and team categories link to AccountSettingsPage
- Align QuickStartPage to monochrome design system: replace cyan/blue/violet
  accent colors with white opacity variants
- Replace non-functional search button with search spinner indicator

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 17:46:35 -05:00
Michael Chihlas
89d343d49a chore: archive 11 completed plan documents
Move completed design/implementation docs from docs/plans/ to docs/archive/
to keep the plans folder focused on active and future work.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 10:51:21 -05:00
chihlasm
01ecba13a2 chore: clean up untracked files and gitignore .claude/ directory
- Add make_superadmin utility scripts (list users, promote to super admin)
- Gitignore entire .claude/ directory (agents, settings, plans)
- Delete leftover tailwind-config-snippet.js and dual-mode plan doc

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 10:00:52 -05:00
chihlasm
6863f8e6e5 fix: move getMonacoEditor to separate file to fix react-refresh lint error
react-refresh/only-export-components disallows mixing component and
non-component exports. Moved the editor ref to monacoEditorRef.ts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 09:57:44 -05:00
chihlasm
5c9b9c4074 Merge pull request #50 from patherly/feat/dual-mode-tree-editor
feat: dual-mode tree editor with Code Mode and variables
2026-02-10 09:55:12 -05:00
chihlasm
eac6e184ec feat: add dual-mode tree editor with Code Mode, variables, and markdown sync
Implements the full dual-mode tree editor (Plan Phases 1-5):

Backend:
- JSONB↔Markdown bidirectional serializer/parser with mistune
- Markdown validator with line/column error reporting
- 3 API endpoints: export-markdown, import-markdown, validate-markdown
- Variable extraction/resolution service ([USER_INPUT], [VAR], [SAVE_AS])
- Session variables JSONB column (migration 028)
- 39 tree markdown tests + variable service tests (403 total passing)

Frontend:
- Monaco-based Code Mode with custom Monarch tokenizer and dark theme
- Autocomplete for @node_id refs, type values, variable names
- Debounced validation (800ms) with inline Monaco error markers
- Syntax help panel (absolute overlay, toggleable)
- Starter template for new trees with valid cross-references
- Bidirectional metadata sync (name/description/category/tags frontmatter)
- Synchronous tree→markdown serializer (fixes async race condition)
- Pre-save validation blocks save on broken refs or missing tree name
- Mode-aware undo/redo: Monaco native in Code Mode, throttled zundo in Flow Mode
- Variable prompt modal and frontend resolver for session navigation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 09:45:26 -05:00
chihlasm
2bd47004e7 docs: update CLAUDE.md for monochrome design system
Remove outdated purple gradient/theme toggle references, add monochrome
design system patterns and component guidelines for future sessions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 22:41:26 -05:00
chihlasm
f4ce1595d6 feat: implement monochrome design system across entire frontend
Migrate all 84 frontend files from the old themed/colored design to a
monochrome glass-morphism design system. Pure black backgrounds, white
text with opacity levels, glass-card components with backdrop-blur, and
functional color reserved for status indicators only.

Foundation: remap CSS variables to monochrome, simplify Tailwind config,
remove theme toggle, convert brand logo/wordmark to white. Pages: all
14 pages updated. Components: all common, library, session, step-library,
tree-editor, tree-preview, admin, and subscription components converted.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 21:41:29 -05:00
chihlasm
1381aaae99 feat: add cross-parent drag-and-drop with validation feedback
Enable moving nodes between different parents in the tree editor.
Drop targets show blue indicator for valid drops and red pulsing
glow for invalid drops (e.g., dropping onto solution nodes or
onto descendants of the dragged node).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 00:13:48 -05:00
chihlasm
b265269024 fix: repair tree editor drag-to-reorder with 6 bug fixes
- Grip-only drag initiation (prevents conflict with click-to-select)
- onDragEnd on each draggable item (clears ghost state after failed drops)
- Trailing drop zone after last child (enables drop-to-last-position)
- Suppress cross-parent drag indicators (no misleading visual feedback)
- onDragLeave handler to clear drop indicators when cursor exits
- Source parent tracking threaded through component tree

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 23:58:48 -05:00
chihlasm
7ab2ff1be2 Merge pull request #47 from patherly/feat/psa-export-and-quickstart
feat: PSA ticket export and Quick-Start landing page
2026-02-08 23:24:25 -05:00
chihlasm
9b5e6f3e53 fix: redirect to home page after login/register instead of /trees
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 20:23:44 -05:00
chihlasm
4f8b7dd7ca feat: add PSA ticket export format and Quick-Start landing page
PSA Export:
- New "PSA / Ticket Note" export format optimized for ConnectWise
- Structured output: Problem, Steps Taken, Resolution, Time Spent, Notes
- Prominent "Copy for Ticket" button on session detail page
- 24 unit tests for PSA export generator

Quick-Start Landing:
- New default landing page with search-first UX
- Auto-focused search bar with debounced tree search
- "Continue Session" cards for active sessions
- "Recent Trees" section from session history
- Home nav item and logo links updated

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 19:36:51 -05:00
chihlasm
f2ae3a51fa fix: resolve all 15 frontend ESLint errors for green CI
- Replace setState-in-effect with state-based tracking (AdminLayout, EditCategoryModal)
- Convert inline SortIcon component to getSortIcon function (TreeTableView)
- Remove unused catch parameters (CreateCategoryModal, EditCategoryModal)
- Replace `any` types with proper types (SessionFilters, AdminCategoriesPage, SessionHistoryPage)
- Fix unused destructuring variable (StepRatingModal)
- Fix constant binary expression in test (utils.test.ts)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 18:43:16 -05:00
chihlasm
6752a55ff8 Merge pull request #46 from patherly/test/frontend-vitest-setup
test: set up Vitest with 61 frontend tests
2026-02-08 18:21:00 -05:00
chihlasm
791fd133c4 test: set up Vitest with 61 frontend tests
Add Vitest + testing-library/react + jsdom for frontend testing.
Tests cover: cn() utility (6), usePermissions hook (27), useTreeValidation
hook (22), and userPreferencesStore (6). CI updated to run frontend tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 18:18:38 -05:00
chihlasm
f703684e15 Merge pull request #45 from patherly/test/backend-coverage
test: add 113 unit tests for backend coverage
2026-02-08 18:01:31 -05:00
chihlasm
064bc0aa48 test: add 113 unit tests for permissions, tree validation, and settings
Cover all permission functions (59 tests), tree validation logic (25 tests),
settings manager parse/infer helpers (21 tests), and Stripe webhook stubs (8 tests).
Key modules now at 100% coverage: permissions.py, tree_validation.py, stripe_handlers.py.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 17:58:48 -05:00
chihlasm
932f389c4b Merge pull request #44 from patherly/docs/migration-strategy
docs: database migration strategy guide
2026-02-08 17:49:49 -05:00
chihlasm
d4acef5903 docs: add database migration strategy guide
Document the 31 migration files, naming conventions, revision chain,
circular FK workaround, NULL casting gotcha, and migration history table.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 17:48:38 -05:00
chihlasm
298af2d6d7 Merge pull request #43 from patherly/test/export-security-and-coverage
test: export security tests + CI coverage reporting
2026-02-08 17:24:21 -05:00
chihlasm
e216d5039e test: add export security tests and CI coverage reporting
Export security tests (26 new tests):
- 11 XSS prevention tests covering all user-supplied fields in HTML export
  (tree name, ticket, client, decisions, notes, timestamps, scratchpad)
- 7 edge case tests (unicode/emoji, empty decisions, missing fields, long content)
- 5 format-specific tests (markdown headers, text numbering)
- 3 HTML structure tests (valid document, CSS, timestamp toggle)

CI coverage reporting:
- Add --cov=app --cov-report flags to pytest in GitHub Actions
- Display per-module coverage summary after test run
- Baseline: 63% overall, 98% on export_service.py

Total tests: 215 (189 existing + 26 new)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 14:53:22 -05:00
chihlasm
af74c1515f Merge pull request #42 from patherly/fix/security-audit
fix: resolve python-jose security vulnerabilities
2026-02-08 14:44:00 -05:00
chihlasm
e772877996 fix: resolve python-jose CVEs (CVE-2024-33663, CVE-2024-33664)
Update python-jose from 3.3.0 to 3.5.0 to fix:
- CVE-2024-33663: Algorithm confusion with ECDSA keys (High)
- CVE-2024-33664: JWT bomb DoS via high compression ratio (High)

Remaining accepted risk: ecdsa CVE-2024-23342 (Minerva timing attack)
- No fix available (maintainer considers side-channel attacks out of scope)
- Non-exploitable in this app: JWTs use HMAC (HS256), not ECDSA signing

All 189 tests pass. npm audit: 0 vulnerabilities.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 14:43:13 -05:00
chihlasm
e5f5415915 Merge pull request #41 from patherly/refactor/tech-debt-q1
refactor: tech debt reduction sprint
2026-02-08 14:23:49 -05:00
chihlasm
a027e683e3 fix: repair all test fixtures - add missing solution fields and fix httpx API
- Add missing `solution` field to solution-type nodes in test tree structures
  (required by `can_publish_tree` validation for published trees)
- Fix `AsyncClient(app=...)` → `ASGITransport(app=...)` in test_save_session_as_tree
  (httpx deprecated the `app` parameter in favor of transport)
- All 189 tests now pass (was 84 passed, 1 failed)

Files fixed: conftest.py, test_permissions_account.py, test_subscription_limits.py,
test_trees.py, test_save_session_as_tree.py

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 14:21:29 -05:00
chihlasm
b97596d286 refactor: tech debt reduction - extract hooks, deduplicate helpers, update deps, add CI
- Extract useCustomStepFlow hook from TreeNavigationPage (1040 → 759 lines)
- Create core/filters.py with shared tree/step visibility filters
- Create services/export_service.py from session export logic
- Add GitHub Actions CI/CD pipeline (pytest + lint + build)
- Add GIN index migration for full-text search on trees
- Update FastAPI 0.128.5, Pydantic 2.12.5, SQLAlchemy 2.0.46, +5 more
- Fix regex → pattern deprecation in Query() params

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 08:14:22 -05:00
chihlasm
f4eb3fe186 fix: resolve admin panel API path issues and ActionMenu overflow
- Fix duplicate /api/v1 paths in admin API calls
- Fix ActionMenu dropdown being clipped by using React Portal
- Fix TeamCategoriesPage API endpoints

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-08 06:53:21 -05:00
Michael Chihlas
159161aa59 fix: add index redirect for /account route
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 06:12:37 -05:00
Michael Chihlas
b570f8415f feat: implement full admin panel with dashboard, user management, and platform settings
Adds complete super_admin panel with 9 pages and account owner categories page.
Backend includes 5 new DB tables, ~25 API endpoints, settings manager with
in-memory cache, and 29 integration tests. Frontend includes reusable admin
components (DataTable, Pagination, ActionMenu, etc.) with code-split lazy loading.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 06:05:59 -05:00
Michael Chihlas
4f57c84d43 docs: add comprehensive admin panel design document
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-08 01:54:09 -05:00
Michael Chihlas
996b664ca9 feat: implement My Trees, admin UI, rating modal, and bundle optimization (Issues #15, #18, #19, #31)
Frontend features:
- My Trees personal dashboard with fork tracking (Issue #15)
- Tree sharing UI with token generation and copy (Issue #16)
- Draft tree badges and validation UI (Issue #25)
- Save session as tree modal (Issue #17)
- Rate/review modal with localStorage tracking (Issue #19)
- Admin category management with drag-and-drop (Issue #18)
- Bundle size optimization with code splitting (Issue #31)

Components created:
- MyTreesPage: Personal tree organization
- AdminCategoriesPage: Category CRUD with @dnd-kit
- ShareTreeModal: Tree sharing interface
- SaveSessionAsTreeModal: Session conversion UI
- StepRatingModal: Post-session rating with stars
- StarRating: Reusable rating component
- PageLoader: Loading fallback for lazy routes
- CreateCategoryModal, EditCategoryModal: Admin modals

Bundle optimization:
- Reduced from 892 KB to 221 KB (75% reduction)
- Dynamic imports for 9 heavy pages
- Vendor chunk splitting for optimal caching
- 6 separate vendor chunks (react, markdown, utils, dnd, icons, state)

Dependencies added:
- @dnd-kit/core, @dnd-kit/sortable, @dnd-kit/utilities

API clients:
- stepCategories: Full CRUD for admin
- Enhanced sessions: saveAsTree endpoint
- Enhanced trees: share, fork, canPublish endpoints

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 23:06:46 -05:00
Michael Chihlas
c7b2c59ef6 feat: implement tree sharing, draft trees, and session-to-tree conversion (Issues #16, #25, #17)
Backend features:
- Tree sharing via secure tokens with expiration (Issue #16)
- Draft tree status with conditional validation (Issue #25)
- Save session as custom tree with fork tracking (Issue #17)
- Tree validation system for publish requirements
- Session-to-tree conversion preserving custom steps

Database migrations:
- 024: Tree sharing (tree_shares table, visibility field)
- 025: Tree status field (draft/published)
- 25b: Merge migration for indexes

New endpoints:
- POST /api/v1/trees/{id}/share - Generate share token
- GET /api/v1/shared/{token} - Public tree access
- POST /api/v1/trees/{id}/can-publish - Validate tree
- POST /api/v1/sessions/{id}/save-as-tree - Convert session

Test coverage:
- 20 tests for draft trees functionality
- 14 tests for session-to-tree conversion
- 15 tests for tree sharing

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 23:06:13 -05:00
Michael Chihlas
9f92547309 feat: implement session history search and filtering (Issue #35)
Implement comprehensive search and filtering for Session History to dramatically
improve findability of past troubleshooting sessions.

Backend Enhancements:
- Update GET /api/v1/sessions with 8 filter parameters:
  * ticket_number - Partial match search (ILIKE)
  * client_name - Partial match search (ILIKE)
  * tree_name - JSONB path query on tree_snapshot
  * started_after/started_before - DateTime range filtering
  * completed_after/completed_before - DateTime range filtering
- Enhanced tree_snapshot to include name, description, category, version
- Migration 11c8abf7ef5b: Added 3 database indexes for performance:
  * ix_sessions_ticket_number (B-tree)
  * ix_sessions_client_name (B-tree)
  * ix_sessions_tree_snapshot_gin (GIN for JSONB queries)
- 7 new integration tests for all filter combinations

Frontend Implementation:
- New SessionFilters component with comprehensive UI:
  * Ticket number search input
  * Client name search input
  * Tree name dropdown (sorted alphabetically)
  * Date range picker with react-day-picker integration
  * Quick presets: Today, This Week, Last 7 Days, This Month
  * Toggle between "Started" and "Completed" date types
  * Active filter chips with remove buttons
  * "Clear All" button
- Complete SessionHistoryPage rewrite:
  * URL state management via useSearchParams (shareable filter links)
  * Enhanced session cards showing tree name, client badge, notes indicator
  * Smart empty states ("Clear filters" vs "Start new session")
  * Debounced search (300ms)
- Custom date picker styling matching ResolutionFlow theme
- Dependencies: react-day-picker@9.13.1, date-fns@4.1.0

Features:
- Multiple filters work together (AND logic)
- Filter state persists in URL for shareable links
- Sub-300ms query performance with database indexes
- Fully responsive design (mobile/tablet/desktop)
- Theme-aware (dark/light mode)
- Toast notifications for errors

Performance:
- Database indexes ensure <300ms queries even with large datasets
- Frontend debouncing reduces API calls
- JSONB GIN index for O(log n) tree name lookups

Bundle Impact:
- JS: +87.83 KB (+12.2%, due to react-day-picker library)
- CSS: +10.53 KB (+25.8%, date picker styles)
- Gzipped: +24.52 KB JS, +1.82 KB CSS

All acceptance criteria met:
✓ Search by ticket number (partial match)
✓ Search by client name (partial match)
✓ Filter by date range (started or completed)
✓ Filter by tree name
✓ Multiple filters work together (AND logic)
✓ Active filters shown as removable chips
✓ "Clear all filters" resets to default view
✓ Search is fast (<300ms)
✓ Filter state in URL (shareable links)
✓ Tree name displayed in session cards

Tests: 34/34 session tests passing (7 new filter tests)

Closes #35

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 21:17:25 -05:00
Michael Chihlas
98ca617ef0 feat: implement toast notification system (Issue #33)
Implement comprehensive toast notification system using Sonner with full
ResolutionFlow theme integration and global error handling.

Core Infrastructure (Phase 1):
- Install sonner@2.0.7 package
- Create toast utility wrapper (lib/toast.ts) with success/error/info/warning/promise methods
- Add Toaster provider to main.tsx with theme-aware configuration
- Custom CSS styling matching ResolutionFlow design system (Purple gradient theme)
- Typography: Plus Jakarta Sans (titles), Inter (body)
- Automatic dark/light mode support via CSS custom properties

Success/Error Notifications (Phase 2):
- TreeEditorPage: Save success/error toasts
- SessionDetailPage: Export/copy success/error toasts
- SettingsPage: Preferences saved toast
- FolderEditModal: Folder create/update/error toasts
- Removed 6 inline error banners in favor of toasts

Error Standardization (Phase 3):
- Global API error interceptor in client.ts
- Automatic toast notifications for network errors, timeouts, 5xx errors
- Handles unhandled API errors gracefully
- Pages can still override with specific error handling

Refinement (Phase 4):
- Standardized vocabulary ("Failed to..." for errors, "...successfully" for success)
- Verified WCAG 2.1 AA accessibility compliance
- Screen reader support, keyboard navigation
- Bundle impact: +450 bytes (+0.06%)

Benefits:
- Consistent user feedback across entire application
- Non-blocking UI notifications
- Auto-dismiss after 4 seconds
- Theme-aware (matches dark/light mode)
- Accessible to all users
- Cleaner codebase (removed error state management)

Closes #33

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 21:16:51 -05:00
Michael Chihlas
89e09edc64 feat: add tree library view system with grid/list/table modes and sorting
Implements Issue #34 - Tree Library Full View System

Backend Changes:
- Add sort_by parameter to GET /api/v1/trees endpoint
- Support 6 sorting options: usage_count, updated_at, created_at, name, name_desc, version
- Maintain backward compatibility (defaults to usage_count)
- Add comprehensive test for sorting functionality
- All 104 backend tests passing

Frontend Changes:
- Create ViewToggle component for switching between Grid/List/Table views
- Create SortDropdown component for 6 sort options
- Create TreeGridView component (extracted from TreeLibraryPage)
- Create TreeListView component (compact row-based layout)
- Create TreeTableView component (sortable table with columns)
- Update userPreferencesStore with view and sort preferences
- Update TreeFilters type to include sort_by parameter
- Update TreeLibraryPage to integrate new components
- View and sort preferences persist to localStorage

Features:
- Grid view: Best for discovery (default)
- List view: Best for quick scanning
- Table view: Best for sorting and comparison
- Responsive design: Mobile/tablet/desktop optimized
- Table view hides columns responsively
- Sortable table headers with visual indicators
- Smooth transitions and hover effects
- No layout shift when switching views

Testing:
- Backend: 104/104 tests pass
- Frontend: Build successful, no TypeScript errors
- All existing functionality preserved

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 20:36:20 -05:00
chihlasm
469456c9c9 Merge pull request #39 from patherly/feat/foundational-schema
feat: add tree forking, custom steps, and session sharing
2026-02-07 19:31:21 -05:00
Michael Chihlas
ffb14cd014 feat: add tree forking, custom step tracking, and session sharing
Implement three foundational schema features from the design doc:

- Tree forking with lineage tracking (migration 022): parent_tree_id,
  root_tree_id, fork_depth columns with self-referential FKs and
  composite analytics index
- Custom step enhancement: CustomStepSchema with source tracking
  (ad-hoc, step-library, forked-tree) for backward-compatible JSONB
- Session sharing (migration 023): session_shares and session_share_views
  tables with account-scoped visibility, cryptographic tokens, view
  tracking, and allow_public_shares account policy

Includes 21 new integration tests (9 forking, 12 sharing), SaaS
consultant-recommended denormalizations, rate limiting on public share
access, and test fixture fix for invite code requirement.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 19:10:47 -05:00
chihlasm
c8e7aaad1a Add foundational domain model design document
Comprehensive schema design for three critical foundational features:

1. Tree Forking Model (Issue #11)
   - Add parent_tree_id, fork_reason, parent_updated_at to trees
   - Self-referential relationship with orphaning on parent delete
   - Update detection mechanism for "parent tree updated" notifications

2. Session Custom Steps Enhancement (Issues #4-#7 partial)
   - Backward-compatible JSONB enhancement (no migration)
   - Track step source (ad-hoc, library, forked-tree)
   - Link to StepLibrary for usage analytics
   - Support "save session as tree" reconstruction

3. Session Share Tokens (Issue #15)
   - New session_shares table with token-based access
   - New session_share_views table for detailed analytics
   - Account-level policy: allow_public_shares
   - Public vs account-only visibility with permission checks

All schema changes designed for backward compatibility and minimal
migration complexity. Establishes durable domain model that future
features depend on.

Migration plan: 022 (tree forking), 023 (session sharing)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 17:46:32 -05:00
chihlasm
ff7894b977 Add UX enhancement design doc: notification system
Design document for Tier 1 UX enhancement implementing toast
notifications using sonner library.

- Comprehensive context on current state problems
- Phase-by-phase implementation plan
- Design patterns and best practices
- Complete verification checklist
- Risk assessment and mitigation strategies

Related: #33, #34, #35

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-07 13:53:14 -05:00
chihlasm
40e588e559 Merge pull request #32 from patherly/feat/subscription-tiers
feat: account-based subscription tiers (Free/Pro/Team)
2026-02-07 03:18:39 -05:00
chihlasm
8dbb87e4d2 fix: add migration 021 to make accounts.owner_id nullable on existing DBs
Railway already ran the old migration 020 which enforced NOT NULL on
owner_id. Since alembic won't re-run a corrected 020, this new migration
explicitly reverts the constraint for databases that already applied it.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 03:06:35 -05:00
chihlasm
974e86a502 fix: resolve circular FK between users and accounts on registration
Account.owner_id and User.account_id are both NOT NULL, creating a
circular dependency that prevents inserting either row first. Fix by:
1. Making owner_id nullable (set immediately after user creation)
2. Creating Account before User, then setting owner_id after flush
3. Removing NOT NULL enforcement on owner_id in migration 020

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 02:55:53 -05:00
chihlasm
7a6f839ef4 feat: update frontend for account-based subscriptions
Replace all team_id/team_admin references with account_id/owner across
types, store, hooks, API clients, components, and pages. Add new
AccountSettingsPage, UpgradePrompt, CheckoutButton, useSubscription
hook, and accounts API client. AuthStore now parallel-fetches account
and subscription data alongside user profile.

Also fix folder sidebar not refreshing after tree deletion by
dispatching the folder-changed event in handleDeleteTree.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 02:39:15 -05:00
chihlasm
e0089a9c5a feat: update all endpoints and schemas for account-based model
Replace team_id with account_id across all API endpoints (trees,
categories, tags, steps, step_categories, admin, auth). Add new
accounts and webhooks endpoints. Registration now atomically creates
Account + Subscription, with account_invite_code bypassing the
platform invite gate.

Schemas updated for account_id/account_role. 82 tests passing
including 18 new tests for accounts, subscriptions, and permissions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 02:39:01 -05:00
chihlasm
4ccb93ee31 feat: add account-based subscription model with migrations
Transition from team-based to account-based multi-tenancy (Free/Pro/Team).
Migrations 016-020 create accounts, subscriptions, plan_limits, and
account_invites tables, then migrate existing users and content FKs.

New models: Account, Subscription, PlanLimits, AccountInvite.
Updated models add account_id alongside existing team_id (coexistence
for safe two-PR deployment). Permissions and deps refactored for
account_role instead of is_team_admin.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 02:38:47 -05:00