Let the operator edit the station config in the window instead of hand-editing the file and relaunching.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-11 19:19:05 +02:00
co-authored by Cursor
parent e642b24be0
commit 775d1b5c82
12 changed files with 1567 additions and 179 deletions
+31 -2
View File
@@ -5,17 +5,22 @@ import (
"fmt"
"io"
wailsruntime "github.com/wailsapp/wails/v2/pkg/runtime"
"gitea.neitzel.de/konrad/funknetz/audio"
"gitea.neitzel.de/konrad/funknetz/station"
)
// App is the window's view of the station.
type App struct {
ctx context.Context
cancel context.CancelFunc
station *station.Station
quit func(context.Context)
}
func (a *App) startup(ctx context.Context) {
a.ctx = ctx
runCtx, cancel := context.WithCancel(ctx)
a.cancel = cancel
if err := audio.Start(runCtx, a.station.WriteMicrophone, a.station.TakePlayback); err != nil {
@@ -46,6 +51,29 @@ func (a *App) HoldSpace() { a.station.HoldSpace() }
// ReleaseSpace reports that Space was released.
func (a *App) ReleaseSpace() { a.station.ReleaseSpace() }
// Config returns the Config window form.
func (a *App) Config() station.ConfigState { return a.station.Config() }
// OpenConfig opens the Config window, re-reading the file.
func (a *App) OpenConfig() { a.station.OpenConfig() }
// Save validates and writes the config form.
func (a *App) Save(form station.ConfigForm) error { return a.station.Save(form) }
// CancelConfig discards the form. When no config has loaded, it quits.
func (a *App) CancelConfig() {
if !a.station.Cancel() {
return
}
quit := a.quit
if quit == nil {
quit = wailsruntime.Quit
}
if a.ctx != nil {
quit(a.ctx)
}
}
func openStation(args []string) (*station.Station, error) {
path, err := resolveConfigPath(args)
if err != nil {
@@ -54,8 +82,9 @@ func openStation(args []string) (*station.Station, error) {
return station.New(station.Options{ConfigPath: path})
}
// openStationReported opens the station from args. A flag or config failure is
// one line on stderr and the returned error. The window is not opened.
// openStationReported opens the station from args. A flag or path failure is
// one line on stderr and the returned error. A missing or invalid config still
// returns a station so the window can open.
func openStationReported(args []string, stderr io.Writer) (*station.Station, error) {
st, err := openStation(args)
if err != nil {