web

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2026 License: MIT Imports: 32 Imported by: 0

Documentation

Overview

Package web serves the review UI in a web browser. It is the browser counterpart of the tui package: the same documents and comment model, with the review result handed back to the caller when the reviewer submits or quits in the page.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenBrowser

func OpenBrowser(url string) error

OpenBrowser opens url in the user's default browser without waiting for it.

Types

type FileResult

type FileResult struct {
	File   markdown.File
	Status markdown.Status
	Review *markdown.ReviewResult // nil when the file was quit (skipped)
}

FileResult is the outcome of reviewing one file.

type Options

type Options struct {
	Port  int    // TCP port on 127.0.0.1; 0 picks a free port
	Theme string // initial color theme: "dark" or "light"
	// Open opens the URL in a browser. nil only prints it.
	Open func(url string) error
	Log  io.Writer // receives the URL and warnings
}

Options configures Serve.

type Result

type Result struct {
	Files []FileResult
}

Result is the outcome of a browser session: one entry per file that was loaded, in review order. It is empty when the picker was cancelled or the session was interrupted.

func Serve

func Serve(ctx context.Context, review Review, opts Options) (Result, error)

Serve starts the review server on the loopback interface and blocks until every file was finished or skipped in the browser (or the picker was cancelled), or ctx is cancelled, which abandons the whole session.

type Review

type Review struct {
	// Pick, when set, is offered in a file picker first (all selected, like
	// the TUI picker); the chosen files are then reviewed in this order.
	Pick []string
	// Paths are reviewed in order when Pick is empty.
	Paths []string
	// Load reads a file when its turn comes. ok=false skips it; Load reports
	// the reason itself.
	Load func(path string) (f markdown.File, ok bool)
}

Review describes what a browser session reviews. Like the TUI, files are reviewed one at a time, and each is loaded only when its turn comes so that edits made while reviewing an earlier file are picked up.

Jump to

Keyboard shortcuts

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