Skip to content

Commit fa1b899

Browse files
committed
Revert "fix: hide closed ACP sessions"
This reverts commit 9a1b856.
1 parent 9a1b856 commit fa1b899

4 files changed

Lines changed: 4 additions & 53 deletions

File tree

app.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,9 +422,6 @@ func (a *App) ListAgentSessions() ([]agent.Session, error) {
422422
}
423423
session.AgentCommand = commandString(endpoint)
424424
session.Key = session.AgentID + ":" + session.ID
425-
if a.manager.IsSessionClosed(session.Key) {
426-
continue
427-
}
428425
sessions = append(sessions, session)
429426
}
430427
}

frontend/src/components/SessionList.jsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,13 @@ export default function SessionList({ activeSessionId, onSelectSession, onNewSes
129129
const handleClose = async (session, e) => {
130130
e.stopPropagation()
131131
setActionError(null)
132-
const key = sessionKey(session)
133-
const snapshot = sessions
134-
setSessions((prev) => prev.filter((s) => sessionKey(s) !== key))
135132
try {
136133
await onBeforeSessionAction?.(session)
137134
await CloseSession(session.id)
138-
onSessionClosed?.(key)
139-
fetchSessions()
135+
await fetchSessions()
136+
onSessionClosed?.(sessionKey(session))
140137
} catch (err) {
141138
console.error('Close session error:', err)
142-
setSessions(snapshot)
143139
setActionError(`Close failed: ${err?.toString() || err}`)
144140
}
145141
}

internal/agent/manager.go

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ type Manager struct {
5656
replayMu sync.Mutex
5757
replays map[string]*sessionReplay
5858
loadedSessions map[string]bool
59-
closedSessions map[string]struct{}
6059
}
6160

6261
type sessionReplay struct {
@@ -76,7 +75,6 @@ func New(ctx context.Context, loadConfig agentclient.ConfigLoader, emit EventEmi
7675
emit: emit,
7776
replays: make(map[string]*sessionReplay),
7877
loadedSessions: make(map[string]bool),
79-
closedSessions: make(map[string]struct{}),
8078
}
8179
}
8280

@@ -411,9 +409,6 @@ func (m *Manager) NewSession(cwd string) (*Session, error) {
411409
sessionID := string(resp.SessionID)
412410
conversationID := m.scopedSessionID(sessionID)
413411
log.Printf("[agent] NewSession created: id=%q", sessionID)
414-
m.mu.Lock()
415-
delete(m.closedSessions, conversationID)
416-
m.mu.Unlock()
417412
session := &Session{
418413
ID: sessionID,
419414
Key: conversationID,
@@ -497,9 +492,6 @@ func (m *Manager) ListSessions() ([]Session, error) {
497492
for _, s := range resp.Sessions {
498493
session := Session{ID: string(s.SessionID), Cwd: s.Cwd}
499494
session.Key = m.scopedSessionID(session.ID)
500-
if m.IsSessionClosed(session.Key) {
501-
continue
502-
}
503495
session.AgentID = m.currentAgentID()
504496
session.AgentName = m.currentAgentID()
505497
if s.Title != nil {
@@ -530,28 +522,9 @@ func (m *Manager) CloseSession(sessionID string) error {
530522
if err != nil {
531523
return err
532524
}
533-
conversationID, acpSessionID := m.splitSessionRef(sessionID)
534-
log.Printf("[agent] CloseSession: id=%q acp=%q", conversationID, acpSessionID)
525+
_, acpSessionID := m.splitSessionRef(sessionID)
535526
_, err = client.CloseSession(&acp.CloseSessionRequest{SessionID: acp.SessionID(acpSessionID)})
536-
if err != nil {
537-
log.Printf("[agent] CloseSession failed: %v", err)
538-
return err
539-
}
540-
m.mu.Lock()
541-
m.closedSessions[conversationID] = struct{}{}
542-
delete(m.loadedSessions, conversationID)
543-
m.mu.Unlock()
544-
return nil
545-
}
546-
547-
func (m *Manager) IsSessionClosed(sessionID string) bool {
548-
if m == nil {
549-
return false
550-
}
551-
m.mu.Lock()
552-
defer m.mu.Unlock()
553-
_, closed := m.closedSessions[sessionID]
554-
return closed
527+
return err
555528
}
556529

557530
func (m *Manager) DeleteSession(sessionID string) error {

internal/agent/manager_test.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,6 @@ func TestConnectEndpointRejectsIDsThatBreakSessionKeys(t *testing.T) {
2828
}
2929
}
3030

31-
func TestClosedSessionStateIsScopedAndInMemory(t *testing.T) {
32-
manager := New(context.Background(), nil, nil)
33-
manager.closedSessions["opencode:session-1"] = struct{}{}
34-
35-
if !manager.IsSessionClosed("opencode:session-1") {
36-
t.Fatal("IsSessionClosed returned false for a closed session")
37-
}
38-
if manager.IsSessionClosed("builtin:session-1") {
39-
t.Fatal("IsSessionClosed mixed sessions from different agents")
40-
}
41-
if New(context.Background(), nil, nil).IsSessionClosed("opencode:session-1") {
42-
t.Fatal("closed session state persisted into a new manager")
43-
}
44-
}
45-
4631
func TestStoreForUpdateUsesReplayStoreAndBatchesProgress(t *testing.T) {
4732
manager := New(context.Background(), nil, nil)
4833
replayStore := conversation.NewStore()

0 commit comments

Comments
 (0)