mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-20 02:17:24 +00:00
feat(infra): tracing recovery, browser cleanup, CLI fixes, UI workspace split (#709)
- Tracing: recover stale running traces/spans on startup (PG + SQLite) - Browser: Chrome orphan cleanup via launcher PID, timeouts, Leakless - Claude CLI: WaitDelay 5s + context-cancel early exit - Agent loop: safety-net defer to finalize orphan root traces - UI: split workspace sharing into separate Memory and KG toggles - Minor: for-range idiom, min() builtin
This commit is contained in:
1 parent
7d7b716074
commit
41e6c8f5cc
15 files changed
+208
-45
No files matched your search
@@ -251,6 +251,29 @@ func (s *SQLiteTracingStore) DeleteTracesOlderThan(ctx context.Context, cutoff t
|
||||
return res.RowsAffected()
|
||||
}
|
||||
|
||||
// RecoverStaleRunningTraces marks traces stuck in "running" since before cutoff as "error".
|
||||
// Also recovers their stuck spans. Called on startup to fix orphans from crashes.
|
||||
func (s *SQLiteTracingStore) RecoverStaleRunningTraces(ctx context.Context, cutoff time.Time) (int64, error) {
|
||||
// Recover stuck spans first.
|
||||
_, err := s.db.ExecContext(ctx,
|
||||
`UPDATE spans SET status = 'error', error = 'recovered: server restart',
|
||||
end_time = datetime('now'), duration_ms = CAST((julianday('now') - julianday(start_time)) * 86400000 AS INTEGER)
|
||||
WHERE status = 'running' AND start_time < ?`, cutoff)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("recover stale spans: %w", err)
|
||||
}
|
||||
|
||||
res, err := s.db.ExecContext(ctx,
|
||||
`UPDATE traces SET status = 'error',
|
||||
error = 'recovered: stuck in running state (server restart)',
|
||||
end_time = datetime('now'), duration_ms = CAST((julianday('now') - julianday(start_time)) * 86400000 AS INTEGER)
|
||||
WHERE status = 'running' AND start_time < ?`, cutoff)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("recover stale running traces: %w", err)
|
||||
}
|
||||
return res.RowsAffected()
|
||||
}
|
||||
|
||||
// ListCodexPoolSpans is not supported in SQLite (Codex pool is a standard-edition feature).
|
||||
func (s *SQLiteTracingStore) ListCodexPoolSpans(_ context.Context, _, _ uuid.UUID, _ []string, _ int) ([]store.CodexPoolSpan, error) {
|
||||
return nil, nil
|
||||
|
||||
Reference in new issue
Block a user