1248 Commits

Author SHA1 Message Date
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
Michael Chihlas
fb84bd8144 docs: add subscription tier implementation plan
Comprehensive implementation plan for transitioning from team-based
to SaaS subscription model with Free/Pro/Team tiers:

- Phase 1 (Days 1-3): Database migration in 6 separate migrations
  - Migration 016: Create accounts, subscriptions, plan_limits, account_invites tables
  - Migration 017: Add account_id and account_role to users
  - Migration 018 (critical): Migrate users/teams to accounts
  - Migration 019: Migrate team_id FKs to account_id on content tables
  - Migration 020: Add constraints and finalize migration
  - Migration 021: Drop old team columns and teams table

- Phase 2 (Days 4-7): Backend updates
  - New models: Account, Subscription, PlanLimits, AccountInvites
  - Refactor permissions system (account_role replaces role/is_team_admin)
  - Add subscription helpers for feature gating
  - Update all 25+ endpoints to use account_id
  - Update test fixtures and fix 61+ tests

- Phase 3 (Days 8-10): Frontend updates
  - Update types (account_id, account_role)
  - New hooks: useSubscription, updated usePermissions
  - Account settings page with subscription info
  - Usage indicators and upgrade prompts
  - Stripe Checkout button (disabled until ready)

- Phase 4 (Days 11-12): Stripe preparation
  - Install Stripe SDK
  - Webhook skeleton with event handlers
  - Code ready to enable when Stripe account created

Key features:
- Build Stripe-ready but ship free-tier-only initially
- Feature branch workflow (feat/subscription-tiers)
- Comprehensive rollback plans for each phase
- All limits configurable via plan_limits table
- 10-12 day timeline with safety checks
- Test on production copy before migration

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 21:36:01 -05:00
Michael Chihlas
1897641082 fix: resolve all 8 pre-existing lint errors (closes #29)
Fixed @typescript-eslint/no-explicit-any (4 occurrences):
- FolderEditModal.tsx: proper error type checking instead of any
- StepForm.tsx: explicit union type for visibility select
- StepLibraryBrowser.tsx: explicit union types for stepType and sortBy selects

Fixed react-hooks/set-state-in-effect (1 occurrence):
- NodeEditorModal.tsx: replaced useEffect with direct state comparison

Fixed @typescript-eslint/no-unused-vars (3 occurrences):
- NodeEditorModal.tsx: removed unused useEffect import
- NodeEditorModal.tsx: added eslint-disable for intentionally destructured children
- usePermissions.ts: removed unused _tree parameter from canDeleteTree
- TreeLibraryPage.tsx: updated canDeleteTree call site

Fixed @typescript-eslint/no-empty-object-type (1 occurrence):
- types/step.ts: changed empty interface to type alias

Verification:
- npm run lint: 0 errors (9 warnings are intentional exhaustive-deps)
- npm run build: succeeds
- TypeScript compilation: passes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 17:38:38 -05:00
Michael Chihlas
a674ba7bcb docs: update CURRENT-STATE.md and roadmap to reflect Phase 2.5 progress
- Updated active phase to Phase 2.5 - Step Library Foundation
- Marked all Phase 2 items as complete (Tree Editor, RBAC, Permissions, UI polish)
- Added comprehensive Frontend section showing completed work:
  - User Preferences (Settings page, export format, theme)
  - Tree Organization (categories, tags, folders with hierarchy)
  - RBAC & Permissions (full role system, permission guards)
  - Session Scratchpad (floating overlay, auto-save)
  - Mobile Responsiveness (touch-friendly, responsive layouts)
  - Design Consistency & Polish (micro-interactions, scrollbars)
- Updated "What's In Progress" to focus on Phase 2.5 items
- Marked Deployment as Production (live on Railway)
- Added recent changes section for Feb 5-6, 2026
- Updated roadmap checkboxes:
  - Phase 1 MVP: User preferences, deployment complete
  - Phase 2: Team features, tree management, mobile polish complete
  - Phase 2.5: All backend items complete, frontend UI in progress
- Session handoff notes reflect current state

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 17:38:27 -05:00
chihlasm
5d464c1287 docs: add subscription tier architecture plan
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 03:04:06 -05:00
chihlasm
36069850bc docs: add comprehensive project review report
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 03:01:25 -05:00
chihlasm
90ff25003d feat: add mobile responsiveness, design consistency, and micro-interactions
- Add mobile hamburger menu with slide-out nav drawer (AppLayout)
- Make modals responsive: full-width on mobile, slide-up animation
- Scratchpad becomes full-screen overlay on mobile with backdrop
- Folder sidebar hidden on mobile, opens as slide-over drawer
- Tree editor shows "Desktop Required" gate on mobile
- Stack action buttons vertically on mobile (sessions, detail pages)
- Increase touch targets throughout (buttons, close icons)
- Add CSS animations: fade-in, slide-in-left, scale-in, btn-press
- Add card hover lift effect and consistent border highlights
- Standardize page padding (px-4 py-6 sm:px-6 sm:py-8)
- Responsive headings (text-2xl sm:text-3xl)
- CustomStepModal goes full-screen on mobile
- Tighten auth page spacing on mobile

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 01:58:39 -05:00
chihlasm
cf6d8bd57b docs: audit and improve CLAUDE.md — add Phase C/D, trim verbose sections
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 00:40:34 -05:00
chihlasm
1e57aa8323 fix: escape SQL wildcards in tag search autocomplete
The % and _ characters in user search input are now escaped before
the LIKE query, preventing unintended wildcard matching in tag search.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 00:26:35 -05:00
chihlasm
94ec19cf07 fix: only register debug endpoint when DEBUG=True
The /debug/cors endpoint is now conditionally registered, preventing
information leakage about CORS configuration in production.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 00:24:02 -05:00
chihlasm
5ae22e041f fix: clean up folder and tag assignments on tree soft delete
When a tree is soft-deleted, folder assignments and tag assignments are
now removed from junction tables. Tag usage counts are decremented with
a floor of zero to prevent negative counts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 00:23:24 -05:00
chihlasm
02e00963e1 feat: add password complexity validation
Passwords must now contain at least one uppercase letter, one lowercase
letter, and one digit (in addition to the existing 10-char minimum).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 00:20:21 -05:00
chihlasm
741938cf1f feat: gate custom step creation tab by permission
Viewers who cannot create steps will only see the "Browse Library"
tab in the CustomStepModal, hiding the "Type My Own" creation form.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 23:39:45 -05:00
chihlasm
722e030ba6 feat: add confirm dialog and tree delete UI on library page
Adds a reusable ConfirmDialog component and integrates tree deletion
into the TreeLibraryPage with permission-gated delete buttons and
a destructive confirmation dialog.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 23:38:41 -05:00
chihlasm
0dfee5cd36 fix: check edit permissions before loading tree into editor
TreeEditorPage now verifies canEditTree() after fetching tree data but
before loading it into the editor store. Previously only checked
canCreateTrees which doesn't prevent non-owners from editing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 23:34:47 -05:00
chihlasm
2ee549bfbc feat: add 403 handling and role-based route guard support
ProtectedRoute now accepts an optional requiredRole prop for role-based
route guards. When specified, users below the required role level are
redirected to /trees. 403 responses already pass through to components
for inline error display.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 23:34:00 -05:00
chihlasm
33368688b2 feat: upgrade tree deletion to soft delete with deleted_at timestamp
Adds deleted_at and deleted_by columns to trees table for proper soft
delete tracking. Supports future 30-day restore window functionality.
The delete endpoint now sets both is_active=False (backward compat) and
deleted_at/deleted_by. Migration backfills existing is_active=False rows.

Fixed ambiguous FK relationship between User/Tree models by adding
explicit foreign_keys to both sides of the author relationship.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 23:33:05 -05:00
chihlasm
3a5ac0f201 feat: add audit log table and integration with admin/tree endpoints
Creates AuditLog model with JSONB details column for tracking admin
actions. Integrates log_audit() helper into admin endpoints (role
change, team admin toggle, deactivate, activate) and tree delete.
IP address column reserved for future Railway proxy header support.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 23:28:41 -05:00
chihlasm
02d06acfb8 feat: add super admin bypass in tree list filter
Super admins now see all trees regardless of ownership, team, or
public/default status. Previously the build_tree_access_filter function
had no super_admin check, so admins could only see their own trees plus
public/default/team trees.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 23:25:56 -05:00
chihlasm
71ba0b95a5 fix: high-severity security hardening (Phase B permissions audit)
Phase B addresses 7 high-severity gaps from the permissions audit:

- B1: Enforce tree access check on session start via can_access_tree
- B2: Replace all inline permission helpers with centralized permissions.py
- B3: Fix require_engineer_or_admin to check is_team_admin before role
- B4: Add is_active field on User with enforcement in get_current_active_user
- B5: Add admin user management endpoints (list, get, role, team-admin, deactivate, activate)
- B6: Add rate limiting on auth/invite endpoints via slowapi (disabled in DEBUG)
- B7: Implement refresh token rotation with JTI-based revocation and meaningful logout

Also reduces access token TTL from 15 to 5 minutes and updates CLAUDE.md
with SaaS/MSP context for future planning sessions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 22:44:05 -05:00
chihlasm
3e0fb92012 fix: critical security hardening (Phase A permissions audit)
- Remove role field from UserCreate schema, hardcode 'engineer' at registration
- Escape all user content in HTML export with html.escape() (XSS fix)
- Add field_validator to reject default SECRET_KEY when DEBUG=False
- Add CHECK constraint on users.role ('engineer'|'viewer') + migration 011
- Fix test_admin fixture to properly grant is_super_admin via ORM
- Fix circular FK (users↔invite_codes) in test DB setup with DROP SCHEMA CASCADE
- Add 5 new security tests (role validation + XSS prevention)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 22:04:37 -05:00
Michael Chihlas
fd8fab97bd docs: update permissions audit with re-audit findings
Re-audited after RBAC commit (34daa26). Key findings:
- permissions.py is dead code (no endpoint imports it)
- require_engineer_or_admin blocks team admins with viewer role
- 49 endpoints bypass get_current_active_user
- 3 critical issues still open (role field, XSS, secret key)
- Updated implementation plan with new Phase B items

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 17:53:25 -05:00
Michael Chihlas
02bd97948e docs: add permissions audit design doc and implementation plan
Full-stack RBAC audit covering frontend UX, backend architecture,
and adversarial analysis. Implementation plan phased by severity
(Critical → High → Medium → Low).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 17:42:38 -05:00
chihlasm
34daa26a67 feat: implement RBAC permissions system
Add role-based access control with hierarchy: super_admin > team_admin >
engineer > viewer. Adds is_super_admin boolean to User model (migration 010),
centralized backend permissions module, frontend usePermissions hook, and
UI enforcement (conditional Create/Edit buttons, editor redirect for viewers,
role badge in header). All endpoint admin checks updated from role=="admin"
to is_super_admin.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 02:42:44 -05:00
Michael Chihlas
d7c5c8c9ce Updated documentation; added PERFORMANCE-HEALTH-CHECK.md 2026-02-04 21:46:32 -05:00
Michael Chihlas
2733a00253 feat: refactor scratchpad to floating overlay with global thin scrollbars
Refactor scratchpad from a flex-layout sidebar that pushes content left
to a floating overlay panel (position: fixed) that doesn't affect layout.
Panel slides in from the right with Ctrl+/ toggle. Main content adjusts
padding responsively when panel is open.

Also apply thin scrollbar styling globally across all scrollable elements
for a consistent, minimal look.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 21:39:05 -05:00
Michael Chihlas
6b8b29571e fix: token refresh and seed tree visibility
Fix broken JWT token refresh that caused "Failed to load trees" after
idle timeout. The refresh endpoint expected token as query param but
frontend sent it as Authorization header. Added proper dependency
(get_refresh_token_payload) and refresh queue to handle concurrent 401s.

Also fix seed trees not being visible to non-admin users by updating
the seed script to set is_public/is_default on existing trees.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 20:41:37 -05:00
Michael Chihlas
7fc98edf1c Merge branch 'feat/session-scratchpad' 2026-02-04 03:13:42 -05:00
Michael Chihlas
a9b9a6113c docs: Update CLAUDE.md with session learnings
Add migration chain non-sequential warning, feature branch workflow
guidance, session components directory, hooks directory, and docs/plans
naming convention.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 03:13:28 -05:00
Michael Chihlas
184e02781f docs: add session scratchpad implementation plan
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 02:55:22 -05:00
Michael Chihlas
4a0193f9af feat: integrate scratchpad sidebar into tree navigation page
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 02:51:52 -05:00
Michael Chihlas
26cf66e239 feat: add ScratchpadSidebar component with auto-save and markdown preview
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 02:50:37 -05:00
Michael Chihlas
a92671157f feat: add scratchpad to frontend types and API client
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 02:49:50 -05:00
Michael Chihlas
7824cddd71 feat: include scratchpad in session export (markdown, text, HTML)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 02:49:11 -05:00
Michael Chihlas
6da2044b20 feat: add PATCH endpoint for session scratchpad
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 02:48:10 -05:00
Michael Chihlas
7d0000827b feat: add scratchpad field to session model and schemas
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 02:47:22 -05:00
Michael Chihlas
d488d2acc8 feat: add scratchpad column to sessions table
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 02:47:18 -05:00
Michael Chihlas
a09f62a751 docs: Add Session Scratchpad design and update project references
- Add Session Scratchpad design doc (Idea 6 from brainstorm)
- Update CLAUDE.md production URLs to resolutionflow.com
- Update CORS lesson domain refs for rebrand
- Add .claude/settings.local.json to gitignore docs
- Add docs/plans/ to project structure

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 02:34:25 -05:00
Michael Chihlas
d28fad7066 docs: Add feature ideas brainstorm (10 concepts for MSP-focused features)
Captures brainstorming session covering session scratchpad, time tracking,
command output capture, share progress/escalation, push steps, path analytics,
multi-tree sessions, recurring issue detection, tree health scores, and
AI tree intelligence. Includes suggested build order and dependency map.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 01:59:32 -05:00
Michael Chihlas
653ac50e55 chore: Add rebrand assets, implementation guide, and gitignore local settings
Adds brand-assets/ (SVGs, brand guide) and REBRAND-IMPLEMENTATION-GUIDE.md
as reference docs. Removes .claude/settings.local.json from tracking
(contains local permissions and tokens).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 00:52:03 -05:00
Michael Chihlas
83df48291a feat: Complete backend and docs rebrand from Patherly to ResolutionFlow
Update APP_NAME, OpenAPI metadata, log messages, root endpoint response,
model docstrings, seed script comments, README heading, and CLAUDE.md
branding references. Frontend rebrand was completed in PR #26; this
covers everything else.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 00:41:22 -05:00
Michael Chihlas
29c1bcd204 docs: Add rebranding info to CLAUDE.md (Patherly → ResolutionFlow)
Document the frontend rebrand including brand colors, fonts, logo
locations, CSS utilities, and naming conventions for future development.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 00:22:47 -05:00
chihlasm
b1d5cc2be3 Merge pull request #26 from patherly/rebrand-to-resolutionflow
Rebrand frontend to ResolutionFlow
2026-02-04 00:03:21 -05:00
Michael Chihlas
f33c3c8b29 fix: Swap folder tree count with menu button on hover
The tree count and hamburger menu were overlapping at the right edge of
folder items. Now the count hides on hover and the menu button appears
in its place.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 23:59:16 -05:00