Skip to content

Commit b98173c

Browse files
feat(console): a comments column on the list page, with the threads of the records the view shows (#39157)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBTXKtrYYWM5CrtT3nwCLimA)_ Fixes #39085 Clause-②: yes (widening) Metadata-protocol: none ## 维护者速读 - 用户看到什么:对象列表页(表格、看板)头部多了一个评论图标,点开后右侧出现 380px 评论栏,列表随之变窄;栏里是当前视图这些记录上的评论串,最新在前,可以就地展开回复、解决、表情、编辑、删除,开关状态浏览器会记住。 - 为什么:专题 #39077 的 U3,用 S3(#39084)的一次性读取口,范围是视图已保存的筛选加上读者未保存的筛选,搜索框不算。 - 出错会怎样:只按读者自己的权限读;筛选发不出去、没权限、读取失败、服务器不支持时,栏里分别说明,不会退回到列出全部记录的评论;关着的时候不发任何请求。 - 要你做什么:无。 ## What changes - **`@object-ui/types`** — optional `DataSource.queryCommentThreads(request)`; its presence is the capability. Re-exports `CommentThreadsQueryRequest` / `CommentThreadsQueryResponse` from `@objectstack/spec/api` (not `CommentThread`, which collides with the collaboration component's name). - **`@object-ui/data-objectstack`** — `ObjectStackAdapter.queryCommentThreads` calls `client.comments.queryThreads` (`POST /api/v1/comments/threads/query`); a refusal passes through as the client threw it. - **`@object-ui/plugin-list`** — `ListView` host prop `onEffectiveFilterChange` (new sibling module `listEffectiveFilter.ts`; `ListView.tsx` gets one call). It reports `buildEffectiveFilter(authored, panel, filter bar, queue, drops)`, the `$filter` the list's own read sends, on every layout (a board answers `onFindParamsChange` with `null`, so that channel could not serve kanban). The search term and a calendar window are not in it. A `FilterOperatorError` reports `{ kind: 'unlowerable' }`, never "no filter". Built only while a host listens and after the object definition loads; reported only when the filter changes by content. - **`@object-ui/plugin-detail`** — presentational `ViewCommentsPanel` (cards, filter menu, load-more, the seven states, Esc/✕), `splitCommentMentions` for the mention highlight. - **`@object-ui/i18n`** — seven `detail.viewComments*` keys in all 11 locales (zh-Hant from the generator), mirrored in `DETAIL_DEFAULT_TRANSLATIONS`. - **`@object-ui/app-shell`** (private) — `objectViewComments.tsx` (the icon and the offer: desktop, grid or kanban, `enable.feeds !== false`, the door present), the lazily loaded `objectViewCommentsColumn.tsx` (the column, and an expanded card as the record's live discussion through `useRecordDiscussion` + `DiscussionContextProvider` + `CommentThread mode="expand"`), and `useViewCommentThreads.ts` (one request per page, keyed by content; a `sys_comment` write announced re-reads the loaded pages in one request up to 50; stale answers dropped; refusals mapped to states). `ObjectView.tsx`, `objectViewListRenderer.tsx`, `objectViewPageHeader.tsx` and `PageHeader.tsx` get calls and pass-throughs only: `PageHeader` takes `comments` into the shell group's first slot (or after the page actions outside the shell). `useCommentsPanelOpen` takes a key; `commentResolutionOf` / `rowMentionsUser` are exported for the card mapping. - Docs: `content/docs/frontend/plugins/plugin-detail.mdx` § The list page's comments column; plugin-detail and plugin-list READMEs; changeset (patch on the five published packages). ## Tests - `ui/packages/app-shell/src/views/ObjectView.commentsColumn-39085.test.tsx` (8): through the real `ObjectView` and `ListView` — icon on a grid, none read while closed; pressed, the column sits in the content row beside the list (`w-[380px] shrink-0`, not `absolute`), reads ONE page with the view's filter; the record name opens the record through the row-click path; ✕ closes and is remembered, no read after; open state remembered and a `sys_comment` write announced re-reads once; icon on a board; no icon with feeds off or without the door. - `ui/packages/app-shell/src/views/useViewCommentThreads-39085.test.tsx` (24): first page once with scope + toggles; nothing before the list reports and nothing for `unlowerable`; re-read on scope/toggle change, none for an equal scope; load-more appends with dedupe; failed next page; write announced re-reads the loaded pages in one request (`limit: 30`); a superseded answer is dropped; cards past the 50-thread re-read ceiling kept with their cursor; a failed re-read keeps the cards and releases a superseded load-more; retry; no door ⇒ `unavailable`; error-to-state table; row mapping. - `ui/packages/plugin-detail/src/comments/ViewCommentsPanel.test.tsx` (14): cards, mention highlight, replies summary, no new-thread box; open-record vs expand; expanded via host; ✕/Esc; load-more and its retry; filtered-empty with show-all; empty; loading, failed + retry; denied/unscoped/unavailable with no filter menu; `splitCommentMentions`. - `ui/packages/plugin-list/src/__tests__/ListView.harness.test.tsx` new block `ListView.onEffectiveFilterChange-39085` (4): grid reports exactly the read's `$filter`, once; a board reports too; the search term is left out; a malformed filter reports `unlowerable` and nothing else. - `ui/packages/data-objectstack/src/queryCommentThreads-39085.test.ts` (4): the filter is normalised as `find` normalises `$filter` (rule list lowered, empty sent as no filter); a filter `find` refuses is refused before any request; answer and refusal pass through. - `ui/e2e/list-frame-geometry-35548.spec.ts`: its source-text pin on `<ObjectViewPageHeader …/>` admits the new `comments={…}` prop (the pin went red on 489710f). ## Acceptance notes - **Filter scopes the threads; view switching changes the column.** The list reports its effective filter (saved + unsaved panel/bar/queue conditions, no search) and the column keys its read on it by content (ObjectView test 2, hook test 3, harness block). A view switch remounts the list, which reports its own filter. - **Narrower access sees fewer threads.** Server side (#39135 runs the filter as the caller); the client sends nothing that widens it, and an unlowerable filter is never sent as "no filter" (harness test 4, hook test 2). - **Replying raises the count; resolving with 「显示已解决」 off removes the thread and clears the row dot.** Writes in an expanded card go through the record page's own unit (`useRecordDiscussion`), which announces `sys_comment`; the column re-reads (ObjectView test 5, hook test 6) and U1's dot re-reads on the same announcement (pinned in #39106). - **「只看我参与的」 keeps a thread where I'm mentioned.** Sent as `onlyMine: true`; the server's participants include mentions (#39081 / #39135). - **No new top-level control.** The icon sits in the shell's button group via `PageHeader`'s `comments`; `useShellPageActionsSlot` was already shaped for it. - **Grid narrows at 1440 px; kanban the same.** The column is a `shrink-0` flex sibling in the content row for both layouts (ObjectView tests 2 and 6). Not measured in a browser. - **Feeds off ⇒ no icon. The drawer has no comments.** ObjectView test 7; the drawer is untouched. - **One threads request per page; none while closed.** ObjectView tests 1, 2, 4, 5; hook tests 1, 4. - Deviation: where the server lacks the threads read (the hosted dispatcher, #39134), the adapter still has the method, so the icon shows and the column says the server cannot list a view's comments (a 404/405/501 maps to `unavailable`), per the claim's premise. - Files to read first: `ui/packages/app-shell/src/views/useViewCommentThreads.ts` (request keying, re-read and stale-drop), `ui/packages/plugin-list/src/listEffectiveFilter.ts` (what is reported and when), `ui/packages/app-shell/src/views/objectViewComments.tsx` (the offer and the scope's lifetime). - Two-minute check: open any feeds-on object list on a self-hosted console, press the speech-bubble icon top right: a 380 px column opens beside the grid listing the comment threads of the rows the view shows; change the filter and the column re-reads. ## Verification - Typecheck (`tsc --noEmit`): types, data-objectstack, plugin-list, plugin-detail, i18n, app-shell — all clean. - New tests: 54 passed across the five files above (the harness block run with `-t`). - Neighbouring suites: PageHeader ×4, ShellPageActions ×2, ConsoleLayout.noTopBar, ObjectView.shellPageActions / headerFold / rowCommentDot, objectViewPageHeader ×2, defaults-maps-mirror-en-pack, RecordDetailView.harness and every `plugin-detail/src/comments` file — 22 files, 301 tests passed. `@object-ui/i18n` suite 110 files, 1874 passed. - Eager closure budget after a console build: `i18n-locale-en` 70.2 KB of 78.7 KB; every ceiling green. - `node scripts/pm/dispatch-gates.mjs --commands`: 74 commands; 72 exit 0. Two NOT MEASURED locally, left to CI: `pnpm --dir ui exec vitest run scripts/` was killed by the container's memory limit (re-run with `--maxWorkers=2`: 172 files, 5159 tests passed), and `check:skill-examples` refused its prerequisite (no `client-react` build; exit 3, nothing measured). - L2 (contract review) PASS on f51a85d with S1 and S2 should-fix; fixed in 669406b (re-read keeps cards past 50, failed re-read keeps cards; adapter filter normalised as `find`) and 0a8ba35 (nits N6, N7). Delta record PASS on 0a8ba35: S1 and S2 closed. After the fixes: the three touched test files 36 passed, `tsc` clean for types, data-objectstack, app-shell. - CI on 489710f: `Build & E2E UI` red on the source pin fixed in f51a85d; `console-service-worker` was flaky there (passed on retry). https://claude.ai/code/session_01WGufzgJzS4DfAbhGoRzv5o --- _Generated by [Claude Code](https://claude.ai/code)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent a294369 commit b98173c

42 files changed

Lines changed: 2585 additions & 14 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
'@object-ui/types': patch
3+
'@object-ui/data-objectstack': patch
4+
'@object-ui/plugin-list': patch
5+
'@object-ui/plugin-detail': patch
6+
'@object-ui/i18n': patch
7+
---
8+
9+
feat(console): a comments column on the list page, with the threads of the records the view shows
10+
11+
Clause-②: yes (widening) — new optional members and exports only: `DataSource.queryCommentThreads` and the `CommentThreadsQueryRequest` / `CommentThreadsQueryResponse` types on `@object-ui/types`; `ListView`'s `onEffectiveFilterChange` host prop and the `ListEffectiveFilter` type on `@object-ui/plugin-list`; `ViewCommentsPanel`, `splitCommentMentions` and their types on `@object-ui/plugin-detail`; nothing removed or renamed
12+
Metadata-protocol: none
13+
14+
An object's list page now has a comments icon in its header, on a grid and on a board, where the object's discussion is on (`enable.feeds` not `false`). A press opens a 380 px column at the page's right and the list narrows to make room; ✕ or Esc closes it, and the browser remembers whether it was left open.
15+
16+
The column lists the comment threads on the records the view shows, newest first: the view's saved filter together with the filters the reader has set on the list and not saved. The search box does not narrow it. The server runs the filter as the reader's own read, so someone who may read fewer records sees fewer threads. Each card names the record (which opens it the way a row does), who wrote the first comment and when, its text with mentions highlighted, and 「N 条回复」 with the latest repliers' faces; 「加载更多」 reads the next page. A card opens its thread in place, with reply, resolve and reopen, reactions, edit and delete as the record page offers them; there is no box for a new thread. The filter menu holds 「显示已解决」 (off) and 「只看我参与的」. The column reads again when the view, its filter or a toggle changes and when a comment is written, and reads nothing while closed. It says so when the reader may not read the comments, when the read failed (with a retry), when the list's filter cannot be sent, and when the server does not answer the threads read (`POST /api/v1/comments/threads/query`).
17+
18+
For React hosts: `ObjectStackAdapter.queryCommentThreads(request)` calls that read; `ListView`'s `onEffectiveFilterChange` reports the filter the list applies, on every layout (`{ kind: 'filter', filter }`, or `{ kind: 'unlowerable' }` for a filter it cannot lower); `ViewCommentsPanel` draws the column from threads its host reads.

‎content/docs/frontend/plugins/plugin-detail.mdx‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,42 @@ The components are exported from `@object-ui/plugin-detail` (`CommentsPanel`,
351351
`CommentComposer`, `useRecordComments`); each reads the discussion off the host's
352352
`DiscussionContext`, as the feed blocks do.
353353

354+
## The list page's comments column
355+
356+
An object's list page carries the same comments icon, without a number, in its
357+
header's button group, on a grid and on a board (objectstack#39085). It is
358+
there only on the desktop, on an object whose discussion is on
359+
(`enable.feeds` not `false`), against a server that answers the threads read
360+
(`POST /api/v1/comments/threads/query`). A press opens a 380 px column at the
361+
page's right and the list narrows to make room; the icon shows it pressed. ✕
362+
or Esc closes it, and the browser remembers whether it was left open. The
363+
record drawer still shows no comments.
364+
365+
- **Which threads.** The comment threads on the records the list shows: the
366+
view's saved filter together with the filters you have set on the list and
367+
not saved. The search box does not narrow them. The server runs that filter
368+
as your own read of the object, so someone who may read fewer records sees
369+
fewer threads. Where the list's filter cannot be sent, the column says so
370+
instead of listing every record's threads.
371+
- **The cards** are newest first, one per thread: the object's icon and the
372+
record's name, who wrote the first comment and when, its text with the
373+
people it mentions highlighted, and 「N 条回复」 with the faces of the latest
374+
repliers. 「加载更多」 reads the next page. The record's name opens the
375+
record the way a row of the list does.
376+
- **A thread in place.** The card, or its 「N 条回复」, opens the thread where
377+
it is, with reply, ✓ resolve and reopen, reactions, Edit and Delete, each
378+
offered exactly as on the record page. There is no box for a new thread:
379+
a new thread starts on the record.
380+
- **The filter menu** holds 「显示已解决」 (off) and 「只看我参与的」, as on the
381+
record page. With nothing left to show it offers 「显示全部」.
382+
- **It stays current.** The column reads again when the view, its filter or a
383+
toggle changes, and when a comment is written: a reply raises the count, a
384+
thread resolved while 「显示已解决」 is off leaves the column, and the row's
385+
comment dot goes with it. Closed, it reads nothing.
386+
- **When it cannot read**, it says which: you may not read this object's
387+
comments, the read failed (with a retry), or the server does not list a
388+
view's comments.
389+
354390
## The `record:activity` block
355391

356392
`RecordActivityTimeline` is a presenter: you hand it `items`. The SDUI block

‎ui/e2e/list-frame-geometry-35548.spec.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,8 @@ test.describe('the list page frame (objectstack#35548)', () => {
310310
// The page bar names the object as the page's heading, and the view bar
311311
// does not (objectstack#36113, which split objectstack#35878's one row).
312312
expect(SRC.pageBar.includes('data-testid="list-view-bar-object-name"'), `${FILES.pageBar} names the object in the view bar again`).toBe(false);
313-
expect(/<ObjectViewPageHeader \{\.\.\.pageBarProps\} hosted=\{listBarHosted\} \/>/.test(read('packages/app-shell/src/views/ObjectView.tsx')), 'the list page no longer draws its page bar above the view bar').toBe(true);
313+
// objectstack#39085 — the bar also carries the comments icon (`comments=`).
314+
expect(/<ObjectViewPageHeader \{\.\.\.pageBarProps\} hosted=\{listBarHosted\}(?: comments=\{[\w.]+\})? \/>/.test(read('packages/app-shell/src/views/ObjectView.tsx')), 'the list page no longer draws its page bar above the view bar').toBe(true);
314315
// One trigger: type icon → name → count → caret, in that source order.
315316
const at = SWITCHER_PARTS.map((p) => switcherBody.indexOf(`data-testid="list-view-switcher-${p}"`));
316317
expect(at.every((i) => i > 0), `a switcher part is missing: ${JSON.stringify(at)}`).toBe(true);

‎ui/packages/app-shell/src/layout/PageHeader.tsx‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,12 @@ export interface ConsolePageHeaderProps {
182182
* nothing keeps today's header at every width.
183183
*/
184184
compactBelow?: number;
185+
/**
186+
* objectstack#39085 — the page's comments entry (the list page's comments
187+
* icon): the first button of the shell's group where the shell draws one,
188+
* else after the page's own actions.
189+
*/
190+
comments?: React.ReactNode;
185191
/**
186192
* CSS color used to tint the top hairline, icon chip background, and
187193
* icon stroke. Defaults to the Shadcn `--primary` token so the header
@@ -233,6 +239,7 @@ export function PageHeader({
233239
actions,
234240
foldedActions,
235241
compactBelow,
242+
comments,
236243
accentColor,
237244
sticky = false,
238245
posture,
@@ -283,7 +290,8 @@ export function PageHeader({
283290
const renderSidebarExpand = useShellSidebarExpandSlot();
284291
const leading = renderSidebarExpand?.();
285292
const pageActions = refreshButton || drawnActions;
286-
const trailing = (pageActions || renderShellGroup) && (
293+
const ownComments = renderShellGroup ? null : comments ?? null;
294+
const trailing = (pageActions || renderShellGroup || ownComments) && (
287295
<div
288296
ref={clusterRef}
289297
className="flex items-center gap-1.5 sm:gap-2 shrink-0"
@@ -295,7 +303,8 @@ export function PageHeader({
295303
{renderShellGroup && pageActions && (
296304
<span aria-hidden="true" className="h-4 w-px shrink-0 bg-border" data-testid="page-header-shell-divider" />
297305
)}
298-
{renderShellGroup?.({ assistantIconOnly })}
306+
{ownComments}
307+
{renderShellGroup?.({ comments, assistantIconOnly })}
299308
</div>
300309
);
301310

‎ui/packages/app-shell/src/layout/shellPageActionsSlot.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ import { usePhoneViewport } from '../hooks/usePhoneViewport.js';
2323

2424
export interface ShellPageActionsSlotProps {
2525
/**
26-
* The comments entry, first in the group: handed by the list and record
27-
* pages only, nothing until the comments work puts its icon here.
26+
* The comments entry, first in the group: handed by the record page
27+
* (objectstack#36112) and the list page (objectstack#39085, through
28+
* `PageHeader`'s `comments`) only.
2829
*/
2930
comments?: React.ReactNode;
3031
/**

0 commit comments

Comments
 (0)