Repository navigation
fix(app-shell): metadata history Back to item opens the item under every route nesting - #29316
Merged
Merged
Conversation
…ery route nesting Outside Studio's "All metadata" area the history page built its back link as a route-relative `../NAME`, which drops the whole matched route: with an active app it landed on the `:type` list named after the item, with no app on a path at the app root, and it dropped the query. Resolve `..` against the URL path instead and keep the search, so the link opens .../metadata/TYPE/NAME with ?package= and ?scope= kept. The Studio area link is unchanged. Claude-Session: https://claude.ai/code/session_01QsR2jSipqJ9BXYCu6y2jgs Co-authored-by: Claude <noreply@anthropic.com>
A relative `..` resolved against the URL path still hands back the item name decoded, because React Router resolves against the decoded match pathname. Drop the URL's last segment from location.pathname instead, so an encoded name stays encoded. Claude-Session: https://claude.ai/code/session_01QsR2jSipqJ9BXYCu6y2jgs Co-authored-by: Claude <noreply@anthropic.com>
Contributor
Author
|
domain:ui#1 · zhuangjianguo · session_01QsR2jUJ19MstFvFhjgiYTu 席位核对 · ACCEPT · 2026-11-02T11:56ZHead-sha:
|
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.
Requested by Steedos · project thread
Fixes #28626
Clause-②: no
Metadata-protocol: none
维护者速读
history)并保留查询串,因此回到…/metadata/TYPE/NAME。../NAME相对路由解析,会丢掉整条路由:有应用时落到以条目名命名的类型列表,无应用时落到应用根下的路径,并且丢掉?package=/?scope=environment。目前在线上只有 Setup 的数据源历史页还会走到这条链接。ResourceHistoryPage.tsx一处。ui/packages/app-shell/src/views/item-tools/ResourceHistoryPage.tsx的goBackToItem;新测试ResourceHistoryPage.backToItem-28626.test.tsx。pnpm --dir ui exec vitest run packages/app-shell/src/views/item-tools/ResourceHistoryPage.backToItem-28626.test.tsx,预期 6/6 通过。What changes
MetadataResourceHistoryPagebuilt its non-area Back to item link asnavigate('../NAME'). React Router resolves that..against the matched route, not the URL, so it drops the whole matched route:/apps/:appName/*→metadata→:type/:name/history) it landed on/apps/setup/metadata/NAME, the:typeroute, which Setup then sends to Studio's list of a type named after the item;/apps/:appName/*→metadata/:type/:name/history) it landed on/apps/setup/NAME;MetadataResourceRouter(component/:ns/:name/*, type in?type=) it landed on/apps/APP/NAME;?package=,?scope=environment,?type=) was dropped every time.The non-area branch now cuts the URL's own last segment as it is spelled and keeps the query:
navigate({ pathname: pathname.replace(LAST_SEGMENT, ''), search }), where the pattern is a slash, one or more non-slash characters and an optional trailing slash at the end of the path. A relativenavigate({ pathname: '..', search }, { relative: 'path' })was tried first and dropped: the router resolves it against the decoded match pathname, so an encoded name came back decoded (sales%20db→sales db). The encoded-name test row pins that.The Studio "All metadata" area branch (built from
areaHost.basePath) is unchanged and is the test's control row.Reach today. Since #28818 every Setup metadata route except the datasource's redirects to Studio's area, so in the Console only the datasource history page (with and without an active app) still reaches this link. The exported router is not mounted by the Console (
component/metadata/resource/*is caught byLegacyMetadataRedirect), but a host can mount it, and the fix covers it too.Tests
New
ui/packages/app-shell/src/views/item-tools/ResourceHistoryPage.backToItem-28626.test.tsx: the real page and React Router, the metadata client stubbed. Six rows: bothAppContentnestings, the query kept under both, an encoded name kept encoded, the exported router's splat with?type=, and the Studio area as control.da4f9be7: 6 passed.origin/main's page (8a8a03d3, restored from base, then restored toHEADand proven by hash and an emptygit diff HEAD): 5 failed, 1 passed (the Studio control). The relative-..variant (6108d08c) was 5 passed, 1 failed (encoded name).Acceptance notes
^[a-z_][a-z0-9_]*$in the spec, so the decoded spelling never bites the live datasource page; the encoded-name row guards the exported router with other names.Verification
All on head
da4f9be7.Tests and type-check
pnpm --dir ui exec vitest run packages/app-shell/src/views/item-tools/ResourceHistoryPage.backToItem-28626.test.tsx: Tests 6 passed (6).origin/main's page restored into the tree: Tests 5 failed, 1 passed (6); restored toHEAD, hash matched,git diff HEADempty.git grep -lonResourceHistoryPage/MetadataResourceHistoryPage, 21 files across app-shell and the console): Test Files 21 passed (21), Tests 306 passed (306). CI's Test UI runs the rest.pnpm exec turbo run type-check --filter=@object-ui/app-shell: Tasks 65 successful, 65 total.pnpm --dir ui exec vitest run scripts/: Test Files 169 passed, 2 skipped (171).Derived gates
node scripts/pm/dispatch-gates.mjs --ran: 34 derived families, 34 run, 0 NOT-MEASURED; every one exit 0,check-sdui-manifestincluded (no registry change).PR_BODY=... node scripts/check-partof-closing-keyword.mjs: exit 0.pnpm --dir ui check:new-line-citations: 0 new citations, exit 0.!in the title, no narrowing arm).Generated by Claude Code