( ctx context.Context, _ string, sessionID string, )
| 250 | } |
| 251 | |
| 252 | func (b *taskSessionBridge) AttachTaskSession( |
| 253 | ctx context.Context, |
| 254 | _ string, |
| 255 | sessionID string, |
| 256 | ) (*taskpkg.SessionRef, error) { |
| 257 | if ctx == nil { |
| 258 | return nil, errors.New("daemon: attach task session context is required") |
| 259 | } |
| 260 | |
| 261 | info, err := b.sessions.Status(ctx, strings.TrimSpace(sessionID)) |
| 262 | if err != nil { |
| 263 | return nil, err |
| 264 | } |
| 265 | if info == nil { |
| 266 | return nil, fmt.Errorf( |
| 267 | "%w: session %q is unavailable", |
| 268 | taskpkg.ErrSessionAttachNotAllowed, |
| 269 | strings.TrimSpace(sessionID), |
| 270 | ) |
| 271 | } |
| 272 | if !isTaskSessionStateLive(info.State) { |
| 273 | return nil, fmt.Errorf( |
| 274 | "%w: session %q is %q", |
| 275 | taskpkg.ErrSessionAttachNotAllowed, |
| 276 | strings.TrimSpace(sessionID), |
| 277 | info.State, |
| 278 | ) |
| 279 | } |
| 280 | |
| 281 | return &taskpkg.SessionRef{ |
| 282 | SessionID: strings.TrimSpace(info.ID), |
| 283 | WorkspaceID: strings.TrimSpace(info.WorkspaceID), |
| 284 | StartedAt: info.CreatedAt, |
| 285 | }, nil |
| 286 | } |
| 287 | |
| 288 | func (b *taskSessionBridge) RequestTaskStop(ctx context.Context, sessionID string, reason taskpkg.StopReason) error { |
| 289 | if ctx == nil { |
nothing calls this directly
no test coverage detected