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 ¶
- func CopyID(d *Data) tea.Cmd
- func CopyMarkdown(d *Data) tea.Cmd
- func Description(renderer *markdown.Renderer, d *Data, width int) string
- func Fetch(workDir, issueID string) tea.Cmd
- func FetchWithFallbacks(workDir, issueID string, fallbacks []ProjectRef) tea.Cmd
- func FormatMarkdown(d *Data) string
- func Heading(d *Data) string
- func IsNotFound(err error) bool
- func LabelsLine(d *Data) string
- func LayoutTabStrip(group Tabs, width int, focused bool) tabs.Strip
- func Lookup(workDir, issueID string, fallbacks []ProjectRef) (*Data, *Owner, error)
- func NormalizeID(id string) string
- func ParentLine(d *Data) string
- func StatusLabel(status string) string
- func StatusLine(d *Data) string
- func StoreTargets(workDir string) []livewatch.Target
- type ActionHint
- type Data
- type FetchedMsg
- type Hit
- type HitKind
- type IssueLoader
- type LoadedMsg
- type Log
- type Model
- func (m *Model) AbandonSelection() textselect.Result
- func (m *Model) ActionHints() []ActionHint
- func (m *Model) Active() bool
- func (m *Model) Arm(modelID int, issueID string, epoch uint64)
- func (m *Model) ClearSelection()
- func (m *Model) Data() *Data
- func (m *Model) Err() error
- func (m *Model) Focused() bool
- func (m *Model) FoundIn() string
- func (m *Model) HandleClick(x, y int) (HitKind, tea.Cmd)
- func (m *Model) HandleHover(x, y int)
- func (m *Model) HandleKey(k tea.KeyMsg) (bool, tea.Cmd)
- func (m *Model) HandleSelectionKey(msg tea.KeyMsg) textselect.Result
- func (m *Model) HandleSelectionMouse(action mouse.MouseAction) textselect.Result
- func (m *Model) HasScrollbar() bool
- func (m *Model) HasSelection() bool
- func (m *Model) Hits() []Hit
- func (m *Model) IssueID() string
- func (m *Model) Load(modelID int, workDir, issueID string, epoch uint64) tea.Cmd
- func (m *Model) Loading() bool
- func (m *Model) ModelID() int
- func (m *Model) NeedsLoad() bool
- func (m *Model) Observe()
- func (m *Model) OffsetAtTrackRow(row int) int
- func (m *Model) OpenSelection() tea.Cmd
- func (m *Model) Owner() (name, root string)
- func (m *Model) PressScrollbar(x, y int) bool
- func (m *Model) Refresh(suppressed bool) tea.Cmd
- func (m *Model) RefreshPending() bool
- func (m *Model) RestoreOwner(name, root string)
- func (m *Model) ResultMatches(msg LoadedMsg) bool
- func (m *Model) Scroll(delta int)
- func (m *Model) ScrollAtBoundary(delta int) bool
- func (m *Model) ScrollOffset() int
- func (m *Model) ScrollbarDrag(y int) bool
- func (m *Model) ScrollbarDragEnd()
- func (m *Model) ScrollbarDragging() bool
- func (m *Model) ScrollbarParams() ui.ScrollbarParams
- func (m *Model) ScrollbarRect() mouse.Rect
- func (m *Model) SelectableAt(x, y int) bool
- func (m *Model) SelectedID() string
- func (m *Model) SelectionCopyCmd(result textselect.Result, wrap func(textselect.CopyNotice) tea.Msg) tea.Cmd
- func (m *Model) SelectionText() []string
- func (m *Model) SetActionHints(hints []ActionHint)
- func (m *Model) SetActive(active bool)
- func (m *Model) SetData(d *Data)
- func (m *Model) SetFocused(focused bool)
- func (m *Model) SetLoader(loader IssueLoader)
- func (m *Model) SetOrigin(x, y int)
- func (m *Model) SetPendingScroll(offset int)
- func (m *Model) SetResult(msg LoadedMsg) bool
- func (m *Model) SetSelection(keys textselect.Keys, copyOnSelect bool)
- func (m *Model) SetSize(width, height int)
- func (m *Model) Title() string
- func (m *Model) View() string
- func (m *Model) WorkDir() string
- type NotModified
- type Owner
- type ProjectRef
- type Ref
- type SearchCandidate
- type TabHit
- type TabStrip
- type Tabs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyMarkdown ¶ added in v1.0.0
CopyMarkdown copies the issue as markdown. A missing issue is a no-op.
func Description ¶
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 a compact-document one, matching the wrap contract New enforces: this card pads its own frame, so Glamour's document margin must stay out of the way.
func Fetch ¶
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 FetchWithFallbacks ¶ added in v1.4.0
func FetchWithFallbacks(workDir, issueID string, fallbacks []ProjectRef) tea.Cmd
FetchWithFallbacks is Fetch with cross-project candidates. The refs are raw config projects; resolving them into verified candidates happens here, inside the command, because it stats files and may shell out to git.
func FormatMarkdown ¶ added in v1.0.0
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 ¶
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 IsNotFound ¶ added in v1.12.0
IsNotFound is the exported form of isNotFound for the content service.
func LayoutTabStrip ¶ added in v1.0.0
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 Lookup ¶ added in v1.12.0
func Lookup(workDir, issueID string, fallbacks []ProjectRef) (*Data, *Owner, error)
Lookup is the state-free issue load the content service and injected loaders share. It is FetchWithFallbacks without the Bubble Tea wrapper.
func NormalizeID ¶ added in v1.0.0
NormalizeID is the tab key: trimmed and held to the same shape a terminal link click can produce. Invalid values are empty.
func StatusLabel ¶
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 ¶
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
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 ¶
FetchedMsg carries one td fetch result. Hosts that track their own request identity wrap it; the app's modal consumes it directly.
FoundIn is nil for a local result. A non-nil Owner means the issue lives in another configured project's store; the card adopts that store as its own (refreshes address it directly) and shows the project name as a badge.
type HitKind ¶
type HitKind int
HitKind names what a click or hover landed on.
const ( HitNone HitKind = iota HitParent HitChild HitBody // HitScrollbar reports a press that began a scrollbar gesture instead of // landing on the card's content. Hosts see it from HandleClick while // ScrollbarDragging is true, which is their cue to start the shared // handler's drag so motions come back to ScrollbarDrag. HitScrollbar )
type IssueLoader ¶ added in v1.12.0
IssueLoader produces an issue load command. IfRevision is the last adopted source revision and may be empty. The command should return FetchedMsg, NotModified, or LoadedMsg.
type LoadedMsg ¶
type LoadedMsg struct {
ModelID int
RequestGeneration uint64
Epoch uint64
IssueID string
Data *Data
Error error
// FoundIn is nil for a local issue. Non-nil, the issue was resolved in
// another project's store; hosts use it to retarget live watchers.
FoundIn *Owner
// 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
// NotModified completes an in-flight refresh without replacing content.
NotModified bool
// Revision is the last adopted source revision, for a later conditional read.
Revision string
}
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.
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
// FallbackRefs, when set, supplies this host's configured projects at
// click time. On a local miss the card searches them (see crossproject.go)
// instead of declaring the issue missing. It is called inside the fetch
// command — resolving candidates stats files and may shell out to git —
// never on the update goroutine. Hosts without cross-project search leave
// it nil and behave exactly as before.
FallbackRefs func() []ProjectRef
// contains filtered or unexported fields
}
Model is one td issue in one content box.
func New ¶
New creates an empty issue viewer.
The card owns its wrap contract: it insets each side by horizontalContentPadding itself, so its markdown must render without Glamour's document margin — the same pairing Notes uses. A nil renderer, or one built without markdown.CompactDocument, is replaced by the card's own compact renderer rather than mutated: an injected instance may be shared with viewers (docview) whose inset is Glamour's margin. This is what keeps every surface that shows a card — workspace leaf, overview preview, app content deck, preview modal — wrapping identically no matter what it injects; without it, body text wraps around width−7 while width−3 columns are free.
func (*Model) AbandonSelection ¶ added in v1.14.0
func (m *Model) AbandonSelection() textselect.Result
AbandonSelection ends a gesture whose release never arrived.
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) Arm ¶ added in v1.0.0
Arm shows the loading placeholder for a restored tab without issuing a load.
func (*Model) ClearSelection ¶ added in v1.14.0
func (m *Model) ClearSelection()
ClearSelection drops the selection and any gesture editing it.
func (*Model) FoundIn ¶ added in v1.4.0
FoundIn is the owning project's display name, or empty for a local issue.
func (*Model) HandleClick ¶
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. A click on an interactive scrollbar instead begins a drag gesture and never activates anything: see scrollbar.go.
func (*Model) HandleHover ¶
HandleHover updates the hover highlight from view-local coordinates. The scrollbar column answers first: hovering the bar highlights the bar and clears any row highlight, the same exclusivity a row hover has.
func (*Model) HandleKey ¶
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) HandleSelectionKey ¶ added in v1.14.0
func (m *Model) HandleSelectionKey(msg tea.KeyMsg) textselect.Result
HandleSelectionKey answers the chords that act on the selection: copy, select-all, and escape.
Escape belongs here rather than in each host: what it means to a live selection is the selection's business, and a host that wrote the rule itself would be a host the other surfaces have to remember to match.
func (*Model) HandleSelectionMouse ¶ added in v1.14.0
func (m *Model) HandleSelectionMouse(action mouse.MouseAction) textselect.Result
HandleSelectionMouse advances the gesture over the card and reports what the host owes for it.
A drag that has run past an edge scrolls the card here rather than in the host: the window it is asking for is this model's own, and a host that moved it would be the second place that knows how far an issue can scroll. The rows it reveals are selected by the next motion event, as the engine's contract says.
func (*Model) HasScrollbar ¶ added in v1.4.0
HasScrollbar reports whether the card currently draws a bar (content overflows the viewport). When false, hosts must register no regions: the reserved column is an anti-jitter spacer, not a control.
func (*Model) HasSelection ¶ added in v1.14.0
HasSelection reports whether anything in this card is selected. It is asked outside a render — by a key, by a click elsewhere — so it settles the expiry itself rather than reporting a selection the next frame will drop.
func (*Model) Hits ¶
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) Load ¶
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) ModelID ¶ added in v1.0.0
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
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.
A card that can never re-read declines to be owed one. A card with no issue, or one that has never loaded, is owned by the host's own load path, and Model.Refresh refuses before it reaches the refresher — so accepting the change here would leave a dirty flag nothing can clear. A host asks whether a refresh is owed in order to retry it, and a permanently owed re-read is a permanent retry: three `td` subprocesses per sibling tab, every update.
func (*Model) OffsetAtTrackRow ¶ added in v1.4.0
OffsetAtTrackRow maps a track row (view-local pointer Y) onto the scroll offset whose thumb top anchors there — the shared core every other interactive scrollbar uses for track clicks and drags.
func (*Model) OpenSelection ¶
OpenSelection loads the selected parent or child. Nothing selected is a no-op.
func (*Model) Owner ¶ added in v1.4.0
Owner returns the owning project's display name and store root when the current issue was resolved in another configured project; empty strings for a local issue.
func (*Model) PressScrollbar ¶ added in v1.4.0
PressScrollbar answers a press on the interactive bar without ever reaching the nav rows: grabbing the thumb where it was pressed, or jumping to the clicked spot and anchoring the thumb there so the same gesture keeps dragging (macOS track-click). It is the arming seam hosts use when their click classification named a repeat press something other than a plain click — Bubble Tea reports a rapid second press as ActionDoubleClick, and routing that through HandleClick could reach a nav row if the bar moved between frames. Reports whether the press was the bar's.
func (*Model) Refresh ¶ added in v1.0.0
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
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) RestoreOwner ¶ added in v1.4.0
RestoreOwner reinstates a persisted cross-project adoption before the first load, so a restored tab refetches from the owning store — and keeps its badge — without re-running the search. Only the restore path calls this.
func (*Model) ResultMatches ¶ added in v1.12.0
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". ResultMatches reports whether msg belongs to this model's current load.
func (*Model) ScrollAtBoundary ¶ added in v1.0.0
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 ¶
ScrollOffset is the current (or still-pending restore) viewport offset.
func (*Model) ScrollbarDrag ¶ added in v1.4.0
ScrollbarDrag extends the live gesture from a held pointer at view-local y, clamping past both ends of the track without ending it. Reports whether a gesture was live.
func (*Model) ScrollbarDragEnd ¶ added in v1.4.0
func (m *Model) ScrollbarDragEnd()
ScrollbarDragEnd settles a finished or cancelled scrollbar gesture.
func (*Model) ScrollbarDragging ¶ added in v1.4.0
ScrollbarDragging reports whether a scrollbar gesture is live.
func (*Model) ScrollbarParams ¶ added in v1.4.0
func (m *Model) ScrollbarParams() ui.ScrollbarParams
ScrollbarParams reports the renderer inputs View draws the bar with: one row per rendered card row, a viewport of height rows. Hosts feed these to ui.RenderScrollbarWithGeometry for region registration and to ui.OffsetAtRow/RowForOffset for press and drag mapping — no scrollbar math lives outside internal/ui.
func (*Model) ScrollbarRect ¶ added in v1.4.0
ScrollbarRect is the track column in view-local cells, spanning the rows the track is drawn over. Zero when no interactive bar exists (nothing overflows, or the reserved column is the anti-jitter spacer); the zero rect contains no point.
func (*Model) SelectableAt ¶ added in v1.14.0
SelectableAt reports whether a press at view-local (x, y) is text rather than one of the card's own targets. A parent row, a subtask row and the scrollbar each answer a click already, and a press on one of them must stay that click rather than arming a gesture over it.
func (*Model) SelectedID ¶
SelectedID is the issue the cursor is on, or the current issue when nothing is selected.
func (*Model) SelectionCopyCmd ¶ added in v1.14.0
func (m *Model) SelectionCopyCmd(result textselect.Result, wrap func(textselect.CopyNotice) tea.Msg) tea.Cmd
SelectionCopyCmd delivers the copy an engine result asked for, phrased by the shared pipeline and wrapped in whatever notification type the host uses. A result that asked for nothing produces no command, so a host can hand every result it gets straight here.
func (*Model) SelectionText ¶ added in v1.14.0
SelectionText is the selection as the user sees it: the rows it covers, without the styling they were drawn with.
func (*Model) SetActionHints ¶
func (m *Model) SetActionHints(hints []ActionHint)
func (*Model) SetActive ¶
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 ¶
SetData installs already-fetched data. Tests and hosts that fetched themselves use this instead of going through Load.
func (*Model) SetFocused ¶
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) SetLoader ¶ added in v1.12.0
func (m *Model) SetLoader(loader IssueLoader)
SetLoader replaces the default td fetch. Nil restores it.
func (*Model) SetOrigin ¶ added in v1.14.0
SetOrigin records where the host last drew this card's body, in the coordinate space its mouse events arrive in. A card that has not been drawn has no origin, so it hit-tests as empty rather than as the top-left corner of the screen.
func (*Model) SetPendingScroll ¶
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) SetSelection ¶ added in v1.14.0
func (m *Model) SetSelection(keys textselect.Keys, copyOnSelect bool)
SetSelection binds the host's shared selection settings: the chords the card answers, and whether finishing a drag copies without being asked.
func (*Model) SetSize ¶
SetSize sets the content box dimensions. A width change invalidates rendered markdown because wrapping depends on it.
func (*Model) Title ¶
Title returns the issue's headline, or its ID before data arrives. A cross-project card is prefixed with its owning project so tab strips, overview headers, and modal titles carry the context, not just the card.
func (*Model) View ¶
View returns exactly the configured number of rows, each no wider than the configured width in terminal cells.
type NotModified ¶ added in v1.12.0
NotModified is returned by an injected loader when a refresh found no change.
type Owner ¶ added in v1.4.0
Owner names the project a cross-project result came from. A nil Owner on a fetch result means local — the ordinary path.
type ProjectRef ¶ added in v1.4.0
ProjectRef is one searchable project: display name plus any directory in it. Hosts map their config's project list to these at click time; resolving them into candidates is this package's job.
func ProjectRefsFromConfig ¶ added in v1.4.0
func ProjectRefsFromConfig(cfg *config.Config) []ProjectRef
ProjectRefsFromConfig maps sidecar's configured projects to searchable refs. All three hosts (workspace panes, the app preview modal, the global overview) call this at click time through their own Model.FallbackRefs handler; it is pure mapping over config, so it is safe on the update goroutine.
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 SearchCandidate ¶ added in v1.4.0
SearchCandidate is a deduped, verified place to look for an issue: its root has been resolved through tdroot.ResolveTDRoot, shown not to be the current project, and stat-checked for a td database.
func BuildCandidates ¶ added in v1.4.0
func BuildCandidates(currentRoot string, refs []ProjectRef) []SearchCandidate
BuildCandidates resolves each ref through tdroot.ResolveTDRoot, skips the current project's resolved root (local-first is tried before this runs and must not be searched twice), dedupes shared roots with the first name winning, and drops candidates whose .todos/issues.db does not exist — a stat, free next to the git spawn ResolveTDRoot may need.
Filesystem reads only; no td processes. Callers run it inside commands spawned by user action, never on the startup path.
type TabHit ¶ added in v1.0.0
TabHit is a drawn tab's click target. Col is relative to the strip's first column; Width is the rendered pill.
type Tabs ¶ added in v1.0.0
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
ActiveView is the selected issue, or nil.