mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-13 18:15:34 +00:00
Makes the Stop button on the traces page actually stop running traces. Seven-phase implementation across provider HTTP, agent router, trace persistence, WS events, tool exec, i18n, and integration tests. - Provider HTTP+SSE ctx-aware: close socket on cancel via CtxBody wrapper - Router 2-phase abort: CAS state machine, 3s grace, force-mark fallback - Trace retry: 3 inline retries + 10-max retry queue, stale recovery 10min - trace.status WS event: real-time UI updates (invalidates query on receive) - Tool exec: process-group kill (SIGTERM→3s→SIGKILL), Rod page ctx watch - i18n: 6 abort toast variants in en/vi/zh - Integration: 9 scenarios, -race clean Fixes tenant-ctx loss in forceMarkTraceAborted and retry worker broadcast (caught by code-reviewer: C1/C2). Stale threshold intentionally 10min because start_time-based; last_span_at migration is a follow-up.
42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
package orchestration
|
|
|
|
import (
|
|
"path/filepath"
|
|
|
|
"github.com/nextlevelbuilder/goclaw/internal/agent"
|
|
"github.com/nextlevelbuilder/goclaw/internal/bus"
|
|
)
|
|
|
|
// MediaResultToBusFiles converts agent.MediaResult slice to bus.MediaFile slice.
|
|
// Filename is derived from the disk basename so downstream persistMedia
|
|
// sanitizer keeps a meaningful stem (UUID-only disk names become UUID fallback).
|
|
func MediaResultToBusFiles(results []agent.MediaResult) []bus.MediaFile {
|
|
if len(results) == 0 {
|
|
return nil
|
|
}
|
|
files := make([]bus.MediaFile, len(results))
|
|
for i, r := range results {
|
|
files[i] = bus.MediaFile{
|
|
Path: r.Path,
|
|
MimeType: r.ContentType,
|
|
Filename: filepath.Base(r.Path),
|
|
}
|
|
}
|
|
return files
|
|
}
|
|
|
|
// BusFilesToMediaResult converts bus.MediaFile slice to agent.MediaResult slice.
|
|
func BusFilesToMediaResult(files []bus.MediaFile) []agent.MediaResult {
|
|
if len(files) == 0 {
|
|
return nil
|
|
}
|
|
results := make([]agent.MediaResult, len(files))
|
|
for i, f := range files {
|
|
results[i] = agent.MediaResult{
|
|
Path: f.Path,
|
|
ContentType: f.MimeType,
|
|
}
|
|
}
|
|
return results
|
|
}
|