mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-22 23:31:12 +02:00
feat: enhance MemoryContent and TeamMemoryManager components with improved memory display and user prompts for empty memory states
This commit is contained in:
parent
84fc72e596
commit
b44c1ee034
3 changed files with 52 additions and 6 deletions
|
|
@ -85,6 +85,7 @@ export function MemoryContent() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const displayMemory = memory.replace(/\(\d{4}-\d{2}-\d{2}\)\s*/g, "");
|
||||||
const charCount = memory.length;
|
const charCount = memory.length;
|
||||||
|
|
||||||
const getCounterColor = () => {
|
const getCounterColor = () => {
|
||||||
|
|
@ -102,6 +103,19 @@ export function MemoryContent() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!memory) {
|
||||||
|
return (
|
||||||
|
<div className="flex flex-col items-center justify-center py-16 text-center">
|
||||||
|
<h3 className="text-base font-medium text-foreground">
|
||||||
|
What does SurfSense remember?
|
||||||
|
</h3>
|
||||||
|
<p className="mt-2 max-w-sm text-sm text-muted-foreground">
|
||||||
|
Nothing yet. SurfSense picks up on your preferences and context as you chat.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<Alert className="bg-muted/50 py-3 md:py-4">
|
<Alert className="bg-muted/50 py-3 md:py-4">
|
||||||
|
|
@ -116,7 +130,7 @@ export function MemoryContent() {
|
||||||
|
|
||||||
<div className="h-[340px] overflow-y-auto rounded-md border">
|
<div className="h-[340px] overflow-y-auto rounded-md border">
|
||||||
<PlateEditor
|
<PlateEditor
|
||||||
markdown={memory}
|
markdown={displayMemory}
|
||||||
readOnly
|
readOnly
|
||||||
preset="readonly"
|
preset="readonly"
|
||||||
variant="default"
|
variant="default"
|
||||||
|
|
@ -139,7 +153,7 @@ export function MemoryContent() {
|
||||||
value={editQuery}
|
value={editQuery}
|
||||||
onChange={(e) => setEditQuery(e.target.value)}
|
onChange={(e) => setEditQuery(e.target.value)}
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
placeholder="e.g. "I prefer TypeScript over JavaScript" or "Remove the entry about Tokyo""
|
placeholder="Tell SurfSense what to remember or forget"
|
||||||
disabled={editing}
|
disabled={editing}
|
||||||
rows={2}
|
rows={2}
|
||||||
className="pr-12 resize-none text-sm"
|
className="pr-12 resize-none text-sm"
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
import { MarkdownPlugin, remarkMdx } from "@platejs/markdown";
|
import { MarkdownPlugin, remarkMdx } from "@platejs/markdown";
|
||||||
import { slateToHtml } from "@slate-serializers/html";
|
import { slateToHtml } from "@slate-serializers/html";
|
||||||
import type { AnyPluginConfig, Descendant, Value } from "platejs";
|
import type { AnyPluginConfig, Descendant, Value } from "platejs";
|
||||||
import { createPlatePlugin, Key, Plate, usePlateEditor } from "platejs/react";
|
import { createPlatePlugin, Key, Plate, useEditorReadOnly, usePlateEditor } from "platejs/react";
|
||||||
import { useEffect, useMemo, useRef } from "react";
|
import { useEffect, useMemo, useRef } from "react";
|
||||||
import remarkGfm from "remark-gfm";
|
import remarkGfm from "remark-gfm";
|
||||||
import remarkMath from "remark-math";
|
import remarkMath from "remark-math";
|
||||||
|
|
@ -60,6 +60,24 @@ export interface PlateEditorProps {
|
||||||
extraPlugins?: AnyPluginConfig[];
|
extraPlugins?: AnyPluginConfig[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function PlateEditorContent({
|
||||||
|
editorVariant,
|
||||||
|
placeholder,
|
||||||
|
}: {
|
||||||
|
editorVariant: PlateEditorProps["editorVariant"];
|
||||||
|
placeholder?: string;
|
||||||
|
}) {
|
||||||
|
const isReadOnly = useEditorReadOnly();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Editor
|
||||||
|
variant={editorVariant}
|
||||||
|
placeholder={isReadOnly ? undefined : placeholder}
|
||||||
|
className="min-h-full"
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export function PlateEditor({
|
export function PlateEditor({
|
||||||
markdown,
|
markdown,
|
||||||
html,
|
html,
|
||||||
|
|
@ -188,7 +206,7 @@ export function PlateEditor({
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<EditorContainer variant={variant} className={className}>
|
<EditorContainer variant={variant} className={className}>
|
||||||
<Editor variant={editorVariant} placeholder={placeholder} className="min-h-full" />
|
<PlateEditorContent editorVariant={editorVariant} placeholder={placeholder} />
|
||||||
</EditorContainer>
|
</EditorContainer>
|
||||||
</Plate>
|
</Plate>
|
||||||
</EditorSaveContext.Provider>
|
</EditorSaveContext.Provider>
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,7 @@ export function TeamMemoryManager({ searchSpaceId }: TeamMemoryManagerProps) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const displayMemory = memory.replace(/\(\d{4}-\d{2}-\d{2}\)\s*/g, "");
|
||||||
const charCount = memory.length;
|
const charCount = memory.length;
|
||||||
|
|
||||||
const getCounterColor = () => {
|
const getCounterColor = () => {
|
||||||
|
|
@ -105,6 +106,19 @@ export function TeamMemoryManager({ searchSpaceId }: TeamMemoryManagerProps) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!memory) {
|
||||||
|
return (
|
||||||
|
<div className="flex flex-col items-center justify-center py-16 text-center">
|
||||||
|
<h3 className="text-base font-medium text-foreground">
|
||||||
|
What does SurfSense remember about your team?
|
||||||
|
</h3>
|
||||||
|
<p className="mt-2 max-w-sm text-sm text-muted-foreground">
|
||||||
|
Nothing yet. SurfSense picks up on team decisions and conventions as your team chats.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<Alert className="bg-muted/50 py-3 md:py-4">
|
<Alert className="bg-muted/50 py-3 md:py-4">
|
||||||
|
|
@ -119,7 +133,7 @@ export function TeamMemoryManager({ searchSpaceId }: TeamMemoryManagerProps) {
|
||||||
|
|
||||||
<div className="h-[340px] overflow-y-auto rounded-md border">
|
<div className="h-[340px] overflow-y-auto rounded-md border">
|
||||||
<PlateEditor
|
<PlateEditor
|
||||||
markdown={memory}
|
markdown={displayMemory}
|
||||||
readOnly
|
readOnly
|
||||||
preset="readonly"
|
preset="readonly"
|
||||||
variant="default"
|
variant="default"
|
||||||
|
|
@ -142,7 +156,7 @@ export function TeamMemoryManager({ searchSpaceId }: TeamMemoryManagerProps) {
|
||||||
value={editQuery}
|
value={editQuery}
|
||||||
onChange={(e) => setEditQuery(e.target.value)}
|
onChange={(e) => setEditQuery(e.target.value)}
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
placeholder="e.g. "We decided to use PostgreSQL" or "Remove the standup entry""
|
placeholder="Tell SurfSense what to remember or forget about your team"
|
||||||
disabled={editing}
|
disabled={editing}
|
||||||
rows={2}
|
rows={2}
|
||||||
className="pr-12 resize-none text-sm"
|
className="pr-12 resize-none text-sm"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue