Show similar earlier incidents and let notes be marked as the fix
The incident view gets a "Seen before" section from the server's new /similar endpoint; an older server without it just shows nothing. C adds a note as the resolution note, alongside c for a plain note. Needs the server release that adds /similar. Claude-Session: https://claude.ai/code/session_01MMados3BD1oSjevHxbmVqU
This commit is contained in:
+11
-5
@@ -146,6 +146,7 @@ type clearStatusMsg struct{}
|
||||
type incidentDetailFetchedMsg struct {
|
||||
incident api.Incident
|
||||
timeline []api.IncidentEvent
|
||||
similar []api.SimilarIncident
|
||||
}
|
||||
type alertDetailFetchedMsg struct{ alert api.Alert }
|
||||
type detailErrMsg struct{ err error }
|
||||
@@ -253,7 +254,9 @@ type Model struct {
|
||||
// Incident detail
|
||||
selectedIncident api.Incident
|
||||
timeline []api.IncidentEvent
|
||||
similar []api.SimilarIncident
|
||||
noteCursor int
|
||||
notePinned bool // the note being typed is the resolution note
|
||||
detailLoading bool
|
||||
detailViewport viewport.Model
|
||||
|
||||
@@ -614,7 +617,7 @@ func (m *Model) refreshDetailContent() {
|
||||
return
|
||||
}
|
||||
m.detailViewport.SetContent(
|
||||
buildIncidentDetailContent(m.styles, m.selectedIncident, m.timeline, m.noteCursor, m.width))
|
||||
buildIncidentDetailContent(m.styles, m.selectedIncident, m.timeline, m.similar, m.noteCursor, m.width))
|
||||
}
|
||||
|
||||
func (m *Model) refreshStatsContent() {
|
||||
@@ -746,7 +749,7 @@ func userFlags(u api.User) string {
|
||||
func noteEvents(timeline []api.IncidentEvent) []api.IncidentEvent {
|
||||
notes := make([]api.IncidentEvent, 0, len(timeline))
|
||||
for _, e := range timeline {
|
||||
if e.Type == api.EventNote {
|
||||
if e.Type == api.EventNote || e.Type == api.EventResolutionNote {
|
||||
notes = append(notes, e)
|
||||
}
|
||||
}
|
||||
@@ -1131,7 +1134,10 @@ func incidentDetail(client *api.Client, id int64) tea.Msg {
|
||||
if err != nil {
|
||||
return detailErrMsg{err}
|
||||
}
|
||||
return incidentDetailFetchedMsg{incident: *incident, timeline: timeline}
|
||||
// Best effort: an older server has no such endpoint, and the incident is
|
||||
// still worth showing without it.
|
||||
similar, _ := client.GetSimilarIncidents(id)
|
||||
return incidentDetailFetchedMsg{incident: *incident, timeline: timeline, similar: similar}
|
||||
}
|
||||
|
||||
func fetchIncidentDetailCmd(client *api.Client, id int64) tea.Cmd {
|
||||
@@ -1185,9 +1191,9 @@ func unsnoozeIncidentCmd(client *api.Client, id int64) tea.Cmd {
|
||||
return incidentActionCmd(client, id, func() error { return client.UnsnoozeIncident(id) })
|
||||
}
|
||||
|
||||
func addNoteCmd(client *api.Client, id int64, content string) tea.Cmd {
|
||||
func addNoteCmd(client *api.Client, id int64, content string, pinned bool) tea.Cmd {
|
||||
return incidentActionCmd(client, id, func() error {
|
||||
_, err := client.AddNote(id, content)
|
||||
_, err := client.AddNote(id, content, pinned)
|
||||
return err
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user