admin
5f34dbb644
feat(capa): add CapaOwnerNotesForm component
2026-07-23 11:57:43 +08:00
admin and Claude Sonnet 4.6
71cf90e1de
feat(capa): add Close CAPA button for HSE after verification
...
Verified CAPAs now show a Close button on the detail page for
HSE/admin, transitioning status to closed.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
2026-07-23 11:41:56 +08:00
admin and Claude Sonnet 4.6
0e479b648f
fix(auth,capa): restore auth callback, fix CAPA status update
...
- auth callback: remove debug redirect, handle both code (PKCE) and
token_hash+type (recovery/magic link) flows correctly
- capa PATCH: use admin client to bypass RLS for status updates
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01WMymkhHZiaYZtUeH9MEHZQ
2026-07-22 19:43:38 +08:00
admin and Claude Sonnet 4.6
4fbab33de4
fix(auth): add forgot/reset to public routes, use Link for basePath, add session guard
...
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01WMymkhHZiaYZtUeH9MEHZQ
2026-07-21 22:36:53 +08:00
admin
4d7ab5d7da
feat(auth): add forgot password link to login form
2026-07-21 22:28:26 +08:00
admin and Claude Sonnet 4.6
33d4dd4b27
feat(admin): remove invite-by-email, direct-add only
...
Strips invite-by-email mode from admin user management UI and API.
POST /api/admin/users now always requires password parameter for
direct user creation. Removes mode toggle, conditional password field,
and invite logic branches. Simplifies user creation flow to single path.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01RkCfBY9L5y3SZ6uaKZzLCV
2026-07-18 17:48:26 +08:00
admin and Claude Sonnet 4.6
e30d583947
feat: split alcohol and urine test into separate fields
...
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
2026-07-17 19:08:27 +08:00
admin and Claude Sonnet 4.6
e949016bd4
feat(admin): add users directly with admin-set password + phone field
...
- POST /api/admin/users: if password supplied → createUser (instant, email_confirm:true); else inviteUserByEmail (existing flow)
- password validated ≥8 chars; never logged in audit_log
- profile update now also saves phone number
- UI: mode toggle (Invite by email / Add directly), phone input always visible, password input shown only in 'Add directly' mode
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01CPf5Rc8QPx6V8KLEEgfKEQ
2026-07-13 16:36:20 +08:00
admin and Claude Sonnet 4.6
690485f74e
feat: delete + deactivate for sites, zones, and trucks; harden incident API error handling
...
- zones: add active column (migration 20260713000005)
- sites/zones API: PATCH (toggle active) + DELETE (blocked when incidents reference it)
- trucks API: PATCH + DELETE with same pattern
- admin page: select active for sites + zones
- site-zone-manager + truck-manager: deactivate toggle + delete button per row with busyId
- incidents API: reject reports on deactivated zone/site; wrap handler in top-level try-catch so unhandled errors return JSON (not HTML)
- report-form: parse JSON separately so HTTP status code surfaces instead of generic "Something went wrong"
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01CPf5Rc8QPx6V8KLEEgfKEQ
2026-07-13 16:05:36 +08:00
admin and Claude Sonnet 4.6
370b985375
feat(admin): truck report link + pre-fill form via ?truck_id=
...
Scanning truck QR opens /ims/report?truck_id=<id>, which pre-selects
incident_type=transport and the truck in the form. TruckManager shows
"Report link / QR target" per truck, mirroring zones.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01CPf5Rc8QPx6V8KLEEgfKEQ
2026-07-13 11:49:56 +08:00
admin and Claude Sonnet 4.6
f90bf4ed03
feat: transport incidents with truck number support
...
- DB: trucks table + incidents.truck_id FK + transport enum value
- Validation: transport type requires truck_id
- Create API: validates truck exists/active, persists truck_id
- Report form: truck dropdown shown when type=transport (required)
- Admin: TruckManager CRUD + /api/admin/trucks route
- Detail: trucks join surfaced in incident-detail + detail page query
- Inbox (HSE + supervisor): truck filter, transport in TYPE_OPTIONS,
fixed stale enum values (dropped dangerous_occurrence/mhe_asset/occupational_disease)
- List: transport label + truck number badge in rows
- i18n: transport + truckLabel/truckPlaceholder in en/ms/zh
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01CPf5Rc8QPx6V8KLEEgfKEQ
2026-07-13 10:56:07 +08:00
admin and Claude Sonnet 4.6
5416929cab
feat: show investigation panel on incident detail page
...
Fetches investigation record (5-Why steps, findings, root cause,
alcohol test, witness refs) and renders below incident details.
Shows completion status and investigator name.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01CPf5Rc8QPx6V8KLEEgfKEQ
2026-07-13 10:15:08 +08:00
admin and Claude Sonnet 4.6
8a9416abb9
fix: lower sidebar breakpoint from md to sm so desktop sidebar renders
...
Responsive variants (md:flex, md:hidden) were silently missing from the
Tailwind CSS bundle due to stale build cache — sidebar was always hidden.
Changed breakpoint to sm (640px) and use rm -rf .next before builds.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01CPf5Rc8QPx6V8KLEEgfKEQ
2026-07-13 09:57:29 +08:00
admin and Claude Sonnet 4.6
d10c690c12
feat: switch embeddings from Voyage AI to Google Gemini text-embedding-004
...
- embedText: call Gemini REST API (768-dim) instead of Voyage (1024-dim)
- Migration: drop+recreate incidents.embedding as vector(768), update
match_incidents function, swap VOYAGE_API_KEY → GOOGLE_AI_API_KEY in app_settings
- Settings UI: relabel to "Google AI API Key (Embeddings)"
- All call sites updated (incidents POST, similar GET)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01CPf5Rc8QPx6V8KLEEgfKEQ
2026-07-13 06:50:35 +08:00
admin
3776bc20b3
fix: rename Anthropic→DeepSeek label in settings, darken text colors
2026-07-12 22:35:02 +08:00
admin
a072ec0a3e
fix: add Settings link to admin sidebar nav
2026-07-12 22:27:00 +08:00
admin and Claude Sonnet 4.6
8061f804f7
feat: self-service change password for all roles
...
- middleware.ts: add /account to isSharedRoute so all roles can reach it
- components/account/change-password-form.tsx: re-auth with current password
then updateUser({password}) with client-side validation (length, match, diff)
- app/(protected)/account/page.tsx: dedicated account page, no role gate
- sidebar.tsx: Account link (all roles) above Logout in desktop footer
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01CPf5Rc8QPx6V8KLEEgfKEQ
2026-07-12 22:17:51 +08:00
admin
c0ec6660ef
feat: sticky incident header with top-positioned action buttons ( fix #5 )
2026-07-12 16:44:42 +08:00
admin
f6064b9580
feat: reporter clickable rows, CAPA owner action buttons, triage segmented severity
2026-07-12 16:42:49 +08:00
admin
180b0dc0a3
feat: persistent sidebar nav with role-scoped links, logout, and mobile bottom tab bar
2026-07-12 16:40:57 +08:00
admin and Claude Fable 5
576557181a
feat: Phase 5 & 6 — usability, compliance hardening, analytics
...
Phase 5 (usability + compliance):
- In-app notification bell/badge: migration 016 adds read state + per-user
RLS + create_in_app_notification SECURITY DEFINER RPC; /api/notifications;
wired into incident creation, CAPA assign/verify, escalation cron
- Incident closure: new POST /api/incidents/[id]/close (requires verification
status + all CAPAs verified); migration 017 locks closed incidents at DB
level (update/delete triggers) with append-only incident_addenda + UI panel
- Server-side pagination on HSE/supervisor incident inboxes (.range, 25/page)
- Investigation form: alcohol/urine test result + witness statement refs
(existing schema columns, now editable)
- Type-specific intake fields: migration 018 adds incidents.type_details
JSONB; whitelist validation; environmental/asset/security/fire field
groups in report form; EN/MS/ZH labels; offline queue support
- JKKP 8 annual register CSV export (/api/reports/jkkp8) + dashboard button
+ January statutory deadline banner
- Admin page: user invite (service-role client), role/site/active management,
site + zone CRUD with QR report links — replaces Phase 0 stub
- Evidence gallery thumbnails via Supabase render transform with fallback
Phase 6 (analytics):
- 12-month stacked trend chart (leading/lagging/other) + top root causes
(lib/dashboard/trends.ts pure helpers)
- AI rising-risk zones: /api/dashboard/ai/risk-flags aggregates 90-day
zone stats, claude-opus-4-8 forced tool_use, panel on HSE + management
dashboards, suggestion audit-logged
Also fixes 9 pre-existing missing /ims basePath prefixes in client fetches
and download links.
132 tests passing, tsc clean, next build clean.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01CPf5Rc8QPx6V8KLEEgfKEQ
2026-07-12 10:25:08 +08:00
admin and Claude Sonnet 4.6
e4d1da033d
fix: prefix all client-side fetch calls with /ims basePath
...
Client components were calling fetch('/api/...') without the /ims prefix,
causing 404s in production where Next.js serves under basePath: '/ims'.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01FFDuBhMKvoWjrWT3ZnGmmr
2026-07-11 21:26:18 +08:00
admin and Claude Sonnet 4.6
448ea4857a
fix: offline sync basePath prefix and stable syncNow callback
...
- fetch URL: /api/incidents → /ims/api/incidents (basePath not auto-prepended in client fetch)
- replace syncing state guard with syncingRef to give syncNow a stable reference, preventing useEffect from re-registering the online listener on every sync cycle
- keep syncing state for UI rendering only
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01FFDuBhMKvoWjrWT3ZnGmmr
2026-07-11 19:11:16 +08:00
admin
c048878600
feat: PWA offline capture — IndexedDB queue, service worker cache, auto-sync on reconnect
2026-07-11 19:07:35 +08:00
admin and Claude Sonnet 4.6
87264a5497
feat: i18n — EN/MS/ZH translations with cookie-based locale switching, report form translated
...
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01FFDuBhMKvoWjrWT3ZnGmmr
2026-07-11 19:01:44 +08:00
admin and Claude Sonnet 4.6
b9ab94c9da
feat: API key settings page — store ANTHROPIC/VOYAGE keys in DB with admin UI
...
- Migration: app_settings table with admin-only RLS (ANTHROPIC_API_KEY, VOYAGE_API_KEY)
- lib/settings.ts: getApiKey() reads DB first, falls back to env var
- lib/claude/client.ts: factory createAnthropicClient(apiKey) replaces singleton
- lib/claude/embed.ts: optional apiKey param, falls back to env
- 3 Claude AI routes + similar route: fetch key from settings before calling AI
- incidents/route.ts: fire-and-forget embed reads VOYAGE key from settings
- GET/POST /api/settings: admin-only masked key management endpoint
- /hse/settings page + ApiKeyForm client component
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01FFDuBhMKvoWjrWT3ZnGmmr
2026-07-11 17:46:40 +08:00
admin and Claude Sonnet 4.6
10e71969dd
feat: AI RCA draft assistant in investigation form
...
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01FFDuBhMKvoWjrWT3ZnGmmr
2026-07-11 16:35:12 +08:00
admin and Claude Sonnet 4.6
547cc6e817
feat: pgvector similar-incident retrieval + SimilarIncidentsPanel
...
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01FFDuBhMKvoWjrWT3ZnGmmr
2026-07-11 16:31:02 +08:00
admin and Claude Sonnet 4.6
f10fa071f9
feat: AI triage suggestion — severity + DOSH flags pre-fill
...
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01FFDuBhMKvoWjrWT3ZnGmmr
2026-07-11 16:27:29 +08:00
admin and Claude Sonnet 4.6
3bec95aaf8
feat: AI report quality check before submission
...
Adds POST /api/incidents/ai/quality-check using Claude tool_use to score incident descriptions 1-10. Report form blocks submission when score < 6, shows amber feedback with suggestions, and offers a 'Submit anyway' override.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01FFDuBhMKvoWjrWT3ZnGmmr
2026-07-11 16:18:39 +08:00
admin and Claude Opus 4.8
804b1fbf33
feat: verification flow — HSE verify/reopen CAPA, auto-transition incident to verification
...
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01FFDuBhMKvoWjrWT3ZnGmmr
2026-07-11 15:18:17 +08:00
admin and Claude Opus 4.8
1780586185
feat: CAPA board — kanban/table view, create CAPA from incident, status tracking
...
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01FFDuBhMKvoWjrWT3ZnGmmr
2026-07-11 15:16:49 +08:00
admin and Claude Opus 4.8
63cb28f520
feat: investigation workspace — 5-Why/fishbone RCA, transitions triaged→investigating→capa_pending
...
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01FFDuBhMKvoWjrWT3ZnGmmr
2026-07-11 15:14:27 +08:00
admin and Claude Opus 4.8
e55c5284a7
feat: triage panel — severity + DOSH checklist, transitions reported→triaged
...
Also excludes node_modules.nosync from tsconfig to fix pre-existing TS type check bleed.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01FFDuBhMKvoWjrWT3ZnGmmr
2026-07-11 15:12:35 +08:00
admin and Claude Sonnet 4.6
7d3f8ec757
fix: export Incident types, replace any casts with typed unknown casts
...
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01AWxyMibCuGGtSQSqfajDQ7
2026-07-11 07:55:26 +08:00
admin and Claude Sonnet 4.6
b281420810
feat: HSE dashboard with incident stats by type and site
...
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01AWxyMibCuGGtSQSqfajDQ7
2026-07-11 07:40:22 +08:00
admin and Claude Sonnet 4.6
713556631b
feat: incident detail page with evidence gallery for HSE and supervisor roles
...
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01AWxyMibCuGGtSQSqfajDQ7
2026-07-11 07:40:06 +08:00
admin and Claude Sonnet 4.6
2f2018f27a
feat: incident inbox pages with filter/search for HSE and supervisor roles
...
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01AWxyMibCuGGtSQSqfajDQ7
2026-07-11 07:39:43 +08:00
admin
3f8da5bd91
feat: incident report form, API route, middleware shared-route + redirect
2026-07-10 13:19:45 +08:00
admin
a40a0f7c59
fix: signed URLs for private bucket, 10MB server-side limit, safe auth destructuring
2026-07-10 12:00:52 +08:00
admin
8a9758c8a6
feat: Phase 1 foundation - incident components, storage, and migrations
2026-07-10 10:48:56 +08:00
admin and Claude Sonnet 4.6
559859470b
feat: add login page and auth callback route
...
- Replace default Next.js home with role-aware root redirect
- Add email/password login form (client component, signInWithPassword)
- Add auth callback route for Supabase code exchange
- Login page at /login, callback at /api/auth/callback
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01AWxyMibCuGGtSQSqfajDQ7
2026-07-09 22:18:21 +08:00