返回 DeepSeek-Reasonix
terminal_worktree_admission.go
根目录 / desktop / terminal_worktree_admission.go
1 package main
2
3 // WriteTerminalForTab holds the project runtime admission through the process
4 // write so a merge reservation cannot begin between target resolution and the
5 // command becoming observable in the workspace.
6 func (a *App) WriteTerminalForTab(tabID, sessionID, data string) error {
7 target, err := a.terminalTargetForTab(tabID, true)
8 if err != nil {
9 return err
10 }
11 releaseAdmission, err := a.beginWorkspaceRuntimeAdmission(target.workspaceRoot)
12 if err != nil {
13 return err
14 }
15 defer releaseAdmission()
16 if a.terminals == nil {
17 return errTerminalManagerOff
18 }
19 return a.terminals.write(target.workspaceKey, sessionID, []byte(data))
20 }
21
22 func (m *terminalManager) hasRunningForTabs(tabIDs map[string]struct{}) bool {
23 if m == nil || len(tabIDs) == 0 {
24 return false
25 }
26 m.mu.Lock()
27 defer m.mu.Unlock()
28 for _, session := range m.sessions {
29 if session == nil || !session.view.Running {
30 continue
31 }
32 if _, ok := tabIDs[session.tabID]; ok {
33 return true
34 }
35 }
36 return false
37 }
38
38 lines GO