Skip to content

fix(messages): surface edited message metadata and text#136

Merged
rianjs merged 1 commit intomainfrom
fix/117-edited-message-text
Mar 28, 2026
Merged

fix(messages): surface edited message metadata and text#136
rianjs merged 1 commit intomainfrom
fix/117-edited-message-text

Conversation

@rianjs
Copy link
Copy Markdown
Collaborator

@rianjs rianjs commented Mar 28, 2026

Summary

  • Added Edited struct (user + ts) to Message type — previously silently dropped during JSON unmarshal
  • Thread and history text output now shows [edited] indicator for modified messages
  • JSON output includes the full edited metadata object

Closes #117

Test plan

  • TestClient_GetThreadReplies_WithEdited — verifies edited metadata is deserialized correctly
  • Verifies unedited messages have nil Edited field
  • All existing tests passing
  • make lint clean

The Message struct was missing the `edited` field, so Slack's edit metadata
was silently dropped during JSON unmarshaling. The `text` field already
contains the latest content from the API, but without the `edited` field
there was no way to tell if a message had been modified.

Adds Edited struct with user/ts fields to Message. Thread and history
text output now shows [edited] indicator for modified messages. JSON output
includes the full edited metadata.

Closes #117
@rianjs
Copy link
Copy Markdown
Collaborator Author

rianjs commented Mar 28, 2026

TDD Assessment

What's covered

The Edited struct and its wire-format deserialization are adequately tested in internal/client/client_test.go (TestClient_GetThreadReplies_WithEdited):

  • edited message correctly populates Edited.User and Edited.TS
  • unedited message correctly leaves Edited as nil
  • the omitempty tag on Edited is exercised implicitly

Gaps

No command-level tests for the [edited] text indicator.

Both history.go and thread.go got the same [edited] rendering logic, but messages_test.go has zero coverage of it. The existing TestRunHistory_Success and TestRunThread_Success tests only assert require.NoError — they don't capture or inspect output.Printf output at all. There are no new tests that:

  1. Verify [edited] appears in text output when Edited != nil (for either runHistory or runThread)
  2. Verify [edited] is absent when Edited == nil
  3. Verify the Edited field is present in JSON output for runHistory — the TestRunHistory_JSONIncludesReactions pattern is the right model but was not replicated for the edited case

Precedent exists for this style of test. TestRunThread_JSONIncludesReactions and TestRunThread_JSONIncludesFiles both capture JSON output and assert on field values. TestRunHistory_JSONIncludesReactions does the same. That same pattern should cover Edited in JSON output and should be mirrored by a text-output test that checks the captured buffer for the literal [edited] string.

JSON serialization

The Edited struct uses json:"user" and json:"ts" (no omitempty). This means a zero-value Edited{} would serialize as {"user":"","ts":""} rather than being omitted. However, because the field on Message is a pointer with omitempty, a nil pointer is omitted correctly. The only risk is if an upstream response sends "edited": {} — the struct would be non-nil but with empty strings. This edge case is untested and low-priority, but worth noting.

Verdict

Client-layer deserialization is well tested. The command-layer rendering of [edited] in both text and JSON output has no test coverage. Two tests should be added following the existing TestRunHistory_JSONIncludesReactions / TestRunThread_JSONIncludesReactions pattern — one for each command — covering both the presence and absence of [edited].

@rianjs rianjs merged commit 19d7a03 into main Mar 28, 2026
2 checks passed
@rianjs rianjs deleted the fix/117-edited-message-text branch March 28, 2026 19:25
rianjs added a commit that referenced this pull request Mar 28, 2026
…138)

## Summary
- **README**: Added canvas command section, `--since` flag on thread,
canvas alias in aliases table
- **CHANGELOG**: Added entries for canvas (#137), `--since` (#135),
edited metadata (#136), truncation fix (#134)
- **integration-tests.md**: Added Part 10 (Canvas Tests), enhanced Part
3.4 with `--since` and full-text verification, enhanced Part 3.5 with
`[edited]` indicator checks

## Test plan
- [x] Docs-only change, no code modified
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.

messages thread returns original text instead of edited/updated text

1 participant