Skip to content

Read, edit, and save incident write-ups in the dashboard - #286

Merged
coryodaniel merged 8 commits into
dashboardfrom
dashboard-postmortem
Nov 30, 2026
Merged

coryodaniel merged 8 commits into
dashboardfrom
dashboard-postmortem

Conversation

@coryodaniel

Copy link
Copy Markdown
Member

Stacked on #285.

w opens the incident write-up inside the dashboard. Before, it wrote the files and showed a toast.

  • Read. The markdown renders with Glamour in the palette's colors, wrapped to the body. j/k, the arrows, pgup/pgdn and g/G scroll.
  • Edit. e opens the raw markdown in a text area, to fill in the root cause and follow-ups. esc goes back to the rendered view with your text.
  • Save. ctrl+s writes <name>.md and the <name>.json recording with 0600, and overwrites an earlier save of the same incident. Within the session, opening the incident again shows the last saved text, so a second save can't drop your root cause.
  • Close. q or esc. With unsaved edits, it asks "discard changes? y/n" first.
  • While the view is open, no other dashboard key acts, but the map keeps updating underneath. The key line shows each mode's keys.

github.com/atotto/clipboard joins go.sum as an indirect dependency of bubbles' textarea.

🤖 Generated with Claude Code

coryodaniel and others added 2 commits November 28, 2026 01:12
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	internal/commands/dashboard/model.go
@coryodaniel

Copy link
Copy Markdown
Member Author

@claude please review.

@claude

claude Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Claude finished @coryodaniel's task in 2m 15s —— View job


Review of #286: read, edit, and save incident write-ups

The change is well structured. The state machine is small, the logic stays in internal/commands/dashboard and not cmd/, the tests are table-driven, and the draft map is cloned before it is mutated. go test ./internal/commands/dashboard/ passes. I did not run make check or make docs.

  • Read the diff and postmortem.go
  • Run the dashboard package tests

Things worth a look

  1. The tutorial overlay still draws over the write-up. views.go hides the incident banner when m.post != nil, but the m.tutorial.on && m.graph != nil overlay is not gated the same way. handleKey sends keys to handlePostmortemKey ahead of handleTutorialKey. If the tutorial is on when w is pressed, the tutorial card could be drawn over the write-up while its keys are ignored. I could not tell whether the tutorial ever lets w through. If it does, gate the overlay on m.post == nil too, or check w isn't reachable during it.

  2. A reopened draft ignores a regenerated timeline. openPostmortem replaces the freshly generated markdown with the saved draft. If the incident has gained timeline entries since the save, they don't show up until the session ends. That matches the "last saved text" behavior in the PR description, so I read it as intentional. Consider saying so in the helpdoc, because a user may expect a clear alarm's timeline to be complete.

  3. n in the discard prompt returns to the rendered view. The key line says n keep editing, but handlePostmortemKey sets p.mode = postRead, so any key other than y lands in the preview. Either change the label to "keep" or return to postEdit when the discard was entered from an edit.

  4. ctrl+s in edit mode leaves the preview stale until esc. savePostmortem copies p.md = p.editor.Value() but does not re-render p.page. esc re-renders, so nothing is visibly wrong. Just note that p.md and the page content can differ while editing.

  5. WriteFile == nil now opens the view. Previously it returned quietly. Now the view opens and only ctrl+s reports "nowhere to save". That seems fine, but it is a behavior change. A test case for it would be cheap if one isn't already there.

  6. The tests cover the happy path well but skip a few edges.

    • A failed .md write after a successful .json write should leave saved unchanged so ● unsaved stays visible. The code appears to handle this.
    • Saving, then editing again, then receiving the async writtenMsg should leave the view dirty relative to msg.md.
    • Adding cases for these in the existing postmortem_test.go would pin the keepSaved behavior.

Smaller notes

  • case key == "ctrl+c": return m.closeLogs(), tea.Quit is odd in a write-up. If closeLogs is only there to match another handler, it can go.
  • renderMarkdown builds a new Glamour renderer on every resize, palette change and esc. That is fine at this document size.
  • The CLAUDE.md comment rule is followed. The generated field comment and the Glamour table-margin comment both explain why.
  • go.sum and go.mod carry only the atotto/clipboard indirect addition, as the description says. The docs/generated and docs/helpdocs edits are consistent with each other. Please confirm make docs shows no diff in CI.

Overall this looks good to merge once the tutorial overlay interaction (1) is checked. Items 3 and 6 are quick follow-ups.

@coryodaniel

Copy link
Copy Markdown
Member Author

Fixed in 4475ce5, with #285 merged in:

  • 1: the tutorial overlay and its footer draw only while no write-up is open. w can't open a write-up during the tour; tested.
  • 2: the discard prompt can only be reached from read mode, since q types in the editor, so read is right. The label now says "keep changes".
  • 3: ctrl+s in edit mode re-renders the preview too.
  • 5–6: tests cover a failed .md write after a good .json, a late save result after more typing, and no writer at all. The helpdoc says reopening shows the last saved text.

No change:

  • 4: closeLogs() stays on ctrl+c. Logs can be open behind the write-up (f, then w), and quitting has to stop that stream.

@claude please review.

@claude

claude Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Claude finished @coryodaniel's task in 1m 51s —— View job


Review of #286 (after 4475ce5)

I read postmortem.go and the views.go, model.go and writeup.go diffs against origin/dashboard-tutorial. go test ./internal/commands/dashboard/ passes. I did not run make check or make docs, so please confirm CI shows no docs diff.

Your fixes

  • Tutorial overlay and footer: both are now gated on m.post == nil in views.go. Good.
  • Discard prompt: q types in the editor, so the prompt is only reachable from read mode, and returning to read is correct. The "keep changes" label fits.
  • ctrl+s in edit mode: it now re-renders the preview. Good.
  • closeLogs() on ctrl+c: that makes sense given logs can be open behind the write-up.
  • Draft handling: keepSaved clones the map and dirty() compares against saved, so a late save result after more typing stays dirty.

One real issue

ctrl+v paste in the editor is silently dropped.

  • The textarea's paste binding is ctrl+v. It returns a command whose result is the unexported pasteMsg.
  • That message reaches Model.update, which has no case for it and falls through to return m, nil (model.go:446-491). Only tea.KeyMsg is forwarded to the editor, in handlePostmortemKey.
  • Pasting your root cause with ctrl+v therefore does nothing. Terminal bracketed paste arrives as a KeyMsg and does work.
  • Fix: in update, when m.post != nil && m.post.mode == postEdit, forward any message the switch doesn't claim to the editor. A default case that calls p.editor.Update(msg) is enough.
  • Add a test that sends the Paste message and checks the editor value.

Minor

  • p.md can lag the editor in edit mode, but dirty() already handles that.
  • renderMarkdown rebuilds a Glamour renderer on every resize and palette change. That is fine at this size.

I think this is good to merge once the paste case is fixed.

@coryodaniel

Copy link
Copy Markdown
Member Author

Fixed in c40e472, with #285 merged in: a message the dashboard doesn't recognize goes to the write-up editor while it's in edit mode, so a ctrl+v paste lands.

There's no test for it. The textarea's paste message is unexported, and pressing ctrl+v in a test reads the real system clipboard.

@claude please review.

@claude

claude Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Claude finished @coryodaniel's task in 1m 57s —— View job


Review of #286 (after c40e472)

c40e472 fixes the dropped ctrl+v paste. I read the two-file diff and the update switch in model.go. go test ./internal/commands/dashboard/ passes. I did not run make check or make docs. The last commit changes no commands, flags or helpdocs, so it shouldn't add a docs diff.

The fix

  • Default case: update now sends any message it doesn't recognize to passToEditor. Every typed case above it returns first, so only messages the dashboard doesn't handle reach the default.
  • Guard: passToEditor does nothing unless m.post != nil and the mode is postEdit. The textarea's pasteMsg, pasteErrMsg and any cursor messages are therefore ignored in read mode and when no write-up is open.
  • Copy: it copies the postmortem struct before updating and stores the copy back. That matches how handlePostmortemKey handles state, so the model's value semantics hold.
  • Test gap: I accept your reasoning. pasteMsg is unexported, and sending ctrl+v in a test reads the real clipboard. A cheap partial test is possible. It would send an arbitrary message type in edit mode and in read mode, then check that the model returns unchanged and doesn't panic. That would pin the guard, though not the paste itself. This is optional.

Nits

  • The comment on the default case explains why, which fits CLAUDE.md. It reads a little vague, though. Naming the paste case directly, as you do in the commit message, would help.
  • passToEditor sits at the end of postmortem.go, after lightColor. It's a model method, so it would fit better next to handlePostmortemKey. This is cosmetic.

No blocking issues. This looks good to merge once CI is green, including the docs-regeneration check.

Base automatically changed from dashboard-tutorial to dashboard November 30, 2026 06:12
@coryodaniel
coryodaniel merged commit 60f3cf4 into dashboard Nov 30, 2026
2 checks passed
@coryodaniel
coryodaniel deleted the dashboard-postmortem branch November 30, 2026 06:12
@coryodaniel

Copy link
Copy Markdown
Member Author

Folded into #272.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant