Repository navigation
Commit c5f8588
feat(ui): an approval opened with no source app stays in an app instead of Setup (#36546)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi92ncfFpPUpTD8314otX5oaG)_
Fixes #35505
Clause-②: no
Metadata-protocol: none
## 维护者速读
-
审批人从首页「我的工作」、铃铛、通知或邮件链接打开一条审批时,不再默认进入系统设置应用,而是留在业务应用里:优先记录所属的应用,其次当前应用、上次用的应用、第一个应用;详情页的关闭和返回回到审批中心。
- 这是你对审批落点的裁决(选项 A),解决审批人被带进系统设置、处理后回到原始审批请求列表的问题。
- 普通审批人和管理员都会碰到;出错时最坏是审批打开在另一个业务应用里,审批本身照常可处理,改动可整体撤回。
- 无。
## What changes
The ruling (option A on the card) binds four items; each is implemented
as follows.
1. **Where a request opened with no source app lands.** The order is the
object's own app, then the current app, then the last used app, then the
first app.
- The last three steps are one resolver,
`resolveApprovalsHostSegment(apps, current, last)` in
`utils/appRoute.ts`. It reads the existing `resolveHostAppSegment` and
the existing `LastAppProvider` (`useLastApp().lastApp`, the
`ui.app.last` preference). No second host rule is added.
- Home's 我的工作 (the inbox link, each pending row, and approval notices),
and the bell (the same three), now host the inbox with it. Outside an
app the last used app is consulted before the first app; inside an app
the current app answers, as before.
- The first step stays where it was: the deep link reads the request's
`object_name` and asks `objectHostAppSegment`. That function gains `{
orSetup: false }`, which stops after "an app that lists the object".
Without such an app the request now stays in the app it was opened in,
instead of falling to Setup.
- `/system/approvals…` still forwards to `/apps/setup/system/approvals…`
(`SystemRedirect` stays a bare redirect, as its pin requires).
`AppContent` now treats the `setup` **name alias** on exactly that inbox
path as "no source app". Before any app chrome mounts, it waits at most
2 s for the last used app to be read, then replaces the URL with
`/apps/HOST/system/approvals` plus the original search and hash (new
file `console/setupAliasApprovals.ts`). Mounting first would record
Setup as the reader's last app. The canonical-address rewrite is skipped
on that path so the two do not race.
2. **The way back from a deep link, and the queue.** The deep link's
redirect now carries history state: `from.pathname` is the approvals
inbox of the app the request opens in, and `from.label` is the inbox
title. The record page's ✕ and the phone's ‹ already follow
`from.pathname`, so they return to the approvals centre, not to
`/apps/APP/sys_approval_request`. `RecordDetailView.tsx` and
`approvalQueueAdvance.tsx` are unchanged.
- Home and the bell open a request with `approvalQueueState(...)` over
the pending rows they hold, so the page draws the counter and 「处理后打开下一条」
works. The deep link keeps that queue and only rewrites `from.pathname`
to the final app's inbox.
- The e-mail link and a notification carry the way back alone (no
queue). The server's link is unchanged; `approval-service.ts` is not
touched.
3. **Setup by agreement.** When Setup is the current or the last used
app, the resolver answers Setup, and the request stays there.
`/apps/com.objectstack.setup/system/approvals` (Setup's own address) is
never moved. Zero-app approvers are not handled, per the ruling. The
`setup` fallback of an inbox mounted with no app segment is unchanged.
4. **The pinned test flips.** See below.
## Tests
Pins that flip with this change (ruling item 4, and the sweep of the
same rule):
| File | Test | Before | After |
|---|---|---|---|
|
`ui/apps/console/src/pages/system/ApprovalsInboxPage.opensServedPage-12484.test.tsx`
| "no app lists the object: the request opens under Setup, never under
the unrelated app" |
`/apps/com.objectstack.setup/sys_approval_request/record/ID` | renamed
"…stays in the app it was opened from, not Setup"; `/apps/probe_app/…` |
|
`ui/packages/app-shell/src/console/__tests__/AppContent.setupItemRoutesVerdict-12706.test.tsx`
| "CONTROL — the approvals inbox stays reachable under the Setup segment
for a refused caller" | inbox drawn at `/apps/setup/system/approvals` |
renamed "…in the caller's own app"; asserts
`/apps/crm/system/approvals`; the file header sentence updated |
Changed because the call shape changed, not a flip:
`HomePage.myWork-12602.test.tsx`, "opens a request in the Approvals
inbox of the app the user is in". The same URL is now called with a
second argument (the queue's history state), so the assertion takes
`expect.objectContaining({ state: … approvalQueue: true })`. Two touched
harnesses (`AppContent.setupItemRoutesVerdict-12706`,
`HomePage.myWork-12602`) gained the module-top `import
'@objectstack/lint'` that `check:test-source-alias` asks of an edited
test file.
Swept and deliberately **not** flipped:
- `AppContent.setupObjectListVerdict-28988.test.tsx`, "CONTROL — a host
route under the Setup segment is not read as an object list": its three
assertions (inbox drawn, no denial, no probe) still hold. The inbox now
draws after the move to the member's app. Left unchanged.
- `record-pointer-card-renderer.test.tsx`, "no app lists the object: the
record opens under Setup": this is a link to the **record** a request is
about, not to the request. Its host rule (owner app, else Setup as the
neutral context) is `objectHostAppSegment`'s default, and the ruling
does not cover it. Not changed: its callers still get the Setup step.
- `HomePage.approvalsTarget.test.tsx` names
`/apps/setup/system/approvals` only in its history docblock; no
assertion lands there.
- `systemRedirectTarget.test.tsx` and `bootRedirectCoverage.test.tsx`
pin `SystemRedirect`'s own hop, which is unchanged.
- No doc under `content/docs/**` names this landing.
New pins, each a top-level `describe` in the component's existing
harness file:
- `utils/__tests__/appRoute.test.ts`: `resolveApprovalsHostSegment`, the
order tier by tier (current over last; last over first; an inactive
current falls to last; neither answers, so the first app and not Setup
ahead of it), Setup kept as current or last, the unloaded list. Also
`isApprovalsInboxLink`, with a CONTROL.
- `utils/__tests__/objectHostApp.test.ts`: `orSetup: false` stops after
the owner app.
- `ApprovalsInboxPage.opensServedPage-12484.test.tsx` (real inbox page
plus real `RecordDetailView`):
- the e-mail link's ✕ returns to the inbox, and no queue switch shows;
- an open carrying Home's or the bell's queue shows 「Open next after
deciding」, and ✕ returns to the inbox;
- when the owner app is another, the way back is that app's inbox;
- CONTROL: opened from Setup, it stays in Setup.
- `HomePage.approvalsTarget.test.tsx`: last used app on a cold landing;
current over last; Setup kept as last app; a pending row navigates with
the queue state.
- `InboxPopover.approvalsSegment-11818.test.tsx`: the same three tiers
for the bell, plus CONTROL: the "see all" drill keeps the generic host.
- `InboxPopover.rightPanel-34589.test.tsx`: "View details" hands the
queue and the way back. CONTROL: "View all" hands none.
- `AppContent.setupItemRoutesVerdict-12706.test.tsx`: the alias inbox
moves through tiers 4, 3 and 2, keeping `?request=`; Setup as current is
moved to Setup's own address; CONTROL: Setup's own address is not moved.
<details><summary>Affected test files, local runs</summary>
At 066d80c, 15 files: the 8 above, plus `systemRedirectTarget`,
`bootRedirectCoverage`, `HomePage.notificationDeepLink`,
`InboxPopover.notificationDeepLink`,
`InboxPopover.unsavedEditsLeave-13253`, `InboxPopover.viewAllTarget` and
`LastAppProvider`.
```
cd ui && pnpm exec vitest run --maxWorkers=2 FILES_15
Test Files 15 passed (15)
Tests 192 passed (192)
TESTEXIT=0
pnpm --filter @object-ui/app-shell run type-check -> TCEXIT=0
pnpm --filter @object-ui/console run type-check -> CONSOLE_TC=0 (at 6f01f71, after the ui closure build)
```
`HomePage.myWork-12602` was not measured locally: the shared verify lock
was held by a sibling run, and two 540 s waits ended in exit 99. Its
reading is CI's: Test UI (10/16) was red at 066d80c on that
assertion, and is green at 1ed5095 and at the final head.
</details>
<details><summary>Ablation (one per changed behaviour; each mutation
landed through scripts/ablation-replace.mjs, restored to the HEAD
blob)</summary>
- Remove `{ orSetup: false }` from the deep link: 1 failed / 13 passed.
Fails "no app lists the object: the request stays in the app it was
opened from, not Setup".
- Drop `state={state}` from the deep link's redirect: 3 failed / 11
passed. Fails all three "way back / queue" cases.
- Delete the alias `Navigate` in `AppContent`: 5 failed / 11 passed.
Fails the flipped CONTROL, plus tiers 4, 3, 2 and the Setup-current
case.
- Home with `resolveHostAppSegment(activeApps, currentAppName)` in place
of the approvals resolver: 3 failed / 6 passed. Fails the last-app,
Setup-as-last and queue cases.
Every leg ended with `blob == HEAD` and an empty `git diff HEAD`.
</details>
## Acceptance notes
- The queue Home hands on is the pending page Home holds, not only the
five rows it shows. The bell's is the rows the panel lists (decided ones
already dropped). When the queue runs out, the page goes to the inbox
and says the list is done, as from the inbox.
- `ui/packages/app-shell/README.md` (the "Setup's `system/*` pages"
paragraph) still says a member reaches the approvals inbox under the
Setup segment from the server's links. That README is outside this
card's file surface, so it is left for the seat.
- `PhoneAppNavBar.tsx` reads the generic host for its Approvals tab, but
only inside an app, where the current app always answers, so it is
unchanged.
- The 2 s wait for the last used app mirrors the phone landing's wait.
It applies only on the alias path, and only when the current app does
not answer.
## Verification
Read first:
1. `ui/packages/app-shell/src/console/AppContent.tsx`, the two early
returns after the boot gate, and the canonical-rewrite effect's new
guard. This is the one hop that runs before any chrome.
2. `ui/apps/console/src/pages/system/ApprovalsInboxPage.tsx`,
`RequestDeepLink` and `deepLinkRequestState`.
3. `ui/packages/app-shell/src/utils/appRoute.ts`,
`resolveApprovalsHostSegment`.
Two-minute check: as a member without Setup access whose last app is
CRM, open `/system/approvals?request=ID` for a request whose object no
app lists. Expect the request page under `/apps/CRM…`, not Setup; ✕
lands on `/apps/CRM…/system/approvals`.
<details><summary>Gates at 1116647</summary>
- Local: `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 39 families at 1116647. Each was
run with stdin from /dev/null, exit taken before any pipe: 39 × exit 0.
- `--ran` reconciliation: "39 derived, 39 run, 0 NOT-MEASURED, 0 UNRUN".
- `node scripts/pm/overlap-check.mjs`: VERDICT clean exit 0.
- `pnpm check:new-line-citations`: 0 new citations.
- CI at 1116647: every required context passed — Lint & Repo Gates,
TypeScript Type Check, Test Core, Governed Surface Queue Guard, Lint UI,
Type Check UI, Test UI (16/16), Build & E2E UI, Live E2E UI, Dogfood
Regression Gate. Check Changeset also passed. Build Core was skipped by
its path selector.
- Not run locally: the full `ui` package suites (CI's Test UI runs them)
and `test:repo`.
</details>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01ADHkmRB34k9WUWeGpRnVNm
<!-- signed: repo:objectstack#2 · os-steve ·
session_01ADHkmRB34k9WUWeGpRnVNm -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent d463c46 commit c5f8588
17 files changed
Lines changed: 638 additions & 51 deletions
File tree
- .changeset
- ui
- apps/console/src/pages/system
- packages/app-shell/src
- console
- __tests__
- home
- __tests__
- layout
- __tests__
- utils
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
| 85 | + | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| |||
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
257 | | - | |
| 257 | + | |
258 | 258 | | |
259 | 259 | | |
260 | 260 | | |
| |||
416 | 416 | | |
417 | 417 | | |
418 | 418 | | |
419 | | - | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
420 | 424 | | |
421 | 425 | | |
422 | 426 | | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
423 | 435 | | |
424 | 436 | | |
425 | 437 | | |
| |||
433 | 445 | | |
434 | 446 | | |
435 | 447 | | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
732 | 732 | | |
733 | 733 | | |
734 | 734 | | |
735 | | - | |
736 | | - | |
737 | | - | |
738 | | - | |
739 | | - | |
740 | | - | |
741 | | - | |
742 | | - | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
743 | 742 | | |
744 | 743 | | |
745 | 744 | | |
746 | 745 | | |
747 | 746 | | |
748 | 747 | | |
749 | 748 | | |
750 | | - | |
751 | | - | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
752 | 774 | | |
753 | 775 | | |
754 | 776 | | |
| |||
776 | 798 | | |
777 | 799 | | |
778 | 800 | | |
| 801 | + | |
| 802 | + | |
779 | 803 | | |
780 | 804 | | |
781 | 805 | | |
| |||
800 | 824 | | |
801 | 825 | | |
802 | 826 | | |
803 | | - | |
804 | | - | |
805 | | - | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
806 | 836 | | |
807 | 837 | | |
808 | 838 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
| |||
469 | 470 | | |
470 | 471 | | |
471 | 472 | | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
472 | 477 | | |
473 | | - | |
| 478 | + | |
474 | 479 | | |
475 | 480 | | |
476 | 481 | | |
477 | 482 | | |
478 | | - | |
| 483 | + | |
479 | 484 | | |
480 | 485 | | |
481 | 486 | | |
| |||
654 | 659 | | |
655 | 660 | | |
656 | 661 | | |
657 | | - | |
658 | | - | |
659 | | - | |
660 | | - | |
661 | | - | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
662 | 667 | | |
663 | 668 | | |
664 | 669 | | |
| |||
1245 | 1250 | | |
1246 | 1251 | | |
1247 | 1252 | | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
1248 | 1257 | | |
1249 | 1258 | | |
1250 | 1259 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
581 | 581 | | |
582 | 582 | | |
583 | 583 | | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
584 | 588 | | |
585 | 589 | | |
586 | 590 | | |
| |||
0 commit comments