Repository navigation
Commit fb4735d
fix(studio): app preview Open and nav route links keep the console basename (#39430)
Fixes #39348
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 在 Studio 里预览一个应用,点工具栏的"打开"或导航行旁的路由链接,新标签页以前跳到控制台外面报
404,现在落在控制台里的这个应用上。
- 属于 Studio 搭建体验;替每个在 Studio 里预览应用的人解决打不开的问题。
- 若出错,受影响的是预览面板里的这几个链接打开的地址;改动只在预览组件,可直接撤回。
- 无。
## What changes
- `AppPreview.tsx`: the toolbar **Open** link and each nav row's route
link now render through a small `RuntimeLink`, which uses react-router's
`Link` when a router sits above the preview. `Link` puts the router
basename (`/_console`) in front of the router path, so the href is
`/_console/apps/crm/` instead of `/apps/crm/`. `target="_blank"` is
kept: `Link` leaves a new-tab click to the browser. This is the same
pattern the agent and tool previews already use (`AgentChatLink`).
- With no router above (the designer gallery harness, the router-less
unit tests) the anchor keeps the bare path, as before.
- A nav row whose entry `resolveHref` marks `external` (a `url` entry
with `target: _blank`) stays a raw anchor; every other row goes through
`Link`, exactly as `NavigationRenderer` draws the same entry in the
running shell. An absolute `https://` url without a target also keeps
its address (react-router's `Link` renders absolute URLs verbatim;
pinned in the test).
- Bounded in-place fix, declared: the card names only the Open link; the
nav row route links in the same file had the same raw-href defect (same
defect class, same mechanical shape, same file under this claim, same
gate family), so they are fixed here and pinned in the same test.
- Changeset `@object-ui/app-shell: patch` (the precedent other app-shell
fixes follow).
## Tests
New `AppPreview.openBasename-39348.test.tsx` (5 cases): under
`MemoryRouter basename="/_console"` Open's href is `/_console/apps/crm/`
with `target=_blank`; a nav row's route link href is
`/_console/apps/crm/account` while its text stays `/apps/crm/account`;
an absolute url entry keeps `https://docs.example.com`; controls at a
root router and with no router give the bare path.
Ablation (original `AppPreview.tsx` restored on disk, test file kept): 2
failed / 3 passed, `expected '/apps/crm/' to be '/_console/apps/crm/'`
and `expected '/apps/crm/account' to be '/_console/apps/crm/account'`;
fix restored afterwards.
<details><summary>Local readings at 8bff235</summary>
- `vitest run` over `AppPreview*`, `adminPreviews*`,
`ResourceEditPage.navDeepLink-11153` (from `ui/`): Test Files 9 passed
(9), Tests 95 passed (95).
- `tsc --noEmit -p tsconfig.json` (app-shell src): exit 0. eslint on the
two files: 0 errors (7 pre-existing `no-explicit-any` warnings on
untouched lines).
- Test typecheck: the whole-package `tsconfig.test.json` run hit the 4
GB heap cap (NOT MEASURED, CI); the same config narrowed to the new test
file: exit 0.
</details>
## Acceptance notes
- Read first: `AppPreview.tsx` `RuntimeLink` (the router/no-router
branch) and the NavRow `item.external` branch.
## Verification
Two-minute check: `objectstack dev --ui --seed-admin` in
`examples/app-showcase`, Studio, open any app, Preview, click **Open**:
the new tab lands on `/_console/apps/APP/`, not a 404.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_016WV4d1cnRvyiAqrarmDhZV
Co-authored-by: Claude <noreply@anthropic.com>1 parent d487185 commit fb4735d
3 files changed
Lines changed: 168 additions & 16 deletions
File tree
- .changeset
- ui/packages/app-shell/src/views/metadata-admin/previews
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
| |||
288 | 289 | | |
289 | 290 | | |
290 | 291 | | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
291 | 335 | | |
292 | 336 | | |
293 | 337 | | |
| |||
364 | 408 | | |
365 | 409 | | |
366 | 410 | | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
| 411 | + | |
| 412 | + | |
371 | 413 | | |
372 | 414 | | |
373 | 415 | | |
374 | 416 | | |
375 | | - | |
| 417 | + | |
376 | 418 | | |
377 | 419 | | |
378 | 420 | | |
| |||
488 | 530 | | |
489 | 531 | | |
490 | 532 | | |
491 | | - | |
492 | | - | |
493 | | - | |
494 | | - | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | | - | |
499 | | - | |
500 | | - | |
501 | | - | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
502 | 551 | | |
503 | 552 | | |
504 | 553 | | |
| |||
0 commit comments