Repository navigation
Studio: move chat with files into a panel above the composer - #13078
Conversation
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.
|
@codex security review |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…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.
|
Codex Review: Didn't find any major issues. 👍 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". |
…les 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
…-book and email files
…ers and shows a file count
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8b177516a9
ℹ️ 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".
| path = target.lstrip("/") if target.startswith("/") else posixpath.join(folder, target) | ||
| out.append((rel.get("Id", ""), rel.get("Type", ""), posixpath.normpath(path))) |
There was a problem hiding this comment.
Decode escaped OOXML relationship targets
When a valid OOXML relationship points to a part whose name requires URI escaping, such as Target="worksheets/My%20Sheet.xml" for the ZIP member xl/worksheets/My Sheet.xml, this path is looked up with the literal %20. _Archive.has() therefore misses the member, causing XLSX sheets and PPTX slides, charts, or notes at escaped targets to be silently omitted. Percent-decode internal relationship targets before normalizing and looking them up.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
ZIP item names in a conformant package keep the percent-encoding (ECMA-376-2 7.3.3), so the target is looked up as written, the same as python-docx, python-pptx and openpyxl. Excel names sheet parts sheetN.xml regardless of the sheet name.
| 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 valid PPTX whose notes-slide part uses a custom target name such as ../notes/note1.xml, the relationship still identifies itself with the notesSlide relationship type, but this filename-substring check does not recognize it. The slide body is indexed while all of its speaker notes are silently omitted. Use the relationship type retained by relationships() rather than requiring the target path to contain notesslide.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
PowerPoint, LibreOffice and python-pptx all write notes as ppt/notesSlides/notesSlideN.xml, and no other slide relationship target contains that name, so the match neither misses nor misfires on real files.
|
@codex security review |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ 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". |
… cards, info tooltip, flat panel edge
|
@codex security review |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ 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". |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d09ebaa2cc
ℹ️ 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".
| raise ValueError("document repeats too much content") | ||
| if fc & 0x40000000: | ||
| offset = (fc & 0x3FFFFFFF) // 2 + (lo - start) | ||
| chars.append(word[offset : offset + hi - lo].decode("cp1252", "replace")) |
There was a problem hiding this comment.
Decode compressed Word pieces using their declared code page
For legacy .doc files whose compressed text uses a non-Western ANSI code page, such as Cyrillic Windows-1251, decoding every compressed piece as cp1252 turns the document into mojibake before it is indexed. Derive the encoding from the Word document's language/code-page metadata rather than hard-coding Western European text.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
MS-DOC 2.4.2: a compressed piece (fCompressed) is 8-bit text in cp1252 with a fixed set of exceptions, independent of any declared code page, so decoding it as cp1252 is the spec behaviour.
|
|
||
|
|
||
| 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") |
There was a problem hiding this comment.
Honor the encoding of legacy PowerPoint byte text
When a .ppt contains TextBytesAtom records encoded with a Windows code page such as cp1251, interpreting their bytes as Latin-1 corrupts all non-Latin text; the fallback scanner repeats the same assumption. Track the applicable PowerPoint text/code-page metadata and decode byte-text records with that encoding in both extraction paths.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
MS-PPT 2.9.39: each byte of a TextBytesAtom is the low byte of a UTF-16 code unit whose high byte is 0, so Latin-1 is the exact decoding; the atom carries no code page.
| {indexing > 0 ? ( | ||
| <Spinner className="size-4" /> | ||
| ) : ( | ||
| <HugeiconsIcon icon={Folder02Icon} strokeWidth={1.5} className="size-6" /> | ||
| )} | ||
| <span>{indexing > 0 ? `Indexing ${indexing} of ${docs.length}` : count}</span> |
There was a problem hiding this comment.
Surface failed files in linked-folder cards
When one or more documents from a linked folder have status === "failed", indexing becomes zero and the card renders the ordinary file count, making the folder look fully indexed even though that content is unavailable to retrieval. Preserve a failed count or error state on the collapsed card instead of treating every non-processing group as successful.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
A linked-folder file that fails to index is discarded by the sync and reported on the folder row in Linked folders; failed rows never reach the folder card, so there is nothing for the card to surface.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0840283a0a
ℹ️ 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".
| self._zip = zipfile.ZipFile(path) | ||
| except zipfile.BadZipFile as exc: | ||
| raise ValueError("file is not a valid archive") from exc | ||
| self._names = {name.lower(): name for name in self._zip.namelist()} |
There was a problem hiding this comment.
Preserve case-sensitive EPUB member names
When an EPUB contains case-distinct resources such as a.xhtml and A.xhtml, this lowercase-keyed map collapses them into one entry even though ZIP/EPUB paths are case-sensitive. Both spine references then read whichever member appeared last, causing one chapter to be duplicated and the other omitted from the indexed text; retain an exact-name lookup for EPUB resources rather than normalizing all archive names to lowercase.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
EPUB 3.3 (OCF file names) requires names in a directory to be unique after case folding, so a.xhtml and A.xhtml cannot both exist in a valid EPUB, and OOXML part names are case-insensitive too.
| 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.
Restrict Strict namespace rewriting to namespace declarations
When an XLSX or PPTX XML part contains one of the Strict namespace URLs as user-visible cell or slide text, these byte-wide replacements rewrite that content to the Transitional URL before extraction. This also affects Transitional packages whose text merely mentions a Strict URL, because the presence check scans the whole part; normalize element and attribute namespaces during parsing, or replace only namespace declaration values, rather than modifying every matching byte sequence.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Only the exact ISO Strict namespace URIs are swapped; a cell or slide whose text is literally one of those URIs is not a realistic document, and the swap changes only that URI string.
| const OFFICE_DOC_EXTS = RAG_DOCUMENT_UPLOAD_ACCEPT.split(",").filter( | ||
| (ext) => !isComposerAttachmentName(`file${ext}`), | ||
| ); |
There was a problem hiding this comment.
Route desktop Office drops to their composer adapter
In the Tauri app, dropping an .xlsx, .xlsm, or .pptx on the composer now classifies it as a RAG document because isComposerAttachmentName does not include the existing OfficeAttachmentAdapter. Unlike the browser composer drop and the + picker, the window-wide native handler therefore sends these files to ThreadDocumentsBar, enables chat-with-files, and indexes them instead of attaching them to the message; exclude the Office adapter's accepted extensions from OFFICE_DOC_EXTS so only drops on the registered files panel are indexed.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
This routing is intended and covered by native-drop-paths.test.ts: before this PR desktop drops of .xlsx, .xlsm and .pptx were refused as unsupported, and now they are indexed for chat with files, so the file reaches the model rather than being lost.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bbc1781f94
ℹ️ 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".
| self._zip = zipfile.ZipFile(path) | ||
| except zipfile.BadZipFile as exc: | ||
| raise ValueError("file is not a valid archive") from exc | ||
| self._names = {name.lower(): name for name in self._zip.namelist()} |
There was a problem hiding this comment.
Bound ZIP entries before materializing the archive
A small crafted ZIP can contain hundreds of thousands or millions of empty members, so opening it already materializes that many ZipInfo objects and this comprehension then duplicates every name into another large dictionary before any byte or XML budget is consulted. Such an authenticated Office/EPUB upload can exhaust the backend process even though its expanded data is tiny; preflight and reject an excessive central-directory entry count before constructing the ZipFile and name map.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Measured: a 1M-entry zip costs about 550 MB inside zipfile.ZipFile itself, the same cost the existing .docx path already pays; the name map adds about 15% on top. Not specific to this change.
| count += 1 | ||
| if count > _MAX_UNIT_ELEMENTS: | ||
| raise ValueError(f"{name} is too large to index") | ||
| elif element.tag in units: | ||
| unit, count = element, 0 |
There was a problem hiding this comment.
Apply the XML element ceiling across streamed units
For streamed shared strings and spreadsheet rows, count is reset whenever each new unit starts, so a document containing millions of individually small units never reaches _MAX_UNIT_ELEMENTS and also bypasses the declared _MAX_XML_ELEMENTS ceiling used by xml(). A terse XLSX or ODS worksheet can therefore force millions of parse iterations and accumulated output rows, consuming excessive CPU and memory; maintain a separate total start-element count for the entire streamed part.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Streamed parts are already bounded by the 128 MB per-member and 512 MB total byte budgets; a worst-case terse sheet parses in linear time under 500 MB RSS. A 2M element ceiling across the part would reject ordinary 100k x 10 sheets.
… and strengthen the light edge
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! 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". |
Problem
Chat with files lived inside the composer. Turning it on added an "Add files to chat with" pill and a row of status chips above the input, with its own hidden file input and its own chip styling. The documents the chat searches looked nothing like the files you attach to a message, and there was no good place to see or manage more than a few of them.
Change
Chat with files is now a card stacked above the composer.
FileCardBody,AttachmentKindIconand theCARD_*classes, now exported fromattachment.tsx). Cards show the indexing stage and progress, a Project badge for shared sources and a hover X to remove. Clicking an indexed card opens the document preview, on the chat page and on the project page. A dashed Add files card ends the strip, and an empty panel says what it takes..pptx,.xlsx,.odt,.epuband friends even though the backend and linked folders indexed them.office_formats.pyandcfb.pyread Word, Excel and PowerPoint (OOXML and legacy binary), OpenDocument, EPUB, Outlook.msg,.eml, MHTML and RTF for indexing.openFilePickerinsrc/lib/open-file-picker.ts, and the panel uses the same helper.Retrieval, uploads and scopes are unchanged.
Testing
studio/frontend:npm run typecheckandnpm run buildpass;npm test11203 passed. New tests cover a linked folder collapsing into one card and project / knowledge base drops accepting every Office, OpenDocument, e-book and email type.studio/backend:pytest tests/test_rag_office_formats.py tests/test_rag_config_upload_exts.py136 passed;tests/test_runtime_text_encoding.pypasses (the compound file reader'sopenwas renamedread, which the encoding guard mistook for a textPath.open)..md,.txt,.csvand.pyfiles; the header read "4 files".dropped.py(header "5 files") and added no message attachment.Not tested here
useSourceDrophook the knowledge base dialog already uses on desktop.