Commit Graph
57 Commits
Author SHA1 Message Date
westfarn bf8f6ea1d2 Point billing clients at /monetization/ instead of /finance/.
Unit Tests / test (pull_request) Failing after 11s
Align FE with backend finance→monetization rename (api/monetization);
backend keeps /api/finance as alias only.
2026-08-04 05:36:11 -05:00
westfarn 75a0d7f637 Add RevenueCat Capacitor IAP; keep Stripe for web billing.
Unit Tests / test (pull_request) Failing after 11s
Native builds purchase/restore via RevenueCat; browser keeps Stripe
checkout/portal. Billing history shows store ledger rows from backend
webhooks. Closes #100.
2026-08-04 03:32:25 -07:00
westfarn 3858b97104 Message actions + citation Sources (#97, #98) (#101)
Deploy Beta / unit-tests (push) Successful in 11s
Unit Tests / test (push) Successful in 12s
Deploy Beta / deploy-beta (push) Failing after 2m10s
## Summary
- Closes [#97](#97) — message action row: copy (raw markdown + code-block copy), thumbs up/down with optimistic updates + down-reason popover, and export menu (PDF / DOCX / CSV / XLSX / TXT) for a single message plus conversation-level export in the chat toolbar.
- Closes [#98](#98) — versioned WS `citations` frame parsing, Sources list under assistant bubbles, clickable `[n]` markers, and history hydrate from `Prompt.citations`.
- Backend companion for ratings: [chat_backend#67](ai_ml_operations/chat_backend#67). Thumbs UI posts to `prompt_feedback` once that lands; votes rehydrate from `conversation_details.feedback`.
- Export libs (`pdfmake`, `docx`, `papaparse`, `xlsx`) are dynamically imported so they stay out of the main path until used.

## Test plan
- [ ] Stream a grounded answer → Sources appear after stream; inline `[n]` highlights the matching source; reload keeps Sources.
- [ ] Non-grounded turn → no Sources header.
- [ ] Copy message + code block; confirm checkmark ~2s; failure path shows toast.
- [ ] Thumbs up/down optimistic UI; clear by re-click; down opens reason popover without blocking the vote (needs chat_backend#67).
- [ ] Export one message and whole conversation in all five formats; check searchable PDF text and DOCX structure.
- [ ] Action row: hover reveal on desktop, always visible on last/touch; hidden while streaming.
- [ ] `npm test -- --testPathPattern='wsFrames|clipboard|exportChat|promptFeedback|ConversationDetailCard'`Reviewed-on: #101
2026-08-04 03:32:17 -07:00
westfarn 5be66dbaa7 iOS App (#99)
Deploy Beta / unit-tests (push) Successful in 11s
Unit Tests / test (push) Successful in 11s
Deploy Beta / deploy-beta (push) Successful in 2m4s
closes #21Reviewed-on: #99
2026-08-03 12:14:21 -07:00
westfarn 4501ee8f3d Docs sync progress, Personal/Company list UX, Analytics heatmap (#92–#94) (#95)
Deploy Beta / unit-tests (push) Successful in 11s
Unit Tests / test (push) Successful in 11s
Deploy Beta / deploy-beta (push) Successful in 2m0s
## Summary
- **#92** — Drive sync progress bar (determinate when total known; indeterminate while listing).
- **#93** — Documents list: Personal vs Company title, company helper copy only on company scope, Personal|Company tabs for company members, search/sort/pagination.
- **#94** — Analytics overhaul: Your activity (heatmap + volume charts) vs Company section for managers/members.

Depends on backend PR for #59/#60 + heatmap API.

## Test plan
- [x] Jest: DocumentStoragePage, Analytics, drive utils
- [ ] Manual: Sync Now shows progress N/M
- [ ] Manual: company user tabs Personal/Company; personal-only users see Personal documents only
- [ ] Manual: Analytics shows heatmap under Your activity

Closes #92
Closes #93
Closes #94Reviewed-on: #95
2026-08-02 04:50:20 -07:00
westfarn 6c96c50d99 Drive Sync now pending UX + error alerts (#90) (#91)
Deploy Beta / deploy-beta (push) Successful in 1m59s
Deploy Beta / unit-tests (push) Successful in 10s
Unit Tests / test (push) Successful in 10s
## Summary
- Closes [#90](#90)
- Depends on backend [chat_backend#57](ai_ml_operations/chat_backend#57) (202 + pending status)
- Sync now: enqueue, poll until status leaves `pending`, show **error/success alert**
- Per-connection `last_sync_error` shown when status is `error`
- OAuth green “Drive connected” banner unchanged (connect-only)
- Refreshes document list on successful sync

## Test plan
- [x] `drive.test` + `DocumentStoragePage.test`
- [ ] Manual with backend #57: Sync fails (Drive API off) → red alert with truncated error
- [ ] Manual: Sync succeeds → success alert + docs refresh
- [ ] Manual: Syncing… / button disabled while pendingReviewed-on: #91
2026-08-02 04:07:22 -07:00
westfarn d5a885f42e Mobile Conversations toggle in header + theme-aware agent bubbles (#87, #88) (#89)
Deploy Beta / unit-tests (push) Successful in 10s
Unit Tests / test (push) Successful in 10s
Deploy Beta / deploy-beta (push) Successful in 2m0s
## Summary
- Closes [#87](#87) — move mobile Conversations toggle inline beside the Hesychia logo in the header (no overlay over chat bubbles)
- Closes [#88](#88) — agent message bubbles follow light/dark theme with correct text contrast; user bubbles unchanged

## Changes
- `Header2`: optional `onOpenConversations` renders compact mobile toggle next to brand; label hides on very narrow screens to avoid crowding the nav hamburger
- `AsyncDashboard2`: wire drawer open via header callback; remove floating `MobileSidebarToggle`
- `ConversationDetailCard`: light-mode agent bubble uses light background + theme text color; dark mode keeps dark translucent bubble + light text

## Test plan
- [ ] Mobile: Conversations control appears beside Hesychia logo; opens/closes drawer as before
- [ ] Mobile: chat message text no longer obscured by floating Conversations chip
- [ ] Narrow phone width: header usable with logo + toggle + hamburger (no overflow)
- [ ] Light mode: agent bubbles light with dark text; user bubbles still gradient
- [ ] Dark mode: agent bubbles dark with light text; readability OK on long replies
- [ ] Unit: `Header2` + `ConversationDetailCard` tests passReviewed-on: #89
2026-08-02 03:39:35 -07:00
westfarn bfed056a0e Documents RAG gate + Drive connect UI (#81-#85) (#86)
Unit Tests / test (push) Successful in 11s
Deploy Beta / unit-tests (push) Successful in 10s
Deploy Beta / deploy-beta (push) Successful in 1m58s
## Summary

Companion to [chat_backend#42](ai_ml_operations/chat_backend#42).

- **#81:** Documents nav + page gated on `plan.features.rag` / `all_future_features`; upgrade CTA for Standard
- **#82:** Upload refreshes list; active toggle via PATCH; clearer company docs labeling
- **#83:** Personal Drive connect (JWT → authorize_url JSON → IdP), list/disconnect/sync/resource ids
- **#84:** Company manager knowledge-source section (`link_company_drive`)
- **#85:** Chat upgrade bubble when WS returns RAG `feature_not_allowed`

## Test plan

- [x] `npm test -- --watchAll=false` (157 OK)
- [ ] Standard plan: Documents hidden; upgrade card if navigated directly
- [ ] Founders/Pro: Documents visible; upload + active toggle
- [ ] Connect Drive (needs BE #42); banner on `?drive_connected=1`
- [ ] Company manager sees company section; member does not
- [ ] RAG-denied chat shows upgrade messageReviewed-on: #86
2026-08-01 14:01:13 -07:00
westfarn 4b685df489 Align Google/Microsoft SSO buttons with brand guidelines (#79) (#80)
Deploy Beta / unit-tests (push) Successful in 10s
Unit Tests / test (push) Successful in 11s
Deploy Beta / deploy-beta (push) Successful in 1m59s
## Summary
- Closes [#79](#79)
- Update `SsoButtons` with official Google multicolor "G" (on white) and Microsoft four-square logo
- Apply Google dark-theme button colors (`#131314` / `#8E918F` / `#E3E3E3`) and Microsoft dark button styling
- Use approved labels: `Continue with Google` / `Sign up with Google`, `Sign in with Microsoft`

## Test plan
- [ ] Sign In with Google + Microsoft OAuth enabled → both buttons show logos + correct labels
- [ ] Sign Up → Google shows "Sign up with Google"; Microsoft shows "Sign in with Microsoft"
- [ ] Click each button still starts existing OAuth redirect flow
- [ ] Dark card contrast looks correct; Google "G" remains multicolor on white
- [ ] `npm test -- --watchAll=false --testPathPattern=SignIn.test --testPathPattern=SsoButtons.test` passesReviewed-on: #80
2026-08-01 13:04:51 -07:00
westfarn 70dfa85d22 Show Beta Hesychia brand name on beta deploy (#77) (#78)
Deploy Beta / unit-tests (push) Successful in 10s
Unit Tests / test (push) Successful in 10s
Deploy Beta / deploy-beta (push) Successful in 1m56s
## Summary
- Closes [#77](#77)
- Sidenav `brandName` becomes **Beta Hesychia** when `REACT_APP_DEPLOY_ENV=beta`; otherwise stays **Hesychia**

## Test plan
- [ ] Local/default build: sidenav shows `Hesychia`
- [ ] Beta build (`.env.beta` / `REACT_APP_DEPLOY_ENV=beta`): sidenav shows `Beta Hesychia`
- [ ] Production build: sidenav still shows `Hesychia`Reviewed-on: #78
2026-08-01 12:34:26 -07:00
westfarn 19698658b1 Add subscription upgrade/change/cancel UX and account self-delete (#75) (#76)
Deploy Beta / unit-tests (push) Successful in 10s
Unit Tests / test (push) Successful in 11s
Deploy Beta / deploy-beta (push) Successful in 1m55s
## Summary
- Closes [#75](#75)
- Companion for [chat_backend#34](ai_ml_operations/chat_backend#34) (self-delete API)
- Account Billing: Upgrade / Change plan / Cancel CTAs (Stripe portal–first), plan picker when multiple public selectable plans exist, cancel confirmation with period-end messaging, complimentary users get no fake cancel
- Usage card Upgrade scrolls/focuses Billing; analytics for upgrade/change/cancel intents
- Danger Zone: email-confirmed `DELETE /user/` then logout → `/signin/`

## Test plan
- [ ] `npm test -- --watchAll=false --testPathPattern='BillingSection|DeleteAccountSection'`
- [ ] Paid Stripe user: Upgrade / Change plan / Cancel → portal (or checkout for higher selectable plan)
- [ ] Cancel confirm shows period-end access copy; scheduled cancel notice when `cancel_at_period_end`
- [ ] Backer/admin: complimentary message, no Cancel/Upgrade
- [ ] Delete account: confirm email → soft-delete → signed out at `/signin/`Reviewed-on: #76
2026-08-01 12:24:10 -07:00
westfarn 5a847b64cc Move plan/quota UI to Account; Gemini-style usage card (#73) (#74)
Deploy Beta / unit-tests (push) Successful in 10s
Unit Tests / test (push) Successful in 10s
Deploy Beta / deploy-beta (push) Successful in 1m55s
## Summary
- Closes [#73](#73)
- Remove per-message `Tokens in … · out …` under assistant bubbles
- Remove dashboard `UsageSummaryBar` (plan / prompts left / period tokens)
- Add Account **Usage limit** card (Gemini-style): plan name, prompt progress meter with rolling-window reset hint, monthly tokens meter when capped (else period in/out), upgrade hint pointing at Billing

## Test plan
- [ ] Chat dashboard: no usage bar above messages
- [ ] Assistant messages: no token footer
- [ ] Account: Usage limit card shows plan + prompt bar (+ token bar when monthly quota set)
- [ ] `npm test -- --watchAll=false --testPathPattern=ConversationDetailCard` passes

Related follow-up: [#75](#75) upgrade/change/cancel subscription.Reviewed-on: #74
2026-07-31 07:08:06 -07:00
westfarn c6bacbb23c Fix BillingSection test mock types so beta build compiles
Deploy Beta / unit-tests (push) Successful in 10s
Unit Tests / test (push) Successful in 10s
Deploy Beta / deploy-beta (push) Successful in 1m57s
Default subscription mock inferred plan as null; widen to union so
foundersSubscription can be passed. Unblocks CRA production build.
2026-07-31 06:29:45 -05:00
westfarn e89ccbbeca Show plan quotas and token usage in chat + billing UI (#72)
Deploy Beta / unit-tests (push) Successful in 11s
Unit Tests / test (push) Successful in 10s
Deploy Beta / deploy-beta (push) Failing after 1m50s
## Summary
Frontend companion to backend [#16](ai_ml_operations/chat_backend#16) / [#17](ai_ml_operations/chat_backend#17) / [#36](ai_ml_operations/chat_backend#36).

- **Token display (#16)**: assistant messages show `Tokens in … · out …`; missing usage renders as `—` (never fabricated 0).
- **Plan + quota UI (#17/#36)**: Account `BillingSection` loads `GET /finance/subscription/` (plan name, prompt remaining, period tokens). Chat dashboard `UsageSummaryBar` shows the same snapshot.
- **Backer path**: Sign-up skips Stripe checkout when `needs_checkout` is false.

Requires backend PR on `feature/plans-quotas-token-usage`.

## Test plan
- [ ] With subscribed user: usage bar + billing show plan and prompt remaining
- [ ] Assistant messages with null tokens show `—`; known counts render numbers
- [ ] Backer signup does not redirect to Stripe
- [ ] Founders signup still starts checkout
- [ ] Jest: `BillingSection`, `ConversationDetailCard`, `finance` helpers passReviewed-on: #72
2026-07-31 04:24:14 -07:00
westfarn 6a6e911ef8 Add Account Billing section + Stripe Customer Portal CTA (#33) (#71)
Deploy Beta / unit-tests (push) Successful in 10s
Unit Tests / test (push) Successful in 11s
Deploy Beta / deploy-beta (push) Successful in 1m58s
## Summary
- Closes [#33](#33)
- Add Billing glass cards on `/account/` (`Account2`): current plan summary + billing history from `GET /finance/invoices/` (and payments fallback)
- **Manage subscription** CTA → `POST /finance/portal/` → redirect to Stripe hosted Customer Portal (return URL `/account/`)
- Empty / unpaid users get **Complete payment** → Checkout instead of a dead portal button
- Visible errors for list/portal failures; fire `BILLING_PORTAL_OPENED`
- Depends on backend portal endpoint: [chat_backend#35](ai_ml_operations/chat_backend#35)

## Test plan
- [ ] `npm test -- --watchAll=false --testPathPattern='(BillingSection|finance\\.test)'`
- [ ] Signed-in user with paid invoices: plan + history render; Manage subscription redirects to portal URL
- [ ] User with no invoices: empty copy + Complete payment starts Checkout
- [ ] Portal/list API errors show alert text (no silent fail)
- [ ] Return from Stripe portal lands on `/account/`
- [ ] No card fields collected in-appReviewed-on: #71
2026-07-31 03:54:07 -07:00
westfarn 553d526862 Fix brace-expansion lock for npm 10 beta deploy (#70)
Deploy Beta / unit-tests (push) Successful in 11s
Unit Tests / test (push) Successful in 10s
Deploy Beta / deploy-beta (push) Successful in 1m57s
## Summary
- Beta deploy after #69 failed: `Cannot find module 'brace-expansion'` during `npm run build:beta`
- Root cause: `package-lock.json` linked `brace-expansion` to empty phantom paths (`minimatch/vendor/brace-expansion-compat`). npm 11 remapped them locally; deploy Node 22 / npm 10 followed the lock literally
- Declare vendored shim as a direct dependency and rewrite lock links to `vendor/brace-expansion-compat`

## Test plan
- [x] `npm ci` under Node 22.23.1 / npm 10.9.8 resolves `brace-expansion` from fork-ts-checker nested minimatch
- [x] `npx react-scripts build` with `.env.beta` succeeds
- [x] `npm audit` still 4 moderate (0 critical / 0 high)
- [ ] Redeploy `chat_web_app` beta after mergeReviewed-on: #70
2026-07-30 16:57:17 -07:00
westfarn 44f412fffa Remediate llm-fe npm audit critical/high vulnerabilities (#69)
Unit Tests / test (push) Successful in 11s
Deploy Beta / unit-tests (push) Successful in 11s
Deploy Beta / deploy-beta (push) Failing after 51s
## Summary
- Closes #53
- `npm audit` in `llm-fe`: **103 → 4** (0 critical, 0 high; 4 moderate remain)
- Applied `npm audit fix`, bumped direct floors (`axios`, `react-router-dom`), pinned `styled-components@6.1.15` for CRA typecheck stability
- Added npm `overrides` for vulnerable transitive leaves (`tar`, `postcss`, `svgo`, `sharp`, `ws`, `flatted`, etc.)
- Vendored CRA-compatible `brace-expansion@5.0.8` shim (v1 default-export API + GHSA-mh99 DoS limits)

## Remaining (documented)
- **moderate:** `react-router`/`react-router-dom` — needs v7 (breaking)
- **moderate:** `webpack-dev-server` via `react-scripts` — CRA incompatible with patched WDS 5.2.6+; needs CRA → Vite (or similar) follow-up
- Deprecation warnings from CRA/`eslint@8`/old `glob` tooling still present until toolchain migrate

## Test plan
- [x] `npm ci` in `llm-fe`
- [x] `npm audit` → 0 critical / 0 high
- [x] `npm run build`
- [x] `npm run test:ci` → 25 suites / 112 tests passedReviewed-on: #69
2026-07-29 17:41:00 -07:00
westfarn b5e16bfa6e Rename Android application ID to ai.hesychia.chat (#68)
Deploy Beta / unit-tests (push) Successful in 12s
Unit Tests / test (push) Successful in 11s
Deploy Beta / deploy-beta (push) Successful in 3m32s
## Summary
- Closes #67
- Renames Android/Capacitor identity from `com.aimloperations.chat` → `ai.hesychia.chat`
- Updates `appId`, Gradle `applicationId`/`namespace`, `MainActivity` package path, `strings.xml` scheme, and Android README

## Notes
- New application ID installs as a separate app beside any old-ID install (expected for early builds).
- App already built and run on a physical device with this identity work in progress.

## Test plan
- [ ] `npx cap sync android` after web build
- [ ] Debug install on device — package shows `ai.hesychia.chat`
- [ ] App launches and reaches login / chat
- [ ] Confirm old `com.aimloperations.chat` install (if present) is separate and can be uninstalledReviewed-on: #68
2026-07-29 11:19:20 -07:00
westfarn 235c73dda8 Point beta FE at beta.backend.hesychia.ai (#64) (#65)
Deploy Beta / unit-tests (push) Successful in 12s
Unit Tests / test (push) Successful in 12s
Deploy Beta / deploy-beta (push) Successful in 3m7s
## Summary
- Closes #64
- Beta FE was still calling `beta.chatbackend.aimloperations.com`, which no longer resolves, so login failed with Axios `ERR_NETWORK`
- Point REST/WS env URLs at the live backend: `beta.backend.hesychia.ai`

## Test plan
- [ ] Redeploy beta FE with updated `.env.beta`
- [ ] Confirm built bundle `baseURL` is `https://beta.backend.hesychia.ai/api/`
- [ ] Sign in on https://beta.hesychia.ai succeeds (no `ERR_NETWORK`)
- [ ] Chat WebSocket connects via `wss://beta.backend.hesychia.ai/ws/chat_again/`Reviewed-on: #65
2026-07-29 05:53:25 -07:00
westfarn f22441371b Surface render crashes and make chat layout viewport-safe (#61) (#63)
Deploy Beta / unit-tests (push) Successful in 13s
Unit Tests / test (push) Successful in 11s
Deploy Beta / deploy-beta (push) Successful in 3m5s
## Summary
- Closes #61
- Replaces #62, which was opened from a branch that still carried the drawer commit already merged in #60 and therefore conflicted. Same change, cherry-picked cleanly onto current `master`.
- **Makes the mobile white screen diagnosable.** The app had **no error boundary anywhere**, so any throw in the dashboard unmounted the whole tree and left an empty `#root`. That matches the reported behavior exactly: brief flash, white page, other routes fine on a fresh load, blank again when navigating back to `/`. `AppErrorBoundary` renders the error name, message, stack, URL and user agent with Reload / Copy details buttons, so the real exception can be read and copied **from the phone**. It is keyed on the route path, so navigating away clears a crash.
- **Responsive layout fixes** for the clipping visible in mobile emulation: `100vw` → `100%`, `100dvh` for the chat shell so mobile URL bars can't push the input row off screen, `min-width: 0` / `flex-shrink` on the input row so attach, model select, textarea and send compress instead of overflowing, `env(safe-area-inset-*)` padding on header, drawer and input area, and message bubbles that wrap long tokens (`overflow-wrap: anywhere`, `max-width` on `pre`/`img`/`table`).
- **Perf:** particle canvas pauses while the tab is hidden, honors `prefers-reduced-motion`, caps particle count for the O(n²) link pass, and re-seeds only on real size changes. Chat auto-scroll now fires on message change rather than on every render.

## Test plan
- [x] `npm run test:ci` — 25 suites / 112 tests pass (adds `AppErrorBoundary` coverage for the pass-through and crash paths)
- [x] `npm run build` — clean
- [ ] Phone browser: sign in and land on `/` — chat renders, or the error card shows the real exception (paste into #61)
- [ ] Phone browser: no horizontal scroll; attach, model select, textarea and send all visible
- [ ] Phone browser: input row still reachable with the keyboard open
- [ ] Long code block / unbroken string stays inside the bubble
- [ ] Desktop: sidebar, chat and input unchanged; background animation still runs
- [ ] Background the tab and return — animation resumes

## Notes
The crash is not reproducible in desktop mobile emulation, so this ships the boundary as the diagnostic path instead of guessing at the throwing call site. Once the error card appears on the phone, the stack should point straight at the cause. Worth landing before the Capacitor Android wrap (#20), since the same failure mode is much harder to inspect inside a WebView.Reviewed-on: #63
2026-07-29 05:43:16 -07:00
westfarn ea40700fd3 Improve mobile conversation drawer layering and empty state (#59) (#60)
Deploy Beta / unit-tests (push) Successful in 11s
Unit Tests / test (push) Successful in 11s
Deploy Beta / deploy-beta (push) Successful in 3m3s
## Summary
- Closes #59
- Mobile conversation drawer is now a fixed sheet with stronger stacking over dashboard content
- Adds explicit close (X) control and empty-state copy when there are no conversations
- Keeps existing close-on-select / New Chat behavior

## Test plan
- [ ] Mobile: open Conversations drawer — sheet + overlay appear above content
- [ ] Tap X or overlay — drawer closes
- [ ] Empty conversation list shows guidance text
- [ ] Select conversation / New Chat closes drawer and chat still works
- [ ] Desktop sidebar layout unchangedReviewed-on: #60
2026-07-29 05:04:33 -07:00
westfarn e6ae9d6b1e Fix mobile white screen: stop Outlet Date.now() remount loop (#54) (#56)
Deploy Beta / unit-tests (push) Successful in 12s
Unit Tests / test (push) Successful in 12s
Deploy Beta / deploy-beta (push) Successful in 3m33s
## Summary

- Follow-up for #54 (localStorage guard in #55 did not fix mobile white screen)
- Confirmed in production bundle: `ProtectedRoutes` rendered `<Outlet key={Date.now()} />`
- That remounts the entire authenticated tree on **every** parent re-render (account fetch, WebSocket connect/status, conversations, messages)
- On mobile this shows as: brief UI flash → solid white page (matches screen recording)
- Also memoize styled-components theme in `GlobalThemeWrapper` so `ParticleBackground` does not tear down/restart its canvas on unrelated re-renders

## Evidence

Production JS currently contains:
```js
e?(0,ma.jsx)(a.sv,{},Date.now()):(0,ma.jsx)(a.C5,{to:"/signin/",replace:!0})
```
i.e. authenticated → `<Outlet key={Date.now()} />`

## Test plan

- [ ] Mobile Vivaldi/Chrome: sign in on hesychia.ai → dashboard stays visible (header, conversations toggle, input)
- [ ] Pull-to-refresh while logged in → UI returns and stays
- [ ] Desktop login still works; switching conversations / WS reconnect does not blank the page
- [ ] Open mobile menu / Conversations sidebar still worksReviewed-on: #56
2026-07-29 04:04:35 -07:00
westfarn 103ca2c5e4 Fix mobile white screen when localStorage throws on access (#54) (#55)
Deploy Beta / unit-tests (push) Successful in 12s
Unit Tests / test (push) Successful in 12s
Deploy Beta / deploy-beta (push) Successful in 3m24s
## Summary

- Closes #54
- Add `getLocalStorageSafe()` helper in `tokenStorage.js` to handle browsers that expose `localStorage` but throw `SecurityError` on access
- Wrap all JWT token get/set/remove calls in try/catch so auth bootstrap no longer crashes React on mobile

## Problem

On mobile browsers, hesychia.ai flashes the UI briefly after login then goes white. Auth startup reads tokens from `localStorage` without guarding against storage access errors (common in private mode or blocked storage).

## Test plan

- [ ] Open hesychia.ai on mobile Safari/Chrome (normal mode) and sign in — dashboard should render
- [ ] Repeat in private/incognito mode — app should not white-screen (may require re-login each session if storage blocked)
- [ ] Verify existing web login/logout still works on desktop
- [ ] Run `npm test -- tokenStorage` in `llm-fe`Reviewed-on: #55
2026-07-29 03:00:04 -07:00
westfarn 799d3d591f Reject empty/whitespace chat messages before send (#52)
Deploy Beta / unit-tests (push) Successful in 12s
Unit Tests / test (push) Successful in 13s
Deploy Beta / deploy-beta (push) Successful in 2m55s
## Summary
- Closes #51
- Trim prompt Yup validation; refuse empty/whitespace in submit handlers and `sendMessage`
- Add WebSocketContext test for empty send rejection

## Test plan
- [x] `WebSocketContext.test.js` empty/whitespace send cases
- [ ] Manually confirm whitespace-only input cannot submit on desktop + mobile viewport
- [ ] Confirm normal messages still send

Related BE: https://git.aimloperations.com/ai_ml_operations/chat_backend/issues/31Reviewed-on: #52
2026-07-28 05:12:39 -07:00
westfarn 86bfbcdb6d Sign-in branding: Hesychia.ai + transparent logo (#49) (#50)
Deploy Beta / unit-tests (push) Successful in 12s
Unit Tests / test (push) Successful in 13s
Deploy Beta / deploy-beta (push) Successful in 3m12s
## Summary
Closes #49.

- Show **Hesychia.ai** wordmark with the brand mark on the sign-in page
- Regenerate brand PNGs with true transparent corners (source soft-glow RGBA had no fully clear pixels)
- Update SignIn test for the new heading

## Test plan
- [ ] Open `/signin/` — mark + **Hesychia.ai** above Sign In
- [ ] Confirm no black square around mark on dark particle background
- [ ] `npm test -- --testPathPattern=SignIn.test --watchAll=false`Reviewed-on: #50
2026-07-28 04:42:36 -07:00
westfarn ab5243abff Fix AnalyticsSession import paths for beta build (#47) (#48)
Deploy Beta / unit-tests (push) Successful in 12s
Unit Tests / test (push) Successful in 11s
Deploy Beta / deploy-beta (push) Successful in 3m0s
## Summary
- Fixes wrong relative imports in `AnalyticsSession.tsx` (`../` → `../../`) so `npm run build:beta` can resolve contexts/utils.
- Unblocks beta deploy; empty docroot was causing `https://beta.hesychia.ai/` nginx 403.

Fixes #47

## Test plan
- [ ] CI unit tests pass
- [ ] Beta deploy workflow succeeds after merge
- [ ] `https://beta.hesychia.ai/` returns 200 with the SPAReviewed-on: #48
2026-07-28 04:20:14 -07:00
westfarn ca230066f8 Ship Hesychia meander logo for rebrand (#30) (#46)
Deploy Beta / unit-tests (push) Successful in 11s
Unit Tests / test (push) Successful in 11s
Deploy Beta / deploy-beta (push) Failing after 1m49s
## Summary
Closes #30.

- Replace old infinity brand mark with the cyan Greek-key (meander) Hesychia emblem
- Update web favicons / PWA icons (`public/`), Capacitor source art (`assets/`), and regenerate Android launcher + splash densities
- Wire mark into Header / Header2, Sign In / Sign Up, and Sidenav branding

## Test plan
- [ ] Favicon + apple-touch icon show new mark in browser tab / home screen
- [ ] Header and auth screens show mark + Hesychia wordmark
- [ ] `npm run assets:generate` already run; Android launcher / splash use new art
- [ ] Old infinity artwork no longer present in `assets/` / `public/` brand slotsReviewed-on: #46
2026-07-28 03:51:21 -07:00
westfarn 347fa75534 Tianji custom event tracking (auth, billing, chat) (#36) (#45)
Deploy Beta / unit-tests (push) Successful in 12s
Unit Tests / test (push) Successful in 12s
Deploy Beta / deploy-beta (push) Failing after 1m16s
## Summary

Closes #36.

Helpers / consent gating already exist from [#42](#42). This PR adds **call sites** + docs:

- `identifyAccount` + `AnalyticsSession` (identify on session; `Logout` when auth ends)
- Auth: Sign In / Sign Up / AuthCallback (SSO) success & fail
- Billing: Checkout started, Payment Success / Canceled
- Chat: Conversation Created, Message Sent (metadata only — no prompt text)
- ToS Acknowledged
- `BILLING_PORTAL_OPENED` reserved until Account portal (#33)
- Catalog: [`llm-fe/ANALYTICS.md`](llm-fe/ANALYTICS.md)

No `chat_backend` changes required.

## Test plan

- [ ] Grant consent on beta → sign in → Tianji shows Login Success + identify
- [ ] Decline consent → same actions produce no custom events (page views still ok)
- [ ] Sign up + checkout + cancel/success return URLs fire expected events
- [ ] New chat + send message → Conversation Created / Message Sent without prompt text
- [ ] Acknowledge ToS → ToS Acknowledged
- [ ] `npm run test:ci -- --testPathPattern='analytics.test|SignIn.test|SignUp.test|AuthCallback.test'`Reviewed-on: #45
2026-07-27 08:40:19 -07:00
westfarn 1c9e04cf86 Merge pull request 'Add cookie / analytics consent banner polish (#37)' (#44) from feat/37-analytics-consent-banner into master
Deploy Beta / unit-tests (push) Successful in 14s
Deploy Beta / deploy-beta (push) Successful in 9s
Unit Tests / test (push) Successful in 12s
Reviewed-on: #44
2026-07-27 08:22:39 -07:00
westfarn 9c814dcc60 Harden analytics consent banner storage and ToS deep-link (#37)
Unit Tests / test (pull_request) Successful in 13s
Version consent in localStorage (v1 + legacy migrate), point banner at Terms analytics section, and document the always-on vs optional policy. Banner/provider shipped in #42.
2026-07-27 09:50:40 -05:00
westfarn 53236e613b Terms of Service page (public + acknowledge) (#39) (#43)
Deploy Beta / unit-tests (push) Successful in 12s
Unit Tests / test (push) Successful in 12s
Deploy Beta / deploy-beta (push) Successful in 9s
## Summary

Closes #39.

- Shared `TermsOfServiceDocument` used by public + acknowledge flows
- `/terms_of_service/` reachable without auth; `/legal/terms-of-service` alias
- Expanded clauses including **Analytics and Cookies** (always-on page views vs consent-gated events)
- Acknowledge still posts `/user/acknowledge_tos/` when signed in
- Links from Sign In, Sign Up, and Footer

## Test plan

- [ ] Visit `/terms_of_service/` logged out — document renders, no Acknowledge
- [ ] Visit `/legal/terms-of-service` — same public content
- [ ] Sign in as user needing ToS — Acknowledge posts and navigates home
- [ ] Confirm Sign In / Sign Up / Footer / consent banner link to ToS
- [ ] `npm run test:ci -- --testPathPattern='TermsOfService|Footer'`Reviewed-on: #43
2026-07-27 07:49:40 -07:00
westfarn 966ad7aba4 Enable beta auto-deploy + Tianji beta ID / consent-gated events (#35) (#42)
Deploy Beta / unit-tests (push) Successful in 13s
Unit Tests / test (push) Successful in 12s
Deploy Beta / deploy-beta (push) Successful in 9s
## Summary

Closes #35.

- **Flip deploy workflows** (mirror `dta_webapp`): push/merge to `master` → auto-deploy **beta**; **Deploy Prod** is `workflow_dispatch` only
- **Tianji**: `REACT_APP_TIANJI_WEBSITE_ID` + `REACT_APP_DEPLOY_ENV` in `.env.production` / `.env.beta`; Tracker loads page views always on prod/beta
- **Consent policy**: page views always live; custom events / identify gated via `analyticsConsent` + `AnalyticsConsentBanner` + `trackEvent`/`identifyUser` helpers (call sites remain #36)
- Remove invalid Tianji `<script>` from `index.tsx` (Tracker component owns injection)
- README documents beta auto / prod button + Tianji policy

## Ops note — beta Tianji website ID

Prod ID unchanged: `cm7x7m52m03kbddswbswrt17y`.

`.env.beta` has `REACT_APP_TIANJI_WEBSITE_ID=` empty until a **Hesychia Beta** website is created in Tianji (workspace `cm7w8087y020lddswyhamadj2`). Paste the new id into `.env.beta` before beta page views show under a distinct site.

## Test plan

- [x] `npm run test:ci` (106 tests)
- [ ] Create Hesychia Beta Tianji website; set `REACT_APP_TIANJI_WEBSITE_ID` in `.env.beta`
- [ ] Merge to master → Deploy Beta runs; prod does **not** auto-deploy
- [ ] Manual Run workflow on Deploy Prod still works
- [ ] Beta build hits `beta.chatbackend` REST/WS; static root `/var/www/beta.chat.aimloperations/html` (8083)
- [ ] Prod/beta: tracker.js loads without accepting consent; banner shows until Accept/Decline; `trackEvent` only fires after AcceptReviewed-on: #42
2026-07-27 06:54:19 -07:00
westfarn 28a805404a Add Google/Microsoft SSO buttons and OAuth callback flow (#24) (#41)
Unit Tests / test (push) Successful in 12s
## Summary
- Frontend half of ai_ml_operations/chat_backend#24
- SSO buttons on Sign In / Sign Up (shown when `/public/settings/` reports provider configured)
- New `/auth/callback/` route stores JWTs, loads account, sends new SSO users through Stripe Checkout
- Error states for denied consent, unverified/missing email, link conflict, etc.
- README note on Capacitor / native redirect URI limits

## Pair with
- Backend PR: `chat_backend` branch `feature/sso-oauth-24`

## Test plan
- [ ] `npm test -- --watchAll=false --testPathPattern="SignIn.test|SignUp.test|AuthCallback.test"`
- [ ] With backend OAuth configured, Continue with Google/Microsoft from Sign In works
- [ ] First-time SSO register lands in Stripe Checkout when `needs_checkout=1`
- [ ] Existing linked user signs in and reaches app / TOS
- [ ] Error query (`email_unverified`, `access_denied`) shows message + back linkReviewed-on: #41
2026-07-27 05:14:24 -07:00
westfarn 400549268c Fix password reset UI (pairs with backend #1) (#40)
Unit Tests / test (push) Successful in 12s
## Summary
- Pair with chat_backend password reset (#1)
- Fix forgot-password request: execute invisible reCAPTCHA, POST `user/reset_password/` with await, correct `/signin/` back link
- Restyle confirmation + set-password pages to match Sign In glass UI
- Set-password: validate link via GET, await POST, enforce ≥8 chars + number + special char
- Sign In “Forgot Password?” navigates to `/password_reset/`

## Test plan
- [ ] `npm test -- --watchAll=false --testPathPattern=PasswordReset.test`
- [ ] From Sign In → Forgot Password → submit email → confirmation page
- [ ] Open email link `/set_password/?slug=…` → set password → redirected to Sign In
- [ ] Invalid/expired slug redirects to Sign In
- [ ] End-to-end with backend `feature/password-reset-1`Reviewed-on: #40
2026-07-27 04:42:36 -07:00
westfarn 1e660c56a8 Add self-serve sign-up + Stripe Checkout (#31) (#34)
Unit Tests / test (push) Successful in 11s
## Summary
- Closes #31
- Public `/signup/` page (Sign In–matched UI): register → JWT → `POST /api/finance/checkout/` → redirect to Stripe hosted Checkout
- `/billing/success` and `/billing/cancel` return URLs
- Sign In ↔ Sign Up links; Sign Up link only when backend `enable_account_registration` is true

Depends on backend PR: registration flag + public settings + gated `/user/create/`

## Test plan
- [ ] `cd llm-fe && CI=true npm run test:ci -- --testPathPattern='SignIn|SignUp'`
- [ ] With registration disabled: `/signup/` shows unavailable; Sign In has no Sign up link
- [ ] With registration enabled: form validates, happy path redirects to Checkout URL
- [ ] Cancel return explains retry; success prompts continue / sign-inReviewed-on: #34
2026-07-27 04:20:20 -07:00
westfarn a4a28ef13e Ship Android app by wrapping the web build with Capacitor (#20) (#28)
Unit Tests / test (push) Successful in 11s
## Summary
- Closes #20
- Add Capacitor 7 to `llm-fe/` (`capacitor.config.ts`, appId `com.aimloperations.chat`, `webDir: build`) and commit the generated `android/` project
- npm scripts: `build:mobile` (`.env.mobile` + CRA build + `cap sync`), `android:open`, `android:sync`, `assets:generate`
- `.env.mobile` defaults to prod backend; override independently of web deploys
- Native chrome: Android back button (history / exit at root), status bar + keyboard resize, safe-area CSS; Preferences registered for JWT mirror (#22)
- Icons/splash via `@capacitor/assets`; signing via optional `keystore.properties`; docs in `llm-fe/ANDROID.md` + root README

Blockers #22 / #23 / #24 already on master.

## Test plan
- [x] `npm run test:ci` (79 tests)
- [x] `npm run build` + `npx cap add android` / `cap sync`
- [ ] `npm run build:mobile` + open in Android Studio on a machine with SDK
- [ ] Emulator/device QA: login, chat stream, theme, back button, keyboard/safe-area, WS resume
- [ ] Generate upload keystore outside repo; `./gradlew bundleRelease` for internal testing trackReviewed-on: #28
2026-07-26 17:12:48 -07:00
westfarn b7f23eb16c Rebrand product to Hesychia (hesychia.ai) (#29) (#32)
Unit Tests / test (push) Successful in 10s
## Summary
- Closes #29
- Rename user-facing product from AIML Operations chat to **Hesychia** (headers, sidenav brand, footer, ToS welcome, sample page)
- Update page metadata (`title`, description, Open Graph, `manifest.json` app name)
- Point README / env comments at **hesychia.ai**; keep live API hosts and deploy webroots until infra cutover

## Android display name
Capacitor tree is not on `master` yet ([#28](#28)). Display name / `appName` → **Hesychia** pushed on `ship-android-capacitor-20` so it lands with that wrap. Package id stays `com.aimloperations.chat` (Play identity; rename later if desired).

## Out of scope (per issue)
- New logo artwork (#30)
- Backend system-prompt identity (`chat_backend` #20)

## Test plan
- [ ] Web UI shows **Hesychia** in header / sidenav / footer (no old product name)
- [ ] Browser tab title and PWA manifest name are Hesychia
- [ ] Footer still credits AI ML Operations, LLC as developer
- [ ] `npm run test:ci` (Footer test updated)
- [ ] After #28 merges: Android launcher / activity title shows HesychiaReviewed-on: #32
2026-07-26 17:07:26 -07:00
westfarn 3162ed1f7f Make auth JWT-only for Capacitor WebView origins (#22) (#26)
Unit Tests / test (push) Successful in 10s
## Summary
- Closes #22
- Drop CSRF cookie / `js-cookie` path; axios uses JWT `Authorization` only (`withCredentials: false`)
- Unified token storage: `localStorage` sync source of truth + optional Capacitor Preferences mirror/hydrate for native shells
- Request interceptor always attaches fresh bearer token; 401 refresh + sign-in redirect use hash-safe native paths
- Companion backend PR: `ai_ml_operations/chat_backend` branch `capacitor-cors-csrf-22` (CORS/CSRF Capacitor origins)

## Test plan
- [x] Unit tests: `tokenStorage`, `nativePlatform`, `jwtHelpers`, Auth/SignIn/WebSocket (`npm run test:ci`)
- [ ] Login from Capacitor Android (`https://localhost`) and iOS (`capacitor://localhost`)
- [ ] Token refresh after access expiry; logout blacklist; password reset; 401 → sign-in
- [ ] Confirm browser build at `chat.aimloperations.com` unchanged
- [ ] Merge companion backend PR so prod CORS includes Capacitor origins when `CORS_ORIGIN_ALLOW_ALL=false`Reviewed-on: #26
2026-07-26 14:09:19 -07:00
westfarn 0fc8739d26 Make routing work from a file-served Capacitor bundle (#24) (#27)
Unit Tests / test (push) Successful in 10s
## Summary
- Closes #24
- Introduce `AppRouter` + `getAppRouter()` so Capacitor uses `HashRouter` (filesystem bundle, no nginx rewrite) while web keeps `BrowserRouter`
- Isolate platform checks in `nativePlatform` (no `Capacitor.isNativePlatform()` sprinkled through the route tree)
- Auth forced redirects (`axiosApi` → `/signin/`) use hash-safe `redirectToAppPath` on native
- Leave CRA `homepage` / absolute `PUBLIC_URL` asset paths unchanged so `/var/www/{env}.chat.aimloperations/html` deploy stays intact; HashRouter keeps document URL at the bundle root so assets resolve

## Test plan
- [x] Unit tests: `AppRouter` + `nativePlatform` (`npm run test:ci`)
- [ ] Capacitor build: open nested route (`/#/account/`), force WebView reload — no blank/404
- [ ] Browser back/forward + Android hardware back with HashRouter
- [ ] Web deploy smoke: deep link reload at `/account/` still works via nginx rewrite
- [ ] Confirm login redirects after 401 still land on sign-in (web path + native hash)Reviewed-on: #27
2026-07-26 13:46:41 -07:00
westfarn 7f16a3dca8 Harden chat WebSocket for mobile lifecycle (#23) (#25)
Unit Tests / test (push) Successful in 11s
## Summary
- Closes #23
- Add WebSocket reconnect with exponential backoff + jitter (capped attempts), heartbeat keepalives, and reconnect on browser visibility/`online` plus Capacitor `App`/`Network` plugins when present
- Refresh JWT before reconnect (coordinates with #22) so conversation refetch after a drop still works
- Mid-stream drop recovery: mark interrupted + refetch conversation; surface connecting/reconnecting/disconnected state and disable send while down

## Test plan
- [x] Unit tests: `websocketReconnect` helpers + `WebSocketProvider` reconnect/resume/send (`npm run test:ci`)
- [ ] Background app ~30s and ~10min, then resume — chat reconnects without reload
- [ ] Airplane mode on/off and cellular↔WiFi — reconnect indicator then restored send
- [ ] Drop mid-stream response — interrupted banner + conversation refetch
- [ ] Confirm nginx/`/ws/` proxy idle timeout stays above heartbeat (25s) or allows ping payloadsReviewed-on: #25
2026-07-26 13:35:39 -07:00
westfarn 2b8d8fba79 Update favicon to new logo (#19)
Unit Tests / test (push) Successful in 9s
## Summary
- Closes #18
- Replace stale `favicon.jpg` / old ICO with multi-size `favicon.ico`, PNG variants (`16x16`, `32x32`), `logo192.png` / `logo512.png`, and `apple-touch-icon.png` generated from the new brand mark
- Point `index.html` and `manifest.json` at the new assets; drop the CRA placeholder app name in the manifest

## Test plan
- [ ] Hard-refresh the app (or clear site data) and confirm the new logo appears in the browser tab
- [ ] Check DevTools Network for `favicon.ico` / PNG icons — no 404s and no requests for `favicon.jpg`
- [ ] On mobile Safari / iOS home-screen add, confirm apple-touch-icon looks correct
- [ ] Confirm PWA/manifest icons resolve to the new 192/512 assetsReviewed-on: #19
2026-07-26 04:35:22 -07:00
westfarn 45d441dcba Fix ESLint and CSS Minimizer errors blocking npm run build (#17)
Unit Tests / test (push) Successful in 10s
## Summary
- Closes #16
- Clear unused imports/bindings, empty `{}` prop patterns, `==` vs `===`, and hook dependency gaps across App, contexts, and pages
- Replace invalid `calc(3rem + unset)` in `index.css` so Css Minimizer no longer fails

## Test plan
- [x] `npm run build` in `llm-fe` succeeds (no ESLint / postcss-calc errors)
- [ ] Spot-check SignIn, dashboard, account, feedback, document storage pages still render
- [ ] Confirm WebSocket/message flows still work after MessageContext dep cleanupReviewed-on: #17
2026-07-25 04:43:21 -07:00
westfarn 5a7a4dd4eb Deploy chat_web_app via server-infra (node-static) (#15)
Unit Tests / test (push) Successful in 10s
## Summary

Implements [chat_web_app#13](#13) Part A: wire the CRA frontend into the same **node-static** deploy path as `dta_webapp` (no Docker for serving).

- `build:prod` / `build:beta` write into `/var/www/{env}.chat.aimloperations/html`
- API/WS URLs come from `REACT_APP_*` (`.env.production` / `.env.beta`) instead of hardcoded localhost
- Gitea unit tests + auto deploy-prod on `master`; deploy-beta via `workflow_dispatch`
- README documents local dev, env files, and webroot layout

Branch includes the #11 unit-test commit (`test:ci`) so CI has a green suite.

Companion server-infra branch (Part B): `issue-13-register-chat-web-app` on `ai_ml_operations/server-infra`.

## Test plan

- [ ] `cd llm-fe && npm run test:ci`
- [ ] Merge + ensure Unit Tests workflow passes on PR
- [ ] Merge server-infra `issue-13-register-chat-web-app`, then sync/pull on runner
- [ ] Redeploy web-static (or full host provision) so nginx listens on **8082**
- [ ] Manual: `server-infra/scripts/deploy.sh --app chat_web_app --env prod --ref <sha>`
- [ ] NPM: point `chat.aimloperations.com` at `adama:8082` + `roslin:8082` + `ai-server-4080:8082`
- [ ] Confirm built assets hit `https://chatbackend.aimloperations.com`Reviewed-on: #15
2026-07-25 04:34:12 -07:00
westfarn c0d83359cc Add unit tests (#11) (#14)
## Summary
- Add Jest/RTL unit tests for data models, Card, Footer, CustomTextField/PasswordField, CustomToastMessage, ConversationCard, AuthContext, and SignIn
- Remove the broken CRA `App.test.tsx` placeholder that expected "learn react"
- Add `npm run test:ci` for non-interactive CI runs

Closes #11

## Test plan
- [ ] `cd llm-fe && npm install`
- [ ] `npm run test:ci` — expect 9 suites / 32 tests passing

Reviewed-on: #14
2026-07-14 18:03:24 -07:00
westfarn 40db2495f2 Closes #10 2025-12-09 05:39:35 -06:00
westfarn caf2c6481f host of Quality of life fixes 2025-12-08 13:51:29 -06:00
westfarn 95f351c5aa final set of updates for the upgrade 2025-12-07 06:17:48 -06:00
westfarn 5c449e1036 UI Redesin! 2025-11-24 06:26:50 -06:00
westfarn 2657334e0c fixing the rebase 2025-09-24 12:02:59 -05:00
westfarn b120f85ccd update button based on state 2025-09-24 11:58:38 -05:00