Documentation
¶
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 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
}
type ThemeConfig ¶
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"`
}