Documentation
¶
Overview ¶
Package ui implements UiService, the API the window calls. It writes nothing outside the data directory.
Index ¶
- Constants
- Variables
- func Account(ctx context.Context, provider planv1.Provider, env []string) string
- func DefaultChord(goos string) string
- func FromWindow(h http.Handler) http.Handler
- func Home() (string, error)
- func InTest() bool
- func InWindow(ctx context.Context, header http.Header) bool
- func IsRealHome(path string) bool
- func IsTestBuild() bool
- func NormalizeChord(chord, goos string) (string, error)
- func RealHome() string
- func SignedIn(ctx context.Context, provider planv1.Provider, env []string) uiv1.ProviderState
- func StampedTestBuild() bool
- func StopBy(ctx context.Context, header http.Header, install bool) string
- func Summoned(ctx context.Context, db *store.Store) (string, error)
- type Action
- type InstallRun
- type Notices
- func (n *Notices) Access() uiv1.NotificationAccess
- func (n *Notices) Focus(focused bool)
- func (n *Notices) IfritWarning(t *planv1.Task)
- func (n *Notices) LeadPrompt(p *planv1.LeadPrompt)
- func (n *Notices) Request() uiv1.NotificationAccess
- func (n *Notices) Respond(ctx context.Context, r Response)
- func (n *Notices) Run(ctx context.Context)
- func (n *Notices) Use(notifier Notifier)
- func (n *Notices) View(wishID string)
- func (n *Notices) Window(title, body string) error
- type Notification
- type Notifier
- type Permission
- type Registrar
- type Response
- type Service
- func (s *Service) ChooseDirectory(_ context.Context, req *connect.Request[uiv1.UiServiceChooseDirectoryRequest]) (*connect.Response[uiv1.UiServiceChooseDirectoryResponse], error)
- func (s *Service) GetEnvironment(ctx context.Context, req *connect.Request[uiv1.UiServiceGetEnvironmentRequest]) (*connect.Response[uiv1.UiServiceGetEnvironmentResponse], error)
- func (s *Service) GetNotifications(context.Context, *connect.Request[uiv1.UiServiceGetNotificationsRequest]) (*connect.Response[uiv1.UiServiceGetNotificationsResponse], error)
- func (s *Service) LastShow() (wishID, terminal string)
- func (s *Service) OpenExternal(_ context.Context, req *connect.Request[uiv1.UiServiceOpenExternalRequest]) (*connect.Response[uiv1.UiServiceOpenExternalResponse], error)
- func (s *Service) OpenLink(ctx context.Context, req *connect.Request[uiv1.UiServiceOpenLinkRequest]) (*connect.Response[uiv1.UiServiceOpenLinkResponse], error)
- func (s *Service) OpenNotificationSettings(context.Context, ...) (*connect.Response[uiv1.UiServiceOpenNotificationSettingsResponse], error)
- func (s *Service) Present(wishID, terminal string)
- func (s *Service) PresentAt(wishID, terminal, target string)
- func (s *Service) PresentTilasm(wishID, tilasmID string)
- func (s *Service) Ready() string
- func (s *Service) RequestNotifications(context.Context, *connect.Request[uiv1.UiServiceRequestNotificationsRequest]) (*connect.Response[uiv1.UiServiceRequestNotificationsResponse], error)
- func (s *Service) SetBuild(build *uiv1.Build)
- func (s *Service) SetHeld(why uiv1.HeldStart, memoryPercent float64, tasks []string)
- func (s *Service) SetNotResumed(lines []string)
- func (s *Service) SetReady(version, notesURL string, installed bool)
- func (s *Service) SetReadyBuild(version string, build *uiv1.Build)
- func (s *Service) SetShortcut(_ context.Context, req *connect.Request[uiv1.UiServiceSetShortcutRequest]) (*connect.Response[uiv1.UiServiceSetShortcutResponse], error)
- func (s *Service) Show(_ context.Context, req *connect.Request[uiv1.UiServiceShowRequest]) (*connect.Response[uiv1.UiServiceShowResponse], error)
- func (s *Service) Touch(context.Context, *connect.Request[uiv1.UiServiceTouchRequest]) (*connect.Response[uiv1.UiServiceTouchResponse], error)
- func (s *Service) Update(ctx context.Context, req *connect.Request[uiv1.UiServiceUpdateRequest]) (*connect.Response[uiv1.UiServiceUpdateResponse], error)
- func (s *Service) View(_ context.Context, req *connect.Request[uiv1.UiServiceViewRequest]) (*connect.Response[uiv1.UiServiceViewResponse], error)
- func (s *Service) Watch(ctx context.Context, _ *connect.Request[uiv1.UiServiceWatchRequest], ...) error
- func (s *Service) WatchShow(ctx context.Context, _ *connect.Request[uiv1.UiServiceWatchShowRequest], ...) error
- func (s *Service) WatchUpdate(ctx context.Context, _ *connect.Request[uiv1.UiServiceWatchUpdateRequest], ...) error
- type Shortcuts
Constants ¶
const ( // DefaultInstallLimit is how long an install may work, its waits aside, before Djinn stops it: go tool task install // takes from 10 s to a minute, a setup after the lock files changed a few minutes more. DefaultInstallLimit = 20 * time.Minute // DefaultAutoRetry is how long an install Djinn starts by itself waits before it looks at a busy machine again. DefaultAutoRetry = 30 * time.Second )
const FlightPlan = "plan"
FlightPlan is the wish id that shows the flying carpet of the active wishes: PLAN in src/wish-app.tsx. A wish's id is a UUID, never this. The flying carpet was called the flight plan, hence the name.
Variables ¶
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 Account ¶ added in v0.2.0
Account is a fingerprint of the account provider's agent is signed in with on this machine, in its own folder: what its status command prints of it (claude auth status: its email, organization and way of signing in, as JSON; codex login status: its line), hashed at once. Empty when the agent documents no status command, is missing or signed out. Djinn keeps the fingerprint alone, never the account's name: the scheduler compares two of them to see that the account changed while a task waits for the usage limit of the one before (harness.WithAccount). env is what an account adds to the agent's environment (plan.AccountEnv), to read its folder; nil for the agent's own.
func DefaultChord ¶
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 FromWindow ¶ added in v0.2.0
FromWindow marks the calls h receives as the native window's: on macOS and Linux, the window's page reaches the server through the Wails asset server, apart from the command line's socket.
func Home ¶
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 InWindow ¶ added in v0.2.0
InWindow tells that a call comes from the window's page: marked by FromWindow, or, over HTTP (Windows, a browser), sent by a page, which names its Origin, where the command line names none.
func IsRealHome ¶ added in v0.1.1
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 ¶
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 SignedIn ¶ added in v0.2.0
SignedIn says where provider's agent stands, run with env added to Djinn's environment (an account's folder): missing, signed out, ready, or unknown when it documents no status command. The driven lead asks it before it offers to move there.
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.
Types ¶
type InstallRun ¶ added in v0.1.2
type InstallRun struct {
// Low runs its commands at a low-priority worker's CPU priority: an install Djinn starts by itself.
Low bool
// Progress is told each step as it comes, and what the install waits for while it waits.
Progress func(step uiv1.InstallStep, waiting string)
// Output is told each line its commands write, as they write it.
Output func(line string)
}
InstallRun is how an install runs, and what it tells as it runs.
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
// KeepLit says that the developer is there, as the Keep lit button of an ifrit's warning does (IfritWarning).
KeepLit func()
// 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 flying carpet 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) IfritWarning ¶ added in v0.2.0
IfritWarning notifies that the ifrit t goes out soon (Task.ifrit.out_time), unless the developer comes back: its Keep lit button keeps it lit, a click shows it. Once per out time. It never waits.
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 ¶
Respond follows what the user did with a notification: a button answers its question, or keeps an ifrit lit; 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 ¶
Run follows the questions, tasks and inbox items stored, and notifies what is new, until ctx ends.
func (*Notices) Use ¶
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.
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
// Shown even while the window is in front on its wish: an ifrit's warning, which the page does not say.
Always bool
}
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; by names who asked, for the log
// of the stop (StopBy). Nil: Update is unavailable.
Restart func(by string) (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, as run says.
// It tells whether a newer Djinn waits at the path of the running one since, to restart on, and returns the end of
// what its command wrote. Nil: no build installs.
Install func(ctx context.Context, build *uiv1.Build, run InstallRun) (newer bool, out string, err error)
// Life is djinn up's: an install runs within it, whatever becomes of the call that asked for it. Nil: it never ends.
Life context.Context
// Busy says why the machine cannot take an install Djinn starts by itself now: a gate held, the machine under
// pressure; "" when it can. Nil: it always can.
Busy func() string
// InstallLimit is how long an install may work, its waits aside, before Djinn stops it. Zero: DefaultInstallLimit.
InstallLimit time.Duration
// AutoRetry is how long an install Djinn starts by itself waits before it looks at a busy machine again. Zero:
// DefaultAutoRetry.
AutoRetry time.Duration
// 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 flying carpet. 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
// Touched says that the developer is there (harness.Presence): it keeps the ifrits lit. Nil: nothing.
Touched func()
// contains filtered or unexported fields
}
Service implements uiv1connect.UiServiceHandler.
func (*Service) ChooseDirectory ¶
func (*Service) GetEnvironment ¶
func (*Service) GetNotifications ¶ added in v0.1.1
func (*Service) LastShow ¶
LastShow is the last wish and terminal the window was asked to show, however old; empty for none.
func (*Service) OpenExternal ¶
func (*Service) OpenNotificationSettings ¶ added in v0.1.1
func (*Service) Present ¶
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
PresentAt is Present with an element of the wish in view (UiServiceWatchShowResponse.target).
func (*Service) PresentTilasm ¶
PresentTilasm asks the windows to show a tilasm, in its wish's Tilasms tab, as Present does a wish.
func (*Service) RequestNotifications ¶ added in v0.1.1
func (*Service) SetBuild ¶
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, then those that carry its line on (W527), then the parallel ones. A build to install by itself (Build.auto) installs, once the machine is free; the others wait for the person's click.
func (*Service) SetHeld ¶ added in v0.4.0
SetHeld reports why this start resumed none of the workers the last djinn up left interrupted, the machine's memory at the Hourglass's last reading for HELD_START_MEMORY, and the tasks it held (cmd/djinn/held.go).
func (*Service) SetNotResumed ¶
SetNotResumed reports the terminals a restart could not run again.
func (*Service) SetReady ¶
SetReady says that a newer Djinn of version waits, its release notes at notesURL (empty for none): installed at the path of the running one already, or a release to download first. An empty version says none does.
func (*Service) SetReadyBuild ¶ added in v0.1.1
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) SetShortcut ¶
func (*Service) Watch ¶ added in v0.1.1
func (s *Service) Watch( ctx context.Context, _ *connect.Request[uiv1.UiServiceWatchRequest], stream *connect.ServerStream[uiv1.UiServiceWatchResponse], ) error
func (*Service) WatchShow ¶
func (s *Service) WatchShow( ctx context.Context, _ *connect.Request[uiv1.UiServiceWatchShowRequest], stream *connect.ServerStream[uiv1.UiServiceWatchShowResponse], ) error
func (*Service) WatchUpdate ¶
func (s *Service) WatchUpdate( ctx context.Context, _ *connect.Request[uiv1.UiServiceWatchUpdateRequest], stream *connect.ServerStream[uiv1.UiServiceWatchUpdateResponse], ) error
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 flying carpet. 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 ¶
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 ¶
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.