2.6 KiB
TASK quick-capture-model: global-quick-capture first-task model
Runs through OpenCode (specs/agents/opencode-runbook.md attached automatically). Task 1 of specs/plugins-parity/global-quick-capture/tasks.md.
OWNS
crates/ui-egui/src/capture/model.rs(new, first write), unit tests inside it.crates/ui-egui/src/capture/mod.rs(new, module/re-export only).crates/ui-egui/src/lib.rs(declare capture module only).
FILES TO OPEN
specs/plugins-parity/global-quick-capture/spec.mdD1.crates/engine/src/capture/mod.rs(note.capture parameter names/caps).crates/ui-egui/src/shell/app/popout.rs(existing child window pattern; do not edit).
GOAL / API
Write crates/ui-egui/src/capture/model.rs in your SECOND tool call: compiling stub plus ONE failing test first. Batch at most three relevant reads in first call, then make test pass. Module declarations listed in OWNS make unit tests discoverable.
Implement pure Draft { text, title, target }, Target { Daily, Inbox } and CaptureState { Hidden, Editing, Saving, Failed } with explicit generation counter and matching completion. submit() validates then returns one note.capture params object/generation; while Saving it emits nothing. hide() preserves draft; discard() clears explicitly. Failure retains text and error; matching success clears; stale result cannot clear newer draft. Validate whitespace-only text, 1 MiB UTF-8 and title 200-character caps, reject over-limit rather than truncating. Report unsent draft for later quit confirmation. No native/window dependency needed.
TESTS
Valid Daily/Inbox params; empty/whitespace; exact 1 MiB/+1 and multibyte bytes; title 200/+1; double-submit one request; failed completion then retry; stale completion preserves newer generation; hide/reopen retains; explicit Discard clears; quit requires confirmation iff unsent draft.
VERIFY
export PATH="$HOME/.cargo/bin:$PATH"
cargo test -p notescraft-ui-egui capture::model
cargo clippy -p notescraft-ui-egui --all-targets -- -D warnings
rustfmt --edition 2024 crates/ui-egui/src/capture/model.rs
Format other owned Rust files individually too; no cargo fmt --all. Verification commands apply when implementing brief; current request is docs only.
DO NOT
Create viewport, register OS shortcuts or commands, do IO, read clipboard, persist draft, touch Cargo, add dependency. Native global-hotkey and Wayland binding approvals are later gates, not prerequisites for pure model. Do not edit outside OWNS, change Git state, commit, use unsafe, panic, unwrap/expect or input-derived indexing. No shared craft-libs API changes.