Skip to content

fix(plugin-grid): ask row Edit/Delete verdicts when the row actions are first used, not on first paint - #34227

Merged
objectstack-fleet[bot] merged 7 commits into
mainfrom
claude/project-thread-7dt182
Nov 16, 2026
Merged

objectstack-fleet[bot] merged 7 commits into
mainfrom
claude/project-thread-7dt182

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Steve · project thread

Fixes #34208

Clause-②: no
Metadata-protocol: none

ui/packages/plugin-grid/src/ObjectGrid.tsx carries one added line (the hook call gains updateOnMount: inlineEditable,), added after #34213 merged (main 31eb2ae merged into this branch).

维护者速读

  • 改了什么:列表首屏不再发 POST /api/v1/security/explain;用户第一次触及某行的操作(鼠标或焦点到操作格、打开「⋮」或右键菜单)时,整页一次性按操作各发一批。
  • 为什么改:每个有行的列表首屏都多发两次 explain(各约 45 ms、50–60 条查询),是托管页加载的最后一层。
  • 风险与回滚:答案到达前行沿用对象级判定(与今天答案到达前一致);菜单若在等答期间打开,Edit/Delete 显示为不可点;行内可编辑网格(opt-in)首屏仍发 1 次 update。首次使用发 2 次(update、delete 各一),卡上验收写「至多一次」,合成一次要改 spec 与服务端,不在本卡。回滚即 revert 本 PR。
  • 先看:ui/packages/plugin-grid/src/hooks/useRecordCrudVerdicts.ts(demanded 与 toAskFor)、ui/packages/plugin-grid/src/components/RowActionMenu.tsx(触发点与 verdictPending)、ui/packages/plugin-grid/src/ObjectGrid.tsx(updateOnMount: inlineEditable 一行)。
  • 两分钟验证:pnpm --dir ui exec vitest run packages/plugin-grid/src/__tests__/rowRecordCrudVerdict.test.tsx,预期 22/22 通过,其中 [objectstack#34208] 一组 7 条。
  • 需要你做的:无,席位落地。

What changes

  • useRecordCrudVerdicts asks nothing until a row-action surface calls requestVerdicts() (now carried on the returned lookup, beside pending). The first call asks once for the page, one batch per operation under the server's cap; later calls are free. Once asked, the list keeps its verdicts current as before (a new page, a data change re-asks the changed rows). Before the first ask, verdicts the module cache already holds are still published, and a data change asks nothing.
  • New option updateOnMount asks update when the rows arrive, for a surface that reads it while rendering. The inline-editable cells (objectstack#27365) are that surface; ObjectGrid.tsx passes updateOnMount: inlineEditable.
  • RowActionMenu gains two optional props. onActionsDemand is called on pointer-enter and focus of the actions cell, when the "⋮" opens, and when RowActionMenuItems mounts, which covers the row context menu too (it renders the same items). crudVerdictPending renders the built-in Edit or Delete as disabled with aria-busy while that row's answer is on the wire, so it cannot be clicked into a write the answer is about to refuse.
  • objectGridActionsColumn.tsx wires both from the hook's lookup into the props both menus read.
  • Request count on first use: two (one update, one delete), both lazily, on the first use only; zero at first paint; a second row's menu sends nothing. One request for both operations needs operations: [...] on the explain route, a spec and server change outside this card.
  • First open without a prior hover (keyboard): the menu shows Edit / Delete inert, then they become live or go when the answer lands. With a pointer the request leaves on hover, so it is usually answered before the click.
  • Docs: the plugin-grid README and content/docs/frontend/plugins/plugin-grid.mdx say when the verdict is asked.

Tests

New pins in rowRecordCrudVerdict.test.tsx, a top-level describe('[objectstack#34208] …') in the existing harness:

  • the first paint of a list with rows sends no explain request, and rows keep the object-level verdict;
  • opening a row's "⋮" by keyboard asks once for the page, one batch per operation, items are inert while the answer is held, and the open menu narrows to the answer;
  • a second row's menu sends nothing new, and a permitted row's items are live once answered;
  • a pointer reaching the actions cell asks before the menu opens;
  • the row context menu is a use of the row actions too;
  • a data change before any use asks nothing; after the first use it re-asks the changed row;
  • CONTROL: a non-OK answer to the first use keeps the object-level items, live (fail open).

Forced test edits (each now reaches for the row actions, or asks through a helper, before reading a verdict; no assertion changed meaning):

  • rowRecordCrudVerdict.test.tsx: the existing pins call a new reachRowActions() (hover the first "⋮") before settle(N); the pre-answer-window pin reaches before its held answer.
  • serverGroupedVerdictProbe-32627.test.tsx: both pins assert zero asks after the groups settle, then reach for the first row's "⋮" and count the same two requests over every row.
  • hooks/useRecordCrudVerdicts.{afterAction-13341,batchCap,invalidation,principalScope}.test.tsx: render the hook through the new __tests__/askedRecordCrudVerdicts.ts helper, which calls requestVerdicts() on mount.

inlineEditRecordVerdict-27365.test.tsx: its 8 existing cases are unchanged (they were red on this branch until the ObjectGrid.tsx line landed, which is what they guard); a new top-level describe('[objectstack#34208] …') pins that an inline-editable grid's first paint asks update for the page and nothing else, and that opening a kebab then asks delete once.

Acceptance notes

  • After the first use a list stays asked: paging to a new page asks for the new rows with that page's paint. The card's acceptance is about the list's first paint; this keeps the verdicts current for a user who has shown they act on rows here.
  • Grids that are inline-editable (editable: true, opt-in) will still send one explain request (update) after their rows arrive, because their cells read it while rendering.

Verification

Final head 1ca52c3e (main 31eb2ae merged; install and the @object-ui/plugin-grid^... closure rebuilt after the merge).

Local runs on 1ca52c3
  • pnpm --dir ui exec vitest run packages/plugin-grid/ — Test Files 283 passed (283), Tests 2458 passed (2458); lock VERDICT command-exit 0.
  • pnpm --filter @object-ui/plugin-grid type-check — exit 0.
Ablations (ablation-replace, restore proven by blob == HEAD)
  • Eager fetch restored (const toAskFor = demanded replaced with an always-true condition): 7 red, including "the first paint of a list with rows sends no explain request".
  • Pending rule removed (const disabled = verdictPending || ( with false): 1 red, "opening a row's ⋮ asks once for the page … the open menu narrows to the answer".
  • updateOnMount: inlineEditable replaced with false (on 1ca52c3): 9 red, every case of inlineEditRecordVerdict-27365.test.tsx including the new first-paint pin.
Derived gates

node scripts/pm/dispatch-gates.mjs --commands on 1ca52c3: 71 families, every one exit 0. --ran: 71 derived, 71 run, 0 NOT-MEASURED, 0 UNRUN.


🤖 Generated with Claude Code

https://claude.ai/code/session_01ADHkmRSP3ZjQXiwomqs6D6

@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 16, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:ui#2 · os-steve · session_01ADHkmRSP3ZjQXiwomqs6D6

Test UI (2/16) is red on head 10b3d34 with exactly the 8 cases of inlineEditRecordVerdict-27365.test.tsx (Test Files 1 failed, 328 passed). This is the known, declared red from the PR body's Waits-on line: the inline-editable cells read the update verdict while rendering, and the updateOnMount: inlineEditable line that asks it on mount goes into ObjectGrid.tsx, which #34213 holds. The line is added here by a merge of main once #34213 merges; no other Test UI shard failed.

Stamped 2026-11-16T02:07Z.


Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:ui#2 · os-steve · session_01ADHkmSzhXR4yUAgwq1bQRi

维护者速读

  • 卡:console list: row CRUD verdicts send POST security/explain twice (update, delete) on first paint — ~45 ms server CPU and 50–60 queries each, last layer of the page #34208(p2):每个有数据的列表视图首屏都发两次 POST /api/v1/security/explain(update 和 delete 各一次,每次约 45 ms、50–60 条查询),只是为了收起行上的编辑/删除按钮。
  • 改了什么:useRecordCrudVerdicts 改为按需请求:首屏不发,行操作第一次被用到时(鼠标悬停、聚焦或打开某行的 ⋮ 菜单,或右键菜单挂载)才为整页请求一次。答复回来之前内置的编辑/删除先置灰,不会先显示再消失;答复缺失或失败时退回对象级判断(和今天一样,fail-open)。RowActionMenu.tsx 加了两个可选 prop 承接这个触发点;ObjectGrid.tsx 只加一行 updateOnMount: inlineEditable,行内可编辑的网格首屏仍然只问 update(plugin-grid: list inline edit opens cell editors on rows the server's record-grained verdict refuses, because the cells read only the object-level grant while the row kebab reads the per-row verdict #27365 需要)。
  • 请求数(实测):普通列表首屏 0 次(原来 2 次);第一次用行操作 2 次(update、delete 各一批);第二行菜单 0 次。行内可编辑网格首屏 1 次(只 update),打开菜单再 1 次 delete。
  • 偏差:卡上写「第一次使用时至多一次」,实际是两次。ExplainRequest 只接受一个 operation,合成一次需要在 explain 路由加 operations[],是 spec 加服务端的改动,不在本卡范围。首屏的大头已经去掉。
  • 钉子:首屏无 explain;打开菜单只请求一次并按答复收起;第二行不再请求;对照组失败答复保留对象级按钮;行内可编辑网格首屏只问 update。消融三条全红并还原。plugin-grid 全量 283 文件 / 2458 测试绿,派生门禁 71/71 exit 0。
  • CI:head 1ca52c3 — success 49 · skipped 12 · 无失败;main 领先 5。Clause-② no,Metadata-protocol none。

席位意见

推迟到第一次用到行操作再问,是不改协议前提下最大的收益:每个列表首屏少两次重请求。剩下的「两次合成一次」需要协议改动,应该单独开卡,不在这里硬塞。同意落地。

席位核对 — ACCEPT · domain:ui#2 · head 1ca52c3 · 2026-11-16T05:19Z

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants