read text aloud

This commit is contained in:
2026-10-23 09:40:20 +02:00
parent 281f5465a6
commit 92b90c0e13
20 changed files with 471 additions and 18 deletions
@@ -95,6 +95,14 @@ extension WorkspaceModel {
overlay.present(.passOn(PassOnRequest(reference: name, anchor: anchor)))
case let .bouwen(name):
passToAgent("/bouwen \(name)", toast: "/bouwen \(name)")
case let .waitWhat(kind):
if let text = terminal.selection(kind)?.trimmingCharacters(in: .whitespacesAndNewlines), !text.isEmpty {
passToAgent("/wait-what `\(text)`", toast: "/wait-what")
}
case let .readAloudText(text):
readAloud.read(text)
case let .readAloudFile(path):
readAloudFile(path)
case let .newFile(directory):
overlay.present(.namePrompt(NamePromptRequest(purpose: .newFile(inDirectory: directory), anchor: anchor)))
case let .newFolder(directory):
@@ -129,6 +137,19 @@ extension WorkspaceModel {
}
}
/// The open file is read from its buffer, unsaved edits included; any other file from disk.
private func readAloudFile(_ path: String) {
let live = editor.flatMap { $0.activePath == path && $0.isLoaded(path) ? $0.text(for: path) : nil }
let files = services?.files
track {
var text = live
if text == nil, case let .text(disk)? = try? await files?.readText(path) { text = disk }
guard !Task.isCancelled else { return }
let prose = MarkdownSpeech.plainText(MarkdownParser.parse(text ?? ""))
if !self.readAloud.read(prose) { self.toasts.show("Nothing to read", detail: path) }
}
}
func submitName(_ name: String) {
guard case let .namePrompt(request) = overlay.current else { return }
overlay.dismiss()