feat(shell): add parallel bash shell subsystem auto-started per workspace
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package shell
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os/exec"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// Status represents the status of a shell for a workspace.
|
||||
type Status struct {
|
||||
WorkspaceID string `json:"workspaceId"`
|
||||
Running bool `json:"running"`
|
||||
PID int `json:"pid,omitempty"`
|
||||
}
|
||||
|
||||
// ExitInfo holds the exit reason of a shell.
|
||||
type ExitInfo struct {
|
||||
Code int
|
||||
Signal string
|
||||
}
|
||||
|
||||
// Session holds the runtime state of a started shell.
|
||||
type Session struct {
|
||||
WorkspaceID string
|
||||
Root string
|
||||
Cmd *exec.Cmd
|
||||
Stdin io.WriteCloser
|
||||
Subscribers map[Subscription]struct{}
|
||||
Exit ExitInfo
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
// removeSubscription removes sub from s.Subscribers. It is safe to call when
|
||||
// the subscription is no longer present.
|
||||
func (s *Session) removeSubscription(sub *subscription) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
delete(s.Subscribers, sub)
|
||||
}
|
||||
Reference in New Issue
Block a user