Track usage independent of conversation save state; fix Analytics toolbar button

Conversation text is still only persisted when explicitly saved (⌘S),
but tokens/cost/model/provider are now logged to a new usage_events
table for every completed AI response regardless — the Analytics
view now reads from this table instead of messages, so it reflects
real usage even for conversations that were never saved. Adds a
By Provider chart mode alongside Over Time/By Model.

Also fixes the Analytics entry point: ToolbarItem(placement: .navigation)
silently doesn't render in a plain .sheet-presented NavigationStack on
macOS. Moved the button inline next to the segmented picker, matching
the codebase's existing convention (e.g. the model-favorites star filter).
This commit is contained in:
2026-08-12 13:49:12 +02:00
parent d460230158
commit 30e18f92a5
7 changed files with 514 additions and 17 deletions
+34
View File
@@ -1,6 +1,40 @@
{
"sourceLanguage" : "en",
"strings" : {
"By Provider" : {
"localizations" : {
"da" : {
"stringUnit" : {
"state" : "translated",
"value" : "Efter udbyder"
}
},
"de" : {
"stringUnit" : {
"state" : "translated",
"value" : "Nach Anbieter"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
"value" : "Par fournisseur"
}
},
"nb" : {
"stringUnit" : {
"state" : "translated",
"value" : "Etter leverandør"
}
},
"sv" : {
"stringUnit" : {
"state" : "translated",
"value" : "Efter leverantör"
}
}
}
},
"Today" : {
"localizations" : {
"da" : {