Skip to content

Studio: linked folders honour .gitignore, folder uploads in the browser, queued drops and retry for failed sources - #13224

Merged
danielhanchen merged 56 commits into
mainfrom
studio-project-sources-followups
Oct 12, 2026
Merged

danielhanchen merged 56 commits into
mainfrom
studio-project-sources-followups

Conversation

@shimmyshimmer

@shimmyshimmer shimmyshimmer commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

Stacked on #13078 (base studio-chat-with-files-panel). This picks up the project, linked folder and source fixes that #13078 left out.

Linked folders

  • .gitignore is honoured. The root .gitignore and nested ones apply, with the usual rules: anchoring, **, negation and directory-only patterns. The rules live in core/rag/gitignore.py.
  • Build output is skipped, but only beside a project manifest. dist, build, out, target, coverage, htmlcov and vendor are skipped when the folder holding them also has package.json, pyproject.toml, Cargo.toml or a similar manifest. A plain build/ folder in a notes vault is still indexed.
  • Large data files and empty files are skipped. Plain-text files over 20 MB are left out. These are logs, CSVs, SQL dumps and JSONL files that used to be embedded in full (RAG_FOLDER_MAX_TEXT_BYTES, 0 turns the limit off). Empty files are left out too: an empty __init__.py used to fail on every sync.
  • The file cap no longer fails the whole sync. A folder past RAG_FOLDER_MAX_FILES indexes the first 10,000 files in sorted order, so the same files are kept from one pass to the next. Only a folder past twice the cap is still refused, and the error now suggests a .gitignore.
  • Every failed file is listed with its reason. The folder row says what was skipped (".gitignore", "build folders", "large data files", "past the file limit"). It also has a "Show N files that couldn't be indexed" list. The job error still names only three files.
  • Syncs that change nothing stay quiet. last_scan_at moves on every 30 s pass, and clients compared it, so every open panel and tab re-fetched the project's full document list every 30 s. Folders now expose lastChangedAt, which moves only when files were added, changed, removed or renamed. Finished jobs report renamedFiles, and a job with no changes does not announce a sources change.
  • Toasts only for syncs you start. "Folder sync failed" now appears only for a sync started from the UI. A periodic pass that fails again shows its error on the folder row instead of a toast every 30 s.

Project Sources, knowledge bases and chat with files

  • Linked folders are one chip on the Sources tab. Each linked folder shows as "Docs · 2,140 files" with indexing progress, instead of one chip per file. The composer panel already did this in Studio: move chat with files into a panel above the composer #13078.
  • Folder uploads in the browser. The browser build cannot link a folder, so Sources now has an "Add folder" button and accepts dropped folders. Both copy in the supported files, up to 2,000 per folder. Hidden folders, node_modules, venvs, .env files, lockfiles and empty files are skipped. On desktop, dropping a folder suggests Link folder instead.
  • Drops and picks during an upload are queued. They used to be refused. They now wait, with a toast, and start when the running upload ends. This applies to the composer panel, Sources and knowledge bases. Files queued for one project are dropped if you switch to another before they start. The scope picker stays locked until the queue is empty.
  • Failed sources stay, with Retry. A file that failed to upload or index used to disappear after a toast. It now stays as a failed card or chip with its reason, a Retry button (when the original file is still in this tab) and an X to remove it. Desktop drops cannot be retried because their path token is spent on the first upload, so those still go away after the toast.

Testing

  • studio/backend: the new tests/test_rag_folder_scan_filters.py has 30 tests:
    • .gitignore patterns and nested files;
    • build output beside a manifest only;
    • oversized text and empty files;
    • a stable subset past the cap, and refusal past twice the cap;
    • last_change_at unchanged on an idle pass;
    • the full failure list in the folder view.
  • studio/backend: test_rag_linked_folders.py, test_rag_source_files_indexing.py, test_rag_linked_folder_grant_retry.py and test_folder_sync_account_rotation.py pass. The exceptions also fail on the base branch on this macOS host, where the temp directory is a denied system path: the three test_scan_does_not_enter_dot_directories cases and test_scan_indexes_source_and_skips_dependencies_and_secrets.
  • studio/frontend: npm run typecheck and npm run build pass, and npm test passes 11212 of 11212. New tests in rag-source-followups.test.ts and rag-upload-lifecycle.test.ts cover:
    • idle syncs not counting as source changes;
    • job change detection;
    • the folder picker's filters and cap;
    • the upload queue (batching, and dropping on a project switch);
    • a refused upload that keeps a failed chip and retries the same file.
  • In an isolated Studio built from this branch (browser build):
    • "Add folder" on a new project's Sources tab uploaded README.md, leave.txt and tool.py, and left out node_modules/ and prod.env. In the screenshot below, the empty.txt failure comes from a run made before empty files were skipped; folder uploads now leave it out.
    • In chat with files, an empty file showed "Couldn't index" with Retry, next to an indexed file.

Sources tab after a folder upload

Failed card with Retry in chat with files

Not tested here

  • Linking a folder needs the desktop app, so these were not exercised in the UI on this host: the folder row's skipped summary, the failure list, the quieter periodic syncs, and the desktop folder-drop hint. They are covered by the backend tests and by unit tests of the change detection.
  • Desktop builds and the updater are not affected and were not run.

Before / after (browser build, merge base vs this branch)

The empty Sources tab gains "Add folder" and the folder drop hint:

Empty Sources tab, before and after

After uploading notes.md and an empty empty.txt (refused with "Uploaded file is empty."), the failed file used to disappear after the toast. It now stays as a failed chip with Retry and remove:

Sources tab after a refused upload, before and after

shimmyshimmer and others added 16 commits October 8, 2026 07:20
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.
…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.
…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
…dumps, keep syncing past the file cap, and report every failed file
… sources, grouped linked folders and quieter folder syncs
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-12T13:02:03.963510Z b9aa205 New commits
🔒 Security Review ✅ Completed 2026-10-12T09:09:11.930847Z fa94d87 Manual request

Security findings

Advisory findings (1)

ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex security review

chatgpt-codex-connector[bot]

This comment was marked as resolved.

…ep Retry when a delete fails, and skip malformed gitignore rules
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

…to studio-project-sources-followups

# Conflicts:
#	studio/frontend/src/features/rag/components/thread-documents-bar.tsx
Base automatically changed from studio-chat-with-files-panel to main October 11, 2026 11:07
…s-followups

# Conflicts:
#	studio/frontend/src/features/rag/components/project-sources-panel.tsx
#	studio/frontend/src/features/rag/components/thread-documents-bar.tsx
#	studio/frontend/src/features/rag/components/use-source-drop.ts
#	studio/frontend/tests/project-sources-model-without-tools.test.ts
#	studio/frontend/tests/rag-thread-initialization.test.ts
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex security 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 Security Review

Here are some automated security review suggestions for this pull request.

Reviewed commit: fa94d871b1

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

directory, ancestor_paths, ancestor_identities, depth, rules = pending.pop()
directory_rel = os.path.relpath(directory, root).replace(os.sep, "/")
directory_rel = "" if directory_rel == "." else directory_rel
rules = (*rules, *_read_gitignore(directory, directory_rel))

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 Security Review

P3 Badge Security: Bound .gitignore rules during linked-folder scans

When a user links a repository controlled by another party, every <=256 KiB .gitignore is parsed into an unbounded number of rules and this line accumulates all ancestor rules. _scan then applies every regex to each directory/file. One valid 256 KiB file can contain 131,072 one-character rules; with the 10,000-file default that is 1.31 billion checks (13.1 million took 4.43 s locally), and nested files retain millions of rule objects. The scan has no cancellation check and auto-sync runs by default, so a crafted repo can pin CPU or exhaust memory after it is linked. Cap rules per file and scan, and check cancellation while scanning.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not changing this: it needs a deliberately crafted .gitignore with 100k+ rules in a folder the user chose to link. Real .gitignore files are a few hundred rules at most, and per-name matching is already bounded (globstar cap, atomic star groups, 256 KB file cap).

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: fa94d871b1

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

@danielhanchen danielhanchen self-assigned this Oct 12, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 12, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 12, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 99f6f99c95

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants