Skip to content

feat: add checkbox support to notes with show_checkbox schema flag#134

Merged
careck merged 16 commits into
masterfrom
feat/note-checkbox
Apr 17, 2026
Merged

feat: add checkbox support to notes with show_checkbox schema flag#134
careck merged 16 commits into
masterfrom
feat/note-checkbox

Conversation

@careck
Copy link
Copy Markdown
Member

@careck careck commented Apr 17, 2026

Summary

  • Add is_checked: bool to the Note struct as a first-class global field (like title), with DB migration, SetChecked operation variant for CRDT sync, and undo support
  • Add show_checkbox: bool schema flag — when set, TreeNode renders an interactive checkbox before the title with strikethrough styling for checked items
  • Add built-in TodoItem system script (show_checkbox: true, is_leaf: true, body textarea) as a ready-to-use checklist note type
  • Wire through full stack: Rust core → RBAC gate → Tauri command → React tree rendering → i18n (7 locales)

Test plan

  • 591 core tests pass (cargo test -p krillnotes-core)
  • TypeScript type check clean (npx tsc --noEmit)
  • TodoItem note shows checkbox in tree
  • Clicking checkbox toggles isChecked and shows strikethrough
  • Checkbox state persists after close/reopen
  • TextNote (no show_checkbox) has no checkbox
  • Undo reverts checkbox toggle
  • Export/import preserves is_checked state
  • Rhai script can read note.is_checked
  • User scripts with show_checkbox: true also get the checkbox

careck added 16 commits April 17, 2026 17:52
The 00_text_note.rhai library script was merged into
00_text_note.schema.rhai but test includes weren't updated.
Adds `is_checked: bool` to the Note struct with `#[serde(default)]`,
adds a DB migration for the `is_checked INTEGER NOT NULL DEFAULT 0`
column, updates schema.sql DDL, NoteRow tuple (13→14 elements),
map_note_row, note_from_row_tuple, and all 7 SELECT/INSERT statements
that feed or write note rows.
Add SetChecked to the Operation enum and wire it into all 7 match
methods (operation_id, timestamp, device_id, author_key,
set_author_key, set_signature, get_signature) plus operation_log
type name table. sync.rs match gaps are intentionally deferred to
Task 4.
Implements set_note_checked() that updates is_checked in the DB,
logs a SetChecked operation, signs it, and pushes a NoteRestore undo
entry. Extends NoteRestore with old_is_checked so undo and redo
correctly restore the checked state. Adds test_set_note_checked test
covering check, persist, uncheck, and undo.
Adds `show_checkbox: bool` to the Schema struct (parsed from the Rhai
map, defaults false). Exposes `is_checked` in both `build_note_map`
(live Note) and `pending_note_to_dynamic` (save-transaction context).
Add SetChecked handler to apply_remote_op, include is_checked in
CreateNote sync INSERT with default 0, add SetChecked to
operation_type_str, and include is_checked in export/import INSERT.
- Add set_note_checked command in commands/notes.rs (returns updated Note)
- Register in generate_handler! in lib.rs
- Add show_checkbox field to SchemaInfo struct and schema_to_info mapping
- Add isChecked to TS Note interface and showCheckbox to SchemaInfo
- Fix useSchema.ts mock objects to include showCheckbox
- Fix krillnotes-rbac gate.rs exhaustive match for SetChecked operation
Add interactive checkbox to TreeNode when schema.showCheckbox is true,
with strikethrough title styling for checked items; wire onToggleChecked
handler through WorkspaceView → TreeView → TreeNode; add i18n keys for
checkNote/uncheckNote in all 7 locale files.
The frontend persists the selected view tab name across note
selections. Using "Details" for TodoItem caused a mismatch when
switching between TextNote ("Content") and TodoItem.
Native <input type="checkbox"> with React controlled checked prop
doesn't reliably fire onChange when unchecking in Tauri's WKWebView.
Use a styled button with role="checkbox" instead.
Two bugs:
1. handleToggleChecked updated notes state but didn't rebuild the tree,
   so the TreeNode never saw the isChecked change.
2. activeTab wasn't reset synchronously when switching notes, causing
   render_view to fire with a stale view label for the new note type.
Effect 4 can fire in the same render cycle as Effect 1, before
setActiveTab('fields') takes effect. Guard by checking that activeTab
matches a loaded view for the current note before calling render_view.
…itch

State updates from Effect 1 (setActiveTab, setViews) don't take effect
until the next render, so Effect 4 fires in the same cycle with stale
values. A ref (viewsForNoteRef) is cleared synchronously at the top of
Effect 1 and only restored after the async view fetch, giving Effect 4
a reliable check that the views belong to the current note.
Adds `set_checked(note_id, checked)` to the Rhai scripting API so that
scripts can programmatically toggle the checkbox state during on_save hooks
and tree actions. Follows the existing set_title/set_field pattern using
PendingNote and the thread-local SaveTransaction.
@careck careck merged commit d0c7394 into master Apr 17, 2026
@careck careck deleted the feat/note-checkbox branch April 22, 2026 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant