notes

package
v0.74.1 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 34 Imported by: 0

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. It checks for .td-root link file first, which points to a shared td root.

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 ActionType

type ActionType string

ActionType represents the type of action performed.

const (
	ActionCreate ActionType = "create"
	ActionUpdate ActionType = "update"
	ActionDelete ActionType = "delete"
)

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 FocusPane

type FocusPane int

FocusPane represents which pane is active.

const (
	PaneList FocusPane = iota
	PaneEditor
)

type InlineAutoSaveResultMsg

type InlineAutoSaveResultMsg struct {
	Err   error
	Epoch 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
}

InlineEditExitedMsg is sent when inline edit mode exits.

type InlineEditStartedMsg

type InlineEditStartedMsg struct {
	SessionName string
	NoteID      string
	NotePath    string
	Editor      string
}

InlineEditStartedMsg is sent when inline edit mode starts successfully.

type Note

type Note struct {
	ID        string     `json:"id"`
	Title     string     `json:"title"`
	Content   string     `json:"content"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	Pinned    bool       `json:"pinned"`
	Archived  bool       `json:"archived"`
	DeletedAt *time.Time `json:"deleted_at,omitempty"`
}

Note represents a single 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
}

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
}

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
	Epoch uint64
}

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) 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) FocusContext

func (p *Plugin) FocusContext() string

FocusContext returns the current focus context.

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) 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.

type Store

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

Store handles SQLite operations for notes.

func NewStore

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

NewStore creates a new Store with the given database path and session ID. If sessionID is empty, it checks TD_SESSION_ID env var, then falls back to "sidecar".

func (*Store) Close

func (s *Store) Close() error

Close closes the database connection.

func (*Store) Create

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

Create inserts a new note and logs the action.

func (*Store) Delete

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

Delete performs a soft delete and logs the action.

func (*Store) Get

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

Get retrieves a note by ID (excluding soft-deleted).

func (*Store) List

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

List retrieves all non-deleted notes, ordered by pinned then updated_at.

func (*Store) ListArchived

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

ListArchived retrieves only archived notes (not deleted), ordered by updated_at.

func (*Store) ListDeleted

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

ListDeleted retrieves only soft-deleted notes, ordered by deleted_at (most recent first).

func (*Store) NotePath

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

NotePath returns the path to the note file for external editor. Since notes are stored in SQLite, this creates a temporary file. Returns empty string if note doesn't exist or on error.

func (*Store) Restore

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

Restore undoes a soft delete by clearing deleted_at.

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 modifies an existing note and logs the action.

func (*Store) UpdateContent

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

UpdateContent updates the content of a note.

type TaskCreatedMsg

type TaskCreatedMsg struct {
	TaskID string
	NoteID string
	Err    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