Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion web-app/src/routes/local-api-server/logs.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createFileRoute } from '@tanstack/react-router'
import { route } from '@/constants/routes'

Check warning on line 2 in web-app/src/routes/local-api-server/logs.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

1-2 lines are not covered with tests

import { useEffect, useState, useRef } from 'react'
import { parseLogLine, readLogs } from '@/services/app'
Expand All @@ -7,75 +7,75 @@
import { useTranslation } from '@/i18n/react-i18next-compat'

Check warning on line 7 in web-app/src/routes/local-api-server/logs.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

4-7 lines are not covered with tests

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const Route = createFileRoute(route.localApiServerlogs as any)({
component: LogsViewer,
})

Check warning on line 12 in web-app/src/routes/local-api-server/logs.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

10-12 lines are not covered with tests

const SERVER_LOG_TARGET = 'app_lib::core::server'
const SERVER_LOG_TARGET = 'app_lib::core::server::proxy'
const LOG_EVENT_NAME = 'log://log'

Check warning on line 15 in web-app/src/routes/local-api-server/logs.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

14-15 lines are not covered with tests

function LogsViewer() {
const { t } = useTranslation()
const [logs, setLogs] = useState<LogEntry[]>([])
const logsContainerRef = useRef<HTMLDivElement>(null)

Check warning on line 20 in web-app/src/routes/local-api-server/logs.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

17-20 lines are not covered with tests

useEffect(() => {
readLogs().then((logData) => {
const logs = logData
.filter((log) => log?.target === SERVER_LOG_TARGET)
.filter(Boolean) as LogEntry[]
setLogs(logs)

Check warning on line 27 in web-app/src/routes/local-api-server/logs.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

22-27 lines are not covered with tests

// Scroll to bottom after initial logs are loaded
setTimeout(() => {
scrollToBottom()
}, 100)
})
let unsubscribe = () => {}
listen(LOG_EVENT_NAME, (event) => {
const { message } = event.payload as { message: string }
const log: LogEntry | undefined = parseLogLine(message)
if (log?.target === SERVER_LOG_TARGET) {
setLogs((prevLogs) => {
const newLogs = [...prevLogs, log]

Check warning on line 40 in web-app/src/routes/local-api-server/logs.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

30-40 lines are not covered with tests
// Schedule scroll to bottom after state update
setTimeout(() => {
scrollToBottom()
}, 0)
return newLogs
})
}
}).then((unsub) => {
unsubscribe = unsub
})
return () => {
unsubscribe()
}
}, [])

Check warning on line 54 in web-app/src/routes/local-api-server/logs.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

42-54 lines are not covered with tests

// Function to scroll to the bottom of the logs container
const scrollToBottom = () => {
if (logsContainerRef.current) {
const { scrollHeight, clientHeight } = logsContainerRef.current
logsContainerRef.current.scrollTop = scrollHeight - clientHeight
}
}

Check warning on line 62 in web-app/src/routes/local-api-server/logs.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

57-62 lines are not covered with tests

// Function to get appropriate color for log level
const getLogLevelColor = (level: string) => {
switch (level) {
case 'error':
return 'text-red-500'
case 'warn':
return 'text-yellow-500'
case 'info':
return 'text-blue-500'
case 'debug':
return 'text-gray-500'
default:
return 'text-gray-500'
}
}

Check warning on line 78 in web-app/src/routes/local-api-server/logs.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

65-78 lines are not covered with tests

// Format timestamp to be more readable
const formatTimestamp = (timestamp: string | number) => {
Expand Down
Loading