fix(app-shell): 空态「Create Your First App」CTA 指向已声明的 app 内 create-app 路由 (#3573) - #3588
Merged
Conversation
…路由 (#3573) 零应用部署的第一屏上,唯一指向「建应用」的 CTA 调用 navigate('/create-app') —— 带前导斜杠的绝对路径,从宿主的根路由树解析。根路由树没有声明 /create-app,于是落到 末尾的 <Route path="*"> 兜底,被 replace 回落地页 `/`:按钮看起来毫无反应。 真正声明 create-app 的是 AppContent 自己,位于 /apps/:appName/* 子树内(无 activeApp 分支与有 app 的路由表各一处)。改为构造 app 作用域的 /apps/<segment>/create-app —— ADR-0048 的规范应用 URL,也正是 AppSidebar 的 add-app 入口已经在用的同一目标。 实测记录(新增路由测试逐条钉住): - 空态的真实 URL 家族是 /apps/setup 及其子路径。空态前置条件要求 !activeApp 且 非 create-app/system/metadata 三条伪路由;要绕过 requestedAppMissing 又必须 isSpecialRoute,相减后只剩 isSetupRoute。零应用用户从 `/` 会被 RootLandingRedirect 送到 /home,AppContent 根本不挂载 —— 空态只在子树内出现。 - 因此「改成相对跳转 navigate('create-app')」不成立:装机的 react-router 7 里 getResolveToMatches 用 LEAF match 的完整 pathname(含 splat)作为相对解析基 (v6 的 v7_relativeSplatPath 开关,v7 已固化)。它只在最浅的 /apps/setup 正确, 从 /apps/setup/<segment> 会拼出 /apps/setup/<segment>/create-app —— 匹配不到 任何路由,渲染成白屏,比原来的弹回更难诊断。 反向验证:两条 CTA 测试在未改的源码上先跑红(dump 里 pathname 为 `/`、 root-landing 已渲染),改后 6/6 全绿。旁边的 go-to-settings-btn 未触及, 其绝对 /apps/setup 目标另有一条测试守住。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GTRjn8xBqp75dk7kFupVRt
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
该断言原本的注释读起来像在背书 `/apps/setup` 这个目标。实测下来裸 `/apps/setup` 正是空态自己的 URL(isSystemRoute 需要 `/system` 段), 零应用部署下这颗按钮同样是死键 —— 已另立 #3590。此处只用于证明 #3573 的改动没碰它,修 #3590 时应一并更新。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GTRjn8xBqp75dk7kFupVRt
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
yinlianghui
marked this pull request as ready for review
August 7, 2026 14:58
This was referenced Aug 7, 2026
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.
Fixes #3573
问题
零应用部署的第一屏上,唯一指向「建应用」的 CTA(
create-first-app-btn)调用navigate('/create-app')—— 带前导斜杠的绝对路径,从宿主的根路由树解析。apps/console/src/App.tsx的根路由树没有声明/create-app,于是落到末尾的兜底path="*"被replace回落地页/。用户看到的是「按钮点了没反应」,没有任何报错。真正声明
create-app的是AppContent自己,位于/apps/:appName/*子树内部(无
activeApp分支一处、有 app 的路由表一处)。实测(先量后改)
① 空态的真实 URL 家族 =
/apps/setup及其子路径。空态前置条件要求
!activeApp且不是 create-app / system / metadata 三条伪路由;要绕过上方的
requestedAppMissing分支又必须isSpecialRoute—— 相减后只剩isSetupRoute。零应用用户从/会被RootLandingRedirect解析到/home(
resolveLandingPath([])),AppContent根本不挂载。空态只在子树内出现,入口是无 activeApp 时侧边栏的系统导航(
AppSidebar的systemFallbackNavigation→
/apps/setup),以及空态自己那颗go-to-settings-btn。② 因此「改成相对跳转」不成立 —— 这是本次唯一的方案偏离,已实测证伪。
派单的首选假设是
navigate('create-app')(相对),理由是相对解析走匹配路由的pathnameBase(splat 被排除)。装机的 react-router 7.18 不是这个行为:叶子 match 贡献的是完整
pathname,含 splat(v6 时代这是v7_relativeSplatPath未来开关,v7 已固化为默认)。所以相对形式是随深度漂移的:只在最浅的
/apps/setup正确,从/apps/setup/sys_inbox_message会拼出/apps/setup/sys_inbox_message/create-app—— 匹配不到无-app 分支里的任何路由,渲染成白屏,比原来的弹回更难诊断。这一步是实跑出来的,不是推断:相对版本跑出
6 条里挂 1 条,dump 里
pathname正是/apps/setup/sys_inbox_message/create-app。改法
构造 app 作用域的
/apps/{appName}/create-app:这是 ADR-0048 的规范应用 URL(
utils/appRoute.ts),也正是AppSidebar的 add-app 入口(add-app-btn)已经在用的同一个目标,以及本文件其余约 8 处导航一致的基址。
appName在该分支上必然存在(见实测 ①:分支只在
/apps/setup…下可达)。测试
新增
packages/app-shell/src/console/__tests__/AppContent.noAppsCta.test.tsx:在
MemoryRouter里复刻宿主根路由树(含那条吃掉/create-app的兜底),在实测出的两种真实 URL 上点 CTA。
反向验证:两条 CTA 断言在未改的源码上先跑红 —— 预测是红,实际也是红,
失败 dump 里
pathname为/、root-landing已渲染,正是 issue 描述的弹回:改后 6/6 全绿。另有两条测试分别钉住「深层 splat URL 解析到同一个
/apps/setup/create-app」(② 的回归闸)和「旁边的go-to-settings-btn仍走绝对/apps/setup」(未触及共享代码的证明),以及一条把 ① 的 URL 家族结论写死的度量测试(非伪路由的
/apps/:appName走 App-not-available 分支,永远到不了这个空态)。pnpm exec vitest run packages/app-shell/→ 286 files / 2498 passed, 1 skipped, 0 failedpnpm --filter @object-ui/app-shell type-check→ exit 0pnpm exec eslint(改动两文件)→ 0 errors(37 条既有no-explicit-anywarning)node scripts/check-control-bytes.mjs→ OK范围
只动了那一行
navigate调用(加注释)+ 新测试 + changeset。未触碰apps/console/src/App.tsx的根路由(宿主契约变更),也未触碰content/docs/releases/。全仓搜索确认create-first-app-btn//create-app字面量再无其他消费方(i18n 各 locale 只有文案键)。
🤖 Generated with Claude Code
https://claude.ai/code/session_01GTRjn8xBqp75dk7kFupVRt
Generated by Claude Code