// SPDX-Licence-Identifier: EUPL-1.2 package session import ( "html" "path" "time" core "dappco.re/go/core" ) // RenderHTML generates a self-contained HTML timeline from a session. // // Example: // err := session.RenderHTML(sess, "/tmp/session.html") func RenderHTML(sess *Session, outputPath string) error { if !hostFS.IsDir(path.Dir(outputPath)) { return core.E("RenderHTML", "parent directory does not exist", nil) } duration := sess.EndTime.Sub(sess.StartTime) toolCount := 0 errorCount := 0 for e := range sess.EventsSeq() { if e.Type == "tool_use" { toolCount++ if !e.Success { errorCount++ } } } b := core.NewBuilder() b.WriteString(core.Sprintf(`
%s
%s