sidebar

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: MIT Imports: 4 Imported by: 1

Documentation

Overview

Package sidebar is the right-hand working-context panel shared by tuigoff apps: an ordered list of entity.Ref, rendered by a product-supplied renderer, with a cursor, remove ("x"/Delete), open (Enter) and a resizable split width — generalised from DataTug chat's F6 workspace dock and Ctrl+←/→ split handling (ui.go splitEnabled/ resizeChatPane, workspace_ui.go).

Keybindings: ↑↓/j/k move cursor, x/Delete removes (RemoveMsg), Enter opens (OpenMsg). F6 visibility and Ctrl+←/→ width are concerns of the composing screen (the sidebar only stores/reports width bounds).

Index

Constants

View Source
const (
	MinChatPercent = 40
	MaxChatPercent = 75
)

Default split-width bounds, matching DataTug's Ctrl+←/→ chatPanePercent clamp (ui.go: max(40, min(75, ...))). Percent is the CHAT pane's share; the sidebar gets the remainder.

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

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

Model is the sidebar panel.

func New

func New(render Renderer) *Model

New returns a visible, empty sidebar using render to format entries.

func (*Model) Add

func (m *Model) Add(ref entity.Ref) bool

Add pins ref unless already present. Reports whether it changed.

func (*Model) ChatPercent

func (m *Model) ChatPercent() int

ChatPercent returns the chat pane's current width share (see MinChatPercent/MaxChatPercent).

func (*Model) Cursor

func (m *Model) Cursor() int

Cursor returns the index of the highlighted entry, or -1 when empty.

func (*Model) GrowChat

func (m *Model) GrowChat(delta int)

GrowChat/ShrinkChat adjust the split by delta percentage points, clamped to [MinChatPercent, MaxChatPercent] (Ctrl+→/Ctrl+← in DataTug).

func (*Model) Refs

func (m *Model) Refs() []entity.Ref

Refs returns the current ordered sidebar entries.

func (*Model) Remove

func (m *Model) Remove(ref entity.Ref) bool

Remove unpins ref. Reports whether it was present.

func (*Model) SetVisible

func (m *Model) SetVisible(v bool)

func (*Model) SetWidth

func (m *Model) SetWidth(width int)

SetWidth sets the panel's rendering width.

func (*Model) ShrinkChat

func (m *Model) ShrinkChat(delta int)

func (*Model) Title

func (m *Model) Title() string

Title returns the sidebar's current header text -- chatshell's own WithSidebarRenderer reads this before replacing m.sidebar wholesale, so a WithSidebarTitle call is never lost regardless of which of the two options a product applies first (see chatshell.WithSidebarRenderer's own doc).

func (*Model) Toggle

func (m *Model) Toggle()

Toggle flips visibility (F6).

func (*Model) Update

func (m *Model) Update(msg tea.Msg) tea.Cmd

Update handles cursor movement, remove and open key presses. focused gates whether the sidebar consumes the key (callers route key events here only while the focus ring is on the sidebar).

func (*Model) View

func (m *Model) View(width int, focused bool) string

View renders the sidebar list using the shared strongo-tui pkg/theme chrome — a header, and per-row selection styling (theme.SelectedRow) matching the same accent every other focused/selected element in an aichat product uses (founder 2026-09-25: side panel styling is centralised, not scattered per package).

func (*Model) Visible

func (m *Model) Visible() bool

func (*Model) WithTitle

func (m *Model) WithTitle(title string) *Model

WithTitle sets the sidebar's header text (default "Pinned") -- content only, e.g. a product's own name for its working-context list. Chained after New, mirroring chatshell's own With* option shape but scoped to this package's own constructor (sidebar.Model has no other options today).

type OpenMsg

type OpenMsg struct{ Ref entity.Ref }

OpenMsg is emitted when the user activates ref (Enter).

type RemoveMsg

type RemoveMsg struct{ Ref entity.Ref }

RemoveMsg is emitted when the user removes ref from the sidebar (x/Delete).

type Renderer

type Renderer func(ref entity.Ref, width int) string

Renderer formats one entity ref for the sidebar list at the given width.

Jump to

Keyboard shortcuts

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