desktop

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 33 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package desktop is the desktop shell's logic, kept apart from the desktop runtime: what the app does with the services' events, how the menu bar icon is kept current, the background work that runs while the app is open, and the order the app shuts down in.

It imports no desktop runtime. The desktop bootstrap (cmd/nilbox, built with the desktop tag) implements the small interfaces declared here over the runtime: the page that hears window events, the window, the menu bar icon, and the app itself. So everything here builds and is tested on any OS.

Index

Constants

View Source
const (
	// DittoBin is macOS's ditto, which copies an app bundle with its signature, its
	// extended attributes, and its links intact.
	DittoBin = "/usr/bin/ditto"

	// CodesignBin is macOS's codesign, which checks a bundle's code signature.
	CodesignBin = "/usr/bin/codesign"
)
View Source
const (
	// DefaultStopTimeout bounds how long Stop waits for the background work in flight,
	// such as a refresh, before it closes the data anyway.
	DefaultStopTimeout = 5 * time.Second

	// DefaultMeasureTimeout bounds a startup measurement whose window never reports its
	// first paint.
	DefaultMeasureTimeout = time.Minute

	// DeferredFallback is how long after launch the deferred work starts when the window
	// never reports its first paint.
	DeferredFallback = 10 * time.Second
)
View Source
const (
	FinishQuitEvery  = 5 * time.Second
	FinishQuitTries  = 4
	FinishWithin     = 25 * time.Second
	FinishStopWithin = 3 * time.Second
)

After a restart to update whose quit was held (event.UpdateQuitHeld), the shell asks to quit again every FinishQuitEvery, FinishQuitTries times, and, the app still running FinishWithin after the restart began starting the update's helper (UpdateQuitHeld.HelperStarted), shuts down in order, waiting for that at most FinishStopWithin, and exits. The helper, which can't be called back, waits 30 seconds from just after that moment for the app to exit, before it gives up, installs nothing, and opens this copy again; timing the exit from the event's arrival instead would lose however long the held quit took to come back.

View Source
const DigestAlgo = "sha512"

DigestAlgo names the digest the desktop runtime's updater checks an update's zip against as it copies it: the manifest's SHA-512.

View Source
const OpenBin = "/usr/bin/open"

OpenBin is macOS's open, which opens an app bundle as Finder does.

View Source
const SetupParam = "setup"

SetupParam is the query parameter of the page's URL that says the first-run setup shows, as SetupValue. The page reads it before it first renders (frontend/src/lib/setup.ts), so its first frame is the setup's, never a flash of the inbox, and drops it once the setup ends; the setup's own state, which the page reads next, is what counts.

View Source
const SetupValue = "1"

SetupValue is SetupParam's value while the setup shows.

View Source
const TextSizeParam = "textSize"

TextSizeParam is the query parameter of the page's URL that carries the text size. The page reads it before it first renders (frontend/src/lib/textSize.ts), so its first frame already shows text at the stored size, and writes it back on every change, so a reload keeps the size the user chose since.

Variables

View Source
var ErrNoFirstPaint = errors.New("the window did not report its first paint in time")

ErrNoFirstPaint is reported when a startup measurement timed out.

View Source
var ErrNotInstallable = errors.New("the update can't be handed to the installer")

ErrNotInstallable is returned by NewArtifact for an update the runtime must not be handed: no zip, no release's version, no size, or no SHA-512.

Functions

func BannerClicked

func BannerClicked(data map[string]any) event.RevealItem

BannerClicked reads the data a clicked banner carried, as BannerData wrote it, into the request to reveal its item, or the run it is about, and to mark its notification read. A banner that stands for many items names none. The data comes back through JSON, so an id is a float64; an id that is not a number, or a URL or a run's start that is not a string, reads as none.

func BannerData

func BannerData(b notify.Banner) map[string]any

BannerData is the data a banner carries for b, which the system hands back when the banner is clicked: the item it is for and the item's URL, or the page or the run of an entry about no item, with when the run started, and the notification it stands for.

func CopyArgs added in v0.3.1

func CopyArgs(from, to string) []string

CopyArgs is the command that copies the app bundle at from into to: `ditto --noqtn`, so ditto marks nothing in the copy as quarantined itself. Each path is an argument of its own, and ditto copies into to, which the move made empty for it. ditto still copies the quarantine mark a download carries, as it copies every extended attribute, so the Mover takes it off the copy afterwards (unquarantine).

func MarshalError

func MarshalError(err error) []byte

MarshalError encodes the cause the desktop runtime sends with an error a bound method returned: {"message": "..."}, holding what the user is told about it (see uierr.Message), and "detail" when an error in its chain is a Detailer. The runtime still sends the error's full text as the failure's own message, for the developer console; the window shows this one. It returns nil, which keeps the runtime's own encoding, only if the cause cannot be encoded.

func OpenArgs added in v0.3.1

func OpenArgs(bundle, dataDir string) (argv []string, ok bool)

OpenArgs works out the command that opens the app bundle at bundle once this app has quit: `open -n <bundle>`, with --args --data-dir=<dataDir> for a sandbox's data directory ("" for the user's own). open needs -n because the app that asks is still running as it does, and, with the same bundle identifier, would be brought forward instead. A path that isn't the absolute, clean path of a .app bundle opens nothing: ok is false.

func PageURL

func PageURL(textSize settings.TextSize, setup bool) string

PageURL is the URL the window opens its page at: the app's root, carrying the text size the page shows from its first frame, and whether it opens on the first-run setup. With no setup it is the same URL it always was.

func PutBack added in v0.3.1

func PutBack(ctx context.Context, db string, r Restore) (string, error)

PutBack puts the backup r offers in place of the database at db, which a newer build saved: the newer database, with its -wal and -shm files, is set aside beside it, kept until the user removes it, and the backup is copied into its place (store.RestoreBackup). The next start opens it and brings it up to date. It returns where the newer database was set aside. A failure is worded for the dialog that says so (PutBackFailure words what to do): almost always the newer database is still in place, but when the copy couldn't be renamed into place and the newer database couldn't be put back either, no database is left there, and the newer one is the file set aside.

func RelaunchArgs added in v0.3.0

func RelaunchArgs(exe, dataDir string) (argv []string, ok bool)

RelaunchArgs works out the command that opens the app again once it has quit, as a reset the user asked for does, so its next start carries the reset out: OpenArgs of the bundle the running executable exe is in. An executable that isn't inside a .app bundle, as `magex app:dev` runs it, has nothing to open: ok is false, and the app only quits.

func RequirementArgs added in v0.3.1

func RequirementArgs(of string) []string

RequirementArgs is the command that writes the designated requirement of of to its output: `codesign --display --requirements -`, of a running process by its ID (the app that runs, whatever has become of the path it ran from) or a bundle by its path, an argument of its own. For a release, signed with the release identity, it is `identifier "<bundle ID>" and certificate leaf = H"<SHA-1>"`, the same for every build; for a build signed ad hoc, the cdhash of that build alone.

func VerifyArgs added in v0.3.1

func VerifyArgs(bundle, requirement string) []string

VerifyArgs is the command that checks the code signature of the bundle at bundle, every nested piece of code included, as strictly as codesign can, and that it meets requirement, the designated requirement of the app that runs (RequirementArgs): `codesign --verify --deep --strict`, the check the update's helper makes of a new version too, with `--test-requirement =<requirement>`, the requirement given as text, an argument of its own.

func WithinArea

func WithinArea(window, area Rect) (x, y int)

WithinArea returns where a window with the given bounds moves to so it sits inside area: left and up, where needed, until its right and bottom edges are inside area, but never past area's left and top edges, so a window larger than area keeps its top-left corner on it. A window already inside area stays where it is.

Types

type App

type App interface {
	// Quit quits the app.
	Quit()
}

App is the running app.

type Artifact added in v0.3.1

type Artifact struct {
	// Path is the zip, and Filename its name, which ends in .zip: the runtime extracts only
	// an archive it can tell by its name, and would put the zip itself in the app's place.
	Path     string
	Filename string

	// Version is the release it holds.
	Version string

	// Size is its size in bytes, and Digest its SHA-512, raw.
	Size   int64
	Digest []byte
}

Artifact is an update the desktop runtime's updater installs: a zip in the app's update cache, already checked against its signed manifest, which the runtime checks again, against Size and Digest, as it copies it beside the running bundle.

func NewArtifact added in v0.3.1

func NewArtifact(zip, version string, size int64, sha512Hex string) (Artifact, error)

NewArtifact checks what the update asks the runtime to install, and returns it: the zip at zip, whose name ends in .zip, of version, a release's, of size bytes, with sha512Hex its SHA-512 in hex, exactly 64 bytes. Without a digest the runtime would install bytes it never checked, so anything short of all of that is ErrNotInstallable.

type Authorizer

type Authorizer interface {
	Authorize() (bool, error)
}

Authorizer asks the user, the first time, to allow notification banners. Every notify.Poster implements it.

type Config

type Config struct {
	Frontend Frontend
	Window   Window
	Tray     Tray
	App      App

	Inbox    Inbox
	Settings Settings

	// Sessions are the agent sessions the menu bar lists first. Optional: without it, the
	// menu lists the inbox alone.
	Sessions Sessions

	// Updates is the app's update, which the menu bar offers above Refresh Now in a build
	// that updates. Optional: without it, the menu offers no update.
	Updates Updates

	// Browser opens a web page in the user's browser, as the menu bar's Download X Manually…
	// does. Optional: without it, the page isn't opened, which is logged.
	Browser URLOpener

	// Exit ends the process with a status, once a restart to update whose quit was held has
	// shut the shell down in order. It defaults to os.Exit.
	Exit func(code int)

	// Workers run in the background from Start until Stop, started in this order.
	Workers []Worker

	// Deferred is work kept off the cold start: it starts once, when the window reports
	// its first paint, or DeferredFallback after launch when it never does, and never in
	// a startup measurement. Each Run returns when its work is done or its context ends,
	// and Stop waits for it as for the workers.
	Deferred []Worker

	// Data is what Stop closes last, once the background work is done: the database.
	Data io.Closer

	// Banners is asked at launch to allow notifications, or, while the first-run setup
	// shows, once it ends. Nil means this build cannot show them, and nothing is asked.
	Banners Authorizer

	// QuitGuard holds a quit while it reports work going, until the user confirms. Nil
	// means nothing holds a quit.
	QuitGuard QuitGuard

	// Clock times the menu bar's snooze ends. It defaults to the system clock.
	Clock clock.Clock

	// Stdout gets a startup measurement's timing line. It defaults to discarding.
	Stdout io.Writer

	// Logger receives what the shell cannot report as an error: a setting it could not
	// read and fell back from, a failed refresh or menu bar redraw, and a startup
	// measurement that never painted. Without it they are not logged.
	Logger *slog.Logger

	// MeasureStartup makes this run a startup measurement: the first paint is printed to
	// Stdout and quits the app, a run that never paints quits failing after
	// MeasureTimeout, and nothing asks to allow banners.
	MeasureStartup bool

	// StopTimeout and MeasureTimeout default to DefaultStopTimeout and
	// DefaultMeasureTimeout.
	StopTimeout    time.Duration
	MeasureTimeout time.Duration
}

Config holds a Shell's dependencies. Frontend, Window, Tray, App, Inbox, and Settings are required; the rest are optional.

type Detailer

type Detailer interface {
	error
	Detail() any
}

Detailer is an error that carries what the window needs to answer it, which the desktop runtime sends beside its message.

type Failure

type Failure struct {
	// Title is the dialog's title.
	Title string

	// Message is its text: what went wrong, and what to do about it where that is known.
	Message string

	// Restore is the backup the dialog offers to put back beside Quit (see Offering), or
	// nil for none.
	Restore *Restore
}

Failure is what the error dialog says when the app cannot start.

func PutBackFailure added in v0.3.1

func PutBackFailure(db string, err error) Failure

PutBackFailure words err, a failure to put a backup back in place of the database at db, for the dialog that says so before the app quits, with what to do: quit the other copy that holds the data open; when no database is left at db, rename the newer one, set aside beside it, back into place; otherwise update the app to open the newer data.

func StartupFailure

func StartupFailure(err error) Failure

StartupFailure words err, which stopped the app from starting, for the error dialog shown before the app quits: nobody sees the standard error of an app opened from the Finder. A database saved by a newer build asks for an update. A database another process holds locked, and data the app may not read or write, say what to do. Each gives what the user is told about the error itself (see uierr.Message).

func (Failure) Offering added in v0.3.1

func (f Failure) Offering(r Restore) Failure

Offering returns f with r offered beside it: its detail under the message, and its button.

type Frontend

type Frontend interface {
	Emit(e event.WindowEvent)
}

Frontend is the window's page. Emit passes a window event on to it, and must not wait for the page.

type Inbox

type Inbox interface {
	Snapshot(ctx context.Context) (inbox.Snapshot, error)
	Refresh(ctx context.Context) (inbox.Snapshot, error)
}

Inbox is the stored inbox the menu bar shows, and the refresh its menu asks for. *inbox.Service implements it.

type Mover added in v0.3.1

type Mover struct {
	// contains filtered or unexported fields
}

Mover moves the app into Applications for the update's Move to Applications (update.Mover): it copies with ditto and checks the copy with codesign, through its runner, reads a copy's quarantine mark, and has the shell hold the app's quit while a move runs and open the copy once the app has quit the normal way.

func NewMover added in v0.3.1

func NewMover(runner execpath.Runner, shell *Shell) *Mover

NewMover returns the Mover that runs ditto and codesign through runner, and holds, quits, and reopens through shell.

func (*Mover) Copy added in v0.3.1

func (m *Mover) Copy(ctx context.Context, from, to string) error

Copy copies the bundle at from into to with ditto (CopyArgs), then takes the quarantine mark a download carries off every file of the copy (unquarantine), so it opens from Applications as the copy the user already opened: never translocated, and with no question from macOS again. Its error says why in ditto's words, or the mark's.

func (*Mover) HoldQuit added in v0.3.1

func (m *Mover) HoldQuit() func()

HoldQuit holds every quit of the app while a move runs (Shell.HoldQuit).

func (*Mover) OpenAfterQuit added in v0.3.1

func (m *Mover) OpenAfterQuit(bundle string)

OpenAfterQuit quits the app the normal way and opens bundle once it has quit (Shell.OpenAfterQuit).

func (*Mover) Translocates added in v0.3.1

func (m *Mover) Translocates(bundle string) (bool, error)

Translocates reports whether macOS would open the bundle at bundle from a hidden, read-only copy: its own folder carries the quarantine mark a download has, without the flag Finder adds as the user moves the app (translocates). It reads the mark and changes nothing.

func (*Mover) Verify added in v0.3.1

func (m *Mover) Verify(ctx context.Context, bundle string) error

Verify checks the code signature of the bundle at bundle, and that it meets the designated requirement of the app that runs, read from this process (RequirementArgs, then VerifyArgs): a copy signed otherwise, such as a build from source beside a release, fails, worded as such. When that requirement can't be read, the error holds update.ErrOwnSignature, since the copy was never judged. Its error says why in codesign's words otherwise.

type QuitGuard

type QuitGuard interface {
	Active() bool
}

QuitGuard says whether quitting now would stop work the user is asked about first: runs going in the app. *scriptrun.Engine implements it.

type Rect

type Rect struct {
	X, Y, Width, Height int
}

Rect is a rectangle on screen, in points, from its top-left corner.

type Restore added in v0.3.1

type Restore struct {
	// Backup is the backup's file, beside the database.
	Backup string

	// At is when it was taken.
	At time.Time

	// Button is the dialog's button that puts it back: "Use my data from Nov 14, 3:02 PM".
	Button string

	// Detail is what the dialog adds under the failure's message: what putting it back keeps
	// and loses.
	Detail string
}

Restore is a backup of the data the startup dialog offers to put back, when a newer build saved the data this one can't open: the newest backup beside the database whose schema this build has.

func FindRestore added in v0.3.1

func FindRestore(err error, db string, now time.Time) (Restore, bool, error)

FindRestore is RestoreOffer over the backups beside the database at db as they are now, and the migrations this build has. A db of "" (the data couldn't be found) offers none; a folder that can't be listed offers none, with the error.

func RestoreOffer added in v0.3.1

func RestoreOffer(err error, backups []store.SnapshotFile, newest int, now time.Time) (Restore, bool)

RestoreOffer works out the backup the startup dialog offers to put back for err, from backups, the files kept beside the database (store.Snapshots), and newest, the newest migration this build has (store.LatestSchema): the newest backup whose schema is known and no newer, which this build opens and brings up to date. ok is false unless err is a database a newer build saved (store.ErrNewerSchema) and there is such a backup. Times are worded in now's location, with the year only when it isn't now's.

type Sessions

type Sessions interface {
	// Waiting returns the running sessions waiting for the user, the longest waiting
	// first.
	Waiting(ctx context.Context) ([]sessions.Session, error)

	// Focus brings forward the terminal tab a running session is in.
	Focus(ctx context.Context, id string) error
}

Sessions are the agent sessions the menu bar lists, and the terminal a click on one brings forward. *sessions.Ledger and *sessions.Service do, which the core joins.

type Settings

type Settings interface {
	Theme(ctx context.Context) (settings.Theme, error)
	MenuBar(ctx context.Context) (bool, error)
	WindowSize(ctx context.Context) (settings.WindowSize, error)
	TextSize(ctx context.Context) (settings.TextSize, error)

	// SetupPending reports whether the first-run setup shows when the window opens.
	SetupPending(ctx context.Context) (bool, error)
}

Settings are the settings the shell reads when the app launches. core.ShellSettings implements it.

type Shell

type Shell struct {
	// contains filtered or unexported fields
}

Shell connects the services to the desktop runtime. It is the services' event.Sink: window events go on to the page, an inbox change redraws the menu bar, a theme or menu bar change reaches the window and the icon, and the first paint ends a startup measurement. It runs the background work, tracked so Stop can wait for it, and keeps the menu bar icon current with one redraw at a time.

The desktop runtime calls Start once the app starts, Launched once it has launched, and Stop when it shuts down.

func New

func New(cfg Config) *Shell

New returns a Shell over cfg that has not started.

func (*Shell) Emit

func (s *Shell) Emit(e event.Event)

Emit acts on e, until the shell stops: a window event goes on to the page, an inbox change also redraws the menu bar, and a sessions or update change does when the sessions waiting for the user or the update's rows read otherwise than the menu shows them, a request to reveal an item brings the window forward, a theme or menu bar change reaches the window or the icon, the first paint ends a startup measurement or starts the deferred work, the user's choice to stop the runs and quit quits, the end of the first-run setup asks to allow banners if the setup held the question, and a reset the user asked for quits so the app opens again. It never waits for a redraw or the quit.

func (*Shell) FocusSession

func (s *Shell) FocusSession(id string, itemID int64, url string)

FocusSession brings forward the terminal tab of a session waiting for the user, as its row in the menu bar asks, in the background; Stop waits for it. When the tab cannot be shown, the session's item is shown in the window instead.

func (*Shell) HidesOnClose

func (s *Shell) HidesOnClose() bool

HidesOnClose reports whether closing the window only hides it, keeping the app running in the menu bar: while the icon shows and the app is not quitting.

func (*Shell) HoldQuit added in v0.3.1

func (s *Shell) HoldQuit() func()

HoldQuit holds every quit while a move to Applications runs, so its copy is never cut off partway: a quit asked for meanwhile (ShouldQuit, or OpenAfterQuit) waits, and goes ahead, once, when the last move under way lets go, which the func it returns does, once. A move ends within update.MoveLimit, so a quit waits that long at most. Only a restart to update, whose helper owns the reopening, and a shell already stopping, go through regardless.

func (*Shell) Launched

func (s *Shell) Launched()

Launched opens the window in the stored theme, at the stored size and text size, on the first-run setup when it shows, shows the menu bar icon when it is on, asks once to allow banners, unless the setup shows, which holds the question until it ends, arms the deferred work's fallback, and starts a startup measurement's timeout. The desktop runtime calls it once the app has launched, when the system appearance the System theme follows is known. A setting that cannot be read falls back to its default, with a note on Stderr.

func (*Shell) OpenAfterQuit added in v0.3.1

func (s *Shell) OpenAfterQuit(bundle string)

OpenAfterQuit quits the app the normal way, which asks first while runs go in the app (ShouldQuit), and has it open the bundle at bundle once it has quit (RelaunchCommand): the copy a move to Applications made or found. While a move holds the quit (HoldQuit), as it does until it ends, the quit waits for it. Asked again, it opens one bundle, the last asked for, once; a quit the user keeps from going through (Keep running, event.QuitKept) forgets it, so a later quit opens nothing. Once the shell is stopping it does nothing.

func (*Shell) Quit

func (s *Shell) Quit()

Quit quits the app.

func (*Shell) RefreshNow

func (s *Shell) RefreshNow()

RefreshNow refreshes the inbox from GitHub in the background, as the menu bar's Refresh Now asks; Stop waits for it. The refresh says when it is stored, and records a failure for the window and the menu bar to show, which is also logged.

func (*Shell) RelaunchCommand added in v0.3.1

func (s *Shell) RelaunchCommand(exe, sandbox string) ([]string, bool)

RelaunchCommand works out the one command that opens the app again once it has quit, for the desktop runtime to run then, from the executable exe, on the sandbox's data directory when it ran on one (""): none while a restart to update quits the app, whose helper opens the new version; else the copy a move to Applications asked to open (OpenArgs), which a reset asked for too carries out as well, since it has the same data; else, after a reset, this bundle again (RelaunchArgs); else none.

func (*Shell) Relaunching added in v0.3.0

func (s *Shell) Relaunching() bool

Relaunching reports whether the app quits to open again, as a reset the user asked for does: the desktop runtime opens the app again once it has shut down (see RelaunchCommand).

func (*Shell) ShouldQuit

func (s *Shell) ShouldQuit() bool

ShouldQuit answers the desktop runtime's question whether the app may quit now, which every quit asks: the menu's, the menu bar's, the system's at a logout, and a restart to update's. A restart to update, and a shell already stopping, always go through. Otherwise, while a move to Applications runs (HoldQuit), it says no and brings the window forward, where the move shows, and the quit goes ahead once the move ends. Else it says yes unless the quit guard reports runs going in the app and the user hasn't chosen to stop them; then it brings the window forward, asks the page to ask the user, and says no. It runs on the main thread, so it answers at once and does the rest in the background.

func (*Shell) ShowWindow

func (s *Shell) ShowWindow()

ShowWindow brings the window forward, unless the shell is stopping.

func (*Shell) Start

func (s *Shell) Start(ctx context.Context)

Start starts the background work: the menu bar's redraws, then each worker in order. It runs once; a later call, or one after Stop, does nothing. When ctx ends, the work ends with it, as it does when the shell stops.

func (*Shell) Stop

func (s *Shell) Stop() error

Stop shuts the shell down, once, in this order: it drops every later event, stops the snooze, measurement, and deferred-work timers, ends the background work and waits for it, up to the stop timeout, and then closes the data. It returns the error closing the data returned, on this and every later call. It is safe to call without Start.

func (*Shell) Stopping

func (s *Shell) Stopping() bool

Stopping reports whether Stop has begun. Work the desktop runtime queued before then checks it, so nothing is drawn once the app is shutting down.

func (*Shell) TimedOut

func (s *Shell) TimedOut() bool

TimedOut reports whether a startup measurement gave up waiting for the first paint; the run then exits with a failure status.

func (*Shell) UpdateAction added in v0.3.1

func (s *Shell) UpdateAction(action menubar.UpdateAction)

UpdateAction does what a click on a row of the update's part of the menu bar asks. A check runs in the background, and how it went shows on the menu's status line for menubar.NoteFor, in place of the line an earlier check left. Restart to Update, Update to X… (the download Just tell me leaves to a click, then the restart), and Try Updating to X Again (either of them, after an install that may work if tried again) bring the window forward and ask it to restart (event.UpdateRestartRequested), so every restart runs the window's one flow: it downloads first when it must, asks first when restarting would stop a run or lose text a sheet holds, and says why when the restart doesn't go ahead. The window is only ever hidden, never gone, so its page hears the request. Download X Manually… opens the version's release page in the browser.

type Tray

type Tray interface {
	// Show puts the icon in the menu bar, if it is not there.
	Show()

	// Hide takes the icon out of the menu bar.
	Hide()

	// Draw sets the icon's count and its menu.
	Draw(sum menubar.Summary)
}

Tray is the menu bar icon. Its methods must not wait for anything Stop waits for: Stop can run on the thread the icon is drawn on.

type URLOpener added in v0.3.1

type URLOpener interface {
	OpenURL(url string) error
}

URLOpener opens a web page in the user's browser: the desktop runtime's.

type Updates added in v0.3.1

type Updates interface {
	Status(ctx context.Context) (update.Status, error)
	CheckNow(ctx context.Context) (update.Status, error)
}

Updates is the app's update as the menu bar offers it: its status, and Check for Updates…. *update.Service implements it. A restart, and the download Just tell me's Update starts it with, are the window's (UpdateAction).

type Window

type Window interface {
	// Open opens the window at size, shrunk to fit the screen, in the native appearance
	// and on the background of theme, with its page showing text at textSize from the
	// first frame, and the first-run setup from its first frame when setup is set.
	Open(theme settings.Theme, size settings.WindowSize, textSize settings.TextSize, setup bool)

	// Show brings the window forward: shown if it was closed into the menu bar, restored
	// if it was minimized, and the app made active.
	Show()

	// SetTheme pins the native appearance to theme and repaints the window's background.
	SetTheme(theme settings.Theme)

	// SetTextSize sets the smallest the window can be to suit textSize, growing the window
	// if it is smaller; the page shows the size itself.
	SetTextSize(textSize settings.TextSize)
}

Window is the app's one window and its native appearance.

type Worker

type Worker interface {
	Run(ctx context.Context)
}

Worker is background work that runs while the app is open, such as the inbox's scheduled refreshes. Run returns once ctx is canceled and the work in flight has returned. *inbox.Scheduler and worktrees.Sweeper implement it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL