Skip to content

feat(console): preview images, PDF, text and CSV in the page from attachments and file fields - #36587

Merged
objectstack-fleet[bot] merged 10 commits into
mainfrom
claude/issue-36442-file-preview
Nov 23, 2026
Merged

objectstack-fleet[bot] merged 10 commits into
mainfrom
claude/issue-36442-file-preview

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

Requested by Steve · project thread
Fixes #36442
Clause-②: yes (widening)
Metadata-protocol: none

维护者速读

  • 控制台用户在记录的附件列表点文件名、或在文件字段点文件链接时,图片、PDF、纯文本和表格文件直接在页面弹窗里看,不再先下载;Word、Excel、PPT 仍只能下载。
  • 这是附件预览决策选定的方案甲(页内预览,社区版默认)的界面半边,服务端那半边由同区另一张卡负责。
  • 若出错,最坏是预览打不开、用户点弹窗里的下载或新标签页照旧拿到文件;没有下载权限的人在预览里同样被拒;可整体撤回。
  • 要你做的:无。

What changes

A shared FilePreviewDialog in @object-ui/fields (decision #34781, option A), opened from a record's attachments and from a file field:

  • Views, no new dependency. Image (PNG, JPEG, GIF, WebP, and SVG through an img element only) via the lightbox's own image element (LightboxImageView, extracted from ImageLightbox); PDF in an iframe on the browser's own viewer, without a sandbox attribute; plain text as text; CSV as a table, read with the GBK-aware decodeSpreadsheetText and parseDelimited, which moved down from @object-ui/plugin-grid (it now imports them from @object-ui/fields; no copy).
  • Download only. Word, Excel, PowerPoint, HTML and every other type: "This file type cannot be previewed. Please download it." HTML was measured as a choice between "unsupported" and "source as text"; this PR takes unsupported: nothing is fetched, nothing is framed, nothing is drawn. A declared HTML type wins over a harmless name, and an .html name wins over a declared plain-text type.
  • The PDF frame needs a PDF signal: the declared application/pdf, or a .pdf name when no type is declared. A .pdf name with another declared type (for example application/octet-stream) is unsupported, so the frame never receives bytes the browser would read as anything else.
  • Limits (maintainer defaults): images and PDF 20 MB, text and CSV 2 MB, judged on the declared size before anything is fetched and on the bytes read when no size is declared; text and CSV show their first 1000 lines (CSV: header plus 1000 rows). Past a limit: "too large, please download" with a download button.
  • Controls: previous / next (and the arrow keys) across a record's attachments; download; open in a new tab.
  • Same door as the download. In the attachments panel the preview mints its link with the download's own call (/files/:id/url with the console's token, now one signedUrlFor both use), and a refusal shows the download's own copy. On a file field the preview uses the field's own link (the stable /files/:id endpoint) and first asks it with redirect: 'manual': a redirect is the grant, a 401/403 is the refusal, so no byte moves twice.
  • Phone: below the useIsMobile breakpoint a PDF is offered in a new tab (the system viewer), never framed; image, text and CSV stay in the page.
  • Cross-origin bucket (the contract in cli/storage: let the console frame a PDF from the storage origin, and document the bucket CORS the file preview needs #36443 / feat(cli): the console's frame-src names the storage origin a PDF preview frames, and nothing wider #36565): text and CSV are read with a GET on the signed link from the page; when the browser refuses that read (no bucket CORS rule for the console origin), the dialog offers "Open in new tab" instead.
  • Wiring: RecordAttachmentsPanel, the row's name is now a button that opens the preview (download stays in the row's menu); FileValueAffordance (file-affordance.tsx), a plain click opens the preview, a modified click keeps the link's own new tab, and a click inside the dialog does not bubble to the grid row behind its portal.
  • Copy: 15 new keys under fields.filePreview in all 12 packs (zh-Hant regenerated from zh-Hans by its generator).

New public exports from @object-ui/fields (preferred names, built under them): FilePreviewDialog, FilePreviewDialogProps, FilePreviewItem, decodeSpreadsheetText, parseDelimited. Alternatives considered: FileViewerDialog / FileViewerDialogProps / FileViewerItem.

New @object-ui/i18n keys (every pack): fields.filePreview.title, fields.filePreview.previous, fields.filePreview.next, fields.filePreview.download, fields.filePreview.openInNewTab, fields.filePreview.loading, fields.filePreview.tooLarge, fields.filePreview.unsupported, fields.filePreview.denied, fields.filePreview.loadFailed, fields.filePreview.blocked, fields.filePreview.pdfOutside, fields.filePreview.truncatedRows, fields.filePreview.truncatedLines, fields.filePreview.empty.

Read first, by risk: filePreviewKind (which bytes may reach the iframe), useResolver in FilePreviewDialog.tsx (the refusal probe and the one-resolver-per-dialog rule), then previewSignedUrl / signedUrlFor in RecordAttachmentsPanel.tsx.

Two-minute check: pnpm --dir ui exec vitest run packages/fields/src/widgets/FilePreviewDialog-36442.test.tsx shows 51 passing.

Tests

  • New card-named file ui/packages/fields/src/widgets/FilePreviewDialog-36442.test.tsx: the kind table (Office, HTML, SVG, PDF-signal cases); each view and its element; SVG only as img, no iframe/object, bytes never fetched; text drawn as text (a script tag in the file stays text); GBK CSV; the 1000-row cap; Office and HTML download only with nothing resolved, fetched or framed; too large per kind, a control at exactly the limit, and a text file judged on its bytes; the refusal from resolveUrl, from the default probe (403), from the text read (403), with a redirect as the control; the CORS-blocked read offering the new tab; previous / next / arrow keys / wrap; download and new tab; phone PDF in a new tab and phone image in the page; the field link opening the preview, a modified click not, a refused field file, a Word field file.
  • Shared harness RecordAttachmentsPanel.test.tsx, new top-level describe: the name opens the preview on the signed link, next walks to the next row's own link, a refused reader gets the download's copy (and the link is asked once), a Word file offers only the download and that download is the row menu's, the row menu still carries Download.
  • Shared harness importParsers.test.ts, new describe: the wizard's parseDelimited / decodeSpreadsheetText are the very functions @object-ui/fields exports.
  • Tests changed because the product changed: none. Existing pins that query getByText('report.pdf') keep passing on the new name button.

Acceptance notes

Verification

Screenshots: NOT MEASURED. Reason: the relay writes text bodies only and no write door here uploads an image to a pull request; a live Console run was not started in this container.

Package suites on the merged head (ab1feda, then c131bca and 81b19aa for the census fixes)
pnpm --dir ui exec vitest run packages/fields/ packages/plugin-grid/ packages/i18n/      (merged head 538f09f4f5)
  Test Files  1 failed | 735 passed | 1 skipped (737)   the zh-Hant pack is generated: regenerated in ab1feda62b
pnpm --dir ui exec vitest run packages/i18n/ FilePreviewDialog-36442 RecordAttachmentsPanel.test importParsers.test   (ab1feda62b)
  Test Files  109 passed (109)   Tests  2138 passed | 13 skipped (2151)
pnpm --dir ui exec vitest run scripts/ packages/plugin-grid/src/importParsers.test.ts   (c131bca361)
  Test Files  173 passed | 2 skipped (175)   Tests  5185 passed | 2 skipped (5187)
pnpm --dir ui exec vitest run dialogViewportGutterCensus-12603 clickableNonControlCensus-13461 FilePreviewDialog-36442 fileCellDownload-9485 RecordAttachmentsPanel.test   (81b19aa54e)
  Test Files  5 passed (5)   Tests  129 passed (129)
pnpm --filter @object-ui/{fields,i18n,plugin-grid,app-shell} type-check   TC-OK on all four
Ablation: delete the default probe's refusal (one line in useResolver)
ablation-replace: ok mutation landed: anchor 1 -> 0, blob 1697ea61da06 -> 6bf8a8ebcffc
  × by default, the stable storage endpoint is asked without following its redirect; a 403 is refused
  × a field file the reader may not download gets the refusal in the preview
  Tests  2 failed | 49 passed (51)
ablation-replace: ok restored: blob == HEAD (1697ea61da06) and `git diff HEAD` is empty
Derived gate list on 81b19aa: 42 of 42 run, all exit 0

node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstack --ran FILE: "42 derived famil(ies) accounted for — 42 run, 0 NOT-MEASURED". check:type-check-debt and the ui scripts/ suite ran under the shared verify lock. node scripts/pm/overlap-check.mjs: VERDICT clean exit 0.

CI on 81b19aa: every required check green (Lint & Repo Gates, TypeScript Type Check, Test Core, Governed Surface Queue Guard, Lint UI, Type Check UI, Test UI, Build & E2E UI, Live E2E UI, Dogfood Regression Gate; Build Core skipped by its selector).

Two shared censuses the first CI round named are now satisfied without touching them: the dialog's width is sm:max-w-[92vw] xl:max-w-5xl, a viewport-relative cap that keeps a margin at every width (the gutter census counts it as not wide), and the dialog stops its own clicks at its content rather than through a clickable wrapper element (the clickable-non-control census).

🤖 Generated with Claude Code

https://claude.ai/code/session_01ADHkmRB34k9WUWeGpRnVNm

@github-actions github-actions Bot added size/xl documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 23, 2026
…s own clicks at its content

Claude-Session: https://claude.ai/code/session_01ADHkmRB34k9WUWeGpRnVNm
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmRB34k9WUWeGpRnVNm

Flake reading — PR #36587 @ 6775877 · 2026-11-23T04:20Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmRB34k9WUWeGpRnVNm

Contract-review-claim: session_01ADHkmRB34k9WUWeGpRnVNm · head 6775877 · 2026-11-23T04:33Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmRB34k9WUWeGpRnVNm

Contract review

Served-tier: TIER_DEFAULT
Head-sha: 67758776705322e53d7ee16fd93aa98933743e4e
Local-runs: none

The face is the Clause-②: yes (widening) declaration alone (PR body and changeset): no published schema, no governed path, no narrowing arm in the changed paths (check-governed-merges.mjs --pr 36587: 0 governed). Area s2-B writes this record itself under the seat's area order (rule 10) and the seat's 2026-11-22T22:57Z exception for this card (a ui-package export plus language-pack keys stay in the area).

① Derived judgments

  • The widening the declaration names is real and complete. @object-ui/fields gains five named exports from src/index.tsx: FilePreviewDialog, types FilePreviewDialogProps and FilePreviewItem, and decodeSpreadsheetText and parseDelimited. The last two moved down from @object-ui/plugin-grid, which now imports them, so there is one copy. @object-ui/i18n gains 15 keys under fields.filePreview in every pack (zh-Hant regenerated by its generator). Nothing else in either package's entry moves.
  • @object-ui/plugin-grid keeps both names in importParsers.ts as re-exports, and its package entry exported neither before or after (index.ts exports parseSpreadsheetFile, parseClipboardTable, inferColumnType), so plugin-grid's published surface does not move.
  • The new dependency edge plugin-grid → fields already existed (plugin-grid depended on fields), so no package dependency is added. filePreviewKind is a module export not named by the barrel, so it is not published.

② Semver level

patch for @object-ui/fields, @object-ui/app-shell, @object-ui/plugin-grid, @object-ui/i18n. AGENTS.md's Post-Task Checklist step 3 grades by the Metadata-protocol kind, and none takes patch; Check Changeset's level axis agrees. No breaking change.

③ Boundary flags

  • Dev open questions: (1) names — A, FilePreviewDialog / FilePreviewDialogProps / FilePreviewItem (the card's wording). (2) HTML — A, download only, never fetched, framed or drawn. (3) Previous/next across a multi-file field value — not in this PR, because the group is built outside the claimed surface; Acceptance note. The card's previous/next control is met on the attachments list. (4) PR fix(service-storage)!: stored bytes outside the inline allow-list are served as attachments, with nosniff and a sandbox CSP #36518 — merged at 2026-11-23T01:06Z; it keeps PDF and text/plain inline, and the CSV view reads bytes with fetch, which ignores the disposition. (5) Landing condition — seat 7 answered on pm:mailbox — repo:objectstack#7 · zhuangjianguo #36199 (7090382918) that the prerequisite is in.
  • Security posture read: SVG only through img; HTML/XHTML is classed unsupported before any read; the iframe opens only for a PDF signal; text and CSV render as React text nodes (no dangerouslySetInnerHTML). On local storage the raw route serves the allow-list, nosniff and the sandbox CSP (served-bytes-policy.ts). On S3 the frame is cross-origin under frame-src (PR feat(cli): the console's frame-src names the storage origin a PDF preview frames, and nothing wider #36565).
  • SQL push-down: not applicable. The preview reads one file through the download's own signed link and permission check.
  • Author: objectstack-fleet[bot] (relay-written); the main merge is the platform's update-branch through the relay.

Implemented-by: claude/issue-36442-file-preview
Reviewed-by: session_01ADHkmRB34k9WUWeGpRnVNm

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmRB34k9WUWeGpRnVNm

席位核对

ACCEPT — PR #36587 @ 6775877 (head of record, full sha on the PR; main merged by the relay's update-branch onto 81b19aa) · card #36442 · L1 first read by area s2-B (area order rule 9) · 2026-11-23T04:34Z · contract review TIER_DEFAULT PASS 7091693978 at the same head

  • Shape: open, draft, base main; first line Fixes #36442, Clause-②: yes (widening), Metadata-protocol: none; no closing keyword near another card (l1-face.mjs --pr 36587 CLEAN).
  • Premise: held (claim 7087915700). The console had no in-page preview: a file name downloaded or opened a tab. The server half (CSP frame-src for the store, bucket CORS doc) landed as cli/storage: let the console frame a PDF from the storage origin, and document the bucket CORS the file preview needs #36443 / PR feat(cli): the console's frame-src names the storage origin a PDF preview frames, and nothing wider #36565. Seat 7's landing condition (7080169736) is answered: the prerequisite is in (7090382918).
  • Scope: 22 files, 1516+/103- (1619 lines incl. 11 locale packs): FilePreviewDialog.tsx + its test (51 cases), delimitedText.ts (moved from plugin-grid; plugin-grid imports it, one copy), ImageLightbox.tsx (image view reused), file-affordance.tsx (a plain click opens the preview, a modified click keeps the new tab), RecordAttachmentsPanel.tsx (the name opens the preview, download stays in the row menu, the preview reads the same signedUrlFor), the fields barrel, the i18n packs, one changeset. Not governed.
  • Diff read: four views (image, PDF frame, text, CSV table) and download-only for Office, HTML and the rest. The limits are 20 MB for media and 2 MB for text/CSV, the first 1000 rows or lines. The refusal is the download's own: a 401/403 from the stable endpoint probe (redirect: 'manual') or from the text read. On a phone, a PDF goes to a new tab. A blocked cross-origin text/CSV read offers the new tab, matching feat(cli): the console's frame-src names the storage origin a PDF preview frames, and nothing wider #36565's doc.
  • Changeset read against the diff: matches (views, limits, same-door refusal, new exports and keys named).
  • Tests and gates: 51 dialog cases + 5 panel cases + the importParsers sameness pin. Ablation (default probe's 401/403 line removed): 2 red (probe 403, field refusal), restore blob equal to HEAD. Two shared censuses that went red on the first CI round (dialog gutter, clickable non-control) were fixed in the card's own files, census lists untouched. 42 of 42 derived gate families run, 0 NOT-MEASURED (ledger /mnt/project-files/objectstack-seat2/36442-gates-ran.txt). Browser screenshots: NOT MEASURED. CI at 6775877: 45 success, 13 skipped, 0 failing; Test UI went red once on flake Test flake: DataPillar.panelHold-27629 'leaving the Actions tab keeps the hold' sometimes sees a save of the unparsable predicate (fails 1 in ~5–8 runs on main) #36619 (reading 7091500002) and passed on its one re-run.
  • Accepted deviations: none in the diff. A stray 6-byte /build1.pid at the dev container's root (outside the repo) was left; nothing in the checkout.
  • Out of scope: previous/next across a multi-file field value previews one file at a time (the group is built in FileField.tsx and the barrel cell renderer, outside the claim): Acceptance notes, not filed. RecordAttachmentsPanel's friendlyError maps ATTACHMENT_DOWNLOAD_DENIED but not FILE_DOWNLOAD_DENIED (source reading, reach not measured): Acceptance notes, not filed.
  • Landing: non-governed, ≤3000 lines; K = 4 (<15) at this head ⇒ area lands it in this stroke.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 23, 2026 04:35
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 23, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⛔ merge queue 构建失败 — 先分诊,再决定要不要重排

队列构建 45112843268 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集),
所以失败的测试可能在本 PR 没碰过的包里 —— 那不是重排能修的。每次盲目重排都会让排在后面的所有 PR 重建一轮。

分类:failure —— 按下面的日志分诊。

失败的 job(日志抽取,best effort):

  • Test UI (13/16) — 失败步骤: Run the ui tests (shard 13/16)

    × "Show me" reopens the action with its text, and fixing it there releases the hold 4046ms
    FAIL   dom  packages/app-shell/src/views/studio-design/DataPillar.panelHold-27629.test.tsx > DataPillar — an action predicate that does not parse holds with the draft (objectstack#27629) > "Show me" r
      ↳ 失败原因: (这条 FAIL 之后 12 行内没有可识别的原因行 —— 点进 job 看)
    

↳ 失败原因 是判读的关键:超时(Test timed out in … / Hook timed out in …)多半是负载/时序,不是本 PR 的回归;
断言(AssertionError: …)才指向真实的行为改变。两者的 FAIL 行长得一模一样,只有这一行能区分。

⚠️ 断言这一侧有一类例外,判据是断言在测什么,不是它是不是 AssertionError。 断言的对象是产品行为(一个值、一个形状、一次拒收)⇒ 照上面读:真实的行为改变,去查,⛔ 不要重排掉;
断言的对象是这次实验自身的有效性前提(跑完的耗时、负载下的先后、任何只在时间预算内才成立的条件)⇒ 它跟超时是同一类,同样对负载敏感,重排一次是合法的判别手段。
识别是机械的:断言的消息或它比较的值本身点名了一段时长、一个时间戳、一个耗时计数。实测过的一对 —— AssertionError: SecurityPlugin.init() ran: expected false to be true 测的是产品行为(真回归);
AssertionError: this run took over a second, so second-precision stamps could have differed too: expected 1006 to be less than 1000 测的是实验前提:它守护的那条不变式当时是绿的,同一个 head 原样重排一次即成功。
穿着 AssertionError 外衣的时间测量,仍然是时间测量。(⛔ 这只改「怎么读一次红」,不改「哪些测试可以重排」——后者由别处管。)

跨 PR 相同签名(24h,按失败测试文件聚合):

历史信号:

  • 本 PR 过去 24h 无队列失败记录(首次)。
  • 过去 24h 队列共有 8 个失败构建(不含本次)。

分诊清单:

  1. 失败测试在本 PR 改动的包里 → 真回归,修 PR。
  2. 失败测试与本 PR 无关 → 看上面的「跨 PR 相同签名」;已有汇总 issue ⇒ flaky/环境问题实锤,去那张 issue 上谈,修好前重排只会再烧一轮全队列。
  3. 两者都不是 → 可能与同组 PR 语义冲突;等前面的 PR 落地或失败出队后再重排一次即可,不要连续重排。

Generated by Claude Code · merge-queue-triage workflow (#4859)

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmRB34k9WUWeGpRnVNm

Second red — PR #36587 @ 6775877, merge queue · 2026-11-23T04:56Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmRB34k9WUWeGpRnVNm

Contract-review-claim: session_01ADHkmRB34k9WUWeGpRnVNm · head 6e7be24 · 2026-11-23T06:42Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmRB34k9WUWeGpRnVNm

Contract review

Served-tier: TIER_DEFAULT
Head-sha: 6e7be24f6bae9c33d27ce19afea5478b529218ec
Local-runs: none

The face is the Clause-②: yes (widening) declaration alone (PR body and changeset): no published schema, no governed path, no narrowing arm in the changed paths (check-governed-merges.mjs --pr 36587: 0 governed). Area s2-B writes this record itself under the seat's area order (rule 10) and the seat's 2026-11-22T22:57Z exception for this card (a ui-package export plus language-pack keys stay in the area).

Delta from the record at 6775877 (7091693978, PASS)

The head moved only by the relay's update-branch merge of main (second parent d7411fa, after #36619's fix PR #36636). The PR's own diff against its merge base is byte-identical: the same 22 files, +1516/-103. main changed zh-Hans.ts and zh-Hant.ts and nine other locale packs between the two bases; the merge is clean and the 15 fields.filePreview keys are unchanged. The judgments below therefore carry over unchanged to this head.

① Derived judgments

  • The widening the declaration names is real and complete. @object-ui/fields gains five named exports from src/index.tsx: FilePreviewDialog, types FilePreviewDialogProps and FilePreviewItem, and decodeSpreadsheetText and parseDelimited. The last two moved down from @object-ui/plugin-grid, which now imports them, so there is one copy. @object-ui/i18n gains 15 keys under fields.filePreview in every pack (zh-Hant regenerated by its generator). Nothing else in either package's entry moves.
  • @object-ui/plugin-grid keeps both names in importParsers.ts as re-exports, and its package entry exported neither before or after (index.ts exports parseSpreadsheetFile, parseClipboardTable, inferColumnType), so plugin-grid's published surface does not move.
  • The new dependency edge plugin-grid → fields already existed (plugin-grid depended on fields), so no package dependency is added. filePreviewKind is a module export not named by the barrel, so it is not published.

② Semver level

patch for @object-ui/fields, @object-ui/app-shell, @object-ui/plugin-grid, @object-ui/i18n. AGENTS.md's Post-Task Checklist step 3 grades by the Metadata-protocol kind, and none takes patch; Check Changeset's level axis agrees. No breaking change.

③ Boundary flags

  • Dev open questions: (1) names — A, FilePreviewDialog / FilePreviewDialogProps / FilePreviewItem (the card's wording). (2) HTML — A, download only, never fetched, framed or drawn. (3) Previous/next across a multi-file field value — not in this PR, because the group is built outside the claimed surface; Acceptance note. The card's previous/next control is met on the attachments list. (4) PR fix(service-storage)!: stored bytes outside the inline allow-list are served as attachments, with nosniff and a sandbox CSP #36518 — merged at 2026-11-23T01:06Z; it keeps PDF and text/plain inline, and the CSV view reads bytes with fetch, which ignores the disposition. (5) Landing condition — seat 7 answered on pm:mailbox — repo:objectstack#7 · zhuangjianguo #36199 (7090382918) that the prerequisite is in.
  • Security posture read: SVG only through img; HTML/XHTML is classed unsupported before any read; the iframe opens only for a PDF signal; text and CSV render as React text nodes (no dangerouslySetInnerHTML). On local storage the raw route serves the allow-list, nosniff and the sandbox CSP (served-bytes-policy.ts). On S3 the frame is cross-origin under frame-src (PR feat(cli): the console's frame-src names the storage origin a PDF preview frames, and nothing wider #36565).
  • SQL push-down: not applicable. The preview reads one file through the download's own signed link and permission check.
  • Author: objectstack-fleet[bot] (relay-written); the main merge is the platform's update-branch through the relay.

Implemented-by: claude/issue-36442-file-preview
Reviewed-by: session_01ADHkmRB34k9WUWeGpRnVNm

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmRB34k9WUWeGpRnVNm

席位核对

ACCEPT — PR #36587 @ 6e7be24 (head of record, full sha on the PR) · card #36442 · L1 delta read by area s2-B · 2026-11-23T06:44Z · contract review TIER_DEFAULT PASS 7093622909 at the same head · first ACCEPT 7091706488 at 6775877

@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 23, 2026
Merged via the queue into main with commit 9c283a1 Nov 23, 2026
58 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-36442-file-preview branch November 23, 2026 07:06
247257110 pushed a commit to 247257110/objectstack that referenced this pull request Nov 23, 2026
… write Field change values (objectstack-ai#36290 part 1) (objectstack-ai#36641)

<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9NRmimMwnUgR1DbqgHtBWM3)_

Part of objectstack-ai#36290

Clause-②: yes (widening)
Metadata-protocol: none

## 维护者速读

- 管理员在 Studio 的字段设置和字段设计器里,原来的「记录历史」开关换成「字段修改值」三选一(默认 / 开 /
关),对象设置的「功能开关」里新增「字段修改值」;普通用户无感。
- 属于记录页「字段修改前后值」专题,落实「默认显示、对象或单个字段可关」的裁决:以前 Studio
写的是不再起作用的旧开关,管理员在界面上关不掉前后值。
- 若出错,管理员可能看到「默认」标成开而动态里实际不显示前后值(或相反),或关掉后回不到默认;改动只在设置界面,可直接撤回。
- 要你做的:无。

## What changes

Card objectstack-ai#36290 part ① (PR 3 of 4; ruling 7076513167 point 1: "Old → new is
shown by default on every object's record page; an object, or a single
field, can turn it off."). PR 1 (objectstack-ai#36399) gave the runtime `fieldHistory`
(field) and `enable.fieldHistory` (object); objectstack-ai#36580 gave the metadata
form a three-way `field-history` widget. The Studio's own producers
still wrote the old key. This PR moves all three named in the release
comment.

**Field inspector** (`ObjectFieldInspector.tsx`, Advanced section)
- The "Track history" box (`value={!!def.trackHistory}`, `patchDef({
trackHistory: v || undefined })`) is gone. Measured reason: since PR 1 a
field's `trackHistory: false` reads like absent and `true` does only
what `fieldHistory: true` does for a media or JSON type (spec describe
of `FieldSchema.trackHistory`), so a second box beside Field change
values could only mislead. A stored `trackHistory` is never written or
removed here; it is still read, because `resolveFieldHistory` reads it.
- New row "Field change values": Default / On / Off over the field's
`fieldHistory`. Default removes the key (`unsetDefKey`, not a patch to
`undefined`); On / Off write `true` / `false`.
- Default names what it resolves to through `resolveFieldHistory` from
`@objectstack/spec/data`, the predicate the activity writer uses. Unlike
the form widget, this rail holds the object document, so it passes the
object: an object with `enable.fieldHistory: false` makes every field's
Default read "Default (Off)", and a note under the row says the object's
off wins.
- The row sits inside the existing `DisplayPatchLock`, so on a read-only
base field it is locked with the same reason as its neighbours
(`fieldHistory` is not on `BASE_FIELD_DISPLAY_WHITELIST`).

**Object settings** (`ObjectSettingsPanel.tsx`, Features card)
- New row "Field change values" (`enable.fieldHistory`), next to "Field
change history" (`enable.trackHistory`). Ticked unless the stored value
is a literal `false`. Unticking writes `false`; ticking again REMOVES
the key (unset already means on, so no `true` the author did not need).
Sibling `enable` keys are kept, as for every other row.
- The Field change history description no longer says "pair with
per-field history tracking to pick which field diffs are summarized" (no
longer true); it points to Field change values.

**Field designer** (`plugin-designer` `FieldDesigner.tsx`, the drawer
behind `MetadataFieldsPage` and the `field-designer` SDUI type)
- The Advanced section's Track History switch wrote `trackHistory:
data.trackHistory === true` on every save, create and edit. It is
replaced by Field Change Values with the same three choices. The update
path no longer names `trackHistory`: a stored value rides the
`...editingField` spread, and a created field carries neither key at
Default.
- Default's label depends on the type, which the author can change in
the same drawer, and a drawer select's options are static. So the choice
is drawn as two rows under form-local names, one per resolved default,
each shown by a `visibleWhen` built from `resolveFieldHistory` over
`DESIGNER_FIELD_TYPES` (with the field's stored `trackHistory`). The
save reads the row shown for the saved type, which is the one on screen
at the click. Neither form-local name reaches the model.
- `DesignerFieldDefinition` (`@object-ui/types`) and its zod mirror gain
an optional `fieldHistory`. Both save paths carry it:
`MetadataFieldsPage` (`toDesignerField` / `fromDesignerField`) and
`MetadataService.toFieldPayload`. Default writes `fieldHistory:
undefined`, which overrides the carried value and is dropped on the
wire, so a stored key is removed. That is the converters' existing
clear-by-absence rule.
- It cannot import `fieldHistoryChoice.ts`, because app-shell depends on
plugin-designer. What it shares is the rule (`resolveFieldHistory` from
`@objectstack/spec/data`). Its own copy of the choice-to-value mapping
is two lines. Its strings are the language-pack keys
`appDesigner.fieldDesigner.fieldHistory`, `fieldHistoryDefault`,
`fieldHistoryOn` and `fieldHistoryOff`, in all 11 locales and the
designer's defaults table. They replace
`appDesigner.fieldDesigner.trackHistory`.

**Shared logic** (`metadata-admin/fieldHistoryChoice.ts`, new): the
three choices, the value each writes and their wording, used by both the
inspector row and the objectstack-ai#36580 `field-history` widget (refactored onto it;
its behaviour and its 10 pins unchanged). The controls stay separate on
purpose: the widget is a `WidgetProps` renderer that sees one form row
and no object; the inspector row is an `InspectorSelectField` with the
inspector's label and lock semantics and the whole object in hand.

**Strings** (studio namespace, en + zh; the other locales fall back to
en by that namespace's design): `designer.field.fieldHistory`,
`designer.field.fieldHistoryObjectOff`,
`engine.studio.settings.capFieldHistory`,
`engine.studio.settings.capFieldHistoryDesc`;
`engine.studio.settings.capTrackHistoryDesc` reworded;
`designer.field.trackHistory` removed with its box.

Not in this PR: record-page rows (part ②, landed as objectstack-ai#36613), the
per-field history card (part ③).

## Tests

- New `ObjectFieldInspector.fieldHistory-36290.test.tsx` (7): Default
(On) for a one-line type; Default (Off) for image / json / password and
Default (On) once `trackHistory: true`; Off writes `false`, On writes
`true`; Default after Off removes the key; no Track history box, no
`trackHistory` written, a stored one kept; the object's off makes
Default (Off) and shows the note; control: no note otherwise.
- New describe in `ObjectSettingsPanel.test.tsx` (4): checked for unset
and `true`, unchecked only for `false`; untick writes `false` with
siblings kept; re-tick removes the key with siblings kept; labelled by
its own title.
- New `FieldDesigner.fieldHistory-36290.test.tsx` (9), on the real
`FieldDesigner` with a drawer double that captures its schema and calls
its own `onSuccess`. The cases: two rows and no Track History row, with
the labels; for every designer type exactly one row's `visibleWhen`
evaluates true (through `evalFieldPredicate`, the form's own evaluator),
and it is the one `resolveFieldHistory` names; a stored `trackHistory:
true` moves a media type to the Default (On) row; an untouched edit
writes neither key; Off writes `false`, On on a media type writes
`true`; a stored `false` opens as Off and Default removes it; a stored
`trackHistory` is kept; a type changed in the drawer saves what is on
screen; a created field at Default carries neither key.
- New `MetadataFieldsPage.fieldHistory-36290.test.tsx` (4), on PUT bytes
through the real page and a real `MetadataClient`. A stored
`fieldHistory: false` survives and no `trackHistory` is written; a
stored `trackHistory: true` survives and gains no `fieldHistory`; a
field with neither key gains neither; every PUT field parses through
`FieldSchema`.
- Extended: `MetadataService.fieldKeyCarryOver.test.ts` adds
`fieldHistory` to its populated entry and its clearable keys;
`designer-zod-arms-10859.test.ts` adds `fieldHistory` to the fully
populated `field-designer` document.
- Forced test changes:
`ObjectFieldInspector.displayPatchReason-28986.test.tsx` names the Field
change values combobox instead of the removed Track history checkbox
among the locked controls;
`ObjectSettingsPanel.businessWording-36512.test.tsx` lists
`enable.fieldHistory` among the keys the tab writes.
`ObjectFieldInspector.externalIdNotOffered-26674.test.tsx` and
`ObjectFieldInspector.retiredIndexed.test.tsx` listed Track history
among the Advanced siblings that still render; they name Field change
values, and (being edited) now pay the formula and lint loads at module
top, as `check:test-source-alias` requires.
`FieldDesigner.externalIdNotOffered-26674.test.tsx` and
`MetadataFieldsPage.externalIdRoundTrip-26674.test.tsx` used the Track
History row as their positive control; they now use the Field Change
Values row.


## Acceptance notes

- The field designer's Default label follows the drawer's type and the
object is not in hand, so an object with `enable.fieldHistory: false` is
not reflected there, the same accepted bound as objectstack-ai#36580's widget. Neither
`FieldDesigner` nor `MetadataFieldsPage` is mounted by the Console
today; both are published exports, and `field-designer` is a registered
SDUI type.
- A stored field `trackHistory: true` on a media or JSON type makes
Default read "Default (On)"; such a field can still be turned off with
Off, but not returned to the type's off-by-default without editing the
key in the form. That is the resolver's answer, not a UI choice.
- `ui/AGENTS.md` objectstack-ai#2 (package README and `content/docs/frontend/` page)
not edited: outside this part's file surface.
- Screenshots NOT MEASURED (no Console build or backend run here).

## Verification

Read first, by risk:
1. `ui/packages/plugin-designer/src/FieldDesigner.tsx`: the
`fieldHistoryRows` memo (two rows, `visibleWhen` built from
`resolveFieldHistory`) and `fieldHistoryFromForm`, which picks the row
for the SAVED type on both save paths.
2.
`ui/packages/app-shell/src/views/studio-design/ObjectSettingsPanel.tsx`:
`patchEnable` with `unsetWhenOn` (re-ticking removes
`enable.fieldHistory`, keeps siblings).
3.
`ui/packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.tsx`:
the Field change values row and the object-off note inside
`DisplayPatchLock`.

Two-minute check: open Studio, an object, Settings, Features: "Field
change values" is ticked. Untick, save, and reopen the object JSON: it
shows `enable.fieldHistory: false`. Tick again: the key is gone. Then
open a field's Advanced section: "Field change values" reads "Default
(Off)" with the note under it.

<details><summary>Runs (local, head 3b5b130 after merging origin/main
9e2a4ac)</summary>

- Builds under the verify lock: the
`@objectstack/{spec,formula,lint,client,sdui-parser}` closure, and
`@object-ui/app-shell^...` again after the merge (VERDICT command-exit 0
each).
- `type-check` (tsc plus `tsconfig.test.json`) of
`@object-ui/app-shell`, `@object-ui/i18n`, `@object-ui/types` and
`@object-ui/plugin-designer`: all four Done, exit 0 (after the merge;
plugin-designer again at 3b5b130).
- Post-merge union at ffa608d: `vitest run
packages/app-shell/src/views/metadata-admin/inspectors/
packages/app-shell/src/views/studio-design/ObjectSettingsPanel
packages/app-shell/src/views/metadata-admin/FieldHistoryWidget-36482.test.tsx
packages/app-shell/src/views/metadata-admin/SchemaForm
packages/plugin-designer/ packages/types/
packages/app-shell/src/services/ packages/i18n/
packages/app-shell/src/__tests__/defaults-maps-mirror-en-pack.test.tsx`
gave Test Files 851 passed (851) and Tests 16838 passed, 14 skipped.
3b5b130 changes only the designer pin's types; that file re-run: 9/9.
- Pre-merge union at 3fa510b (`metadata-admin/`, `studio-design/`,
`i18n/`) gave Test Files 1232 passed and 2 failed (1234). The 2 were
sibling pins still naming Track history, fixed in 58cef60.
- Ablations, each through `scripts/ablation-replace.mjs` (anchor 1 to
0), restored with blob equal to HEAD and `git diff HEAD` empty:
- The inspector writes `trackHistory` again: 2 of 7 new inspector pins
red.
- The settings switch writes `true` instead of removing the key: 1 of 14
red.
- The designer's update path writes `trackHistory: data.trackHistory ===
true` in place of `fieldHistory`: 7 of 13 red across the two new
designer files.
- `dispatch-gates --commands` at 3b5b130 derived 42 families; all 42
ran locally with exit 0; `--ran` reconciliation gives "42 derived, 42
run, 0 NOT-MEASURED, 0 UNRUN".
- `overlap-check` at 3b5b130: VERDICT clean exit 0 against origin/main
d7411fa (three commits past the merged 9e2a4ac; `git merge-tree` is
also clean) and objectstack-ai#36634, objectstack-ai#36629, objectstack-ai#36606, objectstack-ai#36587, objectstack-ai#36525.
- ui extras: `check:new-line-citations` 0, `check:i18n-keys` 0,
`check:i18n-drift` 0, `check:i18n-dead-keys` 0. eslint on the changed
source and test files: 0 errors, and no warnings on added lines.

</details>

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01ADHkmPq6z7KER4Sr6Uu7Ht

---------

Co-authored-by: Claude <noreply@anthropic.com>
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/xl tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

console: preview images, PDF, text and CSV in the page from attachments and file fields (Office stays download only)

2 participants