Documentation
¶
Overview ¶
Package newtab serves the page a session's browser opens on: what lich already knows of the session (the project's running services, the session's artifacts, the pages its browser visited last) and an address field. It is drawn with the window's theme and words, which the window hands over (api.BrowserNewTabPage), since only it knows the resolved theme and the interface language.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Fallback = api.BrowserNewTabPageOptions{ Lang: "en", Colors: api.BrowserNewTabColors{ Background: "#101012", Card: "#18181b", Foreground: "#fafafa", Muted: "#a1a1aa", Border: "#ffffff1a", Accent: "#27272a", Pass: "#10b981", }, Text: api.BrowserNewTabText{ Title: "New tab", Address: "Enter an address, or pick below", AddressError: "That address cannot be opened.", Running: "Running in this project", Worktree: "Worktree port", Artifacts: "Artifacts of this session", Recent: "Recent", }, }
Fallback is the look before the window hands over its own: the dark theme.
Functions ¶
This section is empty.
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service renders the page and remembers the pages a browser visited.
func New ¶
New returns a Service reading src. Until the window hands over its look the page is drawn with Fallback.
func (*Service) Forget ¶
Forget drops the pages kept under a files key, its session being gone for good.
func (*Service) Handler ¶
Handler serves api.NewTabPrefix + session, and its /go, which loads what the address field holds in the session's browser.
type Source ¶
type Source struct {
// Project is the id of the project session belongs to; ok is false for a
// session lich does not know.
Project func(session string) (projectID string, ok bool)
// Services is every project's services (internal/services).
Services func() ([]api.Service, error)
// WorktreePort is the dev-server port the session's checkout reserves, 0
// for none, and Listening whether something answers on it.
WorktreePort func(session string) int
Listening func(port int) bool
// Artifacts is the session's artifacts, newest first, each with the URL
// its browser loads it by.
Artifacts func(session string) []Artifact
// Resolve is the URL the session's browser loads for raw (internal/browser),
// which refuses what the agent's tools refuse.
Resolve func(session, raw string) (string, error)
// Key is the session's files key, which its recent pages are kept under;
// Load and Save read and write them, Drop forgets them.
Key func(session string) string
Load func(key string) string
Save func(key, value string) error
Drop func(key string) error
// Skip reports a URL that is no page to remember: the new-tab page itself.
Skip func(raw string) bool
}
Source is what the page reads, wired at startup.