Documentation
¶
Overview ¶
Package server exposes HTTP routes and, in this file, tracks passive tmux activity for workspace responses.
The workspace sidebar polls /workspaces frequently, but tmux has no durable "agent is working" flag for a pane. The tracker turns cheap observations from a tmux pane snapshot into a short-lived activity signal for the UI. A snapshot includes the active pane title and recent scrollback. The title path catches explicit spinner titles set by tools such as Codex; the output path catches tools that do not update the title but are still producing terminal output.
Samples are keyed by tmux session. Each sample stores the last pane title, a fingerprint of normalized recent output, and the time that fingerprint last changed. A title that matches the known spinner protocol marks the workspace as working immediately. Otherwise, output is considered active when its fingerprint changed within tmuxActivityTTL. Cached samples remain usable for tmuxSampleMinInterval so the UI poll loop does not shell out to tmux on every request unless the previous sample is old enough to refresh. Refresh probes are bounded globally and coalesced per session; if a probe is already running or the limit is full, callers reuse the last cached result when one exists.
Index ¶
- func NewOpenAPI() *huma.OpenAPI
- type EmbedConfig
- type Event
- type EventHub
- type RepoRef
- type Server
- func (s *Server) ActiveWorktreeKey() (string, bool)
- func (s *Server) Hub() *EventHub
- func (s *Server) ListenAndServe(addr string) error
- func (s *Server) Serve(ln net.Listener) error
- func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *Server) SetActiveWorktreeKey(key string)
- func (s *Server) SetVersion(v string)
- func (s *Server) Shutdown(ctx context.Context) error
- type ServerOptions
- type ThemeConfig
- type TmuxActivitySample
- type UIConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewOpenAPI ¶
Types ¶
type EmbedConfig ¶
type EmbedConfig struct {
Theme *ThemeConfig `json:"theme,omitempty"`
UI *UIConfig `json:"ui,omitempty"`
}
type EventHub ¶
type EventHub struct {
// contains filtered or unexported fields
}
EventHub manages SSE subscribers with fan-out broadcasting.
func (*EventHub) Broadcast ¶
Broadcast sends an event to all subscribers. If event.Type is "sync_status", the event is cached for future subscribers. Slow consumers (full channel) are evicted.
func (*EventHub) Close ¶
func (h *EventHub) Close()
Close shuts down the hub: closes the done channel so SSE handlers exit, marks the hub closed so future Subscribe calls fail fast, then cleans up all subscriber channels.
func (*EventHub) Subscribe ¶
Subscribe registers a new subscriber. Returns the event channel and the hub's done channel. The event channel is pre-loaded with the cached lastSyncStatus if available. If the hub is already closed, returns an immediately-closed channel and the closed done channel so callers can exit cleanly without leaking a goroutine.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server holds the HTTP mux and its dependencies.
func New ¶
func New( database *db.DB, syncer *ghclient.Syncer, frontend fs.FS, basePath string, cfg *config.Config, opts ServerOptions, ) *Server
New creates a Server without config persistence. Pass cfg for repo filtering (can be nil for tests that don't need filtering).
func NewWithConfig ¶
func NewWithConfig( database *db.DB, syncer *ghclient.Syncer, clones *gitclone.Manager, frontend fs.FS, cfg *config.Config, cfgPath string, opts ServerOptions, ) *Server
NewWithConfig creates a Server with config persistence for settings/repo endpoints.
func (*Server) ActiveWorktreeKey ¶
ActiveWorktreeKey returns the key of the currently focused worktree and whether it was explicitly set. Thread-safe.
func (*Server) Hub ¶
Hub returns the server's SSE event hub. Callers should never retain the returned pointer beyond the server's lifetime.
func (*Server) ListenAndServe ¶
ListenAndServe starts the HTTP server on addr. Returns http.ErrServerClosed when stopped by Shutdown (matches net/http).
func (*Server) Serve ¶
Serve accepts HTTP connections on the provided listener. Useful for tests and any caller that wants to own the listener lifetime. Returns http.ErrServerClosed when stopped by Shutdown.
func (*Server) ServeHTTP ¶
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler so Server can be used directly.
func (*Server) SetActiveWorktreeKey ¶
SetActiveWorktreeKey sets the key of the currently focused worktree. Thread-safe.
func (*Server) SetVersion ¶
SetVersion sets the version string returned by GET /api/v1/version.
func (*Server) Shutdown ¶
Shutdown stops the HTTP listener (if started via ListenAndServe or Serve), closes the SSE event hub so streaming handlers exit, cancels background goroutines' context, and blocks until they finish or ctx expires. Safe to call concurrently and repeatedly. Every caller drives http.Server.Shutdown with its own ctx (stdlib polls idle-conn closure per call) and waits on a shared drain channel, so a retry with a longer deadline observes true drain for both HTTP handlers and the bg group. Only the first caller closes the hub and cancels bgCtx.
type ServerOptions ¶
type ServerOptions struct {
EmbedConfig *EmbedConfig
Clones *gitclone.Manager // optional clone manager for diff view
WorktreeDir string // base dir for workspace worktrees
}
type ThemeConfig ¶
type TmuxActivitySample ¶
type UIConfig ¶
type UIConfig struct {
HideSync *bool `json:"hideSync,omitempty"`
HideRepoSelector *bool `json:"hideRepoSelector,omitempty"`
HideStar *bool `json:"hideStar,omitempty"`
SidebarCollapsed *bool `json:"sidebarCollapsed,omitempty"`
Repo *RepoRef `json:"repo,omitempty"`
ActiveWorktreeKey string `json:"activeWorktreeKey,omitempty"`
}
Source Files
¶
- api_types.go
- capabilities.go
- detail_sync.go
- event_hub.go
- health_routes.go
- helpers.go
- huma_routes.go
- output_wrappers.go
- provider_route_wrappers.go
- repo_import_handlers.go
- repo_ref.go
- roborev_proxy.go
- roborev_proxy_routes.go
- server.go
- settings_handlers.go
- settings_routes.go
- stack_health.go
- terminal_routes.go
- tmux_activity.go
- workspace_runtime_terminal.go
- ws_debug.go