Repository navigation
feat(console): 「+ Filter」 under the report builder's data source - #36705
Conversation
Claude-Session: https://claude.ai/code/session_01JQwxbXeiNLk9jGd2XxhBfz Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQwxbXeiNLk9jGd2XxhBfz Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQwxbXeiNLk9jGd2XxhBfz Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#1 · os-warren · session_01JQwxbZeHNsF3RWcWpj7rGj Contract reviewServed-tier: The head did not move during the review. Everything below comes from reading the diff and the tree. I ran nothing. CI on the head is green: every check-run is success or skipped. ① Derived judgmentsThe widening is minimal and additive. Declarations: correct. Round trip of a holdable filter: exact. Last condition removed drops the key: yes. An empty group passes Unholdable filter saved byte-identical: yes, for the shapes the bridge recognises. When Does opening ever rewrite? No. Nothing commits on open. But one valid shape is read wrongly and is lost on the next edit (M1). Pins fail without the fix: consistent by reading. Without the change, these fail:
That is 7, the thread's number. Two pins pass on base, and that is right: the pure Fields the door won't lower. Relationship paths are not offered. The door binds a bare object-field key past a shadowing dimension ( ② Semver level
③ Boundary flags
④ Design judgmentThe slot design is right. The builder stays field-agnostic, and the host supplies the one shared editor and the one shared field mapping.
Notes:
Implemented-by: VERDICT: FAIL |
…er no formula fields The shared filter bridge read only the $and rows of a filter that also has other top-level keys and called it editable, so the report builder (and the dataset designer) opened it where the next edit would drop the siblings. It now needs $and to be the only key, and a logical operator in a field slot is not a row. The report filter no longer offers virtual (formula) fields, which the dataset door refuses. Claude-Session: https://claude.ai/code/session_01JQwxbXeiNLk9jGd2XxhBfz Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#1 · os-warren · session_01JQwxbZeHNsF3RWcWpj7rGj Contract reviewServed-tier: The PR head is still Round-1 items
Declarations, exports, tests
No must-fix, no should-fix.
VERDICT: PASS |
|
repo:objectstack#1 · os-warren · session_01JQwxbZeHNsF3RWcWpj7rGj 维护者速读报表编辑器的数据来源下面加了「+ 筛选」:选完数据来源可以直接加条件(比如只看本季度、只看某个负责人),优先列出业务字段,公式字段不出现。条件编辑器复用列表页已有的那一个,不另做一套。#36645 的第 2 项(显示数量为 0 的分组)已按你的选择单开成 #36722,第 3 项(和上一期对比)还在等引擎卡 #35395,所以这张卡先不关。 席位核对 — ACCEPT (L1) · repo:objectstack#1 · head
|
…od chip (objectstack-ai#36767) <!-- claude-projects-attribution: {"github_login":"os-warren"} --> _Requested by **Warren** · [project thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ8Hx43jgsjNPA5ohr5yAhkBL)_ Fixes objectstack-ai#36645 — item 3 (「和上一期对比」). Item 1 shipped in objectstack-ai#36705; item 2 moved to its own card, objectstack-ai#36722; so this closes the card. Clause-②: yes (widening) Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:报表上方的时间范围旁边多了一个「和上一期对比」开关,和「之前同样长的一段时间」比。打开后,按类别分组的柱状图、折线图(比如按状态)每组旁边多一根浅色柱,就是上一期的数;「数字」图在数字下面写「较上期 3(+133.3%)」。横轴本身就是按月/按周的日期时,不提供这个开关,因为两段时间的月份数可能不一样,柱子会对错月份。报表页和搭建页的预览都有。 - 为什么做:仪表盘和报表专题里搭建页的最后一项,是维护者看过的效果图三第 6 项的后半句;挡它的引擎缺陷 objectstack-ai#35395 已于 11-22 修好。 - 出错会怎样:开关只是看的人自己的选择,不存进报表,关掉就和以前一样;服务器拒绝对比时,图的位置会写明原因,不会悄悄消失。选「全部时间」时没有可对比的上一期,开关变灰。可以直接撤回本次合并。 - 要你做什么:无。(两件事没做、需要的话另开功能卡:「默认就打开对比」随报表保存;按「上一个自然月/季度」对比,好让日期横轴也能用。) ## What changes **The switch** (`ui/packages/plugin-report/src/ReportDateRange.tsx`) - `ReportCompareToggle`: 「Compare with previous period」 beside the period chip. Like the chip's own pick it is the viewer's state, keyed on the report's `dateRange` declaration, never written into the report. Off, and disabled, while the period names no window (All time, or a custom range missing an end). - `reportChartComparable(chart, windowDimension)`: offered only where the chart can draw a clean comparison — `bar`, `column`, `horizontal-bar`, `line`, `area` over an x axis that is NOT the window's own date dimension, or a single number (`metric`, `kpi`) — and not on a `seriesBy` split (its series are values of the split dimension, so no series pairs with the measure's earlier window). Pie / donut / funnel / treemap / sankey / table are not offered it. Nothing is offered until the window's dimension is known. - `reportCompareTo`: the selection's `compareTo` only while on AND a window exists. **The chart** (`ui/packages/plugin-report/src/DatasetReportRenderer.tsx`) - `useDatasetRows` takes an optional `compareTo` and sends it beside the window it shifts (`compareTo: { kind: 'previousPeriod', dimension: <the window's dimension> }`, the existing `DatasetSelection.compareTo` contract); it is part of the query signature, so toggling re-queries. Only the embedded chart passes it; the table beside the chart is not asked for a comparison. - Series charts get one more series, `<measure>__compare` (the executor's column), labelled `<measure> · <dashboard.trend.vsPreviousPeriod>` with `variant: 'comparison'`, the chart's existing muted / dashed styling — the dashboard's overlay shape. The chart is compared with the same-length window just before the current one (the contract's `previousPeriod`). On a category axis the rows merge by key, so each category's earlier total sits beside its current one. - A single number shows the previous value and the signed percent change under it (`formatPeriodChange`, module-local; no percent when the previous value is 0). - A click on an earlier-window mark opens no record list (the dashboard's `chartDrillMeasure` rule for the same series); a current mark drills as before. - A refused comparison is drawn as the error where the chart was. Before, any chart error fell back silently to the table; with the switch on that would leave it on over a vanished chart. **Strings, docs, changeset** - `@object-ui/i18n`: one key, `report.dateRange.comparePrevious`, in all 11 locales. The series caption reuses the dashboard's `dashboard.trend.vsPreviousPeriod`. - `content/docs/ui/reports.mdx` › *Period and export*: one bullet on the switch, and the stale 「Declared, not drawn yet」 callout replaced (see Acceptance notes). - `.changeset/36645-report-compare-previous-period.md` (patch; plugin-report, i18n). No spec key, schema, export or server change. Read first (by risk): `DatasetReportChart` in `DatasetReportRenderer.tsx` (the series and the drill guard) · `reportChartComparable` (where the switch is offered). ## Why objectstack-ai#36374 item 6 (board 49, figure 3): the time switch offers 「和上一期对比」 and the chart draws both periods. It waited on objectstack-ai#35395 (`{current_iso_week}` left unshifted by compare-to), closed 2026-11-22 by objectstack-ai#36416. On base `460af0e4` the report renderer never sent `compareTo`, although the analytics executor answers it. ## Verification - New `DatasetReportRenderer.comparePrevious-36645.test.tsx`: `pnpm --dir ui exec vitest run packages/plugin-report/src/__tests__/DatasetReportRenderer.comparePrevious-36645.test.tsx` → 15 passed at `fd8a9260`. Ablation at the first head: `DatasetReportRenderer.tsx` checked out from `origin/main` (the new `ReportDateRange.tsx` exports left in place) → 8 failed | 4 passed; the 4 green by design are the "not offered" cases (donut, table, `seriesBy`, no period), which hold on base because base offers no switch at all. Ablation of the date-axis rule at `fd8a9260`: `ReportDateRange.tsx` and `DatasetReportRenderer.tsx` checked out from `ccb43920` (before the rule) → 2 failed | 13 passed, the two red being the new bar / line "not offered on the window's own date axis" pins. Both restored; `git status` clean before each commit. - `pnpm --dir ui exec vitest run --maxWorkers=3 packages/plugin-report/` at `fd8a9260` → 38 files, 377 passed | 7 skipped. `packages/i18n/` (first head) → 107 files, 2006 passed | 13 skipped (key parity across the 11 locales included). - ESLint on the three touched plugin-report files: 0 errors (warnings only, the file's existing `react-refresh` / test `any` kinds). `pnpm check:new-line-citations` → 0 new. - Not measured locally: the plugin-report type-check (it needs the built `@object-ui/*` declarations this container did not build); covered by CI Type Check UI. - Executor, live (showcase, `showcase_invoice_metrics`, `last_90_days`, grouped by `issued_on`): `{"issued_on":"2026-09","invoice_count":2,"invoice_count__compare":1}`, `2026-10` 2/1, `2026-11` 3/1 — the executor answers `compareTo`. (That date-axis shape is the one the switch no longer offers; see Acceptance notes.) - Browser (showcase on a local server, console from this branch's `ui/` source, zh-CN, admin). Frames in the project folder `issue-36645/`: - `item3-1-switch-beside-period.png` (first head) — the switch beside 「今年」 on a number, off. - `item3-6-date-axis-bar-not-offered.png` (`fd8a9260`) — new report → Invoice Metrics → group by Issued → 近 90 天, bar: the period chip and no switch. - `item3-4-number-previous-and-change.png` (`fd8a9260`) — the same report as 数字: switch on, 7, 「较上期 3 (+133.3%)」. - `item3-7-category-axis-two-periods.png` (`fd8a9260`) — report page 「按状态统计工时(图表)」, its list response intercepted in the browser to add `dateRange: { dimension: 'created_at', defaultRange: 'this_month' }` (showcase ships no report with a period): 本月 + switch on, a lighter earlier-window bar beside each status; the request carried `"dimensions":["status"],…,"timeDimensions":[{"dimension":"created_at","dateRange":"this_month"}],"compareTo":{"kind":"previousPeriod","dimension":"created_at"}`. - `item3-5-all-time-switch-off.png` (first head) — 全部时间: switch off and disabled, one series. ## Acceptance notes - Not done, by design: saving "compare on" as the report's default. That is a new report spec key (a widening of `ReportSchema.dateRange`), a separate Feature if wanted. - Not done: a comparison column in the report's table / 「计算值」 grid; the card asks the chart to draw both periods. - Contract review S1 (comment 7109766175), resolved by the seat's ruling: `ccb43920` first documented the position pairing; `fd8a9260` then stops offering the switch on a chart whose x axis is the window's own date dimension (the bars could pair with the wrong period where the two windows split into different bucket counts), and words docs, changeset and this body as "the same-length window just before it". A calendar-aligned comparison would be a new `compareTo` kind (a spec widening) and the seat files it as a separate Feature card. The `runCompare` unaligned-bucket overwrite the review escalated is an executor defect outside this diff, filed as objectstack-ai#36770. - Fixed here on the seat's word (same file): `content/docs/ui/reports.mdx` › *Period and export* carried the callout 「Declared, not drawn yet … there is no period chip」, false since the renderer draws the chip and the Export control (both `live` in the spec liveness ledger, so `os validate` no longer warns). Replaced with one paragraph saying what the page draws. ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. (not touched) - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; lint passes on the touched files. - [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: n/a. - [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 (the maintainer quick-read above is the allowed Chinese channel). - [x] The *Before Submitting* list in CONTRIBUTING.md is done. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01JQwxbYCxqr63HW2KJGpmAq <!-- signed: repo:objectstack#1 · os-warren · session_01JQwxbYCxqr63HW2KJGpmAq --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Requested by Warren · project thread
Part of #36645 — item 1 only (「+ 筛选」 under the data source). Items 2 (show zero-count groups, waits on the maintainer's pick) and 3 (compare with the previous period, blocked by the engine card) are not touched, so the card stays open.
Clause-②: yes (widening)
Metadata-protocol: none
维护者速读
What changes
The builder (
ui/packages/plugin-report/src/builder/)ReportBuildertakes an optionalfilterslot, drawn under the data source picker while a data source is bound. Host-controlled like the name box: the filterable fields are the dataset object's and the filter's conversion is the console's one shared bridge, so neither is read in this package.runtimeFilter(the old object's fields mean nothing on the new one). Now pinned.The console host (
ui/packages/app-shell/src/views/)ReportBuilderHostfills the slot with the existingFilterConditionField(the dataset designer's editor: the list toolbar'sFilterBuilderbehind thedatasetFilterConditionbridge), bound to the report'sruntimeFilter. Each committed edit lands in the draft, so the preview redraws at once; the last condition removed drops the key (no{}stored).reportFilterFields.ts(new): the fields offered are the dataset OBJECT's own fields, becauseruntimeFilteris keyed by object fields at the dataset door (not by dimensions). Read through the data source'sgetObjectSchemaand mapped by the list Filter panel's mapping (conditionCandidatesOf), so labels are translated, a select offers its options and a lookup its record picker. Hidden fields and virtual (formula) fields are left out (the dataset door refuses a filter on a formula field with 400 INVALID_FIELD); business fields come before system ones (so "Add filter" seeds on a business field); a record-mode amount's currency pairing is dropped because the bridge cannot hold its companion row.datasetFilterCondition.conditionToGroupreads$andas the group only when it is the ONLY top-level key:{ $and: [...], amount: {...} }or{ $and: [...], $not: {...} }(valid spec shapes) are now not representable, and a logical operator in a field slot ($not) is not a row. Before, the siblings were ignored, the filter opened as editable, and the next edit dropped them. This also closes the same hole in the dataset designer.FilterConditionFieldgains two optional props:addLabel(while empty, the trigger is a small 「+ 筛选」 link like 「+ 再分一层」; with rows it keeps the counted box) and an optionallabel.opensInBuilder: a dataset report with a saved filter now opens in the builder when the filter is one the editor can hold (field conditions joined by AND, read by the editor's ownconditionToGroup); an OR, a nested group, two operators on one field, or$andbeside other keys still keep the inspector panel.Exports and strings
@object-ui/plugin-listexportsconditionCandidatesOf,conditionOptionsOfand theConditionCandidateFieldtype (the one mapping, reused rather than copied).@object-ui/i18n:report.builder.source.addFilter,filterAdvanced,filterLoading,filterNoFieldsin all 11 locales..changeset/36645-report-builder-filter.md(patch; plugin-report, app-shell, plugin-list, i18n).Read first (by risk):
ReportView.tsxopensInBuilder(which reports now route to the builder) ·reportFilterFields.ts(which fields are offered) ·FilterConditionField.tsx(shared with the dataset designer; additive props only).Two-minute check: open any dataset report's 「编辑」, click 「+ 筛选」 → 「添加筛选」, pick a field and a value — the chart redraws at once; Save, reopen 「编辑」 — the trigger reads 「1 个条件」.
Tests
plugin-reportreportBuilder-36374.test.tsx, new top-level describe 「the report filter under the data source (objectstack#36645)」: the slot draws under the data source only once one is bound; a filter set/cleared reaches the preview'squeryDatasetselection at once and the report stays spec-valid; switching data source drops the filter, re-picking the same one keeps it.app-shellReportBuilderHost.filter-36645.test.tsx(new; real host, builder,FilterConditionField,FilterBuilder): field list (hidden and formula fields out, system last, options and lookup target kept, no currency pairing); 「+ Filter」 offered and the object definition read; a condition typed is in the preview query and in what Save hands over; an existing filter opens counted, an edit saves, Clear all saves NOruntimeFilter; a filter the editor cannot hold is shown as kept and saved byte-identical, both by shape and by field type ($gton a text field, once the fields are read).app-shelldatasetFilterCondition.test.ts:$andwith a field or$notsibling, a non-array$and, and a top-level$notare not representable; a lone$andstill round-trips.app-shellReportView.saveRefusal-11583.test.tsx: theopensInBuilderpin that asserted "a saved filter keeps the panel" is replaced by the new routing (holdable filter → builder; OR / nested / two-operator /$andwith siblings /$not→ panel). That old assertion encoded the premise this card changes; the other shapes it pinned (cross-tab, several values) are kept.Local runs
inspectors/folder plus the three files above — Test Files 251 passed (251), Tests 3297 passed | 1 skipped (3298).datasetFilterCondition.tsandreportFilterFields.tsturned the 3 new pins red (bridge$andsiblings, routing table, field list).Acceptance notes
runtimeFilter: { priority: { $eq: 'high' } }read back from the served report), 「编辑」 reopened in the builder with 「1 个条件」, Clear all brought back 「+ 筛选」 and the saved report carries noruntimeFilter. Six frames are attached on the project thread (GitHub's image store takes browser uploads only)..customoverlay package). Measured with a chart-type change and no filter on the same report — same refusal, so it is the builder's save path, not the filter. Filed as 报表编辑器保存应用包里自带的报表时返回 403,没有写到 .custom 覆盖包 #36716.account.region) are out of reach, as they are in the dataset designer's filters.Verification
Generated by Claude Code
🤖 Generated with Claude Code
https://claude.ai/code/session_01JQwxbXeiNLk9jGd2XxhBfz