Repository navigation
fix(web): centralize CSR route readiness and preserve initialization behavior - #2
Merged
Merged
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The centralized gate preserves SSR and navigation behavior, with focused coverage for the affected initialization paths.
0 open findings
What changed in this PR
Centralizes initial CSR route-readiness gating for labring#7829 while preserving SSR, navigation state, i18n loading, and marketing attribution behavior.
Changes:
- Adds a one-time route-readiness gate around CSR application initialization.
- Removes redundant page-level readiness checks and adds SSR namespace loading.
- Restores referrer-based attribution and expands targeted tests/documentation.
| File | Description |
|---|---|
projects/app/src/web/context/ClientRouteReadyGate.tsx |
Adds the one-time CSR readiness gate. |
projects/app/src/web/context/AppShell.tsx |
Applies the gate around CSR content. |
projects/app/src/web/context/useInitApp.ts |
Restores referrer attribution fallback. |
projects/app/src/pages/dashboard/create/index.tsx |
Removes the local readiness wrapper. |
projects/app/src/pageComponents/dataset/list/context.tsx |
Removes redundant router readiness guards. |
projects/app/src/pageComponents/dashboard/skill/context.tsx |
Removes redundant router readiness guards. |
projects/app/src/pageComponents/dashboard/agent/context.tsx |
Removes redundant router readiness guards. |
packages/web/hooks/useSafeTranslation.ts |
Supports explicit namespace loading. |
projects/app/src/pageComponents/account/team/MemberNameForm/useMemberNameForm.ts |
Declares the team namespace. |
projects/app/src/pageComponents/account/team/MemberNameForm/index.tsx |
Declares the team namespace. |
projects/app/src/components/Layout/ForceMemberNameModal.tsx |
Declares the team namespace. |
projects/app/test/web/context/ClientRouteReadyGate.test.ts |
Tests gate hydration and navigation behavior. |
projects/app/test/web/context/AppShell.test.ts |
Tests application initialization ordering. |
projects/app/test/web/context/useInitApp.test.ts |
Tests marketing initialization behavior. |
projects/app/test/web/support/marketing/utils.test.ts |
Tests referrer fallback. |
packages/web/test/i18n/useSafeTranslation.test.ts |
Tests namespace loading and translation behavior. |
.agents/design/common/client-i18n-csr-migration.md |
Documents the updated CSR/SSR conventions. |
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
本 PR 基于
fix/i18n,用于补充修复 labring#7829,作者合并后即可更新原 PR。CSR 首次 hydration 时,路由 query 尚未就绪,列表请求和表单初始化可能读取到缺失的参数。现在在 AppShell 中统一等待路由首次就绪,再挂载 AppContent、Layout 和页面,移除三个列表 Context 中重复的
disabled: !router.isReady以及创建页的局部等待包装。门禁仅在首次启动时等待,开启后不再关闭,因此后续路由变化不会因这个门禁卸载业务组件、额外丢失编辑状态或新增白屏。正常跨页面导航仍遵循 Next.js 原有的挂载和卸载行为;SSR 页面直接放行,原有 i18n 资源加载等待仍保留。
另外修复两处 CSR 迁移后的兼容问题:
/chat和/chat/share的 SSR namespace 声明补上account_team,将全局 Layout 强制成员名弹窗所需的资源随页面 props 注入,避免裸显翻译 key。组件继续使用无参数useSafeTranslation(),无需新增组件级加载接口。sourceDomain时仍调用营销归因 helper,恢复document.referrer兜底及首次来源锁定行为。同步更新现有 CSR i18n 设计文档,说明首屏门禁、后续导航及 SSR 页面资源声明约定。
验证:
serverSideTranslations,验证四种语言的 SSR 资源均包含成员名标题、占位文案、按钮及校验文案(8 种页面/语言组合)。watch警告保留。git diff --check通过。未运行全量测试或生产构建。