2026-05-31 20:40:33 -07:00
|
|
|
//! list / health / journal — the Organizational + working-set surface (§6, §7).
|
|
|
|
|
|
feat(views): filter views (§8.2) — saved agenda slices
Make the owner's saved filters first-class so the agenda isn't one flat
list. `list` now takes a ListFilter predicate-as-data (heph-core::filter):
attention include/exclude sets, project-id scope, exclude_projects, and an
actionable do-date gate. New Store::view(name) resolves a built-in ViewSpec
— looking project names up to ids and subtree-expanding them through parent
links — then lists.
Five built-ins seeded from the Todoist queries (design §6.2.1): tom, ondeck,
chores, work, tasks (Schedule dropped — time-of-day isn't modeled on
date-grained do-dates). Surfaced as `heph view <name>` (no name lists them),
the `view` RPC + RemoteStore forward, and `:Heph view <name>` in nvim.
The list RPC/RemoteStore/CLI/heph.nvim migrate to the filter wire; legacy
--scope/--attention/--no-blue map onto it (nvim view.lua updated).
Tests: filter unit predicate, a views integration suite (subtree
scope+exclude, actionable gate, unknown-view error, absent-project empties),
a socket list/view dispatch test, two nvim e2e specs. 154 Rust tests + 18
nvim e2e green; clippy/fmt clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-03 06:39:07 -07:00
|
|
|
use heph_core::{Attention, FixedClock, ListFilter, LocalStore, NewTask, Store, TaskState};
|
2026-05-31 20:40:33 -07:00
|
|
|
|
|
|
|
|
fn store() -> LocalStore {
|
|
|
|
|
LocalStore::open_in_memory(Box::new(FixedClock(1_700_000_000_000))).unwrap()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn task(s: &mut LocalStore, title: &str, attention: Attention) -> String {
|
|
|
|
|
s.create_task(NewTask {
|
|
|
|
|
title: title.into(),
|
|
|
|
|
attention: Some(attention),
|
|
|
|
|
..Default::default()
|
|
|
|
|
})
|
|
|
|
|
.unwrap()
|
|
|
|
|
.node_id
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn list_enumerates_outstanding_including_blue_by_default() {
|
|
|
|
|
let mut s = store();
|
|
|
|
|
task(&mut s, "white", Attention::White);
|
|
|
|
|
task(&mut s, "blue", Attention::Blue);
|
|
|
|
|
let done = task(&mut s, "done", Attention::Red);
|
|
|
|
|
s.set_task_state(&done, TaskState::Done).unwrap();
|
|
|
|
|
|
|
|
|
|
// Default list: outstanding only, blue included; done excluded.
|
feat(views): filter views (§8.2) — saved agenda slices
Make the owner's saved filters first-class so the agenda isn't one flat
list. `list` now takes a ListFilter predicate-as-data (heph-core::filter):
attention include/exclude sets, project-id scope, exclude_projects, and an
actionable do-date gate. New Store::view(name) resolves a built-in ViewSpec
— looking project names up to ids and subtree-expanding them through parent
links — then lists.
Five built-ins seeded from the Todoist queries (design §6.2.1): tom, ondeck,
chores, work, tasks (Schedule dropped — time-of-day isn't modeled on
date-grained do-dates). Surfaced as `heph view <name>` (no name lists them),
the `view` RPC + RemoteStore forward, and `:Heph view <name>` in nvim.
The list RPC/RemoteStore/CLI/heph.nvim migrate to the filter wire; legacy
--scope/--attention/--no-blue map onto it (nvim view.lua updated).
Tests: filter unit predicate, a views integration suite (subtree
scope+exclude, actionable gate, unknown-view error, absent-project empties),
a socket list/view dispatch test, two nvim e2e specs. 154 Rust tests + 18
nvim e2e green; clippy/fmt clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-03 06:39:07 -07:00
|
|
|
let all = s.list(&ListFilter::default()).unwrap();
|
2026-05-31 20:40:33 -07:00
|
|
|
let titles: Vec<_> = all.iter().map(|t| t.attention.unwrap()).collect::<Vec<_>>();
|
|
|
|
|
assert_eq!(all.len(), 2);
|
|
|
|
|
assert!(titles.contains(&Attention::White));
|
|
|
|
|
assert!(titles.contains(&Attention::Blue));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn list_can_exclude_blue_and_filter_by_attention() {
|
|
|
|
|
let mut s = store();
|
|
|
|
|
task(&mut s, "white", Attention::White);
|
|
|
|
|
task(&mut s, "blue", Attention::Blue);
|
|
|
|
|
task(&mut s, "orange1", Attention::Orange);
|
|
|
|
|
task(&mut s, "orange2", Attention::Orange);
|
|
|
|
|
|
feat(views): filter views (§8.2) — saved agenda slices
Make the owner's saved filters first-class so the agenda isn't one flat
list. `list` now takes a ListFilter predicate-as-data (heph-core::filter):
attention include/exclude sets, project-id scope, exclude_projects, and an
actionable do-date gate. New Store::view(name) resolves a built-in ViewSpec
— looking project names up to ids and subtree-expanding them through parent
links — then lists.
Five built-ins seeded from the Todoist queries (design §6.2.1): tom, ondeck,
chores, work, tasks (Schedule dropped — time-of-day isn't modeled on
date-grained do-dates). Surfaced as `heph view <name>` (no name lists them),
the `view` RPC + RemoteStore forward, and `:Heph view <name>` in nvim.
The list RPC/RemoteStore/CLI/heph.nvim migrate to the filter wire; legacy
--scope/--attention/--no-blue map onto it (nvim view.lua updated).
Tests: filter unit predicate, a views integration suite (subtree
scope+exclude, actionable gate, unknown-view error, absent-project empties),
a socket list/view dispatch test, two nvim e2e specs. 154 Rust tests + 18
nvim e2e green; clippy/fmt clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-03 06:39:07 -07:00
|
|
|
let no_blue = ListFilter {
|
|
|
|
|
attention_not: vec![Attention::Blue],
|
|
|
|
|
..Default::default()
|
|
|
|
|
};
|
|
|
|
|
assert_eq!(s.list(&no_blue).unwrap().len(), 3); // blue excluded
|
|
|
|
|
let only_orange = ListFilter {
|
|
|
|
|
attention_in: vec![Attention::Orange],
|
|
|
|
|
..Default::default()
|
|
|
|
|
};
|
|
|
|
|
assert_eq!(s.list(&only_orange).unwrap().len(), 2);
|
2026-05-31 20:40:33 -07:00
|
|
|
}
|
|
|
|
|
|
heph.nvim: task views — next/list/capture/attention/state/log (slice 11b)
Backend: enrich `list` to return titled RankedTask rows (title +
canonical_context_id, via a shared ranked_from_row with `next`), so the
Organizational view needs no N+1 node.get. TDD: query_surface test asserts
list rows carry title + context id.
Plugin:
- view.lua: Tactical `next` + Organizational `list` rendered scratch buffers;
<CR> opens the row's canonical-context doc. Narrowed the node autocmd to
heph://node/* so view buffers (heph://next, heph://list) don't trip it.
- task.lua: capture, set-attention, done/drop, skip, per-task log append, all
resolving "the current task" from the buffer (a task node, or a context doc
via its canonical-context backlink).
- picker.lua: vim.ui.select with Telescope auto-upgrade (headless-safe).
- command.lua: :Heph next/list/capture/attention/done/drop/skip/log/search.
e2e: capture→next→open context→add/check checklist→done; recurring
fresh-checklist (complete rolls forward in place, next occurrence all-unchecked
— the §4.4 hard requirement). 6 specs green via `mise run test-nvim`.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-01 21:12:56 -07:00
|
|
|
#[test]
|
|
|
|
|
fn list_rows_carry_title_and_canonical_context() {
|
|
|
|
|
let mut s = store();
|
|
|
|
|
let id = task(&mut s, "Buy milk", Attention::Orange);
|
|
|
|
|
|
|
|
|
|
// The Organizational view needs titles + the one-keystroke context jump
|
|
|
|
|
// without an N+1 node.get (tech-spec §6, §8).
|
feat(views): filter views (§8.2) — saved agenda slices
Make the owner's saved filters first-class so the agenda isn't one flat
list. `list` now takes a ListFilter predicate-as-data (heph-core::filter):
attention include/exclude sets, project-id scope, exclude_projects, and an
actionable do-date gate. New Store::view(name) resolves a built-in ViewSpec
— looking project names up to ids and subtree-expanding them through parent
links — then lists.
Five built-ins seeded from the Todoist queries (design §6.2.1): tom, ondeck,
chores, work, tasks (Schedule dropped — time-of-day isn't modeled on
date-grained do-dates). Surfaced as `heph view <name>` (no name lists them),
the `view` RPC + RemoteStore forward, and `:Heph view <name>` in nvim.
The list RPC/RemoteStore/CLI/heph.nvim migrate to the filter wire; legacy
--scope/--attention/--no-blue map onto it (nvim view.lua updated).
Tests: filter unit predicate, a views integration suite (subtree
scope+exclude, actionable gate, unknown-view error, absent-project empties),
a socket list/view dispatch test, two nvim e2e specs. 154 Rust tests + 18
nvim e2e green; clippy/fmt clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-03 06:39:07 -07:00
|
|
|
let rows = s.list(&ListFilter::default()).unwrap();
|
heph.nvim: task views — next/list/capture/attention/state/log (slice 11b)
Backend: enrich `list` to return titled RankedTask rows (title +
canonical_context_id, via a shared ranked_from_row with `next`), so the
Organizational view needs no N+1 node.get. TDD: query_surface test asserts
list rows carry title + context id.
Plugin:
- view.lua: Tactical `next` + Organizational `list` rendered scratch buffers;
<CR> opens the row's canonical-context doc. Narrowed the node autocmd to
heph://node/* so view buffers (heph://next, heph://list) don't trip it.
- task.lua: capture, set-attention, done/drop, skip, per-task log append, all
resolving "the current task" from the buffer (a task node, or a context doc
via its canonical-context backlink).
- picker.lua: vim.ui.select with Telescope auto-upgrade (headless-safe).
- command.lua: :Heph next/list/capture/attention/done/drop/skip/log/search.
e2e: capture→next→open context→add/check checklist→done; recurring
fresh-checklist (complete rolls forward in place, next occurrence all-unchecked
— the §4.4 hard requirement). 6 specs green via `mise run test-nvim`.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-01 21:12:56 -07:00
|
|
|
assert_eq!(rows.len(), 1);
|
|
|
|
|
assert_eq!(rows[0].node_id, id);
|
|
|
|
|
assert_eq!(rows[0].title, "Buy milk");
|
|
|
|
|
assert!(rows[0].canonical_context_id.is_some());
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-31 20:40:33 -07:00
|
|
|
#[test]
|
|
|
|
|
fn list_scopes_to_a_project() {
|
|
|
|
|
let mut s = store();
|
|
|
|
|
let project = s
|
|
|
|
|
.create_node(heph_core::NewNode {
|
|
|
|
|
kind: heph_core::NodeKind::Project,
|
|
|
|
|
title: "Work".into(),
|
|
|
|
|
body: None,
|
|
|
|
|
})
|
|
|
|
|
.unwrap();
|
|
|
|
|
s.create_task(NewTask {
|
|
|
|
|
title: "work task".into(),
|
|
|
|
|
attention: Some(Attention::White),
|
|
|
|
|
project_id: Some(project.id.clone()),
|
|
|
|
|
..Default::default()
|
|
|
|
|
})
|
|
|
|
|
.unwrap();
|
|
|
|
|
task(&mut s, "life task", Attention::White);
|
|
|
|
|
|
feat(views): filter views (§8.2) — saved agenda slices
Make the owner's saved filters first-class so the agenda isn't one flat
list. `list` now takes a ListFilter predicate-as-data (heph-core::filter):
attention include/exclude sets, project-id scope, exclude_projects, and an
actionable do-date gate. New Store::view(name) resolves a built-in ViewSpec
— looking project names up to ids and subtree-expanding them through parent
links — then lists.
Five built-ins seeded from the Todoist queries (design §6.2.1): tom, ondeck,
chores, work, tasks (Schedule dropped — time-of-day isn't modeled on
date-grained do-dates). Surfaced as `heph view <name>` (no name lists them),
the `view` RPC + RemoteStore forward, and `:Heph view <name>` in nvim.
The list RPC/RemoteStore/CLI/heph.nvim migrate to the filter wire; legacy
--scope/--attention/--no-blue map onto it (nvim view.lua updated).
Tests: filter unit predicate, a views integration suite (subtree
scope+exclude, actionable gate, unknown-view error, absent-project empties),
a socket list/view dispatch test, two nvim e2e specs. 154 Rust tests + 18
nvim e2e green; clippy/fmt clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-03 06:39:07 -07:00
|
|
|
let scoped = ListFilter {
|
|
|
|
|
scope: vec![project.id.clone()],
|
|
|
|
|
..Default::default()
|
|
|
|
|
};
|
|
|
|
|
assert_eq!(s.list(&scoped).unwrap().len(), 1);
|
2026-05-31 20:40:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn health_counts_the_working_set_honestly() {
|
|
|
|
|
let mut s = store();
|
|
|
|
|
task(&mut s, "r", Attention::Red);
|
|
|
|
|
task(&mut s, "o1", Attention::Orange);
|
|
|
|
|
task(&mut s, "o2", Attention::Orange);
|
|
|
|
|
task(&mut s, "w", Attention::White);
|
|
|
|
|
task(&mut s, "b1", Attention::Blue);
|
|
|
|
|
task(&mut s, "b2", Attention::Blue);
|
|
|
|
|
|
|
|
|
|
let h = s.health().unwrap();
|
|
|
|
|
assert_eq!(h.orange_count, 2);
|
|
|
|
|
assert_eq!(h.active_count, 4); // red + 2 orange + white
|
|
|
|
|
assert_eq!(h.on_deck_count, 2); // 2 blue
|
|
|
|
|
assert_eq!(h.conflict_count, 0);
|
|
|
|
|
assert_eq!(h.sync_status, "local");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn journal_open_or_create_is_idempotent_with_deterministic_id() {
|
|
|
|
|
let mut s = store();
|
|
|
|
|
let a = s.journal_open_or_create("2026-05-31").unwrap();
|
|
|
|
|
let b = s.journal_open_or_create("2026-05-31").unwrap();
|
|
|
|
|
assert_eq!(a.id, b.id);
|
|
|
|
|
assert_eq!(a.kind, heph_core::NodeKind::Journal);
|
|
|
|
|
assert_eq!(a.title, "2026-05-31");
|
|
|
|
|
// The id is deterministic in (owner, date).
|
|
|
|
|
assert_eq!(
|
|
|
|
|
a.id,
|
|
|
|
|
heph_core::deterministic_id(s.owner_id(), heph_core::NodeKind::Journal, "2026-05-31")
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn journal_rejects_non_iso_dates() {
|
|
|
|
|
let mut s = store();
|
|
|
|
|
assert!(s.journal_open_or_create("May 31").is_err());
|
|
|
|
|
assert!(s.journal_open_or_create("2026-5-1").is_err());
|
|
|
|
|
}
|