fix(computer-svc): stream для завершенных задач + Timeweb env vars
- Исправлен Stream() в computer.go: для completed/failed/cancelled задач сразу отправляется финальное событие и канал закрывается (ранее соединение зависало с socket hang up) - Добавлены TIMEWEB_* переменные в docker-compose.yml для computer-svc (LLM через Timeweb Cloud AI для России) - UI компоненты webui обновлены Made-with: Cursor
This commit is contained in:
@@ -645,6 +645,31 @@ func (c *Computer) GetUserTasks(ctx context.Context, userID string, limit, offse
|
||||
}
|
||||
|
||||
func (c *Computer) Stream(ctx context.Context, taskID string) (<-chan TaskEvent, error) {
|
||||
task, err := c.taskRepo.GetByID(ctx, taskID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("task not found: %w", err)
|
||||
}
|
||||
|
||||
if task.Status == StatusCompleted || task.Status == StatusFailed || task.Status == StatusCancelled {
|
||||
ch := make(chan TaskEvent, 1)
|
||||
go func() {
|
||||
eventType := EventTaskCompleted
|
||||
if task.Status == StatusFailed {
|
||||
eventType = EventTaskFailed
|
||||
}
|
||||
ch <- TaskEvent{
|
||||
TaskID: taskID,
|
||||
Type: eventType,
|
||||
Status: task.Status,
|
||||
Progress: task.Progress,
|
||||
Message: task.Message,
|
||||
Timestamp: time.Now(),
|
||||
}
|
||||
close(ch)
|
||||
}()
|
||||
return ch, nil
|
||||
}
|
||||
|
||||
return c.eventBus.Subscribe(taskID), nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user