mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-25 19:15:18 +02:00
feat: enhance memory API responses with limits and update UI components for memory limit handling
This commit is contained in:
parent
fa6d7c60bf
commit
73043a0756
9 changed files with 132 additions and 51 deletions
|
|
@ -14,11 +14,11 @@ import {
|
|||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
import { MEMORY_HARD_LIMIT, useUserMemory } from "@/hooks/use-memory";
|
||||
import { getMemoryLimitState, useUserMemory } from "@/hooks/use-memory";
|
||||
|
||||
export function MemoryContent() {
|
||||
const activeSearchSpaceId = useAtomValue(activeSearchSpaceIdAtom);
|
||||
const { memory, displayMemory, loading, saving, reset } = useUserMemory(
|
||||
const { memory, displayMemory, limits, loading, saving, reset } = useUserMemory(
|
||||
Number(activeSearchSpaceId)
|
||||
);
|
||||
|
||||
|
|
@ -59,11 +59,11 @@ export function MemoryContent() {
|
|||
};
|
||||
|
||||
const charCount = memory.length;
|
||||
const limitState = getMemoryLimitState(charCount, limits);
|
||||
|
||||
const getCounterColor = () => {
|
||||
if (charCount > MEMORY_HARD_LIMIT) return "text-red-500";
|
||||
if (charCount > 15_000) return "text-orange-500";
|
||||
if (charCount > 10_000) return "text-yellow-500";
|
||||
if (limitState.level === "error") return "text-red-500";
|
||||
if (limitState.level === "warning") return "text-orange-500";
|
||||
return "text-muted-foreground";
|
||||
};
|
||||
|
||||
|
|
@ -112,13 +112,7 @@ export function MemoryContent() {
|
|||
</div>
|
||||
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<span className={`text-xs shrink-0 ${getCounterColor()}`}>
|
||||
{charCount.toLocaleString()} / {MEMORY_HARD_LIMIT.toLocaleString()}
|
||||
<span className="hidden sm:inline"> characters</span>
|
||||
<span className="sm:hidden"> chars</span>
|
||||
{charCount > 15_000 && charCount <= MEMORY_HARD_LIMIT && " - Approaching limit"}
|
||||
{charCount > MEMORY_HARD_LIMIT && " - Exceeds limit"}
|
||||
</span>
|
||||
<span className={`text-xs shrink-0 ${getCounterColor()}`}>{limitState.label}</span>
|
||||
<div className="flex items-center gap-1.5 sm:gap-2">
|
||||
<Button
|
||||
type="button"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue