Skip to content

Studio: restore markdown chat import and bulk export - #12513

Merged
mahiatlinux merged 8 commits into
unslothai:mainfrom
Souravrajvi0:feat/chat-markdown-import-export-ff56
Oct 2, 2026
Merged

mahiatlinux merged 8 commits into
unslothai:mainfrom
Souravrajvi0:feat/chat-markdown-import-export-ff56

Conversation

@Souravrajvi0

@Souravrajvi0 Souravrajvi0 commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #12297 (import/export parity).

  • Import: Settings → Data and desktop file picker accept .md / .markdown and parse Studio ## Role transcripts back into chat threads (including combined bulk exports separated by ---).
  • Export: Library multi-select bulk export menus include Markdown (combined file or per-chat zip), matching single-chat markdown export.
  • Copy and native picker strings updated; English settings description mentions Markdown.

Settings tab consolidation (Library vs Data overlap, API vs Remote & LAN) is intentionally out of scope for this PR and can follow in a separate UX pass.

Test plan

  • node --experimental-strip-types --test tests/conversation-markdown-import.test.ts tests/message-jsonl-import.test.ts
  • Manual: export a chat as Markdown, import via Settings → Data
  • Manual: Library → select multiple chats → Export → Markdown (combined and per-chat)

Allow .md/.markdown in the Data settings and native import pickers, parse
Studio transcript headings back into threads, and add Markdown to Library
bulk export (combined and per-chat zip).
Bulk markdown export should match single-chat export and omit sibling branches.
@danielhanchen

Copy link
Copy Markdown
Member

Frontend build + bundle sanity on head 2e375a6d fails at npm run typecheck on a test this PR changes: tests/message-jsonl-import.test.ts(77,17): error TS2352, a cast from readonly ThreadAssistantMessagePart[] (and the other readonly part arrays) to the mutable { text: string; }[]. Casting to readonly { text: string }[] (or going through unknown) should clear it.

@mahiatlinux

Copy link
Copy Markdown
Contributor

@codex review

@mahiatlinux

mahiatlinux commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Markdown already existed for individual chats and project sources. This PR closes the import and bulk-export gaps. The original implementation needed fixes before it was ready.

Pushed fixes to the contributor branch:

  • b4b947d0e: fix the readonly test cast that failed typechecking.
  • 7d55b74b3: preserve Markdown headings, rules, code examples, quotes, lists, and source whitespace during legacy import. Test combined exports using the actual export builder.
  • c66c1eca8: add hidden message-boundary metadata to exported chat Markdown so literal ## User headings and bulk-looking content survive export/import. Validate malformed or truncated metadata, normalize line endings, and retain legacy unframed import support. Project-source Markdown remains plain.
  • 00cf005c7: continue importing later conversations when saving one fails, with accurate imported/failed counts and cleanup.
  • f851c9640: keep model names on comparison halves in combined Markdown, including base/fine-tuned suffixes.

Verification on f851c96409b3edb3a7d4563c28b21a7312346434:

  • 267 tests passed: node --experimental-strip-types --test tests/*markdown*.test.ts tests/*import*.test.ts tests/ndjson-body.test.ts tests/project-source-plan.test.ts.
  • npm run typecheck, npm run build, and npm run bundle:check passed.
  • Negative controls reproduced import corruption on the original PR head and both comparison-naming failures before their fix.
  • Browser verification exercised the Settings import input and both actual Markdown download actions. Imported text containing ordinary headings, rules, literal role headings, and fenced examples remained intact. Combined and per-chat ZIP exports parsed back into three conversations; combined comparison titles retained their model names.

The browser check used the real Settings component with a memory-backed API fixture. Separate frontend installs and browser contexts compared merge base da07ae04c with the repaired head. Environment: Linux x86_64, Node 26.8.2, Playwright 1.62.0, Chromium 151.0.7922.34, 1280×1000.

Review and landing use mirror PR #85 through mirror-pr.py. Codex found no further issues on mirror head 8728c8ed3; all three findings are resolved. The reviewed production files match source head f851c9640, and mirror-pr.py land 12513 confirms nothing remains to land. Upstream CI was still queued when local verification completed.

Before and after Markdown export parity

@mahiatlinux
mahiatlinux self-requested a review October 2, 2026 07:45

@mahiatlinux mahiatlinux left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Ready to merge, all manually checked.

@mahiatlinux

Copy link
Copy Markdown
Contributor
image

@mahiatlinux
mahiatlinux merged commit 1670be3 into unslothai:main Oct 2, 2026
shimmyshimmer pushed a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Nov 14, 2026
…lothai#17652)

Fixes unslothai#17651

## What this changes

On the Projects page in the web UI, **Import chats…** opened a file
dialog filtered to `.json, .jsonl, .ndjson, .csv`. Markdown chat exports
were hidden there, although the importer behind that dialog reads them,
and Settings > Data and the desktop picker both offer them. The page's
hidden file input had its own copy of the extension list, which was not
updated when Markdown import came back in unslothai#12513.

- `projects-page.tsx` now takes its `accept` list from
`CHAT_IMPORT_ACCEPT` (`features/chat/utils/import-chats.ts`), the list
`pickAndImportChats` already uses.
- `data-tab.tsx` (Settings > Data) uses the same constant in place of
its own literal copy, so the three browser pickers cannot drift apart
again. The constant is exported from the chat feature index next to
`pickAndImportChats`.

The desktop app is unchanged: it uses the native picker, which already
lists `md` and `markdown`.

## Testing

**Real Studio in Chromium (Windows 11):** I ran the backend (`run.py
--api-only`) with the vite frontend, opened Projects, chose **Import
chats…** from the import/export menu and read the file chooser the page
opened.

| | picker filter | `holiday notes.md` selectable |
| --- | --- | --- |
| main (d58508d) | `.json,.jsonl,.ndjson,.csv` | no |
| this branch | `.json,.jsonl,.ndjson,.csv,.md,.markdown` | yes |

On this branch I then picked a Markdown chat (`## User` / `## Assistant`
sections), confirmed the import dialog, and the chat was saved as
"holiday notes" (checked through `GET /api/chat/threads`). Settings >
Data still shows `.json,.jsonl,.ndjson,.csv,.md,.markdown` on its import
inputs.

The visible difference is only in the operating system's file dialog,
which a headless browser cannot capture, so there are no before/after
screenshots.

**Tests:** new `tests/chat-import-picker-accept.test.ts` checks that the
Projects page and Settings > Data pickers use `CHAT_IMPORT_ACCEPT`, and
that the list matches the desktop picker's `CHAT_IMPORT_EXTENSIONS` and
covers the extensions the importer routes by name. The first test fails
on main. Full frontend suite on this branch: 15884 tests, 15873 pass, 0
fail (the rest are skips). `node scripts/typecheck.mjs --tests` and
eslint on the changed files are clean.


## Before / after

Projects > import/export > Import chats... on the merge base (d58508d)
and this branch (b2fb4f7), two separate Studio installs. The OS file
dialog is not drawn by a headless browser, so the caption is drawn by
the harness from the file chooser's `accept` attribute that each build
opened.

![Projects import picker filter, before and
after](https://raw.githubusercontent.com/danielhanchen/unsloth-staging-2/pr-media/pr/17652/pr17652_projects_import_filter-065128655cfc.png)

Before: `.json,.jsonl,.ndjson,.csv`, a `.md` export is not selectable.
After: `.json,.jsonl,.ndjson,.csv,.md,.markdown`, it is.

---------

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.

[Bug] Importing chats that have been exported as .md and general housekeeping of settings tab

3 participants