Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio: keep feature indexes and the markdown renderer out of the startup bundle (#16394)
Daniel Hanb36f53d3581e
diff --git a/studio/frontend/scripts/check-bundle-budget.ts b/studio/frontend/scripts/check-bundle-budget.tsindex 4fd1b151816..439b73235b0 100644--- a/studio/frontend/scripts/check-bundle-budget.ts+++ b/studio/frontend/scripts/check-bundle-budget.ts@@ -1,11 +1,6 @@// SPDX-License-Identifier: AGPL-3.0-only// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0-/**- * Budget for JavaScript fetched and run before the first screen: Vite's entry plus modulepreload- * links (static import closure) plus parser-blocking classic scripts such as public/theme-boot.js.- */-import { readFileSync, realpathSync } from "node:fs";import { dirname, join, resolve } from "node:path";import { fileURLToPath } from "node:url";@@ -14,444 +9,14 @@ import { gzipSync } from "node:zlib";const HERE = dirname(fileURLToPath(import.meta.url));const DIST = resolve(HERE, "..", "dist");-/** Measured plus headroom. Transfer = wire bytes; raw = bytes the main thread parses. */export const BUDGET = {- // Re-measured together on one machine and build: 6,023.4 KB raw / 1,802.1 KB transfer at 5b78bafd04,- // plus the margin the previous raises chose (210.8 KB raw, 65.1 KB transfer). The growth since is- // the vLLM / SGLang engine options inside the model config page and Resources tab (#11491), which- // live inline in the chat and settings chunks: lazy-loading the separable inference-engines- // module recovers only 0.6 KB transfer, so what ran out is headroom, not laziness.- // The browser panel's bookmarks, tab dragging and page zoom then added 2.8 KB raw / 1.0 KB- // transfer (6,231.7 -> 6,234.5 KB raw, 1,865.0 -> 1,866.0 KB transfer, one machine and build),- // inside the already-eager chat chunk; raw is raised by that so the margin stays where it was.- // Re-measured again at cc84c7dc7a: 6,278.6 KB raw / 1,879.0 KB transfer, 11.8 KB transfer over.- // Measured commit by commit from the browser panel (#12347), no single import did it: the panel- // itself left 2.9 KB transfer over, the Sandbox settings tab (#12215) added 16.4 KB raw / 4.5 KB- // transfer (its strings in every eager locale and the sandbox pick in the chat adapter), the- // message action bar rework (#12735) 2.9 KB raw, and the other merges in that range the rest,- // all in the eager chat, index and settings chunks. Headroom ran out, so the same margin is put- // back.- // The long-chat render work (#13255: deferred fences and reasoning rows) adds 33.3 KB raw / 13.1 KB- // transfer to the eager chat chunk (6,477.1 -> 6,510.4 KB raw, 1,942.6 -> 1,955.7 KB transfer at- // 160cb41fe, one machine and build); raised by that so main's margin stays where it was.- // Project sources follow-ups (#13224: queued drops, retry on failed sources, folder drops) add- // 6.6 KB raw / 2.0 KB transfer, mostly in the eager chat chunk (6,513.0 -> 6,519.6 KB raw,- // 1,956.4 -> 1,958.4 KB transfer against d4ea5a51d, one machine and build). Lazy-loading the- // folder walker recovered 0.5 KB raw and no transfer, so the budget is raised by that growth.- // Then 19 small Studio merges took main over again with no single import doing it: 6,518.8 ->- // 6,533.6 KB raw, 1,958.0 -> 1,963.7 KB transfer from 5f38afbc2d to 33176a75e9 (one machine and- // build). The largest step is Regenerate title in the Library menu (#13491, +5.2 KB raw / +2.2 KB- // transfer, code that shares the eager chat row menu module); the Library card and composer tweaks- // and the edit_file download link add the rest, 0.2 to 1.7 KB transfer each. Raised by that growth- // so main's margin stays where it was.- // Twelve more Studio merges added 7.1 KB raw / 2.3 KB transfer (6,534.6 -> 6,541.7 KB raw,- // 1,963.9 -> 1,966.2 KB transfer from f68585e2e9 to a7dc8a0640, one machine and build), again with- // no single import doing it. The largest step is per-chat file history and /rewind (#13522, +4.3 KB- // raw / +1.3 KB transfer in the eager chat chunk); the rest are 0.1 to 0.6 KB each. Raised by that- // growth so main's margin stays where it was.- // Sidebar server paging adds 17.4 KB raw / 5.6 KB transfer to the first screen (6,544.5 -> 6,561.9- // KB raw, 1,967.1 -> 1,972.7 KB transfer against b73110c6f, one machine and build), raised by that.- // /compact and the in-loop compaction divider add 3.6 KB raw / 1.4 KB transfer to the eager startup- // JS (6,563.4 -> 6,567.0 KB raw, 1,973.0 -> 1,974.4 KB transfer against 280c45695, one machine- // and build), raised by that.- // Five merges since then add 2.1 KB raw / 0.8 KB transfer (6,567.3 -> 6,569.4 KB raw, 1,974.5 ->- // 1,975.3 KB transfer from a062c04d51 to c35052e42f, one machine and build). The step that crossed- // is the token activity Chart view (#13558, +0.7 KB raw / +0.3 KB transfer): its persisted store- // pulls zustand/middleware into the startup set as a 99th chunk. Raised by that growth so main's- // margin stays where it was.- // Six merges since add 2.9 KB raw / 1.4 KB transfer (6,570.7 -> 6,573.6 KB raw, 1,975.5 -> 1,976.9 KB- // transfer from b8d76e1696 to 8af12324b0, one machine and build), with the chunk count unchanged and- // no single import doing it. The largest step is the audio model selector fix (#13517, +2.9 KB raw /- // +0.9 KB transfer); thinking traces (#13545), MLX precision folders (#13565) and vLLM thinking- // effort (#13571) add the rest. Raised by that growth so main's margin stays where it was.- // The KV cache, GPU memory limit and seed engine options (#13596) add 5.7 KB raw / 1.4 KB transfer- // (6,573.5 -> 6,579.2 KB raw, 1,976.9 -> 1,978.3 KB transfer against abfe3142c, one machine and- // build), inline in the eager chat and settings chunks like the other engine options; raised by that.- // Read aloud's token cap and length warning add 0.2 KB raw / 0.1 KB transfer to the eager chat chunk- // (6,739,816 -> 6,740,052 B raw, 2,021,725 -> 2,021,835 B transfer against af9d97837e, one machine- // and build), which took main over; raised by that.- // Seven merges since add 2.1 KB raw / 0.7 KB transfer (6,741,756 -> 6,743,873 B raw, 2,025,885 ->- // 2,026,588 B transfer from b44035a64 to cbf0f593d, one machine and build, Node 22), with the chunk count- // unchanged and no new dependency. The step that crossed is eval-loss early stopping patience (#13626,- // +806 B raw / +311 B transfer: its training field and strings); the maximized window layout fix in the- // app provider (#13647) 539 B raw, the + menu reorder (#13679, measured together with #13659) 711 B raw,- // and #13703 / #13700 the last 61 B. Raised by that growth so main's margin stays where it was.- // The chat menu's Compact conversation item adds 1.6 KB raw / 0.3 KB transfer to the eager chat chunk- // (6,741,807 -> 6,743,381 B raw, 2,021,316 -> 2,021,655 B transfer against 2a03c22812), raised by that.- // Eleven frontend merges since add 4.6 KB raw / 1.2 KB transfer (6,745,911 -> 6,750,599 B raw, 2,027,285 ->- // 2,028,544 B transfer from 85b6414c68 to 8611f1846c, one machine and build, Node 24), with the chunk count- // unchanged at 95 and no new dependency. No single step crossed: the composer draft kept across chats- // (#13722) 2.1 KB raw / 0.5 KB transfer, the collapsed sidebar rail's Images and Audio entries (#13731)- // 2.1 KB raw / 0.4 KB transfer, and #13665, #13614, #13732, #13661, #13538 the rest (#13744's revert- // gave back 0.4 KB raw). Raised by that growth so main's margin stays where it was.- // Then the Audio API card in Settings (#12821) 2,019 B raw / 557 B transfer and #13630 132 B raw- // (6,750,599 -> 6,752,750 B raw, 2,028,544 -> 2,029,099 B transfer to dd56fb3572, same machine and build).- // Numbers wrapped tightly in dollars render as math (#13649): the shell-context checks that keep- // `$1$?`-style shell text literal add 6,984 B raw / 2,836 B transfer to the eager chat chunk- // (6,753,387 -> 6,760,371 B raw, 2,029,398 -> 2,032,234 B transfer against eba7641835, one machine- // and build, chunk count unchanged at 95), raised by that.- // Re-embedding documents after an embedding model switch (the save toast's action and the Settings row)- // adds 3,018 B raw / 905 B transfer (6,760,371 -> 6,763,389 B raw, 2,032,234 -> 2,033,139 B transfer- // against 525f3ceae, one machine and build, Node 24, chunk count unchanged at 95). Lazy-loading its store- // from both save sites cost 0.3 KB transfer more in chunk overhead, so the budget is raised by that growth.- // Keeping the tool pills in step with the loaded model's tool support (#13621) adds 1.2 KB raw / 0.4 KB- // transfer to the eager chat chunk (6,753,387 -> 6,754,540 B raw, 2,029,398 -> 2,029,795 B transfer- // against 97ed9415f7, before #13649, one machine and build), raised by that.- // Offering the newest audio.cpp release in updates (#13589) adds 385 B raw / 80 B transfer to the eager set- // (6,764,579 -> 6,764,964 B raw, 2,033,464 -> 2,033,544 B transfer from 91f8457ab3 to 7b6b2a8e48, one machine- // and build, Node 24, chunk count unchanged at 95), which put main 43 B raw over. Raised by that growth so- // main's margin stays where it was.- // Naming the Windows update that adds MXC's built-in container (#13798) adds 358 B raw / 93 B transfer, its- // string in the eager English locale (6,765,003 -> 6,765,361 B raw against 3c0061e16, one machine and build,- // Node 24, chunk count unchanged at 95), which put main 55 B raw over. Raised by that growth.- // Each chat keeping its own browser tabs (#13800: the store's per-chat state, background pages in the- // native view, and the off-screen question strings) adds 5,278 B raw / 1,928 B transfer (6,765,003 ->- // 6,770,281 B raw, 2,033,563 -> 2,035,491 B transfer against a8585676d4, one machine and build, Node 24,- // chunk count unchanged at 95), raised by that.- // Always allow on browser agent prompts (#13777) adds 91 B raw / 42 B transfer to the eager chat chunk- // (6,770,922 -> 6,771,013 B raw, 2,035,640 -> 2,035,682 B transfer against cd947468f1, one machine and build,- // Node 24, chunk count unchanged at 95), which put main 71 B raw over. Raised by that growth.- // Word list numbering through the default style and basedOn (#13755) adds 228 B raw / 39 B transfer to the- // eager attachment reader (6,770,962 -> 6,771,190 B raw, 2,035,676 -> 2,035,715 B transfer against 7ae1a5386,- // one machine and build, Node 24, chunk count unchanged at 95). Raised by that growth.- // The "Only show models that fit" Settings row adds 289 B raw / 77 B transfer (6,771,372 -> 6,771,661 B raw,- // 2,035,798 -> 2,035,875 B transfer against 52a3fbefe, 95 chunks, identical under Node 22.22.2 and 24). Main- // already measured 111 B raw / 54 B transfer over the previous limits, so they are set to the measured build.- // Main was 48 B raw / 29 B transfer over at ffa8fc3b9 (6,771,709 B raw, 2,035,904 B transfer). The browser- // panel's notice for pages that hit a sandbox limit (#13761) adds 143 B raw / 44 B transfer (-> 6,771,852 B raw,- // 2,035,948 B transfer, one machine and build, Node 24, chunk count unchanged at 95). Raised by both.- // Keeping site storage across browser panel pages (#13762) adds 1,644 B raw / 466 B transfer, the page-storage- // module the eager browser store imports for tab close and duplicate (6,771,852 -> 6,773,496 B raw, 2,035,948 ->- // 2,036,414 B transfer against 82f16ca55, one machine and build, Node 24, chunk count unchanged at 95). Raised by- // that growth.- // Hub Run refusing audio models neither Audio nor chat can run (#13812) adds 77 B raw / 65 B transfer- // (6,773,445 -> 6,773,522 B raw, 2,036,392 -> 2,036,457 B transfer against 59ab069b5, one machine and build,- // Node 24, chunk count unchanged at 95). Raised by that growth.- // The Windows Desktop install location row on the first-run screen (#13446) adds 1,324 B raw / 342 B- // transfer (6,773,496 -> 6,774,820 B raw, 2,036,386 -> 2,036,728 B transfer against 59ab069b5, one machine- // and build, Node 24, chunk count unchanged at 95). Lazy-loading it cost more transfer and a 96th startup- // chunk (Rollup split react-dom out), so it is imported statically and the budget raised by that growth.- // Opening the OS folder dialog for model folders on Desktop (#13843) adds 235 B raw / 336 B transfer- // (6,777,794 -> 6,778,029 B raw, 2,037,725 -> 2,038,061 B transfer against 199987c63, one machine and build,- // Node 24, chunk count unchanged at 95). Raised by that growth.- // The Windows Long Paths explainer on the first-run startup screen (#13523) adds 1,816 B raw / 519 B- // transfer (6,778,788 -> 6,780,604 B raw, 2,038,337 -> 2,038,856 B transfer against 62e063618, one machine- // and build, Node 24, chunk count unchanged at 95). Main already measured 3,656 B raw / 1,180 B transfer over- // the previous limits there, so they are set to the measured build.- // The downloads panel's "Starting…" row (#13738) adds 1,404 B raw / 353 B transfer (6,778,788 -> 6,780,192 B raw,- // 2,038,337 -> 2,038,690 B transfer against 7c235de6f, one machine and build, Node 24, 95 chunks). Raised by that growth.- // The Image downloads > Info stamp row in Settings > Library, its search entry and strings (#13444) add 348 B- // raw / 83 B transfer to the eager settings and English locale chunks (6,780,553 -> 6,780,901 B raw,- // 2,038,848 -> 2,038,931 B transfer against 9f5b133254, one machine and build, Node 24, chunk count unchanged- // at 95). Raised by that growth.- // Drafter training in the Train tab adds about 4.9 KB raw / 1.4 KB transfer (6,628.3 KB raw, 1,992.9 KB transfer- // measured against cd424654a, one machine and build, 95 chunks): its persisted training-store fields, their- // migration and the en strings hydrate at startup; the section itself is not in the startup set.- // The Run settings Load in 4-bit switch (#13841: the per-model field threaded through every chat load path and- // the resident-config check) adds 1,448 B raw / 433 B transfer, inline in the eager chat chunk (6,787,367 ->- // 6,788,815 B raw, 2,040,805 -> 2,041,238 B transfer against 4494fa58c, one machine and build, Node 24, chunk- // count unchanged at 95). Raised by that growth.- // The Train tab's Preview tokens button, its dialog and strings (#13850) add 2,233 B raw / 858 B transfer- // (6,788,764 -> 6,790,997 B raw, 2,041,243 -> 2,042,101 B transfer against 5e5511027, one machine and build,- // Node 24, chunk count unchanged at 95). Lazy-loading the dialog cost more (2.7 KB transfer) and a 96th- // startup chunk, so it is imported statically and the budget raised by that growth.- // Three small Studio merges since add 747 B raw / 302 B transfer (6,791,021 -> 6,791,768 B raw, 2,042,102 ->- // 2,042,404 B transfer from 587079569a to 4a8b727dfd, one machine and build, Node 24, chunk count unchanged at- // 95), with no single import doing it: Deep research under Tools in the + menu (#13959) took main over, and- // the connection name and provider menu order (#13964) and the attachment card polish (#13970) add the rest.- // Raised by that growth so main's margin stays where it was.- // The Hub fit filter sizing safetensors rows the way transformers loads them adds 497 B raw / 184 B transfer- // (6,791,768 -> 6,792,265 B raw, 2,037,833 -> 2,038,017 B transfer against 23bbee09b1, one machine and build,- // Node 26, chunk count unchanged at 95). A synchronous predicate in a module already in the startup set, so- // nothing to lazy-load; raised by that growth.- // Seven Studio merges after 17901061d1 add 5,031 B raw / 1,798 B transfer (6,791,768 -> 6,796,799 B raw,- // 2,042,404 -> 2,044,202 B transfer from 17901061d1 to 6106de938c, one machine and build, Node 24, chunk count- // unchanged at 95), measured commit by commit. The two largest steps are inline chat markdown tables with- // their hover controls and expand dialog (#13973, +2,561 B raw / +1,063 B transfer, in the eager chat chunk)- // and Latest Unsloth Models ranking (#13969, +1,290 B raw / +445 B transfer); the composer alignment- // (#13965), the resizable hub split view (#13966) and the fit filter (#13945, already raised for above) add the- // rest. Set to the measured build plus the margin main had at 17901061d1 (160 B raw, 189 B transfer).- // Chat with files closing on its X, the app tooltips and the higher-contrast traces (#13989) add 1,339 B raw /- // 377 B transfer (6,796,799 -> 6,798,138 B raw, 2,044,202 -> 2,044,579 B transfer against 1574001bc1, one- // machine and build, Node 24, chunk count unchanged at 95). Raised by that growth so main's margin stays where- // it was.- // Three Studio merges since add 3,117 B raw / 1,058 B transfer (6,798,138 -> 6,801,255 B raw, 2,044,534 ->- // 2,045,592 B transfer from 4ebc263832~1 to d4e005e73e, one machine and build, Node 24, chunk count unchanged at- // 95). Nearly all of it is searching a model maker in the Model hub (#13998, +3,038 B raw / +1,000 B transfer):- // its owner-to-uploads search lives in use-hub-model-search, a hook the startup screen already loads, so there- // is no separate module to lazy-load. #13999 and #13993 add 79 B raw / 58 B transfer. Raised by that growth.- // Sliding the selected pill on every segmented toggle (#14030) adds 4,432 B raw / 1,696 B transfer- // (6,800,980 -> 6,805,412 B raw, 2,045,645 -> 2,047,341 B transfer against 15e4bc8fde, one machine and build,- // Node 24, chunk count unchanged at 95): the shared slide module and SegmentedPill, imported by toggles that- // already live in startup chunks, so there is no separate module to lazy-load. Raised by that growth.- // QwenCloud as a connection (#14033) adds 167 B raw / 43 B transfer (6,804,234 -> 6,804,401 B raw, 2,047,526 ->- // 2,047,569 B transfer against ca3d1d0ce4, one machine and build, Node 24, chunk count unchanged at 95): its- // connection row, logo mapping and capability entries live in tables the startup chunks already load. Raised- // by that growth.- // Z.ai as a connection (#14034) adds 73 B raw / 29 B transfer (6,804,389 -> 6,804,462 B raw, 2,047,551 ->- // 2,047,580 B transfer against f172c8d7c4, one machine and build, Node 24, chunk count unchanged at 95): its- // logo mapping, capability row and vision gate entries live in tables the startup chunks already load. Raised- // by that growth.- // The audio.cpp v0.9.2 picker rows (#14073) add 253 B raw / 59 B transfer to the eager audio catalog- // table (one machine and build, chunk count unchanged at 95). Raised by that.- // The audio "More models" group and catalog refresh (#14072) add 2,559 B raw / 911 B transfer (6,810,132 ->- // 6,812,691 B raw, 2,049,298 -> 2,050,209 B transfer against f2ed00705f, one machine and build, Node 24, chunk- // count unchanged at 95): the picker rows and catalog hook live in the audio picker the startup chunks load.- // Raised by that growth.- // Audio failure actions, seeds and the single voice picker (#14075) add 492 B raw / 134 B transfer (6,812,691 ->- // 6,813,183 B raw, 2,050,209 -> 2,050,343 B transfer against 4bed2fa246, one machine and build, Node 24, chunk count- // unchanged at 95): the shared audio failure and seed helpers are imported by startup chunks. Raised by that growth.- // The Images pill making images and videos with the loaded local models (#14110) adds 5,425 B raw / 1,442 B- // transfer (6,814,532 -> 6,819,957 B raw, 2,050,886 -> 2,052,328 B transfer against 82523339bd, one machine and build,- // Node 24, chunk count unchanged at 95): the local image and video cards in the eager tool UI registry and the- // composer and adapter gates in the eager chat chunk. Raised by that growth.- // Model memory modes, the refusal toasts and the chat-context save phase (#14108) add 4,315 B raw / 1,495 B- // transfer (6,819,958 -> 6,824,273 B raw, 2,052,278 -> 2,053,773 B transfer against e2a214bc08, one machine and- // build, Node 24, chunk count unchanged at 95): the refusal and evicted-model toast helpers are imported by the- // eager chat, image and video chunks. Raised by that growth.- // Matching letter shortcuts by the letter the layout types (#14113) adds 328 B raw / 137 B transfer- // (6,809,493 -> 6,809,821 B raw, 2,049,157 -> 2,049,294 B transfer against a6da154b3, one machine and build,- // Node 24, chunk count unchanged at 95): the matcher runs on every keydown from the first screen, so there is- // no separate module to lazy-load. Raised by that growth.- // Main was still over after those raises (2fee36ffa3: 6,825,378 B raw / 2,053,999 B transfer against 6,818,878 /- // 2,051,590): each was sized from its PR's own delta on top of a limit that already sat below the build, so the- // shortfall carried forward (it starts at #14073, whose limit was 92 B of transfer under its own build). Moving the- // FLUX.3 prompt upsampler client (#14137) out of images/api.ts, which startup chunks import, saves 4,372 B raw /- // 1,291 B transfer. With #14113 on top that leaves 6,821,334 B raw / 2,052,857 B transfer (78e5eefa4d plus this- // change). Three more PRs landed while main was over, without raising the limit: the darker picker toggle (#14183,- // +76 B raw / -243 B transfer), one tooltip design everywhere (#14172, +3,897 B raw / +1,376 B transfer: the shared- // tooltip is in the eager shell) and pinning FLUX.3 Klein in the Images picker (#14184, +418 B raw / +82 B- // transfer). That gives 6,825,725 B raw / 2,054,072 B transfer at b227654927 plus this change (one machine and- // build, Node 24, chunk count unchanged at 95; CI has matched this machine to the byte). Both limits are reset to- // that build plus a 160 B raw / 189 B transfer margin, measured absolutely rather than by delta.- // Opening //host links as web links (#14190) adds 177 B raw / 52 B transfer (6,825,725 -> 6,825,902 B raw,- // 2,054,072 -> 2,054,124 B transfer against 4dc8bf0bd2 and 551dc28123, one machine and build, Node 24, chunk- // count unchanged at 95): open-link.ts is the shared link opener the eager shell imports. Raised by that growth,- // again to the measured build plus the same 160 B raw / 189 B transfer margin.- // Keeping the FLUX.3 Image Klein GGUF row under its Fast FP8 row (#14197) adds 188 B raw / 66 B transfer- // (6,825,902 -> 6,826,090 B raw, 2,054,124 -> 2,054,190 B transfer against 94464babd6 and 1de12ab309, one machine- // and build, Node 24, chunk count unchanged at 95): the picker catalog is imported by startup code (chat-adapter.ts).- // Raised by that growth, to the measured build plus the same 160 B raw / 189 B transfer margin.- // Keeping the session when auth.db is busy (#14151) adds 829 B raw / 393 B transfer (6,826,090 -> 6,826,919 B- // raw, 2,054,190 -> 2,054,583 B transfer against a33463fb16, one machine and build, Node 24, chunk count- // unchanged at 96): the refresh retry and outcome live in features/auth/api.ts, which every authFetch imports.- // Raised by that growth, to the measured build plus the same 160 B raw / 189 B transfer margin.- // Chunked fence lines, hoisted line colour, the progressive highlight queue and pointer state- // (#13919) add 11,012 B raw / 3,984 B transfer (6,826,518 ->- // 6,837,530 B raw, 2,054,604 -> 2,058,588 B transfer against ffd6c3033, one machine and build, Node 24,- // chunk count unchanged at 96), all in the eager chat chunk the fences render from. Raised to that- // build plus the same 160 B raw / 189 B transfer margin.- // Choosing a working folder when creating a project (#13873) adds 1,756 B raw / 719 B transfer (6,837,530 ->- // 6,839,286 B raw, 2,058,588 -> 2,059,307 B transfer against 6c3a9e9b3, main's build being its limit less the margin;- // one machine and build, Node 24, chunk count unchanged at 96): the picker and the folder reconciliation live in the- // create dialog, which the eager sidebar imports. Raised to the measured build plus the same 160 B raw / 189 B- // transfer margin.- // Keeping the Read aloud speech model loaded beside the chat model (#14191) adds 1,442 B raw / 723 B transfer- // (6,826,504 -> 6,827,946 B raw, 2,054,599 -> 2,055,322 B transfer against 9faa995217, one machine and build,- // Node 24, chunk count unchanged at 96): the speech slot routing, evicted-model reports and Voice tab rows sit in- // the audio hook, chat adapter and settings chunks the startup set already loads. Raised by that growth.- // Developer mode opt-in for experimental CPU video generation (#14247) adds 1,777 B raw / 654 B transfer- // (6,840,406 -> 6,842,183 B raw, 2,059,667 -> 2,060,321 B transfer against 88afa84b87 and 26e246d407, one machine- // and build, Node 24, 96 chunks): its strings join the eager English catalog and the developer-mode- // flag is read by the eager shell (__root.tsx, app-sidebar.tsx, env.ts, hardware-verdict.ts). Raised by that- // growth, to the measured build plus a 160 B raw / 189 B transfer margin.- // A setting to hide the macOS menu bar icon (#11937) adds 349 B raw / 78 B transfer (6,842,183 -> 6,842,532 B raw,- // 2,060,321 -> 2,060,399 B transfer against 46e4f50bea and 2b20770c91, one machine and build, Node 24, 96 chunks):- // its strings join the eager English catalog and settings search index. #14223 and #14232 add no raw bytes.- // Raised by that growth, to the measured build at 6ccf0e4e74 (6,842,532 B raw / 2,060,400 B transfer) plus a- // 160 B raw / 189 B transfer margin.- // The Loaded models card's eject confirmation (#14161, eager shell) adds 356 B raw / 158 B transfer over 28a222f20- // (6,842,874 B raw, 2,060,540 B transfer); limits = that build plus the same margin.- // Naming a chat export after its model, title and day (#12586) adds 615 B raw / 65 B transfer (6,842,183 ->- // 6,842,798 B raw, 2,060,321 -> 2,060,386 B transfer against 46e4f50bea, one machine and build, Node 24,- // 96 chunks): the name builder sits beside the chat exporters in the eager chat chunk. Raised by that growth.- // Opening Parallel Slots from the API page's Slots readout (#14225) adds 546 B raw / 212 B transfer (6,842,518 ->- // 6,843,064 B raw, 2,060,427 -> 2,060,639 B transfer against bff0a25b4, one machine and build, Node 24, 96 chunks):- // the field focus and per-visit Advanced reveal live in the Run settings page and the picker, both in the eager chat- // chunk. Raised to the measured build plus the same 160 B raw / 189 B transfer margin.- // Reconciled with main at 87c6408455: the combined build measures 6,844,101 B raw / 2,060,934 B transfer- // (Node 24, 96 chunks). The API Settings button stays in its lazy page. Keep the same 160 B / 189 B margin.- // FLUX.3 workflows, controls and LoRAs (#14312) add 426 B raw / 138 B transfer (6,844,101 -> 6,844,527 B raw,- // 2,060,887 -> 2,061,025 B transfer against 6a19cb20b9, one machine and build, Node 24, 96 chunks), and #14228- // adds 95 B raw / 15 B transfer on top, measured at d3a82576a4 as 6,844,622 B raw / 2,061,040 B transfer. Raised- // to that build plus the same 160 B raw / 189 B transfer margin.- // The modern toggles (#14322) add 449 B raw / 86 B transfer (6,844,459 -> 6,844,908 B raw, 2,061,006 ->- // 2,061,092 B transfer against ad2fc0659c, one machine and build, Node 24, 96 chunks): switch.tsx is a shared UI- // primitive the startup set already carries. #14329 removed 163 B raw just before. Raised to that build plus the- // same 160 B raw / 189 B transfer margin.- // The Desktop chat-only install choice (#14245) adds 679 B raw / 205 B transfer (6,842,169 -> 6,842,848 B raw,- // 2,060,319 -> 2,060,524 B transfer against 26e246d407, one machine and build, Node 24, 96 chunks): the- // first-run checkbox lives in the eager startup screen and the Train hint in the eager sidebar. Raised by that.- // Explicit browser download names retain the prior startup margin.- // The About tab's iGPU memory row (#14317): merged with main at ca0252968 the build measures 6,848,044 B raw /- // 2,062,332 B transfer (Node 24, 96 chunks). Raised to that plus the same 160 B raw / 189 B transfer margin.- // Token usage tracking (#14076) keeps the saved-count matching, recount scheduling and their review guards in the- // eager chat runtime: merged with main at 4e0fe5b99 the build measures 6,857,322 B raw / 2,064,700 B transfer- // (Node 24, 96 chunks). Raised to that plus the same 160 B raw / 189 B transfer margin.- // The Allow oversized model loads row in Settings (#14379) adds its switch and strings to the eager settings- // chunk and locale: 1,886 B raw / 628 B transfer (6,857,308 -> 6,859,194 B raw, 2,064,700 -> 2,065,328 B- // transfer against f1f283a24e, one machine and build, Node 24, 96 chunks). Raised by that, same margin.- // The Rosetta chat-only messages (#14374) in the eager sidebar and hardware verdict add 298 B raw / 127 B- // transfer (6,859,194 -> 6,859,492 B raw, 2,065,328 -> 2,065,455 B transfer against 34c5203ebb, one machine and- // build, Node 24, 96 chunks). Raised to that build plus the same 160 B raw / 189 B transfer margin.- // The retrieved passage viewer (#13987) in the eager chat UI adds 3,132 B raw / 939 B transfer (6,859,492 ->- // 6,862,624 B raw, 2,065,455 -> 2,066,394 B transfer against 98010f6eee, one machine and build, 96 chunks).- // Raised to that build plus the same 160 B raw / 189 B transfer margin.- // Chat safety for diagrams, redirect links and approval cards adds 617 B raw / 238 B transfer (6,862,624 ->- // 6,863,241 B raw, 2,066,394 -> 2,066,632 B transfer against 731cb16c2, one machine and build, the diagram- // source check itself loaded with the first diagram). Raised to that build plus the same margin.- // The sidebar Projects menu's Projects home item and its strings add 240 B raw / no transfer (6,862,692 ->- // 6,862,932 B raw, 2,066,441 -> 2,066,440 B transfer against 2aeeceb07e, one machine and build, 96 chunks).- // Merged with main at 2552ee3895 the build measures 6,863,532 B raw / 2,066,692 B transfer (Node 26, 97 chunks).- // Raised to that build plus the same 160 B raw / 189 B transfer margin.- // Slider tracks round to whole screen pixels at any zoom: theme-boot.js publishes --device-px before first- // paint, 1,501 -> 1,847 B (served uncompressed, so 346 B raw and transfer). Raised by that, same margin.- // Main at dcf5c4009 measures 6,870,312 B raw / 2,068,954 B transfer, already over the line above. Browser panel- // page downloads add 1,468 B raw / 354 B transfer on top (6,871,780 B raw, 2,069,308 B transfer, one machine and- // build, Node 24, 97 chunks). Raised to that build plus the same 160 B raw / 189 B transfer margin.- // Browser store sync across windows (#14277) adds 545 B raw / 288 B transfer on top (6,872,325 B raw, 2,069,596 B- // transfer merged with main at 4962983b0, Node 24, 97 chunks). Raised to that plus the same margin.- // The runtime update card's skip and Undo (#14436) add 1,706 B raw / 424 B transfer against 444f63275c.- // Finished chat replies render lone markdown markers as written, cut ones keep the repair (#14391): +179 B raw /- // +52 B transfer measured against main (6,870,298 -> 6,870,477 B raw, one machine and build). Raised by that.- // Picking a preset forgetting a model's remembered sampling (#14128) keeps its preset marks in the eager chat- // runtime store, about 1,860 B raw / 440 B transfer: merged with main at acb31d909b the build measures- // 6,876,062 B raw / 2,070,545 B transfer (Node 24, 97 chunks). Raised to that plus the same margin.- // Sharing a connection with every account adds the shared flags to the eager provider mapping: 180 B raw /- // 20 B transfer (6,862,624 -> 6,862,804 B raw, 2,066,394 -> 2,066,414 B transfer against 723a43b02, one- // machine and build, Node 22, 96 chunks); the share switch itself is in the lazy Connections tab. Raised by that.- // The browser panel's page history (#14283) on top measures 6,876,588 B raw / 2,070,700 B transfer (merged with- // main at 04d2beec9, Node 24, 97 chunks). Raised to that plus the same margin.- // The MCP app tool arguments on the approval card (#14458) in the eager chat UI add 341 B raw / 110 B transfer- // (6,862,706 -> 6,863,047 B raw, 2,066,422 -> 2,066,532 B transfer against 2aeeceb07e, one machine and build,- // 96 chunks). Raised by that.- // Floating panels remembering their dropped spot (#14355) add 701 B raw / 211 B transfer. Raised by that.- // The Settings > Chat memory editor (#14357) keeps its strings in the eager English locale and the AGENTS.md- // cache counter in the chat adapter (the section itself is lazy): +989 B raw / +364 B transfer over main- // (6,863,532 -> 6,864,521 B raw, 2,066,692 -> 2,067,056 B transfer at e08466e82, 97 chunks). Raised by that.- // REAP on the Export page (#14130) passes its options through the eager export runtime store (the card is- // in the lazy export page): +371 B raw / +119 B transfer (6,878,631 -> 6,879,002 B raw, 2,071,507 ->- // 2,071,626 B transfer against 4df9ce74f, one machine and build, Node 24, 97 chunks). Raised by that.- // The NPU setup card (#14524): +439 B raw / +122 B transfer against fc91656ff (Node 24, 97 chunks), where main- // was already 1 B transfer over; transfer set to the measured build, raw raised by the growth.- // #14524 set transfer to its own measured build with no headroom; merged next to #14508 the startup set- // compresses 7 B larger (2_071_823 B at 5ab80ffdb4, Node 24), so main is over. Measured + 189 B, raw unchanged- // (already 244 B above the measured 6_879_345).- // Chat fork affordances (the sidebar fork mark, the "Forked from" divider and the shared fork toasts) in the- // eager chat chunk: +1_460 B raw / +361 B transfer against 77e742c8e2 (6_879_345 -> 6_880_805 raw,- // 2_071_823 -> 2_072_184 transfer, 97 chunks). Raised by that growth.- // Projects recency and the polling cuts behind projects and sources (#14586) live in the eager chat chunk:- // +505 B raw / +309 B transfer (6,879,331 -> 6,879,836 B raw, 2,071,848 -> 2,072,157 B transfer against- // 2749eeedaa, one machine and build, Node 26, 97 chunks). Raised by that, on top of the fork affordances above.- // The shared custom folder store and its Undo / already-added toasts in the eager model picker: +557 B raw /- // +627 B transfer against 2749eeedaa (6_879_345 -> 6_879_902 raw, 2_071_823 -> 2_072_450 transfer, 97- // chunks); the folders dialog itself stays lazy. Raised by that, on top of the above.- // Shortcut fixes (#14597): stop action, isModEnter, zoom guard and strings in the eager locales:- // +3,339 B raw / +1,727 B transfer (6,881,936 -> 6,885,275 B raw,- // 2,073,188 -> 2,074,915 B transfer against b2ba86a514, Node 26, 98 chunks). Raised by that.- // Run settings save state and Advanced groups (#14589) merged with main at 8bcbf837bd: 6,725.4 KB raw /- // 2,026.7 KB transfer (Node 24, 98 chunks). Raised to that plus about 200 B.- // #14590 (eager locale strings, help entry, API buttons, update card close) merged with main at 356721b31e:- // 6,729.6 KB raw / 2,027.3 KB transfer (Node 24, 98 chunks). Raised to that plus about 200 B.- // Passive Settings update check: +24 B raw / +43 B transfer against e24fa71e1b- // (6,891,238 -> 6,891,262 raw, 2,076,088 -> 2,076,131 transfer, Node 26). Raised by that.- // Local addresses in the desktop browser panel (#14290): the grant, per-tab bookkeeping and agent check live in- // the eager browser store, executor and panel: +1,808 B raw / +551 B transfer (6,891,248 -> 6,893,056 B raw,- // 2,076,155 -> 2,076,706 B transfer against c2f75c486, one machine and build). Raised to that plus the same margin.- // Opt-in reply times (#14500: the Settings > Chat row, its eager English strings and the reply footer gate):- // +1,514 B raw / +418 B transfer over main (6,891,262 -> 6,892,776 B raw, 2,076,131 -> 2,076,549 B transfer- // merged at c2f75c4, Node 24, 98 chunks). Raised by that, on top of the above.- // #14592 + #14601 (system polling, floating panels) merged with main at 0c001fceb: 6,907,598 B raw /- // 2,080,708 B transfer (Node 26, 98 chunks). Raised to that plus about 200 B.- // Settings API / Remote / LAN strings (#14596) merged with main at 870f37741: 6,907,886 B raw / 2,080,818 B- // transfer (Node 26, 98 chunks). Raised to that plus about 200 B.- // Apple unified-memory fit hint (#14598) merged with main at a29487c52: 6,909,320 B raw / 2,081,284 B- // transfer (Node 26, 98 chunks). Raised to that plus about 200 B.- // Desktop Chat only upgrade (#14593), incl. the Train row opening the full install dialog, merged with main- // at c5a9fe021: 6,912,687 B raw / 2,082,221 B transfer (Node 24, 97 chunks). Raised to that plus about 200 B.- // The MLX PLE and expert offload controls (#14326): +7,406 B raw / +2,073 B transfer, plus about 500 B raw- // (a CI build measured about 100 B over a local one). Raised by that.- // Install Training button under the greyed Train row's hint: +424 B raw / +141 B transfer against ee55c3c9a- // (6,920,512 -> 6,920,936 B raw, 2,084,382 -> 2,084,523 B transfer, Node 24, 97 chunks). Raised by that.- // MOSS-Image (#14552): its two image catalog groups, family label and generation defaults sit in the eager- // catalog the chat chunk imports: +1,298 B raw / +181 B transfer (6,919,946 -> 6,921,244 B raw, 2,084,333 ->- // 2,084,514 B transfer against 4e2838ec5f, 2026-10-22, one machine and build, Node 24, chunk count unchanged- // at 97). Raised by that growth so main's margin stays where it was.- // A chat going back to its model when it is still loaded (#14568): the eager chat model notice and the- // adopt-only pick in the chat runtime, +1,970 B raw / +627 B transfer (6,922,858 -> 6,924,828 B raw,- // 2,085,257 -> 2,085,884 B transfer against 1f5576747, Node 24, 98 chunks), where main was already 315 B raw /- // 239 B transfer over. Set to the measured build plus about 300 B raw / 100 B transfer (CI builds measure- // about 100 B over a local one).- // Hub metadata caching and hidden-row filtering (#14265): +548 B raw / +146 B transfer (6,925,639 ->- // 6,926,187 B raw, 2,086,290 -> 2,086,436 B transfer against 0ee5cfc58, Node 24, 98 chunks), where main- // was already over the line above. Set to the merged build plus about 200 B.- // macOS Desktop stray key text guard (#14815), eager in main.tsx: +278 B raw / +114 B transfer- // (6,925,639 -> 6,925,917 B raw, 2,086,290 -> 2,086,404 B transfer against 14e0178e0, Node 24, chunk count- // unchanged at 98). Raised by +278 B raw / +129 B transfer so main's margin stays where it was.- // Browser use step names, docs link and card fence strip (#14681): +1,089 B raw / +298 B transfer (6,925,028 ->- // 6,926,117 B raw, 2,086,327 -> 2,086,625 B transfer against 394aff8545, Node 26, 99 chunks). Raised by that.- // The waiting-for-approval mark, Desktop attention request and tool_approved handling (#14877): measured- // 6,929,942 B raw / 2,087,788 B transfer merged with main at b3004af53 (Node 24, 99 chunks). Set to- // that plus about 300 B raw / 100 B transfer, as for #14568.- // Skill ZIP import/export (#14181) adds 2,721 B raw / 758 B transfer to the eager Skills dialog- // and locale strings (6,929,934 -> 6,932,655 B raw, 2,087,782 -> 2,088,540 B transfer against- // fb104d2b57, one machine and build, Node 22.23.2, unchanged at 99 chunks). Raised by that growth.- // Language and platform tabs on the API page examples (#15084) add 138 B raw / 53 B transfer: Vite's preload map- // in the entry and settings chunks naming the example box, now a lazy chunk shared by the API page and Settings- // (6,932,829 -> 6,932,967 B raw, 2,088,616 -> 2,088,669 B transfer against cfc593f0bd, Node 26, 99 chunks).- // Per-account chat preferences (#15025): +338 B raw / +93 B transfer over the line above (Node 22.23.2, 99 chunks).- // Live prefill progress, the Generation details setting and the loaded placement readout (#14582): the- // stream frame reader, live store slice, reply footer line and timing tooltip rows in the eager chat- // chunk, +8,585 B raw / +2,268 B transfer over main (6,932,829 -> 6,941,414 B raw, 2,088,586 ->- // 2,090,854 B transfer against 1492952a09, Node 22, 99 chunks). Raised by that on top of #15084 and #15025.- // The pinned Run settings footer adds 25 B raw / 49 B transfer to the eager model picker (6,932,829 -> 6,932,854 B- // raw, 2,088,616 -> 2,088,665 B transfer against 2c2e04474b, Node 26, unchanged at 99 chunks). Raised by that.- // Storage overview in Library and System settings (#15083) adds 360 B raw / 56 B transfer, its strings in the- // eager en locale plus 46 B in the settings chunk; the overview itself is a lazy chunk (6,932,829 -> 6,933,189 B- // raw, 2,088,616 -> 2,088,672 B transfer against cfc593f0bd, Node 26, unchanged at 99 chunks). Raised by that.- // Its "System and Engine" page title adds 11 B raw / 34 B transfer to the eager en locale (6,933,189 -> 6,933,200 B- // raw, 2,088,699 -> 2,088,733 B transfer merged with f49cbdf535, Node 26, 99 chunks). Raised by that.- // Scheduled tasks (#13871) add 15.9 KB raw / 5.0 KB transfer (results poll, unseen dots, strings; page and- // dialog lazy): 6,766.5 -> 6,782.4 KB raw, 2,041.5 -> 2,046.5 KB transfer against main 90164297d, one machine- // and build, Node 24, 105 chunks. Raised by that growth over main's budget.- // The control heights and API page round (#15232) adds 2,639 B raw / 717 B transfer, mostly its token table,- // regenerate and tooltip strings in the eager locales (6,945,181 -> 6,947,820 B raw, 2,095,616 -> 2,096,333 B- // transfer against 6eeb690f8d, one machine and build, 105 chunks). Raised by that growth.- // The run settings dropdown per model (#15247: saved settings store, dropdown, pencil and Reset to Default)- // adds 9.9 KB raw / 3.2 KB transfer inside the eager model config page: 6,787.4 -> 6,797.3 KB raw, 2,047.9 ->- // 2,051.1 KB transfer against d4be247222, one machine and build, Node 26, 105 chunks. Raised by that growth.- // Settings and the row menu on the loaded model in Recommended (#15249) add 82 B raw / 176 B transfer to the eager- // model picker (6,960,469 -> 6,960,551 B raw, 2,100,277 -> 2,100,453 B transfer against c9ddc5ab5e, one machine and- // build, Node 26, 105 chunks). Raised by that growth.- // Cosmos3 video families (#14554): +466 B raw / +218 B transfer. Raised by that.- // Lookup-table pricing (#14465): +1,517 B raw / +470 B transfer on top of the lines above (measured merged with- // 4db3eaeb55, Node 24, 99 chunks).- // Chat pins synced through the server (#15293): the sync runtime is a lazy chunk, but the modules it shares- // with startup code (chat-settings-api, sidebar-organization-keys) split into their own eager chunks, plus the- // mount hook and store wiring: +3,074 B raw / +2,025 B transfer (6,958,762 -> 6,961,836 B raw, 2,099,260 ->- // 2,101,285 B transfer against 9c397197e0, Node 24, 106 -> 109 chunks). Raised by that growth.- // Mermaid, node-forge and js-yaml load on first use: -998.5 KB raw / -260.1 KB transfer against 4e673d32e.- // Lowered by that, so the headroom stays what it was and a regression of that size fails here.- // Full Access from a tool approval card (#15485: per-chat grant store and the card's confirm dialog) adds- // 5,293 B raw / 1,953 B transfer to the eager chat chunk (5,940,337 -> 5,945,630 B raw, 1,835,497 ->- // 1,837,450 B transfer against 8222149ee, Node 24, 85 chunks). Raised by that growth.- // The Trick or treat row (#15678) merged in between, unmeasured, and adds 29,984 B raw / 10,952 B transfer- // (5,942,150 -> 5,972,134 B raw, 1,836,750 -> 1,847,702 B transfer, ed9857c0c3 -> 39b8a6ce13, Node 24,- // 85 chunks): its color themes are read by the theme store at startup, and loading its dialog on first- // open saves 3 KB transfer but adds five startup chunks. Raised by that growth.- // The GPU rendering setting (#15482) adds 1,948 B raw / 637 B transfer (5,977,895 -> 5,979,843 B raw,- // 1,849,311 -> 1,849,948 B transfer against b80df648bf, one machine and build, Node 22, 85 chunks both): the app- // provider reports a ready renderer through the setting's API module at startup, plus the setting's strings in- // the eager English catalog and its search rows. Raised by that.- // Chat wallpaper prefs, reset and English strings: +6,365 B raw / +3,589 B transfer (Node 24,- // 85 -> 89 eager chunks). Renderer, contrast and pixel worker stay lazy.- transferBytes: 1_853_999,- rawBytes: 5_997_755,+ // Keep the prior headroom when measured startup imports move out of the entry graph.+ transferBytes: 1_271_720,+ rawBytes: 3_971_182,};// Chunk count is not budgeted: splitting a page out raises it while lowering bytes.-/** Lowercased tag name and attributes; a valueless attribute has value "". */type StartTag = { name: string; attrs: Map<string, string> };/** ASCII whitespace; CR is defensive since the HTML preprocessor turns CR into LF. */@@ -541,10 +106,7 @@ function endOfScriptBody(html: string, start: number): number {const TAG_NAME_START = /[a-z]/i;-/**- * Every start tag in order, skipping comments and script bodies as the browser does.- * Escaped `<!-- <script` bodies may over-count a chunk, never miss one (checked vs parse5).- */+// Escaped `<!-- <script` bodies may over-count a chunk, never miss one (checked vs parse5).function* startTags(html: string): Generator<StartTag> {let i = 0;while (i < html.length) {@@ -583,9 +145,7 @@ function relTokens(tag: StartTag): string[] {return (attr(tag, "rel") ?? "").toLowerCase().split(/\s+/).filter(Boolean);}-/**- * blocking="render" delays first render for any external script, async included (HTML spec).- */+// blocking="render" delays first render even for async scripts (HTML spec).function blocksRender(tag: StartTag): boolean {return (attr(tag, "blocking") ?? "").toLowerCase()@@ -593,10 +153,7 @@ function blocksRender(tag: StartTag): boolean {.includes("render");}-/**- * Eager set relative to dist/. entry and preloads stay separate so missing preload links are- * detectable; `blocking` holds parser-blocking classic scripts like public/theme-boot.js.- */+// Separate entry/preloads so a missing preload closure cannot pass the budget.export type EagerSet = {entry: string[];preloads: string[];@@ -671,14 +228,9 @@ export function eagerChunksFromHtml(html: string): string[] {return [...blocking, ...entry, ...preloads];}-/**- * Text that marks React-preview runtime code. The preview libraries and the bootstrap that imports- * them are only ever fetched when a preview opens, so either string in a startup chunk means that- * code was pulled onto the startup path: a static import where a lazy one was meant.- */+// Preview runtime markers must stay outside the startup graph.export const LAZY_ONLY_NEEDLES = ["__unslothModules", "__vite_ssr_import__"];-/** Every (chunk, needle) pair where an eager chunk contains a needle. A chunk that cannot be read is skipped. */export function eagerChunksContaining(distDir: string,chunks: string[],@@ -717,7 +269,6 @@ function measure(names: string[]): Measured[] | string {try {bytes = readFileSync(join(DIST, name));} catch {- // Report it: concluding the budget is fine must never be reachable here.return `dist/index.html references ${name}, which is not in the build`;}out.push({diff --git a/studio/frontend/src/app/provider.tsx b/studio/frontend/src/app/provider.tsxindex bd1ef02faea..f634042ed0a 100644--- a/studio/frontend/src/app/provider.tsx+++ b/studio/frontend/src/app/provider.tsx@@ -24,9 +24,9 @@ import {usePlatformStore,} from "@/config/env";import { getTauriAuthFailure, tauriAutoAuth } from "@/features/auth";-import { resyncInferenceStatusAfterServerModelChange } from "@/features/chat";+import { resyncInferenceStatusAfterServerModelChange } from "@/features/chat/hooks/use-chat-model-runtime";import { DeepLinkHandler } from "@/features/deep-links";-import { receiveSharedRunConfigUrls } from "@/features/model-picker";+import { receiveSharedRunConfigUrls } from "@/features/model-picker/sharing/receive-link";import {DownloadManagerPanel,dismissStartToasts,@@ -36,16 +36,19 @@ import { NativeIntentDrain } from "@/features/native-intents/native-intent-drainimport {NATIVE_MAC_TITLEBAR_HEIGHT_VAR,NATIVE_MAC_TRAFFIC_LIGHT_INSET_VAR,- applyCustomizationToDocument,- applyInterfaceScale,getAppliedInterfaceZoom,- notifyRendererReady,subscribeAppliedInterfaceZoom,+} from "@/features/settings/lib/interface-scale-runtime";+import {+ applyCustomizationToDocument,useAppearanceCustomStore,+} from "@/features/settings/stores/appearance-custom-store";+import {+ applyInterfaceScale,useInterfaceScaleStore,- usePalette,- useTheme,-} from "@/features/settings";+} from "@/features/settings/stores/interface-scale-store";+import { notifyRendererReady } from "@/features/settings/api/gpu-rendering";+import { usePalette, useTheme } from "@/features/settings/stores/theme-store";import { SttDownloadPrompt } from "@/features/settings/components/stt-download-prompt";import { TauriRepairContext } from "@/hooks/tauri-repair-context";import { TauriUpdateContext } from "@/hooks/tauri-update-context";diff --git a/studio/frontend/src/app/routes/__root.tsx b/studio/frontend/src/app/routes/__root.tsxindex 3150609db95..b5fba5e5ed6 100644--- a/studio/frontend/src/app/routes/__root.tsx+++ b/studio/frontend/src/app/routes/__root.tsx@@ -24,26 +24,23 @@ import {hasSettledAuthSession,useIsAccountOwner,} from "@/features/auth";+import type { ChatSearch } from "@/features/chat/chat-search";+import { loadChatPage, loadedChatPage } from "@/features/chat/load-chat-page";import {- type ChatSearch,- loadChatPage,- loadedChatPage,openFolderAsProject,- startLlamaCppAutoReload,- StopRunningChatsDialog,useOpeningFolder,- useChatRuntimeStore,- usePinnedChatsSync,-} from "@/features/chat";+} from "@/features/chat/utils/open-folder-as-project";+import { startLlamaCppAutoReload } from "@/features/chat/llama-cpp-auto-reload";+import { StopRunningChatsDialog } from "@/features/chat/components/stop-running-chats-dialog";+import { useChatRuntimeStore } from "@/features/chat/stores/chat-runtime-store";+import { usePinnedChatsSync } from "@/features/chat/hooks/use-pinned-chats-sync";import { useExportRuntimeLifecycle } from "@/features/export";import { FIND_SCOPE_ATTRIBUTE, FindInPage } from "@/features/find-in-page";import { HfTokenWarningDialog } from "@/features/hf-auth";import { InterfaceZoom, zoomInterfaceFromMenu } from "@/features/interface-zoom";import { bootstrapPersistedCredentials } from "@/features/credentials/bootstrap";-import {- ManagedEngineOfferDialog,- SharedRunConfigLinkHandler,-} from "@/features/model-picker";+import { ManagedEngineOfferDialog } from "@/features/model-picker/components/managed-engine-offer-dialog";+import { SharedRunConfigLinkHandler } from "@/features/model-picker/sharing/link-handler";import { backfillModelOverrides } from "@/features/model-picker/api/migrate-model-overrides";import { hydratePins } from "@/lib/pins-mirror";import { usePersonalizationSync } from "@/features/profile";@@ -52,22 +49,24 @@ import { ScheduledTaskRunNotifier } from "@/features/scheduled-tasks/run-notifieimport { RemoteCodeConsentDialog } from "@/features/security";import {SETTINGS_TABS,- SettingsDialogMount,- settingsTabVisible,- triggerShortcut,- useHubSourceNotice,useSettingsDialogStore,+} from "@/features/settings/stores/settings-dialog-store";+import { SettingsDialogMount } from "@/features/settings/settings-dialog-mount";+import { settingsTabVisible } from "@/features/settings/settings-tab-visibility";+import {+ triggerShortcut,useShortcut,useShortcutAvailable,- useVoiceSettingsStore,-} from "@/features/settings";+} from "@/features/settings/hooks/use-shortcut";+import { useHubSourceNotice } from "@/features/settings/hooks/use-hub-source-notice";+import { useVoiceSettingsStore } from "@/features/settings/stores/voice-settings-store";import { reconcileSttDevicePreference } from "@/features/settings/api/stt-device";import { useLowDiskNotice } from "@/features/settings/hooks/use-low-disk-notice";-import { useTrainingUnloadGuard } from "@/features/training";+import { useTrainingUnloadGuard } from "@/features/training/hooks/use-training-unload-guard";import { TransformersUpgradeDialog } from "@/features/transformers-upgrade";import { LlmCompressorConsentDialog } from "@/features/export/components/llm-compressor-consent-dialog";import { useNativePathLeasesSupported } from "@/features/native-intents";-import { useRagAvailabilityStore } from "@/features/rag";+import { useRagAvailabilityStore } from "@/features/rag/api/rag-availability";import { useIsMobileShell } from "@/hooks/use-mobile";import { useSidebarPin } from "@/hooks/use-sidebar-pin";import { useTypeToActivate } from "@/hooks/use-type-to-activate";diff --git a/studio/frontend/src/app/routes/chat.tsx b/studio/frontend/src/app/routes/chat.tsxindex a532bb5e0f4..ee86c66d287 100644--- a/studio/frontend/src/app/routes/chat.tsx+++ b/studio/frontend/src/app/routes/chat.tsx@@ -1,7 +1,7 @@// SPDX-License-Identifier: AGPL-3.0-only// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0-import { validateChatSearch } from "@/features/chat";+import { validateChatSearch } from "@/features/chat/chat-search";import { createRoute } from "@tanstack/react-router";import { requireAuth } from "../auth-guards";import { Route as rootRoute } from "./__root";diff --git a/studio/frontend/src/app/routes/hub.tsx b/studio/frontend/src/app/routes/hub.tsxindex ba081ada8a9..a630f39cb3e 100644--- a/studio/frontend/src/app/routes/hub.tsx+++ b/studio/frontend/src/app/routes/hub.tsx@@ -1,7 +1,10 @@// SPDX-License-Identifier: AGPL-3.0-only// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0-import { HUB_CAPABILITY_FILTERS, type HubCapabilityFilter } from "@/features/hub";+import {+ HUB_CAPABILITY_FILTERS,+ type HubCapabilityFilter,+} from "@/features/hub/lib/model-capabilities";import { hubAudioTaskSearch } from "@/lib/hub-audio-task";import type { PipelineType } from "@huggingface/hub";import { createRoute, lazyRouteComponent } from "@tanstack/react-router";diff --git a/studio/frontend/src/app/routes/library.tsx b/studio/frontend/src/app/routes/library.tsxindex e6903b15a78..8e8d8e551b3 100644--- a/studio/frontend/src/app/routes/library.tsx+++ b/studio/frontend/src/app/routes/library.tsx@@ -2,7 +2,7 @@// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0import { createRoute, lazyRouteComponent } from "@tanstack/react-router";-import { validateLibrarySearch } from "@/features/library";+import { validateLibrarySearch } from "@/features/library/search";import { requireAuth } from "../auth-guards";import { Route as rootRoute } from "./__root";diff --git a/studio/frontend/src/app/routes/settings.tsx b/studio/frontend/src/app/routes/settings.tsxindex 04e13adbe4e..e26bd705a50 100644--- a/studio/frontend/src/app/routes/settings.tsx+++ b/studio/frontend/src/app/routes/settings.tsx@@ -3,7 +3,7 @@import { createRoute, redirect } from "@tanstack/react-router";import { getPostAuthRoute } from "@/features/auth";-import { useSettingsDialogStore } from "@/features/settings";+import { useSettingsDialogStore } from "@/features/settings/stores/settings-dialog-store";import { requireAuth } from "../auth-guards";import { Route as rootRoute } from "./__root";diff --git a/studio/frontend/src/app/use-app-menu-actions.ts b/studio/frontend/src/app/use-app-menu-actions.tsindex 820646132d4..db59f0b23c9 100644--- a/studio/frontend/src/app/use-app-menu-actions.ts+++ b/studio/frontend/src/app/use-app-menu-actions.ts@@ -1,7 +1,7 @@// SPDX-License-Identifier: AGPL-3.0-only// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0-import { useKeyboardShortcutsStore } from "@/features/settings";+import { useKeyboardShortcutsStore } from "@/features/settings/stores/keyboard-shortcuts-store";import { isMacPlatform } from "@/features/settings/lib/keyboard-shortcuts";import { isTauri } from "@/lib/api-base";import { useEffect, useMemo, useRef } from "react";diff --git a/studio/frontend/src/components/app-sidebar.tsx b/studio/frontend/src/components/app-sidebar.tsxindex 966b5960c5c..1748372e5db 100644--- a/studio/frontend/src/components/app-sidebar.tsx+++ b/studio/frontend/src/components/app-sidebar.tsx@@ -56,6 +56,7 @@ import {watchApprovalWaiting,} from "@/features/chat/utils/approval-waiting";import { keepOpenedChats, touchOpenedChat } from "@/features/chat/utils/opened-chats";+import { liveThreadBranch } from "@/features/chat/utils/live-thread-head";import { isAssistantLocalThreadId } from "@/features/chat/utils/thread-ids";import {HELP_GROUPS,@@ -166,41 +167,58 @@ import {} from "@tanstack/react-router";import {archiveChatItem,- ChatSearchDialog,+ deleteChatItem,+ renameChatItem,+ type SidebarItem,+} from "@/features/chat/hooks/use-chat-sidebar-items";+import { ChatSearchDialog } from "@/features/chat/components/chat-search-dialog";+import {canForkChatRow,- EditProjectDialog,forkChatRow,- showForkCreatedToast,- showForkFailedToast,getSidebarItemThreadIds,- useForkInFlight,sandboxSessionIdsHolding,+} from "@/features/chat/components/chat-row-menu";+import { EditProjectDialog } from "@/features/chat/components/edit-project-dialog";+import {+ showForkCreatedToast,+ showForkFailedToast,+} from "@/features/chat/utils/fork-toast";+import { useForkInFlight } from "@/features/chat/utils/fork-in-flight";+import {deleteChatProject,- deleteChatItem,moveChatItemToProject,- notifyChatHistoryUpdated,- renameChatItem,- useChatRuntimeStore,useChatProjects,- useChatSearchStore,- useSidebarRowPages,- fetchSidebarRowPage,+} from "@/features/chat/hooks/use-chat-projects";+import {+ notifyChatHistoryUpdated,CHAT_HISTORY_UPDATED_EVENT,fetchSidebarThreadRows,+} from "@/features/chat/api/chat-api";+import { useChatRuntimeStore } from "@/features/chat/stores/chat-runtime-store";+import { useChatSearchStore } from "@/features/chat/stores/chat-search-store";+import {+ useSidebarRowPages,+ fetchSidebarRowPage,readAllSidebarRowIds,readAllSidebarRows,type SidebarRowSlot,+} from "@/features/chat/hooks/use-sidebar-row-pages";+import {sidebarRowQuery,holdRowsPastLoadedChats,mergeManualOrderTail,settledManualOrder,SIDEBAR_PAGE_SIZE,- usePinnedChatsStore,- usePinnedProjectsStore,+} from "@/features/chat/utils/sidebar-row-query";+import { usePinnedChatsStore } from "@/features/chat/stores/pinned-chats-store";+import { usePinnedProjectsStore } from "@/features/chat/stores/pinned-projects-store";+import {rangeBetween,toggleSelected,- useChatPreferencesStore,- usePromptQueueUI,+} from "@/features/chat/utils/row-selection";+import { useChatPreferencesStore } from "@/features/chat/stores/chat-preferences-store";+import { usePromptQueueUI } from "@/features/chat/stores/prompt-queue-ui-store";+import {useSidebarOrganizationStore,applyManualOrder,showsInRecents,@@ -220,8 +238,9 @@ import {type SidebarCustomSection,type SidebarOrganizeBy,type SidebarProjectSort,- type ProjectRecord,- type SidebarItem,+} from "@/features/chat/stores/sidebar-organization-store";+import type { ProjectRecord } from "@/features/chat/types";+import {type ChatNavigationState,adjacentChatItem,countUnreadRows,@@ -229,12 +248,14 @@ import {openChatItemById,recentChatItemAtSlot,useChatNavigationStore,- SectionNameDialog,- removeCustomSectionWithUndo,+} from "@/features/chat/stores/chat-navigation-store";+import { SectionNameDialog } from "@/features/chat/components/section-name-dialog";+import { removeCustomSectionWithUndo } from "@/features/chat/stores/remove-custom-section";+import {sectionKeyLanding,useSectionDrag,- prefetchChatPage,-} from "@/features/chat";+} from "@/features/chat/hooks/use-section-drag";+import { prefetchChatPage } from "@/features/chat/load-chat-page";import {imeOwnsInputKeydown,inputImeHandlers,@@ -246,15 +267,17 @@ import { NewProjectDialog } from "@/features/chat/components/new-project-dialog"import {sidebarNavRowPinned,useAppearanceCustomStore,- useSettingsDialogStore,+ prefersReducedMotion,+} from "@/features/settings/stores/appearance-custom-store";+import { useSettingsDialogStore } from "@/features/settings/stores/settings-dialog-store";+import {isSurfaceBackgrounded,useShortcutLabel,- Shortcut,- type ShortcutId,useShortcut,- prefersReducedMotion,- FullInstallDialog,-} from "@/features/settings";+} from "@/features/settings/hooks/use-shortcut";+import { Shortcut } from "@/features/settings/components/shortcut";+import type { ShortcutId } from "@/features/settings/lib/keyboard-shortcuts";+import { FullInstallDialog } from "@/features/settings/components/full-install-dialog";import type {SidebarNavItemId,SidebarNavItemPref,@@ -275,17 +298,21 @@ import {import { TOUR_OPEN_EVENT, getTourId, useTourAvailable } from "@/features/tour";import {deleteTrainingRun,+ renameTrainingRun,+} from "@/features/training/api/history-api";+import {emitTrainingRunDeleted,emitTrainingRunUpdated,- getTrainingRunDisplayTitle,+} from "@/features/training/events";+import { getTrainingRunDisplayTitle } from "@/features/training/lib/run-display";+import {isTrainingStartPending,- removeTrainingUnloadGuard,- renameTrainingRun,- useDuplicateTrainingRun,- useTrainingCompletionWatch,- useTrainingHistorySidebarItems,useTrainingRuntimeStore,-} from "@/features/training";+} from "@/features/training/stores/training-runtime-store";+import { removeTrainingUnloadGuard } from "@/features/training/hooks/use-training-unload-guard";+import { useDuplicateTrainingRun } from "@/features/training/hooks/use-duplicate-training-run";+import { useTrainingCompletionWatch } from "@/features/training/hooks/use-training-completion-watch";+import { useTrainingHistorySidebarItems } from "@/features/training/hooks/use-training-history-sidebar";import type { TrainingRunSummary } from "@/features/training";import { useExportRuntimeStore } from "@/features/export";import {@@ -303,17 +330,18 @@ import { toast } from "@/lib/toast";import {folderRingKey,sectionRingKey,- DROP_CUE_CLASS,SIDEBAR_TAIL_SCOPE,- useSidebarDrag,type SidebarDragItem,type SidebarDropContext,type SidebarDropEffects,type SidebarDropPlan,type SidebarSection,-} from "@/features/chat";+} from "@/features/chat/lib/sidebar-drag";+import {+ DROP_CUE_CLASS,+ useSidebarDrag,+} from "@/features/chat/hooks/use-sidebar-drag";import { ShutdownDialog } from "@/components/shutdown-dialog";-import { buildChatItemMarkdown } from "@/features/chat/prompt-storage/prompt-storage-dialog";import { useActiveChatMenuStore } from "@/features/chat/stores/active-chat-menu-store";import { type PinnedPage, PinnedPageRow, usePinnedPages } from "@/features/browser";import { useUnseenScheduledRuns } from "@/features/scheduled-tasks";@@ -3924,10 +3952,14 @@ export function AppSidebar() {}async function copyChatItemAsMarkdown(item: SidebarItem) {+ const liveBranch = item.type === "single" ? liveThreadBranch(item.id) : undefined;const empty = { value: false };// Read inside the write: Safari drops the gesture across an await.const copied = await copyToClipboardFrom(async () => {- const markdown = await buildChatItemMarkdown(item);+ const { buildChatItemMarkdown } = await import(+ "@/features/chat/prompt-storage/prompt-storage-dialog"+ );+ const markdown = await buildChatItemMarkdown(item, liveBranch);if (!markdown) {empty.value = true;throw new Error("nothing to copy");diff --git a/studio/frontend/src/components/command-palette.tsx b/studio/frontend/src/components/command-palette.tsxindex 6ba680e1205..54dfb96c640 100644--- a/studio/frontend/src/components/command-palette.tsx+++ b/studio/frontend/src/components/command-palette.tsx@@ -13,19 +13,21 @@ import {CommandShortcut,} from "@/components/ui/command";import { useIsAccountOwner } from "@/features/auth";-import { useChatSearchStore } from "@/features/chat";+import { useChatSearchStore } from "@/features/chat/stores/chat-search-store";+import { DIALOG_SETTINGS_SEARCH_INDEX } from "@/features/settings/dialog-search-index";import {- DIALOG_SETTINGS_SEARCH_INDEX,SETTINGS_TABS,type SettingsTab,- type ShortcutId,- settingsTabVisible,- triggerShortcut,useSettingsDialogStore,+} from "@/features/settings/stores/settings-dialog-store";+import type { ShortcutId } from "@/features/settings/lib/keyboard-shortcuts";+import { settingsTabVisible } from "@/features/settings/settings-tab-visibility";+import {+ triggerShortcut,useShortcut,useShortcutAvailable,useShortcutLabel,-} from "@/features/settings";+} from "@/features/settings/hooks/use-shortcut";import { useT, type TranslationKey } from "@/i18n";import { cn } from "@/lib/utils";import { useCommandPaletteStore } from "@/stores/command-palette";diff --git a/studio/frontend/src/components/floating-monitor.tsx b/studio/frontend/src/components/floating-monitor.tsxindex 206623aea01..34746d1e4fe 100644--- a/studio/frontend/src/components/floating-monitor.tsx+++ b/studio/frontend/src/components/floating-monitor.tsx@@ -8,7 +8,7 @@ import { Progress } from "@/components/ui/progress";import { useChatRuntimeStore } from "@/features/chat/stores/chat-runtime-store";import { FIND_PORTAL_ATTRIBUTE } from "@/features/find-in-page/lib/find-attributes";-import { useMonitorOverlayStore } from "@/features/settings";+import { useMonitorOverlayStore } from "@/features/settings/stores/monitor-overlay-store";import { useCornerCardFrameStore } from "@/features/settings/stores/monitor-frame-store";import { gpuMemoryDisplay } from "@/hooks/gpu-memory-display";import { gpuMemoryTotalsGb, resolveGpuVramUsedGb } from "@/hooks/gpu-vram";diff --git a/studio/frontend/src/components/help-actions.ts b/studio/frontend/src/components/help-actions.tsindex 34f99f1526e..58fb824830f 100644--- a/studio/frontend/src/components/help-actions.ts+++ b/studio/frontend/src/components/help-actions.ts@@ -1,7 +1,11 @@// SPDX-License-Identifier: AGPL-3.0-only// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0-import { type SettingsTab, settingsTabVisible, useSettingsDialogStore } from "@/features/settings";+import {+ type SettingsTab,+ useSettingsDialogStore,+} from "@/features/settings/stores/settings-dialog-store";+import { settingsTabVisible } from "@/features/settings/settings-tab-visibility";import type { TranslationKey } from "@/i18n";import { ChipIcon } from "@/lib/hugeicons-derived";import { openLink } from "@/lib/open-link";diff --git a/studio/frontend/src/components/llama-update-banner.tsx b/studio/frontend/src/components/llama-update-banner.tsxindex 3271832a439..1558277a747 100644--- a/studio/frontend/src/components/llama-update-banner.tsx+++ b/studio/frontend/src/components/llama-update-banner.tsx@@ -3,7 +3,7 @@import { Button } from "@/components/ui/button";import { LlamaUpdateChangelogPanel } from "@/components/update/llama-update-changelog-panel";-import { resyncInferenceStatusAfterServerModelChange } from "@/features/chat";+import { resyncInferenceStatusAfterServerModelChange } from "@/features/chat/hooks/use-chat-model-runtime";import { LLAMA_BACKEND_LABELS } from "@/features/settings/lib/llama-backend-labels";import {llamaUpdateOffered,diff --git a/studio/frontend/src/components/segmented-pill-slide.ts b/studio/frontend/src/components/segmented-pill-slide.tsindex 3f7cb9f78f9..872a88b6f9e 100644--- a/studio/frontend/src/components/segmented-pill-slide.ts+++ b/studio/frontend/src/components/segmented-pill-slide.ts@@ -1,7 +1,7 @@// SPDX-License-Identifier: AGPL-3.0-only// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0-import { prefersReducedMotion } from "@/features/settings";+import { prefersReducedMotion } from "@/features/settings/stores/appearance-custom-store";// Slides a segmented control's selected pill from the old segment to the new one// without running script per frame or forcing layout during the click:diff --git a/studio/frontend/src/components/ui/animated-theme-toggler.tsx b/studio/frontend/src/components/ui/animated-theme-toggler.tsxindex b5bb0f6ddf6..1ed47ae798c 100644--- a/studio/frontend/src/components/ui/animated-theme-toggler.tsx+++ b/studio/frontend/src/components/ui/animated-theme-toggler.tsx@@ -7,7 +7,8 @@ import { HugeiconsIcon } from "@hugeicons/react"import { flushSync } from "react-dom"import { cn } from "@/lib/utils"-import { prefersReducedMotion, setTheme } from "@/features/settings"+import { prefersReducedMotion } from "@/features/settings/stores/appearance-custom-store"+import { setTheme } from "@/features/settings/stores/theme-store"import { isWebKitGTK } from "./theme-view-transition"interface AnimatedThemeTogglerProps extends React.ComponentPropsWithoutRef<"button"> {diff --git a/studio/frontend/src/components/update/release-notes-panel.tsx b/studio/frontend/src/components/update/release-notes-panel.tsxindex 301014f7623..ecce5c3ec2a 100644--- a/studio/frontend/src/components/update/release-notes-panel.tsx+++ b/studio/frontend/src/components/update/release-notes-panel.tsx@@ -1,7 +1,6 @@// SPDX-License-Identifier: AGPL-3.0-only// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0-import { MarkdownPreview } from "@/components/markdown/markdown-preview";import {UPDATE_NOTES_BULLET_CLASS,UPDATE_NOTES_EXPANDED_SCROLL_CLASS,@@ -19,11 +18,63 @@ import { releaseNotesPreview } from "@/lib/release-notes-preview";import {type ReactElement,type ReactNode,+ useCallback,useEffect,useMemo,useRef,+ useState,} from "react";+type MarkdownPreviewComponent =+ typeof import("@/components/markdown/markdown-preview")["MarkdownPreview"];++let markdownPreviewModule: Promise<MarkdownPreviewComponent> | null = null;+let loadedMarkdownPreview: MarkdownPreviewComponent | null = null;++function loadMarkdownPreview(): Promise<MarkdownPreviewComponent> {+ if (!markdownPreviewModule) {+ markdownPreviewModule = import("@/components/markdown/markdown-preview").then(+ (module) => {+ loadedMarkdownPreview = module.MarkdownPreview;+ return module.MarkdownPreview;+ },+ (error: unknown) => {+ markdownPreviewModule = null;+ throw error;+ },+ );+ }+ return markdownPreviewModule;+}++function useMarkdownPreview(): {+ Preview: MarkdownPreviewComponent | null;+ failed: boolean;+ retry: () => void;+} {+ const [Preview, setPreview] = useState(() => loadedMarkdownPreview);+ const [failed, setFailed] = useState(false);+ useEffect(() => {+ if (Preview || failed) return;+ let live = true;+ loadMarkdownPreview().then(+ (component) => {+ if (live) setPreview(() => component);+ },+ () => {+ if (live) setFailed(true);+ },+ );+ return () => {+ live = false;+ };+ }, [Preview, failed]);+ const retry = useCallback(() => {+ window.location.reload();+ }, []);+ return { Preview, failed, retry };+}+interface ReleaseNotesPanelProps {version: string;open: boolean;@@ -74,6 +125,7 @@ export function ReleaseNotesPanel({const t = useT();// Fetched with the popup: the collapsed preview needs the notes too.const { state, notes, retry } = useReleaseNotes({ version, enabled: true });+ const renderer = useMarkdownPreview();const scrollRef = useRef<HTMLElement | null>(null);// No fallback body: the updater's `notes` is install boilerplate the backend strips.@@ -91,11 +143,12 @@ export function ReleaseNotesPanel({);// Start at the top on expand, and again once async notes land.+ const Preview = renderer.Preview;useEffect(() => {- if (open && markdown && scrollRef.current) {+ if (open && markdown && Preview && scrollRef.current) {scrollRef.current.scrollTop = 0;}- }, [open, markdown]);+ }, [open, markdown, Preview]);// The page the notes are on wins, then the caller's URL, then the API's.const notesUrl = notes?.htmlUrl ?? releaseNotesUrl ?? notes?.releaseNotesUrl;@@ -141,11 +194,21 @@ export function ReleaseNotesPanel({className={UPDATE_NOTES_EXPANDED_SCROLL_CLASS}data-testid="update-release-notes-scroll">- <MarkdownPreview- markdown={markdown}- // Rescale Streamdown's headings, code and max-width; `anywhere` splits words.- className="max-h-none overflow-visible border-0 bg-transparent p-0 text-ui-11 [&_[data-streamdown=link-safety-modal]>*]:max-w-md [&_img]:h-auto [&_img]:max-w-full [&>*:first-child]:mt-0 [&>*>*:first-child]:mt-0 [&_code]:text-[0.92em] [&_h1]:mt-4 [&_h1]:font-heading [&_h1]:text-ui-13 [&_h2]:mt-4 [&_h2]:font-heading [&_h2]:text-ui-13 [&_h3]:mt-4 [&_h3]:font-heading [&_h3]:text-ui-11 [&_pre]:text-[0.92em] [&_td]:break-words [&_th]:break-words"- />+ {Preview ? (+ <Preview+ markdown={markdown}+ // Rescale Streamdown's headings, code and max-width; `anywhere` splits words.+ className="max-h-none overflow-visible border-0 bg-transparent p-0 text-ui-11 [&_[data-streamdown=link-safety-modal]>*]:max-w-md [&_img]:h-auto [&_img]:max-w-full [&>*:first-child]:mt-0 [&>*>*:first-child]:mt-0 [&_code]:text-[0.92em] [&_h1]:mt-4 [&_h1]:font-heading [&_h1]:text-ui-13 [&_h2]:mt-4 [&_h2]:font-heading [&_h2]:text-ui-13 [&_h3]:mt-4 [&_h3]:font-heading [&_h3]:text-ui-11 [&_pre]:text-[0.92em] [&_td]:break-words [&_th]:break-words"+ />+ ) : (+ <NotesStatus+ state={renderer.failed ? "error" : "loading"}+ release={notes?.tag ?? null}+ link={link}+ retry={renderer.retry}+ retryLabel={t("settings.dialog.panelReload")}+ />+ )}{notes?.truncated ? (<p className="mt-2 text-ui-10 text-muted-foreground/80">{t("updateNotes.notesTruncated")}@@ -221,11 +284,13 @@ function NotesStatus({release,link,retry,+ retryLabel,}: {state: ReturnType<typeof useReleaseNotes>["state"];release: string | null;link: ReactNode;retry: () => void;+ retryLabel?: string;}): ReactElement {const t = useT();if (state === "loading" || state === "idle") {@@ -244,7 +309,7 @@ function NotesStatus({className={UPDATE_NOTES_LINK_CLASS}data-testid="update-release-notes-retry">- {t("updateNotes.retry")}+ {retryLabel ?? t("updateNotes.retry")}</button>{link}</span>diff --git a/studio/frontend/src/features/api-monitor/api-monitor-overlay.tsx b/studio/frontend/src/features/api-monitor/api-monitor-overlay.tsxindex a8c055bc8aa..3136d85a14c 100644--- a/studio/frontend/src/features/api-monitor/api-monitor-overlay.tsx+++ b/studio/frontend/src/features/api-monitor/api-monitor-overlay.tsx@@ -8,7 +8,8 @@ import type {ApiMonitorResponse,} from "@/features/chat/types/api";import { FIND_PORTAL_ATTRIBUTE } from "@/features/find-in-page/lib/find-attributes";-import { useMonitorFrameStore, useShortcut } from "@/features/settings";+import { useMonitorFrameStore } from "@/features/settings/stores/monitor-frame-store";+import { useShortcut } from "@/features/settings/hooks/use-shortcut";import { FLOATING_PANEL_POSITION_KEYS } from "@/hooks/floating-panel-position";import { useFloatingPanelLayout } from "@/hooks/use-floating-panel-layout";import {diff --git a/studio/frontend/src/features/browser/browser-toggle.tsx b/studio/frontend/src/features/browser/browser-toggle.tsxindex 5140250c7e6..1be9a52983e 100644--- a/studio/frontend/src/features/browser/browser-toggle.tsx+++ b/studio/frontend/src/features/browser/browser-toggle.tsx@@ -8,7 +8,10 @@ import {DropdownMenuShortcut,DropdownMenuTrigger,} from "@/components/ui/dropdown-menu";-import { useShortcut, useShortcutLabel } from "@/features/settings";+import {+ useShortcut,+ useShortcutLabel,+} from "@/features/settings/hooks/use-shortcut";import { useT } from "@/i18n";import { InternetIcon, PlusSignIcon } from "@hugeicons/core-free-icons";import { HugeiconsIcon } from "@hugeicons/react";diff --git a/studio/frontend/src/features/browser/downloads.ts b/studio/frontend/src/features/browser/downloads.tsindex 123670d9218..68c465b2bf3 100644--- a/studio/frontend/src/features/browser/downloads.ts+++ b/studio/frontend/src/features/browser/downloads.ts@@ -1,7 +1,7 @@// SPDX-License-Identifier: AGPL-3.0-only// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0-import { useChatRuntimeStore } from "@/features/chat";+import { useChatRuntimeStore } from "@/features/chat/stores/chat-runtime-store";import { getLocale, translate } from "@/i18n";import { isTauri } from "@/lib/api-base";import { DownloadCancelledError, downloadFile, isDownloadCancelled } from "@/lib/native-files";diff --git a/studio/frontend/src/features/browser/file-kind.ts b/studio/frontend/src/features/browser/file-kind.tsindex 19d226f55f7..10247fc902a 100644--- a/studio/frontend/src/features/browser/file-kind.ts+++ b/studio/frontend/src/features/browser/file-kind.ts@@ -2,7 +2,7 @@// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0import { documentKind, isMarkdown } from "@/components/file-viewer";-import { attachmentTextLanguage } from "@/features/chat";+import { attachmentTextLanguage } from "@/features/chat/attachment-content";import { mediaKind } from "./media-kind";import { REACT_PREVIEW_TYPE } from "./react-preview-type";diff --git a/studio/frontend/src/features/browser/history-store.ts b/studio/frontend/src/features/browser/history-store.tsindex 29f4af77b2f..8c079f983f3 100644--- a/studio/frontend/src/features/browser/history-store.ts+++ b/studio/frontend/src/features/browser/history-store.ts@@ -3,7 +3,7 @@import { create } from "zustand";import { type StateStorage, createJSONStorage, persist } from "zustand/middleware";-import { useChatRuntimeStore } from "@/features/chat";+import { useChatRuntimeStore } from "@/features/chat/stores/chat-runtime-store";import { accountDatabaseName } from "@/lib/account-transition";import { syncAcrossWindows } from "@/lib/sync-across-windows";import { hostOf } from "./address";diff --git a/studio/frontend/src/features/browser/native-view.ts b/studio/frontend/src/features/browser/native-view.tsindex cd9ca362a56..a79f41396e4 100644--- a/studio/frontend/src/features/browser/native-view.ts+++ b/studio/frontend/src/features/browser/native-view.ts@@ -4,7 +4,7 @@/** desktop web pages use per-tab native views for bot checks. macOS puts each page under the app's webview, so* overlays draw over the live page; elsewhere native views cover the DOM, so overlays use snapshots. */-import { useChatRuntimeStore } from "@/features/chat";+import { useChatRuntimeStore } from "@/features/chat/stores/chat-runtime-store";import { getLocale, translate } from "@/i18n";import type { TranslationKey } from "@/i18n";import type { InterpolationValues } from "@/i18n";diff --git a/studio/frontend/src/features/browser/store.ts b/studio/frontend/src/features/browser/store.tsindex 605b98ac66f..66aa12f84d0 100644--- a/studio/frontend/src/features/browser/store.ts+++ b/studio/frontend/src/features/browser/store.ts@@ -1,7 +1,9 @@// SPDX-License-Identifier: AGPL-3.0-only// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0-import { type DocumentAnnotations, onChatThreadsDeleted, useChatRuntimeStore } from "@/features/chat";+import type { DocumentAnnotations } from "@/features/chat/utils/document-annotations";+import { onChatThreadsDeleted } from "@/features/chat/utils/chat-thread-tombstones";+import { useChatRuntimeStore } from "@/features/chat/stores/chat-runtime-store";import { create } from "zustand";import { localOriginOf, unwrapRedirect } from "./address";import type { BrowserPage } from "./api";diff --git a/studio/frontend/src/features/browser/tab-menu.tsx b/studio/frontend/src/features/browser/tab-menu.tsxindex c1a1d2738bb..1ff8e449ad3 100644--- a/studio/frontend/src/features/browser/tab-menu.tsx+++ b/studio/frontend/src/features/browser/tab-menu.tsx@@ -15,8 +15,8 @@ import {DropdownMenuSubContent,DropdownMenuSubTrigger,} from "@/components/ui/dropdown-menu";-import { useChatRuntimeStore } from "@/features/chat";-import { resetToNewChat } from "@/features/library";+import { useChatRuntimeStore } from "@/features/chat/stores/chat-runtime-store";+import { resetToNewChat } from "@/features/library/start-chat";import { useT } from "@/i18n";import { copyToClipboard } from "@/lib/copy-to-clipboard";import { ForkIcon } from "@/lib/fork-icon";diff --git a/studio/frontend/src/features/chat/api/chat-adapter.ts b/studio/frontend/src/features/chat/api/chat-adapter.tsindex 159f0776f50..a072bfdd5ec 100644--- a/studio/frontend/src/features/chat/api/chat-adapter.ts+++ b/studio/frontend/src/features/chat/api/chat-adapter.ts@@ -45,7 +45,7 @@ import {isServedByMlx,loadedContextFields,resolveInitialConfig,-} from "@/features/model-picker";+} from "@/features/model-picker/model-config/per-model-config";import { isMlxId } from "@/features/model-picker/components/model-selector/recommended-fit";import { loadManagedLlamaFlags } from "@/features/model-picker/api/llama-flags";import { fetchLoadExtraArgs } from "@/features/model-picker/api/model-overrides";diff --git a/studio/frontend/src/features/chat/components/chat-row-menu.ts b/studio/frontend/src/features/chat/components/chat-row-menu.tsindex 243b2af9779..2ade91055d1 100644--- a/studio/frontend/src/features/chat/components/chat-row-menu.ts+++ b/studio/frontend/src/features/chat/components/chat-row-menu.ts@@ -26,13 +26,6 @@ import {useChatRuntimeStore,} from "../stores/chat-runtime-store";import type { SidebarItem } from "../hooks/use-chat-sidebar-items";-import {- exportConversationCsv,- exportConversationMarkdown,- exportConversationMessagesJsonl,- exportConversationRawJsonl,- exportConversationShareGPT,-} from "../prompt-storage/prompt-storage-dialog";import {getStoredChatThread,listStoredChatMessages,@@ -74,17 +67,25 @@ export async function exportConversationByFormat(threadId: string,format: ConversationExportFormat,): Promise<void> {+ const liveBranch = liveThreadBranch(threadId);+ const {+ exportConversationCsv,+ exportConversationMarkdown,+ exportConversationMessagesJsonl,+ exportConversationRawJsonl,+ exportConversationShareGPT,+ } = await import("../prompt-storage/prompt-storage-dialog");switch (format) {case "raw-jsonl":- return exportConversationRawJsonl(threadId);+ return exportConversationRawJsonl(threadId, liveBranch);case "messages-jsonl":- return exportConversationMessagesJsonl(threadId);+ return exportConversationMessagesJsonl(threadId, liveBranch);case "csv":- return exportConversationCsv(threadId);+ return exportConversationCsv(threadId, liveBranch);case "sharegpt-jsonl":- return exportConversationShareGPT(threadId);+ return exportConversationShareGPT(threadId, liveBranch);case CONVERSATION_MARKDOWN_FORMAT:- return exportConversationMarkdown(threadId);+ return exportConversationMarkdown(threadId, liveBranch);default: {const unhandled: never = format;throw new Error(`Unhandled export format: ${String(unhandled)}`);diff --git a/studio/frontend/src/features/chat/components/chat-search-dialog.tsx b/studio/frontend/src/features/chat/components/chat-search-dialog.tsxindex 5ded53046d1..89cc6f9249e 100644--- a/studio/frontend/src/features/chat/components/chat-search-dialog.tsx+++ b/studio/frontend/src/features/chat/components/chat-search-dialog.tsx@@ -10,13 +10,13 @@ import {} from "@/components/ui/command";import {COMPOSER_INPUT_SELECTOR,- type ShortcutId,isImeComposing,triggerShortcut,useShortcut,useShortcutAvailable,useShortcutLabel,-} from "@/features/settings";+} from "@/features/settings/hooks/use-shortcut";+import type { ShortcutId } from "@/features/settings/lib/keyboard-shortcuts";import { type TranslationKey, useT } from "@/i18n";import { MessageCircleIcon, TestTubeOutlineIcon } from "@/lib/hugeicons-derived";import { cn } from "@/lib/utils";@@ -44,14 +44,14 @@ import {useMemo,useState,} from "react";-import {- type CachedInventoryRow,- type LocalInventoryRow,- type ModelInventoryFormat,- isHiddenModelId,- useHubInventory,-} from "@/features/hub";-import { modelLabelKey } from "@/features/library";+import type {+ CachedInventoryRow,+ LocalInventoryRow,+} from "@/features/hub/inventory/types";+import type { ModelInventoryFormat } from "@/features/hub/inventory/api";+import { isHiddenModelId } from "@/features/hub/lib/hidden-models";+import { useHubInventory } from "@/features/hub/inventory/use-hub-inventory";+import { modelLabelKey } from "@/features/library/file-kind";import { useChatProjects } from "../hooks/use-chat-projects";import { useChatSidebarItems } from "../hooks/use-chat-sidebar-items";import {diff --git a/studio/frontend/src/features/chat/components/edit-project-dialog.tsx b/studio/frontend/src/features/chat/components/edit-project-dialog.tsxindex bae8481bc6b..1963913d46e 100644--- a/studio/frontend/src/features/chat/components/edit-project-dialog.tsx+++ b/studio/frontend/src/features/chat/components/edit-project-dialog.tsx@@ -15,7 +15,7 @@ import {import { Textarea } from "@/components/ui/textarea";import type { NativeDocumentFolderSelection } from "@/features/native-intents";import { WorkingFolderPicker } from "./working-folder-picker";-import { LinkedFoldersManager } from "@/features/rag";+import { LinkedFoldersManager } from "@/features/rag/components/linked-folders-manager";import { isModEnter } from "@/features/settings/lib/keyboard-shortcuts";import { toast } from "@/lib/toast";import { HugeiconsIcon } from "@hugeicons/react";diff --git a/studio/frontend/src/features/chat/components/new-project-dialog.tsx b/studio/frontend/src/features/chat/components/new-project-dialog.tsxindex c28223f91b7..ef42123c3e7 100644--- a/studio/frontend/src/features/chat/components/new-project-dialog.tsx+++ b/studio/frontend/src/features/chat/components/new-project-dialog.tsx@@ -16,9 +16,9 @@ import {} from "@/components/ui/dialog";import {linkStagedFolders,- ProjectFolderPicker,type StagedFolder,-} from "@/features/rag";+} from "@/features/rag/components/link-staged-folders";+import { ProjectFolderPicker } from "@/features/rag/components/project-folder-picker";import {ProjectSourceDropzone,type StagedSource,diff --git a/studio/frontend/src/features/chat/hooks/use-chat-model-runtime.ts b/studio/frontend/src/features/chat/hooks/use-chat-model-runtime.tsindex 2e19ad8cbb0..0437cb214fe 100644--- a/studio/frontend/src/features/chat/hooks/use-chat-model-runtime.ts+++ b/studio/frontend/src/features/chat/hooks/use-chat-model-runtime.ts@@ -58,11 +58,9 @@ import {} from "@/features/settings/lib/view-logs-action";import { loadModelMemorySettings } from "@/features/settings/api/model-memory";import { loadVramBudgetSettings } from "@/features/settings/api/vram-budget";-import {- listOpenAIModels,- loadMultiModelEnabled,- loadOpenAIAutoSwitchSettings,-} from "@/features/settings";+import { listOpenAIModels } from "@/features/settings/api/openai-models";+import { loadMultiModelEnabled } from "@/features/settings/api/multi-model";+import { loadOpenAIAutoSwitchSettings } from "@/features/settings/api/openai-auto-switch";import {confirmTransformersUpgradeIfNeeded,useTransformersUpgradeDialogStore,@@ -180,9 +178,6 @@ import { isExternalModelId } from "../external-providers";import {DEFAULT_MAX_SEQ_LENGTH,DEFAULT_PER_MODEL_CONFIG,- applyPerModelConfigToRuntime,- confirmManagedEngineIfNeeded,- currentRuntimePerModelConfig,isServedByMlx,normalizeMaxSeqLength,residentIsServedByMlx,@@ -190,7 +185,12 @@ import {savedContextPin,type PerModelConfig,loadedContextFields,-} from "@/features/model-picker";+} from "@/features/model-picker/model-config/per-model-config";+import {+ applyPerModelConfigToRuntime,+ currentRuntimePerModelConfig,+} from "@/features/model-picker/model-config/apply-per-model-config";+import { confirmManagedEngineIfNeeded } from "@/features/model-picker/hooks/managed-engine-offer";import {invalidateLlamaFlagCatalog,loadManagedLlamaFlags,diff --git a/studio/frontend/src/features/chat/hooks/use-chat-search-sources.ts b/studio/frontend/src/features/chat/hooks/use-chat-search-sources.tsindex c9746655e02..e2174fbee55 100644--- a/studio/frontend/src/features/chat/hooks/use-chat-search-sources.ts+++ b/studio/frontend/src/features/chat/hooks/use-chat-search-sources.ts@@ -4,10 +4,10 @@import { AUTH_SESSION_CLEARED_EVENT } from "@/features/auth";import {KIND_ICONS,- type LibraryItem,fileKind,isModelItem,-} from "@/features/library";+} from "@/features/library/file-kind";+import type { LibraryItem } from "@/features/library/api";import type { IconSvgElement } from "@hugeicons/react";import { useEffect, useState } from "react";diff --git a/studio/frontend/src/features/chat/lib/apply-inference-status-to-store.ts b/studio/frontend/src/features/chat/lib/apply-inference-status-to-store.tsindex ba2812662be..521afc687b3 100644--- a/studio/frontend/src/features/chat/lib/apply-inference-status-to-store.ts+++ b/studio/frontend/src/features/chat/lib/apply-inference-status-to-store.ts@@ -1,16 +1,15 @@// SPDX-License-Identifier: AGPL-3.0-only// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0-// Barrel import (lint rule); the model-picker cycle is fine since the call is at runtime.+import { loadedPlacementFrom } from "./partial-offload";+// eslint-disable-next-line no-restricted-imports -- The model-picker index would put the pickers in the startup bundle.import {adoptCachedRepoConfig,loadedContextFields,+ normalizeMlxKvQuant,resolveResidentInitialConfig,savedContextPin,-} from "@/features/model-picker";-import { loadedPlacementFrom } from "./partial-offload";-// eslint-disable-next-line no-restricted-imports -- Avoid the hub barrel's React and download-manager exports.-import { normalizeMlxKvQuant } from "@/features/model-picker/model-config/per-model-config";+} from "@/features/model-picker/model-config/per-model-config";import { modelDisplayName } from "@/features/hub/lib/model-identity";import { getInferenceStatus } from "../api/chat-api";import { isSpeechOnlyStatus } from "./speech-only-status";diff --git a/studio/frontend/src/features/chat/prompt-storage/prompt-storage-dialog.tsx b/studio/frontend/src/features/chat/prompt-storage/prompt-storage-dialog.tsxindex 012e0e87368..a06d062f103 100644--- a/studio/frontend/src/features/chat/prompt-storage/prompt-storage-dialog.tsx+++ b/studio/frontend/src/features/chat/prompt-storage/prompt-storage-dialog.tsx@@ -114,7 +114,7 @@ import {} from "../utils/conversation-markdown";import { planChatItemSources } from "../utils/project-source-plan";import { stripSearchImageTokens } from "../search-images/search-images.ts";-import { saveMarkdownAsProjectSource } from "@/features/rag";+import { saveMarkdownAsProjectSource } from "@/features/rag/api/save-markdown-source";function newId(): string {return crypto.randomUUID().replace(/-/g, "").slice(0, 12);@@ -240,15 +240,15 @@ async function loadConversationMessages(emptyMessage?: string;includeSiblings?: boolean;includeInstructions?: boolean;+ liveBranch?: string[] | null;} = {},) {const {emptyMessage = "No messages in this conversation to export.",includeSiblings = true,includeInstructions = true,+ liveBranch = liveThreadBranch(threadId),} = options;- // read before awaiting storage so a chat switch cannot redirect the lookup- const liveBranch = liveThreadBranch(threadId);const [raw, instructions] = await Promise.all([listStoredChatMessages(threadId),includeInstructions ? chatInstructionsTurn(threadId) : [],@@ -474,9 +474,13 @@ function messageToOpenAI(msg: { role: unknown; content: unknown; attachments?: u}// ShareGPT training JSONL (human/system/gpt turns).-export async function exportConversationShareGPT(threadId: string): Promise<void> {+export async function exportConversationShareGPT(+ threadId: string,+ liveBranch?: string[] | null,+): Promise<void> {const messages = await loadConversationMessages(threadId, {includeSiblings: exportFormatIncludesSiblings("sharegpt"),+ liveBranch,});if (!messages) return;@@ -497,22 +501,30 @@ export async function exportConversationShareGPT(threadId: string): Promise<void}// OpenAI/ChatML JSONL: {"messages": [{"role","content"}, ...]} per conversation; Unsloth reads this as a ChatML dataset.-export async function exportConversationRawJsonl(threadId: string): Promise<void> {- return exportConversationJsonl(threadId, "training");+export async function exportConversationRawJsonl(+ threadId: string,+ liveBranch?: string[] | null,+): Promise<void> {+ return exportConversationJsonl(threadId, "training", liveBranch);}-export async function exportConversationMessagesJsonl(threadId: string): Promise<void> {- return exportConversationJsonl(threadId, "messages");+export async function exportConversationMessagesJsonl(+ threadId: string,+ liveBranch?: string[] | null,+): Promise<void> {+ return exportConversationJsonl(threadId, "messages", liveBranch);}async function exportConversationJsonl(threadId: string,layout: ConversationJsonlLayout,+ liveBranch?: string[] | null,): Promise<void> {const messages = await loadConversationMessages(threadId, {includeSiblings: exportFormatIncludesSiblings(layout === "training" ? "jsonl-raw" : "jsonl-messages",),+ liveBranch,});if (!messages) return;@@ -525,8 +537,11 @@ async function exportConversationJsonl();}-export async function exportConversationCsv(threadId: string): Promise<void> {- const messages = await loadConversationMessages(threadId);+export async function exportConversationCsv(+ threadId: string,+ liveBranch?: string[] | null,+): Promise<void> {+ const messages = await loadConversationMessages(threadId, { liveBranch });if (!messages) return;const rows = ["role,content"];@@ -546,7 +561,11 @@ export async function exportConversationCsv(threadId: string): Promise<void> {const loadDisplayedBranchMessages = (threadId: string,- options: { emptyMessage?: string; includeInstructions?: boolean } = {},+ options: {+ emptyMessage?: string;+ includeInstructions?: boolean;+ liveBranch?: string[] | null;+ } = {},) => loadConversationMessages(threadId, { ...options, includeSiblings: false });export const buildConversationMarkdownForThread =@@ -555,13 +574,16 @@ export const buildConversationMarkdownForThread =renderMessage: messageToMarkdown,});-export const exportConversationMarkdown = createConversationMarkdownExporter({- loadMessages: loadDisplayedBranchMessages,+export const exportConversationMarkdown = (+ threadId: string,+ liveBranch?: string[] | null,+): Promise<void> => createConversationMarkdownExporter<MessageRecord>({+ loadMessages: (id) => loadDisplayedBranchMessages(id, { liveBranch }),renderMessage: messageToMarkdown,download: downloadBlob,exportBasename: conversationBasename,notifyNoContent: () => toast.info("No exportable content."),-});+})(threadId);// "skipped" must not stop a pair; "failed" already toasted, so stop.type SaveSourceOutcome = "saved" | "skipped" | "failed";@@ -618,18 +640,22 @@ export async function saveChatItemAsProjectSource(}/** A sidebar row as one markdown document. Compare halves are named by model, since their order is not stable. */-export async function buildChatItemMarkdown(item: {- id: string;- title: string;- type: string;-}): Promise<string> {+export async function buildChatItemMarkdown(+ item: { id: string; title: string; type: string },+ liveBranch?: string[] | null,+): Promise<string> {const plans = planChatItemSources(item,item.type === "single" ? [] : await listStoredChatThreads({ pairId: item.id }),);return buildNamedConversationsMarkdown(plans,- buildConversationMarkdownForThread,+ liveBranch === undefined+ ? buildConversationMarkdownForThread+ : createConversationMarkdownBuilder<MessageRecord>({+ loadMessages: (id) => loadDisplayedBranchMessages(id, { liveBranch }),+ renderMessage: messageToMarkdown,+ }),);}diff --git a/studio/frontend/src/features/find-in-page/components/find-in-page.tsx b/studio/frontend/src/features/find-in-page/components/find-in-page.tsxindex f4742dd28ee..bee6e9405f9 100644--- a/studio/frontend/src/features/find-in-page/components/find-in-page.tsx+++ b/studio/frontend/src/features/find-in-page/components/find-in-page.tsx@@ -12,7 +12,7 @@ import {isImeComposing,useShortcut,useShortcutAvailable,-} from "@/features/settings";+} from "@/features/settings/hooks/use-shortcut";import { useDocumentFlag } from "@/lib/document-flag";import { Z_LAYER } from "@/lib/z-layers";import { Search01Icon } from "@hugeicons/core-free-icons";diff --git a/studio/frontend/src/features/find-in-page/lib/find-backgrounded.ts b/studio/frontend/src/features/find-in-page/lib/find-backgrounded.tsindex cb173511a99..25861c824b7 100644--- a/studio/frontend/src/features/find-in-page/lib/find-backgrounded.ts+++ b/studio/frontend/src/features/find-in-page/lib/find-backgrounded.ts@@ -1,7 +1,7 @@// SPDX-License-Identifier: AGPL-3.0-only// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0-import { isSurfaceBackgrounded } from "@/features/settings";+import { isSurfaceBackgrounded } from "@/features/settings/hooks/use-shortcut";import { FIND_SCOPE_ATTRIBUTE } from "./find-attributes.ts";export const MODAL_BACKDROP_SELECTOR = [diff --git a/studio/frontend/src/features/hub/catalog/model-readme.tsx b/studio/frontend/src/features/hub/catalog/model-readme.tsxindex 6e5c38161b2..293c6682e48 100644--- a/studio/frontend/src/features/hub/catalog/model-readme.tsx+++ b/studio/frontend/src/features/hub/catalog/model-readme.tsx@@ -22,6 +22,8 @@ import {} from "@/components/assistant-ui/markdown-table";import { codePlugin } from "@/components/assistant-ui/shared-code-plugin";import { math as streamdownMath } from "@streamdown/math";+// Its own: the chat renderers that also import this are not loaded before the Hub.+import "katex/dist/katex.min.css";import { mermaid as streamdownMermaid } from "@/components/assistant-ui/mermaid-plugin";import {createContext,diff --git a/studio/frontend/src/features/hub/download-manager/transport-preference.ts b/studio/frontend/src/features/hub/download-manager/transport-preference.tsindex 7b9aba7ed04..daed08fc87d 100644--- a/studio/frontend/src/features/hub/download-manager/transport-preference.ts+++ b/studio/frontend/src/features/hub/download-manager/transport-preference.ts@@ -5,7 +5,7 @@ import {loadDownloadTransportSettings,subscribeDownloadTransportSettings,updateDownloadTransportSettings,-} from "@/features/settings";+} from "@/features/settings/api/download-transport";import { toast } from "@/lib/toast";import { useCallback, useEffect, useState } from "react";import {diff --git a/studio/frontend/src/features/interface-zoom/components/interface-zoom.tsx b/studio/frontend/src/features/interface-zoom/components/interface-zoom.tsxindex dad39fa2523..4448f007cff 100644--- a/studio/frontend/src/features/interface-zoom/components/interface-zoom.tsx+++ b/studio/frontend/src/features/interface-zoom/components/interface-zoom.tsx@@ -4,15 +4,17 @@import { Button } from "@/components/ui/button";import {getAppliedInterfaceZoom,- isImeComposing,subscribeAppliedInterfaceZoom,- useInterfaceScaleStore,-} from "@/features/settings";+} from "@/features/settings/lib/interface-scale-runtime";+import { isImeComposing } from "@/features/settings/hooks/use-shortcut";import {formatBindingValueLabel,isMacPlatform,} from "@/features/settings/lib/keyboard-shortcuts";-import { INTERFACE_SCALE_RANGE } from "@/features/settings/stores/interface-scale-store";+import {+ INTERFACE_SCALE_RANGE,+ useInterfaceScaleStore,+} from "@/features/settings/stores/interface-scale-store";import {shortcutOwningBinding,useKeyboardShortcutsStore,diff --git a/studio/frontend/src/features/interface-zoom/lib/zoom-actions.ts b/studio/frontend/src/features/interface-zoom/lib/zoom-actions.tsindex 0104f3b6d62..94c30a6ea24 100644--- a/studio/frontend/src/features/interface-zoom/lib/zoom-actions.ts+++ b/studio/frontend/src/features/interface-zoom/lib/zoom-actions.ts@@ -4,7 +4,7 @@import {stepInterfaceScale,useInterfaceScaleStore,-} from "@/features/settings";+} from "@/features/settings/stores/interface-scale-store";import { create } from "zustand";import type { ZoomDirection } from "./zoom-chords.ts";diff --git a/studio/frontend/src/features/library/start-chat.ts b/studio/frontend/src/features/library/start-chat.tsindex 02c2de7ad3a..1a20d819476 100644--- a/studio/frontend/src/features/library/start-chat.ts+++ b/studio/frontend/src/features/library/start-chat.ts@@ -5,7 +5,7 @@ import type { useNavigate } from "@tanstack/react-router";import { getAuthSessionEpoch } from "@/features/auth";// eslint-disable-next-line no-restricted-imports -- the chat barrel imports the Library backimport { useChatRuntimeStore } from "@/features/chat/stores/chat-runtime-store";-import { createModelConfigHandoffRequestId } from "@/features/model-picker";+import { createModelConfigHandoffRequestId } from "@/features/model-picker/model-config/model-config-handoff";import { translate } from "@/i18n";import { toast } from "@/lib/toast";import { MAX_VIDEO_SIZE } from "@/lib/video-utils";diff --git a/studio/frontend/src/features/loaded-models/loaded-models-api.ts b/studio/frontend/src/features/loaded-models/loaded-models-api.tsindex ec5c017aead..321c8c67d72 100644--- a/studio/frontend/src/features/loaded-models/loaded-models-api.ts+++ b/studio/frontend/src/features/loaded-models/loaded-models-api.ts@@ -5,15 +5,12 @@// imported directly because their indexes re-export pages kept out of the eager bundle.import { authFetch, isAccountOwner } from "@/features/auth";-import {- confirmStopRunningChatsIfNeeded,- getInferenceStatus,- isExternalModelId,- requestScopedLocalPromptQueueStop,- resolveInferenceCheckpointId,- unloadModel,- useChatRuntimeStore,-} from "@/features/chat";+import { confirmStopRunningChatsIfNeeded } from "@/features/chat/utils/confirm-stop-running-chats";+import { getInferenceStatus, unloadModel } from "@/features/chat/api/chat-api";+import { isExternalModelId } from "@/features/chat/external-providers";+import { requestScopedLocalPromptQueueStop } from "@/features/chat/utils/prompt-queue-boundary";+import { resolveInferenceCheckpointId } from "@/features/chat/lib/apply-inference-status-to-store";+import { useChatRuntimeStore } from "@/features/chat/stores/chat-runtime-store";import { disposableTimeoutSignal } from "@/features/hub/lib/abort-signals";import { modelIdsMatch } from "@/features/hub/lib/model-identity";import {diff --git a/studio/frontend/src/features/loaded-models/loaded-models-indicator.tsx b/studio/frontend/src/features/loaded-models/loaded-models-indicator.tsxindex 40132dab19e..9e170c65b81 100644--- a/studio/frontend/src/features/loaded-models/loaded-models-indicator.tsx+++ b/studio/frontend/src/features/loaded-models/loaded-models-indicator.tsx@@ -11,7 +11,7 @@ import {} from "@/components/ui/tooltip";import { useAudioWorkspaceStore } from "@/features/audio/stores/audio-workspace-store";import { hasAuthToken, mustChangePassword } from "@/features/auth";-import { useSettingsDialogStore } from "@/features/settings";+import { useSettingsDialogStore } from "@/features/settings/stores/settings-dialog-store";import { usePersistedToggle } from "@/hooks/use-persisted-toggle";import { useT } from "@/i18n";import { isTauri } from "@/lib/api-base";diff --git a/studio/frontend/src/features/profile/hooks/use-personalization-sync.ts b/studio/frontend/src/features/profile/hooks/use-personalization-sync.tsindex 96e09746917..3ecf173e1a9 100644--- a/studio/frontend/src/features/profile/hooks/use-personalization-sync.ts+++ b/studio/frontend/src/features/profile/hooks/use-personalization-sync.ts@@ -3,21 +3,25 @@import {type AppearanceCustomization,- type Palette,- type Theme,isDefaultCustomization,- isPalette,- loadPersonalization,migrateAppearanceMenuDefault,migrateShippedSidebarNavDefault,sanitizeCustomization,- savePersonalization,+ useAppearanceCustomStore,+} from "@/features/settings/stores/appearance-custom-store";+import {+ type Palette,+ type Theme,+ isPalette,setPalette,setTheme,- useAppearanceCustomStore,usePalette,useTheme,-} from "@/features/settings";+} from "@/features/settings/stores/theme-store";+import {+ loadPersonalization,+ savePersonalization,+} from "@/features/settings/api/personalization";import {DEFAULT_LOCALE_PREFERENCE,LOCALE_INITIALIZATION_TIMEOUT_MS,diff --git a/studio/frontend/src/features/rag/components/vision-overrides.ts b/studio/frontend/src/features/rag/components/vision-overrides.tsindex 7035be77b31..1448730143f 100644--- a/studio/frontend/src/features/rag/components/vision-overrides.ts+++ b/studio/frontend/src/features/rag/components/vision-overrides.ts@@ -5,7 +5,7 @@ import {CHAT_RAG_CAPTION_KEY,CHAT_RAG_OCR_KEY,useChatRuntimeStore,-} from "@/features/chat";+} from "@/features/chat/stores/chat-runtime-store";// authFetch sets no AbortSignal, so bound hydration and fall back to the local values.const HYDRATION_WAIT_MS = 8_000;diff --git a/studio/frontend/src/features/scheduled-tasks/run-notifier.tsx b/studio/frontend/src/features/scheduled-tasks/run-notifier.tsxindex b6ef47c05f0..ede7190628a 100644--- a/studio/frontend/src/features/scheduled-tasks/run-notifier.tsx+++ b/studio/frontend/src/features/scheduled-tasks/run-notifier.tsx@@ -4,7 +4,8 @@import { useNavigate, useRouterState } from "@tanstack/react-router";import { Suspense, lazy, useEffect, useRef, useState } from "react";import { AUTH_SESSION_STORED_EVENT, getAuthSessionEpoch, hasSettledAuthSession } from "@/features/auth";-import { notifyChatHistoryUpdated, useChatNavigationStore } from "@/features/chat";+import { notifyChatHistoryUpdated } from "@/features/chat/api/chat-api";+import { useChatNavigationStore } from "@/features/chat/stores/chat-navigation-store";import { translate } from "@/i18n";import { browserAccountKey } from "@/lib/account-transition";import { isTauri } from "@/lib/api-base";diff --git a/studio/frontend/src/features/settings/api/embedding-model.ts b/studio/frontend/src/features/settings/api/embedding-model.tsindex 882794ac5b1..c88b27ce27b 100644--- a/studio/frontend/src/features/settings/api/embedding-model.ts+++ b/studio/frontend/src/features/settings/api/embedding-model.ts@@ -2,7 +2,7 @@// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0import { authFetch } from "@/features/auth";-import { bumpInventoryVersion } from "@/features/hub";+import { bumpInventoryVersion } from "@/features/hub/stores/inventory-events";// Leaf module, not the barrel: tests stub the barrel down to the cache bump.import { hubTokenHeader } from "@/features/hub/lib/hub-token-header";import { readFastApiError } from "@/lib/format-fastapi-error";diff --git a/studio/frontend/src/features/settings/api/hub-settings.ts b/studio/frontend/src/features/settings/api/hub-settings.tsindex 9e919712ef0..285eff75cdc 100644--- a/studio/frontend/src/features/settings/api/hub-settings.ts+++ b/studio/frontend/src/features/settings/api/hub-settings.ts@@ -3,7 +3,7 @@import { fetchDeviceType } from "@/config/env";import { authFetch } from "@/features/auth";-import { clearDownloadTransportCapabilitiesCache } from "@/features/hub";+import { clearDownloadTransportCapabilitiesCache } from "@/features/hub/download-manager/api";import { markRemoteNetworkOnline } from "@/features/hub/lib/network";import { readFastApiError } from "@/lib/format-fastapi-error";import type { HubSource } from "@/lib/hf-endpoint";diff --git a/studio/frontend/src/features/settings/components/stt-download-prompt.tsx b/studio/frontend/src/features/settings/components/stt-download-prompt.tsxindex f2d430f8c00..da9cdca0bbd 100644--- a/studio/frontend/src/features/settings/components/stt-download-prompt.tsx+++ b/studio/frontend/src/features/settings/components/stt-download-prompt.tsx@@ -13,8 +13,12 @@ import {AlertDialogTitle,} from "@/components/ui/alert-dialog";import { audioCppSizeLabel } from "@/features/audio/audio-cpp-catalog";-import { startSttDownload } from "@/features/chat";-import { hfApiToken, listGgufVariants, useHfTokenStore } from "@/features/hub";+import { startSttDownload } from "@/features/chat/adapters/studio-model-dictation-adapter";+import {+ hfApiToken,+ useHfTokenStore,+} from "@/features/hub/stores/hf-token-store";+import { listGgufVariants } from "@/features/hub/inventory/api";import { useT } from "@/i18n";import { MicIcon } from "@/lib/mic-icon";import { toast } from "@/lib/toast";diff --git a/studio/frontend/src/features/settings/lib/stt-download-mirror.ts b/studio/frontend/src/features/settings/lib/stt-download-mirror.tsindex 954a6a65a8b..6817e3a8e94 100644--- a/studio/frontend/src/features/settings/lib/stt-download-mirror.ts+++ b/studio/frontend/src/features/settings/lib/stt-download-mirror.ts@@ -9,13 +9,13 @@ import {loadSttModel,sttEngineFor,sttEngineStatusFor,-} from "@/features/chat";+} from "@/features/chat/adapters/studio-model-dictation-adapter";import {finishExternalJob,- invalidateGgufVariantsCache,startExternalJob,updateExternalJob,-} from "@/features/hub";+} from "@/features/hub/download-manager/external-jobs";+import { invalidateGgufVariantsCache } from "@/features/hub/inventory/api";import { translate } from "@/i18n";import { toast } from "@/lib/toast";import {diff --git a/studio/frontend/src/features/tour/lib/confetti-fireworks.ts b/studio/frontend/src/features/tour/lib/confetti-fireworks.tsindex 8801443abec..10dab58803c 100644--- a/studio/frontend/src/features/tour/lib/confetti-fireworks.ts+++ b/studio/frontend/src/features/tour/lib/confetti-fireworks.ts@@ -5,7 +5,7 @@import type { CreateTypes as ConfettiInstance } from "canvas-confetti";-import { prefersReducedMotion } from "@/features/settings";+import { prefersReducedMotion } from "@/features/settings/stores/appearance-custom-store";type FireworksOpts = {durationMs?: number;diff --git a/studio/frontend/src/features/training/api/datasets-api.ts b/studio/frontend/src/features/training/api/datasets-api.tsindex 98a6b980b8d..0cdedc8c8f1 100644--- a/studio/frontend/src/features/training/api/datasets-api.ts+++ b/studio/frontend/src/features/training/api/datasets-api.ts@@ -2,7 +2,7 @@// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0import { authFetch } from "@/features/auth";-import { hubTokenHeader } from "@/features/hub";+import { hubTokenHeader } from "@/features/hub/lib/hub-token-header";import { readFastApiError } from "@/lib/format-fastapi-error";import type {CheckFormatResponse,diff --git a/studio/frontend/src/features/training/api/models-api.ts b/studio/frontend/src/features/training/api/models-api.tsindex 2c0c5795f3a..f466726cf04 100644--- a/studio/frontend/src/features/training/api/models-api.ts+++ b/studio/frontend/src/features/training/api/models-api.ts@@ -2,7 +2,7 @@// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0import { authFetch } from "@/features/auth";-import { hubTokenHeader } from "@/features/hub";+import { hubTokenHeader } from "@/features/hub/lib/hub-token-header";interface VisionCheckResponse {model_name: string;diff --git a/studio/frontend/src/features/training/api/train-api.ts b/studio/frontend/src/features/training/api/train-api.tsindex cc4de689837..263bddec26b 100644--- a/studio/frontend/src/features/training/api/train-api.ts+++ b/studio/frontend/src/features/training/api/train-api.ts@@ -2,7 +2,7 @@// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0import { authFetch } from "@/features/auth";-import { hubTokenHeader } from "@/features/hub";+import { hubTokenHeader } from "@/features/hub/lib/hub-token-header";import { readFastApiError } from "@/lib/format-fastapi-error";// eslint-disable-next-line no-restricted-importsimport { checkDiskSpace } from "@/features/settings/low-disk-check";diff --git a/studio/frontend/src/features/training/lib/cache-reference.ts b/studio/frontend/src/features/training/lib/cache-reference.tsindex 6a657a6df09..d1f34743af5 100644--- a/studio/frontend/src/features/training/lib/cache-reference.ts+++ b/studio/frontend/src/features/training/lib/cache-reference.ts@@ -1,7 +1,7 @@// SPDX-License-Identifier: AGPL-3.0-only// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0-import { normalizeModelIdentity } from "@/features/hub";+import { normalizeModelIdentity } from "@/features/hub/lib/model-identity";export function cacheLocalPathMatchesSelection(currentLocalPath: string | null | undefined,diff --git a/studio/frontend/src/features/training/stores/training-config-store.ts b/studio/frontend/src/features/training/stores/training-config-store.tsindex 6ff5c7542be..257ef8b8f5b 100644--- a/studio/frontend/src/features/training/stores/training-config-store.ts+++ b/studio/frontend/src/features/training/stores/training-config-store.ts@@ -7,7 +7,7 @@ import {LR_DEFAULT_FULL,LR_DEFAULT_LORA,} from "@/config/training";-import { getHfToken } from "@/features/hub";+import { getHfToken } from "@/features/hub/stores/hf-token-store";import { translate } from "@/i18n";import { toast } from "@/lib/toast";import { isAdapterMethod } from "@/types/training";diff --git a/studio/frontend/src/hooks/use-floating-panel-layout.ts b/studio/frontend/src/hooks/use-floating-panel-layout.tsindex f3508154147..292eb75e206 100644--- a/studio/frontend/src/hooks/use-floating-panel-layout.ts+++ b/studio/frontend/src/hooks/use-floating-panel-layout.ts@@ -1,7 +1,7 @@// SPDX-License-Identifier: AGPL-3.0-only// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0-import { useMonitorFrameStore } from "@/features/settings";+import { useMonitorFrameStore } from "@/features/settings/stores/monitor-frame-store";import {type FrameBox,type PanelIntent,diff --git a/studio/frontend/src/hooks/use-type-to-activate.ts b/studio/frontend/src/hooks/use-type-to-activate.tsindex c90482446da..2a52c5f1aa7 100644--- a/studio/frontend/src/hooks/use-type-to-activate.ts+++ b/studio/frontend/src/hooks/use-type-to-activate.ts@@ -2,7 +2,7 @@// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0import { useEffect } from "react";-import { useSettingsDialogStore } from "@/features/settings";+import { useSettingsDialogStore } from "@/features/settings/stores/settings-dialog-store";/** Focusing during keydown lets the default action insert the character there. */export function useTypeToActivate(): void {diff --git a/studio/frontend/tests/command-palette-handoffs.test.ts b/studio/frontend/tests/command-palette-handoffs.test.tsindex 7ebb6c37283..feb4ea0f574 100644--- a/studio/frontend/tests/command-palette-handoffs.test.ts+++ b/studio/frontend/tests/command-palette-handoffs.test.ts@@ -8,7 +8,7 @@ import test from "node:test";const REGISTRY_SHORTCUT = /useShortcut\("openCommandPalette"/;const RAW_KEY_LISTENER = /addEventListener\("keydown"/;const SETTINGS_INDEX_IMPORT =- /\bDIALOG_SETTINGS_SEARCH_INDEX,\n[^;]*from "@\/features\/settings"/;+ /\bDIALOG_SETTINGS_SEARCH_INDEX \} from "@\/features\/settings\/dialog-search-index"/;const LOCALIZED_SETTINGS_KEYWORDS =/keywords=\{DIALOG_SETTINGS_SEARCH_INDEX\[tab\]\.map\(\(key\) =>\s*t\(key\),?\s*\)\}/;const HARDCODED_SETTINGS_KEYWORDS = /keywords:\s*\[/;diff --git a/studio/frontend/tests/helpers/browser-store-resolver.mjs b/studio/frontend/tests/helpers/browser-store-resolver.mjsindex 8557b9483d9..f5bbd0b390c 100644--- a/studio/frontend/tests/helpers/browser-store-resolver.mjs+++ b/studio/frontend/tests/helpers/browser-store-resolver.mjs@@ -33,10 +33,17 @@ const AUTH_STUB =" throw new Error(\"no network in tests\"); };",);+// The browser stores import these chat modules directly rather than through the chat index.+const CHAT_SPECIFIERS = new Set([+ "@/features/chat",+ "@/features/chat/stores/chat-runtime-store",+ "@/features/chat/utils/chat-thread-tombstones",+]);+export function resolve(specifier, context, next) {if (specifier === "@/features/auth") return { url: AUTH_STUB, shortCircuit: true };if (specifier === "@/lib/toast") return { url: TOAST_STUB, shortCircuit: true };- if (specifier === "@/features/chat") return { url: CHAT_STUB, shortCircuit: true };+ if (CHAT_SPECIFIERS.has(specifier)) return { url: CHAT_STUB, shortCircuit: true };if (specifier === "@/i18n") return { url: I18N_STUB, shortCircuit: true };if (specifier.startsWith("@/lib/")) {return next(new URL(`../../src/lib/${specifier.slice(6)}.ts`, import.meta.url).href, context);diff --git a/studio/frontend/tests/helpers/file-kind-resolver.mjs b/studio/frontend/tests/helpers/file-kind-resolver.mjsindex 24eb96720ad..0b328b88cd7 100644--- a/studio/frontend/tests/helpers/file-kind-resolver.mjs+++ b/studio/frontend/tests/helpers/file-kind-resolver.mjs@@ -16,7 +16,10 @@ const CHAT_STUB =export function resolve(specifier, context, next) {if (specifier === "@/components/file-viewer") return { url: FILE_VIEWER_STUB, shortCircuit: true };- if (specifier === "@/features/chat" && context.parentURL?.includes("/src/features/browser/file-kind")) {+ if (+ (specifier === "@/features/chat" || specifier === "@/features/chat/attachment-content") &&+ context.parentURL?.includes("/src/features/browser/file-kind")+ ) {return { url: CHAT_STUB, shortCircuit: true };}return next(specifier, context);diff --git a/studio/frontend/tests/helpers/loaded-models-eject-resolver.mjs b/studio/frontend/tests/helpers/loaded-models-eject-resolver.mjsindex 15b72fbcfb5..bf58bb6d006 100644--- a/studio/frontend/tests/helpers/loaded-models-eject-resolver.mjs+++ b/studio/frontend/tests/helpers/loaded-models-eject-resolver.mjs@@ -9,6 +9,12 @@ const EJECT_STUB = new URL("./loaded-models-eject-stub.ts", import.meta.url).href;const STUBS = new Map([["@/features/chat", EJECT_STUB],+ ["@/features/chat/api/chat-api", EJECT_STUB],+ ["@/features/chat/external-providers", EJECT_STUB],+ ["@/features/chat/lib/apply-inference-status-to-store", EJECT_STUB],+ ["@/features/chat/stores/chat-runtime-store", EJECT_STUB],+ ["@/features/chat/utils/confirm-stop-running-chats", EJECT_STUB],+ ["@/features/chat/utils/prompt-queue-boundary", EJECT_STUB],["@/features/images/api", EJECT_STUB],["@/features/video/api", EJECT_STUB],["@/features/settings/api/embedding-model", EJECT_STUB],diff --git a/studio/frontend/tests/helpers/store-stubs/per-model-config-resident.ts b/studio/frontend/tests/helpers/store-stubs/per-model-config-resident.tsnew file mode 100644index 00000000000..908ab4e822a--- /dev/null+++ b/studio/frontend/tests/helpers/store-stubs/per-model-config-resident.ts@@ -0,0 +1,12 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++// apply-inference-status-to-store.ts takes these from per-model-config itself rather than the+// model-picker index, so they stay on the model-picker stub; the rest of the module is real.+export * from "../../../src/features/model-picker/model-config/per-model-config.ts";+export {+ adoptCachedRepoConfig,+ loadedContextFields,+ resolveResidentInitialConfig,+ savedContextPin,+} from "./model-picker.ts";diff --git a/studio/frontend/tests/loaded-models-barrel-order.test.ts b/studio/frontend/tests/loaded-models-barrel-order.test.tsindex a393fb7d036..3d518a900c9 100644--- a/studio/frontend/tests/loaded-models-barrel-order.test.ts+++ b/studio/frontend/tests/loaded-models-barrel-order.test.ts@@ -2,7 +2,8 @@// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0// Import cycle: loaded-models/index -> indicator -> settings -> general-tab -> loaded-models.-// Exporting the preference module first avoids a TDZ error on its top-level const.+// Exporting the preference module first avoids a TDZ error on its top-level const. The indicator now+// imports the settings dialog store itself, which breaks the cycle; the order stays as a guard.import assert from "node:assert/strict";import test from "node:test";@@ -25,8 +26,9 @@ test("the preference module is exported before the indicator", () => {);});-test("the cycle this order defends against is still present", () => {- assert.match(INDICATOR, /from "@\/features\/settings"/);+test("the indicator does not import the settings index, the half of the cycle it closed", () => {+ assert.doesNotMatch(INDICATOR, /from "@\/features\/settings"/);+ assert.match(INDICATOR, /from "@\/features\/settings\/stores\/settings-dialog-store"/);assert.match(GENERAL_TAB, /from "@\/features\/loaded-models"/);assert.match(GENERAL_TAB, /LOADED_MODELS_PREFERENCE_KEYS\./);});diff --git a/studio/frontend/tests/markdown-export-branches.test.ts b/studio/frontend/tests/markdown-export-branches.test.tsindex 647b6f3ada8..bcbc2f658ec 100644--- a/studio/frontend/tests/markdown-export-branches.test.ts+++ b/studio/frontend/tests/markdown-export-branches.test.ts@@ -177,6 +177,60 @@ const regenerated = storedMessages([["a1-retry", "u1", "assistant", "Pears."],]);+test("deferred export keeps the branch selected before the exporter loads", async () => {+ const downloads: string[] = [];+ const exporters = loadExporters(regenerated, downloads, []);+ let branch = ["u1", "a1"];+ const unregister = liveThreadHead.registerLiveThreadView({+ threads: () => ({ getState: () => ({ mainThreadId: "thread" }) }),+ threadListItem: () => ({+ getState: () => ({ id: "thread", remoteId: "thread" }),+ }),+ thread: () => ({+ getState: () => ({ messages: branch.map((id) => ({ id })) }),+ }),+ });+ const menu = ts.createSourceFile(+ "chat-row-menu.ts",+ readSrc("features/chat/components/chat-row-menu.ts"),+ ts.ScriptTarget.Latest,+ true,+ );+ const dispatch = menu.statements.find(+ (statement) =>+ ts.isFunctionDeclaration(statement) &&+ statement.name?.text === "exportConversationByFormat",+ );+ assert.ok(dispatch);+ const context = {+ exports: {} as {+ exportConversationByFormat: (id: string, format: string) => Promise<void>;+ },+ liveThreadBranch: liveThreadHead.liveThreadBranch,+ CONVERSATION_MARKDOWN_FORMAT: "markdown",+ require: () => {+ branch = ["u1", "a1-retry"];+ return exporters;+ },+ };+ vm.runInNewContext(+ ts.transpileModule(dispatch.getText(), {+ compilerOptions: {+ module: ts.ModuleKind.CommonJS,+ target: ts.ScriptTarget.ES2022,+ },+ }).outputText,+ context,+ );+ try {+ await context.exports.exportConversationByFormat("thread", "markdown");+ } finally {+ unregister();+ }+ assert.match(downloads[0] as string, /Apples\./);+ assert.doesNotMatch(downloads[0] as string, /Pears\./);+});+const edited = storedMessages([["u1", null, "user", "Name one color."],["a1", "u1", "assistant", "Blue."],diff --git a/studio/frontend/tests/personalization-locale-hydration.test.ts b/studio/frontend/tests/personalization-locale-hydration.test.tsindex b75ee2ce1e9..f02ef6639a2 100644--- a/studio/frontend/tests/personalization-locale-hydration.test.ts+++ b/studio/frontend/tests/personalization-locale-hydration.test.ts@@ -235,31 +235,35 @@ function setup(},);+ // The hook imports these from the settings store, theme store and personalization API modules.+ const settings = {+ isDefaultCustomization: (value: unknown) =>+ Object.keys(value as object).length === 0,+ isPalette: (value: unknown) => typeof value === "string",+ loadPersonalization: async () => {+ await options.remoteGate;+ return options.remote ?? remotePersonalization("de");+ },+ migrateAppearanceMenuDefault: (value: unknown) => value,+ migrateShippedSidebarNavDefault: (value: unknown) => value,+ sanitizeCustomization,+ savePersonalization: (data: SavedPayload) => {+ saves.push(data);+ return Promise.resolve();+ },+ setPalette: () => undefined,+ setTheme: () => undefined,+ useAppearanceCustomStore: appearanceStore,+ usePalette: () => ({ palette: "standard" }),+ useTheme: () => ({ theme: "system" }),+ };const { usePersonalizationSync } = loadWithStubs<{usePersonalizationSync: (enabled: boolean) => void;}>(HOOK_URL, {react: host.react,- "@/features/settings": {- isDefaultCustomization: (value: unknown) =>- Object.keys(value as object).length === 0,- isPalette: (value: unknown) => typeof value === "string",- loadPersonalization: async () => {- await options.remoteGate;- return options.remote ?? remotePersonalization("de");- },- migrateAppearanceMenuDefault: (value: unknown) => value,- migrateShippedSidebarNavDefault: (value: unknown) => value,- sanitizeCustomization,- savePersonalization: (data: SavedPayload) => {- saves.push(data);- return Promise.resolve();- },- setPalette: () => undefined,- setTheme: () => undefined,- useAppearanceCustomStore: appearanceStore,- usePalette: () => ({ palette: "standard" }),- useTheme: () => ({ theme: "system" }),- },+ "@/features/settings/stores/appearance-custom-store": settings,+ "@/features/settings/stores/theme-store": settings,+ "@/features/settings/api/personalization": settings,"@/i18n": {DEFAULT_LOCALE_PREFERENCE: "auto",LOCALE_INITIALIZATION_TIMEOUT_MS: 2_000,diff --git a/studio/frontend/tests/startup-feature-index-imports.test.ts b/studio/frontend/tests/startup-feature-index-imports.test.tsnew file mode 100644index 00000000000..51494774f0a--- /dev/null+++ b/studio/frontend/tests/startup-feature-index-imports.test.ts@@ -0,0 +1,95 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++import assert from "node:assert/strict";+import { existsSync, readFileSync } from "node:fs";+import { dirname, join, normalize, relative } from "node:path";+import test from "node:test";+import { fileURLToPath } from "node:url";++const SRC = fileURLToPath(new URL("../src/", import.meta.url));++const LAZY_FEATURE_INDEXES = [+ "chat",+ "hub",+ "library",+ "model-picker",+ "rag",+ "settings",+ "training",+].map((name) => `features/${name}/index.ts`);++// Static value imports and re-exports, plus bare side-effect imports. `import type` is erased.+const STATIC_IMPORT =+ /^\s*(?:import|export)\s+(?!type\s)(?:[^;'"]*?\bfrom\s+)?["']([^"']+)["']/gm;++function resolveSource(fromFile: string, specifier: string): string | null {+ let base: string;+ if (specifier.startsWith("@/")) base = join(SRC, specifier.slice(2));+ else if (specifier.startsWith(".")) base = join(dirname(fromFile), specifier);+ else return null;+ for (const suffix of ["", ".ts", ".tsx", "/index.ts", "/index.tsx"]) {+ const candidate = normalize(base + suffix);+ if (/\.(ts|tsx)$/.test(candidate) && existsSync(candidate)) return candidate;+ }+ return null;+}++function startupGraph(): Map<string, string> {+ const entry = join(SRC, "main.tsx");+ const parent = new Map<string, string>([[entry, ""]]);+ const stack = [entry];+ while (stack.length > 0) {+ const file = stack.pop() as string;+ for (const match of readFileSync(file, "utf8").matchAll(STATIC_IMPORT)) {+ const target = resolveSource(file, match[1] as string);+ if (target && !parent.has(target)) {+ parent.set(target, file);+ stack.push(target);+ }+ }+ }+ return parent;+}++function chain(parent: Map<string, string>, file: string): string {+ const steps: string[] = [];+ for (let at = file; at; at = parent.get(at) ?? "") {+ steps.push(relative(SRC, at));+ }+ return steps.join(" <- ");+}++test("directory imports use the same path spelling as graph boundaries", () => {+ assert.equal(+ resolveSource(join(SRC, "main.tsx"), "@/features/settings"),+ join(SRC, "features/settings/index.ts"),+ );+});++test("startup code imports lazy features' modules, not their indexes", () => {+ const parent = startupGraph();+ const reached = LAZY_FEATURE_INDEXES.flatMap((index) => {+ const file = join(SRC, index);+ return parent.has(file) ? [chain(parent, file)] : [];+ });+ assert.deepEqual(reached, []);+});++test("the markdown renderer (Streamdown, KaTeX, Shiki) is not in the startup graph", () => {+ const parent = startupGraph();+ const preview = join(SRC, "components/markdown/markdown-preview.tsx");+ const exporters = join(SRC, "features/chat/prompt-storage/prompt-storage-dialog.tsx");+ const reached = [preview, exporters].flatMap((file) =>+ parent.has(file) ? [chain(parent, file)] : [],+ );+ assert.deepEqual(reached, []);+});++test("the startup graph walk sees the shell", () => {+ const parent = startupGraph();+ for (const shell of ["app/routes/__root.tsx", "components/app-sidebar.tsx", "app/provider.tsx"]) {+ assert.ok(parent.has(join(SRC, shell)), `${shell} not reached from main.tsx`);+ }+ assert.ok(parent.size > 300, `only ${parent.size} startup modules found`);+});diff --git a/studio/frontend/tests/store-settings-resolver.mjs b/studio/frontend/tests/store-settings-resolver.mjsindex a74c8c88142..4f761367636 100644--- a/studio/frontend/tests/store-settings-resolver.mjs+++ b/studio/frontend/tests/store-settings-resolver.mjs@@ -12,7 +12,13 @@ const STUBS = new Map([["@/lib/toast", "./helpers/store-stubs/toast.ts"],]);+const PER_MODEL_CONFIG = "@/features/model-picker/model-config/per-model-config";+const RESIDENT_CONFIG_READER = "/src/features/chat/lib/apply-inference-status-to-store.ts";+export function resolve(specifier, context, next) {+ if (specifier === PER_MODEL_CONFIG && context.parentURL?.endsWith(RESIDENT_CONFIG_READER)) {+ return next(new URL("./helpers/store-stubs/per-model-config-resident.ts", import.meta.url).href, context);+ }const stub = STUBS.get(specifier);if (stub) {return next(new URL(stub, import.meta.url).href, context);