Skip to content

fix: make thread view --unread filter correctly across all output modes - #86

Merged
scottlovegrove merged 2 commits into
mainfrom
scottl/thread-view
Mar 15, 2026
Merged

fix: make thread view --unread filter correctly across all output modes#86
scottlovegrove merged 2 commits into
mainfrom
scottl/thread-view

Conversation

@scottlovegrove

Copy link
Copy Markdown
Collaborator

Summary

  • JSON/NDJSON now respect --unread: Previously the structured output paths returned early before unread filtering was applied, so --unread --json returned all comments unfiltered
  • Original post shown when no unread comments: Previously --unread with no unread data just printed "No unread comments in this thread." and exited; now the thread title, channel, and original post are displayed for context before the message
  • Added 6 regression tests covering --unread across human-readable, JSON, and NDJSON output modes

Closes #75

Test plan

  • npm run type-check passes
  • npm test passes (268 tests, 6 new)
  • tw thread view <url> --unread shows original post + "No unread comments."
  • tw thread view <url> --unread --json returns thread with empty comments array
  • tw thread view <url> --json (without --unread) still returns all comments

🤖 Generated with Claude Code

…t modes

The --unread flag had two bugs: JSON/NDJSON output ignored the flag entirely
(returning all comments), and when no unread comments existed the command
exited without showing the original post. Move unread filtering before the
output branches so it applies uniformly, and always display the original
post for context when --unread is set.

Closes #75

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@doistbot
doistbot requested a review from craigcarlyle March 15, 2026 12:32
@scottlovegrove scottlovegrove self-assigned this Mar 15, 2026
@scottlovegrove scottlovegrove added the 👀 Show PR PR must be reviewed before or after merging label Mar 15, 2026

@doistbot-app doistbot-app Bot 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.

This PR improves the consistency of the --unread filter across all output modes and ensures the original post is always displayed for context even when no new comments are present. These changes provide a much more reliable experience for users working with structured data while maintaining helpful context in the CLI. Some efficiency gains could be achieved by limiting user lookups to only those users appearing in the filtered comment set, and the test isolation could be further strengthened to prevent state leaking between test blocks.

Share FeedbackReview Logs

Comment thread src/commands/thread/view.ts
Comment thread src/__tests__/thread.test.ts Outdated
…tion

Build user ID set from displayComments/contextComments instead of all
comments, avoiding unnecessary batch calls when --unread filters most
comments out. Use vi.resetAllMocks() in unread test block for proper
mock isolation between describe blocks.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@scottlovegrove
scottlovegrove merged commit 92478c9 into main Mar 15, 2026
2 checks passed
@scottlovegrove
scottlovegrove deleted the scottl/thread-view branch March 15, 2026 12:47
github-actions Bot pushed a commit that referenced this pull request Mar 15, 2026
## [2.14.1](v2.14.0...v2.14.1) (2026-03-15)

### Bug Fixes

* make thread view --unread filter correctly across all output modes ([#86](#86)) ([92478c9](92478c9))
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 2.14.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

released 👀 Show PR PR must be reviewed before or after merging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tw thread view XXX --unread doesn't work

1 participant