Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/actions/build-and-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,13 @@ runs:
exit 1
fi
wait "$TEST"
- name: Developer modes
# The build above has no developer modes, like every release; this one
# adds them, so they cannot rot unbuilt. A changed define recompiles
# every module (about a minute).
shell: bash
run: |
set -o pipefail
swift build --build-tests -Xswiftc -DPLADDER_DEV_MODES 2>&1 | tee "$RUNNER_TEMP/build-dev-modes.log"
if grep -E "^$PWD/Sources/.*warning:" "$RUNNER_TEMP/build-dev-modes.log"; then exit 1; fi
swift test --skip-build --filter DeveloperModeTests
3 changes: 2 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Before and after any change that touches the code between `recordingStopped` and
```sh
swift build # debug build of everything
swift test # unit tests, well under a second
./scripts/bundle.sh [--run] [--install] # release build → dist/Pladder.app, signed
./scripts/bundle.sh [--run] [--install] [--dev-modes] # release build → dist/Pladder.app, signed
./scripts/release.sh <version> # Developer ID, notarised, stapled → dist/release/Pladder.dmg; publishes nothing
./scripts/changelog.sh <last tag> [<ref>] # the release notes release.yml publishes, from the commit subjects
./scripts/appcast.sh <app> <dmg> <notes.md> # sign the DMG for Sparkle and print the release's appcast.xml
Expand All @@ -52,6 +52,7 @@ swift run -c release pladder-cli polish-set docs/polish-set.json --model s1-mini
| Updates | Sparkle 2, from the app target only. "Check for Updates…" in the menu always; automatic checks (once a day) off by default, `checksForUpdatesAutomatically` in `settings.json`, handed to Sparkle at each launch and change. A scheduled find is one menu line, "Pladder <version> is available — Install…", and opens no window (gentle reminders); installing goes through the normal quit. The DMG is EdDSA-signed in `release.yml` with a `release` environment secret, checked before it is opened, and must carry the same Developer ID. No system profile, no automatic downloads, no first-run prompt | Without it a user had to notice a release, download it and replace the app by hand. The check is not the kind of request the privacy promise is about: it goes only to the GitHub repository the code and releases are in, so anyone can read what it does and where it goes, and it carries nothing about the user, the Mac or any dictation. Off by default, so a copy never told to check makes no request. A window that took focus mid-dictation would get the paste, hence the menu line. The setting lives in `settings.json` with every other one, so a test copy with its own file never checks because the live copy does. The private key is load-bearing: with it lost, every copy needs one manual update. Copies of 0.1.x have no updater and are replaced by hand once |
| Language | Swift 6.2 tools, strict concurrency, SwiftUI | Current toolchain |
| Build | SwiftPM package + `scripts/bundle.sh` wrapping the binary in `Pladder.app` | No Xcode project to maintain; `Package.swift` opens in Xcode |
| Developer modes | `--overlay-demo` and `--screenshots`, with their companion flags, exist only in a build with the Swift compilation condition `PLADDER_DEV_MODES`, which `scripts/make-screenshots.sh` (through `bundle.sh --dev-modes`) and `scripts/overlay-demo.sh` set, in `.build/dev-modes`. `swift build`, `swift run`, Xcode, a plain `bundle.sh` and `--release` have neither; `--dev-modes` refuses `--release` and `--install`. CI builds and tests without the define, then once more with it | A shipped app carries no demo mode. Opt-in rather than opt-out, so a lost flag shows in the two scripts, which then start the plain app, instead of in a shipped app. Not `#if DEBUG`: `make-screenshots.sh` shoots the release-configuration bundle, with its Info.plist, its German strings and no Echo engine. A scratch path of its own, because a changed define recompiles every module. CI builds both: a pull request must not break the configuration that ships, and the modes' code would otherwise rot unbuilt |
| App icon | `Assets/AppIcon.icon`, an Icon Composer document whose layers `scripts/make-icon.swift` draws, compiled by `actool` in `bundle.sh`. The mark is four bars and a text caret; the menu bar glyph, the favicon and the social preview draw the same geometry | macOS 26 takes the light, dark, tinted and clear appearances only from an asset catalog, and `actool` builds one from the document without an Xcode project. A waveform alone is every audio app's icon; the caret says what Pladder does, voice in and text out at the cursor, and still reads at 16 px |
| Website | `site/`: hand-written HTML and one stylesheet in the Mac's own SF and one accent, coral, published by `pages.yml` on a push under `site/**`, at `dinooo13.github.io/pladder` for now. No framework, no build step, no JavaScript, nothing from another server | The README already is the pitch; a static page says it in text a crawler reads without running anything and keeps the app's privacy promise. Every measurement on it is a link to its `docs/BENCHMARKS.md` heading, and `scripts/check-site-numbers.sh` (in `docs.yml`) fails when one no longer stands there. The site names no version or checksum: the button and the SHA-256 link point at `releases/latest`, so a release never makes it stale and never breaks a required check. The hero is T3 Code's chat drawn in HTML and CSS from its MIT source, with Pladder's Live pill over it: text, so it stays sharp at any size and follows the visitor's light or dark mode, and a coding agent's window says who Pladder is for |
| Engine | FluidAudio, Parakeet Ultra (Moondream's post-training of Parakeet TDT 0.6B v3) by default; v3 in the picker | Fastest Swift-native option, runs on the Neural Engine. The recording is transcribed in windows while the key is held, so only the last window and the merge are left at release. Ultra has v3's architecture and windows, makes about a fifth fewer word errors on FLEURS English, German and Spanish, and is as fast (docs/BENCHMARKS.md). A settings file that names v3 keeps it |
Expand Down
8 changes: 7 additions & 1 deletion Sources/Pladder/OverlayDemo.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if PLADDER_DEV_MODES
import AppKit
import Foundation
import PladderCore
Expand All @@ -7,7 +8,11 @@ import PladderCore
// a copy in use. `scripts/overlay-demo.sh` lines its timed output up with a recording.
@MainActor
enum OverlayDemo {
static var isRequested: Bool { CommandLine.arguments.contains("--overlay-demo") }
static var isRequested: Bool { isRequested(in: CommandLine.arguments) }

nonisolated static func isRequested(in arguments: [String]) -> Bool {
arguments.contains("--overlay-demo")
}

private struct Scenario {
let name: String
Expand Down Expand Up @@ -169,3 +174,4 @@ private final class DemoHotkey: HotkeyMonitor, @unchecked Sendable {
func stop() {}
func setCancelKeyEnabled(_ enabled: Bool) {}
}
#endif
36 changes: 20 additions & 16 deletions Sources/Pladder/PladderApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,33 @@ struct PladderApp: App {
@State private var model: AppModel
// The overlay demo and the screenshots are not the app: a throwaway settings file,
// and no menu bar item, which would be a second, slashed Pladder in the bar.
private let isDeveloperMode: Bool
private let showsMenuBarItem: Bool

init() {
let isDeveloperMode = OverlayDemo.isRequested || Screenshots.directory != nil
self.isDeveloperMode = isDeveloperMode
let model = isDeveloperMode
? AppModel(location: .scratch, readPolicy: Screenshots.readPolicy)
: AppModel(location: .live)
#if PLADDER_DEV_MODES
if OverlayDemo.isRequested || Screenshots.directory != nil {
let model = AppModel(location: .scratch, readPolicy: Screenshots.readPolicy)
_model = State(initialValue: model)
showsMenuBarItem = Screenshots.capturesMenu
if OverlayDemo.isRequested {
Task { @MainActor in await OverlayDemo.run() }
} else if let directory = Screenshots.directory {
Screenshots.appModel = model
Task { @MainActor in await Screenshots.run(into: directory) }
}
return
}
#endif
let model = AppModel(location: .live)
_model = State(initialValue: model)
showsMenuBarItem = true
AppDelegate.shutdown = { await model.shutdown() }
// Deferred, so the app has finished launching before the Accessibility prompt.
if OverlayDemo.isRequested {
Task { @MainActor in await OverlayDemo.run() }
} else if let directory = Screenshots.directory {
Screenshots.appModel = model
Task { @MainActor in await Screenshots.run(into: directory) }
} else {
AppDelegate.shutdown = { await model.shutdown() }
Task { @MainActor in model.start() }
}
Task { @MainActor in model.start() }
}

var body: some Scene {
MenuBarExtra(isInserted: .constant(!isDeveloperMode || Screenshots.capturesMenu)) {
MenuBarExtra(isInserted: .constant(showsMenuBarItem)) {
MenuContent(model: model)
} label: {
MenuBarLabel(model: model)
Expand Down
11 changes: 7 additions & 4 deletions Sources/Pladder/Screenshots.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if PLADDER_DEV_MODES
import AppKit
import SwiftUI
import PladderCore
Expand All @@ -6,10 +7,11 @@ import PladderCore
// or the engine, so it can run beside a copy in use; `scripts/make-screenshots.sh` wraps it.
@MainActor
enum Screenshots {
static var directory: URL? {
let args = CommandLine.arguments
guard let index = args.firstIndex(of: "--screenshots"), index + 1 < args.count else { return nil }
return URL(filePath: args[index + 1])
static var directory: URL? { directory(in: CommandLine.arguments) }

nonisolated static func directory(in arguments: [String]) -> URL? {
guard let index = arguments.firstIndex(of: "--screenshots"), index + 1 < arguments.count else { return nil }
return URL(filePath: arguments[index + 1])
}

static var capturesMenu: Bool { CommandLine.arguments.contains("--menu") }
Expand Down Expand Up @@ -407,3 +409,4 @@ private struct SettingsOpener: View {
}
}
}
#endif
25 changes: 25 additions & 0 deletions Tests/PladderTests/DeveloperModeTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#if PLADDER_DEV_MODES
import Foundation
import Testing
@testable import Pladder

struct DeveloperModeTests {
@Test func screenshotsTakeTheDirectoryAfterTheFlag() {
let arguments = ["Pladder", "--screenshots", "/tmp/shots", "--settings-scene"]
#expect(Screenshots.directory(in: arguments) == URL(filePath: "/tmp/shots"))
}

@Test func screenshotsFlagLastWithNoDirectoryIsNoRequest() {
#expect(Screenshots.directory(in: ["Pladder", "--managed", "--screenshots"]) == nil)
}

@Test func screenshotsWithoutTheFlagAreNoRequest() {
#expect(Screenshots.directory(in: ["Pladder", "--settings-scene", "/tmp/shots"]) == nil)
}

@Test func overlayDemoIsRequestedOnlyByItsFlag() {
#expect(OverlayDemo.isRequested(in: ["Pladder", "--style", "minimal", "--overlay-demo"]))
#expect(!OverlayDemo.isRequested(in: ["Pladder", "--screenshots", "/tmp/shots"]))
}
}
#endif
23 changes: 19 additions & 4 deletions scripts/bundle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
# signature, which macOS needs to remember the Accessibility and Microphone
# grants across launches.
#
# Usage: scripts/bundle.sh [--run] [--install] [--release]
# Usage: scripts/bundle.sh [--run] [--install] [--release] [--dev-modes]
# --run launch dist/Pladder.app when done
# --install copy the app to /Applications (replacing an old copy)
# --release Developer ID only, with a secure timestamp (notarisation
# needs both); scripts/release.sh passes it
# --dev-modes with --overlay-demo and --screenshots, in .build/dev-modes;
# scripts/make-screenshots.sh passes it
# SCRATCH=<dir> optional swift build --scratch-path
# CODESIGN_IDENTITY signing identity; auto-detected, "-" forces ad-hoc
# MARKETING_VERSION CFBundleShortVersionString of the bundled Info.plist
Expand All @@ -20,22 +22,35 @@ set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT"

SCRATCH="${SCRATCH:-.build}"
RUN=0
INSTALL=0
RELEASE=0
DEV_MODES=0
for arg in "$@"; do
case "$arg" in
--run) RUN=1 ;;
--install) INSTALL=1 ;;
--release) RELEASE=1 ;;
--dev-modes) DEV_MODES=1 ;;
*)
echo "unknown argument: $arg" >&2
exit 2
;;
esac
done

DEFINES=()
if [[ "$DEV_MODES" -eq 1 ]]; then
if [[ "$RELEASE" -eq 1 || "$INSTALL" -eq 1 ]]; then
echo "--dev-modes never goes into a release or /Applications" >&2
exit 2
fi
DEFINES=(-Xswiftc -DPLADDER_DEV_MODES)
# A changed define recompiles every module, so the two builds keep apart.
SCRATCH="${SCRATCH:-.build/dev-modes}"
fi
SCRATCH="${SCRATCH:-.build}"

APP="$ROOT/dist/Pladder.app"
CONTENTS="$APP/Contents"

Expand Down Expand Up @@ -85,8 +100,8 @@ if [[ "$RELEASE" -eq 1 ]]; then
TIMESTAMP=--timestamp
fi

swift build -c release --product Pladder --scratch-path "$SCRATCH"
BIN_DIR="$(swift build -c release --product Pladder --scratch-path "$SCRATCH" --show-bin-path)"
swift build -c release --product Pladder --scratch-path "$SCRATCH" ${DEFINES[@]+"${DEFINES[@]}"}
BIN_DIR="$(swift build -c release --product Pladder --scratch-path "$SCRATCH" ${DEFINES[@]+"${DEFINES[@]}"} --show-bin-path)"

rm -rf "$APP"
mkdir -p "$CONTENTS/MacOS" "$CONTENTS/Resources"
Expand Down
2 changes: 1 addition & 1 deletion scripts/make-screenshots.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ cd "$ROOT"
OUT="$ROOT/docs/images"
if [[ $# -gt 0 && "$1" != --* ]]; then OUT="$1"; shift; fi

"$ROOT/scripts/bundle.sh"
"$ROOT/scripts/bundle.sh" --dev-modes
# The binary directly, not `open`: screencapture then runs with this
# terminal's Screen Recording grant.
"$ROOT/dist/Pladder.app/Contents/MacOS/Pladder" --screenshots "$OUT" "$@"
4 changes: 2 additions & 2 deletions scripts/overlay-demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ if [[ $# -gt 0 && "$1" != --* ]]; then OUT="$1"; shift; fi
mkdir -p "$OUT"
rm -f "$OUT"/demo.mov "$OUT"/sheet-*.png

swift build --product Pladder
swift build --product Pladder -Xswiftc -DPLADDER_DEV_MODES --scratch-path .build/dev-modes
now() { perl -MTime::HiRes=time -e 'printf "%.3f", time'; }

screencapture -x -v "$OUT/demo.mov" &
RECORDER=$!
# A demo that fails would otherwise leave screencapture recording in the
# background, since `set -e` ends the script before the stop below.
trap 'kill -INT "$RECORDER" 2>/dev/null || true' EXIT
.build/debug/Pladder --overlay-demo "$@" > "$OUT/demo.log"
.build/dev-modes/debug/Pladder --overlay-demo "$@" > "$OUT/demo.log"
# Stopped by hand rather than with -V: the stop time less the movie's length
# is when the first frame was taken, which lines the frames up with the log.
STOPPED=$(now)
Expand Down
Loading