Revert "feat(playback): Create new, correct playback summary function"

This reverts commit 6770c0ac1e.
This commit is contained in:
Jeff Carr 2025-08-22 03:09:24 -05:00
parent 6770c0ac1e
commit 05105e6fd1
1 changed files with 12 additions and 35 deletions

View File

@ -2,53 +2,30 @@ package main
import ( import (
"fmt" "fmt"
"os"
"go.wit.com/lib/protobuf/chatpb"
"go.wit.com/log" "go.wit.com/log"
) )
// doPlayback loads a specified log file and prints a one-line summary for each chat topic. func doPlayback() {
// If no filename is provided, it summarizes the current in-memory chat session. log.Infof("Found %d chat topic(s) in the log.", len(me.chats.GetChats()))
func doPlayback(filename string) {
var playbackChats *chatpb.Chats
var err error
// If a filename is provided, load that file. Otherwise, use the existing session.
if filename != "" {
log.Infof("Loading log file for playback: %s", filename)
data, err := os.ReadFile(filename)
if err != nil {
log.Fatalf("Failed to read playback file: %v", err)
}
playbackChats, err = chatpb.UnmarshalChatsTEXT(data)
if err != nil {
log.Fatalf("Failed to parse playback file: %v", err)
}
} else {
log.Info("No log file specified. Displaying summary of current conversation state.")
playbackChats = me.chats
}
// Ensure all chats and entries have UUIDs before printing.
verifyUuids(playbackChats)
fmt.Println("-------------------------------------------------")
log.Infof("Found %d chat topic(s).", len(playbackChats.GetChats()))
fmt.Println("-------------------------------------------------") fmt.Println("-------------------------------------------------")
for _, chat := range playbackChats.GetChats() { // Iterate through the top-level Chat messages, which are now named groups.
for _, chat := range me.chats.GetChats() {
// Get the number of entries in the chat.
entryCount := len(chat.GetEntries()) entryCount := len(chat.GetEntries())
var formattedTime string
// Use the chat's top-level ctime for the summary. // Get the timestamp of the first entry to represent the chat's start time.
if ctime := chat.GetCtime(); ctime != nil { var formattedTime string
t := ctime.AsTime() if entryCount > 0 && chat.GetEntries()[0].GetCtime() != nil {
formattedTime = t.Format("2006-01-02 15:04:05") t := chat.GetEntries()[0].GetCtime().AsTime()
formattedTime = t.Format("2006-01-02 15:04:05") // YYYY-MM-DD HH:MM:SS
} else { } else {
formattedTime = "No Timestamp" formattedTime = "No Timestamp"
} }
// Print the formatted one-line summary.
fmt.Printf("Topic: %-25s | Entries: %-4d | Started: %s | UUID: %s\n", fmt.Printf("Topic: %-25s | Entries: %-4d | Started: %s | UUID: %s\n",
chat.GetChatName(), chat.GetChatName(),
entryCount, entryCount,