Skip to content

fix(plugin-detail): the approval badge says editable only when the record is editable - #34757

Merged
objectstack-fleet[bot] merged 1 commit into
mainfrom
claude/project-thread-jp2quk
Nov 17, 2026
Merged

objectstack-fleet[bot] merged 1 commit into
mainfrom
claude/project-thread-jp2quk

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

Requested by Steve · project thread

Fixes #34701

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:记录页审批徽章的「审批中 · 可编辑」现在只在当前用户真能编辑这条记录时出现;审批节点不锁记录、但权限、编辑按钮的 disabledWhen 或 readonlyWhen 让记录不可编辑时,徽章只写「审批中」。11 种语言都加了这个中性文案。
  • 为什么改:用户看到「可编辑」后去改,结果每次都被拒(Locked records: a record under approval shows the badge 「审批中 · 可编辑」 though every edit is refused; a PATCH of only read-only fields answers 200 and rewrites updated_by / updated_at #34701,p1)。徽章原来只看审批节点锁不锁,没看页面已经算好的「能否编辑」。
  • 风险与回滚:只改文案判据,不改任何写入或权限行为,没有接线的宿主不受影响(默认仍可编辑)。回滚就是撤回本 PR。
  • 先看:ui/packages/plugin-detail/src/DetailView.tsx 徽章那段(新的 editableHere 判断);ui/packages/plugin-detail/src/__tests__/DetailView.approvalBadgeCanEdit-34701.test.tsx。
  • 两分钟验证:pnpm --dir ui exec vitest run packages/plugin-detail/src/__tests__/DetailView.approvalBadgeCanEdit-34701.test.tsx,预期 5 条全绿;把 DetailView.tsx 换回 main 版本后,「THE DEFECT」和「keeps recall」两条变红。
  • 需要你做的:无,席位落地。

What changes

  • ui/packages/plugin-detail/src/DetailView.tsx: the approval band picks its label and tooltip from three states instead of two. Locked → "Locked for approval" (unchanged). Pending, not locked, and the host's canEdit is not false → "In approval · editable" (unchanged). Pending, not locked, canEdit false → "In approval" with tooltip "This record has a pending approval request" (new). canEdit is the record page's existing conjunction (record permission explain, userActions.edit visibleWhen / disabledWhen, an all-fields readonlyWhen lock, !approvalLocked). The provider default is true, so a host that threads no canEdit keeps its label.
  • ui/packages/plugin-detail/src/useDetailTranslation.ts and all eleven ui/packages/i18n/src/locales/*.ts: two new keys, detail.approvalPending and detail.approvalPendingNotEditableTooltip.
  • Recall, the tally and the band's colour are unchanged: recall belongs to the approval, not to the edit gate.

Out of this PR, per Premise corrected 6944186660 on the card:

  • The server half (an update whose every field is dropped still stamps updated_by / updated_at and runs afterUpdate) is objectql update: when every caller-supplied field is dropped (readonly / readonlyWhen), the row is still stamped and afterUpdate still runs (split from #34701) #34746.
  • A refusal that an app raises only inside an imperative lifecycle hook stays invisible to the client. No new "can this user edit" surface is added. The app should declare that lock with userActions.edit.disabledWhen or readonlyWhen, which the record page already reads, and then this badge is right.
  • "Judge any pending request as the server does" is not needed. The approvals service refuses a second pending request on the same record (DUPLICATE_REQUEST, approval-service.ts openNodeRequest). Measured with the existing test approval-service.test.ts › "openNodeRequest: deduplicates a pending request per (object, record)", which passes on origin/main. The client's "first pending request" read is therefore the only one.

Tests

  • New: DetailView.approvalBadgeCanEdit-34701.test.tsx (5 cases). The defect cell, recall kept on the neutral badge, and three controls: canEdit true, no canEdit threaded, and a locking node.
  • Changed because they rendered an editable badge under canEdit={false}, which is the defect itself. Each now threads canEdit: true (or !locked) where it asserts "editable":
    • DetailView.approvalBand.test.tsx: 4 cases (labels a pending-but-unlocked approval as editable; uses a distinct tooltip; lets the host verdict beat the approval_status mirror; renders the tally on an editable node).
    • DetailView.approvalRecallGate.test.tsx: 3 cases (withdraws recall from a non-submitter; keeps recall for the submitter; offers recall with no submitter identity).
    • DetailView.approvalReadAnswered-12220.test.tsx: 1 case (control: an answered lockRecord: false request reads editable).
    • DetailView.printApprovalBand-12751.test.tsx: the shared harness now passes canEdit={!locked}, which is what the record page threads.

Verification

Approval band tests and ablation
  • pnpm --dir ui exec vitest run packages/plugin-detail/src/__tests__/DetailView.approval packages/plugin-detail/src/__tests__/DetailView.printApprovalBand-12751.test.tsx: 40 passed.
  • Ablation (DetailView.tsx reverted to origin/main, new test kept): "THE DEFECT" fails, 1 failed / 4 passed. The recall case was then tightened to assert the badge does not say "editable", so it fails under the revert too.
  • pnpm --dir ui exec vitest run packages/i18n/: 1894 passed, 13 skipped (locale key parity included).
Derived gates at head c456037

Acceptance notes

  • The card's "and the platform approval lock holds it" did not hold: the badge says editable only when the pending request's lock_record is false, which is the same nodeConfigLocksRecord judgement the server's record lock enforces. The refusal came from the app's own hook. Recorded on the card as Premise corrected 6944186660.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ADHkmNhzp7pQZtyqYheSKu

…cord is editable

On a `lockRecord: false` approval node the detail band read 「审批中 · 可编辑」
from the node alone. The host's `canEdit` (record permission, the edit
action's disabledWhen / visibleWhen, an all-fields readonlyWhen lock) was
never consulted, so a record those gates close said editable and every edit
was refused. With `canEdit` false the badge now reads 「审批中」 / "In
approval" (new `detail.approvalPending` and
`detail.approvalPendingNotEditableTooltip` keys in all eleven locales).

Claude-Session: https://claude.ai/code/session_01ADHkmNhzp7pQZtyqYheSKu
Co-authored-by: Claude <noreply@anthropic.com>
@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 17, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmNhzp7pQZtyqYheSKu

Final head for L1: c456037f8527ee68f92b286c42ab9f62cd70dbbe (#34701, ui half). Gates and tests are in the PR body's Verification section; the dev report is on the card (comment 6945111598).

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmTPcB6fZEwhd2hNQwC

席位核对

L1 verdict: ACCEPT · PR #34757 · card #34701 (ui half, per Premise corrected 6944186660) · first review · L1-c2 of seat repo:objectstack#2

Head-sha: c456037f8527ee68f92b286c42ab9f62cd70dbbe (the head of final-head comment 6945133825; merge base with main is f6f5b50a)

Read from GitHub and the diff at this head, not from the report. 19 files, +179/−17.

Shape

Code (DetailView.tsx)

  • editableHere = inline?.canEdit !== false.
  • The label and tooltip now come from three states:
    • locked → unchanged;
    • pending, not locked, editable → unchanged;
    • pending, not locked, canEdit === false → detail.approvalPending / detail.approvalPendingNotEditableTooltip.
  • Recall, the tally and the colour are untouched.
  • The claim that the host's canEdit is the conjunction holds. RecordDetailView.tsx threads resolveRecordHeaderActionGates(...).edit && recordWriteAllowed && !approvalLocked && editVisible && !editDisabledByPredicate && !editLockedByState, and the provider default is canEdit = true (InlineEditContext.tsx).
  • I checked the blast radius on other hosts:
    • RecordDetailView is the only non-test host that threads approvalPending.
    • Every other host (RecordPreviewCard, recordBinding, RecordDetailPanel, all canEdit={false} or !!fieldSave) reaches the band only through the column fallback. There resolveApprovalLock returns locked = pending, so they never reached the editable label and do not change.

i18n

  • Both new keys are in all 11 locales (2 lines each, checked per file).
  • They are also in the DETAIL_DEFAULT_TRANSLATIONS fallback.
  • zh-Hans reads 「审批中」 / 「该记录有待审批的请求」.

Pins

  • The new file has 5 cases: the defect cell (label, not editable, tooltip, not locked), recall kept on the neutral badge, and three controls (canEdit true, no canEdit threaded, a locking node).
  • Under a revert of DetailView.tsx, both the defect case and the recall case fail. Each asserts not.toHaveTextContent('editable') under canEdit: false, which the old code violates.
  • The four changed test files (9 named cases) each thread canEdit: true or !locked exactly where they assert "editable". They had asserted the defect under the old canEdit={false} harness, and none of their other assertions are loosened.
  • The ablation (1 failed / 4 passed, then the recall case tightened) is lane-reported, and I did not re-run it.

Prose: one nit, not blocking. The changeset's "the badge still said editable and every edit was refused" is slightly loose for the gates now read. With canEdit false the record page already withheld the edit affordances, so the user met a missing pencil or a disabled Edit under an "editable" badge rather than a refusal. The refusal in the card came from the app's hook, which the PR rightly says stays invisible. The rule text ("says editable only when the record is editable for the viewer") is correct. The maintainer quick-read matches the code.

Gates: 62 check-runs on this head, all completed: 47 success, 15 skipped, 0 failed or cancelled. The lane's derived-gate ledger (40/40 run, 0 NOT-MEASURED) is at this head. The one first-pass red (ui scripts/, @objectstack/client unresolved during a parallel build) is a prerequisite and not this diff.

L2 owed: no. None of the four contract faces is touched: Clause-②: no, no narrowing, no packages/spec/src, no governed rule text. This is a ui label change with no surface added.

Landing tier: NOT governed (0 of 19 paths), +179/−17 = 196 lines, no spec face and no narrowing. The area lands it (ordinary queue landing).

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 17, 2026 10:18
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit 81ea504 Nov 17, 2026
63 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-jp2quk branch November 17, 2026 11:05
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