Documentation
¶
Overview ¶
Package system holds the few OS integrations the window needs that are not tied to any domain service — opening a URL in the user's default browser, opening a work-tree file in their editor, raising a desktop notification, and the handful of facts a bug report needs (version, platform, where the log lives).
Index ¶
- func ValidateExternalURL(rawURL string) error
- type AttachNativeOptions
- type Diagnostics
- type NativeHooks
- type QuitOptions
- type Service
- func (s *Service) AttachNative(opts AttachNativeOptions)
- func (s *Service) Diagnostics() Diagnostics
- func (s *Service) Notify(summary, detail string) error
- func (s *Service) OpenExternal(rawURL string) error
- func (s *Service) OpenFile(dir, rel string) error
- func (s *Service) OpenFolder(dir string) error
- func (s *Service) OpenFolderInEditor(dir string) (string, error)
- func (s *Service) Quit(QuitOptions) error
- func (s *Service) RevealLog() error
- func (s *Service) SSHAgentKeys() []string
- func (s *Service) SandboxBackend() string
- func (s *Service) SetEnv(env []string)
- func (s *Service) SetNativeWindow(hooks NativeHooks)
- func (s *Service) SetQuit(quit func() error)
- func (s *Service) ShowWindow(ShowWindowOptions) error
- func (s *Service) TakeUncleanExit() bool
- type ShowWindowOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateExternalURL ¶
ValidateExternalURL accepts absolute http/https URLs only.
Types ¶
type AttachNativeOptions ¶
type AttachNativeOptions struct {
// Executable is the native window's own binary, the one started again when
// lich is asked for its window after that window closed.
Executable string `json:"executable"`
}
AttachNativeOptions is the native window announcing itself.
type Diagnostics ¶
type Diagnostics struct {
Version string `json:"version"`
Platform string `json:"platform"`
LogPath string `json:"logPath"`
}
Diagnostics is what a bug report opens with: the three facts that decide whether a report is actionable, and the log path the user attaches.
type NativeHooks ¶
type NativeHooks struct {
// Raise brings an open native window forward, false when none is connected.
Raise func() bool
// Launch starts the native window on this backend; exited hears how the
// process ended once it does.
Launch func(executable string, exited func(state string)) error
// Locate is the native window's binary, shipped beside lich's.
Locate func() (string, error)
// Failed hears why a native window could not open.
Failed func(reason string)
}
NativeHooks are how lich drives its window, the native one (`lich native`), wired by main.
type QuitOptions ¶
type QuitOptions struct{}
QuitOptions is one Quit call, an object for the reason ShowWindowOptions is.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) AttachNative ¶
func (s *Service) AttachNative(opts AttachNativeOptions)
AttachNative records the native window that started as lich's window.
func (*Service) Diagnostics ¶
func (s *Service) Diagnostics() Diagnostics
func (*Service) Notify ¶
Notify raises a desktop notification through the OS's own notification service — the one channel that still reaches the user after they leave the lich window. summary is the headline, detail the second line (empty omits it).
Delivery only: the window decides when a notification is warranted, because it is the side that knows whether the window has focus and which session the user is looking at.
func (*Service) OpenExternal ¶
OpenExternal opens an http(s) URL in the default browser. Scheme-gated so a crafted terminal escape can never turn a click into a file:// or custom scheme launch. The launcher itself is per-OS (see the open_* files).
func (*Service) OpenFile ¶
OpenFile hands one work-tree file to the application the desktop opens its type with: an image viewer, a PDF reader. Unlike OpenFolderInEditor it never consults $VISUAL/$EDITOR, which would open a PNG in vim. rel goes through relpath.Resolve, as project.ReadFile does, so a symlink out of the checkout is refused rather than opened. The launcher is openFolder's: xdg-open, open and explorer each hand any path, file or folder, to its default handler.
func (*Service) OpenFolder ¶
OpenFolder shows a checkout in the platform's file manager. It never consults $VISUAL/$EDITOR: this is the way out of lich to the OS's own view of the folder, which is the one thing opening it in an editor does not give.
func (*Service) OpenFolderInEditor ¶
OpenFolderInEditor opens a session's checkout in the user's editor. It prefers $VISUAL, then $EDITOR, resolved from the login shell, so a GUI launch still sees rc exports. A terminal editor (vim, nvim, nano, …) is launched nothing: the shell command line to run in a lich terminal session comes back instead, since a detached launch would give it no controlling terminal. A GUI editor, or the file manager when none is set, is launched detached, and "" comes back.
func (*Service) Quit ¶
func (s *Service) Quit(QuitOptions) error
Quit ends lich: the window closes, every session's process ends with it, and the process exits. It returns once the exit is under way, so the reply can be lost to the exit it announces.
func (*Service) RevealLog ¶
RevealLog opens the log's directory with the platform's file manager, not the file itself: the rotated generation (*.old) is often the one holding the bug, and a log file handed to its default handler opens in an editor, not beside the sibling the reporter also needs.
func (*Service) SSHAgentKeys ¶
SSHAgentKeys lists the identities loaded in the user's ssh agent, one line each ("me@example.com (ED25519 256)"), in the order the agent holds them.
It exists for one sentence in the UI. The setting that hands a confined session the ssh agent is read as "let it push with my GitHub key", and what it actually hands over is every identity in the agent, usable against any host — so the control shows the list instead of asking the user to remember it. A choice made without seeing this is a choice about a different thing.
Empty for everything that is not a list of keys: no agent in the environment, no ssh-add on the machine, an agent holding nothing, output this cannot read. The caller draws "nothing loaded", which is the truthful reading of all of them — the flag hands over whatever is there, and nothing is a real answer.
func (*Service) SandboxBackend ¶
SandboxBackend names what confines a session on this machine — "bubblewrap", "sandbox-exec" — or "" when nothing can (internal/sandbox). It answers here rather than beside the provider list because it is a fact about the machine, and the same answer for every provider on it.
The name rather than a yes: the two backends have different holes, and the Sandbox pane says which one is in play so a report about a confined session starts a round ahead. "" is what the pane draws its "cannot confine" state from, and what the new-session dialog reads as "do not offer the choice".
func (*Service) SetEnv ¶
SetEnv replaces the resolved environment after a re-read of the login shell (internal/providers.Service.RefreshPath): an $EDITOR exported by an rc file the user edited while lich was open is found from the same re-check that finds a newly installed agent, rather than from the next launch.
func (*Service) SetNativeWindow ¶
func (s *Service) SetNativeWindow(hooks NativeHooks)
SetNativeWindow wires the native window. Called at startup.
func (*Service) ShowWindow ¶
func (s *Service) ShowWindow(ShowWindowOptions) error
ShowWindow starts the native window on the running backend, or brings it forward when it is open. It returns as soon as the window is asked for, not when it is on screen; a window that cannot open is reported to NativeHooks.Failed, not here.
func (*Service) TakeUncleanExit ¶
TakeUncleanExit reports whether the run before this one ended without quitting cleanly, and clears the flag. It is consumed rather than read because the notice belongs to the launch that followed the bad exit, not to every window that opens on it: each window runs its gate again, the process does not start again with it.
type ShowWindowOptions ¶
type ShowWindowOptions struct{}
ShowWindowOptions is one ShowWindow call. It carries nothing yet; it is an object so a newer launch can still reach an older running lich the day it does (the CLI's options-object rule).