Repository navigation
Commit 4240719
feat(ui): a timesheet list view, an editable row × weekday entry grid (#34925)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} -->
_Requested by **Yibo Wang** · [project
thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBLW6dHPW6sSheA32XPKZzPV)_
Fixes #34382
repo:objectstack#3 · os-support-ai · session_01WGufzgTk2cRpVHpSVk9tzF
Clause-②: yes (widening: one new accepted `type` value on list views,
one new optional config block on the view schema, and a new published
`@object-ui` plugin package with one component)
Metadata-protocol: added (a new list view type and its config block an
author can write)
Skills-docs: regenerated only —
`skills/objectstack-ui/references/react-blocks.md` is the generated
react-blocks contract, which picks up the new `object-timesheet` block;
no hand-written skill text changes
## 维护者速读
- 改了什么:列表视图新增一种类型「工时表」(`type: 'timesheet'`):按行字段(如项目)×
一周七天把明细记录排成可编辑的格子,每格就是一条记录;在空格里输入数字就新建记录,改数字就更新,清空就删除;行合计、日合计、周合计始终显示;一格里有多条记录时只读显示合计。
- 为什么改:HotCRM 的「我的一周」工时录入要按周表格填写,现在只能用按项目分组的列表逐条编辑;HotCRM 等这张卡。
-
风险与回滚:只是新增一种视图类型和一个新的懒加载渲染包,不改已有类型的行为;每格的写入都走正常的记录接口,钩子、校验和权限逐格判定,被拒绝时留在那一格并显示服务端的原因。回滚即还原本
PR。改动 3887 行(129 个文件),超过 3000 行,且涉及 skills/** 生成文件,按 Tier H 处理。
-
先看:`ui/packages/plugin-timesheet/src/timesheetModel.ts`(记录怎么落到行和天、每格该新建/更新/删除哪条);`ObjectTimesheet.tsx`(查询一周、逐格写入、添加行);`packages/spec/src/ui/view.zod.ts`
里新增的 `timesheet` 块。
- 两分钟验证:中文界面给一个有「项目 / 日期 / 工时」字段的对象建一个 `type: 'timesheet'`
视图(`timesheet: { rowFields: ['project'], dateField: 'work_date',
valueField: 'hours' }`),打开后应看到周一开始的一周,在空格输入 4 回车后合计变化,列表里多出一条记录。
- 需要你做的:超过 3000 行,需要 os-zhuang 批准后由席位落地。
## What changes
A list view can now be `type: 'timesheet'`. It pivots detail records
into rows × the seven days of one week, and every cell is editable.
```ts
type: 'timesheet',
timesheet: {
rowFields: ['project', 'task'], // 1–3 fields; one row per distinct combination
dateField: 'work_date', // date or datetime
valueField: 'hours', // number, currency or percent
}
```
- **Spec** (`packages/spec/src/ui/view.zod.ts`): `timesheet` joins the
list view `type` enum and the `VisualizationType` members, and
`TimesheetConfigSchema` is the new optional `timesheet` block
(`rowFields` 1–3 names, `dateField`, `valueField`, all required inside
the block). Liveness rows for the three keys, regenerated artefacts and
reference docs.
- **Renderer**: new lazy package `@object-ui/plugin-timesheet`,
component `object-timesheet`, registered lazily by the console.
`ListView` composes it for a `timesheet` view; `ObjectView` composes it
for a host `views` entry.
- **Query**: one `find` per displayed week, the view filter AND
`dateField` inside the week, capped at the non-grid row ceiling, with
the row fields' relations expanded (field-level read access permitting).
- **Writes**: typing into an empty cell `create`s a record with the
row's field values, the day and the number; changing a one-record cell
`update`s it; clearing it `delete`s it. Each is one call on the record
API, so hooks, validation rules and permissions judge each cell. A
refusal stays on the cell with the server's message and the typed text;
Enter retries. Each write is announced with `notifyDataChanged`.
- **Multi-record cells** show their sum, read-only, with a title saying
to edit them in the list.
- **Week**: starts on the display locale's first day, with previous /
this / next. Row, day and week totals always show.
- **Add row** asks for the row field values with each field's own edit
widget; the first typed day creates the record.
- An incomplete block draws "Timesheet configuration required".
- Strings: lazy namespace `timesheet.*` in 11 languages.
- **Lint**: `view/list-view-field-refs` checks the three names (`error`:
each is written into the records a cell creates);
`view/layout-without-binding` warns on a `timesheet` view with no
complete block.
- **Pickers**: the view switcher, the create-view dialog (with the three
binding fields) and the Studio list-view type section offer the new
type. 8 new eager keys under `console.objectView.*` (the type label, its
description, and the three binding fields' labels and help).
- **Types**: `ObjectTimesheetSchema` joins the `ObjectQLComponentSchema`
union and its zod mirror; `NamedListView` carries `timesheet`.
## Tests
<details><summary>New and updated tests</summary>
- New `plugin-timesheet` suites (29 tests): `timesheetModel.test.ts`
(config resolution and refusals, locale week start, month-end weeks,
local-day placement of instants, datetime written at local noon, row
keying with an expanded lookup by id, totals, added rows, create /
update / delete / none / readonly plans, input parsing) and
`ObjectTimesheet.test.tsx` (missing binding screen, the week query
joined with the view filter, pivot with totals, a two-record cell
read-only, update, create then delete, a refused write kept on its cell,
non-numeric text refused without a write, add row, week navigation).
- Lint: three new `view/list-view-field-refs` position rows; the rule
explanation names `timesheet`.
- Pins moved by the new member, each with its reason in place: spec
type-alias pins 858 → 859, types union arms / zod mirror pairs (201 →
202) / unmirrored-key census (66 declared, 43 read; loose members 75) /
imported defaults, cli registered-type ratchets (the namespaced pin
raised 307 → 308 as a named stopgap, following #31856),
`objectViewHostSurface` measured branches, `ListViewBlock.specInputs`,
`registry-inputs-spec-parity`, `CreateViewDialog.viewTypeParse`,
`ViewSwitcher` view-type table, `normalize-list-view` drawn kinds,
side-effects roster.
</details>
## Acceptance notes
The card's ask, item by item:
- **Declares row keys, date field, value field and week window**:
`timesheet.rowFields` / `dateField` / `valueField`; the week window
follows the viewer's locale first day with previous / this / next (seat
ruling: no authored window key).
- **Writes through the record doors, per cell**: each cell is one
`create` / `update` / `delete` on the data API.
- **Row and column totals**: row, day and week totals, always shown.
Before (`origin/main`): `ListView.type` accepts nine values and none
pivots records into an editable row × day grid; a stored `type:
'timesheet'` is refused by the spec enum.
After, live: console from this branch's source over a real showcase
backend (`objectstack dev --seed-admin`, fresh database). Seeded through
the public doors (`POST /packages`, `PUT /meta/object`, `PUT /meta/view`
with a `type: 'timesheet'` list view, `PUT /meta/app`, five `POST /data`
rows; all 200 / 201). Script, readings and screenshots:
`/mnt/project-files/objectstack-seat3/34382-live/` (project share).
1. **en**, week Sun 11/15 – Sat 11/21: rows `Apollo | 2 | 3 | total 5`,
`Hermes | 1 | 3.5 | total 4.5`; the 3.5 cell (two records) is read-only
with "This day holds more than one record. Edit them in the list."; day
totals `0 2 4 3.5 0 0 0`, week 9.5.
2. Mon 2 → 6 sent `PATCH /api/v1/data/ts_time_entry/<id> {"hours":6}`;
Thu typed 4 created a record (persisted, read back after reload); Hermes
Mon 30 was refused by the field's `max: 24`, and the cell kept 30, red,
with "Not saved: Hours must be ≤ 24"; clearing Apollo Tue sent `DELETE
…/<id>`. Week total 9.5 → 17.5 (with the refused draft not counted in
the row) → 14.5.
3. Next week: empty, all totals 0. Add row "Zeus" adds an empty row.
4. **zh-CN**: the week starts Monday (11/16周一 … 11/22周日), 本周 / 添加行 / 合计,
the read-only title 「这一天有多条记录,请在列表中编辑。」.
5. 375 px: no horizontal page scroll (document scrollWidth 375).
## Verification
<details><summary>Gates</summary>
- Derived gates (`dispatch-gates --commands`, 152) on head 70f915f: 151
exit 0; `check-plugin-teardown-shape --self-test` exit 3 (prerequisite:
this clone is shallow; `git fetch --unshallow` is needed).
`dispatch-gates --ran`: 152 accounted for.
- After the main merge-forward (regen-merge script, artefacts
regenerated, `check:generated` all 14 current) and the last fixes, on
head 3635a48: the touched suites rerun green: ui `plugin-timesheet`,
`types`, `cli`, `i18n`, `plugin-view`, `core` normalize-list-view,
`CreateViewDialog*`, `registry-inputs-spec-parity`,
`ListViewBlock.specInputs`, `one-authority-per-exported-name`,
`side-effects-declaration-consistency` (537 files, 13,481 tests); spec
`type-alias-convention.pin`; lint full suite (9,127 tests).
- Earlier on the branch: spec full suite (one pin, since fixed),
app-shell `ObjectView*` (849) and `studio-design/` (2,577),
`plugin-list` (1,869), `check:i18n` exit 0, `check:dual-build-cjs-loads`
exit 0, `check:liveness` exit 0.
- Full workspace build (`turbo run build --filter='!@objectstack/docs'`)
exit 0; type-check exit 0 for `plugin-timesheet`, `plugin-list`,
`plugin-view`, `types`, `i18n`, `cli`, `core`, `app-shell`, `console`.
- `console` production build + `check-eager-closure-budget` exit 0:
**i18n-locale-en 61,952 B gzip of the 62,000 ceiling** (48 B left after
the merge-forward; this PR's 8 eager keys cost about 130 B). Aggregate
1896.5 KB / 2431.6 KB.
- `check-changeset-no-major`, `check:changeset-fixed`,
`check-empty-changeset`: exit 0.
</details>
Deviations:
- The Studio metadata form (`view.form.ts`) gets no `timesheet` section:
`tree` and `map` have none either, and it would regenerate 12
platform-objects translation files. The block is authored in code or
through the create-view dialog's three fields.
- Lint checks that the three names resolve on the object, not their
field types (date / number); a follow-up can add the type check.
- 8 keys are in the eager `console.objectView` group, not a lazy
namespace: they are read by the create-view dialog and the view
switcher, which render before any timesheet mounts. The grid's own
strings are lazy.
- The cli namespaced registered-type ratchet is raised 307 → 308 for
`object-timesheet`, with a named stopgap paragraph, as #31856 did.
- File surface beyond the claim: `ui/packages/i18n/src/locales/*` (the 8
keys), `ui/packages/types/src/{index,zod/index.zod}.ts`,
`ui/packages/plugin-view/src/ViewSwitcher.tsx`,
`ui/scripts/check-i18n-call-site-keys.mjs` and two `ui/scripts` tests,
`ui/vitest.config.mts`, `.changeset/config.json` (the new package in the
fixed group), `scripts/regen-artifacts.mjs`.
- Client-side permission gating is present: create / update / delete are
read through `resolveAffordance` (`gridAddRow`, `listInlineEdit` plus
the value field's `resolveFieldAffordance`, `rowDelete`), so a cell the
viewer may not write is read-only, Add row shows only with create, and a
write is refused locally with `timesheet.notAllowed`. The server still
judges every write, and a server refusal shows on its cell.
## Fix round 1 (L1-d 6954236029), head 19b3f8d
- **M1, date-time week.** A `datetime` date field is now bounded by the
instants of local midnight (`weekQueryBounds` in `timesheetModel.ts`); a
`date` field keeps its day keys. Pins: `timesheetModel.test.ts` (suite
zone), `ObjectTimesheet.test.tsx` (the query a `datetime` field sends),
and the new zone pin `timesheet.dateTimeZone-34382.test.ts` at UTC+13
(`Pacific/Auckland`) and UTC-8 (`America/Los_Angeles`), registered in
`scripts/__tests__/date-only-zone-pins-10183.test.ts`, which runs it on
the forks pool (7/7 there; the driver passes).
- **S2, grouping.** Cells display with `useGrouping: false`, so `1234.5`
edits back. (Superseded in fix round 2: `parseCellInput` now reads the
display locale's own decimal and group marks.)
- **S1, eager budget.** The seat kept the 8 keys eager (a lazy move
would flash English in the zh dialog) on the maintainer's ceiling raise,
card #34927 (62,000 → 80,600). This PR lands after #34927;
`check-eager-closure-budget` red before that is expected.
- **M3.** Claim amendment 6954290372 on #34382 (full path list, ruling
A, liveness path).
- **CI.** `Build & E2E UI` was red on 3635a48: `sdui.manifest.json`
lacked the `timesheet` type option and input. Regenerated with `node
scripts/gen-sdui-manifest-node.mjs`; `check-sdui-manifest` exit 0.
- **M2, ablations**, each through `scripts/ablation-replace.mjs`, red,
and restored to the HEAD blob (`git diff HEAD` empty):
| # | Behaviour | Mutation | Red |
| --- | --- | --- | --- |
| 1 | pivot (`buildTimesheetRows`) | `sum += amount` → `sum = amount` |
3: row keying, day/week totals, the two-record cell sum |
| 2 | write plan (`planCellWrite`) | readonly when `> 1` record → `> 99`
| 1: never writes a cell holding several records |
| 3 | week query, suite zone | date-time bounds → day keys | 2: model
bounds, the component's `datetime` query |
| 3b | week query, UTC+13 / UTC-8 (forks child) | same | 3 of 7 (rigs
and the date control stay green) |
| 4 | refusal kept on its cell | the catch no longer sets the cell's
draft | 1: keeps a refused write on its cell |
| 5 | lint `timesheet` rows | `scalars: { dateField, valueField }` →
`{}` | 3: both rows and the accounted-paths census |
| 6 | `ListView` `case 'timesheet'` | `timesheet: schema.timesheet`
dropped | 1: the binding reaches the grid |
| 7 | ungrouped display | `useGrouping: false` → `true` | 1: a value of
a thousand edits back |
- Type-check `plugin-timesheet` exit 0; `vitest run
packages/plugin-timesheet/` 33 passed, 7 skipped (the driven zone
cases); the driver `date-only-zone-pins-10183` and
`vitest-timezone-pin-8366` pass; `check:test-source-alias` exit 0.
- Size now 3299 changed lines (+3186 / -113, 110 files).
## Fix round 2 (seat L2 6957515788), head 8f6048c
- **S1, door check.** `checkListViewTimesheetBinding` (spec
`view.zod.ts`) refuses `type: 'timesheet'` with no `timesheet` block, at
`timesheet`, beside `checkListViewChartBinding`: attached on
`ListViewSchema`, `ObjectListViewSchema`, the list overlay and the
component face (`component.zod.ts`), and on objectui's
`ListViewPropsBag` (`objectql.zod.ts`). The kind is new in this release,
so refusing it is not breaking. Pins: `view.test.ts` (each door refuses
with the message; a bound timesheet and a grid pass),
`object-refinement-check-exports.test.ts` (declaration, three
attachments, ChartBinding followed by TimesheetBinding, barrel), types
`spec-object-refinements-7715` / `imported-defaults-8317` /
`list-view-properties-bag-12670` (both faces refuse at
`properties.timesheet`; a bound timesheet passes). Fixtures that parsed
a block-less timesheet now carry a binding
(`view-form-pagination.test.ts`, `ListViewBlock.specInputs-13047`).
- **S2, locale parse.** `parseCellInput(text, locale)` reads the display
locale's decimal and group marks (`Intl.NumberFormat#formatToParts`; a
locale with its own decimal mark, such as `ar-EG`, reads Latin input).
The decimal mark is allowed once, the group mark only between whole
groups of three, and hex or exponents are refused. Pinned: en `1,000` =
1000, `1,234` = 1234, `1,234.5` = 1234.5, `1,5` refused; de `1,5` = 1.5,
`1.000` = 1000, `1.234,5` = 1234.5, `7.5` refused; fr space grouping;
and in `ObjectTimesheet.test.tsx` a typed `1,000` in en-US writes `{
hours: 1000 }`.
- **S3, completeness and bounds.** `timesheet` joins the spec
`functional-completeness.test.ts` it.each and lint's
`validate-functional-completeness.test.ts` (flagged as a warning at
`objects[0].listViews.week.timesheet`, silent once bound).
`TimesheetConfigSchema` bounds: 1 and 3 `rowFields` pass, 0 and 4
refused, each missing key refused, an unknown key (`weekStart`) refused.
- **Ablations** (restored to the HEAD blob, `git diff HEAD` empty): the
check body → `return;` turns 7 spec tests red (direct calls, the
bijection, each door's refusal); locale marks forced to `.`/`,` turns 3
`plugin-timesheet` tests red (de, space grouping, read-back in own
locale).
- Runs on this head: spec `src/ui` + `src/kernel` (7,986 tests), lint
completeness and list-view field refs (229), ui `types`, `plugin-view`,
`plugin-timesheet`, `plugin-list` specInputs,
`CreateViewDialog.viewTypeParse`, cli ratchet, core normalize-list-view,
console registry parity, relay census 11572, affordance census 12082,
i18n (all green); type-check `types`, `plugin-timesheet`, spec `tsc`;
`check:api-surface` and `check:export-origins` current.
- Size now 3887 changed lines (+3742 / -145, 129 files).
## 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.
- [x] 4. One issue, one branch, 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.
- [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_01WGufzgTk2cRpVHpSVk9tzF
<!-- signed: repo:objectstack#3 · os-support-ai ·
session_01WGufzgTk2cRpVHpSVk9tzF -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 1282a46 commit 4240719
129 files changed
Lines changed: 3742 additions & 145 deletions
File tree
- .changeset
- content/docs
- references
- api
- data
- system
- ui
- ui
- components
- docs/audits/2026-07-unknown-key-strictness-ledger.counts
- packages
- lint/src
- spec
- api-surface
- authorable-surface
- declaration-map
- export-origins
- json-schema.manifest
- liveness
- state-counts
- src
- kernel
- ui
- scripts
- skills/objectstack-ui/references
- ui
- apps/console
- dev
- src
- __tests__
- packages
- app-shell/src
- __tests__
- views
- metadata-admin
- studio-design
- cli/src
- __tests__
- utils
- core/src/utils
- __tests__
- i18n
- scripts
- src
- __tests__
- locales
- namespaces
- studio
- timesheet
- plugin-form/src
- plugin-list
- src
- __tests__
- plugin-timesheet
- src
- __tests__
- plugin-view/src
- __tests__
- types/src
- __tests__
- zod
- scripts
- __tests__
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| 116 | + | |
116 | 117 | | |
117 | 118 | | |
118 | 119 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
965 | 965 | | |
966 | 966 | | |
967 | 967 | | |
968 | | - | |
| 968 | + | |
969 | 969 | | |
970 | 970 | | |
971 | 971 | | |
| |||
0 commit comments