2.6.0 #18

Merged
rune merged 26 commits from 2.6.0 into main 2026-11-25 11:50:07 +01:00
Owner

November release.

November release.
rune added 26 commits 2026-11-25 11:49:56 +01:00
The input bar already live-formats inline `code` and fenced ```code```
blocks as you type, but sending a message used to revert to literal
backticks since user messages rendered as plain text. Now reuses
NativeTextEditor's own (already-tested) backtick/fence parsers plus the
existing CodeBlockView component assistant messages already use, so a
sent message shows the same code styling it had while being typed -
without turning on full markdown (bold/italic/lists) for user messages.
Reported by Rune: a weather question triggered his DigitalOcean MCP
server's tool, among others, on a smaller OpenRouter model (Qwen
3.8 27B). Confab exposes every enabled MCP server's full tool list on
every turn with no per-query filtering (by design - the model needs to
see what's available), but toolUsageGuidelines never actually told it
to only use what's relevant - it only covered proving you used tools
once you decided to. Same root cause as the Apple On-Device Paperless/
Mail mixup (bcd45ff): weaker models have looser tool-selection
discipline without explicit guidance. Added a CRITICAL section right
near the top of the block (small models weight early tokens more, per
that same precedent) telling the model irrelevant tools aren't a
reason to call them.
Adds a real guarantee on top of the earlier prompt-level fix: a
"Require Approval" toggle on each External MCP server (default on, for
both new and existing servers) that shows an approval dialog before
that server's tool calls actually execute, mirroring the existing
Bash/Mail/Calendar gate pattern. Scoped per-server rather than
globally - "Allow for Session" on one server never silently approves
a different server's calls, tracked via a Set<UUID> of approved
server IDs instead of a single flag.

- ExternalMCPServer gains requireApproval (Bool, defaults true;
  decodes safely from pre-existing saved servers missing the key)
- ExternalMCPManager.serverForTool(_:) exposes server lookup without
  executing, so the gate can check requireApproval before running
- MCPService.executeExternalMCPAction mirrors executeMailAction's
  suspend/resume-via-continuation pattern
- New ExternalMCPApprovalSheet (server/tool name + pretty-printed
  arguments), built on the shared ApprovalSheetChrome/ApprovalInfoBox
- Toggle lives in the add/edit server sheet (not the already-dense
  server list row), localized into nb/sv/da/de/fr
- Extended ExternalMCPModelsTests with requireApproval decode-default
  and round-trip coverage
build.sh is gitignored and only exists in the maintainer's local
checkout - external contributors cloning the repo had no way to
follow that instruction. Replaced with an explanation of the XProtect
false positive and an actionable workaround (System Settings ->
"Open Anyway") that doesn't require a Developer ID certificate.
Monospace font alone didn't make it stand out against surrounding
plain text, per Rune's screenshot. Adds a light background tint to
the inline code run (Color.primary.opacity(0.1), adapts to light/dark
mode), matching the highlight NativeTextEditor already applies while
typing - just carried through to the sent message.
Claude Opus 5.5 (and presumably future models) reject `temperature` outright
with "`temperature` is deprecated for this model.", breaking any Anthropic
call that sets it (AI-Assisted Merge, regular chat, tool calls). Rather than
hardcoding a model-ID list that will go stale, detect the API's own error
message and retry once without the parameter, across chat(), streamChat(),
and chatWithToolMessages(). streamChat() also now actually reads the error
body on a non-200 status instead of discarding it.
The merge's max_tokens budget was computed to scale with input size per its
own comment, but then hard-capped at 16000 regardless — exactly the kind of
large multi-conversation merge that needs more got silently truncated
mid-JSON, which then failed with an unhelpful "could not be parsed" snippet
that just showed the start of the (truncated) response. Raise the ceiling to
64000, and when parsing still fails, check the response's finish/stop reason
and report truncation explicitly when that's the actual cause.
Caught right after writing them: the merge error strings (including the
new truncation/parse-failure messages from the previous commit) were plain
Swift string literals, never routed through Text()/String(localized:), so
non-English users would always see English error text. Wrap all five cases
in String(localized:) and add translated catalog entries.
Closes the long-open "local embeddings" roadmap item. Apple's NaturalLanguage
framework (NLContextualEmbedding, not the simpler NLEmbedding — which fails to
load for de/fr and has no nb/sv/da support at all, verified live) covers all
six of Confab's languages with no API key, no cost, and no network dependency.
Mean-pools subword token vectors into a 512-dim sentence embedding; semantic
search only ever ranks by relative similarity, so the narrower cosine range
versus cloud embeddings doesn't affect ranking quality.

Enable Embeddings now works out of the box with zero configuration — the new
default provider for untouched installs is Apple On-Device rather than a
cloud key that may not exist.
The Conversations list "Semantic" toggle was plain @State, so it silently
reset to off every time the modal was dismissed and reopened. Moved it to
SettingsService (conversationListSemanticSearchEnabled), same pattern as
embeddingsEnabled.

"Embed All Conversations" only ever reported progress via chat system
messages, invisible while the Settings sheet covers the chat view, and with
no live counter. Added isBatchEmbedding/embeddingBatchProcessed/
embeddingBatchTotal to ChatViewModel, read directly by a progress bar next
to the button. Also dropped the 100ms-per-message rate limit for the
on-device provider — it exists to stay under paid cloud API quotas, which
don't apply locally.
NLContextualEmbedding silently stops contributing to the mean-pooled vector
past ~256 subword tokens per call, so a single embedding over an entire
(truncated) conversation mostly reflected whatever text came first rather
than the conversation's actual topic - this is the likely cause of the poor
real-query relevance confirmed live twice (see project memory). Conversation
text embedded via Apple On-Device is now split into ~700-char windows, each
embedded separately and stored as its own row in a new
conversation_embedding_chunks table (v14 migration); search now scores a
conversation by its best-matching chunk instead of one smeared-out average.
Cloud providers are unaffected - they don't exhibit this truncation, so they
still embed the whole (already-truncated) text as a single chunk.
NLContextualEmbedding was confirmed too weak for real retrieval (general-purpose
LM, not retrieval-trained). Replaces it with a self-converted, int8-quantized
CoreML build of intfloat/multilingual-e5-small (384-dim, retrieval-trained),
downloaded lazily on first use from dl.confab.no (~113MB, too large to bundle)
and compiled/cached locally, plus a from-scratch Swift SentencePiece tokenizer
(bundled vocab, 4.8MB).

- E5Vocab/E5Tokenizer: ported tokenizer, verified against the real HF
  tokenizer's output for known cases including the real "vannskade" test case
- E5EmbeddingModel: CoreML inference (tokenize/pad/mask -> predict -> decode
  the model's float16 output via a hand-rolled, unit-tested bit-conversion
  rather than relying on Float16 arithmetic support on non-ARM hosts)
- E5ModelDownloadService: manifest fetch, resumable-progress download via
  URLSessionDownloadDelegate, sha256 verification, unzip (via Process +
  terminationHandler, never waitUntilExit), compile, and local caching
- EmbeddingService.generateEmbedding now takes an explicit query/passage role:
  multilingual-e5-small requires a "query: "/"passage: " prefix convention to
  retrieve correctly, which the old model never needed
- Settings UI updated with download progress; i18n added for all new strings
  across all 6 shipped languages

Existing stored apple-on-device embeddings have the old 512-dim shape and
will score 0 similarity against new ones (cosineSimilarity already guards
dimension mismatches) -- re-running "Embed All Conversations" is needed to
pick up the new model.

Verified end-to-end (not just unit tests): a standalone script ran the actual
published model through the full tokenize -> pad -> CoreML predict -> decode
pipeline and confirmed correct relevant/irrelevant ranking in English and
Norwegian.
The new multilingual-e5-small on-device embedding model is a lazy ~113MB
download from dl.confab.no, unlike NLContextualEmbedding which used Apple's
own built-in asset delivery. Enabling "Semantic Search" alone shouldn't be
read as consent to that specific network fetch, and the silent background
per-message embedder (fires after every chat message when embeddings are
enabled) must never be what triggers it.

- E5ModelDownloadService.isModelCachedOnDisk: local-only (no network) check
  for whether a compiled model already exists, used to gate every path that
  could otherwise download without asking
- ChatViewModel.embedMessage (the silent background path): skips quietly if
  the model isn't cached yet, never downloads
- SettingsView's "Embed All Conversations" button and ConversationListView's
  semantic search: both show a one-time confirmation alert before the first
  real download, backed by a persisted onDeviceModelDownloadConsented
  setting so it's asked once, not every time
- batchEmbedAllConversations keeps its own guard as a safety net regardless
  of call site
- i18n added for all new strings across all 6 shipped languages
Ported from a standalone SwiftPM package that has no -default-isolation
setting of its own, so neither type carried the explicit nonisolated
marker this project's -default-isolation=MainActor build setting requires
for stateless value types called from a non-MainActor actor context
(E5EmbeddingModel). Surfaced as Swift 6 strict-concurrency warnings in a
Release build, not caught by a Debug build check that only grepped for
"error:" and missed the warnings entirely.
E5ModelDownloadService assumed the downloaded zip's top-level entry was
named "package.mlpackage" -- it's actually named after the original file
(publish-model.sh's convention), e.g. "multilingual-e5-small-int8.mlpackage".
The mismatch meant the post-unzip existence check failed every time, which
threw, which ChatViewModel's per-message catch-and-continue silently logged
and counted as "processed" anyway -- so every single embed re-triggered a
full ~109MB re-download from scratch, forever, with the batch progress
counter climbing the whole time as if nothing were wrong. Live-caught by
Rune watching the download restart repeatedly in Settings.

Fixed by deriving the package directory name from manifest.file (stripping
".zip"). Verified against the real published model, not just a unit test:
unzipped the actual artifact, confirmed the derived name matches the real
directory on disk, and ran it through MLModel.compileModel(at:) + load
standalone (outside the app) to confirm the full pipeline now succeeds.
filteredConversations (semanticResults) is already a correct, globally
cross-folder-ranked top-N list -- confirmed DatabaseService.searchConversa
tionsBySemantic sorts by similarity descending before capping to the
requested limit. But the list view grouped results into Sections by
folder tree order regardless, which silently discards that global ranking:
every (possibly weak) match sitting in whichever folder sorts first gets
shown before a much stronger match in a different folder, making a
perfectly good ranking look useless. It also meant there was nothing
meaningful to collapse, since folder collapse state is already ignored
during any active search -- so the folder header looked clickable but did
nothing, which is exactly what Rune reported seeing.

Fixed by rendering a flat ranked list during active semantic search,
bypassing folder grouping entirely (same code path as the no-folders
case) -- matching the actual mental model of a ranked search, where
"which folder" shouldn't determine display order. Extracted as a pure,
tested gate function (isShowingRankedSemanticResults), matching this
view's existing effectiveCollapsedFolders pattern, and fixed
visibleOrderedConversations (shift-click range selection) to match.
This cycle's work (on-device semantic search model replacement + a real
security hardening pass: Keychain migration, path-traversal/symlink fix,
IMAP injection fix) is a bigger jump than a patch-level bump reflects.
Same root cause as the earlier E5Vocab/E5Tokenizer fix (ae8c77e) -- this
enum was added fresh in this file rather than ported, so it was missed in
that sweep. Surfaced as a Swift 6 isolation warning in a Universal Release
build (role.prefix accessed from E5EmbeddingModel's actor context). Full
clean Debug + Release builds and test suite verified warning-free this
time, not just the one line.
rune merged commit b6c2638d4a into main 2026-11-25 11:50:07 +01:00
Sign in to join this conversation.
No reviewers
No labels
user-feedback
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
rune/oai-swift!18
No description provided.