Repository navigation
Commit f6b008e
refactor(console): the record page's discussion becomes one unit other pages can mount (#39109)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} -->
_Requested by **Yibo Wang** · [project
thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBMRMFECL2eZbHeBsnrEZRLG)_
Fixes #39083
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 用户无感:记录详情页的评论区看起来、用起来都和以前一样,打开记录时发出的请求也和以前一样。
- 属于「列表页对象评论」专题:把记录页的评论读写收成一个可复用的整体,让列表页之后能直接挂上评论。
- 出错时影响的是记录页评论的发、回、表情、改、删、解决与重开;纯重构,撤回这一个提交即可复原。
- 要你做什么:本次改动超过三千行人审线(主要是代码整段搬家),L1 通过后请你人工审阅。
## What changes
The record page's discussion moves out of `RecordDetailView` into
`useRecordDiscussion`
(`ui/packages/app-shell/src/views/useRecordDiscussion.ts`), a hook keyed
by object and record id that a second page can mount. It owns:
- the comment rows and the comments read verdict, per record key;
- the comment read (`readComments`): comments, their reactions on either
store, reply counts, resolutions and resolver names, served from the
record-page payload when the page has one, else read as before;
- every comment write: post, reply, edit, delete, resolve/reopen, react,
with the write gates and the failure toasts unchanged;
- the panel's two record verdicts (may the viewer moderate comments
here, may they update a comment they did not write) and the engagement
flag that defers them.
The record page mounts it once and still calls `readComments` from
inside its own feed effect beside the activity read, so the open
sequence keeps its order. Activity rows reach the unit through
`mergeRows`. The hook reads nothing on mount. Activity and attachments
stay in `RecordDetailView`. The module-level helpers moved verbatim with
the code that uses them. The hook is internal: it is not exported from a
package entry, so no contract-tier record is owed (per the claim).
Diff: 5 files, +1,760 / −1,400 = 3,160 changed lines, mostly a verbatim
move. This is over the 3,000-line human-review line and is deliberately
**not split**.
## Why
Epic #39077 puts the same discussion on list pages (U3, #39085). That
needs the record page's discussion as one unit a host can mount for any
record, which it was not: its state, read and writes were spread through
a 4,000-line component.
## Tests
- New `ui/packages/app-shell/src/views/useRecordDiscussion.test.tsx`
mounts the unit for two records in one component. It checks five things:
nothing is read on mount; each record's comments and reply counts stay
in their own mount; a refused read marks only that record; a reply is
written under its own record and leaves the other mount's rows
identical; `mergeRows` merges into the right record.
- **One existing test edited:**
`ui/packages/plugin-form/src/affordanceGrantMap-12082.test.tsx`, the
write census. It keys write sites by `file :: symbol path :: verb`, so
the six comment write sites move from `RecordDetailView.tsx ::
RecordDetailView > …` to `useRecordDiscussion.ts :: useRecordDiscussion
> …`. The rows they point at and their verbs are unchanged.
- All 27 record-page comment, reaction and feed suites
(`RecordDetailView.*` comment/feed/reaction/payload/open-wave files,
`ShellPageActions*`, `activityItemType-6730`, `countLabels.ruAr-10242`)
pass **unedited**.
<details><summary>Final run (head cb87266): 29 files, 457 tests
passed</summary>
```
RecordDetailView.activityMapIdentity-5878, .activityUnmappedType-5896, .authoredActivityThreading-12249,
.commentWriteFailure-10899, .commentsPanel-36075, .commentsResolved-36075, .discussionExplicitComposition-7298,
.discussionFallbackPipeline-8983, .feedCommentEditDelete-12268, .feedGrant-12082, .feedLoadFailure-29188,
.feedLoading, .feedRecordScope, .harness, .reactionKeepIds-11019, .reactionRecords-12078,
.reactionWriteFailure-10899, .reactionsCommentRowsOnly-11035, .recordOpenOneRequest-28470,
.recordOpenWaves-13010, .recordPagePayload-27627, .replyCountOnRead-12144, .withheldMentions-28218;
layout ShellPageActions-36111, ShellPageActions.askAi-37858, activityItemType-6730; countLabels.ruAr-10242;
useRecordDiscussion; plugin-form affordanceGrantMap-12082
Test Files 29 passed (29)
Tests 457 passed (457)
```
</details>
The rest of the `RecordDetailView.*` suites also pass, in two batches:
50 files with 422 tests, and 32 files with 276 tests.
## Acceptance notes
- **Existing record-page comment suites pass unmodified:** yes, see
above. The only edited test is the write census, named above.
- **Same requests in the same order on open:** checked in the browser
against `main` (showcase app, an account record with the comments panel
open), two runs on each side. The record-scope sequences match, except
for the audit-log read, which shows up once or twice at random on both
`main` and the branch. The record-page payload request bodies are
byte-identical across all runs.
- **Post, reply, react, edit, delete, resolve, reopen behave as
before:** each one driven in the browser on the branch and on `main`.
All seven succeed on both sides and send the same writes: `POST
sys_comment` (post), `POST sys_comment` (reply), `POST
sys_comment_reaction`, `PATCH sys_comment/:id`, `PUT
comments/:id/resolution` (resolve and reopen), `DELETE sys_comment/:id`.
Read back over the API, the stored rows are the edited root (not
resolved after the reopen), the reply removed, and one 👍 on the root.
- **Second mount for another record shares no state:** the unit test
above.
- **Activity and attachments stay put; no request added or removed:**
activity, attachments and their reads stay in `RecordDetailView`; the
request multisets above match.
- **Docs:** not applicable (ui AGENTS rule 2). The hook is internal and
unexported. U3 documents the list-page surface it opens.
## Verification
Read first, in order of risk:
1. `RecordDetailView.tsx`, the feed effect around line 3280:
`discussion.readComments(...)` replaces the inline comment read at the
same point, and `discussion.mergeRows` replaces the two activity merges.
The effect still keys on primitives and reads `discussion` without
keying on it (an eslint-disable line says why).
2. `useRecordDiscussion.ts`, the return block at line 1437: each handler
is handed out under the same gate the old render props used
(`feedsEnabled` plus the matching write gate).
3. `useRecordDiscussion.ts`, `moderatesComments` /
`updatesOthersComments`: they now take the verdict object name and
`verdictsWanted` from the host. Both are still asked after the page's
own editable question, as before.
Two-minute check: open any record, open the comments panel, post a
comment and reply to it. Both appear as before, and the network panel
shows `POST /api/v1/data/sys_comment` twice.
Local gates: all 38 from `dispatch-gates --commands` exit 0. `tsc
--noEmit` passes on app-shell `tsconfig.json` and `tsconfig.test.json`.
ESLint on the four touched source files: 0 errors and 158 warnings. On
`main`, `RecordDetailView.tsx` alone has 156 warnings, and most of them
moved with the code.
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes.
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed. (Not touched.)
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01WGufzew8W6iW6kx7oqmWyo
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent ec73246 commit f6b008e
5 files changed
Lines changed: 1760 additions & 1400 deletions
File tree
- .changeset
- ui/packages
- app-shell/src/views
- plugin-form/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
0 commit comments