wip: refactoring tui

This commit is contained in:
adamdottv
2025-05-28 10:12:08 -05:00
parent 641e9ff664
commit 5e738ce7d3
12 changed files with 938 additions and 467 deletions

View File

@@ -1,7 +1,8 @@
package logs
import (
"context"
// "context"
"fmt"
"log/slog"
"github.com/charmbracelet/bubbles/key"
@@ -41,18 +42,16 @@ func (i *tableCmp) Init() tea.Cmd {
func (i *tableCmp) fetchLogs() tea.Cmd {
return func() tea.Msg {
ctx := context.Background()
// ctx := context.Background()
var logs []logging.Log
var err error
// Limit the number of logs to improve performance
const logLimit = 100
if i.app.CurrentSession.ID == "" {
logs, err = i.app.Logs.ListAll(ctx, logLimit)
} else {
logs, err = i.app.Logs.ListBySession(ctx, i.app.CurrentSession.ID)
}
// TODO: Logs service not implemented in API yet
logs = []logging.Log{}
err = fmt.Errorf("logs service not implemented")
if err != nil {
slog.Error("Failed to fetch logs", "error", err)