Commit Graph

938 Commits

Author SHA1 Message Date
admin b9315c9f8b refactor(chat): synchronize guest chat quota updates for messages and images 2026-06-15 17:47:35 +08:00
admin 31f2433c4b refactor: auto-init guest chat quota on first read, clean up logs
- Remove unused `quotaWarningThreshold` and `warningThreshold` getter from `GuestChatQuota` DTO
- Apply get-or-init pattern in `ChatStorage.getGuestDailyChatQuota` and `getGuestTotalQuota`: when no existing value, initialize with DTO defaults (`threshold` = max per day, `totalQuotaDefault`) and return the seeded data
- Fall back to original `null` result if initialization write fails
- Consolidate logging strategy: drop per-actor trace logs in `chat-machine.ts`, keep business-decision logs in 3 assign actions, move all actor ENTRY/API/DONE chains to `chat-machine.actors.ts` and helper load logs to `chat-machine.helpers.ts`
2026-06-15 17:39:50 +08:00
admin fa694af723 docs(plan): add chat state machine refactor design
Update implementation_plan.md with a detailed refactor plan that splits
`chatInitActor` into two independent actors (`loadQuotaActor` +
`loadHistoryActor`) and redesigns the history loading flow to follow
local → network → save semantics so the UI sees local data first,
then network data.

Key changes outlined in the plan:
- Add new events: `ChatQuotaLoaded`, `ChatHistoryLocalLoaded`,
  `ChatHistoryNetworkLoaded`, `ChatHistorySyncDone`
- Remove dead-code `ChatInit` event
- Extend `ChatState` with `quotaLoaded` and `historyLoaded` flags
- Use an `always` barrier in `guestSession.initializing` and
  `userSession.initializing` so both tasks must complete before
  transitioning to `ready`
- Guest init runs `loadQuota` + `loadHistory` in parallel; non-guest
  init runs `chatWebSocket` + `loadHistory` as independent tasks

Also adds `implementation_plan` to .gitignore.
2026-06-15 17:05:32 +08:00
admin 9b28404673 refactor(chat): remove QuotaDialog and related state/effects
Drop the QuotaDialog component invocation in chat-screen along with
its useState/useEffect wiring, and delete the component files. Update
JSDoc in chat-screen and routes to reflect the removed consumer.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-15 16:24:50 +08:00
admin 1f3980d461 chore(chat): refactor chat init into separate quota and history actors
Split `chatInitActor` into `loadQuotaActor` (guest quota fetch) and `loadHistoryActor` (local → network → save sync), and add `quotaLoaded` / `historyLoaded` state flags so the UI can display loading status during the new local-first history hydration flow. Also drop the now-unused `ChatInit` event and pipe Next.js stdout/stderr to a persistent log file in the post-receive hook for easier troubleshooting.
2026-06-15 16:21:40 +08:00
admin cfc6de5a8c style(pwa-install-dialog): tune content text color and margins
Set content color to #393939 and apply 36px horizontal margin to align
with the dialog's visual rhythm.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-15 15:57:46 +08:00
admin 41dfc6094b chore: update favicon and app icons
Replace favicon.ico and PWA app icons (Icon-192.png, Icon-512.png) with updated versions.
2026-06-15 14:47:27 +08:00
admin 87edc682b4 Merge branch 'dev' into test 2026-06-15 14:26:35 +08:00
admin a1b595ca14 chore: add dev:proxy script and change start port
- Add dev:proxy script using HTTPS_PROXY for proxied local development
- Update start script to run on port 9135
2026-06-15 14:25:26 +08:00
admin 7b143ee1d2 test: trigger debug hook 2026-06-15 14:23:31 +08:00
admin 4a86e95ecf fix(githooks): restore cd-to-repo-top before NVM load
Without cd, git rev-parse --show-toplevel fails inside .git/
with 'must be run in a work tree', causing init_log_file to
write to /logs/post-receive.log (root path), and copy_env_by_branch
to fail with 'cannot stat env-example/...'.
2026-06-15 14:18:58 +08:00
admin cc75bed133 chore(githooks): simplify post-receive hook
Remove the repo top-level navigation logic and its accompanying
explanatory comments from the post-receive hook. The previous code
used `git rev-parse --absolute-git-dir` and `dirname` to determine
and `cd` into the repository's top-level directory, which is no
longer needed. The hook now starts directly with the nvm setup,
making the script leaner and easier to maintain.
2026-06-15 14:10:26 +08:00
admin 3b1ab0fc1b fix(githooks): use git rev-parse --absolute-git-dir for repo root
The $0-based dirname trick didn't work because git invokes
hooks with just the basename (e.g., 'post-receive'), not the
absolute path. Use 'git rev-parse --absolute-git-dir' instead,
which works even when CWD is inside .git/.
2026-06-15 13:07:16 +08:00
admin d3e134d247 fix(githooks): use simple NVM loading (same as .bashrc)
Replace complex pnpm-finding fallback with the same NVM loading
syntax used in ~/.bashrc. Removes the multiple candidate-path
fallback loop in favor of a clean shell snippet.
2026-06-15 13:02:46 +08:00
admin b7e048ed87 fix(githooks): derive repo top from $0 path (not --show-toplevel)
git-receive-pack may invoke hook with CWD inside .git/,
where 'git rev-parse --show-toplevel' errors with
'must be run in a work tree'. Use $(dirname $0) instead.
2026-06-15 11:51:49 +08:00
admin ca3adb0f5b chore(router): disable router proxy and re-exports by commenting out
Comment out `src/router/index.ts` and `src/router/proxy.ts` to temporarily
disable the Next.js 16 proxy (auth-driven redirects) and router re-exports.
This effectively turns off the centralized route guard logic and stops the
proxy from intercepting requests until further iteration.
2026-06-15 11:50:09 +08:00
admin 558b3a32af fix(githooks): cd to repo top + load pnpm into PATH
- cd to repo toplevel first (defensive: git-receive-pack CWD may differ)
- source nvm or directly find pnpm binary if not in PATH
- prepend pnpm's dir to PATH so build/start work

Root cause: post-receive hook was not being triggered on push.
With core.hooksPath=.githooks (relative), git-receive-pack
resolved the path incorrectly. Also pnpm wasn't in PATH during
non-interactive shell invocation.
2026-06-15 11:48:49 +08:00
admin b2170f789b abs path test 2026-06-15 11:39:20 +08:00
admin f0a5f9f7cd trace test from clone 2026-06-15 11:37:48 +08:00
admin caacc5cb83 test from local clone 2026-06-15 11:37:29 +08:00
admin 67bd1b13a2 test: after old hook delete 2026-06-15 11:37:00 +08:00
admin a18fb0f07d test: trace push 2026-06-15 11:35:41 +08:00
admin 5d1aebdfad refactor(auth): extract helpers and actors out of auth-machine
Move the file-local Helpers block (readGuestId) to auth-helpers.ts and the
Actors block (authRepo + 7 fromPromise actors) to auth-actors.ts. Public API
(authMachine, AuthEvent, AuthState, initialState, AuthMachine) is unchanged;
auth-context.tsx and the barrel index.ts need no edits.
2026-06-15 11:33:05 +08:00
admin 9c1622c6bd test: add marker to hook 2026-06-15 11:32:24 +08:00
admin 46cb0a9b9d test: marker push 4 1781494272 2026-06-15 11:31:12 +08:00
admin f5be8d558e test: marker push 3 1781494210 2026-06-15 11:30:10 +08:00
admin fe70c3748a test: marker push 1781494100 2026-06-15 11:28:20 +08:00
admin c26ba02c42 test: trigger post-receive hook 1781493924 2026-06-15 11:25:24 +08:00
admin 65891b3a8a chore(deploy): comment out version bump in deployment script 2026-06-15 10:58:22 +08:00
admin 83fdd73923 refactor(githooks): restructure post-receive hook into modular functions
Refactor the post-receive deployment hook from a linear script into
discrete functions (init_log_file, write_metadata_header,
copy_env_by_branch, run_build, stop_existing_next, launch_next) for
better readability, maintainability, and error isolation.

Key changes:
- Remove `set -e` so deploy errors don't block git push; each step
  handles its own failures (missing env, build failure
2026-06-12 19:08:25 +08:00
admin f72d1ce94f ci(deploy): branch-aware env copy and restore start output silencing
- Select env template per branch: main → .env.production, test/dev → .env.local
- Skip env copy on unknown branches with warning log
- Revert pnpm run start output to /dev/null (debugging complete)
- Reorder LOG_FILE definition before env-copy block so case branches can log
2026-06-12 18:53:30 +08:00
admin c90d2a5139 chore(env): add AUTH_SECRET for next-auth across environments
- Add per-environment AUTH_SECRET (dev/test/prod) for next-auth v4 JWT signing
- Temporarily redirect next start stdout/stderr to LOG_FILE in post-receive hook for server error debugging
2026-06-12 18:42:43 +08:00
admin 546e5f4b3d chore(githooks): rename hooks dir to .githooks and stop old next processes
Move repository-managed git hooks from `git_hooks/` to `.githooks/` to follow the conventional hidden-directory naming, and add a graceful shutdown step in `post-receive` that terminates any running `next start` / `next-server` processes (SIGTERM → wait 2s → SIGKILL → wait 1s) before relaunching, avoiding EADDRINUSE port conflicts so the freshly built code actually takes effect. README updated to reference the new path.
2026-06-12 18:24:08 +08:00
admin 8afcc40b9c fix:社交登录重定向网址错误问题 2026-06-12 18:15:58 +08:00
admin c7b02ecfb6 refactor(auth): extract NextAuth config to shared lib module
Move the NextAuth v4 configuration from the route handler
(src/app/api/auth/[...nextauth]/route.ts) into a dedicated module
(src/lib/auth/auth.ts) to establish a single source of truth. The
route file now simply re-exports the handler from the shared
module, keeping provider setup, JWT/session callbacks, and
environment variable references in one reusable location.
2026-06-12 17:56:01 +08:00
admin dbc9a0cd13 refactor(auth): inline NextAuth v4 config and simplify AuthPlatform API
- Inline NextAuth v4 handler directly in `[...nextauth]/route.ts`, removing
  the `@/lib/auth/nextauth` abstraction layer
- Add Google/Facebook providers with JWT/session callbacks that expose
  `idToken` and `accessToken` on the session for backend exchange
- Refactor `AuthPlatform` from constructor-based to static methods
  (`googleSignIn()` / `facebookSignIn()`)
- Update `auth-machine.ts` and layout comment reference to match new structure
- Align with original Dart `nextauth-helpers.{googleLogin, facebookLogin}()`
  naming and keep persistence concerns (unstorage, backend, custom cookies)
  out of scope for this iteration
2026-06-12 17:20:56 +08:00
admin 1f83171067 chore: add logs directory to gitignore
Add logs/ to .gitignore to prevent log files from being tracked in version control.
2026-06-12 16:57:22 +08:00
admin 8ecdb85543 fix(hook): update post-receive script to handle build and start processes with logging 2026-06-12 16:47:19 +08:00
admin ea339bf621 fix:删除错误配置的代码 2026-06-12 16:43:29 +08:00
admin b36bb2c36b fix(user): make lastMessageAt nullable to handle new backend response 2026-06-12 16:28:33 +08:00
admin 7bc21c1864 chore(auth): add debug logging to guest login flow
Add console.log instrumentation across the guest login pipeline (auth-machine, authRepository, authApi) to trace request lifecycle and surface Zod parsing failures with detailed issue info. Useful for diagnosing lastMessageAt schema mismatches.
2026-06-12 16:21:21 +08:00
admin 4c9fd23b4f chore(release): update worktree paths to match new directory structure
Update WORKTREE_PATH in pre_release_web.sh and release_web.sh to reference the new frontend subdirectory location, aligning scripts with the current project folder structure.
2026-06-12 16:01:09 +08:00
admin a48a380cf7 fix(release): use absolute paths and add error handling in release scripts
- Add error handling to `cd` command to exit with a clear message if the worktree directory is missing
- Change relative `cp` source/destination paths to absolute paths prefixed with `$WORKTREE_PATH`, ensuring files are always read from and written to the intended worktree regardless of the current working directory
- Update inline comments to reflect the new absolute-path behavior in both `pre_release_web.sh` and `release_web.sh`
2026-06-12 15:59:52 +08:00
admin 0660b90809 fix:无法设置token的问题 2026-06-12 15:55:50 +08:00
admin 513b6ac116 fix:返回消息的时间戳错误问题 2026-06-12 15:19:50 +08:00
admin d76b048bb9 chore: move env examples to env-example/ and unify CDN env source
- Reorganize env example files into a dedicated env-example/ directory for clarity
- Update .gitignore to ignore env files (with examples now in env-example/)
- Unify CDN credentials (CF_ZONE_ID / CF_API_TOKEN) to be sourced from .env.local in both test and production deploys
- Update git_hooks/post-receive to copy production env example from new location
- Update deploy scripts (pre_release_web.sh, release_web.sh) to copy the appropriate env example into .env.local before building
- Update _deploy_lib.sh purge_cdn_cache to source from .env.local instead of .env
2026-06-12 15:05:37 +08:00
admin 05674264b8 chore(release): update worktree paths and remove obsolete comments
Update WORKTREE_PATH in release scripts to include "nextjs" prefix in directory names (cozsweet-nextjs-test and cozsweet-nextjs-main) and remove outdated comment blocks from both pre_release_web.sh and release_web.sh.
2026-06-12 14:42:43 +08:00
admin 4fa1ddf22f chore(hooks): copy env example to production env in post-receive
Add preparation step for production environment variables by copying
.env.production.example to .env.production before running build:start,
ensuring required environment variables are available on deployment.
2026-06-12 14:40:07 +08:00
admin c39a8f5f80 refactor(deploy): parameterize git remote in deploy scripts
Replace hardcoded GIT_REMOTE variable with a function parameter so the
shared deploy library can push to either the production or test remote
from the same script. Rename push_to_server to push_to_remote and update
both deploy_web.sh and deploy_web_test.sh to pass the appropriate remote.
2026-06-12 14:39:09 +08:00
admin e2abe03a33 chore: reorganize icons for environment-specific deployment
Move environment-specific icons into dedicated directories (icons/develop, icons/test, icons/production) and update release scripts to copy the appropriate icon set (favicon.ico, Icon-192.png, Icon-512.png) into public/ for each target environment. Update manifest.json to reference the new /images/icons/ path.
2026-06-12 14:33:37 +08:00