Skip to content
2 changes: 1 addition & 1 deletion Sources/Hushtype/DictationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ final class DictationController: ObservableObject {
releasedAt: Date) {
guard let assistant = settings.makeAssistant() else {
session.cancel()
return show(error: "Add your Anthropic key in Settings to use commands.")
return show(error: "Add your Anthropic key in Settings to use commands, or switch polishing to on-device.")
}
let vocabulary = settings.vocabulary
pipelineTask = Task {
Expand Down
8 changes: 4 additions & 4 deletions Sources/Hushtype/Onboarding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ enum OnboardingStep: Int, CaseIterable {
case .welcome: return "Welcome"
case .permissions: return "Permissions"
case .speechModel: return "Voice model"
case .claude: return "Connect Claude"
case .claude: return "Polish"
case .tryIt: return "Try it"
}
}
Expand Down Expand Up @@ -190,7 +190,7 @@ struct OnboardingView: View {
VStack(alignment: .leading, spacing: 14) {
feature("keyboard", .blue, "Works everywhere", "Slack, Mail, Notion, your code editor. Anywhere you can type.")
feature("sparkles", .pink, "Reads like you wrote it", "Filler words gone, punctuation fixed, corrections applied.")
feature("lock.fill", .teal, "Your keys, your data", "Speech is transcribed on this Mac. Only text goes to Claude, with your own key.")
feature("lock.fill", .teal, "Your keys, your data", "Speech is transcribed on this Mac, and it can be polished here too. Claude is optional.")
}
}
}
Expand Down Expand Up @@ -300,7 +300,7 @@ struct OnboardingView: View {

private var claudeStep: some View {
VStack(alignment: .leading, spacing: 0) {
header("Connect Claude", "Your speech is transcribed on this Mac, then Claude turns it into clean, punctuated text. One key is all it takes.")
header("Polish your words", "Hushtype turns what you said into clean, punctuated text. Choose where that happens.")
PolishCard(settings: settings)
}
}
Expand Down Expand Up @@ -400,7 +400,7 @@ struct OnboardingView: View {
switch item {
case .permissions: return Permissions.allGranted && controller.hotkeyActive
case .speechModel: return modelStatus == .installed
case .claude: return !settings.cleanupEnabled || !settings.apiKey(.anthropic).isEmpty
case .claude: return !settings.cleanupEnabled || settings.polishReady
default: return true
}
}
Expand Down
41 changes: 33 additions & 8 deletions Sources/Hushtype/SettingsStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ final class SettingsStore: ObservableObject {
@Published var triggerKey: TriggerKey { didSet { defaults.set(triggerKey.rawValue, forKey: "triggerKey") } }
@Published var language: String { didSet { defaults.set(language, forKey: "language") } }
@Published var cleanupEnabled: Bool { didSet { defaults.set(cleanupEnabled, forKey: "cleanupEnabled") } }
/// Polish on this Mac with Apple Intelligence, or with Claude. Kept per Mac, since whether
/// Apple Intelligence can run depends on the Mac.
@Published var cleanupEngine: CleanupEngine { didSet { defaults.set(cleanupEngine.rawValue, forKey: "cleanupEngine") } }
@Published var dictionaryText: String { didSet { defaults.set(dictionaryText, forKey: "dictionary") } }
@Published var soundsEnabled: Bool { didSet { defaults.set(soundsEnabled, forKey: "soundsEnabled") } }
/// Keep the mic open all the time so dictation starts instantly and catches the first word.
Expand Down Expand Up @@ -53,6 +56,7 @@ final class SettingsStore: ObservableObject {
triggerKey = TriggerKey(rawValue: defaults.string(forKey: "triggerKey") ?? "") ?? .rightOption
language = defaults.string(forKey: "language") ?? "en"
cleanupEnabled = defaults.object(forKey: "cleanupEnabled") as? Bool ?? true
cleanupEngine = CleanupEngine(rawValue: defaults.string(forKey: "cleanupEngine") ?? "") ?? .claude
dictionaryText = defaults.string(forKey: "dictionary") ?? ""
soundsEnabled = defaults.object(forKey: "soundsEnabled") as? Bool ?? true
alwaysReadyMic = defaults.bool(forKey: "alwaysReadyMic")
Expand All @@ -65,6 +69,11 @@ final class SettingsStore: ObservableObject {
syncAPIKey = defaults.bool(forKey: "syncAPIKey")
hasCompletedOnboarding = defaults.bool(forKey: "hasCompletedOnboarding")
onboardingStep = defaults.integer(forKey: "onboardingStep")
if defaults.string(forKey: "cleanupEngine") == nil {
// First run of a version with the choice: people who already use Claude keep it,
// everyone else starts on-device when this Mac supports it.
cleanupEngine = .preferred(hasClaudeKey: !apiKey(.anthropic).isEmpty)
}
}

var vocabulary: [String] { DictationPipeline.vocabulary(from: dictionaryText) }
Expand Down Expand Up @@ -115,15 +124,31 @@ final class SettingsStore: ObservableObject {
return true
}

/// Command mode always needs Claude, even with polishing turned off.
func makeAssistant() -> TranscriptCleaner? {
let key = apiKey(.anthropic)
return key.isEmpty ? nil : TranscriptCleaner(apiKey: key)
/// Command mode uses the chosen engine even with polishing turned off. Nil when Claude is
/// chosen and there's no key.
func makeAssistant() -> (any TranscriptPolisher)? {
switch cleanupEngine {
case .onDevice:
return OnDeviceCleaner()
case .claude:
let key = apiKey(.anthropic)
return key.isEmpty ? nil : TranscriptCleaner(apiKey: key)
}
}

func makeCleaner() -> TranscriptCleaner? {
let key = apiKey(.anthropic)
guard cleanupEnabled, !key.isEmpty else { return nil }
return TranscriptCleaner(apiKey: key)
/// The polisher for dictations, or nil when polishing is off or Claude has no key. On-device
/// polishing is returned even when Apple Intelligence is off, so the notice after a dictation
/// says how to turn it on.
func makeCleaner() -> (any TranscriptPolisher)? {
guard cleanupEnabled else { return nil }
return makeAssistant()
}

/// Whether polishing will actually run with the current choice.
var polishReady: Bool {
switch cleanupEngine {
case .onDevice: return OnDeviceCleaner.availability == .available
case .claude: return !apiKey(.anthropic).isEmpty
}
}
}
66 changes: 45 additions & 21 deletions Sources/Hushtype/SettingsWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ enum SettingsPane: String, CaseIterable, Identifiable {
switch self {
case .home: return "Home"
case .dictation: return "Dictation"
case .claude: return "Claude Polish"
case .claude: return "Polish"
case .dictionary: return "Dictionary"
case .snippets: return "Snippets"
case .history: return "History"
Expand All @@ -27,7 +27,7 @@ enum SettingsPane: String, CaseIterable, Identifiable {
switch self {
case .home: return "Whether Hushtype is ready, and what you've dictated lately."
case .dictation: return "Choose the key you hold to talk, and how Hushtype listens."
case .claude: return "Claude cleans up what you said before it's typed. Only text leaves your Mac."
case .claude: return "Hushtype cleans up what you said before it's typed, on this Mac or with Claude."
case .dictionary: return "Names and terms Hushtype should always spell your way."
case .snippets: return "Say a phrase, and Hushtype types your saved text exactly as written."
case .history: return "Your recent dictations, saved only on this Mac."
Expand Down Expand Up @@ -63,7 +63,7 @@ enum SettingsPane: String, CaseIterable, Identifiable {
switch self {
case .home: return ["status", "ready", "overview", "recent"]
case .dictation: return ["key", "hotkey", "fn", "option", "hands-free", "language", "sound", "microphone", "mic", "shortcut", "command"]
case .claude: return ["polish", "api key", "anthropic", "context", "app", "privacy", "speed", "latency"]
case .claude: return ["claude", "polish", "api key", "anthropic", "on-device", "apple intelligence", "offline", "context", "app", "privacy", "speed", "latency"]
case .dictionary: return ["words", "vocabulary", "names", "spelling", "learn", "corrections"]
case .snippets: return ["shortcut", "expand", "text", "phrase"]
case .history: return ["recent", "copy", "paste last", "search"]
Expand Down Expand Up @@ -520,7 +520,7 @@ private struct HomePane: View {
.font(.system(size: 22, weight: .semibold))
.tracking(-0.4)
Text(ready
? "Let go and your words appear wherever you're typing\(settings.cleanupEnabled ? ", polished by Claude" : "")."
? "Let go and your words appear wherever you're typing\(polishPhrase)."
: "Hushtype still needs a permission before the dictation key works.")
.font(.callout)
.foregroundStyle(.secondary)
Expand Down Expand Up @@ -548,6 +548,11 @@ private struct HomePane: View {
.overlay(RoundedRectangle(cornerRadius: 16, style: .continuous).strokeBorder(Color.primary.opacity(0.1), lineWidth: 0.5))
}

private var polishPhrase: String {
guard settings.cleanupEnabled else { return "" }
return settings.cleanupEngine == .onDevice ? ", polished right on this Mac" : ", polished by Claude"
}

private func pill<Leading: View, Content: View>(@ViewBuilder icon: () -> Leading, @ViewBuilder label: () -> Content) -> some View {
HStack(spacing: 6) {
icon().font(.system(size: 10))
Expand Down Expand Up @@ -750,31 +755,47 @@ private struct ClaudePane: View {
SettingsPage(pane: .claude) {
PolishHero(settings: settings)

SectionLabel("Connection")
if settings.cleanupEnabled {
SectionLabel("Engine")
PolishEnginePicker(settings: settings)
}

SectionLabel(settings.cleanupEngine == .claude ? "Connection" : "On this Mac")
SettingsCard {
VStack(alignment: .leading, spacing: 10) {
HStack(spacing: 12) {
Glyph(symbol: "key")
VStack(alignment: .leading, spacing: 2) {
Text("Anthropic API key").fontWeight(.medium)
Text(settings.iCloudSync && settings.syncAPIKey
? "Saved in iCloud Keychain. Command mode uses it too."
: "Saved in your Keychain. Command mode uses it too.")
.font(.caption).foregroundStyle(.secondary)
switch settings.cleanupEngine {
case .claude:
VStack(alignment: .leading, spacing: 10) {
HStack(spacing: 12) {
Glyph(symbol: "key")
VStack(alignment: .leading, spacing: 2) {
Text("Anthropic API key").fontWeight(.medium)
Text(settings.iCloudSync && settings.syncAPIKey
? "Saved in iCloud Keychain. Command mode uses it too."
: "Saved in your Keychain. Command mode uses it too.")
.font(.caption).foregroundStyle(.secondary)
}
}
APIKeyField(service: .anthropic, settings: settings)
}
APIKeyField(service: .anthropic, settings: settings)
.padding(16)
case .onDevice:
OnDeviceStatus().padding(16)
}
.padding(16)
ToggleRow(title: "Match the app you're in",
subtitle: "Casual in Slack, careful in Mail. Spells names already on screen.",
symbol: "macwindow",
info: "Sends the app's name and the text around your cursor with the transcript, so Claude matches the tone and spells names already on screen. Password fields are never read.",
info: settings.cleanupEngine == .claude
? "Sends the app's name and the text around your cursor with the transcript, so Claude matches the tone and spells names already on screen. Password fields are never read."
: "Gives the on-device model the app's name and the text around your cursor, so it matches the tone and spells names already on screen. It never leaves your Mac, and password fields are never read.",
isOn: $settings.useContext)
}
HStack(spacing: 10) {
trust("lock", "Voice stays here", "Speech is transcribed on this Mac. Audio is never uploaded.")
trust("icloud", "Only text is sent", "Straight to Anthropic, with your own key.")
if settings.cleanupEngine == .claude {
trust("icloud", "Only text is sent", "Straight to Anthropic, with your own key.")
} else {
trust("lock.shield", "Text stays here too", "Apple Intelligence polishes it on this Mac, even offline.")
}
trust("lock.shield", "Passwords skipped", "Secure fields are never read for context.")
}
.padding(.top, 10)
Expand Down Expand Up @@ -811,12 +832,12 @@ private struct PolishHero: View {
HStack(spacing: 12) {
Glyph(symbol: "sparkles", brand: true)
VStack(alignment: .leading, spacing: 2) {
Text("Polish with Claude").fontWeight(.semibold)
Text(settings.cleanupEngine == .claude ? "Polish with Claude" : "Polish on this Mac").fontWeight(.semibold)
Text("Removes filler words, fixes punctuation, applies your corrections.")
.font(.caption).foregroundStyle(.secondary)
}
Spacer(minLength: 12)
Toggle("Polish with Claude", isOn: $settings.cleanupEnabled.animation(.easeInOut(duration: 0.2)))
Toggle("Polish", isOn: $settings.cleanupEnabled.animation(.easeInOut(duration: 0.2)))
.toggleStyle(.switch)
.labelsHidden()
}
Expand Down Expand Up @@ -928,6 +949,9 @@ private struct SpeedCard: View {
if let first = t.polishFirstToken, let polish = t.polish {
parts.append(Segment(id: "Claude's first word", seconds: first, color: .hushViolet))
parts.append(Segment(id: "Claude done", seconds: max(0, polish - first), color: .hushMint))
} else if let polish = t.polish {
// On-device polishing replies all at once.
parts.append(Segment(id: "Polish on this Mac", seconds: polish, color: .hushMint))
}
return parts
}
Expand Down Expand Up @@ -1332,7 +1356,7 @@ private struct GeneralPane: View {
SettingsPage(pane: .general) {
SettingsCard {
ToggleRow(title: "Open Hushtype at login", symbol: "power", isOn: $launchAtLogin)
SettingsRow(title: "Setup assistant", subtitle: "Walk through permissions, your key and Claude again.",
SettingsRow(title: "Setup assistant", subtitle: "Walk through permissions and polishing again.",
symbol: "wand.and.stars") {
Button("Run Setup Again…", action: runSetup)
}
Expand Down
Loading
Loading