m4.5: lists first-class — create a checklist straight from quick-add
CI & Build / Python lint (push) Successful in 3s
CI & Build / TypeScript typecheck (push) Successful in 6s
CI & Build / Python tests (push) Successful in 9s
CI & Build / Build & push image (push) Successful in 34s

Checklist notes existed (M2) but could only be made by creating a text
note and toggling it in the editor — so they were undiscoverable. Now
the board's quick-add can make one in one shot.

- create endpoint accepts kind + items: POST /api/notes with
  kind:"list" and items:[...] creates a checklist note and its items
  atomically. A list note is non-empty when it has a title or ≥1 item.
- quick-add gets a checklist toggle (checkbox icon): flip it and each
  body line becomes an item on save; placeholder switches to
  "One item per line"; resets to a plain note after close.
- notes store create() accepts kind + items; parse_list_items() helper
  (trims, drops blanks) with a unit test.
- title placeholders now read "Title (optional)" in quick-add too.

Third item of M4.5. Display/editing of checklists was already built in
M2; this closes the creation gap.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FRgehjoz7Yv8LkUfADxACm
This commit is contained in:
2026-07-22 08:26:19 -04:00
co-authored by Claude Opus 4.8
parent 0ae02858f7
commit 80324fba3b
4 changed files with 74 additions and 7 deletions
+19 -2
View File
@@ -59,6 +59,13 @@ def is_empty_note(title: str | None, body: str | None) -> bool:
return not (title or "").strip() and not (body or "").strip()
def parse_list_items(raw: object) -> list[str]:
"""Trimmed, non-empty checklist item texts from a create payload's `items`."""
if not isinstance(raw, list):
return []
return [s.strip() for s in raw if isinstance(s, str) and s.strip()]
def normalize_color(color: object) -> str:
return color if color in NOTE_COLORS else "default"
@@ -387,7 +394,14 @@ async def create_note():
data = await request.get_json(silent=True) or {}
title = data.get("title") if isinstance(data.get("title"), str) else ""
body = data.get("body") if isinstance(data.get("body"), str) else ""
if is_empty_note(title, body):
kind = data.get("kind") if data.get("kind") in ("text", "list") else "text"
# A checklist note's "content" is its items, not the body — so it's non-empty
# when it has a title or at least one item (quick-add can create one in one shot).
item_texts = parse_list_items(data.get("items")) if kind == "list" else []
if kind == "list":
if not (title.strip() or item_texts):
return jsonify({"error": "note is empty"}), 400
elif is_empty_note(title, body):
return jsonify({"error": "note is empty"}), 400
async with session_scope() as db:
# New notes go to the top of the manual order.
@@ -402,11 +416,14 @@ async def create_note():
title=clean_title,
display_title=derive_display_title(clean_title, body),
body=body,
kind=kind,
color=normalize_color(data.get("color")),
position=int(max_pos) + 1,
)
db.add(note)
await db.flush() # assign note.id before writing links
await db.flush() # assign note.id before writing items/links
for pos, text in enumerate(item_texts):
db.add(NoteItem(note_id=note.id, text=text, position=pos))
await _rewrite_links(db, note)
await db.commit()
await db.refresh(note)