new features

This commit is contained in:
Mark Gregory
2026-11-19 09:18:49 +00:00
parent a07ddf4d6d
commit 0720c8a18b
13 changed files with 918 additions and 211 deletions
+15 -55
View File
@@ -60,6 +60,12 @@ struct AIStudioApp: App {
.tint(StudioCustomTheme.selected(customThemeID, in: customThemesData)?.accentColor ?? accent.color)
}
.defaultSize(width: 990, height: 690)
Window("Model Performance", id: "modelPerformance") {
PerformanceDashboard(studio: studio)
.preferredColorScheme(theme.colorScheme)
.tint(StudioCustomTheme.selected(customThemeID, in: customThemesData)?.accentColor ?? accent.color)
}
.defaultSize(width: 1030, height: 690)
Settings {
StudioSettingsView(studio: studio)
.preferredColorScheme(theme.colorScheme)
@@ -114,7 +120,6 @@ struct ChatView: View {
@AppStorage("globalCustomPrompt") private var customPrompt = ""
@AppStorage(GenerationSettings.key) private var generationSettings = Data()
@State private var showingPromptBuilder = false
@State private var showingPerformance = false
@State private var showingComparison = false
@State private var comparisonChat: UUID?
@StateObject private var splitStudio = StudioModel()
@@ -327,7 +332,10 @@ struct ChatView: View {
}
}
.disabled(splitStudio.running || (studio.conversations.count < 2 && !showingComparison))
Button("Performance", systemImage: "chart.xyaxis.line") { showingPerformance = true }
Button("Performance", systemImage: "chart.xyaxis.line") {
studio.performanceModel = chatModel
openWindow(id: "modelPerformance")
}
}
}
.toolbar(mode == .zen ? .hidden : .visible, for: .windowToolbar)
@@ -343,7 +351,7 @@ struct ChatView: View {
AgentToolApprovalView(approval: approval) { studio.resolveAgentTool(approval.id, approved: $0) }
}
.sheet(isPresented: $showingLibrary) { DocumentLibraryView(studio: studio) }
.sheet(isPresented: $showingPerformance) { PerformanceDashboard(studio: studio) }
.onChange(of: chatModel, initial: true) { _, choice in studio.performanceModel = choice }
.sheet(isPresented: $showingWorkspace) { WorkspaceResourcesView(studio: studio) }
.sheet(item: $filePreview) { pending in
let preview = pending.preview
@@ -397,6 +405,8 @@ struct ChatView: View {
model = defaults.string(forKey: "ollamaModel") ?? ""
mlxOnly = defaults.bool(forKey: "mlxOnly")
compatibleEnabled = defaults.bool(forKey: "compatibleEnabled")
compatibleEndpoint = defaults.string(forKey: "compatibleEndpoint") ?? "http://127.0.0.1:1234/v1"
compatibleModel = defaults.string(forKey: "compatibleModel") ?? ""
}
.onChange(of: studio.selected) { old, _ in
if old != nil {
@@ -624,7 +634,7 @@ struct ChatView: View {
Button("Send", systemImage: "arrow.up", action: sendMessage)
.buttonStyle(.borderedProminent)
.keyboardShortcut(.return, modifiers: .command)
.disabled(studio.prompt.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty)
.disabled(studio.benchmarkRunning || studio.prompt.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty)
}
}
}
@@ -1034,6 +1044,7 @@ struct MessageView: View {
Text(message.content).textSelection(.enabled)
}
}
if let timing = message.performance { ReplyPerformance(run: timing) }
ForEach(message.documentNames, id: \.self) { name in
Label(name, systemImage: "paperclip")
.font(.caption.weight(.semibold))
@@ -1621,57 +1632,6 @@ struct PromptBuilder: View {
}
}
struct PerformanceDashboard: View {
@Environment(\.dismiss) private var dismiss
@ObservedObject var studio: StudioModel
var body: some View {
VStack(alignment: .leading, spacing: 14) {
HStack {
Text("Inference Performance").font(.title2.bold())
Spacer()
Button("Done") { dismiss() }.keyboardShortcut(.defaultAction)
}
Text("Last 50 generations. First output includes model loading and any fallback.")
.foregroundStyle(.secondary)
if studio.running {
Label("Generation in progress…", systemImage: "ellipsis").foregroundStyle(.secondary)
}
if studio.measurements.isEmpty {
ContentUnavailableView("No measurements yet", systemImage: "chart.xyaxis.line",
description: Text("Send a chat message to collect timing and throughput."))
} else {
Chart {
ForEach(Array(studio.measurements.reversed().enumerated()), id: \.element.id) { index, run in
BarMark(x: .value("Run", index + 1), y: .value("Seconds", run.seconds))
.foregroundStyle(by: .value("Backend", run.backend))
}
}
.chartXAxisLabel("Generation")
.chartYAxisLabel("Total seconds")
.frame(height: 160)
Table(studio.measurements) {
TableColumn("Backend", value: \.backend)
TableColumn("First output") { Text(seconds($0.firstOutput)) }
TableColumn("Total") { Text(seconds($0.seconds)) }
TableColumn("Tokens/s") { Text($0.provider?.tokensPerSecond.map { $0.formatted(.number.precision(.fractionLength(1))) } ?? "—") }
TableColumn("Tokens") { Text($0.provider?.tokens.formatted() ?? "—") }
TableColumn("Characters/s") { run in
Text(run.charactersPerSecond.map { $0.formatted(.number.precision(.fractionLength(1))) } ?? "—")
}
TableColumn("Outcome", value: \.outcome)
}
}
}
.padding(20)
.frame(minWidth: 800, minHeight: 475)
}
private func seconds(_ value: Double?) -> String {
value.map { $0.formatted(.number.precision(.fractionLength(2))) + " s" } ?? "—"
}
}
struct GenerationSettingsView: View {
@AppStorage("globalPromptMode") private var promptMode = PromptMode.standard
@AppStorage("globalCustomPrompt") private var prompt = ""