Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.
fix: restore hub fit badge, bump mlx-swift, fix stuck download UI in mlx provider (#8153)
Akarshan Biswas616ca7210d13
diff --git a/extensions/mlx-extension/src/index.ts b/extensions/mlx-extension/src/index.tsindex d479921b2..d9c3ff68d 100644--- a/extensions/mlx-extension/src/index.ts+++ b/extensions/mlx-extension/src/index.ts@@ -656,9 +656,6 @@ export default class mlx_extension extends AIEngine {})- // Emit download success event so DownloadManagement clears the download state- events.emit('onFileDownloadSuccess', { modelId, downloadType: 'Model' })-// Detect capabilities after downloadconst isVision = await this.isVisionSupported(localPath)@@ -696,6 +693,11 @@ export default class mlx_extension extends AIEngine {size_bytes: modelConfig.size_bytes,capabilities: capabilities,})++ events.emit(DownloadEvent.onFileDownloadAndVerificationSuccess, {+ modelId,+ downloadType: 'Model',+ })} else {// Local folder - use absolute folder path directlyif (!(await fs.existsSync(sourcePath))) {diff --git a/mlx-server/Package.resolved b/mlx-server/Package.resolveddeleted file mode 100644index f58f38fa9..000000000--- a/mlx-server/Package.resolved+++ /dev/null@@ -1,267 +0,0 @@-{- "originHash" : "a5325aafb10df2b4ad6d1ed046de91c9f46d142c8e8abd75d024dfc59d75e4dd",- "pins" : [- {- "identity" : "async-http-client",- "kind" : "remoteSourceControl",- "location" : "https://github.com/swift-server/async-http-client.git",- "state" : {- "revision" : "4b99975677236d13f0754339864e5360142ff5a1",- "version" : "1.30.3"- }- },- {- "identity" : "hummingbird",- "kind" : "remoteSourceControl",- "location" : "https://github.com/hummingbird-project/hummingbird",- "state" : {- "revision" : "daf66bfd4b46c1f3f080a1f3438d8fbecee7ace5",- "version" : "2.19.0"- }- },- {- "identity" : "mlx-swift",- "kind" : "remoteSourceControl",- "location" : "https://github.com/ml-explore/mlx-swift",- "state" : {- "revision" : "6ba4827fb82c97d012eec9ab4b2de21f85c3b33d",- "version" : "0.30.6"- }- },- {- "identity" : "mlx-swift-lm",- "kind" : "remoteSourceControl",- "location" : "https://github.com/ml-explore/mlx-swift-lm",- "state" : {- "branch" : "main",- "revision" : "a3e1bf49f6f44d0e9cba29f1c4a61576f646a1b4"- }- },- {- "identity" : "swift-algorithms",- "kind" : "remoteSourceControl",- "location" : "https://github.com/apple/swift-algorithms.git",- "state" : {- "revision" : "87e50f483c54e6efd60e885f7f5aa946cee68023",- "version" : "1.2.1"- }- },- {- "identity" : "swift-argument-parser",- "kind" : "remoteSourceControl",- "location" : "https://github.com/apple/swift-argument-parser",- "state" : {- "revision" : "c5d11a805e765f52ba34ec7284bd4fcd6ba68615",- "version" : "1.7.0"- }- },- {- "identity" : "swift-asn1",- "kind" : "remoteSourceControl",- "location" : "https://github.com/apple/swift-asn1.git",- "state" : {- "revision" : "810496cf121e525d660cd0ea89a758740476b85f",- "version" : "1.5.1"- }- },- {- "identity" : "swift-async-algorithms",- "kind" : "remoteSourceControl",- "location" : "https://github.com/apple/swift-async-algorithms.git",- "state" : {- "revision" : "6c050d5ef8e1aa6342528460db614e9770d7f804",- "version" : "1.1.1"- }- },- {- "identity" : "swift-atomics",- "kind" : "remoteSourceControl",- "location" : "https://github.com/apple/swift-atomics.git",- "state" : {- "revision" : "b601256eab081c0f92f059e12818ac1d4f178ff7",- "version" : "1.3.0"- }- },- {- "identity" : "swift-certificates",- "kind" : "remoteSourceControl",- "location" : "https://github.com/apple/swift-certificates.git",- "state" : {- "revision" : "7d5f6124c91a2d06fb63a811695a3400d15a100e",- "version" : "1.17.1"- }- },- {- "identity" : "swift-collections",- "kind" : "remoteSourceControl",- "location" : "https://github.com/apple/swift-collections.git",- "state" : {- "revision" : "7b847a3b7008b2dc2f47ca3110d8c782fb2e5c7e",- "version" : "1.3.0"- }- },- {- "identity" : "swift-configuration",- "kind" : "remoteSourceControl",- "location" : "https://github.com/apple/swift-configuration.git",- "state" : {- "revision" : "6ffef195ed4ba98ee98029970c94db7edc60d4c6",- "version" : "1.0.1"- }- },- {- "identity" : "swift-crypto",- "kind" : "remoteSourceControl",- "location" : "https://github.com/apple/swift-crypto.git",- "state" : {- "revision" : "6f70fa9eab24c1fd982af18c281c4525d05e3095",- "version" : "4.2.0"- }- },- {- "identity" : "swift-distributed-tracing",- "kind" : "remoteSourceControl",- "location" : "https://github.com/apple/swift-distributed-tracing.git",- "state" : {- "revision" : "baa932c1336f7894145cbaafcd34ce2dd0b77c97",- "version" : "1.3.1"- }- },- {- "identity" : "swift-http-structured-headers",- "kind" : "remoteSourceControl",- "location" : "https://github.com/apple/swift-http-structured-headers.git",- "state" : {- "revision" : "76d7627bd88b47bf5a0f8497dd244885960dde0b",- "version" : "1.6.0"- }- },- {- "identity" : "swift-http-types",- "kind" : "remoteSourceControl",- "location" : "https://github.com/apple/swift-http-types.git",- "state" : {- "revision" : "45eb0224913ea070ec4fba17291b9e7ecf4749ca",- "version" : "1.5.1"- }- },- {- "identity" : "swift-jinja",- "kind" : "remoteSourceControl",- "location" : "https://github.com/huggingface/swift-jinja.git",- "state" : {- "revision" : "d81197f35f41445bc10e94600795e68c6f5e94b0",- "version" : "2.3.1"- }- },- {- "identity" : "swift-log",- "kind" : "remoteSourceControl",- "location" : "https://github.com/apple/swift-log.git",- "state" : {- "revision" : "2778fd4e5a12a8aaa30a3ee8285f4ce54c5f3181",- "version" : "1.9.1"- }- },- {- "identity" : "swift-metrics",- "kind" : "remoteSourceControl",- "location" : "https://github.com/apple/swift-metrics.git",- "state" : {- "revision" : "0743a9364382629da3bf5677b46a2c4b1ce5d2a6",- "version" : "2.7.1"- }- },- {- "identity" : "swift-nio",- "kind" : "remoteSourceControl",- "location" : "https://github.com/apple/swift-nio.git",- "state" : {- "revision" : "5e72fc102906ebe75a3487595a653e6f43725552",- "version" : "2.94.0"- }- },- {- "identity" : "swift-nio-extras",- "kind" : "remoteSourceControl",- "location" : "https://github.com/apple/swift-nio-extras.git",- "state" : {- "revision" : "3df009d563dc9f21a5c85b33d8c2e34d2e4f8c3b",- "version" : "1.32.1"- }- },- {- "identity" : "swift-nio-http2",- "kind" : "remoteSourceControl",- "location" : "https://github.com/apple/swift-nio-http2.git",- "state" : {- "revision" : "c2ba4cfbb83f307c66f5a6df6bb43e3c88dfbf80",- "version" : "1.39.0"- }- },- {- "identity" : "swift-nio-ssl",- "kind" : "remoteSourceControl",- "location" : "https://github.com/apple/swift-nio-ssl.git",- "state" : {- "revision" : "173cc69a058623525a58ae6710e2f5727c663793",- "version" : "2.36.0"- }- },- {- "identity" : "swift-nio-transport-services",- "kind" : "remoteSourceControl",- "location" : "https://github.com/apple/swift-nio-transport-services.git",- "state" : {- "revision" : "60c3e187154421171721c1a38e800b390680fb5d",- "version" : "1.26.0"- }- },- {- "identity" : "swift-numerics",- "kind" : "remoteSourceControl",- "location" : "https://github.com/apple/swift-numerics",- "state" : {- "revision" : "0c0290ff6b24942dadb83a929ffaaa1481df04a2",- "version" : "1.1.1"- }- },- {- "identity" : "swift-service-context",- "kind" : "remoteSourceControl",- "location" : "https://github.com/apple/swift-service-context.git",- "state" : {- "revision" : "1983448fefc717a2bc2ebde5490fe99873c5b8a6",- "version" : "1.2.1"- }- },- {- "identity" : "swift-service-lifecycle",- "kind" : "remoteSourceControl",- "location" : "https://github.com/swift-server/swift-service-lifecycle.git",- "state" : {- "revision" : "1de37290c0ab3c5a96028e0f02911b672fd42348",- "version" : "2.9.1"- }- },- {- "identity" : "swift-system",- "kind" : "remoteSourceControl",- "location" : "https://github.com/apple/swift-system",- "state" : {- "revision" : "7c6ad0fc39d0763e0b699210e4124afd5041c5df",- "version" : "1.6.4"- }- },- {- "identity" : "swift-transformers",- "kind" : "remoteSourceControl",- "location" : "https://github.com/huggingface/swift-transformers",- "state" : {- "revision" : "573e5c9036c2f136b3a8a071da8e8907322403d0",- "version" : "1.1.6"- }- }- ],- "version" : 3-}diff --git a/mlx-server/Package.swift b/mlx-server/Package.swiftindex 047310d10..aebab582d 100644--- a/mlx-server/Package.swift+++ b/mlx-server/Package.swift@@ -11,8 +11,9 @@ let package = Package(.executable(name: "mlx-server", targets: ["MLXServer"])],dependencies: [- .package(url: "https://github.com/ml-explore/mlx-swift", .upToNextMinor(from: "0.30.6")),+ .package(url: "https://github.com/ml-explore/mlx-swift", .upToNextMinor(from: "0.31.3")),.package(url: "https://github.com/ml-explore/mlx-swift-lm", branch: "main"),+ .package(url: "https://github.com/huggingface/swift-transformers", from: "1.3.0"),.package(url: "https://github.com/apple/swift-argument-parser", from: "1.7.0"),.package(url: "https://github.com/hummingbird-project/hummingbird", from: "2.19.0"),],@@ -25,6 +26,7 @@ let package = Package(.product(name: "MLXLLM", package: "mlx-swift-lm"),.product(name: "MLXLMCommon", package: "mlx-swift-lm"),.product(name: "MLXVLM", package: "mlx-swift-lm"),+ .product(name: "Tokenizers", package: "swift-transformers"),.product(name: "ArgumentParser", package: "swift-argument-parser"),.product(name: "Hummingbird", package: "hummingbird"),],diff --git a/mlx-server/Sources/MLXServer/ModelRunner.swift b/mlx-server/Sources/MLXServer/ModelRunner.swiftindex eb0d6c1fb..7dc689b1a 100644--- a/mlx-server/Sources/MLXServer/ModelRunner.swift+++ b/mlx-server/Sources/MLXServer/ModelRunner.swift@@ -7,6 +7,13 @@ import MLXVLM/// Manages loading and running inference with MLX modelsactor ModelRunner {private var model: ModelContext?+ /// True when the loaded model's chat template injects `<think>` into the+ /// assistant turn opening (Qwen3-family, etc.). In that case the streamed+ /// output begins inside the reasoning block — only `</think>` is emitted —+ /// and the streaming splitter must start in reasoning mode.+ private(set) var injectsThinkingOpener: Bool = false++ func currentInjectsThinkingOpener() -> Bool { injectsThinkingOpener }/// Load a model from the given path/// Supports both local directories and HuggingFace model IDs@@ -42,8 +49,61 @@ actor ModelRunner {}if let dir = modelDir {- self.model = try await loadModel(directory: dir)+ self.model = try await loadModel(+ from: dir,+ using: SwiftTransformersTokenizerLoader()+ )+ self.injectsThinkingOpener = Self.detectInjectsThinkingOpener(in: dir)+ log("[mlx] injectsThinkingOpener=\(injectsThinkingOpener)")+ }+ }++ /// Inspect the model folder to see if the chat template injects a `<think>`+ /// opener into the assistant turn. Heuristic — looks for the literal+ /// `<think>` substring across the conventional template locations:+ /// - `chat_template.jinja` (newer split-file convention, Qwen3-VL etc.)+ /// - `chat_template.json` ({ "chat_template": ... } wrapper)+ /// - `tokenizer_config.json` → `chat_template` (older inline convention)+ private nonisolated static func detectInjectsThinkingOpener(in modelDir: URL) -> Bool {+ // 1. Standalone Jinja file.+ let jinjaURL = modelDir.appendingPathComponent("chat_template.jinja")+ if let body = try? String(contentsOf: jinjaURL, encoding: .utf8),+ body.contains("<think>") {+ return true+ }++ // 2. JSON-wrapped template file.+ let jsonURL = modelDir.appendingPathComponent("chat_template.json")+ if let data = try? Data(contentsOf: jsonURL),+ let json = try? JSONSerialization.jsonObject(with: data) as? [String: Any],+ templateValueContainsThink(json["chat_template"]) {+ return true+ }++ // 3. Inline in tokenizer_config.json.+ let configURL = modelDir.appendingPathComponent("tokenizer_config.json")+ if let data = try? Data(contentsOf: configURL),+ let json = try? JSONSerialization.jsonObject(with: data) as? [String: Any],+ templateValueContainsThink(json["chat_template"]) {+ return true+ }++ return false+ }++ /// `chat_template` can be a string or an array of { name, template } entries.+ private nonisolated static func templateValueContainsThink(_ value: Any?) -> Bool {+ if let body = value as? String {+ return body.contains("<think>")+ }+ if let entries = value as? [[String: Any]] {+ for entry in entries {+ if let body = entry["template"] as? String, body.contains("<think>") {+ return true+ }+ }}+ return false}/// Parse ChatMessages into system instructions, conversation history, and the current user messagediff --git a/mlx-server/Sources/MLXServer/ReasoningSplitter.swift b/mlx-server/Sources/MLXServer/ReasoningSplitter.swiftnew file mode 100644index 000000000..01ee81ecb--- /dev/null+++ b/mlx-server/Sources/MLXServer/ReasoningSplitter.swift@@ -0,0 +1,113 @@+import Foundation++// Splits a streaming model output into reasoning_content and content based on+// <think> / </think> markers, mirroring how llamacpp's --reasoning-format+// option exposes the split to OpenAI-compatible clients.+//+// Handles three cases:+// 1. Explicit: "<think>...</think>final answer"+// — drop the opening <think>, route body to reasoning, drop </think>,+// route the rest to content.+// 2. Implicit: "...reasoning text...</think>final answer"+// — chat template seeded "<think>" into the prompt, so the model output+// only contains the closer. Treat everything before </think> as+// reasoning.+// 3. None: "plain content"+// — no tags at all; emit as content.+//+// The splitter buffers a small head window to disambiguate cases 1/2/3 before+// committing, and keeps a trailing window of "</think>".count chars to handle+// a closing tag that straddles a token boundary.++struct ReasoningSplitter {+ private var buffer: String = ""+ private var resolved: Bool = false+ private var inReasoning: Bool = false++ private static let openTag = "<think>"+ private static let closeTag = "</think>"+ private static let resolveWindow = 32++ init(startInReasoning: Bool = false) {+ if startInReasoning {+ self.resolved = true+ self.inReasoning = true+ }+ }++ /// Feed a streamed token. Returns whatever can now be safely emitted.+ mutating func feed(_ token: String) -> (content: String?, reasoning: String?) {+ buffer += token++ if !resolved {+ if let r = buffer.range(of: Self.openTag) {+ // Explicit reasoning opener.+ buffer.removeSubrange(buffer.startIndex..<r.upperBound)+ inReasoning = true+ resolved = true+ } else if let r = buffer.range(of: Self.closeTag) {+ // Implicit reasoning (no opener, model went straight into thinking).+ let reasoning = String(buffer[buffer.startIndex..<r.lowerBound])+ buffer.removeSubrange(buffer.startIndex..<r.upperBound)+ inReasoning = false+ resolved = true+ let content = drainSafe()+ return (+ content.isEmpty ? nil : content,+ reasoning.isEmpty ? nil : reasoning+ )+ } else if buffer.count >= Self.resolveWindow {+ // No tags in the head window — treat as plain content.+ inReasoning = false+ resolved = true+ } else {+ // Still waiting for enough chars to decide.+ return (nil, nil)+ }+ }++ if inReasoning {+ if let r = buffer.range(of: Self.closeTag) {+ let reasoning = String(buffer[buffer.startIndex..<r.lowerBound])+ buffer.removeSubrange(buffer.startIndex..<r.upperBound)+ inReasoning = false+ let content = drainSafe()+ return (+ content.isEmpty ? nil : content,+ reasoning.isEmpty ? nil : reasoning+ )+ }+ let chunk = drainSafe()+ return (nil, chunk.isEmpty ? nil : chunk)+ }++ let chunk = drainSafe()+ return (chunk.isEmpty ? nil : chunk, nil)+ }++ /// Flush whatever is still buffered when the stream ends.+ mutating func finish() -> (content: String?, reasoning: String?) {+ if buffer.isEmpty { return (nil, nil) }+ let remainder = buffer+ buffer = ""+ if !resolved {+ // Never decided — treat the whole thing as content.+ return (remainder.isEmpty ? nil : remainder, nil)+ }+ if inReasoning {+ return (nil, remainder.isEmpty ? nil : remainder)+ }+ return (remainder.isEmpty ? nil : remainder, nil)+ }++ /// Pull out the safe prefix of the buffer (everything except the trailing+ /// region that could still be a partial closing tag).+ private mutating func drainSafe() -> String {+ let tagLen = Self.closeTag.count+ if buffer.count <= tagLen { return "" }+ let safeLen = buffer.count - tagLen+ let safe = String(buffer.prefix(safeLen))+ buffer = String(buffer.suffix(tagLen))+ return safe+ }+}diff --git a/mlx-server/Sources/MLXServer/Server.swift b/mlx-server/Sources/MLXServer/Server.swiftindex a5a8ce400..c80b65165 100644--- a/mlx-server/Sources/MLXServer/Server.swift+++ b/mlx-server/Sources/MLXServer/Server.swift@@ -317,6 +317,8 @@ struct MLXHTTPServer {tools: tools)+ let startInReasoning = await modelRunner.currentInjectsThinkingOpener()+// Use makeStream so we can create the task externally and register it for cancellationlet (responseStream, continuation) = AsyncStream<ByteBuffer>.makeStream()let activeGenerations = self.activeGenerations@@ -347,6 +349,32 @@ struct MLXHTTPServer {log("[mlx] Warning: Failed to encode initial chunk")}+ var splitter = ReasoningSplitter(startInReasoning: startInReasoning)++ func emitDelta(content: String?, reasoning: String?) {+ if content == nil && reasoning == nil { return }+ let chunk = ChatCompletionChunk(+ id: responseId,+ object: "chat.completion.chunk",+ created: created,+ model: model,+ choices: [+ ChatChunkChoice(+ index: 0,+ delta: ChatDelta(+ role: nil,+ content: content,+ reasoning_content: reasoning+ ),+ finish_reason: nil+ )+ ]+ )+ if let data = try? encodeJSONData(chunk) {+ continuation.yield(buildSSEFrame(data))+ }+ }+do {for try await event in stream {// Stop sending if client disconnected or cancelled@@ -357,22 +385,8 @@ struct MLXHTTPServer {switch event {case .chunk(let token):- let chunk = ChatCompletionChunk(- id: responseId,- object: "chat.completion.chunk",- created: created,- model: model,- choices: [- ChatChunkChoice(- index: 0,- delta: ChatDelta(role: nil, content: token),- finish_reason: nil- )- ]- )- if let data = try? encodeJSONData(chunk) {- continuation.yield(buildSSEFrame(data))- }+ let parts = splitter.feed(token)+ emitDelta(content: parts.content, reasoning: parts.reasoning)case .toolCall(let toolCallInfo):let chunk = ChatCompletionChunk(@@ -408,6 +422,10 @@ struct MLXHTTPServer {case .done(let usage, let timings, let hasToolCalls):+ // Flush anything still buffered in the reasoning splitter+ let tail = splitter.finish()+ emitDelta(content: tail.content, reasoning: tail.reasoning)+let finishReason = hasToolCalls ? "tool_calls" : "stop"// Final chunk with finish_reasonlet finalChunk = ChatCompletionChunk(diff --git a/mlx-server/Sources/MLXServer/TokenizerAdapter.swift b/mlx-server/Sources/MLXServer/TokenizerAdapter.swiftnew file mode 100644index 000000000..c3331895c--- /dev/null+++ b/mlx-server/Sources/MLXServer/TokenizerAdapter.swift@@ -0,0 +1,51 @@+import Foundation+import MLXLMCommon+import Tokenizers++// PR #118 in mlx-swift-lm decoupled the tokenizer/downloader packages from+// the core libraries: loadModel now requires the caller to supply a+// TokenizerLoader. We use huggingface/swift-transformers' AutoTokenizer and+// adapt its Tokenizer protocol to MLXLMCommon's parallel one.++struct SwiftTransformersTokenizerLoader: MLXLMCommon.TokenizerLoader {+ func load(from directory: URL) async throws -> any MLXLMCommon.Tokenizer {+ let inner = try await Tokenizers.AutoTokenizer.from(modelFolder: directory)+ return SwiftTransformersTokenizerAdapter(inner: inner)+ }+}++private struct SwiftTransformersTokenizerAdapter: MLXLMCommon.Tokenizer {+ let inner: any Tokenizers.Tokenizer++ func encode(text: String, addSpecialTokens: Bool) -> [Int] {+ inner.encode(text: text, addSpecialTokens: addSpecialTokens)+ }++ func decode(tokenIds: [Int], skipSpecialTokens: Bool) -> String {+ inner.decode(tokens: tokenIds, skipSpecialTokens: skipSpecialTokens)+ }++ func convertTokenToId(_ token: String) -> Int? {+ inner.convertTokenToId(token)+ }++ func convertIdToToken(_ id: Int) -> String? {+ inner.convertIdToToken(id)+ }++ var bosToken: String? { inner.bosToken }+ var eosToken: String? { inner.eosToken }+ var unknownToken: String? { inner.unknownToken }++ func applyChatTemplate(+ messages: [[String: any Sendable]],+ tools: [[String: any Sendable]]?,+ additionalContext: [String: any Sendable]?+ ) throws -> [Int] {+ try inner.applyChatTemplate(+ messages: messages,+ tools: tools,+ additionalContext: additionalContext+ )+ }+}diff --git a/web-app/src/components/ai-elements/chain-of-thought.tsx b/web-app/src/components/ai-elements/chain-of-thought.tsxindex 329f41d6a..e09bb9ef6 100644--- a/web-app/src/components/ai-elements/chain-of-thought.tsx+++ b/web-app/src/components/ai-elements/chain-of-thought.tsx@@ -117,7 +117,7 @@ export const ChainOfThought = memo(return (<ChainOfThoughtContext.Provider value={contextValue}><Collapsible- className={cn('not-prose mb-4', className)}+ className={cn('not-prose', className)}onOpenChange={handleOpenChange}open={isOpen}{...props}diff --git a/web-app/src/components/ai-elements/reasoning.tsx b/web-app/src/components/ai-elements/reasoning.tsxindex 0fcb9b0a1..708155d7c 100644--- a/web-app/src/components/ai-elements/reasoning.tsx+++ b/web-app/src/components/ai-elements/reasoning.tsx@@ -98,7 +98,7 @@ export const Reasoning = memo(return (<ReasoningContext.Provider value={contextValue}><Collapsible- className={cn('not-prose mb-4', className)}+ className={cn('not-prose', className)}onOpenChange={handleOpenChange}open={isOpen}{...props}diff --git a/web-app/src/containers/ModelInfoHoverCard.tsx b/web-app/src/containers/ModelInfoHoverCard.tsxindex 860559227..fd317084d 100644--- a/web-app/src/containers/ModelInfoHoverCard.tsx+++ b/web-app/src/containers/ModelInfoHoverCard.tsx@@ -16,6 +16,7 @@ import {DEFAULT_CTX_LENGTH,estimateModelFit,parseFileSize,+ sumMlxModelBytes,type FitTier,} from '@/lib/modelCompatibility'import { cn } from '@/lib/utils'@@ -76,12 +77,13 @@ export const ModelInfoHoverCard = ({}: ModelInfoHoverCardProps) => {const hardwareData = useHardware((s) => s.hardwareData)- if (model.is_mlx) return null+ const displayVariant = model.is_mlx+ ? undefined+ : variant ?? selectDefaultQuant(model.quants, defaultModelQuantizations)- const displayVariant =- variant ?? selectDefaultQuant(model.quants, defaultModelQuantizations)-- const fileSizeBytes = parseFileSize(displayVariant?.file_size)+ const fileSizeBytes = model.is_mlx+ ? sumMlxModelBytes(model) || null+ : parseFileSize(displayVariant?.file_size)const tier: FitTier = estimateModelFit(fileSizeBytes,DEFAULT_CTX_LENGTH,@@ -122,14 +124,16 @@ export const ModelInfoHoverCard = ({</div><div className="grid grid-cols-1 gap-4 text-xs">- <div>- <span className="text-muted-foreground block">- {isDefaultVariant ? 'Default Quantization' : 'Quantization'}- </span>- <span className="font-medium mt-1 inline-block">- {extractQuantLabel(displayVariant?.model_id) || 'N/A'}- </span>- </div>+ {!model.is_mlx && (+ <div>+ <span className="text-muted-foreground block">+ {isDefaultVariant ? 'Default Quantization' : 'Quantization'}+ </span>+ <span className="font-medium mt-1 inline-block">+ {extractQuantLabel(displayVariant?.model_id) || 'N/A'}+ </span>+ </div>+ )}<div><span className="text-muted-foreground block">diff --git a/web-app/src/lib/modelCompatibility.ts b/web-app/src/lib/modelCompatibility.tsindex cddedfffa..b82f8564b 100644--- a/web-app/src/lib/modelCompatibility.ts+++ b/web-app/src/lib/modelCompatibility.ts@@ -1,4 +1,5 @@import type { HardwareData } from '@/hooks/useHardware'+import type { CatalogModel } from '@/services/models/types'export type FitTier = 'green' | 'yellow' | 'red' | 'unknown'@@ -42,6 +43,15 @@ export function parseFileSize(input?: string | number | null): number | null {return value * multiplier}+// MLX models are split across multiple safetensors shards; sum them to get+// the on-device weight footprint that should be fed into estimateModelFit.+export function sumMlxModelBytes(model: CatalogModel): number {+ return (model.safetensors_files ?? []).reduce(+ (acc, f) => acc + (parseFileSize(f.file_size) ?? 0),+ 0+ )+}+export function estimateKvCacheBytes(fileSizeBytes: number,ctxLength: number = DEFAULT_CTX_LENGTHdiff --git a/web-app/src/lib/thread-title-summarizer.ts b/web-app/src/lib/thread-title-summarizer.tsindex 396b57a92..fc83fc89f 100644--- a/web-app/src/lib/thread-title-summarizer.ts+++ b/web-app/src/lib/thread-title-summarizer.ts@@ -20,10 +20,16 @@ function buildSummarizePrompt(transcript: string): string {export function cleanTitle(raw: string): string | null {let text = raw.trim()- // Strip reasoning blocks like <think>...</think>- const thinkMatch = text.match(/<\/think>\s*(.*)$/s)- if (thinkMatch) {- text = thinkMatch[1].trim()+ // Strip complete reasoning blocks like <think>...</think> (any tag name)+ text = text.replace(/<(think|thinking|reasoning|analysis)[^>]*>[\s\S]*?<\/\1>/gi, '').trim()++ // If a reasoning opener remains without a close, the output is all reasoning — unusable+ if (/<(think|thinking|reasoning|analysis)[^>]*>/i.test(text)) return null++ // If only a closing tag is present, take what's after the last one+ const lastClose = text.match(/<\/(?:think|thinking|reasoning|analysis)>\s*([\s\S]*)$/i)+ if (lastClose) {+ text = lastClose[1].trim()}// Remove leftover XML-like tags@@ -64,6 +70,9 @@ export async function generateThreadTitle(return null}+ // MLX models often emit reasoning that can't be reliably suppressed; fall back to default title.+ if (selectedProvider === 'mlx') return null+const provider = getProviderByName(selectedProvider)if (!provider) {console.warn('[ThreadTitle] Provider not found:', selectedProvider)diff --git a/web-app/src/locales/en/providers.json b/web-app/src/locales/en/providers.jsonindex 12c962c98..90cf54967 100644--- a/web-app/src/locales/en/providers.json+++ b/web-app/src/locales/en/providers.json@@ -1,5 +1,6 @@{"limitedSupport": "This provider may not be fully supported. Capabilities (tools, vision, audio) are not auto-detected - add models manually and configure capabilities per model.",+ "mlxExperimental": "MLX support is experimental. Embeddings are unavailable, the reasoning toggle is not yet wired through, and some newer model architectures may fail to load. Report issues on GitHub so we can prioritize them.","refreshModelsError": "Provider must have base URL and at least one API key configured to fetch models.","refreshModelsSuccess": "Added {{count}} new model(s) from {{provider}}.","noNewModels": "No new models found. All available models are already added.",diff --git a/web-app/src/routes/hub/index.tsx b/web-app/src/routes/hub/index.tsxindex 6f06d1b2a..72e1c3c19 100644--- a/web-app/src/routes/hub/index.tsx+++ b/web-app/src/routes/hub/index.tsx@@ -3,7 +3,8 @@ import { useVirtualizer } from '@tanstack/react-virtual'import { createFileRoute, useNavigate } from '@tanstack/react-router'import { route } from '@/constants/routes'import { useModelSources } from '@/hooks/useModelSources'-import { cn, sanitizeModelId } from '@/lib/utils'+import { cn, formatBytes, sanitizeModelId } from '@/lib/utils'+import { sumMlxModelBytes } from '@/lib/modelCompatibility'import {useState,useMemo,@@ -547,8 +548,11 @@ function HubContent() {<div className="flex items-center gap-2"><span className="text-muted-foreground font-medium text-xs">{filteredModels[virtualItem.index].is_mlx- ? filteredModels[virtualItem.index]- .safetensors_files?.[0]?.file_size+ ? formatBytes(+ sumMlxModelBytes(+ filteredModels[virtualItem.index]+ ) || undefined+ ): selectDefaultQuant(filteredModels[virtualItem.index].quants,DEFAULT_MODEL_QUANTIZATIONSdiff --git a/web-app/src/routes/settings/providers/$providerName.tsx b/web-app/src/routes/settings/providers/$providerName.tsxindex 4f827a997..6e84b9b45 100644--- a/web-app/src/routes/settings/providers/$providerName.tsx+++ b/web-app/src/routes/settings/providers/$providerName.tsx@@ -737,6 +737,18 @@ function ProviderDetail() {</div>)}+ {provider?.provider === 'mlx' && (+ <div className="flex items-start gap-2 rounded-md border border-main-view-fg/10 bg-main-view-fg/5 px-3 py-2 text-xs text-muted-foreground">+ <IconInfoCircle size={16} className="mt-0.5 shrink-0" />+ <span>+ {t('providers:mlxExperimental', {+ defaultValue:+ 'MLX support is experimental. Embeddings are unavailable, the reasoning toggle is not yet wired through, and some newer model architectures may fail to load. Report issues on GitHub so we can prioritize them.',+ })}+ </span>+ </div>+ )}+<divclassName={cn('flex flex-col gap-3',