mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 21:19:12 +00:00
Convert the default conversation id to a uuid, plus other fixes (#918)
* Update the conversation_id primary key field to be a uuid - update associated API endpoints - this is to improve the overall application health, by obfuscating some information about the internal database - conversation_id type is now implicitly a string, rather than an int - ensure automations are also migrated in place, such that the conversation_ids they're pointing to are now mapped to the new IDs * Update client-side API calls to correctly query with a string field * Allow modifying of conversation properties from the chat title * Improve drag and drop file experience for chat input area * Use a phosphor icon for the copy to clipboard experience for code snippets * Update conversation_id parameter to be a str type * If django_apscheduler is not in the environment, skip the migration script * Fix create automation flow by storing conversation id as string The new UUID used for conversation id can't be directly serialized. Convert to string for serializing it for later execution --------- Co-authored-by: Debanjum Singh Solanky <debanjum@gmail.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import styles from "./chatMessage.module.css";
|
||||
import markdownIt from "markdown-it";
|
||||
import mditHljs from "markdown-it-highlightjs";
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
import { createRoot } from "react-dom/client";
|
||||
|
||||
import "katex/dist/katex.min.css";
|
||||
|
||||
@@ -23,6 +24,7 @@ import {
|
||||
MagnifyingGlass,
|
||||
Pause,
|
||||
Palette,
|
||||
ClipboardText,
|
||||
} from "@phosphor-icons/react";
|
||||
|
||||
import DOMPurify from "dompurify";
|
||||
@@ -377,12 +379,9 @@ export default function ChatMessage(props: ChatMessageProps) {
|
||||
const preElements = messageRef.current.querySelectorAll("pre > .hljs");
|
||||
preElements.forEach((preElement) => {
|
||||
const copyButton = document.createElement("button");
|
||||
const copyImage = document.createElement("img");
|
||||
copyImage.src = "/static/copy-button.svg";
|
||||
copyImage.alt = "Copy";
|
||||
copyImage.width = 24;
|
||||
copyImage.height = 24;
|
||||
copyButton.appendChild(copyImage);
|
||||
const copyIcon = <ClipboardText size={24} weight="bold" />;
|
||||
createRoot(copyButton).render(copyIcon);
|
||||
|
||||
copyButton.className = `hljs ${styles.codeCopyButton}`;
|
||||
copyButton.addEventListener("click", () => {
|
||||
let textContent = preElement.textContent || "";
|
||||
@@ -392,7 +391,6 @@ export default function ChatMessage(props: ChatMessageProps) {
|
||||
textContent = textContent.replace(/^Copy/, "");
|
||||
textContent = textContent.trim();
|
||||
navigator.clipboard.writeText(textContent);
|
||||
copyImage.src = "/static/copy-button-success.svg";
|
||||
});
|
||||
preElement.prepend(copyButton);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user