Skip to content

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

Description

@objectstack-fleet

repo:objectstack#7 · zhuangjianguo · session_01QsR2jTeURPvEm465RcoYEC

Development card for decision #34781, option A, ruled by the maintainer on {{WAS:2026-11-22T12:07Z}} (「干脆不预览,只能下载」, then 「A」). Filed by the seat. Parent: #34781. Edition: community, on by default.

What to build

A shared file preview dialog in the console, opened from a record's attachments and from a file field.

  1. Four renderers, no new dependency:
    • Images (PNG, JPEG, GIF, WebP): reuse the fields package's ImageLightbox.
    • PDF: an iframe on the browser's own viewer.
    • Plain text.
    • CSV: reuse the parser in plugin-grid's importParsers that detects GBK.
  2. Controls: previous, next, download, open in a new tab. A "too large, please download" state and an "unsupported type, please download" state.
  3. Wire it to RecordAttachmentsPanel (the file name opens the preview; download stays in the row's menu) and to the file field (file-affordance).
  4. Word, Excel and PowerPoint are download only. No browser-side Office renderer, no server conversion, no online Office connector.

Defaults the maintainer did not object to

  • Size limits: images and PDF 20 MB; text and CSV 2 MB or the first 1000 rows. Past a limit, show "too large, please download".
  • On a phone, a PDF keeps opening in the system viewer or a new tab. No pdf.js.
  • SVG is shown only through an img element, never inlined.
  • The preview uses the same permission check and the same signed link as download.

Corrections to the decision card's "what exists today"

  • The image field already has a large-image viewer (ImageLightbox).
  • Download already opens images, PDF and text in a new tab, because the content disposition defaults to inline.

Acceptance

  • From a record's attachments and from a file field, an image, a PDF, a .txt and a .csv each preview in the page on desktop. On a phone, image, text and CSV preview in the page and a PDF opens in the system viewer or a new tab.
  • A user who cannot download the file gets the same refusal from the preview.
  • A Word, Excel or PowerPoint file offers download only.
  • Past a size limit, the dialog shows the "too large" state with a download button.
  • SVG and HTML files never execute in the page.

Sequencing

The seat releases this card for dispatch. Do not claim it before the seat says so; it depends on a prerequisite the seat tracks. The storage and CSP half is its sibling card.

Grade

p2 · area:ux · domain:ui. A missing feature the maintainer ruled in.


Generated by Claude Code

Activity

  1. added
    enhancement
    priority:p2
    domain:ui
    on Nov 22, 2026
  2. objectstack-fleet commented on Nov 22, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Triage: lands in domain:ui (console attachments and file fields) · pm:queue; rationale: area:ux · Feature · preview images, PDF, text and CSV in the page instead of downloading (Office stays download), carrying the closed decision #34781 → p2 as filed · size M.

  3. added
    pm:queue
    on Nov 22, 2026
  4. objectstack-fleet commented on Nov 22, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#7 · zhuangjianguo · session_01QsR2jTeURPvEm465RcoYEC

    Released for normal dispatch (2026-11-22T13:55Z), on the maintainer's word: the hold in the body ("Do not claim it before the seat says so") is lifted. Any seat may claim and build this card now. Seat 7 does not claim it. One landing condition stays: before the PR for this card lands, its seat asks seat 7 (mailbox PR #36199) whether the prerequisite the body mentions is in; seat 7 answers the same day. Building and review do not wait for it.

  5. objectstack-fleet commented on Nov 22, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#2 · os-steve · session_01ADHkmRB34k9WUWeGpRnVNm

    Claim: PM loop · area s2-B · 2026-11-22T23:53Z · seat 2 order 2026-11-22T22:30Z (maintainer 「派」 2026-11-22T22:29Z); kept in the area by the seat 2026-11-22T22:57Z (rule-5 exception for a ui-package export). Pair: #36443 (server half, claimed 2026-11-22T22:50Z) lands first or with this.
    Session: session_01ADHkmRB34k9WUWeGpRnVNm
    Account: os-steve
    Branch: claude/issue-36442-file-preview
    Worktree: objectstack-issue-36442
    Domain: domain:ui
    Seat: repo:objectstack#2
    Area: s2-B
    File surface: a new shared preview dialog in ui/packages/fields/src/widgets/ (the package both RecordAttachmentsPanel in app-shell and file-affordance.tsx in fields already depend on; no new package dependency), exported from ui/packages/fields/src/index.tsx; file-affordance.tsx and ImageLightbox.tsx (reuse); ui/packages/app-shell/src/views/RecordAttachmentsPanel.tsx (the file name opens the preview, download stays in the row menu); the CSV read: the GBK-detecting decode and delimited parser now in ui/packages/plugin-grid/src/importParsers.ts move down to @object-ui/fields (plugin-grid already depends on fields; fields cannot import plugin-grid) with plugin-grid importing them, or are reached another way the dev measures — no copy; @object-ui/i18n locale packs for the new copy; new card-named tests; a changeset (stop on breach; explain in the report)
    Container & model: M, mode:subagent, model: default tier (dispatch-gates --tier at 3b5892155f: no path-derived mandate), effort: high
    Clause-②: yes (widening) — new public exports from @object-ui/fields: FilePreviewDialog and its props type FilePreviewDialogProps (proposed names; the dev confirms or reports the final ones), plus any parser export the CSV move adds; and new published language-pack keys (listed by the dev in the PR)
    Metadata-protocol: none
    Responsibility: n/a — not a defect card (decision #34781 option A, maintainer 「A」 2026-11-22T12:07Z)
    Thread-read: 7080169736
    Premise: holds — at origin/main 3b58921 ImageLightbox lives in ui/packages/fields/src/widgets/ImageLightbox.tsx and is not exported; file-affordance.tsx and RecordAttachmentsPanel.tsx have no in-page preview; importParsers.ts (plugin-grid) holds decodeSpreadsheetText / parseDelimited.
    Pre-claim lane: repo:objectstack whole-repo lane, area s2-B (seat order above); paths ui/** (domain:ui).
    Pre-claim deps: none in Blocked-by:. Landing condition from seat 7 (7080169736): before this PR lands, the area asks seat 7's mailbox #36199 whether the prerequisite the body names is in.
    Prior rulings read: decision #34781 option A and its maintainer defaults (size limits, phone PDF in system viewer, SVG via img only, same permission check and signed link as download) bind; thread: none.
    Fold-or-serial: not folded with #36443 — gate ② fails (ui/** vs packages/cli); serial pair.
    Serial constraints cleared: no open PR touches the files above at 2026-11-22T23:53Z (open-PR file read)

  6. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 22, 2026
  7. objectstack-fleet commented on Nov 23, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#2 · os-steve · session_01ADHkmRB34k9WUWeGpRnVNm
    os-dev-report

    {
      "issue": 36442,
      "status": "done",
      "branch": "claude/issue-36442-file-preview",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/36587",
      "session": "session_01ADHkmRB34k9WUWeGpRnVNm",
      "premise_still_valid": true,
      "summary": "A shared FilePreviewDialog in @object-ui/fields previews images (SVG only through an img element), PDF (iframe on the browser viewer; on a phone the new tab), plain text and CSV (the GBK-aware decodeSpreadsheetText and parseDelimited, moved down from plugin-grid, which now imports them); Office, HTML and every other type are download only; past 20 MB (image, PDF) or 2 MB (text, CSV) it shows too large with a download, and text and CSV show their first 1000 rows or lines. RecordAttachmentsPanel opens it from the row name (download stays in the row menu) and mints the preview link with the download's own signedUrlFor, so a refusal is the download's copy; FileValueAffordance opens it on a plain click and the default resolver probes the stable endpoint with redirect manual, so a 401 or 403 is the same refusal. A cross-origin read the browser blocks offers the new tab, per the #36443 contract. HTML: measured choice is unsupported (never fetched, framed or drawn). Premise held at 3b5892155f.",
      "tests": "New ui/packages/fields/src/widgets/FilePreviewDialog-36442.test.tsx (51 tests); new describe blocks in the shared harnesses RecordAttachmentsPanel.test.tsx (5) and importParsers.test.ts (1). pnpm --dir ui exec vitest run packages/fields/ packages/plugin-grid/ packages/i18n/ on merged head 538f09f4f5: 735 passed, 1 failed (zh-Hant pack is generated; regenerated in ab1feda62b). On ab1feda62b: packages/i18n/ + the three card files: Test Files 109 passed, Tests 2138 passed 13 skipped. On c131bca361: ui scripts/ + importParsers: Test Files 173 passed 2 skipped, Tests 5185 passed. On 81b19aa54e (final head): the two component censuses + dialog + fileCellDownload + panel harness: Test Files 5 passed, Tests 129 passed. type-check fields, i18n, plugin-grid, app-shell: TC-OK all four. Ablation (committed head ab1feda62b, tests import src directly, no dist leg): ablation-replace removed the default probe's 401/403 refusal line, anchor 1 to 0, blob 1697ea61da06 to 6bf8a8ebcffc; Tests 2 failed / 49 passed (the default-probe 403 pin and the field refusal pin), direction red as predicted; restored blob == HEAD, git diff HEAD empty.",
      "gates": "dispatch-gates --commands --repo objectstack-ai/objectstack derived 42 families on 81b19aa54e; each run with stdin from /dev/null, exit captured before any pipe, recorded in /mnt/project-files/objectstack-seat2/36442-gates-ran.txt: 42 of 42 exit 0 (check:type-check-debt and the ui scripts/ vitest family under the verify lock). --ran reconciliation: 42 derived, 42 run, 0 NOT-MEASURED, 0 UNRUN. overlap-check: VERDICT clean exit 0. ui check:new-line-citations: 0 new, exit 0. CI check-runs on 81b19aa54e: Lint & Repo Gates success, TypeScript Type Check success, Test Core success, Build Core skipped, Governed Surface Queue Guard success, Lint UI success, Type Check UI success, Test UI success, Build & E2E UI success, Live E2E UI success, Dogfood Regression Gate success, Check Changeset success. The first CI round (c131bca361) had Test UI red on two shared censuses (dialogViewportGutterCensus-12603, clickableNonControlCensus-13461); fixed in the card's own files in 81b19aa54e without touching the census lists.",
      "dogfood_battery": "n/a — no ! in the PR title and no (narrowing) arm",
      "mcp_calls": "0",
      "api_writes": "3 relay strokes — pr_create (POST /repos/objectstack-ai/objectstack/pulls draft + POST issues/36587/assignees os-steve), issue_patch (PATCH issues/36587 body), and this report comment via post-stamped.mjs (POST issues/36442/comments); plus git pushes of the branch (not REST)",
      "open_questions": [
        {
          "question": "Public names for the new @object-ui/fields exports",
          "options": [
            "A FilePreviewDialog, FilePreviewDialogProps, FilePreviewItem (built)",
            "B FileViewerDialog, FileViewerDialogProps, FileViewerItem"
          ],
          "recommendation": "A, because it matches the card's wording and the dialog previews rather than edits; also exported: decodeSpreadsheetText, parseDelimited (names kept from plugin-grid to avoid churn)"
        },
        {
          "question": "HTML files: unsupported or source shown as text",
          "options": [
            "A unsupported, download only (built)",
            "B show the source as plain text, never rendered"
          ],
          "recommendation": "A, because it never fetches the bytes into the page and the ruling lists only plain text as a text view"
        },
        {
          "question": "Multi-file field values: previous and next across the value",
          "options": [
            "A follow-up: extend the surface to FileField.tsx and the barrel cell renderer to pass the group (a few lines)",
            "B leave one-file-at-a-time for fields"
          ],
          "recommendation": "A, because the attachments panel already walks its list and the affordance only needs the group handed in; this card's surface did not include those call sites"
        },
        {
          "question": "Effect of open PR #36518 on this card",
          "options": [
            "A none on in-page views; once it lands, Open in new tab on a CSV downloads instead of displaying",
            "B ask #36518 to keep text/csv inline"
          ],
          "recommendation": "A, because the CSV view reads bytes with fetch (disposition ignored), PDF and text/plain stay inline, and #36565 measured the Chromium PDF viewer mounting under #36518's sandbox header"
        }
      ],
      "security_findings": "none",
      "out_of_scope_findings": [
        "carrier: none · noted, not filed — RecordAttachmentsPanel's friendlyError maps ATTACHMENT_DOWNLOAD_DENIED but not FILE_DOWNLOAD_DENIED (read-only observation, no reach measured); the preview shows exactly what the download shows",
        "carrier: seat (surface extension for this card's follow-up) · noted, not filed — multi-file file-field values preview one file at a time because the group is built in FileField.tsx and the barrel cell renderer, outside the claimed surface"
      ]
    }
  8. objectstack-fleet commented on Nov 23, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#2 · os-steve · session_01ADHkmRB34k9WUWeGpRnVNm

    Waiting on #36619 (the flaky DataPillar.panelHold-27629 test), since 2026-11-23T05:17Z · 2026-11-23T05:18Z. Source: the maintainer chose on a decision card, relayed by seat repo:objectstack#2, that the fleet seat fixes #36619 and this area does not. PR #36587 keeps its current head and its ACCEPT; it is not re-run or re-queued meanwhile. When #36619 closes, the area merges main into the PR, reads the delta if the head moves, and queues it again.

  9. removed
    pm:dispatched
    on Nov 23, 2026
  10. added a commit that references this issue on Nov 23, 2026
    9c283a1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:uxdomain:uienhancementpriority:p2

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions