notes

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 40 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultDBPath

func DefaultDBPath(workDir string) string

DefaultDBPath returns the default database path for a given workdir.

func ExactTitleMatch

func ExactTitleMatch(query string, note Note) bool

ExactTitleMatch returns true if query matches a note's title exactly (case-insensitive).

func FuzzyMatchNote

func FuzzyMatchNote(query string, note Note) int

FuzzyMatchNote scores how well query matches a note's title and content. Returns score (0 = no match). Scoring:

  • Consecutive matches: bonus per consecutive char
  • Word start matches: large bonus
  • Title match bonus: prefer title matches over content
  • Shorter text: small bonus

Types

type AutoSaveTickMsg

type AutoSaveTickMsg struct {
	// ID identifies which auto-save timer this is (for debounce check)
	ID int
}

AutoSaveTickMsg is sent when the auto-save debounce timer fires.

type ExternalEditorPreparedMsg added in v1.0.3

type ExternalEditorPreparedMsg struct {
	ID        string
	Path      string
	Err       error
	Epoch     uint64
	RequestID uint64
}

ExternalEditorPreparedMsg carries an asynchronously-created note export. NotePath may invoke td, so preparing it must never run on Bubble Tea Update.

func (ExternalEditorPreparedMsg) GetEpoch added in v1.0.3

func (m ExternalEditorPreparedMsg) GetEpoch() uint64

type FocusPane

type FocusPane int

FocusPane represents which pane is active.

const (
	PaneList FocusPane = iota
	PaneEditor
)

type InlineAutoSaveResultMsg

type InlineAutoSaveResultMsg struct {
	Err        error
	Epoch      uint64
	Activation uint64
	Generation int
	Content    string
	Saved      bool
	Skipped    bool
	Sequence   uint64
}

InlineAutoSaveResultMsg is sent after an inline auto-save completes.

func (InlineAutoSaveResultMsg) GetEpoch

func (m InlineAutoSaveResultMsg) GetEpoch() uint64

GetEpoch returns the epoch for staleness detection.

type InlineAutoSaveTickMsg

type InlineAutoSaveTickMsg struct {
	// Generation identifies which auto-save timer this is (for staleness check)
	Generation int
}

InlineAutoSaveTickMsg is sent periodically during inline edit mode for auto-save.

type InlineEditExitedMsg

type InlineEditExitedMsg struct {
	NoteID     string
	NotePath   string
	Activation uint64
	Epoch      uint64
}

InlineEditExitedMsg is sent when inline edit mode exits.

type InlineEditStartedMsg

type InlineEditStartedMsg struct {
	SessionName string
	NoteID      string
	NotePath    string
	Editor      string
	Activation  uint64
	Epoch       uint64
}

InlineEditStartedMsg is sent when inline edit mode starts successfully.

type Note

type Note = tdnotes.Note

Note is the plugin's view of a td note.

func FindExactTitleMatch

func FindExactTitleMatch(notes []Note, query string) *Note

FindExactTitleMatch returns the note with exact title match, or nil if none.

type NoteArchiveToggledMsg

type NoteArchiveToggledMsg struct {
	ID    string
	Err   error
	Epoch uint64
}

NoteArchiveToggledMsg is sent when a note's archived state is toggled.

func (NoteArchiveToggledMsg) GetEpoch

func (m NoteArchiveToggledMsg) GetEpoch() uint64

GetEpoch returns the epoch for staleness detection.

type NoteContentSavedMsg

type NoteContentSavedMsg struct {
	ID               string
	Err              error
	Epoch            uint64
	EditorActivation uint64 // Non-zero only for an inline-editor save lifecycle.
	Generation       int    // Built-in autosave generation captured at save start.
	SaveActivation   uint64 // Built-in save lifecycle captured at save start.
	RequestID        uint64 // Built-in request identity; only one may own completion.
	Content          string // Bytes this save wrote; empty for inline/export paths.
	Note             *Note  // Canonical note returned by td when available.
	External         bool   // $EDITOR read-back; not a built-in buffer save.
	Skipped          bool   // In-flight write skipped because a newer persist won.
	ExportPath       string // Retained until an external/inline save is acknowledged.
	ExportRequestID  uint64 // Owns the retained export save attempt.
	WriteSequence    uint64 // Orders all content writes for this note.
}

NoteContentSavedMsg is sent when a note's content is saved from the editor.

func (NoteContentSavedMsg) GetEpoch

func (m NoteContentSavedMsg) GetEpoch() uint64

GetEpoch returns the epoch for staleness detection.

type NoteDeletedMsg

type NoteDeletedMsg struct {
	ID    string
	Err   error
	Epoch uint64
}

NoteDeletedMsg is sent when a note is deleted.

func (NoteDeletedMsg) GetEpoch

func (m NoteDeletedMsg) GetEpoch() uint64

GetEpoch returns the epoch for staleness detection.

type NoteFilter

type NoteFilter int

NoteFilter represents the current note filter view.

const (
	FilterActive NoteFilter = iota
	FilterArchived
	FilterDeleted
)

func (NoteFilter) String

func (f NoteFilter) String() string

String returns the display name for the filter.

type NoteMatch

type NoteMatch struct {
	Note  Note
	Score int // Higher = better match
}

NoteMatch represents a note matching the search query.

func FilterNotes

func FilterNotes(notes []Note, query string) []NoteMatch

FilterNotes filters and scores notes against a query. Returns matches sorted by score descending.

type NotePinToggledMsg

type NotePinToggledMsg struct {
	ID    string
	Err   error
	Epoch uint64
}

NotePinToggledMsg is sent when a note's pinned state is toggled.

func (NotePinToggledMsg) GetEpoch

func (m NotePinToggledMsg) GetEpoch() uint64

GetEpoch returns the epoch for staleness detection.

type NoteRestoredMsg

type NoteRestoredMsg struct {
	ID    string
	Title string
	Err   error
	Epoch uint64
}

NoteRestoredMsg is sent when a note is restored (undo delete/archive).

func (NoteRestoredMsg) GetEpoch

func (m NoteRestoredMsg) GetEpoch() uint64

GetEpoch returns the epoch for staleness detection.

type NoteSavedMsg

type NoteSavedMsg struct {
	Note             *Note
	Err              error
	Epoch            uint64
	EditorActivation uint64 // Non-zero only for an inline-editor save lifecycle.
}

NoteSavedMsg is sent when a note is created or updated.

func (NoteSavedMsg) GetEpoch

func (m NoteSavedMsg) GetEpoch() uint64

GetEpoch returns the epoch for staleness detection.

type NotesLoadedMsg

type NotesLoadedMsg struct {
	Notes       []Note
	Err         error
	RecoveryErr error
	Epoch       uint64
	RequestID   uint64
	Filter      NoteFilter
}

NotesLoadedMsg is sent when notes are loaded from the database.

func (NotesLoadedMsg) GetEpoch

func (m NotesLoadedMsg) GetEpoch() uint64

GetEpoch returns the epoch for staleness detection.

type Plugin

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

Plugin implements the notes plugin.

func New

func New() *Plugin

New creates a new Notes plugin.

func (*Plugin) BlocksGlobalKeys added in v0.96.0

func (p *Plugin) BlocksGlobalKeys() bool

BlocksGlobalKeys reports whether a plugin-owned modal has keyboard focus.

func (*Plugin) Commands

func (p *Plugin) Commands() []plugin.Command

Commands returns the available commands.

func (*Plugin) ConsumesTextInput

func (p *Plugin) ConsumesTextInput() bool

ConsumesTextInput reports whether notes currently has an active text-entry surface and should receive printable keys directly.

func (*Plugin) Cursor added in v0.88.0

func (p *Plugin) Cursor() *tea.Cursor

Cursor exposes the inline editor's native cursor in plugin-local coordinates.

func (*Plugin) FocusContext

func (p *Plugin) FocusContext() string

FocusContext returns the current focus context.

func (*Plugin) FooterStatus added in v1.0.3

func (p *Plugin) FooterStatus() (string, bool)

FooterStatus keeps slow/failed saves visible after the transient toast.

func (*Plugin) ID

func (p *Plugin) ID() string

ID returns the plugin identifier.

func (*Plugin) Icon

func (p *Plugin) Icon() string

Icon returns the plugin icon character.

func (*Plugin) Init

func (p *Plugin) Init(ctx *plugin.Context) error

Init initializes the plugin with context.

func (*Plugin) IsFocused

func (p *Plugin) IsFocused() bool

IsFocused returns whether the plugin is focused.

func (*Plugin) Name

func (p *Plugin) Name() string

Name returns the plugin display name.

func (*Plugin) PreferredMouseMode added in v0.88.0

func (p *Plugin) PreferredMouseMode() tea.MouseMode

PreferredMouseMode reduces idle hover traffic only while the inline terminal owns input. Modal and ordinary notes views retain all-motion hover.

func (*Plugin) SetFocused

func (p *Plugin) SetFocused(f bool)

SetFocused sets the focus state.

func (*Plugin) Start

func (p *Plugin) Start() tea.Cmd

Start begins plugin operation.

func (*Plugin) Stop

func (p *Plugin) Stop()

Stop cleans up plugin resources.

func (*Plugin) Update

func (p *Plugin) Update(msg tea.Msg) (plugin.Plugin, tea.Cmd)

Update handles messages.

func (*Plugin) View

func (p *Plugin) View(width, height int) string

View renders the plugin.

func (*Plugin) WheelAtBoundary added in v1.0.0

func (p *Plugin) WheelAtBoundary(msg tea.MouseWheelMsg) bool

WheelAtBoundary implements plugin.WheelBoundaryConsumer for the Notes list and markdown preview. It mirrors handleMouseScroll's routing without moving the cursor, loading a note, or rendering.

Textarea edit mode stays unknown: ScrollYOffset is readable but the last reachable offset is not a public contract, so inventing a boundary would mis-report. Keep this false rather than guessing. The inline tmux editor's wheel belongs to the embedded application and is not translated into textarea rules. Open modals are answered by the modal itself, in the same precedence Update uses, and never by the panes underneath.

type Store

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

Store persists notes through the td CLI. Sidecar must never open .todos/issues.db itself — a second long-lived SQLite writer alongside transient td processes corrupts the WAL (td-adbf16). Tests use the in-process backend via NewTestStore against an isolated database.

func NewStore

func NewStore(baseDir, sessionID string) (*Store, error)

NewStore returns a lazy CLI-backed store rooted at the project directory. It deliberately does no PATH or database I/O: plugin Init runs before the first frame, while the first List call runs in a tea.Cmd and reports any missing td binary/database asynchronously. baseDir is the project root (not the issues.db path). sessionID, when non-empty, is exported as TD_SESSION_ID for attribution.

func NewTestStore added in v1.0.0

func NewTestStore(baseDir, sessionID string) (*Store, error)

NewTestStore creates an isolated in-process td database for tests.

func (*Store) Close

func (s *Store) Close() error

Close closes the test backend, if any. The CLI backend holds no handles.

func (*Store) Create

func (s *Store) Create(title, content string) (*Note, error)

Create inserts a new note.

func (*Store) Delete

func (s *Store) Delete(id string) error

Delete soft-deletes a note.

func (*Store) Get

func (s *Store) Get(id string) (*Note, error)

Get retrieves a note by ID, including soft-deleted rows. Missing notes return (nil, nil) to match the previous store contract.

func (*Store) List

func (s *Store) List(includeArchived bool) ([]Note, error)

List retrieves non-deleted notes. includeArchived includes archived ones.

func (*Store) ListArchived

func (s *Store) ListArchived() ([]Note, error)

ListArchived retrieves archived, non-deleted notes.

func (*Store) ListDeleted

func (s *Store) ListDeleted() ([]Note, error)

ListDeleted retrieves soft-deleted notes.

func (*Store) NotePath

func (s *Store) NotePath(id string) string

NotePath writes the note to a unique 0600 temp file for an external editor.

func (*Store) Restore

func (s *Store) Restore(id string) error

Restore undeletes a note.

func (*Store) SaveContent added in v1.0.3

func (s *Store) SaveContent(id, content string) (*Note, error)

SaveContent updates only the body and returns td's canonical updated note. Production deliberately performs one td invocation: `td note edit` already validates that the note exists and is live. The in-process test adapter must read the current title because the package API takes title and content.

func (*Store) ToggleArchive

func (s *Store) ToggleArchive(id string) error

ToggleArchive toggles the archived state of a note.

func (*Store) TogglePin

func (s *Store) TogglePin(id string) error

TogglePin toggles the pinned state of a note.

func (*Store) Unarchive

func (s *Store) Unarchive(id string) error

Unarchive sets archived=false for a note.

func (*Store) Update

func (s *Store) Update(note *Note) error

Update writes title and content. Pin/archive changes should use TogglePin / ToggleArchive — td's Update does not touch those flags.

func (*Store) UpdateContent

func (s *Store) UpdateContent(id, content string) error

UpdateContent updates the body of a note and leaves Title unchanged. Title is set at create time (NV query / first line); content-only saves must not clobber a title written via td note edit --title.

type TaskCreatedMsg

type TaskCreatedMsg struct {
	TaskID     string
	NoteID     string
	Err        error
	ArchiveErr error
	Epoch      uint64
}

TaskCreatedMsg is sent when a task is created from a note.

func (TaskCreatedMsg) GetEpoch

func (m TaskCreatedMsg) GetEpoch() uint64

GetEpoch returns the epoch for staleness detection.

type UndoAction

type UndoAction struct {
	Type   UndoActionType
	NoteID string
	Title  string // For toast message
}

UndoAction represents an undoable action.

type UndoActionType

type UndoActionType string

UndoActionType represents the type of undoable action.

const (
	UndoDelete  UndoActionType = "delete"
	UndoArchive UndoActionType = "archive"
)

Jump to

Keyboard shortcuts

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