ui

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: Apache-2.0 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 ui implements UiService, the API the window calls. It writes nothing outside the data directory.

Index

Constants

View Source
const FlightPlan = "plan"

FlightPlan is the wish id that shows the flight plan of the active wishes: PLAN in src/wish-app.tsx. A wish's id is a UUID, never this.

Variables

View Source
var Develop bool

Develop is set by a development build of djinn, one built from a checkout rather than installed at a version: its data directory is then djinn-dev, so that the djinn being built never reaches the user's own djinn, its window, its socket or its wishes. DJINN_HOME still decides when it is set.

Functions

func DefaultChord

func DefaultChord(goos string) string

DefaultChord is the chord of a system until one is chosen. Ctrl+Alt+Space is free in GNOME (checked on GNOME 42), and supposed free in KDE Plasma and Windows. On macOS, Ctrl+Option+Space is VoiceOver's, and Cmd+Option+Space Finder's search: Ctrl+Cmd+J instead.

func Home

func Home() (string, error)

Home is the data directory: $DJINN_HOME, by default djinn in the user's configuration folder (djinn-dev for a development build).

func InTest added in v0.1.1

func InTest() bool

InTest reports whether the current process is running under `go test`, with DJINN_TEST=1, or is a test build.

func IsRealHome added in v0.1.1

func IsRealHome(path string) bool

IsRealHome reports whether path points to the user's real Djinn data directory.

func IsTestBuild added in v0.1.1

func IsTestBuild() bool

IsTestBuild reports whether the current binary was built for testing or is an e2e binary.

func NormalizeChord

func NormalizeChord(chord, goos string) (string, error)

NormalizeChord checks a chord and writes it the one way Djinn shows it: modifiers in order, then the key, such as Ctrl+Alt+Space; on macOS Alt is written Option. A chord needs Ctrl, Alt, Cmd or Super, so that it never takes a key from typing, and one key: a letter, a digit, F1 to F12, or Space. Empty stays empty: off.

func RealHome added in v0.1.1

func RealHome() string

RealHome returns the default data directory of the user: ~/.config/djinn (or djinn-dev for a development build).

func StampedTestBuild added in v0.1.1

func StampedTestBuild() bool

StampedTestBuild reports whether the binary was stamped a test build when linked, as task e2e and e2e-native stamp theirs: unlike IsTestBuild, a go test binary is not.

func Summoned

func Summoned(ctx context.Context, db *store.Store) (string, error)

Summoned is what the global shortcut shows: the active wish with the newest question that waits for the developer, else the flight plan. A question being investigated waits for the lead, not for the developer.

Types

type Action

type Action struct {
	ID    string
	Title string
}

Action is a button of a notification. Its ID comes back in Response.Action.

type Notices

type Notices struct {
	Store *store.Store
	// Language of the notifications' texts.
	Language string
	// Show brings the window forward on a wish, with target in view (UiServiceWatchShowResponse.target).
	Show func(wishID, target string)
	// Answer answers a question with a choice, as the window would.
	Answer func(ctx context.Context, questionID string, choice planv1.Choice) error
	// contains filtered or unexported fields
}

Notices tells the user, by a system notification, of what waits for them in an active wish: a question asked (the edit question of a task included), a task that waits for an answer or failed, or a wish that became ready to review. A click brings the window forward on the wish, there; a button answers the question. It tells of each new inbox item too, and of the choice the lead shows: a click brings the window forward, where the flight plan shows the inbox and the attention bar the lead's choice. Each event shows once, and none of a wish while the window is in front on it. Without a notifier (a headless build, the browser) it shows nothing.

func (*Notices) Access added in v0.1.1

func (n *Notices) Access() uiv1.NotificationAccess

Access tells whether the system shows the notifications.

func (*Notices) Focus added in v0.1.1

func (n *Notices) Focus(focused bool)

Focus says whether the window is in front.

func (*Notices) LeadPrompt added in v0.1.1

func (n *Notices) LeadPrompt(p *planv1.LeadPrompt)

LeadPrompt notifies the choice p the lead's agent shows in its terminal (an approval, a folder to trust): once per choice, again when another comes; nil says it went. A click brings the window forward, where the attention bar answers it. It never waits: it runs in the terminal's reader.

func (*Notices) Request added in v0.1.1

func (n *Notices) Request() uiv1.NotificationAccess

Request asks the system to show the notifications, and tells whether it does. Once it does, the choice the lead shows is notified again: the system may have refused it before.

func (*Notices) Respond

func (n *Notices) Respond(ctx context.Context, r Response)

Respond follows what the user did with a notification: a button answers its question; a click, or an answer that fails, brings the window forward on the wish, there, or as it is for an inbox item or the lead's choice, which have none.

func (*Notices) Run

func (n *Notices) Run(ctx context.Context)

Run follows the questions, tasks and inbox items stored, and notifies what is new, until ctx ends.

func (*Notices) Use

func (n *Notices) Use(notifier Notifier)

Use shows the notifications with notifier from now on; nil shows none. A choice the lead showed before, and still shows, is notified then: the lead may ask to trust its folder before the window can notify.

func (*Notices) View added in v0.1.1

func (n *Notices) View(wishID string)

View says which wish the page shows; empty for none.

type Notification

type Notification struct {
	// ID names the notification: one with the same ID replaces it.
	ID    string
	Title string
	Body  string
	// WishID and Target come back with a click: the wish to show, and the element of it to bring into view
	// (UiServiceWatchShowResponse.target). Both are empty for an inbox item.
	WishID string
	Target string
	// QuestionID is the question the buttons answer; empty without buttons.
	QuestionID string
	// Actions are the buttons that answer the question, in order.
	Actions []Action
}

Notification is a system notification: a question to answer, a task or wish that waits, a new inbox item, or the lead's choice.

type Notifier

type Notifier interface {
	Notify(Notification) error
}

Notifier shows system notifications: the window's notification service, or a fake in tests.

type Permission added in v0.1.1

type Permission interface {
	// Allowed tells whether the system shows the notifications.
	Allowed() (bool, error)
	// Allow asks the system to show them, and tells whether it does: on macOS its dialog shows the first time only.
	Allow() (bool, error)
}

Permission is a notifier that needs the system's permission to show anything (macOS). A notifier without it shows them as soon as it runs.

type Registrar

type Registrar interface {
	Register(chord string, pressed func()) error
	Unregister(chord string) error
}

Registrar takes global shortcuts from the system: the window's (Wails), or a fake in tests. Register calls pressed on each press, wherever the focus is; it fails when the system refuses the chord.

type Response

type Response struct {
	WishID     string
	QuestionID string
	Target     string
	// Action is the button pressed: an Action.ID; empty for a click on the notification itself.
	Action string
}

Response is what the user did with a notification.

type Service

type Service struct {
	uiv1connect.UnimplementedUiServiceHandler

	// Home is the data directory: $DJINN_HOME, by default djinn in the user's configuration folder.
	Home string
	// Version of djinn, as GetEnvironment reports it.
	Version string
	// Open opens a link in the default browser. Tests replace it.
	Open func(link string) error
	// Raise brings the window to the front, or in browser mode prints the address of the page again. Nil does
	// nothing.
	Raise func()
	// Window tells that Raise brings a native window to the front.
	Window bool
	// Restart restarts Djinn on the newer one that waits at its path, once the response to Update is sent, and
	// returns the version it restarts on and how many terminals it will run again. Nil: Update is unavailable.
	Restart func() (version string, terminals int, err error)
	// AgentPath is the PATH where GetEnvironment looks for the agents, and nowhere else. Nil: Djinn's own, brought
	// up to date by machine.ExtendPath, which the workers and the leads get too. Tests replace it.
	AgentPath func() string
	// Install installs a build that SetBuild proposed: its project's install command, run on its commit, telling
	// progress each step and what it waits for. It tells whether a newer Djinn waits at the path of the running one
	// since, to restart on. Nil: no build installs.
	Install func(ctx context.Context, build *uiv1.Build, progress func(step uiv1.InstallStep, waiting string)) (newer bool, err error)
	// ChooseFolder opens the system's folder dialog over the window, titled title and open in directory, and returns
	// the folder chosen, or empty when the user cancelled. Nil: the page has no folder dialog (the browser).
	ChooseFolder func(title, directory string) (string, error)
	// Shortcuts is the global shortcut that brings the window forward. Nil: SetShortcut is unavailable.
	Shortcuts *Shortcuts
	// Linked is the wish a link shows: the tilasm's, or the wish itself; an error of code NotFound when it is not on
	// this machine. Nil: OpenLink is unavailable.
	Linked func(ctx context.Context, l link.Link) (wishID string, err error)
	// WatchLoad streams operating load and memory stats. Nil: no load stats streamed in Watch.
	WatchLoad func(ctx context.Context, send func(*djinnv1.LoadServiceWatchResponse) error) error

	// Shown is called when the window is asked to show a wish or a terminal.
	Shown func(wishID, terminal string)
	// Known tells whether a wish is still on this machine: a show of the last minute whose wish was deleted since is
	// not replayed to a window that opens, which would leave the wish it shows for the flight plan. Nil: every wish is.
	Known func(ctx context.Context, wishID string) bool
	// Notices shows the system notifications, and knows whether the system lets it. Nil: none (a test).
	Notices *Notices
	// contains filtered or unexported fields
}

Service implements uiv1connect.UiServiceHandler.

func New

func New(version string) (*Service, error)

New returns the service on the data directory of this machine.

func (*Service) LastShow

func (s *Service) LastShow() (wishID, terminal string)

LastShow is the last wish and terminal the window was asked to show, however old; empty for none.

func (*Service) Present

func (s *Service) Present(wishID, terminal string)

Present asks the windows to show a wish and a terminal: the ones watching now, and one that starts watching within a minute.

func (*Service) PresentAt added in v0.1.1

func (s *Service) PresentAt(wishID, terminal, target string)

PresentAt is Present with an element of the wish in view (UiServiceWatchShowResponse.target).

func (*Service) PresentTilasm

func (s *Service) PresentTilasm(wishID, tilasmID string)

PresentTilasm asks the windows to show a tilasm, in its wish's Tilasms tab, as Present does a wish.

func (*Service) Ready

func (s *Service) Ready() string

Ready is the version of the newer Djinn waiting; empty for none.

func (*Service) SetBuild

func (s *Service) SetBuild(build *uiv1.Build)

SetBuild proposes to install build, the last push of an integration branch, in place of the one proposed before for the same branch of the same project: each branch keeps its own, the branch the running Djinn was built from first.

func (*Service) SetNotResumed

func (s *Service) SetNotResumed(lines []string)

SetNotResumed reports the terminals a restart could not run again.

func (*Service) SetReady

func (s *Service) SetReady(version, notesURL string)

SetReady says that a newer Djinn of version waits at the path of the running one, its release notes at notesURL (empty for none); an empty version says none does.

func (*Service) SetReadyBuild added in v0.1.1

func (s *Service) SetReadyBuild(version string, build *uiv1.Build)

SetReadyBuild names the newer Djinn of version that waits, as a build: its commit, the branch and wish it comes from, how it compares with the running one. Nothing when another version waits now.

func (*Service) View added in v0.1.1

func (*Service) Watch added in v0.1.1

type Shortcuts

type Shortcuts struct {
	// Home is the data directory.
	Home string
	// GOOS is the system the chords are written for; empty for this one.
	GOOS string
	// Store finds the open questions.
	Store *store.Store
	// Show brings the window forward on a wish, or on FlightPlan.
	Show func(wishID string)
	// contains filtered or unexported fields
}

Shortcuts holds the global shortcut that brings the window forward: on the wish with the newest open question, else on the flight plan. The chord is a setting, kept in settings.json; it is taken from the system while a registrar is set, that is while the native window runs.

func (*Shortcuts) Refused

func (s *Shortcuts) Refused(err error)

Refused says that the system refused the chord after Register returned: on Wayland, the desktop's portal answers later, and may have no global shortcuts at all.

func (*Shortcuts) Set

func (s *Shortcuts) Set(chord string) (*uiv1.Shortcut, error)

Set chooses chord, as NormalizeChord reads it; empty turns the shortcut off. It is kept even when the system refuses it: State says why, and the next start tries again.

func (*Shortcuts) State

func (s *Shortcuts) State() *uiv1.Shortcut

State is the shortcut as it is now.

func (*Shortcuts) Use

func (s *Shortcuts) Use(r Registrar)

Use takes the chord from the system with r from now on. Nil forgets it, as the window closes: the system takes back the chords of an app that stops.

Jump to

Keyboard shortcuts

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