Skip to content

Commit fd3351f

Browse files
maxbeizerCopilot
andcommitted
Fix dismiss from detail view dismissing wrong session
When entering detail view from mission's Attention panel, the tasklist cursor doesn't change. So DismissSelected() was dismissing whatever the tasklist cursor pointed at, not the session displayed in the detail view. Now the detail view dismiss reads the session from taskDetail.Session() and dismisses it by ID, ensuring the correct session is removed regardless of how the detail view was entered. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent dfb1c13 commit fd3351f

3 files changed

Lines changed: 18 additions & 4 deletions

File tree

internal/tui/components/taskdetail/taskdetail.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ func (m *Model) SetTask(session *data.Session) {
112112
m.session = session
113113
}
114114

115+
// Session returns the currently displayed session, or nil.
116+
func (m *Model) Session() *data.Session {
117+
return m.session
118+
}
119+
115120
// SetAllSessions updates the full session list for dependency graph rendering.
116121
func (m *Model) SetAllSessions(sessions []data.Session) {
117122
m.allSessions = sessions

internal/tui/components/tasklist/tasklist.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,14 +390,19 @@ func (m *Model) DismissSelected() {
390390
if selected == nil || selected.ID == "" {
391391
return
392392
}
393-
m.dismissedIDs[selected.ID] = struct{}{}
393+
m.DismissByID(selected.ID)
394+
}
395+
396+
// DismissByID removes a session by ID from the view and marks it dismissed.
397+
func (m *Model) DismissByID(id string) {
398+
m.dismissedIDs[id] = struct{}{}
394399
if m.dismissedStore != nil {
395-
m.dismissedStore.Add(selected.ID)
400+
m.dismissedStore.Add(id)
396401
}
397402
// Remove from current sessions
398403
newSessions := make([]data.Session, 0, len(m.sessions)-1)
399404
for _, s := range m.sessions {
400-
if s.ID != selected.ID {
405+
if s.ID != id {
401406
newSessions = append(newSessions, s)
402407
}
403408
}

internal/tui/keyhandlers.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,11 @@ func (m Model) handleDetailKeys(msg tea.KeyPressMsg) (tea.Model, tea.Cmd) {
325325
m.toast.Push("ℹ️", "Git Activity", "only available for local sessions with a working directory")
326326
}
327327
case "x":
328-
m.taskList.DismissSelected()
328+
session := m.taskDetail.Session()
329+
if session != nil && session.ID != "" && m.dismissedStore != nil {
330+
m.dismissedStore.Add(session.ID)
331+
m.taskList.DismissByID(session.ID)
332+
}
329333
m.lastFingerprint = "" // force recompute
330334
m.lastSplitTaskID = ""
331335
m.recomputeAndDisplay(m.visibleSessions())

0 commit comments

Comments
 (0)