Skip to content

fix(messages): remove text truncation from thread command#134

Merged
rianjs merged 1 commit intomainfrom
fix/128-thread-text-truncation
Mar 28, 2026
Merged

fix(messages): remove text truncation from thread command#134
rianjs merged 1 commit intomainfrom
fix/128-thread-text-truncation

Conversation

@rianjs
Copy link
Copy Markdown
Collaborator

@rianjs rianjs commented Mar 28, 2026

Summary

  • Thread command was hard-truncating messages at 80 characters in text output, forcing users to use --output json to read full content
  • Added flatten() helper (newlines→spaces, no truncation) for detail views; thread uses it instead of truncate()
  • History command retains 80-char truncation (appropriate for list view)

Closes #128

Test plan

  • TestFlatten — 6 cases covering empty, short, long, and multiline strings
  • Existing TestTruncate still passes (history unaffected)
  • make lint clean

The thread command hard-truncated messages at 80 characters in text output,
making it impossible to read full message content without switching to JSON.

Thread is a detail view for reading conversations, so it should display full
content. History (list view) retains truncation.

Adds flatten() helper that replaces newlines with spaces without truncating.

Closes #128
@rianjs
Copy link
Copy Markdown
Collaborator Author

rianjs commented Mar 28, 2026

TDD Assessment

What changed

  • New flatten() function: replaces newlines with spaces, no truncation.
  • runThread text output path switched from truncate(text, 80) to flatten(text).

flatten() unit tests — adequate

TestFlatten covers the cases that matter:

  • No newlines (passthrough)
  • Single newline
  • Multiple newlines
  • Empty string
  • Long string preserved (the key behavioral difference from truncate)
  • Long string with newlines preserved

No gaps here. The only minor omission is a \r\n (Windows-style) input case, but Slack's API does not produce \r\n in message text, so this is not worth adding.


Integration-level test for runThread text output — gap exists

TestRunThread_Success exercises the text output path but does not assert on what was printed. It only asserts require.NoError. This means:

  • A regression that silently truncates output again (e.g. accidentally reverting to truncate) would not be caught by any test.
  • A message with embedded newlines going through flatten is never verified end-to-end.

The JSON path already has output-capture tests (TestRunThread_JSONIncludesReactions, TestRunThread_JSONIncludesFiles). The text path has no equivalent.

Suggested addition (not blocking, but worth a follow-up issue):

func TestRunThread_TextOutput_MultilineMessage(t *testing.T) {
    server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
        switch r.URL.Path {
        case "/conversations.replies":
            _ = json.NewEncoder(w).Encode(map[string]interface{}{
                "ok": true,
                "messages": []map[string]interface{}{
                    {"ts": "1234567890.123456", "user": "U001", "text": "Line one\nLine two\nLine three that is quite long and should not be truncated"},
                },
            })
        case "/users.info":
            mockUserInfoHandler(w, r)
        }
    }))
    defer server.Close()

    c := client.NewWithConfig(server.URL, "test-token", nil)
    opts := &threadOptions{limit: 100}

    var buf strings.Builder
    output.Writer = &buf
    defer func() { output.Writer = os.Stdout }()

    err := runThread("C123", "1234567890.123456", opts, c)
    require.NoError(t, err)

    got := buf.String()
    assert.Contains(t, got, "Line one Line two Line three that is quite long and should not be truncated")
    assert.NotContains(t, got, "...", "thread text should not be truncated")
}

Summary

Area Verdict
flatten() unit tests Adequate — all meaningful cases covered
runThread text output assertions Gap — no assertion that flatten is actually applied or that long/multiline content survives
runThread JSON path Adequate — output captured and asserted

The flatten() function itself is correct and well-tested. The one actionable gap is the lack of output assertions in TestRunThread_Success for the text path.

Copy link
Copy Markdown

@monit-reviewer monit-reviewer left a comment

Choose a reason for hiding this comment

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

Automated PR Review

Reviewed commit: 0c6ee08

Summary

No issues found. (1 info-level observations excluded)


Completed in 2m 26s | $0.37
Field Value
Reviewers hybrid-synthesis, database:sql-reviewer, security:code-auditor, harness-engineering:knowledge-reviewer, harness-engineering:enforcement-reviewer, harness-engineering:architecture-reviewer, harness-engineering:legibility-reviewer
Reviewed by pr-review-daemon · monit-pr-reviewer
Duration 2m 26s (Reviewers: 45s · Synthesis: 24s)
Cost $0.37
Tokens 115.8k in / 11.2k out
Turns 13

@rianjs rianjs merged commit 7be1eac into main Mar 28, 2026
2 checks passed
@rianjs rianjs deleted the fix/128-thread-text-truncation branch March 28, 2026 19:15
rianjs added a commit that referenced this pull request Mar 28, 2026
- README: add canvas command section, --since flag on thread, canvas alias
- CHANGELOG: add entries for canvas, --since, edited metadata, truncation fix
- integration-tests: add canvas tests (Part 10), thread --since and
  [edited] indicator verification to existing sections
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.

fix: text output truncates long messages in thread command

2 participants