Skip to content

[fm] handle multi-line comment fields in FM displayers#10710

Merged
hawkw merged 5 commits into
mainfrom
eliza/multiline-comments
Jul 2, 2026
Merged

[fm] handle multi-line comment fields in FM displayers#10710
hawkw merged 5 commits into
mainfrom
eliza/multiline-comments

Conversation

@hawkw

@hawkw hawkw commented Jul 1, 2026

Copy link
Copy Markdown
Member

This branch changes the various multi-line fmt::Display implementations for fault management types in nexus_types::fm to handle comment fields that span multiple lines. I'd like to be able to put multi-line text in comment fields in #10593, and the present Display impls will wreck it, because subsequent lines won't be indented and will lack the leading // to show that it's part of a comment. This branch fixes that.

I originally made this change in #10593, but figured it was worth pulling out into its own little PR so that it could merge separately. I might make some additional changes to the display stuff, and didn't want to have giant merge conflicts later when #10593 merges.

@hawkw hawkw self-assigned this Jul 1, 2026
@hawkw hawkw added the fault-management Everything related to the fault-management initiative (RFD480 and others) label Jul 1, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the fault-management (nexus_types::fm) multi-line fmt::Display output to correctly render comment fields that contain multiple lines by emitting each line with consistent indentation and a leading //.

Changes:

  • Updated multiple FM Display implementations to render comment values line-by-line via comment.lines().
  • Standardized comment rendering in case display sections (ereports/alerts/bundles) to use //-prefixed lines.
  • Updated analysis report and log entry displayers to support multi-line comments.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
nexus/types/src/fm/case.rs Switches several case-related display sections to emit multi-line comments with // prefixes and consistent indentation.
nexus/types/src/fm/analysis_reports.rs Updates analysis-report and log-entry display formatting so multi-line comments render as multiple indented // lines.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 362 to +365
writeln!(f, "{BULLET:>indent$}ereport {}", ereport.id)?;
for line in comment.lines() {
writeln!(f, "{:>indent$}// {line}", "")?;
}
Comment on lines 418 to +421
writeln!(f, "{BULLET:>indent$}alert {id}",)?;
for line in comment.lines() {
writeln!(f, "{:>indent$}// {line}", "")?;
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks i changed this on purpose

Comment on lines 452 to +456
writeln!(f, "{BULLET:>indent$}bundle {id}",)?;

for line in comment.lines() {
writeln!(f, "{:>indent$}// {line}", "")?;
}
Comment on lines 362 to +365
writeln!(f, "{BULLET:>indent$}ereport {}", ereport.id)?;
for line in comment.lines() {
writeln!(f, "{:>indent$}// {line}", "")?;
}
Comment on lines 205 to +210
let colon = if kvs.is_empty() { "" } else { ":" };
writeln!(f, "{:indent$}{bullet}{event}{colon}", "")?;
if let Some(comment) = comment {
writeln!(f, "{:indent$} // {comment}", "")?;
for line in comment.lines() {
writeln!(f, "{:indent$} // {line}", "")?;
}
@@ -84,8 +84,8 @@ impl AnalysisReport {
indent,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pulling this into a new PR; appreciate it being decoupled

this_sitrep(*assigned_sitrep_id)
)?;
writeln!(f, "{:>indent$}{ASSIGNMENT_ID:<WIDTH$} {id}", "")?;
writeln!(f, "{:>indent$}{COMMENT:<WIDTH$} {comment}\n", "",)?;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... I think copilot was also saying something to this effect, but do we want to add a writeln!(f, "")? here?

We took out the \n that coincidentally used to be after the comment, so now all the CaseEreports will be smushed together

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they have bullet points, so i removed the newline since i felt like it was wasting vertical space. i can put it back if you feel strongly about it?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, nah, I didn't realize there was "some separator". Don't care that much

Comment thread nexus/types/src/fm/case.rs Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the const str COMMENT is only used here, but we aren't actually printing out the comment: string anywhere anymore. We could probably remove this?

)?;
writeln!(f, "{:>indent$}{DATA}", "")?;
writeln!(f, "{}", data_selection.display(indent + 2))?;
writeln!(f, "{:>indent$}{COMMENT:<WIDTH$} {comment}\n", "")?;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think copilot is weird with where it's choosing to insert commentary , but the \n that was removed was here. I think I agree; it's worth putting it back?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, i will return the newlines

@hawkw hawkw enabled auto-merge (squash) July 2, 2026 17:22
@hawkw hawkw merged commit a82a6fa into main Jul 2, 2026
19 checks passed
@hawkw hawkw deleted the eliza/multiline-comments branch July 2, 2026 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fault-management Everything related to the fault-management initiative (RFD480 and others)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants