newtab

package
v0.94.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: AGPL-3.0 Imports: 16 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 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

View Source
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 Artifact

type Artifact struct {
	Name     string
	URL      string
	Modified int64
}

Artifact is one of the session's artifacts as the page lists it.

type Recent

type Recent struct {
	URL   string `json:"url"`
	Title string `json:"title"`
}

Recent is a page the session's browser visited.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service renders the page and remembers the pages a browser visited.

func New

func New(src Source) *Service

New returns a Service reading src. Until the window hands over its look the page is drawn with Fallback.

func (*Service) Forget

func (s *Service) Forget(key string)

Forget drops the pages kept under a files key, its session being gone for good.

func (*Service) Handler

func (s *Service) Handler() http.Handler

Handler serves api.NewTabPrefix + session, and its /go, which loads what the address field holds in the session's browser.

func (*Service) Look

func (s *Service) Look(look api.BrowserNewTabPageOptions) error

Look takes the window's theme and words. A color or language that is not one is refused, as they are written into the page's CSS and markup.

func (*Service) Visit

func (s *Service) Visit(owner, rawURL, title string)

Visit remembers that owner's browser is on rawURL, newest first, once each, and keeps the title the page gets after its URL. Only web pages count.

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.

Jump to

Keyboard shortcuts

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