Repository navigation
Studio: chat attachment cards, chips and the Library viewer - #12017
Conversation
…gin links in Library
…nd text downloads
…slides, originals sweep on message removal
…lized PDF pages, large DOCX images
…ch, run origins under outputs
… attach, whole-text downloads
… and sweep lock, deduplicated storage
Spreadsheets - Read sheet XML as text instead of through DOMParser, and only up to the rows kept. Unpack only the parts the workbook uses, so custom XML and pivot caches are skipped. Shared strings decode lazily. - Parse each number format once per workbook instead of once per cell. - Grid renders only the columns in view, with memoized rows. - Quoted semicolons no longer split format sections, scientific formats keep their literals, and elapsed times show fractional seconds. Presentations - Pictures stay as Blobs with object URLs made per mounted slide, instead of base64 data URLs for the whole deck. Video and audio are not unpacked. - Native tables are capped like chart tables. SmartArt labels are read. Word - Rendering stops after 50,000 elements, with a note. Chat - Office text for the model is budgeted in UTF-8 bytes, delimiters included. - Attaching an XLSX or PPTX reads the file once. Chat originals - Sweeps no longer create the originals folder, so a late sweep cannot recreate a deleted account's workspace. - Startup sweeps every account. Deleting an attachment from the Library sweeps too.
- A negative value in its own fraction section, such as (# ?/?), no longer gets an extra minus. - String cells use the format's text section: the fourth section, or a single section with @. ABC in 0;0;0;"SKU-"@ shows SKU-ABC. - Shared strings are scanned from the part's bytes only up to the highest index a cell uses, and decoded one at a time, instead of building the whole table.
This comment has been minimized.
This comment has been minimized.
- A worksheet whose first row runs past the 64 MB XML cap is truncated instead of decoded whole. - At most 100 visible sheets are read, so empty sheets cannot add unbounded tabs and unzip passes. - PPTX inflates only what visible slides use: their XML and rels, charts, SmartArt data and, for the viewer, their pictures. Notes, comments, masters and unused media are skipped. - Each slide mounts at most 10,000 paragraphs, table cells and pictures, ending with a "…" when cut. - Built-in formats files leave out are filled in: currency (5 to 8), fractions (12, 13), accounting (41 to 44) and 48. East Asian date and time IDs fall back to the standard ones.
…ards keep their edge
- The attachment inventory records the extracted text size of documents with a kept original (inventory version 5). Disk usage counts that text for every message, and the original only once and only while on disk. - Elapsed-time formats replace parsed placeholders only, so quoted or escaped text stays as written: [h]:mm "hours" shows 1:00 hours.
…gins - PPTX slides are parsed one at a time instead of all held as DOMs, hidden slides are found from the root tag, and at most 500 slides are read with a note when more follow. - Negative elapsed times in their own section use that section's sign, so [h]:mm;([h]:mm) shows (1:00). - Documents sent in a temporary chat keep their file in memory, so they still open as pages, grids or slides. Saving the chat uploads them as originals. Serialized attachments never carry the File. - Exports record their source checkpoint, and Library links an export to a training run only through that metadata. Older Studio exports fall back to their folder name; folders with no export metadata get no run link.
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eaaff2900f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const observer = new ResizeObserver(layout); | ||
| observer.observe(el); |
There was a problem hiding this comment.
Recompute card overflow when UI scale changes
When the user changes the UI font size while attachments are present, --ui-space-scale changes each card's minimum width and the gap without changing this container's content-box width, so this observer does not fire and the effect also does not rerun because it depends only on count. For example, ten cards that fit in two rows at the default scale can require three rows at 20px yet remain in data-layout="wrap" instead of switching to the scrolling strip. Observe a card as well, or subscribe the calculation to the UI scale/font-size setting.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Below the bar: this is layout only (two rows of cards instead of a scrolling strip after a font-size change), nothing is lost or hidden, and the next attachment change recomputes it.
| const [open, setOpen] = useState(false); | ||
| const [failed, setFailed] = useState(false); |
There was a problem hiding this comment.
Reset preview failures when the attachment changes
After an image emits onError, failed remains true for the lifetime of this index-based attachment component, including after the viewer closes. If the user then switches to another conversation branch or edits the message so a valid image occupies the same attachment index, the thumbnail updates but reopening the viewer still renders “cannot preview” without ever trying the new src. Reset this state when src changes (and apply the same reset to AttachmentVideoDialog, which repeats this state pattern).
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Below the bar: it needs an image that already failed to decode and then a branch switch that puts a valid image at the same index; the thumbnail is right and reopening after a reload retries.
| extra={ | ||
| <> | ||
| <ScaleMenu | ||
| value={scale} |
There was a problem hiding this comment.
Make attachment viewer controls responsive
On a narrow viewport, this fixed-width scale control—and, for HTML, the two additional view toggles—is rendered alongside the viewer's fixed-width “Chat about this”, download, and close buttons. MediaViewer keeps that header on one non-wrapping flex row with shrink disabled on every control, while its dialog is only 92vw wide and clips overflow; at a 350px viewport the controls alone exceed the available header width, so right-side actions become clipped and unreachable. Collapse or hide secondary controls, or provide a wrapping/overflow menu layout at small widths.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Below the bar: a 350px viewport is not a width Studio targets; at supported widths every header control is reachable.
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
# Conflicts: # studio/frontend/src/components/assistant-ui/attachment-document-dialog.tsx
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 56bc3e6ea2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| void navigate({ to: "/chat", search: { new: nonce } }).then(() => { | ||
| requestAnimationFrame(() => | ||
| useLibraryChatHandoffStore.getState().offer(`single:${nonce}`, handoff), |
There was a problem hiding this comment.
Fence the deferred handoff against session changes
If the auth session is cleared after navigate() starts but before this promise/animation-frame callback runs, chat-handoff-store clears the old account's pending files and then this callback reintroduces them for the new account. This affects every Library handoff, including chatAboutMedia, despite its earlier epoch check. Fresh evidence beyond the earlier load() concern is that the new asynchronous window is created inside startLibraryChat itself, after loading has completed; capture the session epoch before navigation and verify it again before calling offer.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not reachable across accounts: a late offer can only refill the store in the same page session, and signing in as a different account goes through transitionBrowserAccount, which calls location.replace and discards all client state before that account sees anything (lib/account-transition.ts). The same account signing back in only gets its own files.
…chment-formats Takes the Library stack as the new base; the next commit re-applies this PR as a layer on top of it.
# Conflicts: # studio/frontend/src/components/assistant-ui/attachment-document-dialog.tsx # studio/frontend/src/components/assistant-ui/attachment-preview.tsx # studio/frontend/src/components/assistant-ui/attachment-selection.ts
unslothai#12001 and unslothai#12017 landed on main; this keeps only this PR's layer on top.
…i#12017) * Studio: document viewer for PDF, Word, Excel and PowerPoint, with origin links in Library * Studio: smaller corner radius on the file viewer * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Studio: show chat CSV and markdown attachments without the chat wrapper * Studio: Library grid and sort polish, edge to edge document pages * Studio: address review on originals sweep, 1904 dates, slide tables and text downloads * Studio: Excel formats, formula cells, Office text cap and extensionless originals * Studio: Excel date tokens and built-in time formats, hidden rows and slides, originals sweep on message removal * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Studio: workbook cell cap, early 1900 dates, fraction formats, virtualized PDF pages, large DOCX images * Studio: Excel digit placeholders, slide charts, Office checks at attach, run origins under outputs * Studio: conditional Excel formats, virtualized slides, Office read at attach, whole-text downloads * Studio: shared formulas, chart and line-break reading, originals save and sweep lock, deduplicated storage * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Studio: faster document viewer, open review fixes Spreadsheets - Read sheet XML as text instead of through DOMParser, and only up to the rows kept. Unpack only the parts the workbook uses, so custom XML and pivot caches are skipped. Shared strings decode lazily. - Parse each number format once per workbook instead of once per cell. - Grid renders only the columns in view, with memoized rows. - Quoted semicolons no longer split format sections, scientific formats keep their literals, and elapsed times show fractional seconds. Presentations - Pictures stay as Blobs with object URLs made per mounted slide, instead of base64 data URLs for the whole deck. Video and audio are not unpacked. - Native tables are capped like chart tables. SmartArt labels are read. Word - Rendering stops after 50,000 elements, with a note. Chat - Office text for the model is budgeted in UTF-8 bytes, delimiters included. - Attaching an XLSX or PPTX reads the file once. Chat originals - Sweeps no longer create the originals folder, so a late sweep cannot recreate a deleted account's workspace. - Startup sweeps every account. Deleting an attachment from the Library sweeps too. * Studio: slim down document viewer and chat originals tests * Studio: fraction sign, text format sections, lazy shared strings - A negative value in its own fraction section, such as (# ?/?), no longer gets an extra minus. - String cells use the format's text section: the fourth section, or a single section with @. ABC in 0;0;0;"SKU-"@ shows SKU-ABC. - Shared strings are scanned from the part's bytes only up to the highest index a cell uses, and decoded one at a time, instead of building the whole table. * Studio: let a full 5,000 by 200 sheet fit the workbook cell budget * Studio: chat attachment cards, chips and the Library viewer * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Studio: tighter Office reader bounds, built-in currency formats - A worksheet whose first row runs past the 64 MB XML cap is truncated instead of decoded whole. - At most 100 visible sheets are read, so empty sheets cannot add unbounded tabs and unzip passes. - PPTX inflates only what visible slides use: their XML and rels, charts, SmartArt data and, for the viewer, their pictures. Notes, comments, masters and unused media are skipped. - Each slide mounts at most 10,000 paragraphs, table cells and pictures, ending with a "…" when cut. - Built-in formats files leave out are filled in: currency (5 to 8), fractions (12, 13), accounting (41 to 44) and 48. East Asian date and time IDs fall back to the standard ones. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Studio: five attachment cards per row, borderless image cards, dark cards keep their edge * Studio: count extracted text in storage, keep elapsed-time literals - The attachment inventory records the extracted text size of documents with a kept original (inventory version 5). Disk usage counts that text for every message, and the original only once and only while on disk. - Elapsed-time formats replace parsed placeholders only, so quoted or escaped text stays as written: [h]:mm "hours" shows 1:00 hours. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Studio: slide cap, elapsed sign, temporary chat documents, export origins - PPTX slides are parsed one at a time instead of all held as DOMs, hidden slides are found from the root tag, and at most 500 slides are read with a note when more follow. - Negative elapsed times in their own section use that section's sign, so [h]:mm;([h]:mm) shows (1:00). - Documents sent in a temporary chat keep their file in memory, so they still open as pages, grids or slides. Saving the chat uploads them as originals. Serialized attachments never carry the File. - Exports record their source checkpoint, and Library links an export to a training run only through that metadata. Older Studio exports fall back to their folder name; folders with no export metadata get no run link. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Studio: XLSM by MIME, format literals, bounded styles and DOCX parts - The macro-enabled workbook MIME key is lowercase, as lookups are, so an XLSM picked without its extension keeps its original and opens as a grid. - Padding, fill and bracket tags are removed only outside quoted and escaped text: "A_B"0 shows A_B1. Currency symbols stay literal, so [$kr.-41D] no longer reads its dot as a decimal point. - Only the number format, font and cell format sections of styles.xml are decoded, each found by a byte scan and capped at 16 MB. - The DOCX viewer keeps oversized images only, not other large parts. - When a sent document's original is gone, its stored text stays downloadable, as a .txt file. * Studio: index Office archives once, percent in scientific formats, MIME-only CSV, sweep after upserts * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Studio: attachment viewers mount on first open, sent text downloads whole - Every attachment tile mounted a MediaViewer up front, whose project menu subscribes to and refetches the project list. The viewer now mounts on first open and stays for its close animation, so a long thread pays nothing for tiles never opened. - A sent text file's Download and Chat about this used the capped preview text; they now cut the whole body from the stored text, as the document viewer does. - A failed read for Chat about this or Download shows a toast instead of rejecting silently. - The audio viewer offers Download only when there is a clip to build it from. * Studio: cap slides before inflating them, elapsed placeholder widths, percent fractions * Studio: parse each slide as it is read, grouped shape frames, CDATA-safe sheet scan, scaled fractions, finished runs first * Studio: bound cell text and DOCX paragraphs before parsing, slide paragraph budget, hidden shared-formula masters, quoted fraction literals, repeated percent, false font flags * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Studio: compact shared-string offsets, capped CSV fields and slide XML, engineering notation, group flips and rotation, MIME-only CSV in Library * Studio: bound every DOM-parsed Office part, read slide charts and pictures per frame * Studio: one sweep scheduler thread, deck text and chart budgets, ZIP64 part sizes, DOCX images by content type, whole-row and column formula shifts * Studio: slide shapes in document order, own flips, picture budget and declared types, clipped table cells, lazy workbook support parts, quoted sheet names * Fix cached empty string formula results in document viewer * Keep out-of-range date cells from aborting document previews * Studio: bounded worksheet inflation, deck text charged per box, fraction search by continued fractions, PDF canvas bounds, main part from package rels, Markdown by MIME * Studio attachments: play videos in the viewer, keep local display settings on legacy records - Sent and composer videos open a video player in the Library viewer instead of falling through to the text viewer; composer clips are labelled and iconed as video rather than audio by their .mp4 name. - Personalization reports whether composerAttachments / sentAttachments were saved, so a record written before they existed keeps the browser's values instead of the server defaults. * Studio viewer: ZIP64 and streamed shared strings, referenced DOCX images, picture crop, PDF text layer bound * Studio viewer: inflate only the DOCX relationships read, bound PDF image size * Studio viewer: cap ZIP entries, mark sheets cut past the shared strings bound, bound picture pixels * Studio viewer: bound DOCX picture pixels, refuse SVGs that embed rasters, cap DOCX entries * Studio viewer: mark sheets cut when styles are past their bound, release a document when its viewer closes * Studio viewer: bound PDF page operations, bound format precision, read the hidden flag from the slide root * Studio viewer: cap shared strings indexed, keep structured references, bound format codes; recheck an original before removing it * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Studio viewer: pixel budgets per slide and document, cut DOCX markup before parsing, release PDF pages, cap listed pages and style tags, bound export metadata * Trim comments in document viewer and chat originals * Drop redundant comments across attachment viewer changes * Keep comments that record non-obvious invariants in the viewer * Declare contentType on the attachment selectAttachmentSource reads * Trim attachment display comments * Studio viewer: show the integer in formats without whole digits, read lowercase cell references, prefix DOCX ids * Studio attachments: drop a viewer load or chat handoff that finishes after a sign-out * Revert the sign-out fence on viewer actions: loads resolve from memory and an account switch reloads the page * Re-measure the startup bundle budget for the chat attachment cards * Keep aui-attachment-root on composer attachment cards, which studiobench counts * Studio viewer: decode a composer Markdown file as its attachment adapter does * Write the export metadata fixture with json.dumps so Windows paths stay valid JSON --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: imagineer99 <[email protected]> Co-authored-by: danielhanchen <[email protected]> Co-authored-by: Daniel Han <[email protected]>
Summary
Reworks how attached files look in the composer and in sent messages, and opens every attachment in the Library's viewer.
Stacked on #12001 (document viewer). Merge that first; this PR's base is its branch.
Composer
Sent messages
Viewer
Attaching before a model is loaded
Settings
Testing
npm test: 9037 passing.npm run i18n:check: all 12 locales in parity.tsc --noEmit: clean. No new lint errors in the touched files.pytest tests/test_personalization_settings.py: 41 passed.Screenshots
Before is #12001 (
studio-document-viewer, d93cda6), after is this branch, each in its own Studio install, on a chat with three sent files.Before, the sent files show as three identical file icons with no names. After, each shows as a row with its name, its type and a colored icon.