Skip to content

Commit ce2891b

Browse files
maxbeizerCopilot
andcommitted
Fix panic and stale mission view on detail dismiss
Two bugs: 1. DismissByID panicked with 'makeslice: cap out of range' when the session wasn't in the tasklist (empty list → cap of -1). Fixed by using len(m.sessions) as capacity instead of len-1. 2. Mission view wasn't updated after dismiss because viewMode was set to ViewModeMission *after* recomputeAndDisplay ran. Since recompute only pushes data to the active view, mission never got the updated session list. Fixed by setting viewMode before recompute. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent fd3351f commit ce2891b

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

internal/tui/components/tasklist/tasklist.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ func (m *Model) DismissByID(id string) {
400400
m.dismissedStore.Add(id)
401401
}
402402
// Remove from current sessions
403-
newSessions := make([]data.Session, 0, len(m.sessions)-1)
403+
newSessions := make([]data.Session, 0, len(m.sessions))
404404
for _, s := range m.sessions {
405405
if s.ID != id {
406406
newSessions = append(newSessions, s)

internal/tui/keyhandlers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,8 @@ func (m Model) handleDetailKeys(msg tea.KeyPressMsg) (tea.Model, tea.Cmd) {
332332
}
333333
m.lastFingerprint = "" // force recompute
334334
m.lastSplitTaskID = ""
335-
m.recomputeAndDisplay(m.visibleSessions())
336335
m.viewMode = ViewModeMission
336+
m.recomputeAndDisplay(m.visibleSessions())
337337
m.mission.SetSize(m.ctx.Width, m.ctx.Height-6)
338338
}
339339
return m, nil

0 commit comments

Comments
 (0)