Skip to content

Studio: read Office, OpenDocument, e-book, email, RTF and web page files in chat with files - #13081

Merged
shimmyshimmer merged 15 commits into
studio-chat-with-files-panelfrom
studio-chat-with-files-formats
Oct 10, 2026
Merged

shimmyshimmer merged 15 commits into
studio-chat-with-files-panelfrom
studio-chat-with-files-formats

Conversation

@shimmyshimmer

@shimmyshimmer shimmyshimmer commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

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 .epub

plus the variants people also send around:

.docm .dotx .dotm .xltx .xltm .pptm .potx .potm .ppsx .ppsm .ott .ots .otp .mht .mhtml .xhtml .xht

The new readers live in core/rag/office_formats.py and only use the standard library, so there are no new dependencies.

Format What gets indexed
.xlsx .xlsm Each sheet as rows (a | b | c), headed Sheet: 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 Same as .docx. python-docx's Document() refuses the macro and template main parts, so they are opened through Package.open() with those content types registered to DocumentPart; any other package under a Word extension is still refused.
.xltx .xltm .pptm .potx .potm .ppsx .ppsm Same readers as .xlsx and .pptx (the package layout is identical).
.ott .ots .otp Same reader as .odt .ods .odp.
.mht .mhtml Single file web pages saved by Chrome, Edge or Word are MIME messages, so they go through the .eml reader: the page text is indexed and embedded resources are skipped.
.xhtml .xht Same text extraction as .html.
.xls Same, from BIFF8 records with the same number formats, including strings split across CONTINUE records, date and time cells, and error values such as #N/A. Excel 5.0/95 Book streams (still offered in Excel's Save As) decode their byte strings with the workbook CODEPAGE.
.pptx .ppt One page per slide, with tables, text boxes, chart titles and data, SmartArt labels (.pptx), scatter and bubble chart values, and speaker notes. Master text and the notes slide number are skipped. .ppt follows the edit history to the latest save, so slides left over from earlier saves are not indexed.
.doc Body text, text boxes, footnotes and endnotes from the piece table (8-bit and UTF-16 pieces). Field codes are dropped and table cells become rows.
.odt .ods .odp Text, sheets and slides from content.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 Chapters in spine order, including URI-escaped paths. The navigation page is skipped.
.eml .msg From, To, Cc, Date and Subject headers, every inline body part (HTML bodies, binary or string, and compressed RTF bodies are converted to text) and attachment names. .msg ANSI properties use the message code page, and Exchange senders get their SMTP address.
.rtf Body text, decoded with the active font's charset or the document code page, with emoji kept and the Unicode side of \upr groups preferred. Tracked deletions, font tables, field instructions and other destinations are dropped.

.csv .tsv .json .xml were already parsed by the backend, so they only needed adding to the panel picker.

.doc .xls .ppt .msg share the OLE compound file container, so there is a small reader for it in core/rag/cfb.py. It matches olefile on real files, and also opens the .doc files macOS textutil writes (their FAT is shorter than the file).

Safety

  • Encrypted or password protected files, and EPUBs whose chapters are DRM encrypted, fail with a clear error.
  • Damaged files fail with could not read X: file is damaged instead of a stack trace.
  • XML with entity declarations is refused.
  • Archive members are capped at 128 MB each and 512 MB in total.
  • XML parts are capped at 2M elements. Sheet rows, shared strings and .ods rows 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.
  • Repeated OpenDocument cells and rows, and reused .xlsx and .xls shared strings, can add at most 32M characters.
  • A negative RTF \bin length is ignored instead of rewinding the parser.
  • Compressed RTF bodies in .msg stop at their declared size, and bodies over 128 MB are refused.
  • RTF groups nested past 1000 levels are refused.
  • Number format codes over 1024 characters are ignored, so the cell keeps its stored number.
  • .doc text is bounded by the size of its WordDocument stream, so a piece table that repeats one range is refused.
  • The compound file FAT is bounded by the file size. Before, a DIFAT that names one FAT sector over and over turned a 0.2 MB file into a 2 GB FAT table.

Frontend

  • DOCUMENT_UPLOAD_EXTS in config.py is mirrored by RAG_DOCUMENT_UPLOAD_ACCEPT in rag.ts, and a test keeps the two in sync.
  • The panel's picker and drop target use the new CHAT_FILES_ACCEPT.
  • The skipped file toast now says what is supported.
  • RAG_UPLOAD_ACCEPT is 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.
  • Desktop: dropping .doc .xls .xlsx .xlsm .xltx .xltm .ppt .pptx .pptm .ppsx .ott .ots .otp .msg .mht .mhtml .xhtml .xht on the window now indexes them in chat with files (OFFICE_ATTACHMENT_EXTS in native_path_policy.rs, kept equal to OFFICE_DOC_EXTS by 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.py builds 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.py writes the compound file fixtures.
  • Checked against real files from openpyxl, xlwt, python-pptx, odfpy, ebooklib and macOS textutil, plus a 3,000 row .xls and a 4,000 paragraph .doc with Greek and Japanese text.
  • Dropped one file of each type onto the panel in a local Studio: every file indexed and is searchable.
  • .xlsx dates, times and durations checked against openpyxl, .xls dates and error values against xlrd, and the compressed RTF decoder against compressed_rtf round trips.
  • .ppt checked against 22 sample files from Apache POI's test data: slide counts, slide order, text boxes and notes match POI's own test expectations.
  • The Office variants, OpenDocument templates, .mhtml and .xhtml were 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 check and the native_path_policy Rust tests pass. All test_rag*.py backend tests pass.

Known limitations

  • Formula cells without a cached value come out empty.
  • Spreadsheet columns past 1,024 are not indexed; the cap bounds the padding a sparse row can add.
  • Tracked deletions in .doc files are still indexed (the .docx, .odt and .rtf readers skip them).
  • Non PDF files still have no inline preview.

@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

This comment has been minimized.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@shimmyshimmer
shimmyshimmer force-pushed the studio-chat-with-files-formats branch from 1aedb3e to c4b71ce Compare October 8, 2026 16:11
…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.
@shimmyshimmer
shimmyshimmer force-pushed the studio-chat-with-files-formats branch from c4b71ce to 191de6e Compare October 8, 2026 16:11
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

chatgpt-codex-connector[bot]

This comment was marked as resolved.

- 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.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

chatgpt-codex-connector[bot]

This comment was marked as resolved.

- 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.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

chatgpt-codex-connector[bot]

This comment was marked as resolved.

- 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.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +69 to +72
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)
]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +1558 to +1563
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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +605 to +607
notes = next(
(t for t in slide_rels.values() if "notesslide" in t.lower() and zf.has(t)),
None,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PowerPoint and the other common writers name notes parts notesSlides/notesSlideN.xml; a renamed notes part is not something a real producer writes.

Comment on lines +1758 to +1760
headers = {
label: (_msg_prop(cf, (), prop, codec) or "").strip() for prop, label in _MSG_HEADERS
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +1156 to +1157
if pieces is None:
raise ValueError("Word document has no piece table")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 10, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 10, 2026
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

shimmyshimmer pushed a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Oct 10, 2026
@shimmyshimmer shimmyshimmer changed the title Studio: read Office, OpenDocument, e-book, email and RTF files in chat with files Studio: read Office, OpenDocument, e-book, email, RTF and web page files in chat with files Oct 10, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +241 to +243
seconds = round(serial * 86_400)
hours, rest = divmod(abs(seconds), 3600)
return f"{'-' if seconds < 0 else ''}{hours}:{rest // 60:02}:{rest % 60:02}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Durations are rendered to whole seconds on purpose; sub-second duration formats are rare in documents people chat with, and the value stays searchable.

@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +1470 to +1472
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()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +1058 to +1060
if word == "ansicpg" and arg:
document_codepage = _rtf_codec(f"cp{arg}") or "cp1252"
codepage = fonts.get(default_font, document_codepage)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +1171 to +1174
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"))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +783 to +785
manifest = "META-INF/manifest.xml"
if zf.has(manifest) and b"encryption-data" in zf.read(manifest):
raise ValueError("file is password protected")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only a package with a file literally named encryption-data trips this, which no real document contains.

Comment on lines +124 to +126
if b"purl.oclc.org/ooxml/" in data:
for strict, transitional in _STRICT_NS:
data = data.replace(strict, transitional)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Office and LibreOffice write OOXML parts as UTF-8; a Strict package with UTF-16 parts is not something a real producer writes.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 10, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 10, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 10, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 10, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 10, 2026
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +563 to +567
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 ""

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +1796 to +1800
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"):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in ccfac06: a whitespace-only plain body now falls through to the HTML and RTF bodies.

Comment on lines +383 to +386
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])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An explicitly empty section only changes whether a zero or negative cell shows as blank; indexing the stored number loses nothing searchable.

Comment on lines +472 to +474
col = _column_index(c.get("r", "")) if c.get("r") else len(cells)
if col < 0 or col >= _MAX_COLUMNS:
continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: ccfac0666a

ℹ️ 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".

@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex security review

@shimmyshimmer
shimmyshimmer merged commit cf51ef2 into studio-chat-with-files-panel Oct 10, 2026
@shimmyshimmer
shimmyshimmer deleted the studio-chat-with-files-formats branch October 10, 2026 03:10
shimmyshimmer added a commit that referenced this pull request Oct 11, 2026
* 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>
danielhanchen added a commit that referenced this pull request Oct 12, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant