render

package
v1.59.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package render contains HTML template models and parsing.

Index

Constants

View Source
const (
	CreateClone    = "clone"
	CreateWorktree = "worktree:"
)

The values the create form's one select carries. An empty value is the plain project, CreateClone a directory a repository is cloned into, and a worktree carries the project it forks behind CreateWorktree, because the prefix is what keeps a project that is called "clone" apart from the kind of the same name.

View Source
const DocsLead = "" /* 382-byte string literal not displayed */

DocsLead is the note above the topics.

Variables

This section is empty.

Functions

func CoderLabel

func CoderLabel(id string) string

CoderLabel names a coder id for display. One implementation for the templates and the handlers, so a label never differs by surface. A brand casing the plain capitalization cannot produce is special cased.

func DeleteWorktreeNote added in v1.59.0

func DeleteWorktreeNote(p project.Project) string

DeleteWorktreeNote is the extra sentence the delete confirm carries for a project whose repository has linked worktrees. Worktrees that are projects of their own are deleted with the main and named; one lying elsewhere on the disk is left alone but its repository dies here, so it is named too. A worktree inside the project directory goes with the directory anyway and needs no word. Empty when none of that applies.

func DockerIconClass

func DockerIconClass(name string) string

DockerIconClass answers the class one icon name renders as. A name nobody knows and no name at all both end at the neutral command icon: an empty box in a menu reads as a broken page.

func DockerRunStatus

func DockerRunStatus(run docker.RunView) string

DockerRunStatus is the one line that says where a run stands: that it is going, the exit code it ended with, or what went wrong instead.

func HTMLTemplate

func HTMLTemplate(assetPath func(string) string, version, assetBuild string, plugins []*pluginhost.Serve) *template.Template

HTMLTemplate returns the parsed template set used by Gin's HTML renderer. plugins feeds the two plugin funcs: pluginElements binds every final element name to its plugin's starter module in the import map, which is how the lazy element loader finds plugin code; pluginSlot is the markup the plugins added for a named slot.

func HostBarClass

func HostBarClass(percent int) string

HostBarClass colors one bar by its own reading.

func HostBarHeight

func HostBarHeight(percent int) template.HTMLAttr

HostBarHeight is HostBarStyle for the standing mini bars of the float card.

func HostBarStyle

func HostBarStyle(percent int) template.HTMLAttr

HostBarStyle writes the width of a bar. It is built here rather than interpolated in the template so the value never lands in a CSS context the template escaper has to guess at.

func HostLevelClass

func HostLevelClass(level string) string

HostLevelClass colors the status icon by the worst of the readings.

func HostRingClass

func HostRingClass(percent int) string

HostRingClass colors a ring gauge. Unlike a bare number a ring is always visible, so the quiet state is an explicit green rather than no class.

func OriginIcon added in v1.59.0

func OriginIcon(origin string) string

OriginIcon names the tabler icon a project's origin is shown with. The forges the row can recognize get their own brand, everything else gets a globe: the origin is the one thing on the row that lives somewhere else, and that reads better than a third git glyph beside the branch and the worktree.

func WorktreeChoice added in v1.59.0

func WorktreeChoice(name string) string

WorktreeChoice is the select value that forks the given project.

func WorktreeSource added in v1.59.0

func WorktreeSource(choice string) string

WorktreeSource names the project a choice forks, empty for every choice that forks none.

Types

type AgentsFormData

type AgentsFormData struct {
	Page
	Base         string // canonical coder URL prefix, "/settings/coders/<id>"
	IsEdit       bool
	OriginalID   string
	ID           string
	Description  string
	Instructions string
	FormAction   string
	SubmitLabel  string
	Heading      string
}

AgentsFormData is the model for create/edit forms.

type AgentsListData

type AgentsListData struct {
	Page
	SettingsNav SettingsNav
	Base        string // canonical coder URL prefix, "/settings/coders/<id>"
	Agents      []coder.Agent
}

AgentsListData is the model for the agents list.

type AssistantAttachmentView

type AssistantAttachmentView struct {
	Name     string
	URL      string
	Media    string
	SizeText string
}

AssistantAttachmentView is one file a message carries, ready to embed.

type AssistantCard

type AssistantCard struct {
	ID         string
	Title      string
	Preview    string
	CoderLabel string
	URL        string
	Messages   int
	Unfinished bool
	Current    bool
	// Updated is a machine stamp (RFC3339), the dc-time element renders it in
	// the browser locale.
	Updated string
}

AssistantCard is one row on the assistant history. The title names the conversation, the same way `dev-cockpit assistant conversation-list` prints it, and the preview of the last answer sits under it.

type AssistantCoderOption

type AssistantCoderOption struct {
	ID    string
	Label string
}

AssistantCoderOption is one selectable coder on the new conversation control.

type AssistantData

type AssistantData struct {
	Page
	ID string
	// Panel says the surface renders inside the overlay: it gets its own
	// compact head row and scrolls internally instead of with the page.
	Panel bool
	// View is which of the overlay's own sections renders: "chat", "jobs",
	// "memory" or "history". The overlay is its own world, nothing in it
	// opens a modal or navigates the page behind it.
	View string
	// MemoryData and HistoryData feed the overlay's memory and history views,
	// set only when that view renders.
	MemoryData  *AssistantMemoryData
	HistoryData *AssistantHistoryData
	CoderID     string
	CoderLabel  string
	// Coders is only used when more than one is installed: the new
	// conversation control then asks which one answers.
	Coders   []AssistantCoderOption
	Messages []AssistantMessageView
	Running  bool
	// Blocked carries the reason the composer is off. Empty means the
	// assistant accepts messages.
	Blocked string
	// NewCoderID is the coder a new conversation started from a blocked one
	// runs on. It is empty when this conversation's coder is gone, then the
	// new one picks whichever coder is installed.
	NewCoderID string
	// CurrentURL points at the conversation that still takes messages, set
	// only while looking at a different one. An earlier conversation then
	// sends the reader on instead of offering to start another one.
	CurrentURL string
	// Jobs are the coders the assistant steers. Empty when nothing is
	// steered, which is the normal state.
	Jobs []AssistantJobView
	// JobsOpen is how many of them still wake the assistant. It is what the
	// button that opens the list shows without being opened: the icon carries
	// it the way every other status in the cockpit does, through its colour.
	JobsOpen int
	// JobsOlder is how many closed jobs the list holds back, so nothing is
	// dropped silently. The open jobs always all render.
	JobsOlder int
	// JobsURL is the jobs path: it serves the list on its own, so the page can
	// pull it when a check changed something, and it takes the two actions on a
	// job. One path, so the forms post where the fragment came from.
	JobsURL string
	// EarlierCount is how many messages are held back above the rendered
	// window, and AllURL renders the whole transcript, anchored at the oldest
	// message that was already on the page.
	EarlierCount int
	AllURL       string
	StreamURL    string
	PostURL      string
	MessageURL   string
	UploadURL    string
	// SttURL takes a recorded clip and answers its transcript. Empty while
	// speech to text is off, which is what takes the talk button away.
	SttURL string
	// TTS says the spoken answers are on: the messages carry their audio
	// routes and the composer offers the voice mode toggle.
	TTS            bool
	MaxPromptBytes int
	MaxUploadBytes int64
	// MemoryCount is what the assistant knows about the user, shown as a
	// badge so the memory never grows unnoticed.
	MemoryCount  int
	HistoryCount int
	// Draft is the unsent message this conversation holds, rendered straight
	// into the message box, and DraftFiles are the files that were uploaded
	// for it, as the JSON the composer rebuilds its chips from. Both come from
	// the conversation, so the draft is there on the next device too.
	Draft      string
	DraftFiles string
	// DraftURL serves the stored draft on its own, which is how a second device
	// catches up after a save somewhere else and after a reconnect.
	DraftURL string
	// ContextPercent is how full the coder's context window stood at the end of
	// the last turn, drawn as the ring around the new conversation button. Zero
	// means there is nothing to show, either because no turn reported a reading
	// yet or because that model's window is unknown, and the ring then stays
	// empty: a wrong percentage is worse than none. It is rendered here as well
	// as pushed with the end frame, so opening the panel shows the number
	// without waiting for a turn.
	ContextPercent int
}

AssistantData is the model for the assistant conversation surface, rendered as the full page and as the interior of the docked panel.

type AssistantHistoryData

type AssistantHistoryData struct {
	Page
	Conversations []AssistantCard
	Available     bool
	// CurrentURL is the conversation that still takes messages. While there is
	// one, the page sends the reader there instead of offering to start
	// another one next to it.
	CurrentURL string
}

AssistantHistoryData is the model for the earlier conversations.

type AssistantJobView

type AssistantJobView struct {
	Terminal string
	Name     string
	Project  string
	Task     string
	DoneWhen string
	State    string
	Open     bool
	// Checking says a check is running on this job right now, so the page can
	// show it instead of leaving the user to read a counter.
	Checking bool
	Note     string
	Wakes    int
	MaxWakes int
	// Expires is a machine stamp (RFC3339); the dc-time element renders it in
	// the browser locale like the conversation timestamps.
	Expires string
	// URL opens the coder the job steers.
	URL string
}

AssistantJobView is one steered job on the conversation page: what the assistant keeps an eye on, what it costs, and where it stands.

type AssistantMemoryData

type AssistantMemoryData struct {
	Page
	Entries []AssistantMemoryEntry
}

AssistantMemoryData is the model for the memory page. Editing happens in place, each row carries its own prefilled form.

type AssistantMemoryEntry

type AssistantMemoryEntry struct {
	Slug  string
	Title string
	Body  string
	// Updated is a machine stamp (RFC3339), the dc-time element renders it in
	// the browser locale.
	Updated string
}

AssistantMemoryEntry is one thing the assistant knows about the user.

type AssistantMessageData

type AssistantMessageData struct {
	Message AssistantMessageView
}

AssistantMessageData is the model for the single-message fragment the browser pulls when a streamed answer finished.

type AssistantMessageView

type AssistantMessageView struct {
	ID    string
	RunID string
	User  bool
	// Wake is set on a message a check wrote: which coder it was about and what
	// it concluded. It never renders as something the user said.
	Wake        *AssistantWakeView
	Author      string
	Text        string
	HTML        template.HTML
	Attachments []AssistantAttachmentView
	State       string
	Error       string
	Streaming   bool
	Failed      bool
	CanRetry    bool
	// Queued marks a message still waiting for the running turn to end, and
	// CanDiscard says the page may still take it back. A waiting entry in a
	// read-only conversation renders as never sent instead.
	Queued     bool
	CanDiscard bool
	Time       string
	// AudioURL serves this answer spoken, set only while text to speech is on
	// and the answer is complete; the speaker button renders from it.
	AudioURL string
}

AssistantMessageView is one rendered message. User text stays plain, assistant answers are rendered from Markdown server-side with raw HTML disabled.

type AssistantWakeView

type AssistantWakeView struct {
	Terminal string
	Name     string
	Verdict  string
	Done     bool
	Blocked  bool
	// Expired marks the one message a job writes when it ran out of checks or
	// out of time, so the reader knows nobody is looking any more.
	Expired bool
	URL     string
}

AssistantWakeView describes the check a message came from.

type BackupGroup

type BackupGroup struct {
	Label    string
	Sections []BackupSection
}

BackupGroup groups the export sections on the backup page.

type BackupImport

type BackupImport struct {
	Token    string
	Created  string
	Host     string
	Version  string
	Sections []BackupImportSection
}

BackupImport describes an uploaded archive waiting for the import selection, the adaptive part of the import flow.

type BackupImportSection

type BackupImportSection struct {
	ID             string
	Label          string
	Description    string
	Files          int
	Size           string
	Supported      bool
	Requires       string
	RequiresLabels string
}

BackupImportSection is one section found in an uploaded backup archive. Requires and RequiresLabels drive the same dependency enforcement and hint as the export form, limited to the sections the archive contains.

type BackupListData

type BackupListData struct {
	Backups   []BackupRow
	CSRFToken string
}

BackupListData feeds the standalone backup list fragment, pulled live by dc-backup-list. It carries no flash, so a live refresh never eats the redirect flash of a create or delete.

type BackupMergeData

type BackupMergeData struct {
	Page
	ID       string
	FilePath string
	Text     bool
	Content  string
	Previous string
	Restart  bool
}

BackupMergeData feeds the merge page for one overwritten file. Restart marks cockpit files, saving a merge or restoring restarts the server.

type BackupReviewRow

type BackupReviewRow struct {
	ID        string
	Path      string
	CSRFToken string
	Restart   bool
}

BackupReviewRow is one overwritten file awaiting a keep, restore, or merge decision. It carries the CSRF token so the shared row template can render its action forms without extra template helpers. Restart marks cockpit files, restoring or merging one restarts the server.

type BackupRow

type BackupRow struct {
	ID       string
	Name     string
	Created  string
	Size     string
	Sections int
	Running  bool
	Done     bool
	Error    string
}

BackupRow is one stored backup in the export tab list.

type BackupSection

type BackupSection struct {
	ID             string
	Label          string
	Description    string
	Detail         string
	Available      bool
	Requires       string
	RequiresLabels string
}

BackupSection is one selectable export section on the backup form. Requires carries the space joined section ids this one depends on, for the dc-backup-sections dependency enforcement; RequiresLabels the same dependencies as human labels, rendered under the checkbox so the relationship is visible before anything toggles. Detail carries an extra enumeration line under the checkbox, the dotfiles section lists the files it discovered there.

type BranchChoice added in v1.59.0

type BranchChoice struct {
	Ref    string
	Name   string
	Remote bool
	Taken  string
	Head   bool
}

BranchChoice is one branch a new worktree can stand on. Ref is what the form submits and the server resolves again, the branch's own name or, for one that so far only exists on a remote, the remote ref; Name is the local branch the working copy ends up on in both cases. Taken names the project or the directory whose working copy already holds this branch, which is the one thing that makes a branch unavailable, and is empty while it is free.

type CoderAttachData

type CoderAttachData struct {
	Page
	Running         coder.Running
	Identifier      string
	Coder           string // owning coder id
	ProjectName     string // owning project, empty when CWD is outside the projects root
	Files           []filesystem.File
	MaxUploadSizeMB string
	Error           string
	Message         string
	StreamURL       string
	ResizeURL       string
	InputURL        string
}

CoderAttachData is the model for the attach page.

type CoderChoice

type CoderChoice struct {
	ID           string
	Agents       []coder.AgentOption
	DefaultAgent string
}

CoderChoice is one selectable coder in the new-coder form together with its agent choices.

type CoderFilesData

type CoderFilesData struct {
	Page
	Identifier      string
	Files           []filesystem.File
	MaxUploadSizeMB string
	Error           string
	Message         string
}

CoderFilesData is the model for the coder files HTML fragment.

type CoderNewData

type CoderNewData struct {
	Page
	Projects          []ProjectOption
	DefaultPath       string
	Coders            []CoderChoice
	SelectedCoder     string
	AutomaticApproval bool
	Return            string // where Cancel goes back to (the page you came from)
	// Panel marks a create opened from the editor terminal panel's + menu, the
	// one caller whose create goes back to the editor instead of the coder's
	// page. It rides the query into the form and back out through the POST,
	// like Return does; Return alone cannot carry this, every quick nav link
	// on an editor page sends the same editor return for its Cancel.
	Panel bool
	// SplitGroup and SplitColumn carry a split view the new coder joins right
	// after it starts: the group id, and a member of the column it stacks into
	// (empty for a column of its own at the right edge). They ride the query
	// into the form and back out through the POST, like Return does.
	SplitGroup  string
	SplitColumn string
}

CoderNewData is the model for the new-coder form. Project is chosen from a select that stands in the order the projects page is in; DefaultPath holds the project the form was opened from and is empty without one, then the first project of that order is the preselection.

type DockerActionRow

type DockerActionRow struct {
	docker.Action
	Argv  []string
	Error string
}

DockerActionRow is one configured compose command on the settings form, together with the argv it splits into, so what a line really becomes is visible under the field it is typed in. Error carries what makes the line unusable, an unclosed quote for example.

func DockerActionRows

func DockerActionRows(actions []docker.Action) []DockerActionRow

DockerActionRows pairs every configured command with the argv it splits into. The split is the same function the run uses, so the preview cannot drift away from what actually starts.

func (DockerActionRow) IconClass

func (r DockerActionRow) IconClass() string

IconClass is the picture the row's icon name stands for.

func (DockerActionRow) TimeoutLabel

func (r DockerActionRow) TimeoutLabel() string

TimeoutLabel is how long the entry may run, the value as it is stored when it can be read at all.

type DockerButton

type DockerButton struct {
	ID      string
	Icon    string
	Label   string
	Command string
	Confirm bool
}

DockerButton is one configured command as a surface offers it: the icon resolved to a class, everything else as it is stored.

func DockerButtons

func DockerButtons(actions []docker.Action) []DockerButton

DockerButtons resolves the configured commands for the surfaces that render them, the projects page and the editor's docker view.

type DockerContainer

type DockerContainer struct {
	docker.Container
	Links []docker.Link
}

DockerContainer is one container as the row renders it: what the daemon says, plus the addresses it answers on. Those are resolved here and not in the template, because which label carries an address is configuration and applying it is the matcher's job, not a template's.

type DockerIcon

type DockerIcon struct {
	Name  string
	Class string
}

DockerIcon is one entry of the icon vocabulary as the settings form offers it, the name that is stored next to the picture it stands for.

func DockerIcons

func DockerIcons() []DockerIcon

DockerIcons is the vocabulary in the order it is offered.

type DockerLinkRuleRow

type DockerLinkRuleRow struct {
	docker.LinkRule
	Error string
	// Sample are the first few addresses the rule currently yields, Found how
	// many there are in total.
	Sample []string
	Found  int
}

DockerLinkRuleRow is one configured link rule on the settings form, together with what makes it unusable and what it finds in the containers that run right now. A regular expression nobody can try is a field nobody can fill in, so the row answers both questions where the pattern is typed.

func DockerLinkRuleRows

func DockerLinkRuleRows(rules []docker.LinkRule, containers []docker.Container) []DockerLinkRuleRow

DockerLinkRuleRows pairs every rule with its verdict and its preview. The preview runs through the same matcher the pages build their links with, on the same cached container list they read, so what a row promises cannot drift away from what the menus offer.

func (DockerLinkRuleRow) More

func (r DockerLinkRuleRow) More() int

More is how many findings the row does not show.

type DockerRunData

type DockerRunData struct {
	Page
	Project string
	// Stack is the project relative directory the command ran in, empty for
	// the project root.
	Stack  string
	Run    docker.RunView
	Status string
	Output string
	// OutputURL is what the page repaints from, StopURL what calls the run
	// off while it is still going.
	OutputURL string
	StopURL   string
}

DockerRunData feeds the output page of one compose run. The page is not watching a process: it reads the file the detached run writes into, which is why it answers the same way while the run goes and long after it ended.

func (DockerRunData) Failed

func (d DockerRunData) Failed() bool

Failed reports whether the run has something to complain about, the one thing that colors the status line.

type DockerStack

type DockerStack struct {
	docker.Stack
	Busy      bool
	RunID     string
	RunAction string
	RunGoing  bool
}

DockerStack is one compose control point rendered as a chip. Busy marks a compose run in flight, the menu then disables the actions. Run names the newest run of that stack, the one whose output the menu leads to, whether it is still going or over.

type DocsCap

type DocsCap struct {
	Text string
	Icon string
}

DocsCap is one rendered key cap. Caps named after a Tabler icon render as that glyph, so a pair like the arrow keys shares one font.

type DocsData

type DocsData struct {
	Page
	Lead   string
	Topics []DocsTopic
}

DocsData feeds the documentation page: one intro line plus the topics, each rendered as a collapsible panel of title/description rows.

type DocsItem

type DocsItem struct {
	Title string
	// Tag marks the context a control belongs to (Touch, Desktop, Coder).
	Tag      string
	TagClass string
	// Keys holds the keyboard alternatives, each a sequence of key caps.
	Keys []DocsKeys
	Desc template.HTML
}

DocsItem is one documented control, gesture, or shortcut.

func (DocsItem) HasKeys

func (i DocsItem) HasKeys() bool

HasKeys reports whether the item carries a keyboard shortcut.

type DocsKeys

type DocsKeys struct {
	Caps []string
}

DocsKeys is one key combination, rendered as kbd caps joined by a plus.

func (DocsKeys) Parts

func (k DocsKeys) Parts() []DocsCap

Parts returns the caps of the combination in render order.

type DocsTopic

type DocsTopic struct {
	Key   string
	Title string
	Icon  string
	Lead  string
	// Intro is an optional paragraph rendered above the items.
	Intro template.HTML
	// LinkURL and LinkText render an optional action next to the title.
	LinkURL  string
	LinkText string
	Items    []DocsItem
}

DocsTopic groups the documented behavior of one area of the app.

func DocsTopics

func DocsTopics() []DocsTopic

DocsTopics returns the documentation content.

func (DocsTopic) Count

func (t DocsTopic) Count() int

Count returns the number of documented entries in the topic.

type EditorData

type EditorData struct {
	Page
	Project    project.Project
	MaxEditKiB int64
	// MaxEditSize is the same limit as the file tree writes its sizes, so the
	// sentence in the empty editor reads like the rows next to it rather than
	// as a five digit KiB number.
	MaxEditSize string
	// Return is the safe in-app URL the header back button leads to, passed by
	// the linking page as ?return like the create forms' Cancel.
	Return string
	// Projects feeds the project switcher in the file tree header, one entry
	// per selectable project linking to its editor page.
	Projects []EditorProject
	// The diff's limits ride along as page data: the diff itself is computed in
	// the browser, so this is where the values have to be. How it looks, the
	// view and the folding, is not here, that is per device in the editor's own
	// settings.
	DiffMaxLines int
	DiffMaxKiB   int
	// LSPExts is the code navigation surface as comma joined `ext:Label`
	// pairs of the enabled language server profiles, so the client never
	// mirrors the registry and a disabled profile leaves no surface.
	LSPExts string
	// Terminal is the session id a panel-marked coder create handed back via
	// ?terminal=, rendered into the page because the client must not read it
	// from the URL: a boosted navigation swaps the body before it pushes the
	// URL, so the editor's init still sees the previous address. The terminal
	// panel activates that session's tab.
	Terminal string
}

EditorData is the model for the per-project code editor page.

type EditorInactiveCoder

type EditorInactiveCoder struct {
	ID      string
	Name    string
	Coder   string
	URL     string
	HasNews bool
}

EditorInactiveCoder is one resumable coder in the panel's + menu.

type EditorLSPProfile

type EditorLSPProfile struct {
	ID       string
	Label    string
	Command  string
	Server   string
	Selected string
	DockerOK bool
}

EditorLSPProfile is one language on the LSP tab: its select offers Automatic, Server over Docker, and Off, with Selected carrying the stored pick, "auto" while nothing explicit is stored. Command is the full line the description names, DockerOK whether the local daemon answers right now.

type EditorProject

type EditorProject struct {
	Name         string
	URL          string
	Current      bool
	Active       bool
	LastUsedUnix int64
}

EditorProject is one project switcher entry in the editor's tree header. The entries render with the data-project-* attributes @dc/project-sort reads, so the client orders the menu like every other project listing.

type EditorProjectsData

type EditorProjectsData struct {
	Projects []EditorProject
}

EditorProjectsData feeds the switcher fragment, the very rows the editor page renders inside its dropdown. The client pulls it when the project set changes instead of building the markup a second time in the browser.

type EditorTerminal

type EditorTerminal struct {
	ID            string
	Name          string
	Kind          string // "coder" or "shell"
	Coder         string
	URL           string
	StreamURL     string
	ResizeURL     string
	InputURL      string
	ScrollHistory bool
	HasNews       bool
	Working       bool
	Steered       bool
	SteerPrefill  string
	// FilesData feeds a coder's files modal, the same one the attach pages
	// carry; nil for shells and for coders whose files cannot be listed.
	FilesData *CoderFilesData
}

EditorTerminal is one session in the editor's terminal panel: the tab entry and the pane the client mounts a terminal island into.

type EditorTerminalsData

type EditorTerminalsData struct {
	Sessions  []EditorTerminal
	Inactive  []EditorInactiveCoder
	CSRFToken string
}

EditorTerminalsData feeds the editor's terminal panel fragment: the live coders and shells of one project in tab strip order, plus the project's inactive coders for the panel's + menu.

type ErrorPage

type ErrorPage struct {
	Title   string // document <title>, consumed by html_head.gohtml
	Status  int
	Heading string
	Message string

	// CSRFToken and Jingle stay empty. html_head.gohtml evaluates both on
	// every page, a model without the fields fails the whole error render.
	// TestErrorPageRenders guards this contract.
	CSRFToken string
	Jingle    string
}

ErrorPage is the model for the standalone HTTP error page. It deliberately avoids the shared Page model so it can be rendered from anywhere (including a panic recovery) without touching the session, CSRF token, or flash store.

type Flash

type Flash struct {
	Message string
	Level   string // "success" | "error"
}

Flash carries a one-shot notice from a previous request.

type InstructionsData

type InstructionsData struct {
	Page
	SettingsNav  SettingsNav
	Base         string // canonical coder URL prefix, "/settings/coders/<id>"
	Instructions string
}

InstructionsData is the model for the global instructions editor.

type JingleOption

type JingleOption struct {
	ID    string
	Label string
}

JingleOption is one selectable notification jingle. The IDs must match the tune keys in the client's @dc/jingle module.

type LoginData

type LoginData struct {
	Page
	Next string
}

LoginData is the model for the login form.

type Page

type Page struct {
	Title     string
	ActiveTab string
	Flash     Flash
	// FlashProject, when set, anchors the flash to a project card on the projects
	// page (rendered there instead of at the top of the page).
	FlashProject string
	CSRFToken    string
	User         string
	// MultiCoder is true when more than one coder is active, switching on the
	// coder badges and selectors across the UI.
	MultiCoder bool
	QuickNav   QuickNav
	// Jingle is the cross-device notification jingle selection, rendered into
	// a meta tag so the client picks the right tune.
	Jingle string
	// HasTabStrip marks the attach pages, which render the terminal tab strip
	// inline. Every other page gets a hidden switcher-only terminal-tabs
	// instance from the layout, so the double Ctrl/Meta switcher works app wide.
	HasTabStrip bool
	// AssistantID is the conversation the assistant entry points open, and
	// AssistantNews whether it has unread news. The three entry points carry
	// the id as a notification target, so dc-notifications marks them live the
	// way it marks a terminal row.
	AssistantID   string
	AssistantNews bool
	// BackupReviewCount is the number of open backup overwrite reviews,
	// rendered as a badge on the Settings nav so the pending resolution is
	// visible app wide. Fresh on every navigation (whole body boost).
	BackupReviewCount int
	// Steered marks the coders an open job holds, keyed by terminal id: the
	// assistant owns those and may write into them, and every surface shows
	// it as the purple steered mark. SteerPrefill carries the stored
	// criterion of a closed job, which is what the steer dialog offers when
	// such a terminal is steered again. Surfaces read both by id
	// (`{{index $.Steered .ID}}`) instead of carrying the values through
	// their own view structs; the fragments refresh on the terminals event,
	// so the marks stay current without client logic.
	Steered      map[string]bool
	SteerPrefill map[string]string
	// Working marks the sessions somebody is working in right now, keyed by
	// terminal id, read the same way (`{{index $.Working .ID}}`). It is the
	// state at render time; the client keeps it live from the activity
	// event, toggling the same class on the same icons.
	Working map[string]bool
	// Host is the machine's load, memory and disk at render time, so the status
	// in the header is right before the first event arrives. It refreshes over
	// the event stream from there.
	Host hostinfo.Stats
}

Page carries request-scoped metadata shared by all templates.

type ProjectDelete

type ProjectDelete struct {
	Running bool
	Failed  string
}

ProjectDelete is what a row says about its own deletion: one that brings compose stacks down runs longer than its request, and a failure has nobody left to flash it, so both live on the row.

type ProjectDocker

type ProjectDocker struct {
	Stacks     []DockerStack
	Containers []DockerContainer
}

ProjectDocker is one project's docker presence: the compose stacks it can drive and the containers that exist. Either list may be empty, a project with only a compose file still gets its compose button on the row.

func (ProjectDocker) AnyRunning

func (d ProjectDocker) AnyRunning() bool

AnyRunning reports whether one of the project's containers runs, the state the row button's icon colors on.

func (ProjectDocker) Working

func (d ProjectDocker) Working() bool

Working reports whether a compose command of this project is in flight, which is what the row's docker icon rides the wave for. Both halves count: a run this process started holds the stack busy, and a run adopted after a restart is going without anybody holding anything.

type ProjectNav

type ProjectNav struct {
	Name           string
	Path           string
	EditorURL      string
	NewCoderURL    string
	NewShellURL    string
	Terminals      []ProjectNavItem
	InactiveCoders []ProjectNavItem
	// Active mirrors the projects page: a project counts as active when it has a
	// running session or shell. LastUsedUnix is its last-opened timestamp. Both
	// feed the project browser's client-side sort (same modes as the list page).
	Active       bool
	LastUsedUnix int64
	HasNews      bool
}

ProjectNav is the per-project quick-access model shared by the subpages (editor, session, shell). It lists the project's editor plus its live terminals and inactive sessions, so a subpage can offer one-click navigation to every sibling resource of the same project. Terminals holds the running coders and shells merged in tab strip order, the same order the projects page shows its chips.

type ProjectNavItem

type ProjectNavItem struct {
	ID      string
	Name    string
	URL     string
	Kind    string // "coder" or "shell", empty on inactive entries
	Coder   string // owning coder id, shown when several coders run
	HasNews bool
}

ProjectNavItem is one navigable resource. URL points at the attach page for active sessions and shells, and at the resume action for inactive sessions.

type ProjectNewData added in v1.59.0

type ProjectNewData struct {
	Page
	Sources []ProjectOption
	// Create is the choice the select stands on, one of the values above.
	Create       string
	Source       string
	SourceBranch string
	Branches     []BranchChoice
	// Fill carries a refused create's own values back into the form.
	Fill ProjectNewFill
}

ProjectNewData is the model for the create form. Source empty is the plain create the page has always been; with a source the form makes a linked worktree of that project, and everything below Source describes that one repository. Sources lists the projects that can be forked, as the same options every other create form's project select carries, so the browser puts them into the order the projects page stands in.

func (ProjectNewData) AnyTaken added in v1.59.0

func (d ProjectNewData) AnyTaken() bool

AnyTaken reports whether one of the offered branches stands in a working copy already. The form says why those cannot be picked, and only says it when there is such a branch to explain.

func (ProjectNewData) DefaultBranch added in v1.59.0

func (d ProjectNewData) DefaultBranch() string

DefaultBranch names the branch the form opens on: the first free one, never a taken one, because a browser preselects the first option and a taken branch is exactly the choice git would refuse.

func (ProjectNewData) DefaultMode added in v1.59.0

func (d ProjectNewData) DefaultMode() string

DefaultMode is which half of the branch choice the form opens on. A repository whose branches all stand in a working copy already, the ordinary state of a project with one branch, has nothing to check out, and the form opens on the new branch instead of on a list where everything is refused.

func (ProjectNewData) DefaultStart added in v1.59.0

func (d ProjectNewData) DefaultStart() string

DefaultStart is where a new branch begins by default: the branch the source project stands on, which is the state somebody looking at that project has in mind.

func (ProjectNewData) Locals added in v1.59.0

func (d ProjectNewData) Locals() []BranchChoice

Locals are the repository's own branches, Remotes the ones that so far only exist on a remote. The form keeps them apart because they mean two different things when picked, and a template cannot split a list.

func (ProjectNewData) Remotes added in v1.59.0

func (d ProjectNewData) Remotes() []BranchChoice

type ProjectNewFill added in v1.59.0

type ProjectNewFill struct {
	Name      string
	CloneURL  string
	Mode      string
	Branch    string
	NewBranch string
	Start     string
}

ProjectNewFill is what the person had already typed when a create was refused. The form comes back carrying it, because a refusal on the last field must not cost somebody the whole form. Every value is what was submitted, and the defaults below take it only where it still makes sense: a branch that is gone or taken since is not preselected.

type ProjectOption added in v1.55.0

type ProjectOption struct {
	Name         string
	Path         string
	Active       bool
	LastUsedUnix int64
}

ProjectOption is one project in the project select of a create form. The select is server rendered alphabetically and put into the user's order in the browser, so an option carries everything @dc/project-sort compares: the name, whether the project runs something, and when it was last opened.

func ProjectOptions added in v1.55.0

func ProjectOptions(nav []ProjectNav) []ProjectOption

ProjectOptions turns the quick nav's project browser into that select. Both list every project with the same marks, and the quick nav is built for every page render anyway, so a create form takes its projects from there instead of scanning the coders and shells a second time.

type ProjectsListData

type ProjectsListData struct {
	Page
	Projects []project.Project
	// Docker holds each project's docker presence, keyed by project name,
	// joined through the compose working directory. Nil while no daemon
	// answers, the chip row then simply has no docker chips.
	Docker map[string]ProjectDocker
	// DockerActions is the configured compose commands, the same list for
	// every project because it describes the install and not one stack, with
	// their icons already resolved. Empty is a real answer: the menu then says
	// so and offers the defaults back.
	DockerActions []DockerButton
	// Deleting holds the rows whose project is being deleted or whose
	// deletion failed, keyed by project name. Nil while none is.
	Deleting map[string]ProjectDelete
}

ProjectsListData is the model for the projects list page.

type PushDevice

type PushDevice struct {
	ID       string
	Label    string
	Endpoint string
	Added    string
	Icon     string
	Stale    bool
}

PushDevice is one registered Web Push subscription shown on the settings page. Endpoint lets the dc-push-settings element recognize the row that belongs to the current device. Stale marks devices bound to older VAPID keys that can no longer receive pushes.

type PushWebhook

type PushWebhook struct {
	ID  string
	URL string
}

PushWebhook is one registered notification webhook.

type QuickNav

type QuickNav struct {
	// Active is the flat list of live coders and shells, ordered exactly like the
	// attach page tab strip (same @dc_tab_pos sort), so the quick nav and the tab
	// strip agree and a drag in either persists through POST /terminal-tabs/order.
	Active []TerminalTab
	// Strip is Active folded like the tab strip: split view groups become one
	// entry with their members, so the quick nav renders groups as blocks.
	Strip []StripTab
	// UnreadCount is the number of targets with unread news, rendered into
	// the toggle badge server-side so the badge survives a boosted body swap
	// (the app-wide event stream sends its snapshot on connect, not per
	// navigation); the client keeps it live from there.
	UnreadCount int
	CurrentID   string
	// Focus is the split member whose pane is active on the current page, so
	// the group block can mark that member row and the project context can
	// follow it even when the group's members span several projects.
	Focus string
	// CurrentProject is the project of the page you're on (terminal/editor), used
	// to preselect it in the new-session / new-shell forms. Empty when there is
	// no project context.
	CurrentProject string
	// CurrentProjectPath is that project's working directory, for the direct
	// "new shell in current project" form (which posts a path, not a name).
	CurrentProjectPath string
	// CurrentPath is the path of the page being rendered, passed to the create
	// forms as their Cancel return target.
	CurrentPath string
	// AllProjects feeds the two-level project browser: every project (alpha
	// sorted, like the projects page) with its editor, sessions and shells.
	AllProjects []ProjectNav
}

QuickNav feeds the quick nav floating button: the live sessions and shells you can jump to, plus the identifier of the one you are currently attached to.

func (QuickNav) HasInactiveCoders

func (q QuickNav) HasInactiveCoders() bool

HasInactiveCoders reports whether any project carries a resumable session. It switches on the resume section in the tab strip's plus menu.

type SettingsBackupData

type SettingsBackupData struct {
	Page
	SettingsNav     SettingsNav
	Tab             string
	Backups         []BackupRow
	Import          *BackupImport
	ImportError     string
	Review          []BackupReviewRow
	ReviewMoreCount int
}

SettingsBackupData feeds the backup settings page. Tab picks the visible pane, "export" or "import", resolved server side so every redirect flow lands on the right one.

type SettingsBackupNewData

type SettingsBackupNewData struct {
	Page
	Groups []BackupGroup
}

SettingsBackupNewData feeds the create backup form page.

type SettingsCoder

type SettingsCoder struct {
	ID  string
	URL string
}

SettingsCoder is one coder row in the settings sidebar. URL keeps the section the page is on, so switching the coder stays in the same section.

type SettingsDockerData

type SettingsDockerData struct {
	Page
	SettingsNav SettingsNav
	// DockerHost is the stored docker-host setting, empty means resolve
	// automatically. DockerStatus is the current connection line under the
	// field, DockerConnected colors it.
	DockerHost      string
	DockerStatus    string
	DockerConnected bool
	// Actions is the configured compose commands, each with the argv it
	// splits into, so the form shows what a line really becomes. Empty means
	// no buttons anywhere, and the page then offers the defaults back.
	Actions []DockerActionRow
	// Icons is the icon vocabulary an entry picks from, name and picture.
	Icons []DockerIcon
	// LinkRules is where a container's own address comes from, each rule with
	// what it finds in what runs right now. Empty means the menus offer the
	// published ports and nothing else.
	LinkRules []DockerLinkRuleRow
	// LinkSchemes is what a rule may pin its links to, the empty one being
	// the page's own scheme.
	LinkSchemes []string
}

SettingsDockerData feeds the docker settings page: which daemon the cockpit talks to, and the compose commands its menus offer.

type SettingsEditorData

type SettingsEditorData struct {
	Page
	SettingsNav    SettingsNav
	Section        string
	GitPollSeconds int
	DiffMaxLines   int
	DiffMaxKiB     int
	// Exclusions is the newline joined folder list the search tab edits.
	Exclusions string
	// LSPProfiles are the code navigation's language server profiles the
	// LSP tab offers a server select for.
	LSPProfiles []EditorLSPProfile
}

SettingsEditorData feeds the editor settings pages, one per tab. The values are the effective ones, so a form always shows what applies, not what happens to be stored. Section marks the open tab the way the coder pages mark theirs, so the page can grow more of them.

type SettingsGeneralData

type SettingsGeneralData struct {
	Page
	SettingsNav    SettingsNav
	RestoreEnabled bool
	HistoryEnabled bool
}

SettingsGeneralData feeds the general settings page.

type SettingsNav

type SettingsNav struct {
	Active   string
	Coders   []SettingsCoder
	Selected string // coder id the page is scoped to, empty off the coder pages
	Section  string // active coder section: "instructions" | "agents" | "skills"
	Reviews  int    // open backup overwrite reviews, badge on the backup entry
}

SettingsNav feeds the settings sidebar, the one navigation every settings page shares (`settings_nav.gohtml`). Active names the entry to mark ("general", "editor", "docker", "notifications", "assistant", "coder", "backup"). The coder pages are settings of one coder, so the sidebar picks the coder first and the page then shows that coder's sections: with several coders active the entry becomes one row per coder (Selected marks it), a single coder host keeps one plain Coder row pointing at Home.

func (SettingsNav) Multi

func (n SettingsNav) Multi() bool

Multi reports whether the coder entry splits into one row per coder. Single coder hosts keep the plain Coder row, like every other adaptive surface.

type SettingsNotificationsData

type SettingsNotificationsData struct {
	Page
	SettingsNav    SettingsNav
	Jingles        []JingleOption
	Selected       string
	VAPIDPublicKey string
	Devices        []PushDevice
	StaleDevices   bool
	Webhooks       []PushWebhook
	BaseURL        string
}

SettingsNotificationsData feeds the notifications settings page.

type SettingsVoiceData added in v1.55.0

type SettingsVoiceData struct {
	Page
	SettingsNav SettingsNav
	Section     string
	// Engines are the speech engines, each with its select. Selected carries
	// the stored pick, "auto" while nothing explicit is stored.
	Engines []VoiceEngine
	// DockerOK is whether the local daemon answers right now, named in the
	// description under each select.
	DockerOK bool
}

SettingsVoiceData feeds the assistant settings page's voice tab: one select per speech engine, the same three way choice the editor LSP page offers. Section marks the open tab the way the editor pages mark theirs, so the page can grow more of them.

type ShellAttachData

type ShellAttachData struct {
	Page
	Shell       shell.Shell
	ProjectName string // owning project, empty for home/ungrouped shells
	StreamURL   string
	ResizeURL   string
	InputURL    string
	RenameURL   string
}

ShellAttachData is the model for the shell attach page.

type ShellNewData

type ShellNewData struct {
	Page
	Projects    []ProjectOption
	DefaultPath string
	Return      string // where Cancel goes back to (the page you came from)
	// SplitGroup and SplitColumn carry a split view the new shell joins right
	// after it starts: the group id, and a member of the column it stacks into
	// (empty for a column of its own at the right edge). They ride the query
	// into the form and back out through the POST, like Return does.
	SplitGroup  string
	SplitColumn string
}

ShellNewData is the model for the new-shell form. Project is chosen from a select that stands in the order the projects page is in; DefaultPath holds the project the form was opened from and is empty without one, then the first project of that order is the preselection.

type SkillRow

type SkillRow struct {
	coder.Skill
	Managed bool
}

SkillRow is one skill of the list plus what the cockpit knows about it: a managed skill is the cockpit's own, written at start and kept current, so the page renders it locked instead of editable.

type SkillsFormData

type SkillsFormData struct {
	Page
	Base         string // canonical coder URL prefix, "/settings/coders/<id>"
	IsEdit       bool
	OriginalID   string
	ID           string
	Description  string
	Instructions string
	FormAction   string
	SubmitLabel  string
	Heading      string
}

SkillsFormData is the model for create/edit skill forms.

type SkillsListData

type SkillsListData struct {
	Page
	SettingsNav SettingsNav
	Base        string // canonical coder URL prefix, "/settings/coders/<id>"
	Skills      []SkillRow
}

SkillsListData is the model for the skills list.

type SplitAttachData

type SplitAttachData struct {
	Page
	GroupID     string
	GroupName   string
	ProjectName string // the members' shared project, empty when they differ
	// Focus is the member whose pane starts active (a member link redirects
	// here carrying ?focus); defaults to the first member. FocusExplicit
	// tells the client a ?focus was requested, so it must not restore the
	// remembered pane over it.
	Focus         string
	FocusExplicit bool
	Members       []SplitMember
	// Cols and Rows are the grid tracks the panes are placed on: one column
	// per rendered column, and enough equal rows that every column divides
	// them evenly (a column of two panes and one of three share six rows).
	Cols int
	Rows int
}

SplitAttachData is the model for the split view attach page.

type SplitMember

type SplitMember struct {
	ID            string
	Name          string
	Kind          string // "coder" or "shell"
	Coder         string // owning coder id, empty for shells
	Project       string
	URL           string // the member's own attach page
	StreamURL     string
	ResizeURL     string
	InputURL      string
	ScrollHistory bool // shells scroll the tmux history
	// Col is the rendered column, 1 based and left to right, and Row/RowSpan
	// place the pane inside that column's stack. The three are the pane's
	// place in the page's one grid: the panes stay flat siblings so a layout
	// change is a style change and never a DOM move, which is what keeps the
	// streams connected. Order is the visual reading of that grid, columns
	// left to right and top to bottom, rendered as the pane's `order` style:
	// the keyboard stepping walks it, and it can differ from the flat member
	// order the strip surfaces render. Computed by splitLayout, mirrored by
	// terminal-split.
	Col     int
	Row     int
	RowSpan int
	Order   int
	// FilesData feeds the member's own files modal; nil for shells. The
	// active pane's contextual footer opens it through a per-member modal id.
	FilesData *CoderFilesData
}

SplitMember is one terminal pane on the split view page.

type StripTab

type StripTab struct {
	TerminalTab
	Members []TerminalTab
}

StripTab is one rendered entry of the tab strip: a single session, or a split view group folding several sessions into one tab. Group entries fill the embedded TerminalTab with the group's values (ID is the group id, URL the split page, Kind "split", HasNews the aggregate) and carry the member sessions in group order.

func (StripTab) IsActive

func (t StripTab) IsActive(currentID string) bool

IsActive reports whether this strip entry represents the current page: the entry itself, or for a group one of its members, so a member's own page keeps its group tab highlighted.

func (StripTab) MemberCols

func (t StripTab) MemberCols() string

MemberCols returns the space separated column indices matching MemberIDs (0 for a member that renders as a column of its own). The strip is the split page's live mirror, so a column change made anywhere travels to an open split through this attribute, the way the member order does.

func (StripTab) MemberIDs

func (t StripTab) MemberIDs() string

MemberIDs returns the space separated session ids behind this strip entry, the members for a group, the session itself otherwise. The strip client posts these expanded ids when it persists the tab order.

func (StripTab) MemberKinds

func (t StripTab) MemberKinds() string

MemberKinds returns the space separated kinds matching MemberIDs, so the strip client knows each member's stop/delete endpoint.

type TerminalTab

type TerminalTab struct {
	ID        string
	Name      string
	URL       string
	Project   string // owning project name, shown under the tab name
	Coder     string // owning coder id, empty for shells
	Kind      string // "coder" or "shell"
	HasNews   bool
	Working   bool // somebody is working in there right now, see Page.Working
	StartedAt time.Time
	TabPos    int    // strip position from @dc_tab_pos, 0 when unset
	Group     string // split view group id from @dc_tab_group, empty when ungrouped
	GroupPos  int    // position inside the group from @dc_tab_gpos, 0 when unset
	GroupName string // group display name from @dc_tab_gname, may be empty
	GroupCol  int    // column inside the group from @dc_tab_gcol, 0 for a column of its own
}

TerminalTab is one entry in the attach page tab strip: a live coder or shell.

type VoiceEngine added in v1.55.0

type VoiceEngine struct {
	// Key is the form field and settings suffix ("stt", "tts").
	Key string
	// Label names what the engine does, Detail what runs behind it.
	Label  string
	Detail string
	// Server is the engine's short name, the value scheme's Docker option.
	Server   string
	Selected string
	// OptionKey is the form field of the engine's second select, empty for an
	// engine with nothing to pick; OptionLabel names it, OptionDetail stands
	// under it, Options are the fixed choices and OptionSelected the one in
	// force, which is the engine's own default while nothing is stored.
	OptionKey      string
	OptionLabel    string
	OptionDetail   string
	Options        []VoiceOption
	OptionSelected string
}

VoiceEngine is one engine on the voice page.

type VoiceOption added in v1.55.0

type VoiceOption struct {
	ID    string
	Label string
}

VoiceOption is one choice of an engine's second select: the stored id and what the page calls it.

Jump to

Keyboard shortcuts

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