Wire KeepRunningInTray to runtime so tray, close, and autostart follow the saved setting.

Autostart entries pass --start-in-tray only when the tray is enabled; Settings warns that the notification icon needs a restart (Fyne limitation).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-05 22:44:02 +03:00
parent 5170cc5f99
commit 5b0e6fe51b
22 changed files with 356 additions and 97 deletions
+17
View File
@@ -5,6 +5,23 @@ package domain
// launches omit this flag and open the normal window.
const StartInTrayArgument = "--start-in-tray"
// AutostartArguments returns the command-line suffix written to a platform
// autostart entry when KeepRunningInTray is enabled. An empty string means the
// app should open its window normally after sign-in.
func AutostartArguments(keepInTray bool) string {
if keepInTray {
return StartInTrayArgument
}
return ""
}
// ResolveStartHidden reports whether an autostart launch should skip showing
// the main window. The CLI flag is ignored when KeepRunningInTray is off so a
// stale shortcut cannot hide the app with no tray icon to restore it.
func ResolveStartHidden(cliStartInTray, keepInTray bool) bool {
return cliStartInTray && keepInTray
}
// ExecutionMode controls whether due jobs run concurrently or one at a time.
type ExecutionMode string
+18 -20
View File
@@ -2,29 +2,27 @@ package domain
import "testing"
// TestJobListViewIsCompact pins the normalization rule: only the exact
// "compact" value selects the one-line rows, so empty and unrecognised values
// (including configs written before the field existed) keep the detailed look.
func TestJobListViewIsCompact(t *testing.T) {
cases := []struct {
view JobListView
want bool
}{
{JobListViewCompact, true},
{JobListViewDetailed, false},
{"", false},
{"Compact", false},
{"tiny", false},
func TestAutostartArguments(t *testing.T) {
if got := AutostartArguments(true); got != StartInTrayArgument {
t.Errorf("AutostartArguments(true) = %q, want %q", got, StartInTrayArgument)
}
for _, tc := range cases {
if got := tc.view.IsCompact(); got != tc.want {
t.Errorf("JobListView(%q).IsCompact() = %v, want %v", tc.view, got, tc.want)
}
if got := AutostartArguments(false); got != "" {
t.Errorf("AutostartArguments(false) = %q, want empty", got)
}
}
func TestDefaultConfigUsesDetailedJobList(t *testing.T) {
if got := DefaultConfig().JobListView; got != JobListViewDetailed {
t.Errorf("default JobListView = %q, want %q", got, JobListViewDetailed)
func TestResolveStartHidden(t *testing.T) {
cases := []struct {
cli, keep, want bool
}{
{true, true, true},
{true, false, false},
{false, true, false},
{false, false, false},
}
for _, tc := range cases {
if got := ResolveStartHidden(tc.cli, tc.keep); got != tc.want {
t.Errorf("ResolveStartHidden(%v, %v) = %v, want %v", tc.cli, tc.keep, got, tc.want)
}
}
}