Add CalDAV calendar integration, LLM-suggested tags, and settings refinements

- CalDAV integration: per-user calendar config, create/list/search events
  via caldav library, LLM tools for calendar operations from chat
- LLM-suggested tags: new tag_suggestions service prompts LLM with existing
  tags and note content to suggest 3-5 relevant tags; exposed via API
  endpoints (suggest-tags, append-tag); integrated into editor views
  (suggest button + clickable pills) and chat tool calls (pills in
  ToolCallCard with one-click apply)
- Settings/model UI refinements, generation task improvements

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-15 22:40:20 -05:00
parent 8996b45e50
commit d7bc3f3222
22 changed files with 1158 additions and 837 deletions
+179 -1
View File
@@ -1,11 +1,15 @@
<script setup lang="ts">
import { computed } from "vue";
import { computed, ref } from "vue";
import { apiPost } from "@/api/client";
import type { ToolCallRecord } from "@/types/chat";
const props = defineProps<{
toolCall: ToolCallRecord;
}>();
const appliedTags = ref<Set<string>>(new Set());
const applyingTag = ref<string | null>(null);
const label = computed(() => {
if (!props.toolCall.result.success) return "Error";
switch (props.toolCall.result.type) {
@@ -15,6 +19,10 @@ const label = computed(() => {
return "Created note";
case "search":
return "Searched notes";
case "event":
return "Created event";
case "events":
return "Found events";
default:
return "Tool call";
}
@@ -33,12 +41,70 @@ const linkTo = computed(() => {
return `/notes/${data.id}`;
});
const noteId = computed(() => {
const data = props.toolCall.result.data;
if (!data || typeof data.id !== "number") return null;
return data.id;
});
const suggestedTags = computed(() => {
return props.toolCall.result.suggested_tags ?? [];
});
const eventData = computed(() => {
const data = props.toolCall.result.data;
if (!data || props.toolCall.result.type !== "event") return null;
return data as { title: string; start: string; end: string };
});
const eventList = computed(() => {
const data = props.toolCall.result.data;
if (!data || props.toolCall.result.type !== "events") return null;
const events = data.events as Array<{ title: string; start: string; end: string; location?: string }> | undefined;
return events ?? [];
});
const eventCount = computed(() => {
const data = props.toolCall.result.data;
if (!data || props.toolCall.result.type !== "events") return 0;
return (data.count as number) ?? 0;
});
function formatEventTime(iso: string): string {
if (!iso) return "";
try {
const d = new Date(iso);
return d.toLocaleString(undefined, {
weekday: "short",
month: "short",
day: "numeric",
hour: "numeric",
minute: "2-digit",
});
} catch {
return iso;
}
}
const searchResults = computed(() => {
const data = props.toolCall.result.data;
if (!data || props.toolCall.result.type !== "search") return null;
const results = data.results as Array<{ id: number; title: string; type: string }> | undefined;
return results && results.length > 0 ? results : null;
});
async function applyTag(tag: string) {
if (!noteId.value || appliedTags.value.has(tag) || applyingTag.value) return;
applyingTag.value = tag;
try {
await apiPost(`/api/notes/${noteId.value}/append-tag`, { tag });
appliedTags.value.add(tag);
} catch {
// silently fail
} finally {
applyingTag.value = null;
}
}
</script>
<template>
@@ -60,9 +126,40 @@ const searchResults = computed(() => {
</router-link>
</div>
</template>
<template v-else-if="eventData">
<span class="tool-event-title">{{ eventData.title }}</span>
<span class="tool-event-time">{{ formatEventTime(eventData.start) }}</span>
</template>
<template v-else-if="eventList !== null">
<span class="tool-search-info">{{ eventCount }} found</span>
<div v-if="eventList.length > 0" class="tool-event-list">
<div v-for="(ev, i) in eventList.slice(0, 5)" :key="i" class="tool-event-item">
<span class="tool-event-item-title">{{ ev.title }}</span>
<span class="tool-event-item-time">{{ formatEventTime(ev.start) }}</span>
</div>
<div v-if="eventList.length > 5" class="tool-event-more">
+{{ eventList.length - 5 }} more
</div>
</div>
</template>
<template v-else-if="linkTo">
<router-link :to="linkTo" class="tool-link">{{ title }}</router-link>
</template>
<!-- Suggested tags pills -->
<div v-if="suggestedTags.length > 0" class="tag-suggestions">
<span class="tag-suggestions-label">Suggested tags:</span>
<button
v-for="tag in suggestedTags"
:key="tag"
:class="['tag-pill', { applied: appliedTags.has(tag) }]"
:disabled="appliedTags.has(tag) || applyingTag === tag"
@click="applyTag(tag)"
>
#{{ tag }}
<span v-if="appliedTags.has(tag)" class="tag-check">&#10003;</span>
</button>
</div>
</div>
</template>
@@ -121,4 +218,85 @@ const searchResults = computed(() => {
color: var(--color-text-muted);
margin-right: 0.1rem;
}
.tool-event-title {
font-weight: 600;
color: var(--color-text);
}
.tool-event-time {
color: var(--color-text-muted);
font-size: 0.75rem;
}
.tool-event-list {
display: flex;
flex-direction: column;
gap: 0.2rem;
width: 100%;
}
.tool-event-item {
display: flex;
justify-content: space-between;
align-items: baseline;
gap: 0.5rem;
}
.tool-event-item-title {
color: var(--color-text);
font-size: 0.8rem;
}
.tool-event-item-time {
color: var(--color-text-muted);
font-size: 0.75rem;
white-space: nowrap;
}
.tool-event-more {
color: var(--color-text-muted);
font-size: 0.75rem;
font-style: italic;
}
/* Tag suggestions */
.tag-suggestions {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 0.3rem;
width: 100%;
margin-top: 0.25rem;
padding-top: 0.3rem;
border-top: 1px solid var(--color-border);
}
.tag-suggestions-label {
font-size: 0.7rem;
color: var(--color-text-muted);
font-weight: 500;
}
.tag-pill {
display: inline-flex;
align-items: center;
gap: 0.2rem;
padding: 0.15rem 0.5rem;
border: 1px solid var(--color-primary);
border-radius: 999px;
background: transparent;
color: var(--color-primary);
font-size: 0.75rem;
cursor: pointer;
transition: background 0.15s, color 0.15s;
}
.tag-pill:hover:not(:disabled) {
background: var(--color-primary);
color: #fff;
}
.tag-pill.applied {
background: var(--color-success, #2ecc71);
border-color: var(--color-success, #2ecc71);
color: #fff;
cursor: default;
}
.tag-pill:disabled:not(.applied) {
opacity: 0.6;
cursor: wait;
}
.tag-check {
font-size: 0.65rem;
}
</style>