Add settings page, model management, and chat UX improvements

- Settings infrastructure: key-value settings table, GET/PUT API, Pinia store
- Configurable assistant name (default "Fable") in settings and LLM system prompt
- Model catalog with 18 models in 3 categories (General Purpose, Coding,
  Uncensored / Creative Writing) with download/select/remove functionality
- Move Ollama status indicator from chat views to global nav bar
- Chat bubble layout: user messages right-aligned, assistant left-aligned
- Floating dark input bar with auto-focus and circular send button
- Fix HTML entity rendering (' apostrophe issue in marked/DOMPurify pipeline)
- Fix new chat button navigation (fetchConversation before router.push)
- Recent chats section on home page with "New Chat" button
- Update summary.md with Phase 4.5 changes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-10 21:32:02 -05:00
parent 834fd80640
commit 38b1ac933e
20 changed files with 1257 additions and 236 deletions
+14 -1
View File
@@ -1,14 +1,18 @@
<script setup lang="ts">
import { ref, computed } from "vue";
import { ref, computed, onMounted, onUnmounted } from "vue";
import { useRoute } from "vue-router";
import AppHeader from "@/components/AppHeader.vue";
import ChatPanel from "@/components/ChatPanel.vue";
import ToastNotification from "@/components/ToastNotification.vue";
import { useTheme } from "@/composables/useTheme";
import { useChatStore } from "@/stores/chat";
import { useSettingsStore } from "@/stores/settings";
useTheme();
const route = useRoute();
const chatStore = useChatStore();
const settingsStore = useSettingsStore();
const chatPanelOpen = ref(false);
const contextNoteId = computed(() => {
@@ -24,6 +28,15 @@ const contextNoteId = computed(() => {
function toggleChatPanel() {
chatPanelOpen.value = !chatPanelOpen.value;
}
onMounted(() => {
chatStore.startStatusPolling();
settingsStore.fetchSettings();
});
onUnmounted(() => {
chatStore.stopStatusPolling();
});
</script>
<template>
+45
View File
@@ -1,11 +1,28 @@
<script setup lang="ts">
import { computed } from "vue";
import { useTheme } from "@/composables/useTheme";
import { useChatStore } from "@/stores/chat";
const { theme, toggleTheme } = useTheme();
const chatStore = useChatStore();
const emit = defineEmits<{
toggleChatPanel: [];
}>();
const statusLabel = computed(() => {
if (chatStore.ollamaStatus === "unavailable") return "Ollama unavailable";
if (chatStore.modelStatus === "not_found") return "Model downloading...";
if (chatStore.chatReady) return "Connected";
return "Checking...";
});
const statusClass = computed(() => {
if (chatStore.ollamaStatus === "unavailable") return "status-red";
if (chatStore.modelStatus === "not_found") return "status-yellow";
if (chatStore.chatReady) return "status-green";
return "status-yellow";
});
</script>
<template>
@@ -16,6 +33,10 @@ const emit = defineEmits<{
<router-link to="/notes" class="nav-link">Notes</router-link>
<router-link to="/tasks" class="nav-link">Tasks</router-link>
<router-link to="/chat" class="nav-link">Chat</router-link>
<router-link to="/settings" class="nav-link">Settings</router-link>
<span class="status-indicator" :class="statusClass" :title="statusLabel">
<span class="status-dot"></span>
</span>
<button class="btn-chat-panel" @click="emit('toggleChatPanel')" title="Open chat panel">
&#x1F4AC;
</button>
@@ -59,6 +80,30 @@ const emit = defineEmits<{
.nav-link:hover {
color: var(--color-primary);
}
.status-indicator {
display: flex;
align-items: center;
}
.status-dot {
width: 8px;
height: 8px;
border-radius: 50%;
flex-shrink: 0;
}
.status-green .status-dot {
background: #22c55e;
}
.status-yellow .status-dot {
background: #eab308;
animation: pulse-dot 2s infinite;
}
.status-red .status-dot {
background: #ef4444;
}
@keyframes pulse-dot {
0%, 100% { opacity: 1; }
50% { opacity: 0.4; }
}
.btn-chat-panel {
background: none;
border: 1px solid var(--color-border);
+76 -27
View File
@@ -1,8 +1,11 @@
<script setup lang="ts">
import { computed } from "vue";
import { renderMarkdown } from "@/utils/markdown";
import { useSettingsStore } from "@/stores/settings";
import type { Message } from "@/types/chat";
const settingsStore = useSettingsStore();
const props = defineProps<{
message: Message;
isStreaming?: boolean;
@@ -19,7 +22,7 @@ const roleLabel = computed(() => {
case "user":
return "You";
case "assistant":
return "Assistant";
return settingsStore.assistantName;
default:
return props.message.role;
}
@@ -28,39 +31,57 @@ const roleLabel = computed(() => {
<template>
<div class="chat-message" :class="`role-${message.role}`">
<div class="message-header">
<span class="role-label">{{ roleLabel }}</span>
<div class="message-actions" v-if="message.role === 'assistant' && !isStreaming">
<button class="btn-save" @click="emit('saveAsNote', message.id)" title="Save as note">
Save as Note
</button>
<div class="message-bubble">
<div class="message-header">
<span class="role-label">{{ roleLabel }}</span>
<div class="message-actions" v-if="message.role === 'assistant' && !isStreaming">
<button class="btn-save" @click="emit('saveAsNote', message.id)" title="Save as note">
Save as Note
</button>
</div>
</div>
<div class="message-content prose" v-html="rendered"></div>
<div
v-if="message.context_note_id"
class="context-badge"
>
<router-link :to="`/notes/${message.context_note_id}`">
Note #{{ message.context_note_id }}
</router-link>
</div>
</div>
<div class="message-content prose" v-html="rendered"></div>
<div
v-if="message.context_note_id"
class="context-badge"
>
<router-link :to="`/notes/${message.context_note_id}`">
Note #{{ message.context_note_id }}
</router-link>
</div>
</div>
</template>
<style scoped>
.chat-message {
padding: 0.75rem 1rem;
border-radius: 8px;
margin-bottom: 0.5rem;
display: flex;
margin-bottom: 0.75rem;
}
.role-user {
background: var(--color-bg-secondary);
justify-content: flex-end;
}
.role-assistant {
justify-content: flex-start;
}
.message-bubble {
max-width: 80%;
padding: 0.75rem 1rem;
border-radius: 16px;
}
.role-user .message-bubble {
background: var(--color-primary);
color: #fff;
border-bottom-right-radius: 4px;
}
.role-assistant .message-bubble {
background: var(--color-bg-card);
border: 1px solid var(--color-border);
border-bottom-left-radius: 4px;
}
.message-header {
display: flex;
align-items: center;
@@ -68,26 +89,51 @@ const roleLabel = computed(() => {
margin-bottom: 0.25rem;
}
.role-label {
font-size: 0.8rem;
font-size: 0.75rem;
font-weight: 600;
color: var(--color-text-muted);
text-transform: uppercase;
letter-spacing: 0.03em;
}
.role-user .role-label {
color: rgba(255, 255, 255, 0.7);
}
.role-assistant .role-label {
color: var(--color-text-muted);
}
.message-content {
font-size: 0.95rem;
line-height: 1.5;
line-height: 1.55;
word-break: break-word;
}
.message-content :deep(p:last-child) {
margin-bottom: 0;
}
/* User bubble content overrides for readability on primary bg */
.role-user .message-content :deep(a) {
color: rgba(255, 255, 255, 0.9);
text-decoration: underline;
}
.role-user .message-content :deep(code) {
background: rgba(255, 255, 255, 0.15);
color: #fff;
}
.role-user .message-content :deep(pre) {
background: rgba(0, 0, 0, 0.2);
}
.role-user .message-content :deep(blockquote) {
border-left-color: rgba(255, 255, 255, 0.4);
color: rgba(255, 255, 255, 0.85);
}
.message-actions {
display: flex;
gap: 0.5rem;
}
.btn-save {
font-size: 0.75rem;
padding: 0.15rem 0.5rem;
font-size: 0.7rem;
padding: 0.1rem 0.4rem;
background: transparent;
border: 1px solid var(--color-border);
border-radius: 4px;
@@ -100,13 +146,16 @@ const roleLabel = computed(() => {
border-color: var(--color-primary);
}
.context-badge {
margin-top: 0.5rem;
font-size: 0.8rem;
margin-top: 0.4rem;
font-size: 0.75rem;
}
.context-badge a {
color: var(--color-primary);
text-decoration: none;
}
.role-user .context-badge a {
color: rgba(255, 255, 255, 0.8);
}
.context-badge a:hover {
text-decoration: underline;
}
+64 -90
View File
@@ -1,6 +1,7 @@
<script setup lang="ts">
import { ref, computed, watch, nextTick, onMounted, onUnmounted } from "vue";
import { ref, computed, watch, nextTick } from "vue";
import { useChatStore } from "@/stores/chat";
import { useSettingsStore } from "@/stores/settings";
import { renderMarkdown } from "@/utils/markdown";
import ChatMessage from "@/components/ChatMessage.vue";
@@ -13,6 +14,7 @@ const emit = defineEmits<{
}>();
const store = useChatStore();
const settingsStore = useSettingsStore();
const messageInput = ref("");
const messagesEl = ref<HTMLElement | null>(null);
@@ -26,20 +28,6 @@ watch(
() => scrollToBottom()
);
const statusLabel = computed(() => {
if (store.ollamaStatus === "unavailable") return "Unavailable";
if (store.modelStatus === "not_found") return "Downloading...";
if (store.chatReady) return "Connected";
return "Checking...";
});
const statusClass = computed(() => {
if (store.ollamaStatus === "unavailable") return "status-red";
if (store.modelStatus === "not_found") return "status-yellow";
if (store.chatReady) return "status-green";
return "status-yellow";
});
function scrollToBottom() {
nextTick(() => {
if (messagesEl.value) {
@@ -48,14 +36,6 @@ function scrollToBottom() {
});
}
onMounted(() => {
store.startStatusPolling();
});
onUnmounted(() => {
store.stopStatusPolling();
});
async function sendMessage() {
const content = messageInput.value.trim();
if (!content || store.streaming) return;
@@ -96,10 +76,6 @@ function onInputKeydown(e: KeyboardEvent) {
<aside class="chat-panel">
<div class="panel-header">
<h3>Chat</h3>
<span class="status-indicator" :class="statusClass">
<span class="status-dot"></span>
{{ statusLabel }}
</span>
<span v-if="contextNoteId" class="context-indicator">
Note #{{ contextNoteId }}
</span>
@@ -115,13 +91,18 @@ function onInputKeydown(e: KeyboardEvent) {
@save-as-note="handleSaveAsNote"
/>
</template>
<div v-if="store.streaming" class="chat-message role-assistant streaming">
<div class="message-header">
<span class="role-label">Assistant</span>
<!-- Streaming bubble -->
<div v-if="store.streaming" class="chat-message role-assistant">
<div class="streaming-bubble">
<div class="message-header">
<span class="role-label">{{ settingsStore.assistantName }}</span>
</div>
<div class="message-content prose" v-html="streamingRendered"></div>
<span class="typing-indicator"></span>
</div>
<div class="message-content prose" v-html="streamingRendered"></div>
<span class="typing-indicator"></span>
</div>
<p
v-if="!store.currentConversation?.messages.length && !store.streaming"
class="empty-msg"
@@ -134,7 +115,7 @@ function onInputKeydown(e: KeyboardEvent) {
<textarea
v-model="messageInput"
@keydown="onInputKeydown"
:placeholder="store.chatReady ? 'Type a message...' : statusLabel"
:placeholder="store.chatReady ? 'Type a message...' : 'Chat unavailable'"
:disabled="store.streaming || !store.chatReady"
rows="2"
></textarea>
@@ -143,7 +124,7 @@ function onInputKeydown(e: KeyboardEvent) {
@click="sendMessage"
:disabled="!messageInput.trim() || store.streaming || !store.chatReady"
>
Send
&uarr;
</button>
</div>
</aside>
@@ -182,35 +163,6 @@ function onInputKeydown(e: KeyboardEvent) {
font-size: 1rem;
flex: 1;
}
.status-indicator {
display: flex;
align-items: center;
gap: 0.3rem;
font-size: 0.75rem;
color: var(--color-text-muted);
white-space: nowrap;
}
.status-dot {
width: 7px;
height: 7px;
border-radius: 50%;
flex-shrink: 0;
}
.status-green .status-dot {
background: #22c55e;
}
.status-yellow .status-dot {
background: #eab308;
animation: pulse-dot 2s infinite;
}
.status-red .status-dot {
background: #ef4444;
}
@keyframes pulse-dot {
0%, 100% { opacity: 1; }
50% { opacity: 0.4; }
}
.context-indicator {
font-size: 0.8rem;
color: var(--color-primary);
@@ -237,27 +189,37 @@ function onInputKeydown(e: KeyboardEvent) {
padding: 0.75rem;
}
.streaming {
border: 1px solid var(--color-border);
border-radius: 8px;
padding: 0.75rem 1rem;
background: var(--color-bg-card);
margin-bottom: 0.5rem;
/* Streaming bubble — matches ChatMessage assistant style */
.chat-message {
display: flex;
margin-bottom: 0.75rem;
}
.streaming .message-header {
.role-assistant {
justify-content: flex-start;
}
.streaming-bubble {
max-width: 90%;
padding: 0.75rem 1rem;
border-radius: 16px;
border-bottom-left-radius: 4px;
background: var(--color-bg-card);
border: 1px solid var(--color-border);
}
.streaming-bubble .message-header {
display: flex;
align-items: center;
margin-bottom: 0.25rem;
}
.streaming .role-label {
font-size: 0.8rem;
.streaming-bubble .role-label {
font-size: 0.75rem;
font-weight: 600;
color: var(--color-text-muted);
text-transform: uppercase;
letter-spacing: 0.03em;
}
.streaming .message-content {
.streaming-bubble .message-content {
font-size: 0.95rem;
line-height: 1.5;
line-height: 1.55;
word-break: break-word;
}
@@ -276,40 +238,52 @@ function onInputKeydown(e: KeyboardEvent) {
50% { opacity: 1; }
}
/* Dark floating input */
.panel-input {
display: flex;
align-items: flex-end;
gap: 0.5rem;
padding: 0.75rem;
border-top: 1px solid var(--color-border);
background: var(--color-bg-secondary);
margin: 0 0.5rem 0.5rem;
padding: 0.5rem 0.5rem 0.5rem 0.75rem;
background: #1c1c1e;
border-radius: 16px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.panel-input textarea {
flex: 1;
resize: none;
padding: 0.5rem;
border: 1px solid var(--color-border);
border-radius: 6px;
padding: 0.35rem 0.5rem;
border: none;
border-radius: 10px;
font-family: inherit;
font-size: 0.9rem;
background: var(--color-bg);
color: var(--color-text);
}
.panel-input textarea:focus {
background: transparent;
color: #fff;
outline: none;
border-color: var(--color-primary);
}
.panel-input textarea::placeholder {
color: rgba(255, 255, 255, 0.4);
}
.panel-input textarea:disabled {
opacity: 0.5;
}
.btn-send {
padding: 0.5rem 1rem;
width: 30px;
height: 30px;
padding: 0;
display: flex;
align-items: center;
justify-content: center;
background: var(--color-primary);
color: #fff;
border: none;
border-radius: 6px;
border-radius: 50%;
cursor: pointer;
font-size: 0.85rem;
align-self: flex-end;
font-size: 1rem;
flex-shrink: 0;
}
.btn-send:disabled {
opacity: 0.5;
opacity: 0.35;
cursor: default;
}
+5
View File
@@ -59,6 +59,11 @@ const router = createRouter({
name: "chat-conversation",
component: () => import("@/views/ChatView.vue"),
},
{
path: "/settings",
name: "settings",
component: () => import("@/views/SettingsView.vue"),
},
],
});
+69
View File
@@ -0,0 +1,69 @@
import { ref, computed } from "vue";
import { defineStore } from "pinia";
import { apiGet, apiPut, apiPost } from "@/api/client";
import type { AppSettings } from "@/types/settings";
export const useSettingsStore = defineStore("settings", () => {
const settings = ref<AppSettings>({});
const loading = ref(false);
const installedModels = ref<string[]>([]);
const assistantName = computed(
() => settings.value.assistant_name || "Fable"
);
const defaultModel = computed(
() => settings.value.default_model || ""
);
async function fetchSettings() {
loading.value = true;
try {
settings.value = await apiGet<AppSettings>("/api/settings");
} catch {
// Use defaults on error
} finally {
loading.value = false;
}
}
async function updateSettings(updates: AppSettings) {
loading.value = true;
try {
settings.value = await apiPut<AppSettings>("/api/settings", updates);
} finally {
loading.value = false;
}
}
async function fetchInstalledModels() {
try {
const data = await apiGet<{ models: { name: string }[] }>("/api/chat/models");
installedModels.value = data.models.map((m) => m.name);
} catch {
installedModels.value = [];
}
}
async function pullModel(model: string) {
await apiPost("/api/chat/models/pull", { model });
}
async function deleteModel(model: string) {
await apiPost("/api/chat/models/delete", { model });
await fetchInstalledModels();
}
return {
settings,
loading,
installedModels,
assistantName,
defaultModel,
fetchSettings,
updateSettings,
fetchInstalledModels,
pullModel,
deleteModel,
};
});
+13
View File
@@ -0,0 +1,13 @@
export interface AppSettings {
assistant_name?: string;
default_model?: string;
[key: string]: string | undefined;
}
export interface ModelInfo {
name: string;
description: string;
size: string;
bestFor: string;
category: string;
}
+15 -4
View File
@@ -2,20 +2,31 @@ import { marked } from "marked";
import DOMPurify from "dompurify";
import { linkifyTags, linkifyWikilinks } from "@/utils/tags";
function decodeEntities(text: string): string {
const textarea = document.createElement("textarea");
textarea.innerHTML = text;
return textarea.value;
}
export function renderMarkdown(text: string): string {
const html = marked(text) as string;
const decoded = decodeEntities(text);
const html = marked(decoded) as string;
const withTags = linkifyTags(html);
const withLinks = linkifyWikilinks(withTags);
return DOMPurify.sanitize(withLinks, {
const sanitized = DOMPurify.sanitize(withLinks, {
ADD_ATTR: ["data-tag", "data-title"],
});
// marked escapes ' to &#39; — replace after sanitization to ensure clean rendering
return sanitized.replace(/&#39;/g, "'");
}
export function renderPreview(text: string): string {
const html = marked(text) as string;
const decoded = decodeEntities(text);
const html = marked(decoded) as string;
const withTags = linkifyTags(html);
const withLinks = linkifyWikilinks(withTags);
return DOMPurify.sanitize(withLinks, {
const sanitized = DOMPurify.sanitize(withLinks, {
FORBID_TAGS: ["a", "img"],
});
return sanitized.replace(/&#39;/g, "'");
}
+77 -88
View File
@@ -1,16 +1,19 @@
<script setup lang="ts">
import { onMounted, onUnmounted, ref, computed, watch, nextTick } from "vue";
import { onMounted, ref, computed, watch, nextTick } from "vue";
import { useRoute, useRouter } from "vue-router";
import { useChatStore } from "@/stores/chat";
import { useSettingsStore } from "@/stores/settings";
import { renderMarkdown } from "@/utils/markdown";
import ChatMessage from "@/components/ChatMessage.vue";
const route = useRoute();
const router = useRouter();
const store = useChatStore();
const settingsStore = useSettingsStore();
const messageInput = ref("");
const messagesEl = ref<HTMLElement | null>(null);
const inputEl = ref<HTMLTextAreaElement | null>(null);
const sending = ref(false);
const summarizing = ref(false);
@@ -24,36 +27,17 @@ const streamingRendered = computed(() => {
return renderMarkdown(store.streamingContent);
});
const statusLabel = computed(() => {
if (store.ollamaStatus === "unavailable") return "Ollama unavailable";
if (store.modelStatus === "not_found") return "Model downloading...";
if (store.ollamaStatus === "available" && store.modelStatus === "ready")
return "Connected";
return "Checking...";
});
const statusClass = computed(() => {
if (store.ollamaStatus === "unavailable") return "status-red";
if (store.modelStatus === "not_found") return "status-yellow";
if (store.chatReady) return "status-green";
return "status-yellow";
});
const inputPlaceholder = computed(() => {
if (!store.chatReady) return `Chat unavailable${statusLabel.value}`;
if (!store.chatReady) return "Chat unavailable";
return "Type a message... (Enter to send, Shift+Enter for new line)";
});
onMounted(async () => {
store.startStatusPolling();
await store.fetchConversations();
if (convId.value) {
await store.fetchConversation(convId.value);
}
});
onUnmounted(() => {
store.stopStatusPolling();
nextTick(() => inputEl.value?.focus());
});
watch(convId, async (newId) => {
@@ -63,6 +47,7 @@ watch(convId, async (newId) => {
} else {
store.currentConversation = null;
}
nextTick(() => inputEl.value?.focus());
});
watch(
@@ -84,6 +69,7 @@ async function selectConversation(id: number) {
async function newConversation() {
const conv = await store.createConversation();
await store.fetchConversation(conv.id);
router.push(`/chat/${conv.id}`);
}
@@ -115,6 +101,7 @@ async function sendMessage() {
// Refresh conversation list to show updated title/timestamps
store.fetchConversations();
scrollToBottom();
nextTick(() => inputEl.value?.focus());
}
async function handleSaveAsNote(messageId: number) {
@@ -184,10 +171,6 @@ function onInputKeydown(e: KeyboardEvent) {
<template v-if="store.currentConversation">
<div class="chat-header">
<h2>{{ store.currentConversation.title || "New Chat" }}</h2>
<span class="status-indicator" :class="statusClass">
<span class="status-dot"></span>
{{ statusLabel }}
</span>
<button
v-if="store.currentConversation.messages.length"
class="btn-summarize"
@@ -205,13 +188,18 @@ function onInputKeydown(e: KeyboardEvent) {
:message="msg"
@save-as-note="handleSaveAsNote"
/>
<div v-if="store.streaming" class="chat-message role-assistant streaming">
<div class="message-header">
<span class="role-label">Assistant</span>
<!-- Streaming message (assistant typing) -->
<div v-if="store.streaming" class="chat-message role-assistant">
<div class="message-bubble streaming-bubble">
<div class="message-header">
<span class="role-label">{{ settingsStore.assistantName }}</span>
</div>
<div class="message-content prose" v-html="streamingRendered"></div>
<span class="typing-indicator"></span>
</div>
<div class="message-content prose" v-html="streamingRendered"></div>
<span class="typing-indicator"></span>
</div>
<p
v-if="!store.currentConversation.messages.length && !store.streaming"
class="empty-msg"
@@ -222,6 +210,7 @@ function onInputKeydown(e: KeyboardEvent) {
<div class="input-area">
<textarea
ref="inputEl"
v-model="messageInput"
@keydown="onInputKeydown"
:placeholder="inputPlaceholder"
@@ -233,7 +222,7 @@ function onInputKeydown(e: KeyboardEvent) {
@click="sendMessage"
:disabled="!messageInput.trim() || store.streaming || !store.chatReady"
>
Send
&uarr;
</button>
</div>
</template>
@@ -344,34 +333,6 @@ function onInputKeydown(e: KeyboardEvent) {
text-overflow: ellipsis;
white-space: nowrap;
}
.status-indicator {
display: flex;
align-items: center;
gap: 0.35rem;
font-size: 0.8rem;
color: var(--color-text-muted);
white-space: nowrap;
}
.status-dot {
width: 8px;
height: 8px;
border-radius: 50%;
flex-shrink: 0;
}
.status-green .status-dot {
background: #22c55e;
}
.status-yellow .status-dot {
background: #eab308;
animation: pulse-dot 2s infinite;
}
.status-red .status-dot {
background: #ef4444;
}
@keyframes pulse-dot {
0%, 100% { opacity: 1; }
50% { opacity: 0.4; }
}
.btn-summarize {
padding: 0.3rem 0.75rem;
@@ -396,30 +357,40 @@ function onInputKeydown(e: KeyboardEvent) {
.messages-container {
flex: 1;
overflow-y: auto;
padding: 1rem;
padding: 1rem 1.5rem;
}
.streaming {
border: 1px solid var(--color-border);
border-radius: 8px;
padding: 0.75rem 1rem;
background: var(--color-bg-card);
margin-bottom: 0.5rem;
/* Streaming bubble — matches ChatMessage assistant style */
.chat-message {
display: flex;
margin-bottom: 0.75rem;
}
.streaming .message-header {
.role-assistant {
justify-content: flex-start;
}
.streaming-bubble {
max-width: 80%;
padding: 0.75rem 1rem;
border-radius: 16px;
border-bottom-left-radius: 4px;
background: var(--color-bg-card);
border: 1px solid var(--color-border);
}
.streaming-bubble .message-header {
display: flex;
align-items: center;
margin-bottom: 0.25rem;
}
.streaming .role-label {
font-size: 0.8rem;
.streaming-bubble .role-label {
font-size: 0.75rem;
font-weight: 600;
color: var(--color-text-muted);
text-transform: uppercase;
letter-spacing: 0.03em;
}
.streaming .message-content {
.streaming-bubble .message-content {
font-size: 0.95rem;
line-height: 1.5;
line-height: 1.55;
word-break: break-word;
}
@@ -438,40 +409,52 @@ function onInputKeydown(e: KeyboardEvent) {
50% { opacity: 1; }
}
/* Floating dark input bar */
.input-area {
display: flex;
align-items: flex-end;
gap: 0.5rem;
padding: 0.75rem 1rem;
border-top: 1px solid var(--color-border);
background: var(--color-bg-secondary);
margin: 0 1rem 0.75rem;
padding: 0.5rem 0.5rem 0.5rem 0.75rem;
background: #1c1c1e;
border-radius: 20px;
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}
.input-area textarea {
flex: 1;
resize: none;
padding: 0.5rem 0.75rem;
border: 1px solid var(--color-border);
border-radius: 6px;
padding: 0.4rem 0.5rem;
border: none;
border-radius: 12px;
font-family: inherit;
font-size: 0.95rem;
background: var(--color-bg);
color: var(--color-text);
}
.input-area textarea:focus {
background: transparent;
color: #fff;
outline: none;
border-color: var(--color-primary);
}
.input-area textarea::placeholder {
color: rgba(255, 255, 255, 0.4);
}
.input-area textarea:disabled {
opacity: 0.5;
}
.btn-send {
padding: 0.5rem 1.25rem;
width: 34px;
height: 34px;
padding: 0;
display: flex;
align-items: center;
justify-content: center;
background: var(--color-primary);
color: #fff;
border: none;
border-radius: 6px;
border-radius: 50%;
cursor: pointer;
font-size: 0.9rem;
align-self: flex-end;
font-size: 1.1rem;
flex-shrink: 0;
}
.btn-send:disabled {
opacity: 0.5;
opacity: 0.35;
cursor: default;
}
@@ -497,5 +480,11 @@ function onInputKeydown(e: KeyboardEvent) {
width: 200px;
min-width: 160px;
}
.messages-container {
padding: 0.75rem;
}
.input-area {
margin: 0 0.5rem 0.5rem;
}
}
</style>
+77
View File
@@ -1,15 +1,20 @@
<script setup lang="ts">
import { ref, onMounted } from "vue";
import { useRouter } from "vue-router";
import { apiGet } from "@/api/client";
import type { Note, NoteListResponse } from "@/types/note";
import type { Task, TaskListResponse } from "@/types/task";
import type { Conversation } from "@/types/chat";
import NoteCard from "@/components/NoteCard.vue";
import TaskCard from "@/components/TaskCard.vue";
import type { TaskStatus } from "@/types/task";
import { useTasksStore } from "@/stores/tasks";
import { useChatStore } from "@/stores/chat";
const router = useRouter();
const recentNotes = ref<Note[]>([]);
const recentTasks = ref<Task[]>([]);
const recentChats = ref<Conversation[]>([]);
const loading = ref(true);
const tasksStore = useTasksStore();
@@ -32,6 +37,15 @@ onMounted(async () => {
console.error("Failed to load recent tasks:", e);
}
try {
const chatData = await apiGet<{ conversations: Conversation[]; total: number }>(
"/api/chat/conversations?limit=3&offset=0"
);
recentChats.value = chatData.conversations;
} catch (e) {
console.error("Failed to load recent chats:", e);
}
loading.value = false;
});
@@ -43,6 +57,13 @@ function onStatusToggle(id: number, status: TaskStatus) {
}
});
}
async function newChat() {
const chatStore = useChatStore();
const conv = await chatStore.createConversation();
await chatStore.fetchConversation(conv.id);
router.push(`/chat/${conv.id}`);
}
</script>
<template>
@@ -52,6 +73,28 @@ function onStatusToggle(id: number, status: TaskStatus) {
<p v-if="loading" class="loading">Loading...</p>
<template v-else>
<section class="section">
<div class="section-header">
<h2>Recent Chats</h2>
<router-link to="/chat" class="see-all">See all</router-link>
</div>
<div v-if="recentChats.length" class="cards">
<router-link
v-for="chat in recentChats"
:key="chat.id"
:to="`/chat/${chat.id}`"
class="chat-card"
>
<span class="chat-card-title">{{ chat.title || "Untitled" }}</span>
<span class="chat-card-meta">{{ chat.message_count }} messages</span>
</router-link>
</div>
<div v-else class="empty-state">
<p class="empty-text">No chats yet.</p>
</div>
<button class="btn-cta btn-new-chat" @click="newChat">+ New Chat</button>
</section>
<section class="section">
<div class="section-header">
<h2>Recent Notes</h2>
@@ -130,6 +173,38 @@ function onStatusToggle(id: number, status: TaskStatus) {
flex-direction: column;
gap: 0.75rem;
}
.chat-card {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0.75rem 1rem;
background: var(--color-bg-card);
border: 1px solid var(--color-border);
border-radius: 8px;
text-decoration: none;
color: var(--color-text);
transition: border-color 0.15s;
}
.chat-card:hover {
border-color: var(--color-primary);
}
.chat-card-title {
font-size: 0.95rem;
font-weight: 500;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
flex: 1;
margin-right: 1rem;
}
.chat-card-meta {
font-size: 0.8rem;
color: var(--color-text-muted);
white-space: nowrap;
}
.btn-new-chat {
margin-top: 0.75rem;
}
.empty-state {
text-align: center;
padding: 1.5rem 0;
@@ -143,8 +218,10 @@ function onStatusToggle(id: number, status: TaskStatus) {
padding: 0.4rem 1rem;
background: var(--color-primary);
color: #fff;
border: none;
border-radius: 4px;
text-decoration: none;
font-size: 0.9rem;
cursor: pointer;
}
</style>
+607
View File
@@ -0,0 +1,607 @@
<script setup lang="ts">
import { ref, computed, onMounted } from "vue";
import { useSettingsStore } from "@/stores/settings";
import type { ModelInfo } from "@/types/settings";
const store = useSettingsStore();
const assistantName = ref("");
const saving = ref(false);
const saved = ref(false);
const pulling = ref<string | null>(null);
const deleting = ref<string | null>(null);
const confirmDelete = ref<string | null>(null);
const MODEL_CATALOG: ModelInfo[] = [
// — General Purpose —
{
name: "llama3.1",
description: "Meta's Llama 3.1 8B — strong general-purpose model with good instruction following.",
size: "4.7 GB",
bestFor: "General chat, writing, Q&A",
category: "General Purpose",
},
{
name: "llama3.1:70b",
description: "Meta's Llama 3.1 70B — significantly more capable, better reasoning and nuance.",
size: "40 GB",
bestFor: "Complex reasoning, detailed analysis",
category: "General Purpose",
},
{
name: "mistral",
description: "Mistral 7B — fast and efficient with strong performance for its size.",
size: "4.1 GB",
bestFor: "Fast responses, general tasks",
category: "General Purpose",
},
{
name: "gemma2",
description: "Google's Gemma 2 9B — well-rounded model strong in reasoning and conversation.",
size: "5.4 GB",
bestFor: "Conversation, reasoning, summarization",
category: "General Purpose",
},
{
name: "qwen2.5",
description: "Alibaba's Qwen 2.5 7B — multilingual model with strong coding and math skills.",
size: "4.7 GB",
bestFor: "Multilingual, code, math",
category: "General Purpose",
},
{
name: "phi3",
description: "Microsoft Phi-3 Mini — compact model with surprising capability for its size.",
size: "2.3 GB",
bestFor: "Light tasks, low resource usage",
category: "General Purpose",
},
{
name: "neural-chat",
description: "Intel's fine-tune optimized for natural conversation. Lighter filtering than base models.",
size: "4.1 GB",
bestFor: "Natural conversation, general tasks",
category: "General Purpose",
},
{
name: "yi",
description: "01.AI's Yi 6B — Chinese-developed model, more permissive on creative content.",
size: "3.5 GB",
bestFor: "Creative content, multilingual",
category: "General Purpose",
},
{
name: "command-r",
description: "Cohere's Command R 35B — enterprise-grade model with light content filtering.",
size: "20 GB",
bestFor: "RAG, conversation, creative tasks",
category: "General Purpose",
},
// — Coding —
{
name: "codellama",
description: "Meta's Code Llama — specialized for code generation and understanding.",
size: "3.8 GB",
bestFor: "Code generation, debugging, technical docs",
category: "Coding",
},
{
name: "deepseek-coder-v2",
description: "DeepSeek Coder V2 — state-of-the-art coding model with strong math ability.",
size: "8.9 GB",
bestFor: "Code, math, technical problem solving",
category: "Coding",
},
// — Uncensored / Creative Writing —
{
name: "dolphin-mistral",
description: "Eric Hartford's Dolphin fine-tune of Mistral 7B. Safety/refusal data removed from training.",
size: "4.1 GB",
bestFor: "Uncensored general chat, creative writing",
category: "Uncensored / Creative Writing",
},
{
name: "dolphin-llama3",
description: "Dolphin fine-tune of Llama 3 8B. Uncensored training on a stronger base model.",
size: "4.7 GB",
bestFor: "Uncensored chat, strong reasoning",
category: "Uncensored / Creative Writing",
},
{
name: "dolphin-mixtral",
description: "Dolphin fine-tune of Mixtral 8x7B MoE. Uncensored with mixture-of-experts architecture.",
size: "26 GB",
bestFor: "Uncensored + high capability (needs RAM)",
category: "Uncensored / Creative Writing",
},
{
name: "nous-hermes2",
description: "Nous Research's Hermes 2 — trained on diverse synthetic data with minimal refusal behavior.",
size: "4.1 GB",
bestFor: "Instruction following, few refusals",
category: "Uncensored / Creative Writing",
},
{
name: "openhermes",
description: "Community fine-tune focused on helpfulness. Based on Mistral 7B without refusal patterns.",
size: "4.1 GB",
bestFor: "Helpful assistant, minimal filtering",
category: "Uncensored / Creative Writing",
},
{
name: "mythomist",
description: "A 7B model specifically tuned for creative and narrative writing including mature themes.",
size: "4.1 GB",
bestFor: "Creative fiction, narrative writing",
category: "Uncensored / Creative Writing",
},
{
name: "samantha-mistral",
description: "Eric Hartford's Samantha personality model. Designed as a helpful companion without refusals.",
size: "4.1 GB",
bestFor: "Companion chat, unrestricted conversation",
category: "Uncensored / Creative Writing",
},
];
const selectedModel = ref("");
const modelStatuses = computed(() => {
const installed = new Set(
store.installedModels.map((m) => m.replace(/:latest$/, ""))
);
return MODEL_CATALOG.map((m) => ({
...m,
installed: installed.has(m.name) || installed.has(m.name.replace(/:.*$/, "")),
active: isActiveModel(m.name),
}));
});
const categories = computed(() => {
const cats: string[] = [];
for (const m of modelStatuses.value) {
if (!cats.includes(m.category)) cats.push(m.category);
}
return cats;
});
function modelsInCategory(category: string) {
return modelStatuses.value.filter((m) => m.category === category);
}
function isActiveModel(name: string): boolean {
const current = selectedModel.value || store.defaultModel;
if (!current) return false;
const clean = current.replace(/:latest$/, "");
return clean === name || clean === name.replace(/:.*$/, "");
}
onMounted(async () => {
await store.fetchSettings();
assistantName.value = store.assistantName;
selectedModel.value = store.defaultModel;
store.fetchInstalledModels();
});
async function saveAssistant() {
saving.value = true;
saved.value = false;
try {
await store.updateSettings({ assistant_name: assistantName.value.trim() || "Fable" });
saved.value = true;
setTimeout(() => (saved.value = false), 2000);
} finally {
saving.value = false;
}
}
async function selectModel(name: string) {
selectedModel.value = name;
saving.value = true;
try {
await store.updateSettings({ default_model: name });
} finally {
saving.value = false;
}
}
async function pullModel(name: string) {
pulling.value = name;
try {
await store.pullModel(name);
// Poll for completion
const poll = setInterval(async () => {
await store.fetchInstalledModels();
const installed = new Set(
store.installedModels.map((m) => m.replace(/:latest$/, ""))
);
if (installed.has(name) || installed.has(name.replace(/:.*$/, ""))) {
clearInterval(poll);
pulling.value = null;
}
}, 5000);
// Stop polling after 10 minutes max
setTimeout(() => {
clearInterval(poll);
if (pulling.value === name) pulling.value = null;
}, 600_000);
} catch {
pulling.value = null;
}
}
async function removeModel(name: string) {
if (confirmDelete.value !== name) {
confirmDelete.value = name;
return;
}
confirmDelete.value = null;
deleting.value = name;
try {
await store.deleteModel(name);
// If the deleted model was active, clear the selection
if (isActiveModel(name)) {
selectedModel.value = "";
}
} finally {
deleting.value = null;
}
}
function cancelDelete() {
confirmDelete.value = null;
}
</script>
<template>
<main class="settings-page">
<h1>Settings</h1>
<section class="settings-section">
<h2>Assistant</h2>
<div class="field">
<label for="assistant-name">Assistant Name</label>
<input
id="assistant-name"
v-model="assistantName"
type="text"
placeholder="Fable"
class="input"
/>
<p class="field-hint">
The name used for the AI assistant in chat messages and LLM context.
</p>
</div>
<div class="actions">
<button class="btn-save" @click="saveAssistant" :disabled="saving">
{{ saving ? "Saving..." : "Save" }}
</button>
<span v-if="saved" class="saved-msg">Saved!</span>
</div>
</section>
<section class="settings-section">
<h2>Model</h2>
<p class="section-desc">
Choose which LLM model to use for chat. Models need to be downloaded before use.
</p>
<div v-for="cat in categories" :key="cat" class="model-category">
<h3 class="category-label">{{ cat }}</h3>
<div class="model-list">
<div
v-for="model in modelsInCategory(cat)"
:key="model.name"
class="model-card"
:class="{ active: model.active }"
>
<div class="model-info">
<div class="model-name-row">
<span class="model-name">{{ model.name }}</span>
<span class="model-size">{{ model.size }}</span>
</div>
<p class="model-desc">{{ model.description }}</p>
<p class="model-best-for">
<strong>Best for:</strong> {{ model.bestFor }}
</p>
</div>
<div class="model-actions">
<template v-if="model.installed">
<button
v-if="!model.active"
class="btn-select"
@click="selectModel(model.name)"
:disabled="saving"
>
Select
</button>
<span v-else class="active-badge">Active</span>
<template v-if="confirmDelete === model.name">
<button
class="btn-confirm-delete"
@click="removeModel(model.name)"
:disabled="deleting !== null"
>
{{ deleting === model.name ? "Removing..." : "Confirm" }}
</button>
<button class="btn-cancel-delete" @click="cancelDelete">
Cancel
</button>
</template>
<button
v-else
class="btn-remove"
@click="removeModel(model.name)"
:disabled="deleting !== null || model.active"
:title="model.active ? 'Cannot remove the active model' : 'Remove model'"
>
Remove
</button>
</template>
<button
v-else
class="btn-pull"
@click="pullModel(model.name)"
:disabled="pulling !== null"
>
{{ pulling === model.name ? "Pulling..." : "Download" }}
</button>
</div>
</div>
</div>
</div>
</section>
</main>
</template>
<style scoped>
.settings-page {
max-width: 700px;
margin: 2rem auto;
padding: 0 1rem;
}
.settings-page h1 {
margin: 0 0 1.5rem;
}
.settings-section {
background: var(--color-bg-card);
border: 1px solid var(--color-border);
border-radius: 8px;
padding: 1.25rem;
margin-bottom: 1.5rem;
}
.settings-section h2 {
margin: 0 0 0.5rem;
font-size: 1.1rem;
}
.section-desc {
margin: 0 0 1rem;
font-size: 0.9rem;
color: var(--color-text-secondary);
}
.field {
margin-bottom: 1rem;
}
.field label {
display: block;
font-size: 0.9rem;
font-weight: 600;
margin-bottom: 0.35rem;
color: var(--color-text);
}
.input {
width: 100%;
padding: 0.5rem 0.75rem;
border: 1px solid var(--color-border);
border-radius: 6px;
font-size: 0.95rem;
background: var(--color-bg);
color: var(--color-text);
box-sizing: border-box;
}
.input:focus {
outline: none;
border-color: var(--color-primary);
}
.field-hint {
margin: 0.35rem 0 0;
font-size: 0.8rem;
color: var(--color-text-muted);
}
.actions {
display: flex;
align-items: center;
gap: 0.75rem;
}
.btn-save {
padding: 0.5rem 1.25rem;
background: var(--color-primary);
color: #fff;
border: none;
border-radius: 6px;
cursor: pointer;
font-size: 0.9rem;
}
.btn-save:disabled {
opacity: 0.6;
cursor: default;
}
.btn-save:hover:not(:disabled) {
opacity: 0.9;
}
.saved-msg {
color: #22c55e;
font-size: 0.9rem;
font-weight: 600;
}
/* Model list */
.model-list {
display: flex;
flex-direction: column;
gap: 0.75rem;
}
.model-card {
display: flex;
justify-content: space-between;
align-items: flex-start;
gap: 1rem;
padding: 1rem;
border: 1px solid var(--color-border);
border-radius: 8px;
background: var(--color-bg);
transition: border-color 0.15s;
}
.model-card.active {
border-color: var(--color-primary);
background: color-mix(in srgb, var(--color-primary) 5%, var(--color-bg));
}
.model-info {
flex: 1;
min-width: 0;
}
.model-name-row {
display: flex;
align-items: baseline;
gap: 0.5rem;
margin-bottom: 0.3rem;
}
.model-name {
font-weight: 600;
font-size: 0.95rem;
font-family: monospace;
}
.model-size {
font-size: 0.75rem;
color: var(--color-text-muted);
white-space: nowrap;
}
.model-desc {
margin: 0 0 0.25rem;
font-size: 0.85rem;
color: var(--color-text-secondary);
line-height: 1.4;
}
.model-best-for {
margin: 0;
font-size: 0.8rem;
color: var(--color-text-muted);
}
.model-best-for strong {
color: var(--color-text-secondary);
}
.btn-select {
padding: 0.35rem 0.9rem;
background: var(--color-primary);
color: #fff;
border: none;
border-radius: 6px;
cursor: pointer;
font-size: 0.85rem;
}
.btn-select:hover:not(:disabled) {
opacity: 0.9;
}
.btn-select:disabled {
opacity: 0.6;
cursor: default;
}
.btn-pull {
padding: 0.35rem 0.9rem;
background: var(--color-bg-secondary);
color: var(--color-text);
border: 1px solid var(--color-border);
border-radius: 6px;
cursor: pointer;
font-size: 0.85rem;
}
.btn-pull:hover:not(:disabled) {
border-color: var(--color-primary);
color: var(--color-primary);
}
.btn-pull:disabled {
opacity: 0.6;
cursor: default;
}
.active-badge {
padding: 0.25rem 0.75rem;
background: var(--color-primary);
color: #fff;
border-radius: 12px;
font-size: 0.8rem;
font-weight: 600;
}
/* Category headers */
.model-category {
margin-bottom: 1.5rem;
}
.model-category:last-child {
margin-bottom: 0;
}
.category-label {
margin: 0 0 0.5rem;
font-size: 0.85rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.05em;
color: var(--color-text-muted);
}
/* Model actions layout */
.model-actions {
display: flex;
align-items: center;
flex-shrink: 0;
gap: 0.4rem;
}
/* Remove button */
.btn-remove {
padding: 0.25rem 0.6rem;
background: transparent;
color: var(--color-text-muted);
border: 1px solid var(--color-border);
border-radius: 6px;
cursor: pointer;
font-size: 0.75rem;
}
.btn-remove:hover:not(:disabled) {
border-color: #ef4444;
color: #ef4444;
}
.btn-remove:disabled {
opacity: 0.4;
cursor: default;
}
.btn-confirm-delete {
padding: 0.25rem 0.6rem;
background: #ef4444;
color: #fff;
border: none;
border-radius: 6px;
cursor: pointer;
font-size: 0.75rem;
font-weight: 600;
}
.btn-confirm-delete:hover:not(:disabled) {
background: #dc2626;
}
.btn-confirm-delete:disabled {
opacity: 0.6;
cursor: default;
}
.btn-cancel-delete {
padding: 0.25rem 0.6rem;
background: transparent;
color: var(--color-text-muted);
border: 1px solid var(--color-border);
border-radius: 6px;
cursor: pointer;
font-size: 0.75rem;
}
.btn-cancel-delete:hover {
color: var(--color-text);
border-color: var(--color-text-muted);
}
</style>