Repository navigation
feat(console): preview images, PDF, text and CSV in the page from attachments and file fields - #36587
Conversation
…achments and file fields Claude-Session: https://claude.ai/code/session_01ADHkmRB34k9WUWeGpRnVNm Co-authored-by: Claude <noreply@anthropic.com>
… and wiring Claude-Session: https://claude.ai/code/session_01ADHkmRB34k9WUWeGpRnVNm Co-authored-by: Claude <noreply@anthropic.com>
…refusal keeps its cause Claude-Session: https://claude.ai/code/session_01ADHkmRB34k9WUWeGpRnVNm Co-authored-by: Claude <noreply@anthropic.com>
…pp-shell builds for; changeset Claude-Session: https://claude.ai/code/session_01ADHkmRB34k9WUWeGpRnVNm Co-authored-by: Claude <noreply@anthropic.com>
…iew keys Claude-Session: https://claude.ai/code/session_01ADHkmRB34k9WUWeGpRnVNm Co-authored-by: Claude <noreply@anthropic.com>
… module scope Claude-Session: https://claude.ai/code/session_01ADHkmRB34k9WUWeGpRnVNm Co-authored-by: Claude <noreply@anthropic.com>
…s own clicks at its content Claude-Session: https://claude.ai/code/session_01ADHkmRB34k9WUWeGpRnVNm Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#2 · os-steve · session_01ADHkmRB34k9WUWeGpRnVNm Flake reading — PR #36587 @ 6775877 · 2026-11-23T04:20Z
|
|
repo:objectstack#2 · os-steve · session_01ADHkmRB34k9WUWeGpRnVNm Contract-review-claim: session_01ADHkmRB34k9WUWeGpRnVNm · head 6775877 · 2026-11-23T04:33Z |
|
repo:objectstack#2 · os-steve · session_01ADHkmRB34k9WUWeGpRnVNm Contract reviewServed-tier: The face is the ① Derived judgments
② Semver levelpatch for ③ Boundary flags
Implemented-by: VERDICT: PASS |
|
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
|
⛔ merge queue 构建失败 — 先分诊,再决定要不要重排队列构建 45112843268 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集), 分类: 失败的 job(日志抽取,best effort):
跨 PR 相同签名(24h,按失败测试文件聚合):
历史信号:
分诊清单:
Generated by Claude Code · merge-queue-triage workflow (#4859) |
|
repo:objectstack#2 · os-steve · session_01ADHkmRB34k9WUWeGpRnVNm Second red — PR #36587 @ 6775877, merge queue · 2026-11-23T04:56Z
|
|
repo:objectstack#2 · os-steve · session_01ADHkmRB34k9WUWeGpRnVNm Contract-review-claim: session_01ADHkmRB34k9WUWeGpRnVNm · head 6e7be24 · 2026-11-23T06:42Z |
|
repo:objectstack#2 · os-steve · session_01ADHkmRB34k9WUWeGpRnVNm Contract reviewServed-tier: The face is the Delta from the record at 6775877 (7091693978, PASS)The head moved only by the relay's update-branch merge of ① Derived judgments
② Semver levelpatch for ③ Boundary flags
Implemented-by: VERDICT: PASS |
|
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
|
… 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>
Requested by Steve · project thread
Fixes #36442
Clause-②: yes (widening)
Metadata-protocol: none
维护者速读
What changes
A shared
FilePreviewDialogin@object-ui/fields(decision #34781, option A), opened from a record's attachments and from a file field:imgelement only) via the lightbox's own image element (LightboxImageView, extracted fromImageLightbox); PDF in aniframeon the browser's own viewer, without asandboxattribute; plain text as text; CSV as a table, read with the GBK-awaredecodeSpreadsheetTextandparseDelimited, which moved down from@object-ui/plugin-grid(it now imports them from@object-ui/fields; no copy)..htmlname wins over a declared plain-text type.application/pdf, or a.pdfname when no type is declared. A.pdfname with another declared type (for exampleapplication/octet-stream) is unsupported, so the frame never receives bytes the browser would read as anything else./files/:id/urlwith the console's token, now onesignedUrlForboth 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/:idendpoint) and first asks it withredirect: 'manual': a redirect is the grant, a 401/403 is the refusal, so no byte moves twice.useIsMobilebreakpoint a PDF is offered in a new tab (the system viewer), never framed; image, text and CSV stay in the page.GETon 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.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.fields.filePreviewin 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/i18nkeys (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 theiframe),useResolverinFilePreviewDialog.tsx(the refusal probe and the one-resolver-per-dialog rule), thenpreviewSignedUrl/signedUrlForinRecordAttachmentsPanel.tsx.Two-minute check:
pnpm --dir ui exec vitest run packages/fields/src/widgets/FilePreviewDialog-36442.test.tsxshows 51 passing.Tests
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 asimg, noiframe/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 fromresolveUrl, 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.RecordAttachmentsPanel.test.tsx, new top-leveldescribe: 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.importParsers.test.ts, newdescribe: the wizard'sparseDelimited/decodeSpreadsheetTextare the very functions@object-ui/fieldsexports.getByText('report.pdf')keep passing on the new name button.Acceptance notes
FileField.tsxand the cell renderer in the fields barrel, outside this card's claimed file surface. The attachments panel walks its whole list.useIsMobile, under 768 px), not a device check.fetch, which ignores the disposition; feat(cli): the console's frame-src names the storage origin a PDF preview frames, and nothing wider #36565 measured Chromium mounting its PDF viewer under that PR's sandbox header). The "Open in new tab" for a CSV would download it rather than display it once fix(service-storage)!: stored bytes outside the inline allow-list are served as attachments, with nosniff and a sandbox CSP #36518 lands.frame-srcand the text and CSV reads need the bucket CORS rule cli/storage: let the console frame a PDF from the storage origin, and document the bucket CORS the file preview needs #36443 documents; without them the dialog offers the new tab, as that card's contract states.FILE_DOWNLOAD_DENIED(field-owned files) has no friendly copy in the attachments panel's mapper; the panel only mapsATTACHMENT_DOWNLOAD_DENIED. The preview shows exactly what the download shows. Observation only.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)
Ablation: delete the default probe's refusal (one line in useResolver)
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-debtand the uiscripts/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