issueview

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package issueview fetches one td issue and renders it as a reusable card.

Hosts size the card and decide when it is active. An active card walks parent/child/sibling issues with the arrow keys; an inactive one only scrolls, so a modal can share those keys with its own chrome until the user tabs to the card and presses enter, or clicks it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyID added in v1.0.0

func CopyID(d *Data) tea.Cmd

CopyID copies just the issue id. A missing issue is a no-op.

func CopyMarkdown added in v1.0.0

func CopyMarkdown(d *Data) tea.Cmd

CopyMarkdown copies the issue as markdown. A missing issue is a no-op.

func Description

func Description(renderer *markdown.Renderer, d *Data, width int) string

Description renders the issue body as markdown wrapped to width, falling back to the raw text when no renderer is available. A nil renderer builds the default one.

func Fetch

func Fetch(workDir, issueID string) tea.Cmd

Fetch runs `td show` and, when that succeeds, `td tree` so the card can show subtasks and walk an epic's children. workDir sets the command's working directory so td uses the correct project database.

func FormatMarkdown added in v1.0.0

func FormatMarkdown(d *Data) string

FormatMarkdown renders one issue the way td monitor yanks it: a heading, identity, metadata, then description and acceptance when they exist. An epic includes its child titles so a yank of the card is still useful when the full child bodies were never fetched.

func Heading

func Heading(d *Data) string

Heading is the issue's headline: "<id>: <title>". Hosts use this for chrome (pane chips, modal titles) so the card can draw the id separately.

func LabelsLine

func LabelsLine(d *Data) string

LabelsLine lists the issue's labels.

func LayoutTabStrip added in v1.0.0

func LayoutTabStrip(group Tabs, width int, focused bool) tabs.Strip

LayoutTabStrip is the issue header: an end-truncated title strip so the issue ID stays visible. Hosts draw this row and register hit regions from the same Tabs so a click cannot land on a tab that was never rendered.

func NormalizeID added in v1.0.0

func NormalizeID(id string) string

NormalizeID is the tab key: trimmed and held to the same shape a terminal link click can produce. Invalid values are empty.

func ParentLine

func ParentLine(d *Data) string

ParentLine names the issue's parent.

func StatusLabel

func StatusLabel(status string) string

StatusLabel turns a td status token into the uppercase label the card draws, using the model's names rather than invented ones (in_review stays IN REVIEW, not REVIEWABLE).

func StatusLine

func StatusLine(d *Data) string

StatusLine joins the issue's status, type, priority, and points. Kept for hosts that still want a single meta row.

func StoreTargets added in v1.0.0

func StoreTargets(workDir string) []livewatch.Target

StoreTargets returns what to watch for changes to the td store backing workDir, or nil when no store can be resolved.

td keeps issues in SQLite. In WAL mode a write lands in issues.db-wal and may not touch issues.db until a checkpoint, so watching the database file alone would miss most changes and catch them late. Watching the containing directory catches the database, its WAL and its shared-memory file with one registration, and the directory holds only those, so there is no noise to filter.

This resolves a path; it must not run on the startup path.

Types

type ActionHint

type ActionHint struct {
	Key, Label string
}

ActionHint is one key/label pair drawn in the card's ACTIONS row.

type Data

type Data struct {
	ID          string   `json:"id"`
	Title       string   `json:"title"`
	Status      string   `json:"status"`
	Type        string   `json:"type"`
	Priority    string   `json:"priority"`
	Points      int      `json:"points"`
	Description string   `json:"description"`
	Acceptance  string   `json:"acceptance"`
	ParentID    string   `json:"parent_id"`
	Labels      []string `json:"labels"`
	CreatedAt   string   `json:"created_at"`
	UpdatedAt   string   `json:"updated_at"`
	Logs        []Log    `json:"logs"`

	// Filled by a follow-up tree fetch; not present on `td show` JSON.
	Parent   *Ref  `json:"-"`
	Children []Ref `json:"-"`
	Siblings []Ref `json:"-"`
}

Data holds one td issue plus the related rows the card needs to render and navigate: children (subtasks), parent, siblings, and recent logs.

type FetchedMsg

type FetchedMsg struct {
	IssueID string
	Data    *Data
	Error   error
}

FetchedMsg carries one td fetch result. Hosts that track their own request identity wrap it; the app's modal consumes it directly.

type Hit

type Hit struct {
	Kind   HitKind
	Index  int
	ID     string
	X, Y   int
	W, H   int
	Cursor int
}

Hit is one interactive rectangle in the last View, in view-local cells.

type HitKind

type HitKind int

HitKind names what a click or hover landed on.

const (
	HitNone HitKind = iota
	HitParent
	HitChild
	HitBody
)

type LoadedMsg

type LoadedMsg struct {
	ModelID           int
	RequestGeneration uint64
	Epoch             uint64
	IssueID           string
	Data              *Data
	Error             error

	// Refresh marks a result produced by Model.Refresh rather than Model.Load:
	// an in-place re-read that must not disturb scroll, cursor or hover, and
	// that is discarded entirely when it found nothing new. See live.go.
	Refresh bool
}

LoadedMsg is the result of a Model load. Its identity fields ensure a result can only be applied to the model, request, and plugin epoch that issued it.

func (LoadedMsg) GetEpoch

func (m LoadedMsg) GetEpoch() uint64

GetEpoch allows callers to apply the normal plugin epoch checks if desired.

type Log

type Log struct {
	Timestamp string `json:"timestamp"`
	Session   string `json:"session"`
	Message   string `json:"message"`
	Type      string `json:"type"`
}

Log is one progress line from `td show`.

type Model

type Model struct {

	// OpenHandler, when set, receives parent/subtask/sibling activations
	// instead of Load retargeting this model. Hosts that tab issues use this
	// so navigation cannot destroy the issue the user is reading.
	OpenHandler func(issueID string) tea.Cmd

	// OpenInTDHandler, when set, is what O does: it hands the selected issue
	// to the host so the host can put it in front of the user in td. The
	// capability lives here rather than in each host's key switch so every
	// surface that shows an issue card answers O the same way and advertises
	// it in the same ACTIONS row.
	OpenInTDHandler func(issueID string) tea.Cmd
	// contains filtered or unexported fields
}

Model is one td issue in one content box.

func New

func New(renderer *markdown.Renderer) *Model

New creates an empty issue viewer. A nil renderer uses the default markdown renderer.

func (*Model) ActionHints

func (m *Model) ActionHints() []ActionHint

SetActionHints replaces the ACTIONS row. An empty list hides the section unless the card can still show its own navigation hints. ActionHints returns the host-supplied ACTIONS row.

func (*Model) Active

func (m *Model) Active() bool

Active reports whether arrow keys should navigate the epic.

func (*Model) Arm added in v1.0.0

func (m *Model) Arm(modelID int, issueID string, epoch uint64)

Arm shows the loading placeholder for a restored tab without issuing a load.

func (*Model) Data

func (m *Model) Data() *Data

Data returns the current issue, or nil before a successful fetch.

func (*Model) Err

func (m *Model) Err() error

Err returns the last fetch error, if any.

func (*Model) Focused

func (m *Model) Focused() bool

Focused reports whether the card is the current tab stop.

func (*Model) HandleClick

func (m *Model) HandleClick(x, y int) (HitKind, tea.Cmd)

HandleClick selects and opens a parent or child row at view-local (x, y). A click on empty chrome still only activates the card so the next arrow key can navigate; hosts do not need a separate double-click path for issue rows.

func (*Model) HandleHover

func (m *Model) HandleHover(x, y int)

HandleHover updates the hover highlight from view-local coordinates.

func (*Model) HandleKey

func (m *Model) HandleKey(k tea.KeyMsg) (bool, tea.Cmd)

HandleKey applies issue keys. When the card is not active, arrows and j/k only scroll. When it is active, arrows walk parent/subtasks/siblings and enter opens the selected row; j/k, paging, and g/G still scroll. A navigation key returns a Load command for the new issue.

func (*Model) Hits

func (m *Model) Hits() []Hit

Hits returns the interactive rectangles from the last View, in view-local cells. Hosts that want per-row regions register these; hosts that only have a pane box can call HandleClick with local coordinates instead.

func (*Model) IssueID

func (m *Model) IssueID() string

IssueID returns the issue this model is targeting.

func (*Model) Load

func (m *Model) Load(modelID int, workDir, issueID string, epoch uint64) tea.Cmd

Load retargets the model at issueID and returns a command that fetches it. Only the issueview-owned LoadedMsg is broadcast. A pending restore scroll survives so SetResult can apply it to this generation.

func (*Model) Loading

func (m *Model) Loading() bool

Loading reports whether a fetch is outstanding.

func (*Model) ModelID added in v1.0.0

func (m *Model) ModelID() int

ModelID is the load identity last passed to Load. Hosts route async results by this, not by pane-leaf identity.

func (*Model) NeedsLoad added in v1.0.0

func (m *Model) NeedsLoad() bool

NeedsLoad reports whether this model has never been asked to Load.

func (*Model) Observe added in v1.0.0

func (m *Model) Observe()

Observe records that the td store moved. It is cheap and idempotent: a burst of signals owes exactly one re-read.

func (*Model) OpenSelection

func (m *Model) OpenSelection() tea.Cmd

OpenSelection loads the selected parent or child. Nothing selected is a no-op.

func (*Model) Refresh added in v1.0.0

func (m *Model) Refresh(suppressed bool) tea.Cmd

Refresh returns a command that re-reads the issue in place, or nil when no re-read is owed.

Unlike Model.Load it leaves the card exactly as it is: same scroll, same cursor, same hover, same data on screen, and no "Loading issue…" placeholder. The user should not be able to tell a refresh happened unless something actually changed.

It returns nil when nothing is owed, when a re-read is already running, when a Load is still in flight, or when the host vetoes with suppressed. A vetoed refresh stays owed and lands on the next call, so a host may pass its own "the user is mid-interaction" state without dropping the update.

func (*Model) RefreshPending added in v1.0.0

func (m *Model) RefreshPending() bool

RefreshPending reports whether a re-read is owed but has not started, so a host can re-offer a refresh once its veto lifts.

func (*Model) Scroll

func (m *Model) Scroll(delta int)

Scroll moves the viewport by delta rows and clamps it to the issue.

func (*Model) ScrollAtBoundary added in v1.0.0

func (m *Model) ScrollAtBoundary(delta int) bool

ScrollAtBoundary reports whether delta would leave this issue viewport unchanged. It is safe to ask from Bubble Tea's pre-update input filter.

func (*Model) ScrollOffset

func (m *Model) ScrollOffset() int

ScrollOffset is the current (or still-pending restore) viewport offset.

func (*Model) SelectedID

func (m *Model) SelectedID() string

SelectedID is the issue the cursor is on, or the current issue when nothing is selected.

func (*Model) SetActionHints

func (m *Model) SetActionHints(hints []ActionHint)

func (*Model) SetActive

func (m *Model) SetActive(active bool)

SetActive enables epic/subtask arrow navigation. Hosts that share those keys with something else (the preview modal) only set this after the user tabs to the card and presses enter, or clicks it.

func (*Model) SetData

func (m *Model) SetData(d *Data)

SetData installs already-fetched data. Tests and hosts that fetched themselves use this instead of going through Load.

func (*Model) SetFocused

func (m *Model) SetFocused(focused bool)

SetFocused marks the card as the current tab stop. It is a visual cue distinct from Active: focused-but-inactive still scrolls on arrows.

func (*Model) SetPendingScroll

func (m *Model) SetPendingScroll(offset int)

SetPendingScroll remembers an offset for the current load generation. A stale result cannot consume it because SetResult rejects stale generations before applying or clearing this value.

func (*Model) SetResult

func (m *Model) SetResult(msg LoadedMsg) bool

SetResult applies msg if it belongs to the current load. It returns false without changing the model for stale model, request, epoch, or issue results.

A result produced by Model.Refresh is applied in place instead: see applyRefresh. It also returns false when the refresh found nothing new, so a host can treat "false" uniformly as "nothing to repaint".

func (*Model) SetSize

func (m *Model) SetSize(width, height int)

SetSize sets the content box dimensions. A width change invalidates rendered markdown because wrapping depends on it.

func (*Model) Title

func (m *Model) Title() string

Title returns the issue's headline, or its ID before data arrives.

func (*Model) View

func (m *Model) View() string

View returns exactly the configured number of rows, each no wider than the configured width in terminal cells.

type Ref

type Ref struct {
	ID       string `json:"id"`
	Title    string `json:"title"`
	Status   string `json:"status"`
	Type     string `json:"type"`
	Priority string `json:"priority"`
}

Ref is a lightweight issue pointer used for parent, children, and siblings.

type TabHit added in v1.0.0

type TabHit = tabs.Hit

TabHit is a drawn tab's click target. Col is relative to the strip's first column; Width is the rendered pill.

type TabStrip added in v1.0.0

type TabStrip = tabs.Strip

TabStrip is the header row: only tabs, packed left to right.

type Tabs added in v1.0.0

type Tabs struct {
	tabs.Group[*Model]
}

Tabs is one issue pane's open issues. The pane tree points at this group, not at one model. The stable key is a trimmed, validated TD issue ID.

func (Tabs) ActiveView added in v1.0.0

func (t Tabs) ActiveView() *Model

ActiveView is the selected issue, or nil.

func (Tabs) Find added in v1.0.0

func (t Tabs) Find(issueID string) int

Find returns the first tab whose key is the normalized issue ID, or -1.

func (*Tabs) OpenOrFocus added in v1.0.0

func (t *Tabs) OpenOrFocus(issueID string, view *Model) (index int, created bool)

OpenOrFocus selects the tab for issueID, or appends view and selects it. An invalid ID is a no-op.

Jump to

Keyboard shortcuts

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