Documentation
¶
Overview ¶
Package view persists named "smart views" — saved bundles of the `nt list` filter so a user can capture a query once and recall it by name (T4). Views live in $NT_DIR/views.json, a machine-managed file (like undo.jsonl), kept separate from the hand-edited, read-only config.toml so `nt view save` never rewrites a user's annotated config. The package is surface-agnostic: it knows only the filter shape, not how any front-end renders a list, so the CLI, TUI, and web can all share these specs.
Index ¶
- Constants
- func Apply(tasks []*task.Task, spec Spec, blocked map[string]bool) []*task.Task
- func Keep(t *task.Task, spec Spec, blocked map[string]bool) bool
- func Load(dir string) (map[string]Spec, error)
- func Names(views map[string]Spec) []string
- func Save(dir string, views map[string]Spec) error
- func SortTasks(rows []*task.Task, by string)
- func ValidName(s string) error
- type Spec
Constants ¶
const FileName = "views.json"
FileName is the views file's basename within $NT_DIR.
Variables ¶
This section is empty.
Functions ¶
func Apply ¶ added in v0.15.0
Apply selects and orders tasks per spec — the one shared implementation behind `nt list`, `nt view recall`, and the web's saved views, so the same named view can never filter differently on different surfaces (the drift the core audit warned about). blocked is the dependency-blocked id set (task.BlockedIDs) computed over the full document.
func Keep ¶ added in v0.15.0
Keep reports whether one task is selected by spec. An explicit Status matches the task's effective status (a dependency-blocked open task is "blocked"); otherwise the default-list visibility rule applies: done hides unless All, dependency-blocked hides unless All/ShowBlocked.
func Load ¶
Load reads $NT_DIR/views.json. A missing file yields an empty (non-nil) map and no error, so callers can treat "no views yet" as the normal first run.
func Save ¶
Save writes the view set atomically. An empty map is written as `{}` rather than removing the file, keeping the path stable.
Types ¶
type Spec ¶
type Spec struct {
Status string `json:"status,omitempty"`
Tag string `json:"tag,omitempty"`
Project string `json:"project,omitempty"`
Sort string `json:"sort,omitempty"`
All bool `json:"all,omitempty"`
ShowBlocked bool `json:"showBlocked,omitempty"`
Tree bool `json:"tree,omitempty"`
}
Spec is one saved view: the subset of `nt list` flags that select and order tasks. Output-only choices (e.g. --json) are deliberately excluded — they are a recall-time concern, not part of the saved query.