fix(detail): the approval band honors the node's lockRecord instead of assuming every approval locks (#2902) - #2906
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
… of assuming every approval locks (#2902) The detail page treated "a pending approval request exists" as "this record is locked". An approval node declares `lockRecord` (default `true`), and on `lockRecord: false` the server keeps accepting writes while that node waits — so the console asserted a lock the backend did not enforce. The label was the smaller half. The same conflated signal fed `canEdit`, so the record-level inline-edit session was suppressed too: no pencils, `enter()` a no-op. On a single-approver step — the case `lockRecord: false` exists for, where the approver is meant to fill in the missing detail before deciding — the capability was unreachable from the UI. And a flow chaining nodes with different policies drew one identical band for "edit freely" and "your save dies with RECORD_LOCKED", so the states were indistinguishable until Save failed. Approval state is now two signals: `approvalPending` (an approval is running — drives the band and recall, both meaningful either way) and `locked` (it also forbids edits, from the pending node's `lock_record`). The band renders amber lock + "Locked for approval" or sky clock + "In approval · editable", each with its own tooltip; recall left the locked branch, since an editable pending approval is just as recallable. `InlineEditProvider`'s new `approvalPending` prop defaults to `locked`, so a host threading only `locked` is unchanged. The `approval_status` fallback has no node granularity and still reads as locked, as does a pending request from a backend too old to report the policy — failing closed beats offering an edit the server rejects. Needs framework#3814 for `lock_record` on the request row. Closes #2902 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
xuyushun441-sys
pushed a commit
that referenced
this pull request
Jul 28, 2026
The approval-band half of this PR landed independently as #2906 while it was open, so the merge is mostly a de-duplication. Resolved toward main for everything #2906 already shipped, keeping only what is genuinely new here. Taken from main wholesale: - `useRecordApprovals` — main's `lock_record` + `recordLockedByApproval`. This PR's field name `locks_record` was simply wrong: framework#3834 merged as `lock_record`, which is what the server actually sends. - `InlineEditContext` — identical `approvalPending` contract; no diff left. - the band's markup/styling (sky "In approval · editable" variant) and the `approvalPendingEditable` / `approvalPendingTooltip` key names, dropping this PR's `inApprovalEditable*` spelling of the same two strings. Kept from this branch: - `disabled: approvalLocked` on the header Edit CTA. #2906 gated inline edit but left the full-form CTA live on a locked record, so the user still filled a screen before Save returned RECORD_LOCKED. - `DetailView` no longer OR-s the `approval_status` mirror into `isLocked` unconditionally. A flow configuring an `approvalStatusField` mirrors `approval_status: 'pending'` regardless of `lockRecord`, so on a `lockRecord: false` node main's derivation re-locked the band while the host had correctly resolved "not locked" — pencils live and saves landing under a band reading "Locked for approval". `approvalPending && !locked` is the tell that the host has an opinion (the provider defaults `approvalPending` to `locked`, so a pre-#2902 host can never produce it). Covered by a new test. - the recall tooltip's unlocked variant, and everything in parts 2 and 3 (batch `droppedFields` warnings, the localized by-reason toast, and dropping the hand-stamped `updated_at`), which main never touched. Also drops a duplicate `Clock` import git merged in from both sides. Green: 2849 tests across plugin-detail / data-objectstack / i18n / react / app-shell; `pnpm type-check` clean on all 76 packages; 0 lint errors.
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.
Closes #2902. 依赖 framework objectstack-ai/objectstack#3815(新字段
lock_record)。定性:是 bug,且是「从来没接出来」而非回归
lockRecord是 spec 里正式的节点配置项(ApprovalNodeConfigSchema,z.boolean().default(true)),服务端在plugin-approvals的beforeUpdate钩子里严格执行。平台自己定义、自己执行的开关,UI 不读 —— 平台内部行为不一致。git 追溯确认不是回归:objectui 的
approvalLocked由 #2572 引入时就是「approval_status或有 pending request」的二值判断,#2618 只补了第二个来源,从未有过节点粒度;framework 侧的行投影也从第一版起就没带过锁信号。这个能力自诞生起就是 server-only。影响面比 issue 描述的更大
issue 只提了 band 文案。实际上同一个信号还掐着
canEdit(RecordDetailView.tsx):所以
lockRecord: false的节点上行内编辑被整个禁掉 —— 铅笔不出现、enter()空转。报告人是从独立「编辑」表单路由进去才存成功的,那条路没接这个门。实际业务里审批链上的单人节点(部门负责人 / 厂长)正是配lockRecord: false,本意就是让审批人在审批时补充内容 —— 这个能力在 Console 里比 issue 写的更彻底地不存在。改动
审批状态拆成两个信号:
approvalPending—— 有审批在跑。驱动 band 和撤回按钮,两者无论记录可不可改都有意义。locked—— 这个审批还禁编辑。取自当前 pending 节点的lock_record。band 两态:琥珀色锁 +「审批中已锁定」,或天蓝色时钟 +「审批中 · 可编辑」,各自独立 tooltip。撤回按钮移出 locked 分支 —— 可编辑的 pending 审批一样可以撤回,原来藏在锁分支里等于不锁的节点连撤回都没了。
InlineEditProvider新增可选approvalPending,缺省回落到locked,只 threadlocked的老 host 行为完全不变。记录自身的approval_status仍作为无 approvals API 后端的兜底,它没有节点粒度所以只能读作锁定;老后端不返回lock_record时同样 fail closed —— 放出一个必然被服务端拒掉的编辑,比藏起一个本可放行的更糟。新增
detail.approvalPendingEditable/detail.approvalPendingTooltip,十种语言全部翻译。真机 UI 实测
showcase 后端 + objectui HMR console,推了一条真实审批走完两个节点(framework PR 里把 Manager Review 改成
lockRecord: false、Executive Review 保持true):lock_record: falselock_record: true)→ band 当场翻成琥珀色锁「审批中已锁定」API 同步确认两条 request:
Manager Review / approved / lock_record:false、Executive Review / pending / lock_record:true。测试
新增 12 条:band 两态 5 条(可编辑态文案 / 独立 tooltip / 锁定态仍为锁 / 只给
locked的老 host 不变 / 无审批不渲染)、InlineEditContext3 条(两信号独立 / 缺省回落 / 可编辑态enter()仍可用)、recordLockedByApproval5 条(含 fail-closed 与「flow 推进时逐节点独立读」)。plugin-detail + react + app-shell hooks 共 724 通过,i18n 91 通过。
合并顺序
framework PR 先合。没有它时
lock_record为undefined,本 PR 逻辑 fail closed 回落到当前行为,不会崩。🤖 Generated with Claude Code