Repository navigation
Commit d25d912
fix(console): the approvals inbox keeps its tab, filters, search and sort across a request page and Back (#36979)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} -->
_Requested by **Yibo Wang** · [project
thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBTDAJKyXUan6fJCKsZUf5Pv)_
Fixes #36966
Clause-②: no
Metadata-protocol: none
## 维护者速读
-
审批人在审批收件箱里切到「全部」、按状态筛选或搜索后打开一条申请,按浏览器返回,原来回到「待我审批」且筛选全清空;现在回到离开时的标签、筛选、搜索和排序,刷新页面也保留。
- 属于审批收件箱体验改进,替逐条处理「全部 → 已撤回」或「我提交的」的审批人省去每次重建筛选。
- 出错时最坏是收件箱打开在默认状态(与改动前一样),不丢数据、不影响审批动作;可直接撤回本次合并。
- 无
## What changes
The approvals inbox (`ApprovalsQueue` in `ApprovalsInboxPage.tsx`) held
its tab, status / process / object filters, search text and sort in
`useState` alone, so the queue's remount on Back from a request's page
reset them all. They now live in the inbox's query string, through a
small codec beside the page, `approvalsInboxUrlState.ts` (the same shape
as the metadata list's `metadataListState.ts`).
| Param | Carries | Default (no param) |
|---|---|---|
| `scope` | the tab: `submitted` or `all` | `pending` |
| `status` | one `APPROVAL_STATUSES` value, on tabs other than `pending`
| every status |
| `process` | the process label a row shows | every process |
| `object` | the object machine name | every object |
| `q` | the search text | no search |
| `sort` | `oldest` or `amount` | `recent` |
Design points the card asked to settle:
- **Replace vs push.** Every write uses `setSearchParams(..., { replace:
true })`, the tab change included, so filter changes add no history
entries and Back leaves the inbox. Measured in the browser: after a tab
switch, a sort change and a search, one Back from the inbox lands on the
page before it.
- **Search debounce.** The search box keeps its own draft; the draft
reaches `q` after 350 ms, the same delay the server search already used
(the old `serverQuery` debounce is replaced by it, and on the paginated
tabs `q` IS the server query). A row opened inside the debounce first
writes the pending text into the inbox's own entry, then navigates, so
Back returns to it too. The draft follows the address only on a
navigation the page did not write (a link here, Back / Forward), never
on its own REPLACE, the rule `ResourceListPage` uses; it is applied
during render, not in an effect.
- **Invalid values.** Reading is strict and quiet: an unknown `scope` or
`sort`, or a `status` outside `APPROVAL_STATUSES`, reads as the default.
A `status` on the `pending` tab is ignored (that tab draws no status
filter, so it would hide rows behind a control that is not shown).
`process` and `object` name data, so they are checked once, at the first
load that returns rows, and dropped only when those rows are the whole
answer (the pending tab, or `rows.length >= total`) and none carries the
value; otherwise the value is kept and offered in its dropdown (an
object no loaded row labels shows by its machine name). A filter picked
from the dropdowns is never second-guessed.
- **`onTabChange`.** It writes one patch: the new `scope`, and `status`,
`process`, `object`, `q`, `sort` back to their defaults (deleted from
the address). Params the inbox does not own are kept.
- **`?request=` deep link.** Unchanged: `ApprovalsInboxPage` still
routes `?request=` to `RequestDeepLink` before the queue mounts, with or
without inbox params beside it.
- **Record-page round trip and full reload.** Both restore: the state is
read from the address on mount, and the first server read already
carries `q` and `status` (no debounce wait on a reload).
Two choices worth a look:
- The tab rides `scope`, not the card's suggested `tab`: `tab` is a
console-reserved param (`RECORD_DETAIL_TAB_PARAM`, the record page's
detail tab, in app-shell's `urlParams.ts`), which that registry says a
page must never repurpose. None of the six names is in
`RESERVED_URL_PARAMS`.
- The state survives a reload. Object list views strip their `uf_*`
state on a document reload (the list-draft rule in `listDraftStore.ts`);
the inbox does not, because the card asks for reload survival and the
inbox has no saved-view baseline to fall back to. If the reload reset is
wanted here too, it is a follow-up, not part of this fix.
The status filter accepts the full `APPROVAL_STATUSES` vocabulary, so
the status select's missing `cancelled` option (#36960, the next card in
this area) only needs its option added; this PR does not touch the
option list.
## Tests
New pin file `ApprovalsInboxPage.stateInUrl-36966.test.tsx` (8 cases,
the real page under a memory router with a stub request page):
1. All + Recalled + object + sort + search, open a row, Back: same tab,
selects, search, rows and address.
2. A fresh mount of the written address (a reload) opens the same inbox;
the first server read already carries `q` and `status`.
3. A search typed and opened inside the debounce still comes back on
Back.
4. Writes are REPLACE: after filter changes, one Back leaves the inbox.
5. Invalid control: unknown `scope` / `sort`, a `status` on the pending
tab, and an unknown `status` value all read as defaults.
6. Full-set control: with every row loaded, a process / object no row
carries reads as all and leaves the address; one a row carries is kept.
9. On a paginated tab whose first page lacks them, a process and object
the address names are kept, in the address and in the controls (round 2,
L1 S1).
7. A tab change clears the filters, search and sort from the address and
keeps other params.
8. The `?request=` deep link still opens the request, with inbox params
beside it, and the queue reads no list.
<details><summary>Against main's page source: 7 of 8 fail (the deep-link
preservation pin passes, as it should)</summary>
`git restore --source=0212714711` of `ApprovalsInboxPage.tsx` (tree
only, blob verified equal to the base), same test file, then restored
from HEAD (blob equal to HEAD, `git diff HEAD` empty):
```
× All + Recalled + object + sort + search → open a row → Back ...
AssertionError: expected [ 'INV-1001' ] to deeply equal [ 'INV-4004' ]
× a reload of the written address ...
× a search typed and opened within the debounce ...
× writes REPLACE ...
× values the inbox does not offer read as the defaults
× a process or object no row carries ...
× changing tab clears ...
Tests 7 failed | 1 passed (8)
```
</details>
<details><summary>Ablation (scripts/ablation-replace.mjs) on HEAD
b84c138</summary>
Mutation: the writer's `{ replace: true }` → `{ replace: false }` in
`ApprovalsQueue`. The console test imports the page from `src` (no
package `dist/` in the resolution path), so no rebuild or dist preflight
applies.
```
ablation-replace: ok mutation landed: anchor 1 -> 0, blob c5b4e17 -> df34395b9a16
× writes REPLACE: filter changes leave one history entry, so Back leaves the inbox
Tests 1 failed | 7 passed (8)
ablation-replace: ok restored: blob == HEAD (c5b4e17) and `git diff HEAD` is empty
```
</details>
<details><summary>Affected suites on HEAD b84c138</summary>
```
pnpm --filter @object-ui/console type-check → exit 0
pnpm --dir ui exec vitest run --maxWorkers=2 apps/console/src/pages/system/ApprovalsInboxPage \
apps/console/src/__tests__/approvalsInboxComponentRef.test.tsx \
apps/console/src/pages/consoleFaces.displayLocale-9909.test.tsx
Test Files 22 passed (22)
Tests 131 passed (131)
```
ESLint on the three touched source files: no new findings against the
base (the page's warning counts per rule equal main's; the new files
have none).
</details>
<details><summary>Derived gate families on HEAD b84c138: 37 of 37
run, all exit 0</summary>
`node scripts/pm/dispatch-gates.mjs --commands` (tree
`objectstack-ai/objectstack` at b84c138, merge base 0212714)
derived 37 families; each was run and its exit code captured before any
pipe. Reconciliation: `Run reconciliation — 37 derived, 37 run, 0
NOT-MEASURED, 0 UNRUN` (a derived zero: all 37 recorded an exit code).
One family needed a second run: `pnpm --dir ui exec vitest run scripts/`
went red in the batch on two 15 s timeouts in files this diff does not
touch (`check-readme-exports.test.ts`, `select-affected-tests.test.ts`)
while the box was shared; those two files re-run alone at
`--maxWorkers=1` passed, `Test Files 2 passed (2)`, `Tests 161 passed
(161)`. The batch run otherwise read `Tests 2 failed | 5124 passed`.
CI's run of that family is the one of record.
`pnpm check:new-line-citations` (under `ui/`): `0 new citation(s)`.
</details>
## Acceptance notes
- Server search on the paginated tabs matched only the object machine
name in the showcase run (`q=invoice` found 4, `q=INV` and `q=Invoice`
found 0). That is the server search, #36959's scope; noted, not touched
here.
- The process and object selects only draw with two or more options
among the loaded rows, so a search that narrows the rows to one object
hides the object select while its filter still applies (shown as "N of
M"). Unchanged by this PR.
## Verification
Read first, by risk:
1. `ui/apps/console/src/pages/system/ApprovalsInboxPage.tsx`: the
`openRequest` flush (writes the pending search into the current entry,
then navigates) and the draft-follows-address block next to
`useNavigationType`.
2. `ui/apps/console/src/pages/system/approvalsInboxUrlState.ts`: the
codec and its defaults.
3. The seeded process / object check (`seedFiltersChecked`) in the page.
Two-minute check: open the approvals inbox, switch to All, set the
status to Recalled, open a row, press Back. Expected: the All tab,
Recalled, the same rows, and an address ending
`?scope=all&status=recalled`.
<details><summary>Browser run (showcase on its own port, the Console
from ui/ source via Vite, the issue's exact sequence)</summary>
Main's page source (tree-only restore of `0212714711`):
```
[main] 1-before-open: {"url":".../system/approvals","tab":"All","combos":["Recalled","Newest first"],"rows":2}
[main] 3-after-back: {"url":".../system/approvals","tab":"My Pending4","combos":["All processes","All objects","Newest first"],"rows":4}
[main] 4-after-reload: {"url":".../system/approvals","tab":"My Pending4", ... "rows":4}
[main] VERDICT back-restores=false reload-restores=false
```
This branch:
```
[fix] 1-before-open: {"url":".../system/approvals?scope=all&status=recalled","tab":"All","combos":["Recalled","Newest first"],"rows":2}
[fix] 3-after-back: {"url":".../system/approvals?scope=all&status=recalled","tab":"All","combos":["Recalled","Newest first"],"rows":2}
[fix] 4-after-reload: {"url":".../system/approvals?scope=all&status=recalled","tab":"All","combos":["Recalled","Newest first"],"rows":2}
[fix] VERDICT back-restores=true reload-restores=true
```
The component route the issue names (`/component/approvals/inbox`), with
sort and search:
```
after search+sort: .../component/approvals/inbox?scope=all&sort=oldest&q=invoice
after Back: .../component/approvals/inbox?scope=all&sort=oldest&q=invoice tab=All search=invoice sort=Oldest first rows 4->4
one more Back: /apps/com.example.showcase/page/showcase_capability_map
deep link -> .../sys_approval_request/record/areq_d081b5c8-... (asked areq_d081b5c8-...)
```
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01WGufziG2t1d9cfRQJDrHkB)_
<!-- signed: repo:objectstack#3 · os-support-ai ·
session_01WGufziG2t1d9cfRQJDrHkB -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 8c29b81 commit d25d912
4 files changed
Lines changed: 582 additions & 34 deletions
File tree
- .changeset
- ui/apps/console/src/pages/system
| 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 | + | |
| 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 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 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 | + | |
0 commit comments