@@ -656,6 +663,13 @@ onUnmounted(() => {
cursor: default;
}
+.chat-body {
+ flex: 1;
+ display: flex;
+ min-height: 0;
+ overflow: hidden;
+}
+
.messages-container {
flex: 1;
overflow-y: auto;
@@ -666,6 +680,68 @@ onUnmounted(() => {
margin: 0 auto;
width: 100%;
}
+
+.context-sidebar {
+ width: 220px;
+ min-width: 180px;
+ border-left: 1px solid var(--color-border);
+ background: var(--color-bg-secondary);
+ display: flex;
+ flex-direction: column;
+ padding: 0.75rem;
+ gap: 0.35rem;
+ overflow-y: auto;
+}
+.context-sidebar-header {
+ font-size: 0.7rem;
+ font-weight: 700;
+ text-transform: uppercase;
+ letter-spacing: 0.05em;
+ color: var(--color-text-muted);
+ margin-bottom: 0.25rem;
+}
+.context-note {
+ display: flex;
+ align-items: center;
+ gap: 0.3rem;
+ padding: 0.3rem 0.4rem;
+ border-radius: var(--radius-sm);
+ background: var(--color-bg-card);
+ border: 1px solid var(--color-border);
+ font-size: 0.82rem;
+}
+.context-note-pinned {
+ border-color: var(--color-primary);
+}
+.context-note-icon {
+ font-size: 0.75rem;
+ flex-shrink: 0;
+}
+.context-note-name {
+ flex: 1;
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ color: var(--color-text);
+ text-decoration: none;
+}
+.context-note-name:hover {
+ color: var(--color-primary);
+}
+.context-note-remove {
+ background: none;
+ border: none;
+ cursor: pointer;
+ color: var(--color-text-muted);
+ font-size: 1rem;
+ line-height: 1;
+ padding: 0 0.1rem;
+ flex-shrink: 0;
+}
+.context-note-remove:hover {
+ color: var(--color-danger, #e74c3c);
+}
.messages-inner {
margin-top: auto;
}
@@ -743,67 +819,6 @@ onUnmounted(() => {
50% { opacity: 1; }
}
-/* Context pills */
-.context-pills {
- display: flex;
- flex-wrap: wrap;
- align-items: center;
- gap: 0.35rem;
- padding: 0.5rem 0;
-}
-.context-pills-label {
- font-size: 0.75rem;
- color: var(--color-text-muted);
- font-weight: 600;
- text-transform: uppercase;
- letter-spacing: 0.03em;
-}
-.context-pill {
- display: inline-flex;
- align-items: center;
- gap: 0.15rem;
- background: var(--color-bg-secondary);
- border: 1px solid var(--color-border);
- border-radius: 12px;
- padding: 0.15rem 0.35rem 0.15rem 0.5rem;
- font-size: 0.8rem;
-}
-.context-pill-link {
- color: var(--color-primary);
- text-decoration: none;
- max-width: 150px;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-.context-pill-link:hover {
- text-decoration: underline;
-}
-.context-pill-btn {
- background: none;
- border: none;
- cursor: pointer;
- font-size: 0.85rem;
- line-height: 1;
- padding: 0 0.15rem;
- color: var(--color-text-muted);
- border-radius: 50%;
- width: 18px;
- height: 18px;
- display: flex;
- align-items: center;
- justify-content: center;
-}
-.context-pill-btn:hover {
- background: var(--color-border);
-}
-.context-pill-btn.promote:hover {
- color: var(--color-primary);
-}
-.context-pill-btn.exclude:hover {
- color: var(--color-danger, #e74c3c);
-}
-
/* Input wrapper */
.input-wrapper {
max-width: 960px;
@@ -813,33 +828,6 @@ onUnmounted(() => {
box-sizing: border-box;
}
-/* Attached note */
-.attached-note {
- padding: 0.25rem 0.5rem;
-}
-.attached-note-pill {
- display: inline-flex;
- align-items: center;
- gap: 0.25rem;
- background: var(--color-primary);
- color: #fff;
- border-radius: 12px;
- padding: 0.2rem 0.5rem;
- font-size: 0.8rem;
-}
-.attached-note-remove {
- background: none;
- border: none;
- color: rgba(255, 255, 255, 0.7);
- cursor: pointer;
- font-size: 1rem;
- line-height: 1;
- padding: 0 0.15rem;
-}
-.attached-note-remove:hover {
- color: #fff;
-}
-
/* Floating input bar */
.input-area {
display: flex;
@@ -1038,6 +1026,9 @@ onUnmounted(() => {
background: var(--color-overlay);
z-index: 99;
}
+ .context-sidebar {
+ display: none;
+ }
.messages-container {
padding: 0.75rem;
}
diff --git a/src/fabledassistant/routes/chat.py b/src/fabledassistant/routes/chat.py
index 6e71fc4..cbf95f2 100644
--- a/src/fabledassistant/routes/chat.py
+++ b/src/fabledassistant/routes/chat.py
@@ -23,6 +23,7 @@ from fabledassistant.services.generation_buffer import (
get_buffer,
)
from fabledassistant.services.generation_task import run_generation
+from fabledassistant.services.notes import get_notes_by_ids
from fabledassistant.services.settings import get_setting
logger = logging.getLogger(__name__)
@@ -62,7 +63,14 @@ async def get_conversation_route(conv_id: int):
if conv is None:
return jsonify({"error": "Conversation not found"}), 404
result = conv.to_dict()
- result["messages"] = [m.to_dict() for m in conv.messages]
+ note_ids = [m.context_note_id for m in conv.messages if m.context_note_id]
+ note_map = await get_notes_by_ids(uid, note_ids) if note_ids else {}
+ result["messages"] = []
+ for m in conv.messages:
+ msg_dict = m.to_dict()
+ if m.context_note_id and m.context_note_id in note_map:
+ msg_dict["context_note_title"] = note_map[m.context_note_id].title
+ result["messages"].append(msg_dict)
return jsonify(result)
diff --git a/src/fabledassistant/services/caldav.py b/src/fabledassistant/services/caldav.py
index ce8ac80..03abdc0 100644
--- a/src/fabledassistant/services/caldav.py
+++ b/src/fabledassistant/services/caldav.py
@@ -530,6 +530,21 @@ async def list_todos(
return await asyncio.to_thread(_list)
+async def search_todos(
+ user_id: int,
+ query: str,
+ include_completed: bool = False,
+ calendar_name: str | None = None,
+) -> list[dict]:
+ """Search CalDAV todos by keyword in summary or description."""
+ todos = await list_todos(user_id, include_completed=include_completed, calendar_name=calendar_name)
+ q = query.lower()
+ return [
+ t for t in todos
+ if q in t.get("summary", "").lower() or q in (t.get("description") or "").lower()
+ ]
+
+
async def complete_todo(
user_id: int,
query: str,
diff --git a/src/fabledassistant/services/generation_task.py b/src/fabledassistant/services/generation_task.py
index a34e5c4..17d8185 100644
--- a/src/fabledassistant/services/generation_task.py
+++ b/src/fabledassistant/services/generation_task.py
@@ -41,6 +41,10 @@ _TOOL_LABELS: dict[str, str] = {
"create_task": "Creating task",
"create_note": "Creating note",
"update_note": "Updating note",
+ "delete_note": "Deleting note",
+ "delete_task": "Deleting task",
+ "get_note": "Reading note",
+ "list_notes": "Listing notes",
"list_tasks": "Searching tasks",
"search_notes": "Searching notes",
"create_event": "Creating calendar event",
@@ -51,6 +55,7 @@ _TOOL_LABELS: dict[str, str] = {
"list_calendars": "Listing calendars",
"create_todo": "Creating todo",
"list_todos": "Listing todos",
+ "search_todos": "Searching todos",
"update_todo": "Updating todo",
"complete_todo": "Completing todo",
"delete_todo": "Removing todo",
@@ -58,7 +63,7 @@ _TOOL_LABELS: dict[str, str] = {
# Tools that write data and require explicit user confirmation before executing.
_WRITE_TOOLS: frozenset[str] = frozenset({
- "create_task", "create_note", "update_note",
+ "create_task", "create_note", "update_note", "delete_note", "delete_task",
"create_event", "update_event", "delete_event",
"create_todo", "update_todo", "complete_todo", "delete_todo",
})
@@ -68,8 +73,13 @@ _TOOL_ACTIONS: dict[str, str] = {
"create_task": "create a task",
"create_note": "create a new note",
"update_note": "update an existing note",
+ "delete_note": "permanently delete a note",
+ "delete_task": "permanently delete a task",
+ "get_note": "read a note",
+ "list_notes": "list notes",
"list_tasks": "look up tasks",
"search_notes": "search through notes",
+ "search_todos": "search calendar todos",
"create_event": "schedule a calendar event",
"list_events": "check the calendar",
"search_events": "search calendar events",
@@ -351,7 +361,7 @@ async def run_generation(
# Invalidate the note context cache after any successful note write
# so the next turn can pick up newly created/modified notes.
- if result.get("success") and tool_name in {"create_task", "create_note", "update_note"}:
+ if result.get("success") and tool_name in {"create_task", "create_note", "update_note", "delete_note", "delete_task"}:
clear_conv_note_cache(conv_id)
tool_record = {
@@ -422,7 +432,7 @@ async def run_generation(
timing["tools"].append({"name": tool_name, "ms": int((time.monotonic() - t_tool) * 1000)})
logger.info("Tool %s result: success=%s", tool_name, result.get("success"))
- if result.get("success") and tool_name in {"create_task", "create_note", "update_note"}:
+ if result.get("success") and tool_name in {"create_task", "create_note", "update_note", "delete_note", "delete_task"}:
clear_conv_note_cache(conv_id)
tool_record = {
diff --git a/src/fabledassistant/services/intent.py b/src/fabledassistant/services/intent.py
index 1fd897b..c54233d 100644
--- a/src/fabledassistant/services/intent.py
+++ b/src/fabledassistant/services/intent.py
@@ -89,10 +89,16 @@ Rules:
- "which calendars", "list calendars", "my calendars" → use list_calendars.
- "create a calendar todo", "add a CalDAV todo" → use create_todo. Default to create_task for general tasks unless the user explicitly mentions CalDAV or calendar todo.
- "show calendar todos", "list calendar todos" → use list_todos.
+- "find calendar todo", "search calendar todos", "find todo named X" → use search_todos with query=.
- "completed/finished calendar todo" → use complete_todo.
- "delete/remove calendar todo" → use delete_todo.
- "remind me X minutes/hours before" an event → convert to reminder_minutes parameter on create_event.
- When the user asks about events in a time period (e.g. "events in September", "what's on next week", "my schedule for March"), use list_events with date_from/date_to covering that period. Do NOT use search_events for time-based queries — search_events is only for keyword matching against event titles.
+- "delete", "remove", "trash", "get rid of" a note (not a task) → use delete_note with query=. NEVER use this for tasks.
+- "delete", "remove", "trash", "get rid of" a task → use delete_task with query=. NEVER use this for notes.
+- "read", "open", "show me", "what does X say", "display", "pull up" a specific note → use get_note with query=.
+- "list my notes", "show notes", "recent notes", "browse notes", "notes tagged X" → use list_notes (with optional q or tags).
+- "tag X with Y", "add tag Y to X", "untag Y from X", "remove tag Y from X" → use update_note with tags=[Y] and tag_mode="add" or "remove".
- Do NOT wrap the JSON in markdown code fences."""
diff --git a/src/fabledassistant/services/llm.py b/src/fabledassistant/services/llm.py
index ddd4bc6..b248db7 100644
--- a/src/fabledassistant/services/llm.py
+++ b/src/fabledassistant/services/llm.py
@@ -324,23 +324,27 @@ async def build_context(
tool_lines = [
"You have access to tool functions. You MUST use them when the user asks you to create, add, find, schedule, or search for anything.",
"CRITICAL: Call the tool functions directly. NEVER write out function calls as text or code. NEVER describe what you would do — just do it.",
- "Available actions: create_task, create_note, update_note, list_tasks, search_notes.",
+ "Available actions: create_task, create_note, update_note, delete_note, delete_task, get_note, list_notes, list_tasks, search_notes.",
]
if has_caldav:
tool_lines[-1] = (
- "Available actions: create_task, create_note, update_note, list_tasks, search_notes, "
+ "Available actions: create_task, create_note, update_note, delete_note, delete_task, get_note, list_notes, list_tasks, search_notes, "
"create_event, list_events, search_events, update_event, delete_event, "
- "list_calendars, create_todo, list_todos, update_todo, complete_todo, delete_todo."
+ "list_calendars, create_todo, list_todos, search_todos, update_todo, complete_todo, delete_todo."
)
tool_lines.append("For calendar events, use ISO 8601 datetime format (e.g. 2026-09-30T00:00:00).")
tool_lines.append("CalDAV todos are separate from app tasks. Use create_task for app tasks, create_todo for CalDAV todos.")
tool_lines.append("When the user says 'remind me' with a time before an event, use the reminder_minutes parameter.")
+ tool_lines.append("Use search_todos to find a specific CalDAV todo by keyword when list_todos would return too many results.")
tool_lines.append("For relative dates like 'Friday' or 'next week', resolve them to YYYY-MM-DD format.")
tool_lines.append(
"Use update_note to edit/expand an existing note OR to update a task's status/priority/due_date. "
"Use create_note ONLY for genuinely new notes with a different title. "
"Use list_tasks to find tasks by status, priority, or due date (e.g. overdue, high priority, in progress). "
- "If a note was created earlier in the conversation and the user provides more content for it, use update_note."
+ "If a note was created earlier in the conversation and the user provides more content for it, use update_note. "
+ "Use get_note to read the full content of a specific note. "
+ "Use list_notes to browse notes by recency or tag. "
+ "Use delete_note / delete_task only when explicitly asked to delete — these require confirmation."
)
tool_guidance = "\n".join(tool_lines)
diff --git a/src/fabledassistant/services/notes.py b/src/fabledassistant/services/notes.py
index eb834a5..4e63121 100644
--- a/src/fabledassistant/services/notes.py
+++ b/src/fabledassistant/services/notes.py
@@ -250,6 +250,17 @@ async def search_notes_for_context(
return list(result.scalars().all())
+async def get_notes_by_ids(user_id: int, note_ids: list[int]) -> dict[int, Note]:
+ """Batch fetch notes by ID list. Returns {note_id: Note}."""
+ if not note_ids:
+ return {}
+ async with async_session() as session:
+ result = await session.execute(
+ select(Note).where(Note.user_id == user_id, Note.id.in_(note_ids))
+ )
+ return {n.id: n for n in result.scalars().all()}
+
+
async def get_backlinks(user_id: int, note_id: int) -> list[dict]:
note = await get_note(user_id, note_id)
if note is None:
diff --git a/src/fabledassistant/services/tools.py b/src/fabledassistant/services/tools.py
index 1c29e84..463f3f1 100644
--- a/src/fabledassistant/services/tools.py
+++ b/src/fabledassistant/services/tools.py
@@ -15,10 +15,11 @@ from fabledassistant.services.caldav import (
list_events,
list_todos,
search_events,
+ search_todos,
update_event,
update_todo,
)
-from fabledassistant.services.notes import create_note, get_note_by_title, list_notes, update_note
+from fabledassistant.services.notes import create_note, delete_note, get_note_by_title, list_notes, update_note
from fabledassistant.services.tag_suggestions import suggest_tags
logger = logging.getLogger(__name__)
@@ -132,6 +133,16 @@ _CORE_TOOLS = [
"type": "string",
"description": "New due date in YYYY-MM-DD format",
},
+ "tags": {
+ "type": "array",
+ "items": {"type": "string"},
+ "description": "Tags to apply (see tag_mode for how they're applied)",
+ },
+ "tag_mode": {
+ "type": "string",
+ "enum": ["replace", "add", "remove"],
+ "description": "'replace' sets tags to exactly this list, 'add' appends without duplicates, 'remove' removes listed tags (default: replace)",
+ },
},
"required": ["query"],
},
@@ -149,6 +160,104 @@ _CORE_TOOLS = [
"type": "string",
"description": "Search query to find notes/tasks",
},
+ "type": {
+ "type": "string",
+ "enum": ["note", "task"],
+ "description": "Restrict results to only notes or only tasks. Omit to search both.",
+ },
+ },
+ "required": ["query"],
+ },
+ },
+ },
+ {
+ "type": "function",
+ "function": {
+ "name": "get_note",
+ "description": (
+ "Retrieve the full content of a specific note. Use this when the user asks to read, "
+ "view, or check what a particular note says. Returns the complete note body."
+ ),
+ "parameters": {
+ "type": "object",
+ "properties": {
+ "query": {
+ "type": "string",
+ "description": "Title or keyword to identify the note",
+ },
+ },
+ "required": ["query"],
+ },
+ },
+ },
+ {
+ "type": "function",
+ "function": {
+ "name": "list_notes",
+ "description": (
+ "Browse the user's notes (not tasks). Use this when the user asks to see, list, or browse "
+ "their notes — by recency, keyword, or tag. For tasks, use list_tasks instead."
+ ),
+ "parameters": {
+ "type": "object",
+ "properties": {
+ "q": {
+ "type": "string",
+ "description": "Optional keyword filter",
+ },
+ "tags": {
+ "type": "array",
+ "items": {"type": "string"},
+ "description": "Filter notes that have ALL of these tags",
+ },
+ "sort": {
+ "type": "string",
+ "enum": ["updated_at", "created_at", "title"],
+ "description": "Sort field (default: updated_at)",
+ },
+ "limit": {
+ "type": "integer",
+ "description": "Maximum number of notes to return (default 10)",
+ },
+ },
+ },
+ },
+ },
+ {
+ "type": "function",
+ "function": {
+ "name": "delete_note",
+ "description": (
+ "Delete a note permanently. Use ONLY when the user explicitly asks to delete or remove a note. "
+ "This action requires user confirmation and cannot be undone."
+ ),
+ "parameters": {
+ "type": "object",
+ "properties": {
+ "query": {
+ "type": "string",
+ "description": "Title or keyword to find the note to delete",
+ },
+ },
+ "required": ["query"],
+ },
+ },
+ },
+ {
+ "type": "function",
+ "function": {
+ "name": "delete_task",
+ "description": (
+ "Delete a task permanently. Use ONLY when the user explicitly asks to delete or remove a task. "
+ "This action requires user confirmation and cannot be undone."
+ ),
+ "parameters": {
+ "type": "object",
+ "properties": {
+ "query": {
+ "type": "string",
+ "description": "Title or keyword to find the task to delete",
+ },
},
"required": ["query"],
},
@@ -518,6 +627,34 @@ _CALDAV_TOOLS = [
},
},
},
+ {
+ "type": "function",
+ "function": {
+ "name": "search_todos",
+ "description": (
+ "Search CalDAV todos by keyword. Use this when the user asks to find a specific calendar todo "
+ "by name or content, rather than listing all todos."
+ ),
+ "parameters": {
+ "type": "object",
+ "properties": {
+ "query": {
+ "type": "string",
+ "description": "Keyword to search for in todo summary or description",
+ },
+ "include_completed": {
+ "type": "boolean",
+ "description": "Include completed todos in search (default false)",
+ },
+ "calendar_name": {
+ "type": "string",
+ "description": "Optional calendar name to restrict search",
+ },
+ },
+ "required": ["query"],
+ },
+ },
+ },
]
@@ -622,6 +759,21 @@ async def execute_tool(user_id: int, tool_name: str, arguments: dict) -> dict:
update_fields["priority"] = arguments["priority"]
if "due_date" in arguments:
update_fields["due_date"] = _parse_due_date(arguments["due_date"])
+ if "tags" in arguments:
+ new_tags = arguments["tags"]
+ if isinstance(new_tags, list):
+ tag_mode = arguments.get("tag_mode", "replace")
+ if tag_mode == "add":
+ existing = list(note.tags or [])
+ for t in new_tags:
+ if t not in existing:
+ existing.append(t)
+ update_fields["tags"] = existing
+ elif tag_mode == "remove":
+ existing = list(note.tags or [])
+ update_fields["tags"] = [t for t in existing if t not in new_tags]
+ else:
+ update_fields["tags"] = new_tags
updated = await update_note(user_id, note.id, **update_fields)
if updated is None:
@@ -673,7 +825,13 @@ async def execute_tool(user_id: int, tool_name: str, arguments: dict) -> dict:
elif tool_name == "search_notes":
query = arguments.get("query", "")
- notes, total = await list_notes(user_id=user_id, q=query, limit=5)
+ type_filter = arguments.get("type")
+ is_task: bool | None = None
+ if type_filter == "note":
+ is_task = False
+ elif type_filter == "task":
+ is_task = True
+ notes, total = await list_notes(user_id=user_id, q=query, is_task=is_task, limit=5)
results = []
for n in notes:
results.append({
@@ -859,6 +1017,110 @@ async def execute_tool(user_id: int, tool_name: str, arguments: dict) -> dict:
"data": result,
}
+ elif tool_name == "search_todos":
+ results = await search_todos(
+ user_id=user_id,
+ query=arguments.get("query", ""),
+ include_completed=bool(arguments.get("include_completed", False)),
+ calendar_name=arguments.get("calendar_name"),
+ )
+ return {
+ "success": True,
+ "type": "todos",
+ "data": {
+ "count": len(results),
+ "todos": results,
+ },
+ }
+
+ elif tool_name == "get_note":
+ query = arguments.get("query", "")
+ note = await get_note_by_title(user_id, query)
+ if note is None:
+ notes, _ = await list_notes(user_id=user_id, q=query, limit=3)
+ if not notes:
+ return {"success": False, "error": f"No note found matching '{query}'."}
+ note = notes[0]
+ return {
+ "success": True,
+ "type": "note_content",
+ "data": {
+ "id": note.id,
+ "title": note.title,
+ "body": note.body or "",
+ "tags": note.tags or [],
+ },
+ }
+
+ elif tool_name == "list_notes":
+ tags_raw = arguments.get("tags")
+ tags = tags_raw if isinstance(tags_raw, list) else None
+ notes, total = await list_notes(
+ user_id=user_id,
+ q=arguments.get("q") or arguments.get("query"),
+ tags=tags,
+ is_task=False,
+ sort=arguments.get("sort", "updated_at"),
+ order="desc",
+ limit=int(arguments.get("limit", 10)),
+ )
+ results = [
+ {
+ "id": n.id,
+ "title": n.title,
+ "tags": n.tags or [],
+ "preview": (n.body[:200] + "...") if n.body and len(n.body) > 200 else (n.body or ""),
+ }
+ for n in notes
+ ]
+ return {
+ "success": True,
+ "type": "notes_list",
+ "data": {
+ "total": total,
+ "count": len(results),
+ "results": results,
+ },
+ }
+
+ elif tool_name == "delete_note":
+ query = arguments.get("query", "")
+ note = await get_note_by_title(user_id, query)
+ if note is None:
+ notes, _ = await list_notes(user_id=user_id, q=query, is_task=False, limit=3)
+ if not notes:
+ return {"success": False, "error": f"No note found matching '{query}'."}
+ note = notes[0]
+ if note.status is not None:
+ return {"success": False, "error": f"'{note.title}' is a task. Use delete_task instead."}
+ deleted = await delete_note(user_id, note.id)
+ if not deleted:
+ return {"success": False, "error": "Failed to delete note."}
+ return {
+ "success": True,
+ "type": "note_deleted",
+ "data": {"id": note.id, "title": note.title},
+ }
+
+ elif tool_name == "delete_task":
+ query = arguments.get("query", "")
+ note = await get_note_by_title(user_id, query)
+ if note is None:
+ notes, _ = await list_notes(user_id=user_id, q=query, is_task=True, limit=3)
+ if not notes:
+ return {"success": False, "error": f"No task found matching '{query}'."}
+ note = notes[0]
+ if note.status is None:
+ return {"success": False, "error": f"'{note.title}' is a note. Use delete_note instead."}
+ deleted = await delete_note(user_id, note.id)
+ if not deleted:
+ return {"success": False, "error": "Failed to delete task."}
+ return {
+ "success": True,
+ "type": "task_deleted",
+ "data": {"id": note.id, "title": note.title},
+ }
+
else:
return {"success": False, "error": f"Unknown tool: {tool_name}"}
diff --git a/summary.md b/summary.md
index af1f59a..6466467 100644
--- a/summary.md
+++ b/summary.md
@@ -12,7 +12,7 @@
> Include file-level details in the commit body when the change is non-trivial.
## Last Updated
-2026-02-18 — Phase 11: streaming status transparency UX + model load state indicator
+2026-02-19 — Phase 12: persistent context sidebar, note title in chat, expanded tool suite
## Project Overview
Fabled Assistant is a self-hosted note-taking and task-tracking application with
@@ -207,6 +207,7 @@ for AI-assisted features.
- `context_note_id` tracks which note was attached as context when message was sent
- `tool_calls` stores an array of tool call records `[{function, arguments, result, status}]` for assistant messages that used tools
- `to_dict()` returns: `id`, `conversation_id`, `role`, `content`, `status`, `context_note_id`, `tool_calls`, `created_at`
+- `context_note_title` is NOT a DB column — it is synthesised at query time in `get_conversation_route` via a batch `get_notes_by_ids()` lookup and injected into the message dict so the frontend can display the note title without a separate fetch
## Project Structure (Current)
```
@@ -265,9 +266,9 @@ fabledassistant/
│ │ ├── generation_buffer.py # In-memory SSE event buffer with cancel_event, reconnect support, auto-cleanup; supports chat (int keys) and assist (string keys)
│ │ ├── generation_task.py # Background asyncio tasks: run_generation (chat, DB flush, titles, intent routing + tool loop) + run_assist_generation (lightweight, no DB)
│ │ ├── intent.py # Intent routing: classify_intent() makes fast non-streaming LLM call to detect tool intent before streaming
-│ │ ├── tools.py # LLM tool definitions (create_task, create_note, update_note, list_tasks, search_notes, full CalDAV suite incl. update_todo) + execute_tool dispatcher
+│ │ ├── tools.py # LLM tool definitions (create/delete note+task, update_note w/tag management, get_note, list_notes, search_notes w/type filter, list_tasks, full CalDAV suite incl. search_todos) + execute_tool dispatcher
│ │ ├── tag_suggestions.py # LLM-powered tag suggestions: suggest_tags() builds prompt with existing tags, calls generate_completion, parses JSON response
-│ │ ├── caldav.py # CalDAV integration: full event lifecycle (create/list/search/update/delete), todos (create/list/complete/delete), list_calendars, timezone (ZoneInfo), reminders (VALARM), attendees, multi-calendar search
+│ │ ├── caldav.py # CalDAV integration: full event lifecycle (create/list/search/update/delete), todos (create/list/search/update/complete/delete), list_calendars, timezone (ZoneInfo), reminders (VALARM), attendees, multi-calendar search
│ │ ├── settings.py # Settings CRUD with user_id isolation: get_setting, set_setting, set_settings_batch, get_all_settings
│ │ ├── logging.py # App logging: log_audit, log_usage, log_error, get_logs, get_log_stats, delete_old_logs, start_log_retention_loop
│ │ ├── email.py # SMTP email service: get_smtp_config, is_smtp_configured, send_email, send_test_email
@@ -320,7 +321,7 @@ fabledassistant/
│ │ ├── RegisterView.vue # Register form with password confirmation; shows "closed" message when registration disabled
│ │ ├── RegisterInviteView.vue # Invitation-based registration: validates token, creates account with pre-set email
│ │ ├── UserManagementView.vue # Admin user management: registration toggle, invitations (send/revoke), user list with delete
- │ │ ├── ChatView.vue # Dedicated /chat page: responsive sidebar (overlay on mobile), bubble messages, note picker, context pills, model selector in header
+ │ │ ├── ChatView.vue # Dedicated /chat page: responsive sidebar (overlay on mobile), bubble messages, note picker, persistent context sidebar (right panel, hidden mobile), model selector in header
│ │ ├── HomeView.vue # Actionable dashboard: overdue, due today, due this week, high priority, in progress tasks; recent chats with inline chat input; recently edited notes; model warming on mount
│ │ ├── SettingsView.vue # Settings page: assistant name, model catalog, data export/restore (admin)
│ │ ├── NotesListView.vue # Note list: search, sort, tag filter pills, pagination
@@ -335,7 +336,7 @@ fabledassistant/
│ │ ├── ChatPanel.vue # Slide-out chat panel (right side overlay, receives contextNoteId prop), bubble-style messages, floating dark input, note picker, context pills with promote/exclude
│ │ ├── ModelSelector.vue # Model dropdown (v-model pattern): fetches installed + running models, hot/cold indicators
│ │ ├── DashboardChatInput.vue # Inline chat bar: ModelSelector + note picker + textarea + send button; emits submit event
- │ │ ├── ToolCallCard.vue # Compact card for tool call results (created task/note link, search results, errors) + suggested tag pills with apply-on-click
+ │ │ ├── ToolCallCard.vue # Compact card for tool call results (created/deleted task/note, note content, notes list, search results, CalDAV events/todos, errors) + suggested tag pills with apply-on-click
│ │ ├── ChatMessage.vue # Message bubble: markdown rendering, tool call cards, configurable assistant name label, "Save as Note" action on assistant messages
│ │ ├── NoteCard.vue # Card with rendered markdown preview (v-html), TagPill, tag-click emit, hover edit button
│ │ ├── TaskCard.vue # Card with rendered preview (body not description), StatusBadge (clickable), PriorityBadge, due date, tags, hover edit button
@@ -542,7 +543,12 @@ When adding a new migration, follow these conventions:
- Background generation with `GenerationBuffer` (in-memory SSE fan-out, `Last-Event-ID` reconnect, 60s cleanup)
- Stop generation with partial content preservation
- Note-aware context building: current note + keyword search for related notes + URL fetching
-- Context pills with promote/exclude controls; note picker (paperclip) in chat input
+- **Persistent context sidebar:** Right panel in ChatView accumulates auto-found notes across turns.
+ Manually attached note appears with 📌 pin, clears after send. × excludes from future auto-search.
+ Hidden on mobile (≤768px). Replaces old ephemeral context pills in the message stream.
+- Note picker (paperclip) in chat input; attached note title passed to store for optimistic render.
+ `context_note_title` synthesised server-side at conversation load via batch `get_notes_by_ids()`;
+ message badge shows note title instead of "Note #N".
- LLM-generated conversation titles (re-generated every 10th message)
- Save assistant messages as notes (LLM-titled, chat-tagged); summarize conversations
- Dedicated `/chat` page with responsive sidebar + slide-out chat panel from header
@@ -573,12 +579,17 @@ When adding a new migration, follow these conventions:
Full tool suite:
- `create_task` / `create_note` — create new items
- `update_note` — edit note content (replace/append) AND update task fields: `status`, `priority`,
- `due_date`; finds by exact title first, falls back to fuzzy search; prevents duplicate notes
+ `due_date`, `tags` (with `tag_mode`: replace/add/remove); finds by exact title first, falls back to fuzzy search
+ - `delete_note` / `delete_task` — permanently delete (require user confirmation via confirm UI;
+ validates type so delete_note won't delete a task and vice versa; clears note context cache)
+ - `get_note` — retrieve full note body by title/keyword (search_notes only returns 200-char preview)
+ - `list_notes` — browse notes by recency/keyword/tags with configurable limit; notes only (use list_tasks for tasks)
- `list_tasks` — filter tasks by `status`, `priority`, `due_before`, `due_after`, `limit`;
backed by `list_notes(is_task=True)`; enables "overdue tasks", "high priority", "in progress" queries
- - `search_notes` — keyword search across notes and tasks
+ - `search_notes` — keyword search across notes and tasks; optional `type: "note"|"task"` filter
- Full CalDAV suite: `create_event`, `list_events`, `search_events`, `update_event`, `delete_event`,
- `list_calendars`, `create_todo`, `list_todos`, `update_todo`, `complete_todo`, `delete_todo`
+ `list_calendars`, `create_todo`, `list_todos`, `search_todos`, `update_todo`, `complete_todo`, `delete_todo`
+ (`search_todos` keyword-filters the todo list — companion to `list_todos`)
- **Streaming status transparency:** The backend emits `status` SSE events at each pipeline stage
so the user always sees what's happening instead of a blank progress dot. Stages:
(1) `"Analyzing your request..."` before intent classification; (2) human-readable tool label
@@ -597,11 +608,13 @@ When adding a new migration, follow these conventions:
Dedicated intent model configurable via `OLLAMA_INTENT_MODEL` env var or per-user `intent_model`
setting — allows a smaller/faster model for routing while the main model handles responses.
Intent router rules cover: update/delete events, CalDAV todos, time-period → list_events (not
- search_events), update_note vs create_note disambiguation, reminder_minutes conversion.
+ search_events), update_note vs create_note disambiguation, reminder_minutes conversion,
+ delete_note vs delete_task disambiguation, get_note for "read/show me this note", list_notes for
+ "browse/list notes", tag management via update_note (tag_mode add/remove), search_todos.
- **CalDAV calendar integration:** Per-user CalDAV settings (URL, username, password, calendar name, timezone).
LLM tools: `create_event` (all_day, recurrence, timezone, reminder_minutes, attendees, calendar_name),
`list_events`, `search_events`, `update_event`, `delete_event`, `list_calendars`,
- `create_todo`, `list_todos`, `complete_todo`, `delete_todo`.
+ `create_todo`, `list_todos`, `search_todos`, `update_todo`, `complete_todo`, `delete_todo`.
All-day events use iCalendar DATE values; recurrence uses RRULE (e.g. `FREQ=YEARLY`).
VALARM components added for reminders. Attendees via mailto: vCalAddress.
Multi-calendar search: when no specific calendar configured, all calendars are scanned.