Repository navigation
Studio: read Office, OpenDocument, e-book, email, RTF and web page files in chat with files - #13081
Conversation
|
@codex review |
|
@codex security review |
This comment has been minimized.
This comment has been minimized.
1aedb3e to
c4b71ce
Compare
…t with files Adds parsers for .doc .xls .xlsx .xlsm .ppt .pptx .msg .eml .rtf .odt .ods .odp .epub using only the standard library, and lets the chat with files panel pick and drop them along with .csv .tsv .json .xml.
- RTF: ignore negative \bin lengths, and decode literal 8-bit text in the document code page. - ODF: skip tracked deletions, keep bookmark references, read nested tables once, and cap text added by repeated cells and rows. - EPUB: resolve URI-escaped manifest paths. - OOXML: read Strict namespaces. - PPTX: drop only the notes slide number placeholder, not numeric notes. - XLS: format date cells from FORMAT, XF and DATEMODE records. - DOC: include footnotes, endnotes and text boxes. - MSG: decode String8 properties with the message code page, and fall back to the compressed RTF body. - Desktop: route dropped .doc .xls .xlsx .xlsm .ppt .pptx .msg files to chat with files.
c4b71ce to
191de6e
Compare
|
@codex review |
- RTF: pair UTF-16 surrogates from \uN so astral characters survive, and skip text marked \deleted. - MSG: stop decoding compressed RTF at its declared size and refuse oversized bodies. - ODS: read typed cell values written without a text paragraph. - XLS and XLSX: treat the CJK and Thai built-in date formats as dates.
Incremental saves keep old record versions in the stream, so slides from earlier saves were indexed too. The reader now follows the Current User edit chain and its persist directories to the live document, reads each slide's shapes in order (placeholders through OutlineTextRefAtom, plus text boxes), and appends speaker notes matched by slide id. A broken edit link continues with the next older edit; files without an edit chain keep the old scan.
|
@codex review |
- XLSX and XLS: time-of-day and [h] duration formats keep their own text, and serials before March 1900 account for Excel's 29 February 1900, as openpyxl does. - XLS: error cells and cached formula errors read as #DIV/0!, #N/A and so on, and long formula strings continue into CONTINUE records. - RTF: bytes decode with the active font's charset or code page, and groups nested past 1000 levels are refused. - MSG: Exchange senders get their SMTP address. - EML: an empty plain part falls back to the HTML part.
|
@codex review |
- Find the main OOXML part through _rels/.rels, and sharedStrings and styles through the workbook rels. - Stream sheet rows and shared strings with per-element, per-row and depth caps so large or crafted parts cannot exhaust memory. - Show Excel numbers with their display format (percent, grouping, scientific, literals, currency, sections). - Add pptx chart titles and cached series data. - Keep internal empty ODF cells, drop only trailing ones; stream .ods rows. - Prefer the Unicode branch of RTF \upr groups. - Join every inline body part of mixed emails.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b65627bc8c
ℹ️ 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".
| class _Archive: | ||
| def __init__(self, path: str): | ||
| try: | ||
| self._zip = zipfile.ZipFile(path) |
There was a problem hiding this comment.
Bound ZIP entry counts before opening archives
With the default 200 MB upload allowance, a crafted Office, OpenDocument, or EPUB archive can contain millions of empty members because each central-directory entry needs only a few dozen bytes. zipfile.ZipFile eagerly creates ZipInfo objects and lookup tables for every entry before the decompressed-byte budget is applied, so such an upload can exhaust an ingestion worker without reading any member content. Inspect and reject excessive central-directory counts before constructing ZipFile, then retain a defensive count limit afterward.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Needs a deliberately crafted archive; the cost is bounded by the 200 MB upload cap and no real Office, OpenDocument or EPUB package comes near that entry count.
| dir_bytes = self._read_chain(first_dir, self._fat, self._raw_sector, self._sector) | ||
| self._entries = [ | ||
| _Entry(dir_bytes[i : i + 128], major) for i in range(0, len(dir_bytes) - 127, 128) | ||
| ] |
There was a problem hiding this comment.
Cap compound-file directory entries before materializing them
For an uploaded OLE file whose directory chain occupies most of the allowed file, this eagerly copies the entire chain and creates one _Entry object per 128 bytes; a near-200 MB file can therefore produce roughly 1.5 million objects in addition to multiple copies of the input and exhaust the ingestion worker. Apply a conservative directory-entry/byte limit while reading the chain rather than materializing every entry first.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
The directory chain is loop checked and bounded by the file size, so a crafted file costs a small multiple of its size. The real amplification here was the FAT built from repeated DIFAT entries, which 13fd53d now bounds to the file size.
| elif inst == 0 and slides and child == _PPT_TEXT_HEADER: | ||
| slides[-1][2].append("") | ||
| elif inst == 0 and slides and child in (_PPT_TEXT_CHARS, _PPT_TEXT_BYTES): | ||
| if not slides[-1][2]: | ||
| slides[-1][2].append("") | ||
| slides[-1][2][-1] = _ppt_text(data, child, child_body, child_stop) |
There was a problem hiding this comment.
Retain text from the notes SlideListWithText instance
For ordinary binary presentations whose speaker-note text is stored in the instance-2 SlideListWithText payload rather than duplicated in drawing records inside the Notes container, the notes remain absent from extraction. Fresh evidence after the attempted fix is that these branches still collect TextHeaderAtom and text atoms only when inst == 0, while instance 2 saves only the persist reference and later passes an empty placeholder list to _ppt_sheet_lines; collect the instance-2 text alongside each notes reference and supply it when rendering that note.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Per MS-PPT 2.4.14.6 the notes list (instance 2) holds only NotesPersistAtom records; PowerPoint stores note text in each NotesContainer's drawing, which is what this reads.
| notes = next( | ||
| (t for t in slide_rels.values() if "notesslide" in t.lower() and zf.has(t)), | ||
| None, |
There was a problem hiding this comment.
Resolve notes slides by relationship type
For a conforming .pptx whose notes part has a noncanonical name such as ppt/notes/n1.xml, this filename check misses the part even though the slide relationship identifies it as a notesSlide, so all speaker notes on that slide disappear. Preserve relationship types when resolving slide relationships and select the target whose type ends in /notesSlide rather than requiring notesslide in the member path.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
PowerPoint and the other common writers name notes parts notesSlides/notesSlideN.xml; a renamed notes part is not something a real producer writes.
| headers = { | ||
| label: (_msg_prop(cf, (), prop, codec) or "").strip() for prop, label in _MSG_HEADERS | ||
| } |
There was a problem hiding this comment.
Read SMTP addresses from MSG recipient storages
For an Exchange-generated .msg, PidTagDisplayTo and PidTagDisplayCc commonly contain only recipient display names, while the searchable SMTP addresses live in __recip_version1.0_#... storages under PidTagSmtpAddress (39FE). Building To/Cc exclusively from these top-level display properties means searches for recipient addresses such as [email protected] fail; enumerate recipient storages, classify them with PidTagRecipientType, and include their SMTP addresses in the corresponding headers.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
To and Cc come from PidTagDisplayTo and PidTagDisplayCc, which MS-OXOMSG defines as the recipients' display names, matching what Outlook shows; indexing recipient SMTP addresses is an enhancement, not lost text.
…es, MHTML and XHTML in chat with files
…he compound file FAT to the file size
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 13fd53d8b4
ℹ️ 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".
| if not code: | ||
| if format_id in _BUILTIN_DURATION_FORMATS: | ||
| return "duration" | ||
| return "date" if format_id in _BUILTIN_DATE_FORMATS else None |
There was a problem hiding this comment.
Distinguish time-only formats from calendar dates
Fresh evidence after the earlier time-format fix is that built-in time-only IDs are still returned as date, leaving _serial_text to guess from whether the value is below 1. For example, serial 1.5 with built-in format 18 (h:mm AM/PM) is displayed by Excel as 12:00 PM, but this indexes it as 1900-01-01 12:00:00; retain a separate time-only kind and render the fractional day regardless of the integer portion.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
This matches openpyxl, which the reader follows on purpose: a time format on a value of 1 or more reads back as a datetime, so the time is still indexed and nothing is lost.
| if pieces is None: | ||
| raise ValueError("Word document has no piece table") |
There was a problem hiding this comment.
Handle non-complex Word documents without a piece table
Valid Word 97–2003 documents with fComplex clear do not have a Pcdt piece table; their text is represented by the implicit contiguous piece beginning at fcMin. Such a file always reaches this exception and cannot be indexed, so synthesize the simple piece from the FIB fields instead of requiring pieces for every .doc.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
MS-DOC 2.4.1 Retrieving Text reads text through FibRgFcLcb97.fcClx, whose Clx contains a Pcdt, for every Word 97-2003 file; fComplex only marks an incremental save, so a valid .doc always has a piece table.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d56d4d7ef5
ℹ️ 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".
| seconds = round(serial * 86_400) | ||
| hours, rest = divmod(abs(seconds), 3600) | ||
| return f"{'-' if seconds < 0 else ''}{hours}:{rest // 60:02}:{rest % 60:02}" |
There was a problem hiding this comment.
Preserve fractional seconds in duration cells
When an .xlsx or .xls cell uses a duration format with fractional seconds, such as [h]:mm:ss.000, this rounds the serial to whole seconds before rendering it. A displayed value such as 0:00:00.500 is therefore indexed as 0:00:00, losing searchable value information and even becoming indistinguishable from zero; retain the precision requested by the format code when formatting durations.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Durations are rendered to whole seconds on purpose; sub-second duration formats are rare in documents people chat with, and the value stays searchable.
…ings to the repeat budget
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ff27034f5e
ℹ️ 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".
| def _ppt_text(data: bytes, kind: int, start: int, end: int) -> str: | ||
| text = data[start:end].decode("utf-16-le" if kind == _PPT_TEXT_CHARS else "latin-1", "replace") | ||
| return _clean_control(text.replace("\r", "\n").replace("\x0b", "\n")).strip() |
There was a problem hiding this comment.
Decode PowerPoint byte text with its ANSI code page
When a binary .ppt uses a TextBytesAtom for non-ASCII text, Latin-1 is not the encoding of those ANSI bytes. For example, a Western presentation's byte 0x92 should become a curly apostrophe but is indexed here as the C1 control U+0092, and presentations using other Windows code pages are corrupted more broadly; decode byte atoms using the presentation/font charset with an appropriate Windows fallback, including in the fallback scanner that repeats this conversion.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
MS-PPT 2.9.43 defines each TextBytesAtom byte as the low byte of a UTF-16 character whose high byte is 0x00, which is Latin-1; text outside that range is stored as TextCharsAtom.
| if word == "ansicpg" and arg: | ||
| document_codepage = _rtf_codec(f"cp{arg}") or "cp1252" | ||
| codepage = fonts.get(default_font, document_codepage) |
There was a problem hiding this comment.
Honor legacy RTF character-set declarations
When an RTF declares \mac, \pc, or \pca without an explicit \ansicpgN, the parser leaves document_codepage at CP1252 and corrupts literal and hex-escaped text. For example, \mac \'8e represents é in Mac Roman but is currently returned as Ž; update the document code page when these standard character-set controls are encountered.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Word, TextEdit and other current writers always emit \ansicpgN; \mac, \pc and \pca without it only come from very old tools, so this stays out of scope.
| chars.append(word[offset : offset + hi - lo].decode("cp1252", "replace")) | ||
| else: | ||
| offset = fc + 2 * (lo - start) | ||
| chars.append(word[offset : offset + 2 * (hi - lo)].decode("utf-16-le", "replace")) |
There was a problem hiding this comment.
Suppress tracked deletions in binary Word text
When a .doc retains tracked changes, deleted characters remain in the piece-table text and are marked through character formatting such as sprmCFRMarkDel. This loop unconditionally decodes every piece, while _word_text handles only fields and control characters, so removed or sensitive text enters the index unlike tracked deletions in the other new readers; consult the CHPX runs and omit deletion-marked spans.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Reading CHPX runs for revision marks is a separate piece of work; visible text is never lost, and this is listed under known limitations in the description.
| manifest = "META-INF/manifest.xml" | ||
| if zf.has(manifest) and b"encryption-data" in zf.read(manifest): | ||
| raise ValueError("file is password protected") |
There was a problem hiding this comment.
Detect actual ODF encryption elements
When an unencrypted OpenDocument package has any manifest text containing encryption-data, this substring check rejects it as password protected even if no encryption element exists. For example, a legitimate embedded file named Pictures/encryption-data.png appears in manifest:full-path and makes the whole .odt, .ods, or .odp unreadable; parse the manifest and test specifically for a manifest:encryption-data element.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Only a package with a file literally named encryption-data trips this, which no real document contains.
| if b"purl.oclc.org/ooxml/" in data: | ||
| for strict, transitional in _STRICT_NS: | ||
| data = data.replace(strict, transitional) |
There was a problem hiding this comment.
Normalize Strict OOXML namespaces after decoding XML
When a Strict OOXML part is encoded as UTF-16, its raw bytes do not contain the ASCII purl.oclc.org/ooxml/ sequence, so this namespace replacement never runs. ElementTree then produces Strict namespace tags while all subsequent _q(...) lookups use transitional namespaces, causing valid Strict .xlsx workbooks to lose their sheets and Strict .pptx files to lose their slides; normalize parsed tag namespaces independently of the part's XML encoding.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Office and LibreOffice write OOXML parts as UTF-8; a Strict package with UTF-16 parts is not something a real producer writes.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d5c417a8f4
ℹ️ 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".
| for axes, store in ((("cat", "xVal"), categories), (("val", "yVal"), points)): | ||
| for axis in axes: | ||
| for point in series.iterfind(f"{_q('c', axis)}//{_q('c', 'pt')}"): | ||
| v = point.find(_q("c", "v")) | ||
| store[int(point.get("idx", "0") or 0)] = v.text or "" if v is not None else "" |
There was a problem hiding this comment.
Keep category caches separate for each chart series
When a multi-series scatter, bubble, or category chart gives each series a different X/category cache, every iteration writes into the same categories dictionary, so later series overwrite earlier coordinates while each Y/value cache remains separate. The extracted rows consequently pair earlier series' values with the final series' coordinates, indexing data relationships that do not exist; retain category points per series or emit each series' coordinate/value pairs independently.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in ccfac06: when series carry different X or category caches, each series is written as its own block of x | y rows; charts that share one category cache keep the table layout.
| if not body and cf.exists("__substg1.0_10130102"): | ||
| body = html_text(cf.open("__substg1.0_10130102")) | ||
| if not body and (html := _msg_prop(cf, (), "1013", codec)): | ||
| body = html_text(codecs.BOM_UTF8 + html.encode("utf-8")) | ||
| if not body and cf.exists("__substg1.0_10090102"): |
There was a problem hiding this comment.
Treat whitespace-only MSG bodies as empty
When PidTagBody contains only spaces or line breaks but the MSG has a populated HTML or compressed-RTF body, the nonempty Python string prevents every fallback here; the final .strip() then removes it and the message is indexed without its body. Test body.strip() before choosing the plain body so these valid HTML/RTF messages use their rendered content.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in ccfac06: a whitespace-only plain body now falls through to the HTML and RTF bodies.
| if value < 0 and len(sections) > 1 and sections[1]: | ||
| return _format_section(-value, sections[1]) | ||
| if value == 0 and len(sections) > 2 and sections[2]: | ||
| return _format_section(0.0, sections[2]) |
There was a problem hiding this comment.
Respect empty numeric format sections
When an Excel custom format deliberately leaves its negative or zero section empty, such as 0;-0;, the truthiness checks skip that selected section and fall back to the positive section, so a zero that Excel displays as blank is indexed as 0 (and an empty negative section exposes the negative value). Select sections based on their presence in the format rather than whether their token list is nonempty, returning an empty string for an explicitly empty section.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
An explicitly empty section only changes whether a zero or negative cell shows as blank; indexing the stored number loses nothing searchable.
| col = _column_index(c.get("r", "")) if c.get("r") else len(cells) | ||
| if col < 0 or col >= _MAX_COLUMNS: | ||
| continue |
There was a problem hiding this comment.
Preserve XLSX cells beyond column 1024
When a valid modern Excel worksheet contains data in column 1025 or later, this check silently drops those cells even though XLSX supports up to 16,384 columns. Any experiment or dataset using the rightmost portion of a sheet is therefore indexed with entire fields missing; use the XLSX column limit here rather than the shared 1,024-column cap.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
The 1024 column cap bounds the padding a sparse row can add; sheets wider than that are rare in documents people chat with, and this is listed under known limitations in the description.
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! 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 security review |
* Studio: move chat with files into a panel above the composer Chat with files now has its own card stacked above the composer, with a header (title, Project / This chat scope, Add files, paging arrows, close) over a strip of the chat's documents drawn as composer attachment cards. - Files reach the index only through the panel: its Add files button and drops on the panel. Composer attachments stay with the message. - The panel picker reuses the composer's file chooser via openFilePicker. - On a new chat the greeting, panel and composer center as one block. - Light mode draws a border, dark mode keeps the composer shadow. - Knowledge base chats and inherited project sources use the same panel. * Studio: more bottom padding on the chat with files panel * Studio: keep panel drops while busy and open previews on the project page - A drop on the chat with files panel during an upload is refused with a toast instead of falling through to the message attachments. - The project landing composer mounts the document preview, so its file cards open. * Studio: read Office, OpenDocument, e-book, email, RTF and web page files in chat with files (#13081) * Studio: read Office, OpenDocument, e-book, email and RTF files in chat with files Adds parsers for .doc .xls .xlsx .xlsm .ppt .pptx .msg .eml .rtf .odt .ods .odp .epub using only the standard library, and lets the chat with files panel pick and drop them along with .csv .tsv .json .xml. * Studio: address review on Office, ODF, e-book, email and RTF parsing - RTF: ignore negative \bin lengths, and decode literal 8-bit text in the document code page. - ODF: skip tracked deletions, keep bookmark references, read nested tables once, and cap text added by repeated cells and rows. - EPUB: resolve URI-escaped manifest paths. - OOXML: read Strict namespaces. - PPTX: drop only the notes slide number placeholder, not numeric notes. - XLS: format date cells from FORMAT, XF and DATEMODE records. - DOC: include footnotes, endnotes and text boxes. - MSG: decode String8 properties with the message code page, and fall back to the compressed RTF body. - Desktop: route dropped .doc .xls .xlsx .xlsm .ppt .pptx .msg files to chat with files. * Studio: harden RTF, compressed RTF, ODS and Excel date parsing - RTF: pair UTF-16 surrogates from \uN so astral characters survive, and skip text marked \deleted. - MSG: stop decoding compressed RTF at its declared size and refuse oversized bodies. - ODS: read typed cell values written without a text paragraph. - XLS and XLSX: treat the CJK and Thai built-in date formats as dates. * Studio: read .ppt slides from the latest save, with text boxes and notes Incremental saves keep old record versions in the stream, so slides from earlier saves were indexed too. The reader now follows the Current User edit chain and its persist directories to the live document, reads each slide's shapes in order (placeholders through OutlineTextRefAtom, plus text boxes), and appends speaker notes matched by slide id. A broken edit link continues with the next older edit; files without an edit chain keep the old scan. * Studio: format Excel times and errors, and read RTF font charsets - XLSX and XLS: time-of-day and [h] duration formats keep their own text, and serials before March 1900 account for Excel's 29 February 1900, as openpyxl does. - XLS: error cells and cached formula errors read as #DIV/0!, #N/A and so on, and long formula strings continue into CONTINUE records. - RTF: bytes decode with the active font's charset or code page, and groups nested past 1000 levels are refused. - MSG: Exchange senders get their SMTP address. - EML: an empty plain part falls back to the HTML part. * Read charts, number formats and package rels; bound XML parsing - Find the main OOXML part through _rels/.rels, and sharedStrings and styles through the workbook rels. - Stream sheet rows and shared strings with per-element, per-row and depth caps so large or crafted parts cannot exhaust memory. - Show Excel numbers with their display format (percent, grouping, scientific, literals, currency, sections). - Add pptx chart titles and cached series data. - Keep internal empty ODF cells, drop only trailing ones; stream .ods rows. - Prefer the Unicode branch of RTF \upr groups. - Join every inline body part of mixed emails. * Read Office macro, template and slideshow files, OpenDocument templates, MHTML and XHTML in chat with files * Decode Excel 5.0/95 byte strings with the workbook code page; bound the compound file FAT to the file size * Refuse EPUBs with DRM encrypted chapters; leave oversized number formats as stored * Skip the upload and index test where sqlite-vec cannot load * Trim comments * Read SmartArt labels and string HTML bodies; charge reused shared strings to the repeat budget * Read scatter chart caches; bound .doc text to the stream size * Keep each scatter series' X values; fall back from a blank .msg plain body * Studio: name the compound file stream reader read, not open * Studio: let projects and knowledge bases take Office, OpenDocument, e-book and email files * Studio: chat with files panel takes desktop drops, groups linked folders and shows a file count * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Studio: draw the light chat with files panel edge as a crisp hairline * Studio: file thumbnails and the attachment viewer for chat with files cards, info tooltip, flat panel edge * Studio: open large sources on click and read EPUB package paths as URLs * Studio: cap legacy spreadsheet cells and cache compound file directory lookups * Studio: file count pill, title tooltip, and the viewer size limit for source cards * Cap card thumbnails by bytes and release them off screen * Open the files panel tooltip only on resting over its title * Decode files panel text previews like composer attachments * Show the files panel count always, with the description on its hover, and strengthen the light edge * Decode Mac and PC RTF character sets, and keep every level of chart categories * Stream OpenDocument spreadsheet templates like spreadsheets * Trim comments * Keep the note in the folder-name catch --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
…er, queued drops and retry for failed sources (#13224) * Studio: move chat with files into a panel above the composer Chat with files now has its own card stacked above the composer, with a header (title, Project / This chat scope, Add files, paging arrows, close) over a strip of the chat's documents drawn as composer attachment cards. - Files reach the index only through the panel: its Add files button and drops on the panel. Composer attachments stay with the message. - The panel picker reuses the composer's file chooser via openFilePicker. - On a new chat the greeting, panel and composer center as one block. - Light mode draws a border, dark mode keeps the composer shadow. - Knowledge base chats and inherited project sources use the same panel. * Studio: more bottom padding on the chat with files panel * Studio: keep panel drops while busy and open previews on the project page - A drop on the chat with files panel during an upload is refused with a toast instead of falling through to the message attachments. - The project landing composer mounts the document preview, so its file cards open. * Studio: read Office, OpenDocument, e-book, email, RTF and web page files in chat with files (#13081) * Studio: read Office, OpenDocument, e-book, email and RTF files in chat with files Adds parsers for .doc .xls .xlsx .xlsm .ppt .pptx .msg .eml .rtf .odt .ods .odp .epub using only the standard library, and lets the chat with files panel pick and drop them along with .csv .tsv .json .xml. * Studio: address review on Office, ODF, e-book, email and RTF parsing - RTF: ignore negative \bin lengths, and decode literal 8-bit text in the document code page. - ODF: skip tracked deletions, keep bookmark references, read nested tables once, and cap text added by repeated cells and rows. - EPUB: resolve URI-escaped manifest paths. - OOXML: read Strict namespaces. - PPTX: drop only the notes slide number placeholder, not numeric notes. - XLS: format date cells from FORMAT, XF and DATEMODE records. - DOC: include footnotes, endnotes and text boxes. - MSG: decode String8 properties with the message code page, and fall back to the compressed RTF body. - Desktop: route dropped .doc .xls .xlsx .xlsm .ppt .pptx .msg files to chat with files. * Studio: harden RTF, compressed RTF, ODS and Excel date parsing - RTF: pair UTF-16 surrogates from \uN so astral characters survive, and skip text marked \deleted. - MSG: stop decoding compressed RTF at its declared size and refuse oversized bodies. - ODS: read typed cell values written without a text paragraph. - XLS and XLSX: treat the CJK and Thai built-in date formats as dates. * Studio: read .ppt slides from the latest save, with text boxes and notes Incremental saves keep old record versions in the stream, so slides from earlier saves were indexed too. The reader now follows the Current User edit chain and its persist directories to the live document, reads each slide's shapes in order (placeholders through OutlineTextRefAtom, plus text boxes), and appends speaker notes matched by slide id. A broken edit link continues with the next older edit; files without an edit chain keep the old scan. * Studio: format Excel times and errors, and read RTF font charsets - XLSX and XLS: time-of-day and [h] duration formats keep their own text, and serials before March 1900 account for Excel's 29 February 1900, as openpyxl does. - XLS: error cells and cached formula errors read as #DIV/0!, #N/A and so on, and long formula strings continue into CONTINUE records. - RTF: bytes decode with the active font's charset or code page, and groups nested past 1000 levels are refused. - MSG: Exchange senders get their SMTP address. - EML: an empty plain part falls back to the HTML part. * Read charts, number formats and package rels; bound XML parsing - Find the main OOXML part through _rels/.rels, and sharedStrings and styles through the workbook rels. - Stream sheet rows and shared strings with per-element, per-row and depth caps so large or crafted parts cannot exhaust memory. - Show Excel numbers with their display format (percent, grouping, scientific, literals, currency, sections). - Add pptx chart titles and cached series data. - Keep internal empty ODF cells, drop only trailing ones; stream .ods rows. - Prefer the Unicode branch of RTF \upr groups. - Join every inline body part of mixed emails. * Read Office macro, template and slideshow files, OpenDocument templates, MHTML and XHTML in chat with files * Decode Excel 5.0/95 byte strings with the workbook code page; bound the compound file FAT to the file size * Refuse EPUBs with DRM encrypted chapters; leave oversized number formats as stored * Skip the upload and index test where sqlite-vec cannot load * Trim comments * Read SmartArt labels and string HTML bodies; charge reused shared strings to the repeat budget * Read scatter chart caches; bound .doc text to the stream size * Keep each scatter series' X values; fall back from a blank .msg plain body * Studio: name the compound file stream reader read, not open * Studio: let projects and knowledge bases take Office, OpenDocument, e-book and email files * Studio: chat with files panel takes desktop drops, groups linked folders and shows a file count * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Studio: draw the light chat with files panel edge as a crisp hairline * Studio: file thumbnails and the attachment viewer for chat with files cards, info tooltip, flat panel edge * Studio: linked folders honour .gitignore, skip build output and data dumps, keep syncing past the file cap, and report every failed file * Studio: open large sources on click and read EPUB package paths as URLs * Studio: linked folders skip empty files and report renames * Studio: folder uploads in the browser, queued drops, retry for failed sources, grouped linked folders and quieter folder syncs * Studio: cap legacy spreadsheet cells and cache compound file directory lookups * Studio: file count pill, title tooltip, and the viewer size limit for source cards * Studio: key the upload queue by chat, cap folders after filtering, keep Retry when a delete fails, and skip malformed gitignore rules * Keep dropped folders with their destination, stop walks at the cap, fail closed on unreadable .gitignore * Match .gitignore globs without exponential backtracking * Cap card thumbnails by bytes and release them off screen * Open the files panel tooltip only on resting over its title * Decode files panel text previews like composer attachments * Drop a UTF-8 BOM before reading .gitignore rules * Show the files panel count always, with the description on its hover, and strengthen the light edge * Decode Mac and PC RTF character sets, and keep every level of chart categories * Stream OpenDocument spreadsheet templates like spreadsheets * Keep a retryable failed row when a refresh sees the failure first * Type the lifecycle harness's refresh * Skip pnpm-lock.yml in browser folder uploads as the scan does * Trim comments * Trim comments * Keep the note in the folder-name catch * Lighten the chat with files border in light mode * Lighten the chat with files border to 10% in light mode * Move the light-mode border change to its own PR * Expect a failed upload or index to stay as a failed row in the upload browser cases * Trim comments in the linked-folder and source upload changes * Drop restating comments in the source upload changes * Re-measure the Studio startup budget for the project sources follow-ups * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Daniel Han <[email protected]>
Builds on #13078 (the chat with files panel), so it targets that branch. Once #13078 merges this can be retargeted to
main.What this does
Chat with files now indexes all of these:
.pdf .doc .docx .xls .xlsx .xlsm .ppt .pptx .txt .md .html .csv .tsv .eml .msg .json .xml .rtf .odt .ods .odp .epubplus the variants people also send around:
.docm .dotx .dotm .xltx .xltm .pptm .potx .potm .ppsx .ppsm .ott .ots .otp .mht .mhtml .xhtml .xhtThe new readers live in
core/rag/office_formats.pyand only use the standard library, so there are no new dependencies..xlsx.xlsma | b | c), headedSheet: name. Numbers keep their display format (25%,1,234.50,(1,234.50),1.23E+04, currency and literal text). Date cells come out as dates (including the CJK and Thai built-in formats), times and[h]durations as times, matching openpyxl. The workbook is found through the package relationships, and Strict OOXML files work too..docm.dotx.dotm.docx. python-docx'sDocument()refuses the macro and template main parts, so they are opened throughPackage.open()with those content types registered toDocumentPart; any other package under a Word extension is still refused..xltx.xltm.pptm.potx.potm.ppsx.ppsm.xlsxand.pptx(the package layout is identical)..ott.ots.otp.odt.ods.odp..mht.mhtml.emlreader: the page text is indexed and embedded resources are skipped..xhtml.xht.html..xlsCONTINUErecords, date and time cells, and error values such as#N/A. Excel 5.0/95Bookstreams (still offered in Excel's Save As) decode their byte strings with the workbookCODEPAGE..pptx.ppt.pptx), scatter and bubble chart values, and speaker notes. Master text and the notes slide number are skipped..pptfollows the edit history to the latest save, so slides left over from earlier saves are not indexed..doc.odt.ods.odpcontent.xml. Typed cell values without a text paragraph are read, empty cells between values are kept while trailing ones are dropped, and tracked deletions are skipped..epub.eml.msg.msgANSI properties use the message code page, and Exchange senders get their SMTP address..rtf\uprgroups preferred. Tracked deletions, font tables, field instructions and other destinations are dropped..csv .tsv .json .xmlwere already parsed by the backend, so they only needed adding to the panel picker..doc .xls .ppt .msgshare the OLE compound file container, so there is a small reader for it incore/rag/cfb.py. It matches olefile on real files, and also opens the.docfiles macOStextutilwrites (their FAT is shorter than the file).Safety
could not read X: file is damagedinstead of a stack trace..odsrows are streamed, with each row capped at 200k elements and nesting at 512 levels. A 100k row sheet peaks at about 125 MB instead of 770 MB..xlsxand.xlsshared strings, can add at most 32M characters.\binlength is ignored instead of rewinding the parser..msgstop at their declared size, and bodies over 128 MB are refused..doctext is bounded by the size of itsWordDocumentstream, so a piece table that repeats one range is refused.Frontend
DOCUMENT_UPLOAD_EXTSinconfig.pyis mirrored byRAG_DOCUMENT_UPLOAD_ACCEPTinrag.ts, and a test keeps the two in sync.CHAT_FILES_ACCEPT.RAG_UPLOAD_ACCEPTis unchanged, so the project and knowledge base pickers behave as before. The backend does accept the new types there now, and linked folders will index them..doc .xls .xlsx .xlsm .xltx .xltm .ppt .pptx .pptm .ppsx .ott .ots .otp .msg .mht .mhtml .xhtml .xhton the window now indexes them in chat with files (OFFICE_ATTACHMENT_EXTSinnative_path_policy.rs, kept equal toOFFICE_DOC_EXTSby a test). Types the composer already handles (.odt .ods .odp .rtf .epub .eml, and the tool-only.docm .dotx .dotm .potx .potm .ppsm) still drop into the composer.Testing
tests/test_rag_office_formats.pybuilds fixtures for every new type, checks each parser, the failure cases, and runs upload, ingestion and lexical search for all 30 new extensions.tests/_compound_file.pywrites the compound file fixtures.textutil, plus a 3,000 row.xlsand a 4,000 paragraph.docwith Greek and Japanese text..xlsxdates, times and durations checked against openpyxl,.xlsdates and error values against xlrd, and the compressed RTF decoder againstcompressed_rtfround trips..pptchecked against 22 sample files from Apache POI's test data: slide counts, slide order, text boxes and notes match POI's own test expectations..mhtmland.xhtmlwere also checked with files derived from real python-docx, openpyxl, python-pptx and odfpy output.npm run typecheck,npm test(11019 pass),npm run build,cargo checkand thenative_path_policyRust tests pass. Alltest_rag*.pybackend tests pass.Known limitations
.docfiles are still indexed (the.docx,.odtand.rtfreaders skip them).