OpenHRApp / Others
CLAUDE.md19 starsChanged 7 months agoMITView on GitHub
ALL contributors (human or AI) MUST read and follow these instructions. For all web browsing, use the /browse skill from gstack. Never use mcp__claude-in-chrome__* tools for browsing. First-time setup (all contributors must run once): Prerequisites: bun must be installed. The script clones gstack to ~/.claude/skills/gstack/ and runs ./setup. Available gstack skills: /office-hours, /plan-ceo-review, /plan-eng-review, /plan-design-review, /design-consultation, /design-shotgun, /design-html, /review, /ship, /land-and-deploy, /canary, /benchmark, /browse, /connect-chrome, /qa, /qa-only, /design-review, /setup-browser-cookies, /setup-deploy, /setup-gbrain, /retro, /investigate, /document-release, /document-generate, /codex, /cso, /autoplan, /plan-devex-review, /devex-review,…
- Commits and pushes
In this repository9 other files it gives its agents.
- .agents/skills/vercel-react-best-practices/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- public/llms-full.txtllms.txt
- public/llms.txtllms.txt
- frontend-designSkill
- seo-auditSkill
- theme-factorySkill
- vercel-react-best-practicesSkill
- web-design-guidelinesSkill
The file
Show its rules and text
We split this CLAUDE.md into the rules it gives an agent
23 rules. About 0 are common, 13 are distinctive, and 10 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈13
Distinctive · estimate
This author's own choices. Worth a look.
10
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 213
If workflow approverRole = HR/ADMIN → status = PENDING_HR (skip manager)
- Very specific: line 214
If employee has no lineManagerId → status = PENDING_HR
- Distinctive: line 218
Leave balance = quota[type] - sum(approved_days[type])
- Distinctive: line 227
Check overrides for active date range
- Very specific: line 228
Use employee's assigned shift (shiftId)
- Distinctive: line 229
Use organization default shift
- Very specific: line 243
All images auto-converted to WebP via convertToWebP() utility
- Very specific: line 359
ALL native-feature components MUST have an <ErrorBoundary> wrapper
- Distinctive: line 360
Always handle permission-denied / no-geolocation errors with readable messages
- Distinctive: line 361
Test camera + location on real iOS Safari and Android Chrome before shipping (PWA standalone mode is stricter than the browser tab)
- Very specific: line 376
All native feature components must have <ErrorBoundary> wrapper
- Distinctive: line 377
Use custom hooks for camera and location — never call plugins directly
- Distinctive: line 378
All user-facing errors must show readable messages, never raw JS errors
- Distinctive: line 379
All images must be auto-converted to WebP before upload
- Distinctive: line 380
Never delete or modify existing notification/email logic without explicit approval
- Very specific: line 381
Always include organization_id in new records for multi-tenant isolation
- Distinctive: line 425
After completing any code changes:
- Very specific: line 427
Commit with a descriptive message: git commit -m "description of changes"
- Distinctive: line 430
Always push immediately after committing.
- Distinctive: line 471
Add or update a regression check — unit test when the test framework lands, or a documented manual verification in the commit message until …
- Very specific: line 474
Update src/data/changelog.ts with a fix or change entry.
- Very specific: line 475
Never bypass hooks or skip validation on the commit (--no-verify is forbidden).
- Distinctive: line 517
Before shipping any change touching frozen files:
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. ALL contributors (human or AI) MUST read and follow these instructions.
gstack — Web Browsing & Skills
For all web browsing, use the /browse skill from gstack. Never use mcp__claude-in-chrome__* tools for browsing.
First-time setup (all contributors must run once):
powershell -ExecutionPolicy Bypass -File scripts/setup-gstack.ps1Prerequisites: bun must be installed. The script clones gstack to ~/.claude/skills/gstack/ and runs ./setup.
Available gstack skills: /office-hours, /plan-ceo-review, /plan-eng-review, /plan-design-review, /design-consultation, /design-shotgun, /design-html, /review, /ship, /land-and-deploy, /canary, /benchmark, /browse, /connect-chrome, /qa, /qa-only, /design-review, /setup-browser-cookies, /setup-deploy, /setup-gbrain, /retro, /investigate, /document-release, /document-generate, /codex, /cso, /autoplan, /plan-devex-review, /devex-review, /careful, /freeze, /guard, /unfreeze, /gstack-upgrade, /learn.
Build & Development Commands
npm run dev # Start Vite dev server on port 3000
npm run build # Production build
npm run preview # Serve production build locallyBackend: Supabase project must be running. Edge Functions are deployed via supabase functions deploy. Database schema is managed through migrations in supabase/migrations/.
Architecture Overview
OpenHR is a React 19 + TypeScript HR management system using Supabase as the backend. It runs as a PWA on web (installable on desktop, iOS, and Android via the browser).
Key characteristics:
- No React Router — Uses local state routing in
App.tsxviacurrentPathstate - Context + Event Bus for state management (no Redux)
- Service layer facade — All API calls go through
hrServicewhich aggregates domain services - Multi-tenant — Every query includes
org_idfiltering viaapiClient.getOrganizationId() - PWA-enabled with service worker support, install-to-homescreen on iOS/Android, and offline caching
Data Flow Pattern
Pages/Components → Hooks → hrService (facade) → Domain Services → apiClient → Supabase SDK (via `src/services/supabase.ts`)Directory Structure
src/
├── components/ # UI components organized by feature
│ ├── admin/ # Admin verification panel
│ ├── ads/ # Ad banner components (AdBanner, PublicAdBanner)
│ ├── announcements/ # Announcement cards + form modal
│ ├── attendance/ # Camera feed, location display, attendance actions
│ ├── blog/ # Blog navbar, footer, sidebar, rich text editor
│ ├── dashboard/ # Admin/Manager/Employee dashboards, stats, widgets
│ ├── landing/ # Landing page sections (Hero, Features, FAQ, CTA, etc.)
│ ├── leave/ # Leave flows (Employee, Manager, Admin, HR modules)
│ ├── notifications/ # Notification bell + admin form modal
│ ├── organization/ # Org config (holidays, leaves, placement, shifts, teams, workflow)
│ ├── registration/ # Registration verification page
│ ├── review/ # Performance review modules (Employee, Manager, HR, Admin)
│ ├── settings/ # Theme selector
│ ├── subscription/ # Subscription banner, guard, suspended page
│ ├── superadmin/ # Super admin panels (ads, appearance, blog, storage, etc.)
│ └── tutorials/ # Tutorial navbar + footer
├── config/ # database.ts (Supabase URL resolution)
├── context/ # AuthContext, ThemeContext, SubscriptionContext
├── data/ # countries.ts (country list)
├── hooks/ # Data fetching hooks by feature
│ ├── announcements/ # useAnnouncements
│ ├── attendance/ # useAttendance, useCamera, useGeoLocation
│ ├── dashboard/ # useDashboard
│ ├── notifications/ # useNotifications
│ ├── organization/ # useOrganization
│ └── review/ # usePerformanceReview
├── layouts/ # MainLayout (sidebar + header + content)
├── pages/ # Full-page components (route targets)
├── services/ # Domain services (all Supabase API interactions)
└── utils/ # attendanceUtils, imageConvert, sanitizeRouting System
Type: State-based routing — NO React Router. Navigation uses currentPath state in App.tsx.
Public Routes (No Auth Required)
| Path | Component | Notes |
/ | <LandingPage /> | Landing page for unauthenticated users |
/privacy | <PrivacyPolicyPage /> | Clean URL via pushState |
/terms | <TermsOfServicePage /> | Clean URL via pushState |
/download | <DownloadPage /> | Clean URL via pushState |
#/blog | <BlogPage /> | Hash-based navigation |
#/blog/{slug} | <BlogPostPage /> | Hash-based navigation |
#/how-to-use | <TutorialsPage /> | Hash-based navigation |
#/how-to-use/{slug} | <TutorialPage /> | Hash-based navigation |
/?token={TOKEN} | <VerifyAccount /> | Email verification |
Authenticated Routes (State-based currentPath)
| currentPath | Component | Roles Allowed |
dashboard | <Dashboard /> | ALL |
super-admin | <SuperAdmin /> | SUPER_ADMIN |
upgrade | <Upgrade /> | ADMIN, HR |
profile | <Settings /> | ALL |
employees | <EmployeeDirectory /> | ADMIN, HR, MANAGER |
attendance | <Attendance /> | ALL (renders outside MainLayout) |
attendance-logs | <AttendanceLogs viewMode="MY" /> | ALL |
attendance-audit | <AttendanceLogs viewMode="AUDIT" /> | ADMIN, HR, MANAGER |
leave | <Leave /> | ALL |
announcements | <Announcements /> | ALL |
admin-notifications | <AdminNotifications /> | ADMIN, HR |
performance-review | <PerformanceReview /> | ALL |
reports | <Reports /> | ADMIN, HR |
organization | <Organization /> | ADMIN, HR |
settings | <Settings /> | ALL |
Sidebar Menu Items
| Menu Item | Route | Roles |
| Dashboard | dashboard | ADMIN, HR, MANAGER, EMPLOYEE |
| My Profile | profile | ALL |
| My Attendance | attendance-logs | ALL |
| Attendance Audit | attendance-audit | ADMIN, HR, MANAGER |
| Leave | leave | ALL |
| Announcements | announcements | ALL |
| Notifications | admin-notifications | ADMIN, HR |
| Team Directory | employees | ADMIN, HR, MANAGER |
| Performance | performance-review | ALL |
| Organization | organization | ADMIN, HR |
| Reports | reports | ADMIN, HR |
| Settings | settings | ADMIN, HR |
Super Admin has a separate menu: Organizations (super-admin) + My Profile (profile).
Special Navigation Parameters
handleNavigate('attendance', { autoStart: 'OFFICE' }) // Quick clock-in office
handleNavigate('attendance', { autoStart: 'FACTORY' }) // Quick clock-in factory
handleNavigate('attendance', { autoStart: 'FINISH' }) // Quick clock-out
handleNavigate('leave', { autoOpen: true }) // Auto-open leave formRole-Based Access Control
Roles: SUPER_ADMIN, ADMIN, HR, MANAGER, TEAM_LEAD, EMPLOYEE
- Sidebar menu items filtered by
role.rolesarray inSidebar.tsx - Dashboard dispatches to role-specific components (AdminDashboard, ManagerDashboard, EmployeeDashboard)
- Services filter data by
organization_idfor multi-org isolation - SUPER_ADMIN bypasses all subscription checks
Role Visibility for Data
| Data | ADMIN/HR | MANAGER/TEAM_LEAD | EMPLOYEE |
| Employees | All in org | Direct reports + team | Team peers only |
| Attendance | All in org | Team members | Own only |
| Leaves | All in org | Team + own | Own only |
| Reviews | All in org | Direct reports + own | Own only |
Service Layer — COMPLETE REFERENCE
Service Facade
hrService.ts re-exports ALL methods from domain services as a single unified interface. Always use hrService from components/hooks, never import domain services directly (except employeeService.applyForLeave and apiClient).
All Services
| Service | File | Purpose |
apiClient | api.client.ts | Supabase wrapper + event bus + WebP FormData |
authService | auth.service.ts | Login, logout, registration, password reset, verification |
employeeService | employee.service.ts | Employee CRUD, profile updates, avatar upload |
employeeService | employeeService.ts | Leave application wrapper (calls hrService) |
attendanceService | attendance.service.ts | Punch in/out, session auto-close, late notifications |
leaveService | leave.service.ts | Leave CRUD, workflow routing, balance calculation |
organizationService | organization.service.ts | Config, departments, holidays, teams, workflows, policies |
shiftService | shift.service.ts | Shift CRUD, override management, resolution logic |
reviewService | review.service.ts | Review cycles, self-assessment, manager review, HR finalize |
announcementService | announcement.service.ts | Announcement CRUD + bulk notification broadcast |
notificationService | notification.service.ts | Notification CRUD, preferences, bulk create |
superAdminService | superadmin.service.ts | Org management, user management, platform stats |
upgradeService | upgrade.service.ts | Donation, trial extension, ad-supported requests |
blogService | blog.service.ts | Blog post CRUD (public + admin) |
tutorialService | tutorial.service.ts | Tutorial CRUD (public + admin) |
showcaseService | showcase.service.ts | Showcase org management |
socialLinksService | sociallinks.service.ts | Social media links management |
contactService | contact.service.ts | Contact form submission |
verificationService | verification.service.ts | Email verification, test email, manual verify |
emailService | emailService.ts | Daily attendance summary email formatting |
Key Business Logic
Leave Workflow Routing (leave.service.ts):
- Employee submits leave
- System checks department workflow config (
organizationService.getWorkflows()) - If workflow
approverRole= HR/ADMIN → status =PENDING_HR(skip manager) - If employee has no
lineManagerId→ status =PENDING_HR - Otherwise → status =
PENDING_MANAGER - Manager approves → status changes to
PENDING_HR - HR/Admin approves → status =
APPROVED(final) - Leave balance = quota[type] - sum(approved_days[type])
Attendance Auto-Close (attendance.service.ts):
- On
getActiveAttendance(), checks for open sessions (no check_out) - Past-date sessions: auto-closes with
autoSessionCloseTime+ remark - Same-day expired: auto-closes if
currentTime >= autoSessionCloseTime - Sends ATTENDANCE notification on auto-close
Shift Resolution (shift.service.ts):
- Check overrides for active date range
- Use employee's assigned shift (
shiftId) - Use organization default shift
- Return null
Performance Review Lifecycle (review.service.ts):
DRAFT→SELF_REVIEW_SUBMITTED(employee) →MANAGER_REVIEWED(manager) →COMPLETED(HR)- Auto-calculates attendance + leave summaries from cycle period
- Supports both JSON fields and legacy individual competency columns
Caching (organization.service.ts):
- Caches: config, departments, designations, holidays, leavePolicy, reviewConfig, leaveTypes, notificationConfig
prefetchMetadata()called on login for performanceclearCache()called on logout
Image Handling:
- All images auto-converted to WebP via
convertToWebP()utility - Applies to: avatars, selfies, blog covers, tutorial covers, showcase logos, upgrade screenshots
apiClient.toFormData()handles data URL → WebP Blob conversion
Custom Hooks — COMPLETE REFERENCE
| Hook | File | Purpose | Key Returns |
useAttendance | hooks/attendance/useAttendance.ts | Clock in/out, late calculation, shift resolution | {currentTime, activeRecord, submitPunch, status, employeeShift} |
useCamera | hooks/attendance/useCamera.ts | Live video stream, selfie capture, torch, gallery picker | {videoRef, stream, takeSelfie, takePhoto, selectFromGallery} |
useGeoLocation | hooks/attendance/useGeoLocation.ts | GPS location, reverse geocoding, geofence matching | {location, detectLocation, watchLocation, geoFences} |
useDashboard | hooks/dashboard/useDashboard.ts | Role-based dashboard data aggregation | {data: DashboardData, isLoading} |
useAnnouncements | hooks/announcements/useAnnouncements.ts | Fetch + filter announcements by role/expiry | {announcements, visibleAnnouncements, refresh} |
useNotifications | hooks/notifications/useNotifications.ts | Notifications + user preferences + muted filtering | {notifications, unreadCount, markAsRead, updatePreferences} |
useOrganization | hooks/organization/useOrganization.ts | All org config CRUD (departments, teams, shifts, etc.) | {departments, teams, config, workflows, leavePolicy, ...setters} |
usePerformanceReview | hooks/review/usePerformanceReview.ts | Review cycles, auto-transitions, role-filtered reviews | {data: PerformanceReviewData, refreshData} |
React Contexts
| Context | File | Purpose |
AuthContext | context/AuthContext.tsx | User session state, login/logout, PocketBase auth store sync |
SubscriptionContext | context/SubscriptionContext.tsx | Subscription status, canPerformAction(), periodic refresh (2min) |
ThemeContext | context/ThemeContext.tsx | 13+ themes, dark mode (light/dark/system), CSS variable injection, realtime sync |
Utilities
| Utility | File | Purpose |
consolidateAttendance | utils/attendanceUtils.ts | Merge multiple daily punches into single record per employee/day |
calculatePunctuality | utils/attendanceUtils.ts | Determine PRESENT/LATE based on shift + grace period |
calculateDuration | utils/attendanceUtils.ts | Calculate work hours between check-in and check-out |
convertToWebP | utils/imageConvert.ts | Convert any image (data URL or Blob) to WebP format |
convertFileToWebP | utils/imageConvert.ts | Convert File to WebP with renamed extension |
sanitizeHtml | utils/sanitize.ts | DOMPurify-based HTML sanitization (XSS prevention) |
Constants & Defaults (src/constants.tsx)
| Constant | Value |
DEPARTMENTS | Engineering, HR, Finance, Operations, Marketing, Sales, Product, Factory |
DESIGNATIONS | Senior/Junior Developer, HR Manager, Operations Lead, etc. (9 values) |
OFFICE_LOCATIONS | Dhaka HQ, Chittagong, Sylhet, Factory Zone, Remote Office (with lat/lng/radius) |
BD_HOLIDAYS | 9 Bangladesh holidays (national + festival + Islamic) |
DEFAULT_COMPETENCIES | Agility, Collaboration, Customer Focus, Developing Others, Global Mindset, Innovation Mindset |
DEFAULT_RATING_SCALE | 1-5 (Needs Improvement → Outstanding) |
DEFAULT_LEAVE_TYPES | ANNUAL, CASUAL, SICK (with balance), MATERNITY, PATERNITY, EARNED, UNPAID (no balance) |
DEFAULT_CONFIG | Timezone: Asia/Dhaka, Currency: BDT, Working Days: Mon-Thu+Sun, Office: 09:00-18:00 |
DEFAULT_NOTIFICATION_CONFIG | All types enabled, IMMEDIATE digest, quiet hours disabled |
Subscription System
Statuses: TRIAL, ACTIVE, EXPIRED, SUSPENDED, AD_SUPPORTED
| Status | Access | UI |
| TRIAL | Full access | Countdown banner |
| ACTIVE | Full access | No restrictions |
| EXPIRED | Read-only | Upgrade prompt, write actions blocked |
| SUSPENDED | Complete lockout | SuspendedPage, cannot login |
| AD_SUPPORTED | Full access | Ad banners shown |
Key files:
src/context/SubscriptionContext.tsx— State,canPerformAction(), 2-min refreshsrc/components/subscription/— SubscriptionGuard, SubscriptionBanner, SuspendedPagesupabase/functions/cron-expire-trials/— Auto-expiration + trial reminders (7d, 3d, 1d)supabase/functions/—/api/openhr/subscription-statusendpoint
Types (src/types.ts) — COMPLETE REFERENCE
Core Enums
Role: SUPER_ADMIN | ADMIN | MANAGER | HR | EMPLOYEE | TEAM_LEAD | MANAGEMENTWorkType: OFFICE | FIELDSubscriptionStatus: ACTIVE | TRIAL | EXPIRED | SUSPENDED | AD_SUPPORTEDUpgradeRequestType: DONATION | TRIAL_EXTENSION | AD_SUPPORTEDDonationTier: TIER_3MO | TIER_6MO | TIER_1YR | TIER_LIFETIME
Entity Interfaces
User— id, email, role, name, department, designation, avatar, teamId, shiftId, organizationIdEmployeeextends User — joiningDate, mobile, emergencyContact, salary, status, employmentType, location, nid, lineManagerId, workTypeOrganization— id, name, address, logo, country, subscriptionStatus, trialEndDateSubscriptionInfo— status, trialEndDate, daysRemaining, isSuperAdmin, isReadOnly, isBlocked, showAdsTeam— id, name, leaderId, department, organizationIdAttendance— id, employeeId, employeeName, date, checkIn, checkOut, status, location, remarks, selfie, dutyType, organizationIdLeaveRequest— id, employeeId, employeeName, lineManagerId, type, startDate, endDate, totalDays, reason, status, appliedDate, approverRemarks, managerRemarks, organizationIdLeaveBalance— employeeId + dynamic key-value pairs per leave typeShift— id, name, startTime, endTime, lateGracePeriod, earlyOutGracePeriod, earliestCheckIn, autoSessionCloseTime, workingDays[], isDefaultPerformanceReview— id, employeeId, cycleId, lineManagerId, status, selfRatings[], managerRatings[], attendanceSummary, leaveSummary, hrFinalRemarks, hrOverallRatingAnnouncement— id, title, content, authorId, priority, targetRoles[], expiresAtAppNotification— id, userId, type, title, message, isRead, priority, referenceId, referenceType, actionUrlAppConfig— companyName, timezone, currency, dateFormat, workingDays, officeStartTime, officeEndTime, lateGracePeriod, earlyOutGracePeriod, autoSessionCloseTimeLeavePolicy— defaults: Record<string, number>, overrides: Record<employeeId, Record<string, number>>LeaveWorkflow— department, approverRoleHoliday— id, date, name, isGovernment, typeCustomLeaveType— id, name, hasBalance, description
Camera & Geolocation — Web APIs
The app is PWA-only. All native-feature hooks use standard browser APIs:
src/hooks/attendance/useCamera.ts—navigator.mediaDevices.getUserMedia()for live stream;<input type="file" accept="image/*" capture="user">fallback for iOS PWA / blocked stream. WebP output viaconvertToWebP().src/hooks/attendance/useGeoLocation.ts—navigator.geolocation.getCurrentPosition()/watchPosition()with high-accuracy → network fallback, plus OpenStreetMap Nominatim reverse geocoding.
Rules:
- ALL native-feature components MUST have an
<ErrorBoundary>wrapper - Always handle permission-denied / no-geolocation errors with readable messages
- Test camera + location on real iOS Safari and Android Chrome before shipping (PWA standalone mode is stricter than the browser tab)
PWA Requirements
manifest.json: name, short_name, icons (192px + 512px), theme_color, background_color, display: standalone- Service worker via
vite-plugin-pwa+ Workbox - Lighthouse PWA score must be > 90
Code Standards — MUST FOLLOW
- One responsibility per component
- All native feature components must have
<ErrorBoundary>wrapper - Use custom hooks for camera and location — never call plugins directly
- All user-facing errors must show readable messages, never raw JS errors
- All images must be auto-converted to WebP before upload
- Never delete or modify existing notification/email logic without explicit approval
- Always include
organization_idin new records for multi-tenant isolation - snake_case for database fields, camelCase for TypeScript properties
- Services handle the conversion between the two naming conventions
Configuration Files
| File | Purpose |
vite.config.ts | Port 3000, path alias @/ → ./src/, PWA plugin |
src/config/database.ts | Supabase URL from env or hardcoded fallback |
src/constants.tsx | All default config values, departments, locations, holidays, competencies |
vercel.json | Vercel deployment config |
tsconfig.json | TypeScript configuration |
Key Files Reference
| File | Purpose |
src/App.tsx | State-based routing, auth check, subscription guard |
src/layouts/MainLayout.tsx | Sidebar + header + content + mobile nav |
src/components/Sidebar.tsx | Role-filtered sidebar menu |
src/types.ts | All TypeScript entity interfaces |
src/constants.tsx | All default configuration values |
src/config/database.ts | Supabase URL resolution |
src/context/AuthContext.tsx | Authentication state management |
src/context/SubscriptionContext.tsx | Subscription state + access control |
src/context/ThemeContext.tsx | Theme management (13+ themes, dark mode) |
src/services/hrService.ts | Unified service facade |
src/services/api.client.ts | Supabase client + event bus |
src/hooks/attendance/useCamera.ts | Camera hook (live stream + file-input fallback) |
src/hooks/attendance/useGeoLocation.ts | Location hook (browser geolocation + OSM geocoding) |
src/components/ErrorBoundary.tsx | Error boundary for native features |
src/services/supabase.ts | Supabase client SDK + auth + storage helpers |
supabase/functions/ | Edge Functions (auth, cron jobs, notifications, admin operations) |
supabase/migrations/ | Database schema migrations |
Git Workflow — MUST FOLLOW
After completing any code changes:
- Stage the changed files:
git add <specific files>(never usegit add .orgit add -A) - Commit with a descriptive message:
git commit -m "description of changes" - Push to the current branch:
git push origin <current-branch>
Always push immediately after committing. Never leave unpushed commits.
Pre-Commit Checklist
- Camera and location tested on real iOS Safari + Android Chrome (and PWA standalone) — not just desktop
- Permission-denied UI shows readable messages
- Lighthouse PWA score > 90
- No hardcoded credentials, API keys, or Supabase URLs
- All notification hooks intact (leave, attendance, review)
- Edge Functions deployed via
supabase functions deploy
Debugging
# Test camera/location on a phone against the dev server:
# 1. Start dev: npm run dev (Vite serves on port 3000)
# 2. Expose via HTTPS tunnel (ngrok / cloudflared / Vite + cert)
# 3. Open the tunnel URL on the phone — getUserMedia / geolocation
# require HTTPS (or localhost) to work.
# Check Supabase Edge Function logs
# Use: supabase functions logs --project-ref <ref>Frozen Modules — Change-Control MUST FOLLOW
Two features — login-session stability and the attendance check-in/out lifecycle — have regressed three times during unrelated refactors. The logic that owns those features is now isolated into dedicated, single- responsibility modules. Every edit to any file in this list is a FROZEN change and requires ALL of the following, no exceptions:
- Enter plan mode first (
EnterPlanMode). No direct edits. - Get explicit user approval of the plan before executing.
- State in the plan which frozen file is being touched and why.
- Add or update a regression check — unit test when the test framework lands, or a documented manual verification in the commit message until then.
- Update
src/data/changelog.tswith afixorchangeentry. - Never bypass hooks or skip validation on the commit
(
--no-verifyis forbidden).
Frozen files
src/services/session/sessionManager.tssrc/services/session/sessionManager.types.tssrc/services/workday/workdaySessionManager.tssrc/services/workday/workdaySessionManager.types.tssrc/context/AuthContext.tsx— delegation layer only, do not move session logic back into it
Invariants (a violation is a bug)
- Only
sessionManager.tsmay callsupabase.auth.signOut(). The one tolerated exception isauth.service.ts: the post-login unverified-account clear (which runs before the user is considered logged in). Every other call site is a regression and must route throughsessionManager.forceLogout(reason). - A transient network error MUST NOT log users out. The retry +
classification logic in
sessionManager.tsis load-bearing; do not replace it with a single-shot refresh. - Only
workdaySessionManager.tsmay mutatecheck_outfrom the client as a "system auto-close". User-initiated check-outs go throughattendanceService.updateAttendance(unchanged). The remark appended for client fallback closures is" [System: Auto-closed — no check-out recorded]"— keep it distinguishable from the server cron remark (" [System: Auto-Closed Past Date]"/" [System: Max Time Reached]"). getActiveAttendanceMUST delegate toworkdaySessionManager.reconcileOpenSessions— do not add a parallel implementation that reads attendance and decides closure rules.- The
cron-auto-close-sessionsEdge Function MUST be deployed and the pg_cron schedule that invokes it MUST remain active. This is the server-side counterpart to the client-side fallback inworkdaySessionManager.ts. workdaySessionManagerMUST NOT close today's session. Same-day max-time closure is owned by the server cron; a client-side same-day close would race the cron and double-close.
Deployment checklist for session/attendance changes
Before shipping any change touching frozen files:
- Manually verified: login does NOT log out on flaky network — set DevTools → Network → Offline for ~60 s, return to Online, session must survive; a "Reconnecting…" UI banner is acceptable but a redirect to login is a regression.
- Manually verified: hard 401 DOES log the user out (invalidate the token server-side or force a password change mid-session).
- Manually verified: create an attendance record dated yesterday with
empty
check_outfor a test employee. Log in as that employee. The record must be updated withcheck_outpopulated and remarks appended; a one-time toast must appear. The UI must NOT show an "active session" card for yesterday. - Confirmed
cron-auto-close-sessionsEdge Function is deployed and the function log shows successful runs on the expected cadence. - Commit message documents which frozen file was touched and the manual verification performed.
Past incidents to learn from
- Incident 1 & 2 (see
src/data/changelog.ts2026-04-13): auto-logout after 1–2 days; PWA service-worker update caused logouts. Both were caused by refactors that did not preserve the token-refresh contract. - Incident 3 (this change, 2026-04-18): forgotten check-outs stayed
"active" because client-side auto-close was removed and the server
cron couldn't be guaranteed deployed. Fixed by isolating the lifecycle
into
workdaySessionManager.tswith a client-side fallback.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

