generated from eblume/project-template
Some checks failed
Build / validate (pull_request) Failing after 2s
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>
125 lines
3.9 KiB
Rust
125 lines
3.9 KiB
Rust
//! list / health / journal — the Organizational + working-set surface (§6, §7).
|
|
|
|
use heph_core::{Attention, FixedClock, LocalStore, NewTask, Store, TaskState};
|
|
|
|
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.
|
|
let all = s.list(None, None, true).unwrap();
|
|
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);
|
|
|
|
assert_eq!(s.list(None, None, false).unwrap().len(), 3); // blue excluded
|
|
assert_eq!(
|
|
s.list(None, Some(Attention::Orange), true).unwrap().len(),
|
|
2
|
|
);
|
|
}
|
|
|
|
#[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).
|
|
let rows = s.list(None, None, true).unwrap();
|
|
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());
|
|
}
|
|
|
|
#[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);
|
|
|
|
let scoped = s.list(Some(&project.id), None, true).unwrap();
|
|
assert_eq!(scoped.len(), 1);
|
|
}
|
|
|
|
#[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());
|
|
}
|