Documentation
¶
Overview ¶
Package ui implements UiService, the API the window calls. It writes nothing outside the data directory.
Index ¶
- Constants
- Variables
- func DefaultChord(goos string) string
- func Home() (string, error)
- func NormalizeChord(chord, goos string) (string, error)
- func Summoned(ctx context.Context, db *store.Store) (string, error)
- func WriteAtomic(path string, data []byte) error
- type Action
- type Notices
- type Notification
- type Notifier
- 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(context.Context, *connect.Request[uiv1.UiServiceGetEnvironmentRequest]) (*connect.Response[uiv1.UiServiceGetEnvironmentResponse], 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) Present(wishID, terminal string)
- func (s *Service) PresentTilasm(wishID, tilasmID string)
- func (s *Service) Ready() string
- func (s *Service) SetBuild(build *uiv1.Build)
- func (s *Service) SetNotResumed(lines []string)
- func (s *Service) SetReady(version, notesURL string)
- 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) Update(ctx context.Context, req *connect.Request[uiv1.UiServiceUpdateRequest]) (*connect.Response[uiv1.UiServiceUpdateResponse], 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 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 ¶
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 ¶
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 ¶
Home is the data directory: $DJINN_HOME, by default ~/.config/djinn (djinn-dev for a development build).
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 Summoned ¶
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.
func WriteAtomic ¶
WriteAtomic writes a temporary file next to path, readable by the owner only, then renames it over path: a reader sees the old content or the new one, never a part of it. The rename tries again a moment on Windows, where an antivirus scanning the file refuses it.
Types ¶
type Notices ¶
type Notices struct {
Store *store.Store
// Language of the notifications' texts.
Language string
// Show brings the window forward on a wish.
Show func(wishID 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 of each question asked in an active wish, by a system notification: a click brings the window forward on the wish, a button answers the question. It tells of each new inbox item too: a click brings the window forward, where the flight plan shows the inbox; nothing answers the item from the notification. Without a notifier (a headless build, the browser) it shows nothing.
func (*Notices) Respond ¶
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, or as it is for an inbox item, which has none.
type Notification ¶
type Notification struct {
// ID names the notification: the question's or the item's identifier.
ID string
Title string
Body string
// WishID and QuestionID come back with what the user does with it; both are empty for an inbox item.
WishID string
QuestionID string
// Actions are the buttons that answer the question, in order.
Actions []Action
}
Notification is a system notification of a question or of an inbox item.
type Notifier ¶
type Notifier interface {
Notify(Notification) error
}
Notifier shows system notifications: the window's notification service, or a fake in tests.
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
// 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 ~/.config/djinn.
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)
// 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)
// contains filtered or unexported fields
}
Service implements uiv1connect.UiServiceHandler.
func (*Service) ChooseDirectory ¶
func (*Service) GetEnvironment ¶
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) 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) PresentTilasm ¶
PresentTilasm asks the windows to show a tilasm, in its wish's Tilasms tab, as Present does a wish.
func (*Service) SetBuild ¶
SetBuild proposes to install build, a batch committed into a wish's integration branch, in place of the one proposed before; nil proposes none.
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 at the path of the running one, its release notes at notesURL (empty for none); an empty version says none does.
func (*Service) SetShortcut ¶
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 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 ¶
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.