Skip to content

feat: add compact conversation to the chat menu - #13579

Merged
danielhanchen merged 2 commits into
unslothai:mainfrom
Lyxot:feat/manual-compact-13453
Oct 14, 2026
Merged

danielhanchen merged 2 commits into
unslothai:mainfrom
Lyxot:feat/manual-compact-13453

Conversation

@Lyxot

@Lyxot Lyxot commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Adds Compact conversation to the Unsloth Studio chat menu. The button queues the same one-shot next-message request as /compact, reuses the header’s context-usage ring, and translates its label and feedback in all 14 locales.

Reuses the manual-compaction foundation merged in #13562. The button is one commit on that foundation; the command, request consumption, backend, and transcript/divider behavior remain unchanged.

The button follows the dependency’s GGUF/MLX and tool-capability requirements. Empty and unsupported chats show feedback; model loading, streaming, composer preflight, and already-issued assistant runs block the action. Queued feedback acknowledges a request; the dependency’s per-turn backend gates decide whether a checkpoint reset can occur.

Fixes #13453.

Validation

After retargeting onto main, all 18 manual-compaction tests, typecheck, and frontend build pass. The earlier stacked-head validation is recorded below; review and staging CI were not rerun, as requested.

  • 59 focused frontend tests pass, covering the button, selected-chat isolation, busy-state boundaries, ring/menu bindings, and existing branch exports/forks.
  • All 40 targeted mutations are caught, with green-copy baseline and failing-copy sentinel checks.
  • 43 existing bundle-budget tests also pass (102 focused checks total). Bundle allowance increases only by measured button growth: 1,570 raw and 535 compressed bytes, preserving the base margins.
  • Frontend build and typecheck pass. Targeted ESLint retains the unchanged restricted favorites-store import.
  • All 11 inherited manual-compaction test bodies are unchanged; seven button tests are appended. Base command/adapter/backend/divider files are unchanged.
  • UI captures below are a live run against a loaded local GGUF, not fixtures: the menu ring matches the header, the click queues the request, and the next message is compacted by the backend while the model still answers from the compacted turns.

UI evidence

Captured on head 06ce9c82f2 (latest main) with a local Qwen3.5-2B GGUF at a 2,048-token window, so the ring visibly fills. Headless Chrome, 1280x760 at 2x.

The menu item's ring matches the header indicator (1.3k / 2.0k):
图片

After clicking Compact conversation:
图片

The next message carries the compaction: the backend reports it, and the model still answers from the compacted turns (codename and ship date from the first message):
图片

Before / after (merge base 3a6179b vs head 5939ad4)

Two isolated Studio installs, same seeded saved chat, header chat menu opened. The menu gains Compact conversation above Fork, with the context ring as its glyph:

Chat menu before and after

Clicking it with no model loaded explains the GGUF / MLX tool-support requirement instead of queueing a request:

Clicking Compact conversation with no model loaded

@Lyxot
Lyxot requested a review from danielhanchen as a code owner October 13, 2026 09:36
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 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 ✅ Completed 2026-10-14T13:59:25.316389Z 5939ad4 Manual request
ℹ️ 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.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@Lyxot
Lyxot force-pushed the feat/manual-compact-13453 branch from a18305e to 80f53f8 Compare October 13, 2026 11:26
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 80f53f8669

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

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 13, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 13, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 13, 2026
@Lyxot
Lyxot force-pushed the feat/manual-compact-13453 branch from 80f53f8 to 5ddc1d0 Compare October 13, 2026 11:40
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@Lyxot
Lyxot force-pushed the feat/manual-compact-13453 branch 2 times, most recently from a904f98 to 6d2af9a Compare October 13, 2026 12:20
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 13, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 6d2af9ac2f

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

@Lyxot

Lyxot commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator Author

Review and staging CI completed for 6d2af9ac2f46c4690147ea11580ca0a6f5617ebf on unchanged #13562 base 38f560814e933b8c80ebeb05f250e613ef467266. Codex confirmed “Didn't find any major issues” on this exact head. All retained review threads are resolved.

The branch now has one button commit, retaining the verified composer/direct-run busy guards and loaded tool-capability check, with request-only queued feedback in all 14 locales. The command, adapter, backend, divider, and workflows remain unchanged. Eight comments in four unrelated review threads were removed as requested. 102 focused checks, typecheck/build, 40 targeted mutations, and independent review passed locally. Bundle allowances increase only by measured button growth (1,570 raw /535 compressed bytes), preserving both base margins.

Staging #157 tested the same head and base and is now closed; the shared head branch is retained. Both PRs have the MLX label. CI finished with 34 passing and 4 failing checks, with no pending jobs. Passing checks include frontend Windows unit tests, cross-platform composer/browser checks, source lint, API/auth, and macOS UI/API/GGUF inference.

The four failures were checked and left outside this button scope:

Check Result and evidence
Frontend bundle sanity Build/tests pass; inherited compressed startup overrun remains exactly 1,358 bytes. Same-toolchain base: 2,014,358 bytes against 2,013,000; head: 2,014,893 against 2,013,535. Both have 98 chunks.
Backend Python 3.13, a–k 5 failed / 24,284 passed: 2 diffusion optimizer fixture failures and 3 H3 trainer failures due to missing diffusers. Backend and workflows match the base byte for byte.
Backend Python 3.13, l–r 1 failed / 23,547 passed: inherited test expects sandbox_level as final parameter, while the dependency appends compact_context. Source and test are unchanged.
Repo CPU rest 1 failed / 12,043 passed: existing weight-fetch call-site assertion in test_st_subfolder_weights_are_fetched.py, covering vision.py/llama.py. Both source and tests match the base byte for byte.

No further monitoring was configured.

@danielhanchen
danielhanchen deleted the branch unslothai:main October 13, 2026 13:34
@Lyxot Lyxot reopened this Oct 13, 2026
@Lyxot
Lyxot changed the base branch from studio-compact-command to main October 13, 2026 13:38
@Lyxot
Lyxot force-pushed the feat/manual-compact-13453 branch from 6d2af9a to f11fd7f Compare October 13, 2026 13:42
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 5bd6add56d

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

@Lyxot

Lyxot commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator Author

Review and staging CI completed for 5bd6add56d3578dcc82b95d0e22b5c58e3a0aa3f on latest main af9d97837e97944e056c68a3c5c951bace434d07.

Codex: Didn't find any major issues on this exact head, first round. No review threads remain open.

What changed in this pass:

  • Rebased onto latest main. The only conflict was check-bundle-budget.ts: main's budget is kept and raised by the button's own growth, measured by building main and this head on one machine (6,581.9 -> 6,583.4 KB raw, 1,974.3 -> 1,974.8 KB transfer, 99 chunks each), so bundle:check leaves exactly main's margin. The comment now cites a commit on main.
  • One Hebrew string (compactUnsupported) now uses the same term as the other compaction strings and the auto-compact setting.
  • The queued-prompt thread was answered without a code change: the button keeps /compact's next-dispatched-request contract, and /compact itself runs ahead of the prompt-queue gates.

CI: Staging #161 ran the same head and base: 38 passing, 0 failing. That includes Frontend unit tests (Windows) and Frontend build + bundle sanity, which failed on the previous head only because of an image-restore-negative-prompt test since fixed on main. It also includes the Python 3.13 a-k, l-r and rest shards, Repo tests (CPU, rest) and Chat UI, API, Update and GGUF inference. The staging PR is closed; the shared head branch is retained.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 06ce9c82f2

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

@Lyxot

Lyxot commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator Author

Review and staging CI completed for 06ce9c82f266562ec0214d3535a4e36ad7687941 on main 2a03c22812f4936df2328b5410ed095d232f0dd6.

Codex: Didn't find any major issues on this exact head, first round. No review threads are open.

What changed in this pass:

  • Rebased onto main again to clear a new conflict in check-bundle-budget.ts, the only conflicting file. Main's budget is kept and raised by the button's growth, measured by building main and this head on one machine: 6,741,807 -> 6,743,381 B raw, 2,021,316 -> 2,021,655 B transfer, 95 chunks each. Without the raise the head is 145 B over main's raw budget; with it, bundle:check leaves exactly main's margin (5,294 B transfer, 1,429 B raw).
  • UI evidence in the description is replaced with a live run on this head: a local GGUF with a 2,048-token window. It shows the menu ring matching the header, the request toast, and the next message compacted by the backend while the model still answers from the compacted turns.

CI: Staging #165 ran the same head and base (#161 could not be reopened after the force-push): 36 passing, 2 failing. Both failures come from main and reproduce on 2a03c22812 without this PR:

Check Cause
Frontend build + bundle sanity Fails at the locale parity step: settings.data.library.filesNotRestored exists in overlay but not in en (it.ts). npm run i18n:check:strict reports the same error on the base commit. This PR only adds four chatMenu strings to it.ts.
Repo tests (CPU, studio) tests/studio/test_token_count_prompt_parity.py fails with ReferenceError: skillsForTools is not defined from chat-adapter.ts, which this PR does not touch. The same test fails on the base commit.

Passing checks include Frontend unit tests (Windows), Chat UI, API, Update and GGUF inference, the Python 3.13 a-k, l-r and rest shards, and Repo tests (CPU, rest). The staging PR is closed; the shared head branch is retained.

@danielhanchen danielhanchen self-assigned this Oct 14, 2026
# Conflicts:
#	studio/frontend/scripts/check-bundle-budget.ts
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 14, 2026
@unslothai unslothai deleted a comment from Lyxot Oct 14, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 14, 2026
@unslothai unslothai deleted a comment from Lyxot Oct 14, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 14, 2026
@unslothai unslothai deleted a comment from Lyxot Oct 14, 2026
@unslothai unslothai deleted a comment from Lyxot Oct 14, 2026
@unslothai unslothai deleted a comment from Lyxot Oct 14, 2026
@unslothai unslothai deleted a comment from Lyxot Oct 14, 2026
@unslothai unslothai deleted a comment from Lyxot Oct 14, 2026
@unslothai unslothai deleted a comment from Lyxot Oct 14, 2026
@unslothai unslothai deleted a comment from Lyxot Oct 14, 2026
@unslothai unslothai deleted a comment from Lyxot Oct 14, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 5939ad4a1c

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

[Feature] allow manual compact conversation

2 participants