-
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathSettingsSearchIndex.swift
More file actions
309 lines (292 loc) · 10.3 KB
/
Copy pathSettingsSearchIndex.swift
File metadata and controls
309 lines (292 loc) · 10.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
// SettingsSearchIndex.swift
// VocaMac
//
// Lightweight searchable index over settings controls (no third-party deps).
import Foundation
/// One searchable settings control / topic entry.
struct SettingsSearchEntry: Hashable, Identifiable {
let id: String
let page: SettingsPage
let title: String
let subtitle: String?
let keywords: [String]
init(
id: String,
page: SettingsPage,
title: String,
subtitle: String? = nil,
keywords: [String] = []
) {
self.id = id
self.page = page
self.title = title
self.subtitle = subtitle
self.keywords = keywords
}
}
/// Indexes settings controls for live sidebar search.
enum SettingsSearchIndex {
/// Full catalog of searchable settings rows.
static let entries: [SettingsSearchEntry] = [
// Dictation
SettingsSearchEntry(
id: "activation-mode",
page: .dictation,
title: "Activation Mode",
subtitle: "Push to talk or double-tap toggle",
keywords: ["hotkey", "ptt", "toggle", "hold"]
),
SettingsSearchEntry(
id: "hotkey",
page: .dictation,
title: "Hotkey",
subtitle: "Activation key",
keywords: ["shortcut", "option", "key"]
),
SettingsSearchEntry(
id: "trailing-space",
page: .dictation,
title: "Trailing Space After Dictation",
subtitle: "Space between utterances",
keywords: ["space", "output", "glue", "whitespace"]
),
SettingsSearchEntry(
id: "auto-capitalize",
page: .dictation,
title: "Auto-Capitalize Sentences",
subtitle: "Capitalize after punctuation",
keywords: ["capitalize", "output", "sentence", "punctuation"]
),
// Snippets
SettingsSearchEntry(
id: "snippets",
page: .snippets,
title: "Custom Snippets",
subtitle: "Replace spoken triggers with saved text",
keywords: ["snippet", "shortcut", "expansion", "trigger", "replace", "macro", "abbreviation"]
),
// Speech Model
SettingsSearchEntry(
id: "models",
page: .speechModel,
title: "Speech Models",
subtitle: "Download and select engines",
keywords: ["whisper", "parakeet", "sherpa", "apple", "model", "download"]
),
SettingsSearchEntry(
id: "language",
page: .speechModel,
title: "Transcription Language",
subtitle: "Auto-detect or pick a language",
keywords: ["language", "locale", "english", "hungarian"]
),
SettingsSearchEntry(
id: "translation",
page: .speechModel,
title: "Translation",
subtitle: "Translate speech to English",
keywords: ["translate", "english"]
),
SettingsSearchEntry(
id: "vocabulary",
page: .speechModel,
title: "Custom Vocabulary",
subtitle: "Hint proper nouns to Whisper",
keywords: ["vocab", "dictionary", "terms"]
),
// Audio
SettingsSearchEntry(
id: "microphone",
page: .audio,
title: "Microphone",
subtitle: "Input device",
keywords: ["mic", "device", "input", "audio"]
),
SettingsSearchEntry(
id: "silence",
page: .audio,
title: "Silence Detection",
subtitle: "Auto-stop after silence",
keywords: ["vad", "silence", "sensitivity", "threshold"]
),
SettingsSearchEntry(
id: "sound-effects",
page: .audio,
title: "Sound Effects",
subtitle: "Start and stop cues",
keywords: ["sound", "beep", "audio", "tone", "preview"]
),
// Performance
SettingsSearchEntry(
id: "model-status",
page: .performance,
title: "Model Status",
subtitle: "Loaded or unloaded",
keywords: ["loaded", "unload", "ram", "memory", "status", "pause"]
),
SettingsSearchEntry(
id: "auto-pause",
page: .performance,
title: "Auto-Pause for Apps",
subtitle: "Unload while listed apps run",
keywords: ["pause", "game", "app", "offload", "unload"]
),
SettingsSearchEntry(
id: "idle-unload",
page: .performance,
title: "Unload Model When Idle",
subtitle: "Keep-alive timeout",
keywords: ["idle", "keepalive", "keep-alive", "battery", "ram", "unload"]
),
SettingsSearchEntry(
id: "resources",
page: .advanced,
title: "Resource Usage",
subtitle: "App CPU and memory",
keywords: ["cpu", "memory", "ram", "resources", "system"]
),
SettingsSearchEntry(
id: "system-info",
page: .advanced,
title: "System Information",
subtitle: "CPU, RAM, Metal",
keywords: ["system", "metal", "device", "hardware"]
),
// Application
SettingsSearchEntry(
id: "launch-at-login",
page: .application,
title: "Launch at Login",
keywords: ["startup", "login"]
),
SettingsSearchEntry(
id: "clipboard",
page: .application,
title: "Preserve Clipboard",
keywords: ["clipboard", "paste"]
),
SettingsSearchEntry(
id: "cursor-overlay",
page: .application,
title: "Recording Overlay",
subtitle: "Style and position near the cursor",
keywords: ["overlay", "cursor", "indicator", "mic", "position", "style"]
),
// Gateway
SettingsSearchEntry(
id: "gateway",
page: .gateway,
title: "Gateway",
subtitle: "Optional self-hosted VocaGateway",
keywords: ["gateway", "vocagateway", "pair", "phone", "docker", "self-hosted", "qr"]
),
SettingsSearchEntry(
id: "gateway-pair",
page: .gateway,
title: "Pair phone",
subtitle: "QR code for VocaPhone",
keywords: ["pair", "phone", "qr", "pairing"]
),
SettingsSearchEntry(
id: "gateway-docker",
page: .gateway,
title: "Docker fallback",
subtitle: "Install Docker Desktop when native binary is missing",
keywords: ["docker", "desktop", "container", "compose"]
),
// Stats / Advanced / About
SettingsSearchEntry(
id: "stats",
page: .stats,
title: "Usage Stats",
keywords: ["streak", "words", "history"]
),
SettingsSearchEntry(
id: "logs",
page: .advanced,
title: "Debug Logs",
keywords: ["log", "debug", "export"]
),
SettingsSearchEntry(
id: "permissions",
page: .advanced,
title: "Permissions",
keywords: ["mic", "accessibility", "input monitoring"]
),
SettingsSearchEntry(
id: "about",
page: .about,
title: "About",
subtitle: "This app, the Voca family, and how to reach us",
keywords: ["about", "vocamac", "beta"]
),
SettingsSearchEntry(
id: "updates",
page: .about,
title: "Updates",
keywords: ["version", "release", "nightly", "update"]
),
SettingsSearchEntry(
id: "family",
page: .about,
title: "Part of VocaHQ",
subtitle: "VocaLinux, VocaMac, VocaWin, VocaPhone, VocaGateway",
keywords: ["family", "vocahq", "vocalinux", "vocamac", "vocawin", "windows", "vocaphone", "vocagateway"]
),
SettingsSearchEntry(
id: "github-issues",
page: .about,
title: "Report a bug or idea",
subtitle: "GitHub issues",
keywords: ["github", "issues", "bug", "feedback", "idea"]
),
SettingsSearchEntry(
id: "discord",
page: .about,
title: "Discord",
subtitle: "Talk to us",
keywords: ["discord", "chat", "community"]
),
SettingsSearchEntry(
id: "x",
page: .about,
title: "X",
subtitle: "Talk to us",
keywords: ["x", "twitter", "x.com"]
),
SettingsSearchEntry(
id: "email",
page: .about,
title: "Email",
subtitle: "hello@vocahq.com",
keywords: ["email", "mail", "hello"]
),
]
/// Entries whose title, subtitle, or keywords contain `query` (case-insensitive).
static func matches(query: String) -> [SettingsSearchEntry] {
let trimmed = query.trimmingCharacters(in: .whitespacesAndNewlines)
guard !trimmed.isEmpty else { return entries }
let needle = trimmed.lowercased()
return entries.filter { entry in
if entry.title.lowercased().contains(needle) { return true }
if let subtitle = entry.subtitle, subtitle.lowercased().contains(needle) { return true }
return entry.keywords.contains { $0.lowercased().contains(needle) }
}
}
/// Match counts keyed by page (pages with zero matches omitted).
static func matchCounts(query: String) -> [SettingsPage: Int] {
let trimmed = query.trimmingCharacters(in: .whitespacesAndNewlines)
guard !trimmed.isEmpty else { return [:] }
var counts: [SettingsPage: Int] = [:]
for entry in matches(query: trimmed) {
counts[entry.page, default: 0] += 1
}
return counts
}
/// First page that has matches, or nil when the query is empty / no hits.
static func firstMatchingPage(query: String) -> SettingsPage? {
let trimmed = query.trimmingCharacters(in: .whitespacesAndNewlines)
guard !trimmed.isEmpty else { return nil }
return matches(query: trimmed).first?.page
}
}