Keep a contact note's formatting when the TUI edits it - #504
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approved
The implementation is consistent with existing rich-text and terminal-safety mechanisms and has focused regression coverage.
Review effort: Balanced
Findings: None
What changed in this PR
Preserves contact-note formatting during TUI display, editing, and saving.
Changes:
- Converts HEY note HTML to safe Markdown and saves edits as HTML.
- Renders formatted notes in contact details.
- Adds regression tests and updates TUI documentation.
[!TIP]
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or rungh pr ready --undo.
Click "Ready for review" or rungh pr readyto reengage.
| File | Description |
|---|---|
internal/tui/contacts.go |
Adds Markdown-based note handling and rendering. |
internal/tui/contacts_test.go |
Tests formatting preservation, rendering, safety, and fallbacks. |
docs/tui.md |
Documents Markdown note editing. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
The TUI's note editor was handed HEY's plain `note`, which to_plain_text has flattened: bold is gone and a list item is a "•". Saving sent that text back as the whole note, so editing a note written in HEY's web app, even without changing a word, stripped its bold, lists and links. The editor now works the way `hey contact note set` does: it edits the note's rich text as Markdown, read from `note_html` by htmlutil.ToMarkdown, and saves it as HTML through htmlutil.FromMarkdown. The detail view renders that Markdown with markdown.Render, as the journal and thread bodies do, rather than printing the plain text. Both go through the sealed Markdown type, so the note is stripped of escape sequences before it is shown or edited; the editor used to be handed the plain note raw. A note containing an attachment or other markup Markdown cannot preserve is still shown, but the TUI now refuses to open it in the Markdown editor. That keeps the TUI in line with the CLI's lossless guard and prevents an unchanged save from discarding unsupported content.
robzolkos
force-pushed
the
tui-note-keeps-formatting
branch
from
September 27, 2026 03:04
156583d to
fd84490
Compare
Copilot
AI
dismissed their stale review, a newer Copilot review was requested
September 27, 2026 03:14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


The TUI's contact note editor was handed HEY's plain
note—to_plain_text, where bold is dropped and a list item becomes "•" — and saved that text back as the whole note. Editing a note written in HEY's web app, even without changing a word, stripped its bold, lists and links.The editor now works the way
hey contact note setalready does:note_htmlbyhtmlutil.ToMarkdown(which ignores thetrix-contentwrapper), incontactNoteMarkdown.htmlutil.FromMarkdown, so bold, italics, lists, links, headings and line breaks round-trip.markdown.Render, as the journal and thread bodies are, rather than as plain text. That is the samehtmlutil.Markdownvalue the editor uses, so the view and the editor agree, and it costs one call.--note-htmlfor editing.Terminal safety: the note is now an
htmlutil.Markdownfrom end to end, so escape sequences are stripped before it is shown or edited. The editor used to be handed the plain note raw, escape sequences included.TestSinksAreSanitizedstill passes.A note HEY serves as plain text only (it serves both or neither) is HTML-escaped first, so its characters stay literal and are saved back as the same text.
An unchanged save still writes, as before; the difference is that what it writes is now the note's own formatting.
After rebasing onto #500, the TUI uses the same
MarkdownIsLosslessguard ashey contact note set, so the CLI and TUI make the same preservation decision.Tests in
internal/tui/contacts_test.go, with a real HEYnote_htmlshape:TestContactsViewNoteEditorKeepsFormattingWrittenInHEY: an unchanged save keeps<strong>and the list. Fails on main.TestContactsViewNoteEditorAddsToAFormattedNote: adding a list item keeps the existing formatting, and the detail view renders the result. Fails on main.TestContactsViewNoteStripsEscapeSequences: the detail strips escape sequences and the editor refuses the now-lossy rewrite. Fails on main, where the editor held the sequences raw.TestContactsViewRefusesToEditANoteMarkdownCannotPreserve: a note containing a table remains readable but cannot be opened in the Markdown editor or written.TestContactsViewShowsANoteRenderedFromItsFormatting,TestContactsViewEmptyNoteCannotBeSaved,TestContactNoteMarkdownKeepsPlainTextLiteral: rendering, the empty note, and the plain-text fallback.docs/tui.mdnow says the note is edited as Markdown and keeps HEY's formatting.Summary by cubic
The TUI's contact note editor now keeps a note's formatting when you edit it. It previously edited HEY's plain-text note, so an unchanged save stripped bold, lists, and links. The editor now reads the note's
note_htmlas Markdown, edits and saves it as Markdown HTML (likehey contact note setdoes), and renders the contact detail view from that same Markdown.Notes are now stripped of escape sequences before being shown or edited; previously the editor held the raw plain note. A note HEY serves only as plain text is HTML-escaped first, keeping its characters literal. A note carrying formatting Markdown can't preserve — like a table or attachment — is shown but the editor refuses to open it, pointing to
hey contact note set --note-html, so an unchanged save can't discard that content. An empty note still can't be saved.Written for commit fd84490. Summary will update on new commits.