Commit Graph

556 Commits

Author SHA1 Message Date
admin eed0b94ece Merge branch 'dev' into test 2026-06-17 17:47:54 +08:00
admin 56b2c39ca5 fix(user): normalize last message timestamp 2026-06-17 17:47:07 +08:00
admin abbf78dc53 Merge branch 'dev' into test 2026-06-17 17:40:56 +08:00
admin 7f8e327582 chore(deploy): install dependencies before build 2026-06-17 17:40:01 +08:00
admin 4d36c25a7e Merge branch 'dev' into test 2026-06-17 17:35:38 +08:00
admin 5d66cef85c refactor(dto): move app models into dto layer 2026-06-17 17:34:55 +08:00
admin a9098d9d87 Merge branch 'dev' into test 2026-06-17 17:30:20 +08:00
admin f0b5275c55 refactor(sidebar): comment out user info section and membership option 2026-06-17 17:30:16 +08:00
admin dc57ed5c67 Merge branch 'dev' into test 2026-06-17 17:28:35 +08:00
admin 67d0bd5cd0 refactor(hooks): remove unused PWA install and visibility hooks
refactor(package): remove deprecated dev:proxy script
fix(user): ensure user-auth-sync is exported in index
2026-06-17 17:27:18 +08:00
admin 9bc208d81f Merge branch 'dev' into test 2026-06-17 17:23:48 +08:00
admin a969030f40 fix(chat): prevent guest quota reset on read failures 2026-06-17 17:22:45 +08:00
admin 42c683c63a Merge branch 'dev' into test 2026-06-17 17:11:45 +08:00
admin afba85e809 fix(auth): update routing for subscription access 2026-06-17 17:11:34 +08:00
admin d074f1a813 fix(auth): hide email option in other sign-in dialog 2026-06-17 17:07:53 +08:00
admin daccb6a60b Merge branch 'dev' into test 2026-06-17 16:59:13 +08:00
admin b34533b242 refactor(auth): use icon library for provider icons 2026-06-17 16:58:24 +08:00
admin 3940129b32 Merge branch 'dev' into test 2026-06-17 16:47:03 +08:00
admin 08d512d9d6 chore(githooks): remove pre-push hook script 2026-06-17 16:46:45 +08:00
admin 0a60175079 Merge branch 'dev' into test 2026-06-17 16:37:24 +08:00
admin a1864c2421 refactor(fonts): use woff2 athelas assets 2026-06-17 16:37:23 +08:00
admin b02305665f Merge branch 'dev' into test 2026-06-17 16:36:52 +08:00
admin 24100b128c chore(githooks): run pre release before push 2026-06-17 16:33:37 +08:00
admin 7d5ff0d96c Merge branch 'dev' into test 2026-06-17 16:20:49 +08:00
admin f39e7e0672 fix(pwa): suppress install dialog in in-app browsers 2026-06-17 16:19:21 +08:00
admin 62468ffc6a fix(theme): use next font athelas variable globally 2026-06-17 16:07:10 +08:00
admin 5c26ad9d5b refactor(splash): remove Athelas font references from CSS files 2026-06-17 16:05:20 +08:00
admin f7201fa654 fix(chat): make send button circular 2026-06-17 15:54:05 +08:00
admin a6ee0d5e24 refactor(env): centralize app environment detection 2026-06-17 15:31:15 +08:00
admin 977c0905bd refactor(chat): remove redundant auth state management from ChatScreen documentation
refactor(chat): update guest chat quota logic to use isProduction utility
fix(user): add TODO for user initialization event on login status change
2026-06-17 15:30:36 +08:00
admin b67beaeae6 refactor(auth): remove dead AuthReset event
AuthReset was declared in the AuthEvent union and handled in
auth-machine.idle.on with `assign(() => initialState)`, but
nothing in the codebase actually dispatches it anymore.

History of dispatch sites (now all gone):
- sidebar-screen.tsx previously dispatched AuthReset post-logout
  alongside router.replace(ROUTES.chat) — that was simplified to
  just dispatch AuthLogoutSubmitted, the state machine's
  loggingOut state now does the context reset itself in onDone
  via the same `assign(() => initialState)` action.
- chat-screen / splash / auth screens never dispatched it.
- The /auth screen's pendingRedirect-based redirect loop doesn't
  need it (the redirect is one-shot, not a state that needs
  resetting).

So the event handler is unreachable. Remove the type member
from auth-events.ts and the handler from auth-machine.ts.

No behavior change: the only path that 'reset auth state' was
already covered by loggingOut.onDone.

Verified via `grep -rn 'AuthReset' src/`: only 2 hits remain
after this commit — both are the type declaration and the
machine handler, which is now also gone (zero hits).
2026-06-17 15:13:44 +08:00
admin 3ad8bf061c Merge branch 'dev' into test 2026-06-17 15:07:42 +08:00
admin bda1605ce7 fix(auth): redirect to splash after logout 2026-06-17 15:07:16 +08:00
admin 22f3aabe7a Merge branch 'dev' into test 2026-06-17 14:35:38 +08:00
admin 0d2a515e51 fix(sidebar): redirect to splash screen after logout 2026-06-17 14:35:28 +08:00
admin 958ff9dd22 Merge branch 'dev' into test 2026-06-17 14:24:44 +08:00
admin 1d7d9cfbfc fix(chat): hydrate user avatar after auth restore 2026-06-17 14:23:07 +08:00
admin 287affa34a refactor(app): move route screens out of components
Exclude test and spec files from generated barrels so page imports do not load test modules at runtime.
2026-06-17 14:13:42 +08:00
admin fe690e944f Merge branch 'dev' into test 2026-06-17 13:07:20 +08:00
admin cda76a1651 fix(splash): keep login button text on one line 2026-06-17 13:06:56 +08:00
admin 374794d7f0 Merge branch 'dev' into test 2026-06-17 12:59:59 +08:00
admin c3f2f8d954 fix(sidebar): trigger logout from click 2026-06-17 12:59:48 +08:00
admin 1152491088 refactor(repositories): use barrel imports 2026-06-17 12:09:40 +08:00
admin d41b3c4473 refactor(schemas): extract nullable-default helpers to shared file
The three defensive Zod helpers (stringOrEmpty, numberOrZero,
booleanOrFalse) used by user.ts are general-purpose Zod utilities
that any schema may need — they're not user-specific. The original
inline declaration in user.ts had two downsides:

1. Any new schema (chat, auth, metrics, etc.) that needs the same
   'null | undefined → default scalar' pattern would have to
   duplicate the helper.

2. The long defensive-parse comment block (11 lines) lived inside
   user.ts and didn't explain the helpers' general purpose.

Move them to src/data/schemas/nullable-defaults.ts (top-level
sibling of auth/, chat/, metrics/, user/ subdirs) so any schema
can import them. Keep the original explanation verbatim at the
top of the new file.

Bundled in this commit:
- user.ts imports the helpers from the new file (drops 11 lines
  of comment + 3 const declarations)
- 3 auto-generated barrel index files regenerated by barrelsby
  to pick up the new exports (chat/, subscription/, stores/user/)
2026-06-17 12:05:09 +08:00
admin 312f41cdaf Merge branch 'dev' into test 2026-06-17 12:00:55 +08:00
admin 10e6c69af8 fix(pwa): prepare beforeinstallprompt listener early to avoid event loss
The previous install flow had a timing race: the
`beforeinstallprompt` event fires at unpredictable times after
page load (often ~30s+ into the session, when Chrome's heuristic
finally decides the user is engaged). If the listener was
attached only inside the dialog's onClick handler, by the time
the user clicked OK the event had already fired into the void
and the deferred prompt was null — so `install()` returned
"unavailable" every time.

The new flow attaches the listener as early as possible:

1. `pwaUtil.prepareInstallPrompt()` — new public method that
   calls the private `attachListener()`. Idempotent (guard via
   `listenersAttached`).

2. `pwaUtil.canPromptInstall()` — companion getter that returns
   whether a deferred event is currently cached. Useful for UI
   to decide whether to even show the install CTA.

3. `pwa-install-overlay.tsx` — calls `prepareInstallPrompt()`
   right after the isSupported / isInstalled guards. The overlay
   mounts when the user enters /chat, so this is the earliest
   practical point in the user flow.

4. `pwa-screen.tsx` — calls `prepareInstallPrompt()` BOTH at
   module load (synchronous, so the listener is attached before
   the splash screen's useEffects run) AND in a useEffect for
   robustness. The splash screen is the very first screen the
   user sees, so attaching here is the earliest possible.

5. `pwa-install-dialog.tsx` — `handleInstall` is now async,
   and `onInstall` accepts `() => void | Promise<void>`. The
   overlay calls `await pwaUtil.install()` so the deferred
   prompt flow can complete before the dialog unmounts.

Together: the listener is now attached from the moment the
splash screen module loads, the deferred prompt is captured
whenever Chrome decides to fire the event, and the dialog's
install button can reliably `prompt()` against the cached
deferred. The full install flow now works end-to-end.
2026-06-17 12:00:24 +08:00
admin 22d59f69c4 Merge branch 'dev' into test 2026-06-17 11:52:44 +08:00
admin c07a10ee80 refactor(splash): handle Skip redirect in splash screen, decouple SplashButton
Previously, the Skip button (guest login entry) relied on the auth
state machine's `pendingRedirect` flag to trigger the navigation
to /chat after guest login completed. That introduced a
non-obvious coupling: the button dispatched an event, the machine
ran an actor, the auth screen (or splash useEffect) saw the flag
and redirected.

This refactor moves the redirect into the splash screen itself:

- `SplashButton` now takes an `onSkip` prop and no longer knows
  about auth dispatch. Pure presentation component.
- `SplashScreen` provides `handleSkip` that dispatches the
  `AuthGuestLoginSubmitted` event AND immediately calls
  `router.replace(/chat)` for snappier perceived navigation.
- `auth-machine.ts`: `loadingGuestLogin.onDone` no longer sets
  `pendingRedirect: true` (splash already navigated). Sets
  it to `false` explicitly so other screens (auth, sidebar) that
  also react to `pendingRedirect` don't double-navigate if the
  user triggers guest login from a non-splash surface in the future.

No behavior change for the happy path: Skip → /chat works the same.
The refactor is purely about responsibility allocation and
component decoupling.
2026-06-17 11:51:35 +08:00
admin d5938ca1fb Merge branch 'dev' into test 2026-06-17 11:32:29 +08:00
admin 015ec111bd fix(pwa): rename serwist route from [[...slug]] to [path] to match Serwist's hardcoded param
The Serwist createSerwistRoute factory returns a GET handler with
`params: Promise<{ path: string }>` hardcoded. Next.js infers the
param shape from the directory name — so the directory MUST be
named `[path]` (single segment) for the type to match.

`[[...slug]]` (catch-all) was wrong on two counts:
1. The segment name is `slug`, not `path` (Serwist expects
   exactly `path`).
2. The shape is `string[]` (array), not `string` (Serwist
   expects a single string).

Per the Serwist source comment: 'Asset and chunk names must be at
the top, as our path is /serwist/[path], not /serwist/[...path]'
— all SW output files (sw.js, workbox-XXX.js) are flat, single
segment is sufficient.

The fix is a directory rename only — the route.ts content
(createSerwistRoute call) is unchanged.

Verification:
- pnpm build now succeeds (TypeScript check passes)
- The Serwist route appears in the build output as `●  /serwist/[path]`
  prerendered with `sw.js` and `sw.js.map` static pages
- `pnpm start` + Chrome: `/serwist/sw.js` will be served by the
  route handler and registered by <SerwistProvider>
2026-06-17 11:30:57 +08:00