feat: per-user assistant name and system prompt customization
CI / checks (push) Failing after 2m12s
CI / build (push) Successful in 4m50s

Each user can rename the AI assistant and edit their own system prompt in Settings.
This commit is contained in:
ginnoir
2026-07-04 23:26:17 -05:00
parent a2e5eb111d
commit e5e509081c
17 changed files with 370 additions and 59 deletions
+10
View File
@@ -0,0 +1,10 @@
import { AGENT_SYSTEM_PROMPT } from "@/modules/agent/tools";
export const DEFAULT_ASSISTANT_NAME = "Assistant";
export const MAX_ASSISTANT_NAME_LENGTH = 40;
export const MAX_ASSISTANT_SYSTEM_PROMPT_LENGTH = 8000;
export function resolveAssistantSystemPrompt(customPrompt: string | null | undefined): string {
const trimmed = customPrompt?.trim();
return trimmed ? trimmed : AGENT_SYSTEM_PROMPT;
}
+30 -3
View File
@@ -1,13 +1,40 @@
import { eq } from "drizzle-orm";
import { db } from "@/lib/db";
import { DEFAULT_ASSISTANT_NAME } from "@/lib/assistant-config";
import { users } from "@/modules/_core/schema";
export async function getAssistantEnabled(userId: string): Promise<boolean> {
export {
DEFAULT_ASSISTANT_NAME,
MAX_ASSISTANT_NAME_LENGTH,
MAX_ASSISTANT_SYSTEM_PROMPT_LENGTH,
resolveAssistantSystemPrompt,
} from "@/lib/assistant-config";
export type AssistantPreferences = {
enabled: boolean;
name: string;
systemPrompt: string | null;
};
export async function getAssistantPreferences(userId: string): Promise<AssistantPreferences> {
const [row] = await db
.select({ assistantEnabled: users.assistantEnabled })
.select({
assistantEnabled: users.assistantEnabled,
assistantName: users.assistantName,
assistantSystemPrompt: users.assistantSystemPrompt,
})
.from(users)
.where(eq(users.id, userId))
.limit(1);
return row?.assistantEnabled ?? false;
return {
enabled: row?.assistantEnabled ?? false,
name: row?.assistantName?.trim() || DEFAULT_ASSISTANT_NAME,
systemPrompt: row?.assistantSystemPrompt ?? null,
};
}
export async function getAssistantEnabled(userId: string): Promise<boolean> {
const prefs = await getAssistantPreferences(userId);
return prefs.enabled;
}