chat

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package chat is the Workbench chat for harness sessions: a gotth-live page that shows one session's transcript as its event log grows and sends the operator's messages into the open session through the harness service, in process. It is served from the harness host app; it owns no listener.

Measured on a phone

mobile_browser_test.go drives the page in headless Chromium emulating a phone (390x844, device scale 3, touch) over a throttled network (100 ms latency, 1.6 Mbps down, 750 kbps up, shaping the page's requests; the WebSocket's frames pass it untouched), with the renderer warmed by one prior load. Milliseconds, median of five where several were taken:

page                      first paint  live   record to paint  send round trip
before (2026-10-02)       140          246    172 (64–228)     36
after  (2026-10-02)       144          260    165 (78–238)     25

The first paint figures are from navigation start, 138 and 141 ms after the request left the browser; the page was never slow, it was clumsy. docs/mobile-before.png and docs/mobile-after.png are the page as measured. What changed on a phone: the composer is pinned above the keyboard and the viewport does not jump when it opens; the transcript is anchored to its newest message unless the operator scrolls up; text is 16 px or larger with 44 px tap targets; Markdown and code render, and a code block scrolls sideways instead of widening the page. Replies arrive at the executor's granularity, one message per record, each morphed in without a reflow of the rest.

Index

Constants

View Source
const (
	PagePath = "/chat/:assignment"
	LivePath = "/chat/:assignment/live"
)

Routes: the page for one session and the live mount under it. The live handler routes by path suffix, so one application serves every session.

Variables

View Source
var (
	// ErrNoService reports a chat built without the harness service.
	ErrNoService = errors.New("harness chat: the session service is required")
	// ErrNoAssignment reports a page or connection whose path names no
	// assignment.
	ErrNoAssignment = errors.New("harness chat: the request names no assignment")
)

Functions

func PageURL

func PageURL(base string, assignment string) string

PageURL is the chat page of one assignment under base, the host's address.

Types

type Chat

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

Chat is the live application and its routes.

func NewChat

func NewChat(service *harness.AgentSessionService, origins []string, logger *slog.Logger) (*Chat, error)

NewChat builds the chat over service. origins is the browser Origin allowlist, one per address the host serves; nothing else is accepted.

func (*Chat) Register

func (chat *Chat) Register(router gin.IRouter)

Register mounts the page and the live routes on the caller's router.

func (*Chat) Start

func (chat *Chat) Start(scope *runtime.Scope) error

Start starts the live application's connection scope.

Jump to

Keyboard shortcuts

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