Documentation
¶
Overview ¶
Package tray is the Blitz tray icon's behaviour, apart from the icon library: what the service's state is, the menu for it, and what its items do. cmd blitz-tray draws it with fyne.io/systray.
Index ¶
- Constants
- Variables
- func ApprovalsTitle(n int) string
- func Arrived(seen map[string]bool, tasks []*pb.HumanTask) []*pb.HumanTask
- func Detached(name string, args ...string) error
- func Do(ctx context.Context, sock string, a Action, open func(link string) error) error
- func Exited(pid int, d time.Duration) bool
- func Failed(seen map[string]bool, runs []*pb.WorkflowRun, since time.Time) []*pb.WorkflowRun
- func FetchApprovals(ctx context.Context, sock string) []*pb.GoingServiceRun
- func FetchRuns(ctx context.Context, sock string) ([]*pb.WorkflowRun, error)
- func FetchTasks(ctx context.Context, sock string) ([]*pb.HumanTask, string, error)
- func ICO(pngData []byte) ([]byte, error)
- func Key(entries []Entry) string
- func Label(e Entry) string
- func Language(b *i18n.Bundle, prefs []byte, system []string) language.Tag
- func LogDir() string
- func PageDir(dir string) (fs.FS, error)
- func ProcessesLink(workspace string, id int) string
- func ProcessesTitle(procs []*pb.WorkspaceProcess) string
- func Pulse(icon []byte, alpha float64) ([]byte, error)
- func RunLink(alerts string, r *pb.WorkflowRun) string
- func Serve(o pageserver.Options, in io.Reader, out io.Writer) error
- func ServiceExecutable(ctx context.Context, sock string) string
- func ServiceLogDir(ctx context.Context, sock string) string
- func SetupLocale()
- func Shutdown(ctx context.Context, sock string) error
- func SystemLanguages() []string
- func TasksLink(alerts string, arrived []*pb.HumanTask) string
- func TasksTitle(n int) string
- func WatchRuns(ctx context.Context, sock string, retry time.Duration, ...)
- func WithDot(icon []byte) ([]byte, error)
- func WorkersLink(workspace, name string) string
- func WorkflowLink(workspace, workflow, run string) string
- type Action
- type ActionKind
- type Actions
- type Conn
- type Entry
- func ApprovalEntries(runs []*pb.GoingServiceRun) []Entry
- func Going(l Live, spaces []Space, now time.Time) []Entry
- func MCPEntries(e Extras) []Entry
- func ProcessEntries(procs []*pb.WorkspaceProcess, spaces []Space) []Entry
- func SpaceEntries(s Space, workers []*pb.Worker, flows []Flow, conns []Conn, l Live) []Entry
- type Extras
- type Flow
- type Item
- type Link
- type Live
- type Menu
- type Space
- type Status
- type Update
Constants ¶
const ( IconPlay = "play" IconStop = "stop" IconEye = "eye" IconFolder = "folder" IconJob = "job" IconWorkflow = "workflow" IconConnector = "connector" DotRunning = "dot-running" DotFailed = "dot-failed" DotWaiting = "dot-waiting" SwitchOn = "switch-on" SwitchOff = "switch-off" )
Icon names: each drawn as a character before the entry's title (Label).
Variables ¶
var PulseFrames = []float64{1, 0.82, 0.62, 0.45, 0.62, 0.82}
PulseFrames are the icon's brightness while something runs, one frame after another, a breath of about a second and a half.
Functions ¶
func ApprovalsTitle ¶ added in v0.9.0
ApprovalsTitle is the Jobs menu's title for n runs waiting.
func Arrived ¶ added in v0.7.1
Arrived returns the tasks not in seen, and makes seen the tasks now waiting (an answered task is forgotten).
func Detached ¶
Detached starts a program in its own session, with no terminal and its output discarded, and reaps it when it exits.
func Do ¶ added in v0.7.1
Do does what a click asks of the service at sock; ShowWorkers, ShowWorkflow and ShowProcess open their links with open.
func Failed ¶ added in v0.7.1
func Failed(seen map[string]bool, runs []*pb.WorkflowRun, since time.Time) []*pb.WorkflowRun
Failed returns the runs that failed after since and aren't in seen, and adds them to seen.
func FetchApprovals ¶ added in v0.9.0
func FetchApprovals(ctx context.Context, sock string) []*pb.GoingServiceRun
FetchApprovals are the organization's runs waiting for the person's answer (spec_053 EN-43): none when not connected, signed out, or from an older service.
func FetchRuns ¶ added in v0.7.1
FetchRuns asks the service for the latest workflow runs, in every workspace (spec_043_workflows WF-19), newest first.
func FetchTasks ¶ added in v0.7.1
FetchTasks asks the service for the human tasks workflows wait on, in every workspace (timers aren't the user's to answer), and how the user wants to hear of them ([ui] task_alerts: notify, open or off).
func ICO ¶ added in v0.4.0
ICO wraps a PNG in an icon file (.ico), which Windows wants for a tray icon: one image, stored as the PNG itself, as Windows Vista and later read it.
func Language ¶
Language is the language the tray shows: the desktop app's setting (prefs, the content of ~/.blitz/desktop.json) unless it's "system"; else the first of the system's languages (most preferred first) with a catalog; else English. It chooses as the app's window does.
func LogDir ¶
func LogDir() string
LogDir is where the service's logs go by the settings file: log.dir of the global settings.
func PageDir ¶ added in v0.7.0
PageDir is the built page in dir, checked to be one (it has index.html).
func ProcessesLink ¶ added in v0.8.5
ProcessesLink opens the desktop app's processes view on a workspace's process.
func ProcessesTitle ¶ added in v0.8.4
func ProcessesTitle(procs []*pb.WorkspaceProcess) string
ProcessesTitle is the submenu's own item: how many are running, and how many of them look bad (spec_052_processes).
func RunLink ¶ added in v0.7.1
func RunLink(alerts string, r *pb.WorkflowRun) string
RunLink is the link that tells the desktop app a workflow run failed: blitz://run, with notify=1 a notification (titled and worded here in the user's language) that opens the app on the run (its workspace, its workflow's canvas). "" when alerts are off.
func Serve ¶ added in v0.7.0
Serve serves the desktop page for a window that shows it (the Electron app, which runs blitz-tray --serve): it writes a one-time link to the page to out as a JSON line, a new one for each "link" line it reads from in, and stops serving when in ends, so it never outlives the window that started it.
func ServiceExecutable ¶ added in v0.7.0
ServiceExecutable is the program the service at sock runs from, as it says (GetServiceInfo); "" when it isn't running or doesn't say.
func ServiceLogDir ¶
ServiceLogDir is where the service at sock writes its log, as it says (ListLogDays): the log.dir it started with. "" when it isn't running, doesn't say, or has its log off.
func SetupLocale ¶
func SetupLocale()
SetupLocale shows the tray in the desktop app's language (Settings › Language), from the same catalogs, with ui.locales_dir's added.
func Shutdown ¶ added in v0.4.0
Shutdown asks the service at sock to stop (WorkspaceService.Shutdown): how the tray stops one it can't signal (Windows).
func SystemLanguages ¶
func SystemLanguages() []string
SystemLanguages are the user's languages, most preferred first: macOS's list (programs started at login have no LANG there), then LANGUAGE, LC_ALL, LC_MESSAGES and LANG.
func TasksLink ¶ added in v0.7.1
TasksLink is the link that tells the desktop app tasks have arrived (spec_038_electron EL-110): blitz://tasks opens its tasks window (or its dialog, when the app is open), with notify=1 a notification first, titled and worded here in the user's language. "" when alerts are off or nothing arrived.
func TasksTitle ¶ added in v0.7.1
TasksTitle is the tray menu's item for the waiting tasks.
func WatchRuns ¶ added in v0.8.0
WatchRuns follows every workspace's workflow runs on the service at sock (WatchWorkflowRuns): on each change, on hears the runs going on and lately ended. When the stream ends (the service stops or restarts), on hears none, and it's asked again after retry, until ctx is done.
func WorkersLink ¶ added in v0.7.1
WorkersLink is the blitz:// link that opens the app on a workspace's jobs, on one job's details when name is given.
func WorkflowLink ¶ added in v0.8.0
WorkflowLink is the blitz:// link that opens the app on a workflow's canvas, and on one of its runs when run is given.
Types ¶
type Action ¶ added in v0.7.1
type Action struct {
Kind ActionKind
Workspace string
Category string
Scope string
Name string
RunID string
Hash string
On bool
ID int
}
Action is an entry's click.
type ActionKind ¶ added in v0.7.1
type ActionKind int
ActionKind is what clicking an entry does.
const ( NoAction ActionKind = iota SetMCP // turn an MCP server on or off (On) StopRun // stop a worker's run (RunID) RunWorker // run a worker now EnableWorker // enable a worker at the hash reviewed (Hash) DisableWorker // disable a worker ShowWorkers // open the app on a workspace's workers RunWorkflow // run a workflow in the background (Name) StopWorkflow // stop a workflow's run (RunID) ShowWorkflow // open the app on a workflow's canvas (Name), on a run (RunID) SetConnector // turn a connection on or off in a workspace (Category, Scope, Name, On) StopProcess // stop an agent's background process (Workspace, ID) ShowProcess // open the app's processes view on one (Workspace, ID) AnswerServiceRun // approve (On) or deny an organization's run waiting (RunID, EN-43) )
What an entry does.
type Actions ¶
type Actions struct {
// Run starts a program and doesn't wait for it.
Run func(name string, args ...string) error
// Beside is the tray's own directory (blitzd and the app are there
// when installed together).
Beside string
// Status is the service's state now.
Status func() Status
// Wait polls until the service is (or isn't) running, for up to d.
Wait func(running bool, d time.Duration) bool
// LogDir is where the running service says its log is ("" when it
// doesn't say); nil asks nobody. The settings file answers otherwise.
LogDir func() string
// Shutdown asks the service to stop (nil: nobody is asked, and Stop
// signals it).
Shutdown func() error
}
Actions are what the menu's items do. Each has what it needs to find and run the system's programs; tests replace them.
func (Actions) OpenApp ¶
OpenApp opens the desktop app: the bundle the tray is in (macOS), the app the tray is in, beside it or on PATH (blitz-desktop on Linux, Blitz.exe on Windows).
func (Actions) OpenLink ¶ added in v0.7.1
OpenLink opens a link (blitz://…) with the program the system has for it: the desktop app, for blitz links.
func (Actions) OpenLogs ¶
OpenLogs shows the logs folder in the file manager: the running service's, which may not be the settings file's (another --config, or log.dir changed since it started).
type Conn ¶ added in v0.8.0
type Conn struct {
Category string
// Scope is workspace (.agents/connectors/<category>) or global.
Scope string
Name string
// On says it's served in the workspace (CON-17).
On bool
}
Conn is a connection a workspace reaches.
type Entry ¶ added in v0.7.1
type Entry struct {
Title string
Checkbox bool
Checked bool
Disabled bool
Icon string
Action Action
Children []Entry
}
Entry is a menu item: a title, a checkbox (Checked) or not, greyed out (Disabled), its icon (Icon*, Dot*: main draws it), what a click does, and a submenu.
func ApprovalEntries ¶ added in v0.9.0
func ApprovalEntries(runs []*pb.GoingServiceRun) []Entry
ApprovalEntries are the waiting runs, each with what it asks and Approve, Deny and Show in Blitz (the window's Processes, where the organization's runs are).
func Going ¶ added in v0.8.0
Going are the menu's running entries: each job's run (with its workflow's progress when it runs one), then each other workflow run going on, named with its workspace when there's more than one; each opens on Show in Blitz and Stop. A run waiting on a person or a timer has the waiting dot.
func MCPEntries ¶ added in v0.7.1
MCPEntries are the MCP servers submenu: each global server, checked while it's on; a click turns it off or on.
func ProcessEntries ¶ added in v0.8.4
func ProcessEntries(procs []*pb.WorkspaceProcess, spaces []Space) []Entry
ProcessEntries are the Processes submenu: each running process, its command (marked when it looks bad), under it its workspace (named as spaces name it), what it uses and why it looks bad, Show in Blitz and Stop; none, a line saying so.
func SpaceEntries ¶ added in v0.8.0
SpaceEntries are a workspace's submenu: Jobs, each job with Run now, Stop while it runs, Enabled and Show in Blitz, marked running or failed; then Workflows, each with Run, Stop while it runs and Show in Blitz, marked running; then Connectors, each connection it reaches checked while it's on there (connEntries). A section with nothing in it is left out, and a workspace with none has no submenu (none).
type Extras ¶ added in v0.7.1
type Extras struct {
MCP []*pb.MCPServerConfig
Workers []*pb.Worker
Runs []*pb.WorkerRun
// Processes are the agents' background processes still running
// (EL-112); none from an older service.
Processes []*pb.WorkspaceProcess
}
Extras is what the submenus show: the global MCP servers, every workspace's workers and the runs going on.
type Link ¶ added in v0.7.0
type Link struct {
URL string `json:"url"`
// Fingerprint is the page server's certificate's (SHA-256, colon-
// separated hex): the one certificate the window trusts for it.
Fingerprint string `json:"fingerprint"`
}
Link is what Serve writes for each link it makes: one JSON line.
type Live ¶ added in v0.8.0
type Live struct {
// Runs are workflow runs going on and lately ended (WatchWorkflowRuns).
Runs []*pb.WorkflowRun
// JobRuns are jobs' runs going on (ListRunningWorkerRuns).
JobRuns []*pb.WorkerRun
}
Live is what's going on, as the service says.
type Menu ¶
type Menu struct {
Running bool // which icon
Tooltip string
// State is the first line: what the service is doing (not clickable).
State Item
Start, Stop, Restart Item
}
Menu is what the tray shows for a status.
type Status ¶
type Status struct {
// Running means the service answers on its socket.
Running bool
// Installed means it starts at login (a launchd agent or systemd unit).
Installed bool
// Version and PID are what the running service says (GetServiceInfo).
Version string
PID int
// Org is the organization Blitz is connected to: its branding's name,
// else its service's (spec_053_enterprise EN-51); "" for none.
Org string
}
Status is the service as the tray sees it.
type Update ¶ added in v0.7.0
type Update struct {
Staged, Root, Relaunch string
// WaitPID is the app's process, waited for (0: none).
WaitPID int
Actions Actions
// ServiceExe is the running service's program ("" if none runs).
ServiceExe func() string
// Exited waits up to d for process pid to end.
Exited func(pid int, d time.Duration) bool
Log io.Writer
}
Update puts a downloaded desktop app in place of the running one (blitz-tray --apply-update, run by the app's host from outside the app, spec_038_electron EL-90): it waits for the app to quit, stops the service if it runs from the app (Windows can't replace a program in use), swaps them, starts the service again and then the app, the new one or, if the swap failed, the old one.