feat(service): expose subscribe, input, exit status for ws handler

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
tao.chen
2026-07-03 12:10:50 +08:00
co-authored by Claude
parent 13a5aeda2c
commit 11ccdda579
2 changed files with 63 additions and 0 deletions
+26
View File
@@ -3,6 +3,8 @@ package service
import (
"log/slog"
"io"
"codespace/internal/process"
"codespace/internal/workspace"
)
@@ -70,3 +72,27 @@ func (s *ProcessService) Status(workspaceID string) (process.Status, error) {
}
return s.processes.Status(workspaceID), nil
}
// Subscribe subscribes to output events for the workspace process.
func (s *ProcessService) Subscribe(workspaceID string) (process.Subscription, error) {
if _, err := s.workspaces.Get(workspaceID); err != nil {
return nil, err
}
return s.processes.Subscribe(workspaceID)
}
// Input returns the stdin writer for the workspace process.
func (s *ProcessService) Input(workspaceID string) (io.WriteCloser, error) {
if _, err := s.workspaces.Get(workspaceID); err != nil {
return nil, err
}
return s.processes.Stdin(workspaceID)
}
// ExitStatus returns the exit status for the workspace process.
func (s *ProcessService) ExitStatus(workspaceID string) (process.ExitInfo, error) {
if _, err := s.workspaces.Get(workspaceID); err != nil {
return process.ExitInfo{}, err
}
return s.processes.ExitStatus(workspaceID)
}