forked from mediar-ai/screenpipe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'mediar-ai:main' into test-cli-ci
- Loading branch information
Showing
25 changed files
with
507 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import React, { useEffect, useState, useRef } from "react"; | ||
import { listen } from "@tauri-apps/api/event"; | ||
import { cn } from "@/lib/utils"; | ||
import Convert from 'ansi-to-html'; | ||
|
||
interface LogViewerProps { | ||
className?: string; | ||
} | ||
|
||
const convert = new Convert({newline: true}); | ||
|
||
const LogViewer: React.FC<LogViewerProps> = ({ className }) => { | ||
const [logs, setLogs] = useState<string[]>([]); | ||
const logContainerRef = useRef<HTMLDivElement>(null); | ||
|
||
useEffect(() => { | ||
const unlisten = listen<string>("sidecar_log", (event) => { | ||
setLogs((prevLogs) => [...prevLogs, event.payload].slice(-100)); // Keep last 100 logs | ||
}); | ||
|
||
return () => { | ||
unlisten.then((f) => f()); // Cleanup listener when component unmounts | ||
}; | ||
}, []); | ||
|
||
useEffect(() => { | ||
if (logContainerRef.current) { | ||
logContainerRef.current.scrollTop = logContainerRef.current.scrollHeight; | ||
} | ||
}, [logs]); | ||
|
||
const htmlLogs = logs.map((log) => convert.toHtml(log)); | ||
|
||
return ( | ||
<div | ||
ref={logContainerRef} | ||
className={cn( | ||
"h-64 overflow-y-auto bg-black p-2 font-mono text-sm text-white", | ||
"whitespace-pre-wrap break-words", | ||
className | ||
)} | ||
> | ||
{htmlLogs.map((log, index) => ( | ||
<div | ||
key={index} | ||
dangerouslySetInnerHTML={{ __html: log }} | ||
className="leading-5" | ||
/> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
export default LogViewer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
"use client" | ||
|
||
import * as CollapsiblePrimitive from "@radix-ui/react-collapsible" | ||
|
||
const Collapsible = CollapsiblePrimitive.Root | ||
|
||
const CollapsibleTrigger = CollapsiblePrimitive.CollapsibleTrigger | ||
|
||
const CollapsibleContent = CollapsiblePrimitive.CollapsibleContent | ||
|
||
export { Collapsible, CollapsibleTrigger, CollapsibleContent } |
Oops, something went wrong.