Documentation
¶
Overview ¶
Package panel is what an agent may ask of the right pane of its own tab and what the pane answers: the command parser, the cleaning of a page's answer, and the bridge that carries a command to the person's page over the sync socket and the answer back to the agent that waits for it.
Index ¶
- Constants
- Variables
- func CleanState(v any) *jsvalue.Object
- func ConnTarget(conn, kind, key string) string
- func IsTabKind(v any) bool
- func Kinds() []string
- func ParseConnTarget(target string) (conn, kind, key string, ok bool)
- func RateDecision(stamps []int64, now int64, limit int, windowMs int64) (bool, []int64)
- func UUID() string
- type Bridge
- type Command
- type Link
- type LinkChoice
- type Outcome
- type Result
- type Targets
Constants ¶
const ( MaxArg = 512 MaxMessage = 400 )
const ( ReasonConnect = "connect" ReasonEmbed = "embed" ReasonAccount = "account" )
The reasons a Link opens in no tab.
Variables ¶
var TabKinds = Kinds()
TabKinds are Kinds, for the callers that range over them.
Functions ¶
func CleanState ¶
CleanState keeps only a well-formed pane state.
func ConnTarget ¶
ConnTarget is the target of the task tab for an issue ("issue") or a page ("page") of a connection: the connection's id and the key exactly as the provider writes it, never derived from an address.
func Kinds ¶ added in v0.16.86
func Kinds() []string
Kinds are the kinds of tab the pane can hold, in the order the pane lists them.
func ParseConnTarget ¶
ParseConnTarget is ConnTarget's inverse; ok is false for a target that names no connection.
func RateDecision ¶
RateDecision is a sliding window over the times of the commands let through; a refused one is not counted.
Types ¶
type Bridge ¶
type Bridge struct {
// Publish sends an event to every page; Subscribers counts the pages (and relays) connected.
Publish func(event *jsvalue.Object)
Subscribers func() int
Now func() time.Time
// contains filtered or unexported fields
}
Bridge holds the commands waiting for an answer and each tab's recent commands.
func (*Bridge) Answer ¶
Answer settles a command with the first answer; false for a later one or an id never issued.
func (*Bridge) Dispatch ¶
Dispatch asks the page that shows the tab right now and waits for its answer; timeout 0 is the default 8 s.
func (*Bridge) RateAllowed ¶
RateAllowed counts a command of the tab against its limit (12 a minute); a refused one is not counted.
type Command ¶
type Command struct {
Kind string // open, show, hide, status
Tab string
Target string // "" for none
// Auto: the runtime asked, seeing what the agent works on, not the agent; the person may switch these off.
Auto bool
// Reload: the thing changed, a tab that shows it reloads; nothing opens for it.
Reload bool
// Place: where in the file to show (a range of cells, a time, a page); "" for none.
Place string
}
type Link ¶
type Link struct {
Tab, Target, Reason string
Choices []LinkChoice // Exact native task targets, only when Reason is ReasonAccount.
}
Link is where one address opens. Tab "link" is an address that opens in no tab of the pane: Reason says why (ReasonConnect: the connection that reads it has no working sign-in; ReasonEmbed: its service cannot be framed) and Target is the address itself, which the person may open by choice, never in the remote browser by itself.
type LinkChoice ¶
type LinkChoice struct {
Target, Label, Detail string
}
type Outcome ¶
Outcome is how a command ended: answered (with Result), no-ui, timeout, busy or rate-limited.
type Result ¶
type Result struct {
OK bool
Message string
State *jsvalue.Object // {visible, open, active}; nil when the page sent none
}
Result is a page's answer to a command, shape-checked, cleaned and clipped: the browser is not trusted.
func ParseResult ¶
ParseResult reads a page's answer; nil when the body is not one.
type Targets ¶
type Targets struct {
// StandDomain is the domain of the feature stands (".preview.example.org"); "" opens none.
StandDomain string
// PortalHost publishes documents (/a/<slug>) and boards (/b/<slug>); ReaderHost is the platform, whose reader
// shows a document at ReaderPath<slug>.
PortalHost, ReaderHost string
// ArtifactsHost and BoardsHost are the hosts of a deployment that serves documents (/a/<slug>) and boards (/b/<slug>)
// from separate servers; PortalHost is the one host that serves both.
ArtifactsHost, BoardsHost string
ReaderPath string
// GitLabHosts are the GitLab servers whose merge requests and commits a tab shows; the first is named in hints.
GitLabHosts []string
// GitHubHost is the GitHub whose pull requests, commits and issues the same tab shows ("" is github.com).
GitHubHost string
// TaskKey matches a key of the tracker; TaskExamples are named in the hint.
TaskKey *regexp.Regexp
TaskExamples string
// TrackerHosts are the tracker's servers: the page of a task there opens the task tab, as its key does.
TrackerHosts []string
// DesignRef is the id of the machine's design that a text names (its id, its folder or a file in it, its title),
// "" for none; nil: the machine has no design library and "open design" takes no target.
DesignRef func(text string) string
// DesignBoard is the design of the machine's library an absolute path lies in and the board of it the path is (a
// page under the design's project/, as its viewer names it; "" for the design's other files), ("", "") outside the
// library; nil: no library. A file of a design opens in the design's tab, never as a file.
DesignBoard func(path string) (design, board string)
// AppRef is the canonical "<app id>[/<view>]" of an installed app's pane view that a text names, "" for none; nil:
// the machine has no apps and "open app" takes no target.
AppRef func(text string) string
// AppWhyNot says why an installed app the text names opens no pane view when it is the app's state (it waits for
// the person's consent, it is turned off), "" otherwise; nil says nothing more than the hint.
AppWhyNot func(text string) string
// Resolve asks what the deployment's connections (an issue tracker, a wiki) and its documents provider make of an
// address, before any generic site: a zero Link is "none of mine". nil: nothing is asked.
Resolve func(ctx context.Context, text string) Link
}
Targets are the deployment's addresses a command may point a tab at.
func (Targets) Classify ¶ added in v0.15.40
The kinds of addresses (docs/pane-opening.md), each by its exact pattern:
document https://<PortalHost|ArtifactsHost>/a/<slug>, https://<ReaderHost><ReaderPath><slug> artifacts board https://<PortalHost|BoardsHost>/b/<slug>[?k=<key>] artifacts stand https://<one label><StandDomain>/…, no port; ai-… and auth are not stands browser dev server http(s)://localhost:<port> (127.0.0.1, 0.0.0.0), a bare port browser MR, commit https://<GitLabHosts>/<project>/-/merge_requests/<n>, /-/commit/<sha>; GitHub's gitlab task a TaskKey (PROJ-12), https://<TrackerHosts>/issue/<key> task
A document is never the browser: a page of the portal or the platform that is none of these is a plain site.
Classify is the tab a link or a name the agent wrote opens in, by the rules of open: a tracker key is the task tab, a GitLab merge request or commit or a GitHub pull request, commit or issue the gitlab tab, a document or a board of the portal the artifacts tab, and any other http(s) address the browser. "" for what opens nothing. The chat's chips and the pane's links ask it, so the pane has one set of rules for the agent's open command and for what the person clicks.
func (Targets) ClassifyLink ¶
ClassifyLink is Classify with the reason an address opens in no tab (Tab "link"). The connections and the documents provider are asked after the fixed rules and before the generic site, so an address one of them reads never reaches the browser.
func (Targets) DesignOf ¶
DesignOf is the command that opens the file at an absolute path where it belongs when it is a design's: the design's tab, on its board (Place) when the path is one. ok is false for a path outside the library: an agent that opens `<library>/<id>/project/Board.dc.html` as a file gets the design, not its source.